From 0e53a1c4b91475dbf82ac2c76a97e5f8595c8803 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Sat, 22 Nov 2025 10:28:01 +0100 Subject: [PATCH 1/2] display gaps in peek and fix segment overflow bug --- wled00/FX_fcn.cpp | 2 +- wled00/ws.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index f2a474a486..2ace8e1206 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -458,7 +458,7 @@ void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, ui return; } if (i1 < Segment::maxWidth || (i1 >= Segment::maxWidth*Segment::maxHeight && i1 < strip.getLengthTotal())) start = i1; // Segment::maxWidth equals strip.getLengthTotal() for 1D - stop = i2 > Segment::maxWidth*Segment::maxHeight ? MIN(i2,strip.getLengthTotal()) : constrain(i2, 1, Segment::maxWidth); + stop = i2 > Segment::maxWidth*Segment::maxHeight && i1 >= Segment::maxWidth*Segment::maxHeight ? MIN(i2,strip.getLengthTotal()) : constrain(i2, 1, Segment::maxWidth); // check for 2D trailing strip startY = 0; stopY = 1; #ifndef WLED_DISABLE_2D diff --git a/wled00/ws.cpp b/wled00/ws.cpp index 6a02247203..bf897fb114 100644 --- a/wled00/ws.cpp +++ b/wled00/ws.cpp @@ -236,7 +236,9 @@ bool sendLiveLedsWs(uint32_t wsClient) #ifndef WLED_DISABLE_2D if (strip.isMatrix && n>1 && (i/Segment::maxWidth)%n) i += Segment::maxWidth * (n-1); #endif - uint32_t c = strip.getPixelColor(i); + uint32_t c = 0; + if (strip.getMappedPixelIndex(i) < 0xFFFF) // draw ledmap gaps gaps in black + c = strip.getPixelColor(i); uint8_t r = R(c); uint8_t g = G(c); uint8_t b = B(c); From 1d4d9f36e391bb89e88036de7c464a6144c517d9 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Sat, 22 Nov 2025 13:05:46 +0100 Subject: [PATCH 2/2] move mapping to gPc(), add function to read buffer without mapping --- wled00/FX.cpp | 2 +- wled00/FX.h | 3 ++- wled00/ws.cpp | 4 +--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 036e97a75c..d93c0df908 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -161,7 +161,7 @@ uint16_t mode_copy_segment(void) { } else { // 1D source, source can be expanded into 2D for (unsigned i = 0; i < SEGMENT.vLength(); i++) { if(SEGMENT.check2) { - sourcecolor = strip.getPixelColor(i + sourcesegment.start); // read from global buffer (reads the last rendered frame) + sourcecolor = strip.getPixelColorNoMap(i + sourcesegment.start); // read from global buffer (reads the last rendered frame) } else { sourcesegment.setDrawDimensions(); // set to source segment dimensions diff --git a/wled00/FX.h b/wled00/FX.h index 250df2646d..fbea92bf76 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -965,7 +965,8 @@ class WS2812FX { }; unsigned long now, timebase; - inline uint32_t getPixelColor(unsigned n) const { return (n < getLengthTotal()) ? _pixels[n] : 0; } // returns color of pixel n + inline uint32_t getPixelColor(unsigned n) const { return (getMappedPixelIndex(n) < getLengthTotal()) ? _pixels[n] : 0; } // returns color of pixel n, black if out of (mapped) bounds + inline uint32_t getPixelColorNoMap(unsigned n) const { return (n < getLengthTotal()) ? _pixels[n] : 0; } // ignores mapping table inline uint32_t getLastShow() const { return _lastShow; } // returns millis() timestamp of last strip.show() call const char *getModeData(unsigned id = 0) const { return (id && id < _modeCount) ? _modeData[id] : PSTR("Solid"); } diff --git a/wled00/ws.cpp b/wled00/ws.cpp index bf897fb114..18f51e4894 100644 --- a/wled00/ws.cpp +++ b/wled00/ws.cpp @@ -236,9 +236,7 @@ bool sendLiveLedsWs(uint32_t wsClient) #ifndef WLED_DISABLE_2D if (strip.isMatrix && n>1 && (i/Segment::maxWidth)%n) i += Segment::maxWidth * (n-1); #endif - uint32_t c = 0; - if (strip.getMappedPixelIndex(i) < 0xFFFF) // draw ledmap gaps gaps in black - c = strip.getPixelColor(i); + uint32_t c = strip.getPixelColor(i); // note: LEDs mapped outside of valid range are set to black uint8_t r = R(c); uint8_t g = G(c); uint8_t b = B(c);