Refactoring led handler, webserver and mqtt to all use a common BE status enum rather than relying on duplicatitng logic or using led color

This commit is contained in:
Matt Holmes 2025-08-21 17:33:15 +01:00
parent 980d914ffd
commit d4f0e188fe
5 changed files with 55 additions and 44 deletions

View file

@ -53,27 +53,25 @@ void LED::exe(void) {
}
// Set color
switch (get_event_level()) {
case EVENT_LEVEL_INFO:
switch (get_emulator_status()) {
case EMULATOR_STATUS::STATUS_OK:
color = led_color::GREEN;
pixels.setPixelColor(COLOR_GREEN(brightness)); // Green pulsing LED
break;
case EVENT_LEVEL_WARNING:
case EMULATOR_STATUS::STATUS_WARNING:
color = led_color::YELLOW;
pixels.setPixelColor(COLOR_YELLOW(brightness)); // Yellow pulsing LED
break;
case EVENT_LEVEL_DEBUG:
case EVENT_LEVEL_UPDATE:
color = led_color::BLUE;
pixels.setPixelColor(COLOR_BLUE(brightness)); // Blue pulsing LED
break;
case EVENT_LEVEL_ERROR:
case EMULATOR_STATUS::STATUS_ERROR:
color = led_color::RED;
pixels.setPixelColor(COLOR_RED(esp32hal->LED_MAX_BRIGHTNESS())); // Red LED full brightness
break;
default:
case EMULATOR_STATUS::STATUS_UPDATING:
color = led_color::BLUE;
pixels.setPixelColor(COLOR_BLUE(brightness)); // Blue pulsing LED
break;
}
pixels.show(); // This sends the updated pixel color to the hardware.
}