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; }