From d50dc1fa1cebdecdc0d5d1e36f72be12034db189 Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 20 Sep 2025 17:22:42 +0200 Subject: ok --- src/esp/halfcab/halfcab.ino | 77 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/src/esp/halfcab/halfcab.ino b/src/esp/halfcab/halfcab.ino index 5af220d..9dac98c 100644 --- a/src/esp/halfcab/halfcab.ino +++ b/src/esp/halfcab/halfcab.ino @@ -57,44 +57,83 @@ #define LED_TYPE WS2812B #define COLOR_ORDER GRB +enum colors_e { + R, + G, + B +}; + #define BLACK CRGB(0, 0, 0) #define RED CRGB(255, 0, 0) +#define GREEN CRGB(0, 255, 0) +#define BLUE CRGB(0, 0, 255) #define GRUV CRGB(255, 80, 0) CRGB leds[NUM_LEDS]; void -setup(void) +fill(CRGB color) { uint8_t i; - FastLED.addLeds(leds, NUM_LEDS); - FastLED.setBrightness(BRIGHTNESS); - FastLED.clear(); - FastLED.show(); i = 0; while (i < NUM_LEDS) { - leds[i] = GRUV; + leds[i] = color; i++; } FastLED.show(); - // delay(50); - // while (i < 255) { - // FastLED.setBrightness(i); - // FastLED.show(); - // delay(100); - // i += 10; - // } - // i = 0; - // while (i < NUM_LEDS) { - // leds[i] = BLACK; - // i++; - // } - // FastLED.show(); +} + +void +blink(void) +{ + fill(BLUE); + delay(100); + fill(BLACK); + delay(100); + fill(BLUE); + delay(100); + fill(BLACK); + delay(1000); +} + +void +plain(void) +{ +} + +void +setup(void) +{ + Serial.begin(115200); + + FastLED.addLeds(leds, NUM_LEDS); + FastLED.setBrightness(BRIGHTNESS); + fill(BLACK); } void loop(void) { + uint8_t i; + uint8_t com; + + blink(); + com = 0; + while (Serial.available() <= 0) { + /* empty */ + } + com = Serial.read(); + if (com == 0xff) { + plain(); + return; + } else { + i = 0; + while (i < NUM_LEDS) { + leds[i] = GREEN; + i++; + } + FastLED.show(); + } delay(10); } -- cgit v1.2.3