#include "leds.h"
#include <ezButton.h>
#define BUTTON_UP 35
#define BUTTON_DOWN 33
#define BUTTON_LEFT 34
#define BUTTON_RIGHT 32
#define BUTTON_SEL 25
// ezButton up(35);
// ezButton down(33);
// ezButton left(34);
// ezButton right(32);
// ezButton sel(25);
uint8_t ring = 0;
type enum {
START,
COLOR,
SHAPE,
WON
} State;
State state;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
leds_init();
// up.setDebounceTime(50);
// down.setDebounceTime(50);
// left.setDebounceTime(50);
// right.setDebounceTime(50);
// sel.setDebounceTime(50);
pinMode(BUTTON_UP, INPUT_PULLUP);
pinMode(BUTTON_DOWN, INPUT_PULLUP);
pinMode(BUTTON_LEFT, INPUT_PULLUP);
pinMode(BUTTON_RIGHT, INPUT_PULLUP);
pinMode(BUTTON_SEL, INPUT_PULLUP);
rings_show();
state = START;
}
void loop() {
if (digitalRead(BUTTON_UP) == LOW) {
Serial.printf("V++:%d\n", ring_increaseV(ring));
rings_show();
delay(100);
}
if (digitalRead(BUTTON_DOWN) == LOW) {
Serial.printf("V++:%d\n", ring_decreaseV(ring));
rings_show();
delay(100);
}
if (digitalRead(BUTTON_LEFT) == LOW) {
Serial.printf("H--:%d\n", ring_decreaseH(ring));
rings_show();
delay(100);
}
if (digitalRead(BUTTON_RIGHT) == LOW) {
Serial.printf("H++:%d\n", ring_increaseH(ring));
rings_show();
delay(100);
}
if (digitalRead(BUTTON_SEL) == LOW) {
ring = (ring + 1) % RINGS;
Serial.printf("Selected ring %d\n", ring);
ring_blink(ring, 200, 3);
delay(500);
}
}