From c8d264e4fb352c7d523070cd23d25f122386cfab Mon Sep 17 00:00:00 2001 From: Awawa <69086569+awawa-dev@users.noreply.github.com> Date: Wed, 19 Jul 2023 22:05:11 +0200 Subject: [PATCH] Option to clear LEDs during esp8266 startup (#31) --- platformio.ini | 3 ++- src/main.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 48ae652..e927868 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1,11 +1,12 @@ ; You can adjust speed of the serial port communication by adjusting 'SERIALCOM_SPEED' variable in [env] section +; Also you can force to clear LEDs on the esp8266 start up (-DCLEAR_LEDS=number_of_leds_to_clear) ; The pinout can not be changed for esp8266 board [platformio] default_envs = SK6812_RGBW_COLD, SK6812_RGBW_NEUTRAL, WS281x_RGB, SPI_APA102_SK9822_HD107, SPI_WS2801 [env] -build_flags = -DSERIALCOM_SPEED=2000000 +build_flags = -DSERIALCOM_SPEED=2000000 ;-DCLEAR_LEDS=24 ;remove leading semi-colon to uncomment extra_scripts = pre:extra_script.py platform = espressif8266 board = d1_mini diff --git a/src/main.cpp b/src/main.cpp index ee5657e..320711b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,6 +38,9 @@ #define _XSTR2(x,y) _STR(x) _STR(y) #define VAR_NAME_VALUE2(var) #var " = " _XSTR2(var) +#ifdef CLEAR_LEDS + #pragma message(VAR_NAME_VALUE(CLEAR_LEDS)) +#endif #ifdef NEOPIXEL_RGBW #pragma message(VAR_NAME_VALUE(NEOPIXEL_RGBW)) #endif @@ -77,6 +80,18 @@ void setup() Serial.begin(SERIALCOM_SPEED); while (!Serial) continue; +#ifdef CLEAR_LEDS + LED_DRIVER* _ledStrip = new LED_DRIVER(CLEAR_LEDS); + ColorDefinition _black(0); + _ledStrip->Begin(); + for(int i = 0; i < CLEAR_LEDS; i++) + _ledStrip->SetPixelColor(i, _black); + _ledStrip->Dirty(); + _ledStrip->Show(false); + delay(10); + delete _ledStrip; +#endif + // Display config Serial.println(HELLO_MESSAGE);