Fix for #3403
This commit is contained in:
parent
b0a56a431b
commit
7e6eb65950
@ -1573,7 +1573,7 @@ void WS2812FX::purgeSegments(bool force) {
|
|||||||
}
|
}
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
_segments.shrink_to_fit();
|
_segments.shrink_to_fit();
|
||||||
if (_mainSegment >= _segments.size()) setMainSegmentId(0);
|
/*if (_mainSegment >= _segments.size())*/ setMainSegmentId(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
byte id = elem["id"] | it;
|
byte id = elem["id"] | it;
|
||||||
if (id >= strip.getMaxSegments()) return false;
|
if (id >= strip.getMaxSegments()) return false;
|
||||||
|
|
||||||
|
bool newSeg = false;
|
||||||
int stop = elem["stop"] | -1;
|
int stop = elem["stop"] | -1;
|
||||||
|
|
||||||
// append segment
|
// append segment
|
||||||
@ -27,6 +28,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
if (stop <= 0) return false; // ignore empty/inactive segments
|
if (stop <= 0) return false; // ignore empty/inactive segments
|
||||||
strip.appendSegment(Segment(0, strip.getLengthTotal()));
|
strip.appendSegment(Segment(0, strip.getLengthTotal()));
|
||||||
id = strip.getSegmentsNum()-1; // segments are added at the end of list
|
id = strip.getSegmentsNum()-1; // segments are added at the end of list
|
||||||
|
newSeg = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//DEBUG_PRINTLN("-- JSON deserialize segment.");
|
//DEBUG_PRINTLN("-- JSON deserialize segment.");
|
||||||
@ -118,8 +120,12 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
// do not call seg.setUp() here, as it may cause a crash due to concurrent access if the segment is currently drawing effects
|
// do not call seg.setUp() here, as it may cause a crash due to concurrent access if the segment is currently drawing effects
|
||||||
// WS2812FX handles queueing of the change
|
// WS2812FX handles queueing of the change
|
||||||
strip.setSegment(id, start, stop, grp, spc, of, startY, stopY);
|
strip.setSegment(id, start, stop, grp, spc, of, startY, stopY);
|
||||||
|
if (newSeg) seg.refreshLightCapabilities(); // fix for #3403
|
||||||
|
|
||||||
if (seg.reset && seg.stop == 0) return true; // segment was deleted & is marked for reset, no need to change anything else
|
if (seg.reset && seg.stop == 0) {
|
||||||
|
if (id == strip.getMainSegmentId()) strip.setMainSegmentId(0); // fix for #3403
|
||||||
|
return true; // segment was deleted & is marked for reset, no need to change anything else
|
||||||
|
}
|
||||||
|
|
||||||
byte segbri = seg.opacity;
|
byte segbri = seg.opacity;
|
||||||
if (getVal(elem["bri"], &segbri)) {
|
if (getVal(elem["bri"], &segbri)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user