aboutsummaryrefslogtreecommitdiffstats
path: root/src/esp
diff options
context:
space:
mode:
authorjoe <rbo@gmx.us>2025-09-24 20:15:13 +0200
committerjoe <rbo@gmx.us>2025-09-24 20:15:13 +0200
commit79a12ba5dfde346c7ba33cb246ec6bde268e74c6 (patch)
tree304b73e073c5e7e806535b7d8b6c907bc042ee0a /src/esp
parentpausing that shit (diff)
downloadhalfcab-79a12ba5dfde346c7ba33cb246ec6bde268e74c6.tar.gz
halfcab-79a12ba5dfde346c7ba33cb246ec6bde268e74c6.tar.bz2
halfcab-79a12ba5dfde346c7ba33cb246ec6bde268e74c6.tar.xz
halfcab-79a12ba5dfde346c7ba33cb246ec6bde268e74c6.tar.zst
halfcab-79a12ba5dfde346c7ba33cb246ec6bde268e74c6.zip
ok
Diffstat (limited to '')
-rw-r--r--src/esp/halfcab/halfcab.ino53
1 files changed, 26 insertions, 27 deletions
diff --git a/src/esp/halfcab/halfcab.ino b/src/esp/halfcab/halfcab.ino
index 58621db..f99393e 100644
--- a/src/esp/halfcab/halfcab.ino
+++ b/src/esp/halfcab/halfcab.ino
@@ -55,6 +55,15 @@
CRGB leds[NUM_LEDS];
+byte
+read_byte()
+{
+ while (Serial.available() <= 0) {
+ /* empty */
+ }
+ return (Serial.read());
+}
+
void
fill(CRGB color)
{
@@ -106,29 +115,20 @@ plain(void)
fill(color);
}
-// void
-// dynamic(void)
-// {
-// uint8_t i;
-//
-// i = 0;
-// while (i < NUM_LEDS) {
-// while (Serial.available() <= 0) {
-// /* empty */
-// }
-// leds[i].r = Serial.read();
-// while (Serial.available() <= 0) {
-// /* empty */
-// }
-// leds[i].g = Serial.read();
-// while (Serial.available() <= 0) {
-// /* empty */
-// }
-// leds[i].b = Serial.read();
-// i++;
-// }
-// FastLED.show();
-// }
+void
+dynamic(void)
+{
+ uint8_t i;
+
+ i = 0;
+ while (i < NUM_LEDS) {
+ leds[i].r = read_byte();
+ leds[i].g = read_byte();
+ leds[i].b = read_byte();
+ i++;
+ }
+ FastLED.show();
+}
void
setup(void)
@@ -147,13 +147,12 @@ loop(void)
uint8_t com;
com = 0;
- while (Serial.available() <= 0) {
- /* empty */
- }
- com = Serial.read();
+ com = read_byte();
if (com == 0xff) {
plain();
return;
+ } else if (com == 0xfe) {
+ dynamic();
} else {
fill(BLUE);
}