diff --git a/usermods/Tubes/Tubes.h b/usermods/Tubes/Tubes.h index 5c59f730eb..94aad9e8e3 100644 --- a/usermods/Tubes/Tubes.h +++ b/usermods/Tubes/Tubes.h @@ -20,6 +20,8 @@ #define MASTER_PIN 25 #define LEGACY_PIN 32 // DigUno Q4 +extern uint32_t savedStrip[]; + class TubesUsermod : public Usermod { private: @@ -90,6 +92,27 @@ class TubesUsermod : public Usermod { master.handleOverlayDraw(); } + #ifdef LED_MASK_OFFSET + uint16_t len = strip.getLengthTotal(); + uint16_t savedLen = std::min(len, static_cast(MAX_SAVED_LEDS)); + static_assert( LED_MASK_OFFSET < 0xffff, "LED_MASK_OFFSET set to large"); + uint16_t maskLength = std::min(len, static_cast(LED_MASK_OFFSET)); + // save existing strip + for (auto i = 0; i < savedLen; i++) { + savedStrip[i] = strip.getPixelColor(i); + } + // shift all colors to beginning of strip by mask length + uint16_t p = 0; + for (auto i = maskLength; i < len; i++) { + strip.setPixelColor(p++, strip.getPixelColor(i)); + } + // black out the remaining + for ( ; p < len; p++) { + strip.setPixelColor(p, CRGB::Black); + } + #endif + + // When AP mode is on, make sure it's obvious // Blink when there's a connected client if (apActive) { diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 8e35f00af7..337309beae 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -3,6 +3,7 @@ #include "wled_ethernet.h" #include #include "espnow_broadcast.h" +#include #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET) #include "soc/soc.h" @@ -40,6 +41,10 @@ void WLED::reset() ESP.restart(); } +#ifdef LED_MASK_OFFSET + uint32_t savedStrip[MAX_SAVED_LEDS] {0}; +#endif + void WLED::loop() { #ifdef WLED_DEBUG @@ -121,12 +126,21 @@ void WLED::loop() handlePresets(); yield(); - if (!offMode || strip.isOffRefreshRequired()) + if (!offMode || strip.isOffRefreshRequired()) { strip.service(); + #ifdef LED_MASK_OFFSET + // restore existing strip + uint16_t savedLen = std::min(strip.getLengthTotal(), static_cast(MAX_SAVED_LEDS)); + for (auto i = 0; i < savedLen; i++) { + strip.setPixelColor(i, savedStrip[i]); + } + #endif + #ifdef ESP8266 else if (!noWifiSleep) delay(1); //required to make sure ESP enters modem sleep (see #1184) #endif + } } #ifdef WLED_DEBUG stripMillis = millis() - stripMillis;