Fixed spacing LEDs not blanked if offset is changed
This commit is contained in:
parent
a643b56555
commit
cadda12371
@ -647,7 +647,7 @@ class WS2812FX {
|
||||
setTransitionMode(bool t),
|
||||
calcGammaTable(float),
|
||||
trigger(void),
|
||||
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0),
|
||||
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0, uint16_t offset = UINT16_MAX),
|
||||
resetSegments(),
|
||||
makeAutoSegments(),
|
||||
fixInvalidSegments(),
|
||||
|
@ -567,12 +567,14 @@ bool WS2812FX::hasCCTBus(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, uint8_t spacing) {
|
||||
void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, uint8_t spacing, uint16_t offset) {
|
||||
if (n >= MAX_NUM_SEGMENTS) return;
|
||||
Segment& seg = _segments[n];
|
||||
|
||||
//return if neither bounds nor grouping have changed
|
||||
if (seg.start == i1 && seg.stop == i2 && (!grouping || (seg.grouping == grouping && seg.spacing == spacing))) return;
|
||||
if (seg.start == i1 && seg.stop == i2
|
||||
&& (!grouping || (seg.grouping == grouping && seg.spacing == spacing))
|
||||
&& (offset == UINT16_MAX || offset == seg.offset)) return;
|
||||
|
||||
if (seg.stop) setRange(seg.start, seg.stop -1, 0); //turn old segment range off
|
||||
if (i2 <= i1) //disable segment
|
||||
@ -602,6 +604,7 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
|
||||
seg.grouping = grouping;
|
||||
seg.spacing = spacing;
|
||||
}
|
||||
if (offset < UINT16_MAX) seg.offset = offset;
|
||||
_segment_runtimes[n].reset();
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
|
||||
uint16_t grp = elem["grp"] | seg.grouping;
|
||||
uint16_t spc = elem[F("spc")] | seg.spacing;
|
||||
strip.setSegment(id, start, stop, grp, spc);
|
||||
uint16_t of = seg.offset;
|
||||
|
||||
uint16_t len = 1;
|
||||
if (stop > start) len = stop - start;
|
||||
@ -73,9 +73,10 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
int offsetAbs = abs(offset);
|
||||
if (offsetAbs > len - 1) offsetAbs %= len;
|
||||
if (offset < 0) offsetAbs = len - offsetAbs;
|
||||
seg.offset = offsetAbs;
|
||||
of = offsetAbs;
|
||||
}
|
||||
if (stop > start && seg.offset > len -1) seg.offset = len -1;
|
||||
if (stop > start && of > len -1) of = len -1;
|
||||
strip.setSegment(id, start, stop, grp, spc, of);
|
||||
|
||||
byte segbri = 0;
|
||||
if (getVal(elem["bri"], &segbri)) {
|
||||
|
Loading…
Reference in New Issue
Block a user