From 3a25bad6eebf355e775281eb4ba424e4754c020d Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Mon, 16 Sep 2024 19:54:48 +0200 Subject: [PATCH] Update Leds handling and meaning --- v10/interface.c | 53 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/v10/interface.c b/v10/interface.c index d7806bc..1cf9ff7 100644 --- a/v10/interface.c +++ b/v10/interface.c @@ -281,18 +281,59 @@ void interface_update(char heat_mode) dprintf(5, 0, "Command: %d%%", command_val); dprintf(6, 0, "Mode: %c", heat_mode); dprintf(7, 0, MODULE_VERSION_STR " - " SOFT_VERSION_STR "." COMPILE_VERSION); - - /* Update RGB leds */ - /* FIXME : use for error signal */ - ws2812_set_pixel(&ws2812_leds, 0, (home_conso_value / 2000), (solar_prod_value / 2000), 0); - ws2812_set_pixel(&ws2812_leds, 1, 0, 0, command_val); - ws2812_send_frame(&ws2812_leds, 0); } else { /* Config mode. Mode entered by button action, which implies that interface board is present. */ interface_mode = config_interface_handle(); } /* Update Oled display */ ssd130x_display_full_screen(&display); + + if (1) { + static uint8_t blink = 0; /* For blinking leds */ + uint8_t red = 0, green = 0, blue = 0; + /* Update RGB leds */ + /* FIXME : use for error signal */ + if (blink != 0) { + ws2812_set_pixel(&ws2812_leds, 0, 0, 0, 0); + ws2812_set_pixel(&ws2812_leds, 1, 0, 0, 0); + blink = 0; + } else { + switch (heat_mode) { + case mode_water_critical: /* Both Leds to Full RED */ + if (blink == 0) { + ws2812_set_pixel(&ws2812_leds, 0, 255, 0, 0); + ws2812_set_pixel(&ws2812_leds, 1, 255, 0, 0); + blink = 1; + } + break; + case mode_overvoltage: /* First Led Red blinking */ + if (blink == 0) { + ws2812_set_pixel(&ws2812_leds, 0, 255, 0, 0); + blink = 1; + } + break; + case mode_overtemp: /* Second Led Red blinking */ + if (blink == 0) { + ws2812_set_pixel(&ws2812_leds, 1, 255, 0, 0); + blink = 1; + } + break; + default: + if (heat_mode == mode_manual) { /* -> Green */ + green = command_val; + } else if (heat_mode == mode_forced) { /* -> Yellow */ + green = command_val; + blue = command_val; + } else { /* -> Blue */ + blue = command_val; + } + ws2812_set_pixel(&ws2812_leds, 0, (home_conso_value / 2000), (solar_prod_value / 2000), 0); + ws2812_set_pixel(&ws2812_leds, 1, red, green, blue); + break; + } + } + ws2812_send_frame(&ws2812_leds, 0); + } } -- 2.43.0