From 2c0f3f1ef3fbbac264163ac47b5928a1397b3a9b Mon Sep 17 00:00:00 2001 From: Mitchell Marino Date: Fri, 28 Mar 2025 00:58:51 -0500 Subject: [PATCH] state tracking for LEDs --- main/drivers/leds.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/main/drivers/leds.cpp b/main/drivers/leds.cpp index cd8954c..bbad0de 100644 --- a/main/drivers/leds.cpp +++ b/main/drivers/leds.cpp @@ -1,6 +1,7 @@ #include "leds.h" #include "led_strip.h" #include +#include "state_tracking.h" static const char* TAG = "leds"; @@ -29,6 +30,13 @@ void init_leds() { void led_set(uint32_t led, uint8_t r, uint8_t g, uint8_t b) { led_strip_set_pixel(leds, led, r, g, b); + + if (is_state_tracking()) { + char buf[32]; + uint32_t color = (r << 16) | (g << 8) | b; + sprintf(buf, "%ld,%ld", led, color); + event_occured("LED_SET", buf); + } } void led_set(uint32_t led, uint32_t color) { @@ -37,9 +45,16 @@ void led_set(uint32_t led, uint32_t color) { void leds_flush() { led_strip_refresh(leds); + + if (is_state_tracking()) { + event_occured("LED_FLUSH", NULL); + } } -void leds_clear() -{ +void leds_clear() { led_strip_clear(leds); + + if (is_state_tracking()) { + event_occured("LED_CLR", NULL); + } }