From 278061bd7cd489e911c23bf72f4aaf05c5a6ef66 Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Sat, 3 Aug 2024 18:13:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Updates=20led=20service=20to=20s?= =?UTF-8?q?how=20isConnected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp | 6 +++--- esp32/lib/ESP32-sveltekit/LEDService.h | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp b/esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp index 45606a6..bb6bcf0 100644 --- a/esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp +++ b/esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp @@ -200,6 +200,9 @@ void ESP32SvelteKit::startServices() { void IRAM_ATTR ESP32SvelteKit::loop() { while (1) { +#if FT_ENABLED(FT_WS2812) + _ledService.loop(); +#endif _wifiSettingsService.loop(); _apSettingsService.loop(); #if FT_ENABLED(FT_ANALYTICS) @@ -207,9 +210,6 @@ void IRAM_ATTR ESP32SvelteKit::loop() { #endif #if FT_ENABLED(FT_BATTERY) _batteryService.loop(); -#endif -#if FT_ENABLED(FT_WS2812) - _ledService.loop(); #endif _peripherals.loop(); delay(20); diff --git a/esp32/lib/ESP32-sveltekit/LEDService.h b/esp32/lib/ESP32-sveltekit/LEDService.h index 4306f27..7f6383f 100644 --- a/esp32/lib/ESP32-sveltekit/LEDService.h +++ b/esp32/lib/ESP32-sveltekit/LEDService.h @@ -41,13 +41,17 @@ class LEDService { if (_brightness >= 200) direction = -5; if (_brightness <= 50) direction = 5; _brightness += direction; - fillFromPallette(0); + if (WiFi.isConnected()) { + fillFromPallette(OceanColors_p, 0); + } else { + fillFromPallette(ForestColors_p, 128); + } FastLED.show(); }); } - void fillFromPallette(uint8_t colorIndex) { - CRGB color = ColorFromPalette(currentPalette, colorIndex, _brightness, currentBlending); + void fillFromPallette(CRGBPalette16 colorPalette, uint8_t colorIndex) { + CRGB color = ColorFromPalette(colorPalette, colorIndex, _brightness, currentBlending); for (int i = 0; i < WS2812_NUM_LEDS; ++i) { leds[i] = color; }