Skip to content

Commit

Permalink
realtime mode bugfixes
Browse files Browse the repository at this point in the history
- busses: ignore not valid bus instances
- "use main segment only": prevent flickering du to intermitted strip.service().
  • Loading branch information
softhack007 committed Dec 20, 2024
1 parent fd2bce5 commit 02f51d4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ void WS2812FX::service() {
if(nowUp >= seg.next_time || _triggered || (doShow && seg.mode == FX_MODE_STATIC)) // WLEDMM ">=" instead of ">"
{
if (seg.grouping == 0) seg.grouping = 1; //sanity check
doShow = true;
if (!seg.freeze) doShow = true;
uint16_t frameDelay = FRAMETIME; // WLEDMM avoid name clash with "delay" function

if (!seg.freeze) { //only run effect function if not frozen
Expand Down
3 changes: 3 additions & 0 deletions wled00/bus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@ void IRAM_ATTR __attribute__((hot)) BusManager::setPixelColor(uint16_t pix, uint

for (uint_fast8_t i = 0; i < numBusses; i++) { // WLEDMM use fast native types
Bus* b = busses[i];
if (b->isValid() == false) continue; // WLEDMM ignore invalid (=not ready) busses
uint_fast16_t bstart = b->getStart();
if (pix < bstart || pix >= bstart + b->getLength()) continue;
else {
Expand Down Expand Up @@ -1346,6 +1347,7 @@ uint32_t IRAM_ATTR __attribute__((hot)) BusManager::getPixelColor(uint_fast16_t

for (uint_fast8_t i = 0; i < numBusses; i++) {
Bus* b = busses[i];
if (b->isValid() == false) continue; // WLEDMM ignore invalid (=not ready) busses
uint_fast16_t bstart = b->getStart();
if (pix < bstart || pix >= bstart + b->getLength()) continue;
else {
Expand All @@ -1369,6 +1371,7 @@ uint32_t IRAM_ATTR __attribute__((hot)) BusManager::getPixelColorRestored(uint_

for (uint_fast8_t i = 0; i < numBusses; i++) {
Bus* b = busses[i];
if (b->isValid() == false) continue; // WLEDMM ignore invalid (=not ready) busses
uint_fast16_t bstart = b->getStart();
if (pix < bstart || pix >= bstart + b->getLength()) continue;
else {
Expand Down
1 change: 1 addition & 0 deletions wled00/bus_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class Bus {
inline uint8_t getAutoWhiteMode() const { return _autoWhiteMode; }
inline static void setGlobalAWMode(uint8_t m) { if (m < 5) _gAWM = m; else _gAWM = AW_GLOBAL_DISABLED; }
inline static uint8_t getGlobalAWMode() { return _gAWM; }
inline bool isValid() const {return _valid;}

inline static uint32_t restore_Color_Lossy(uint32_t c, uint8_t restoreBri) { // shamelessly grabbed from upstream, who grabbed from NPB, who ..
if (restoreBri < 255) {
Expand Down
8 changes: 7 additions & 1 deletion wled00/udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,13 @@ void realtimeLock(uint32_t timeoutMs, byte md)
if (!realtimeMode && !realtimeOverride) {
// this code runs once when we enter realtime mode
// WLEDMM begin - we need to init segment caches before putting any pixels
USER_PRINT(F("realtimeLock() entering realtime mode [timeoutMs="));
USER_PRINT(timeoutMs); USER_PRINT(",mode="); USER_PRINT(md);
if (useMainSegmentOnly) USER_PRINTLN(F(", main segment only].")) else USER_PRINTLN(F("]."));
USER_FLUSH();

if (strip.isServicing()) {
USER_PRINTLN(F("realtimeLock() enter RTM: strip is still drawing effects."));
USER_PRINTLN(F("realtimeLock() entering RTM: strip is still drawing effects."));
strip.waitUntilIdle();
}
strip.service(); // WLEDMM make sure that all segments are properly initialized
Expand Down Expand Up @@ -211,6 +216,7 @@ void exitRealtime() {
strip.show(); // possible fix for #3589
}
busses.invalidateCache(false); // WLEDMM
USER_PRINTLN(F("exitRealtime() realtime mode ended."));
updateInterfaces(CALL_MODE_WS_SEND);
}

Expand Down

0 comments on commit 02f51d4

Please sign in to comment.