Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support defining an offset an making the X first LEDs for continuing… #56

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions usermods/Tubes/Tubes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#define MASTER_PIN 25
#define LEGACY_PIN 32 // DigUno Q4

extern uint32_t savedStrip[];


class TubesUsermod : public Usermod {
private:
Expand Down Expand Up @@ -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<uint16_t>(MAX_SAVED_LEDS));
static_assert( LED_MASK_OFFSET < 0xffff, "LED_MASK_OFFSET set to large");
uint16_t maskLength = std::min(len, static_cast<uint16_t>(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) {
Expand Down
16 changes: 15 additions & 1 deletion wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "wled_ethernet.h"
#include <Arduino.h>
#include "espnow_broadcast.h"
#include <algorithm>

#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET)
#include "soc/soc.h"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<uint16_t>(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;
Expand Down
Loading