Skip to content

Commit 9094b31

Browse files
authored
Display gaps in peek, fix segment overflow bug (#5105)
- display gaps in peek - fix segment overflow bug when loading preset with larger bounds than current setup
1 parent 32b104e commit 9094b31

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

wled00/FX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ uint16_t mode_copy_segment(void) {
172172
} else { // 1D source, source can be expanded into 2D
173173
for (unsigned i = 0; i < SEGMENT.vLength(); i++) {
174174
if(SEGMENT.check2) {
175-
sourcecolor = strip.getPixelColor(i + sourcesegment.start); // read from global buffer (reads the last rendered frame)
175+
sourcecolor = strip.getPixelColorNoMap(i + sourcesegment.start); // read from global buffer (reads the last rendered frame)
176176
}
177177
else {
178178
sourcesegment.setDrawDimensions(); // set to source segment dimensions

wled00/FX.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,8 @@ class WS2812FX {
965965
};
966966

967967
unsigned long now, timebase;
968-
inline uint32_t getPixelColor(unsigned n) const { return (n < getLengthTotal()) ? _pixels[n] : 0; } // returns color of pixel n
968+
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
969+
inline uint32_t getPixelColorNoMap(unsigned n) const { return (n < getLengthTotal()) ? _pixels[n] : 0; } // ignores mapping table
969970
inline uint32_t getLastShow() const { return _lastShow; } // returns millis() timestamp of last strip.show() call
970971

971972
const char *getModeData(unsigned id = 0) const { return (id && id < _modeCount) ? _modeData[id] : PSTR("Solid"); }

wled00/FX_fcn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, ui
458458
return;
459459
}
460460
if (i1 < Segment::maxWidth || (i1 >= Segment::maxWidth*Segment::maxHeight && i1 < strip.getLengthTotal())) start = i1; // Segment::maxWidth equals strip.getLengthTotal() for 1D
461-
stop = i2 > Segment::maxWidth*Segment::maxHeight ? MIN(i2,strip.getLengthTotal()) : constrain(i2, 1, Segment::maxWidth);
461+
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
462462
startY = 0;
463463
stopY = 1;
464464
#ifndef WLED_DISABLE_2D

wled00/ws.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ bool sendLiveLedsWs(uint32_t wsClient)
230230
#ifndef WLED_DISABLE_2D
231231
if (strip.isMatrix && n>1 && (i/Segment::maxWidth)%n) i += Segment::maxWidth * (n-1);
232232
#endif
233-
uint32_t c = strip.getPixelColor(i);
233+
uint32_t c = strip.getPixelColor(i); // note: LEDs mapped outside of valid range are set to black
234234
uint8_t r = R(c);
235235
uint8_t g = G(c);
236236
uint8_t b = B(c);

0 commit comments

Comments
 (0)