state tracking for LEDs

This commit is contained in:
Mitchell Marino 2025-03-28 00:58:51 -05:00 committed by Mitchell M
parent c359ecb544
commit a198ae4225

View File

@ -1,6 +1,7 @@
#include "leds.h" #include "leds.h"
#include "led_strip.h" #include "led_strip.h"
#include <esp_log.h> #include <esp_log.h>
#include "state_tracking.h"
static const char* TAG = "leds"; 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) { void led_set(uint32_t led, uint8_t r, uint8_t g, uint8_t b) {
led_strip_set_pixel(leds, led, r, g, 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) { 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() { void leds_flush() {
led_strip_refresh(leds); led_strip_refresh(leds);
if (is_state_tracking()) {
event_occured("LED_FLUSH", NULL);
}
} }
void leds_clear() void leds_clear() {
{
led_strip_clear(leds); led_strip_clear(leds);
if (is_state_tracking()) {
event_occured("LED_CLR", NULL);
}
} }