Skip to content

Commit

Permalink
Fix for Aircoookie#3403
Browse files Browse the repository at this point in the history
  • Loading branch information
blazoncek authored and softhack007 committed Oct 6, 2023
1 parent 7e21003 commit 3eb360d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@ void WS2812FX::purgeSegments(bool force) {
}
if (deleted) {
_segments.shrink_to_fit();
if (_mainSegment >= _segments.size()) setMainSegmentId(0);
/*if (_mainSegment >= _segments.size())*/ setMainSegmentId(0);
}
}

Expand Down
5 changes: 5 additions & 0 deletions wled00/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
if (!elem["rev2D"].isNull()) elem["rY"] = elem["rev2D"];
if (!elem["rot2D"].isNull()) elem["tp"] = elem["rot2D"];

bool newSeg = false;
int stop = elem["stop"] | -1;

// if using vectors use this code to append segment
if (id >= strip.getSegmentsNum()) {
if (stop <= 0) return false; // ignore empty/inactive segments
strip.appendSegment(Segment(0, strip.getLengthTotal()));
id = strip.getSegmentsNum()-1; // segments are added at the end of list
newSeg = true;
}

// WLEDMM: before changing segments, make sure our strip is _not_ servicing effects in parallel
Expand Down Expand Up @@ -188,9 +190,12 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
}
if (stop > start && of > len -1) of = len -1;
seg.setUp(start, stop, grp, spc, of, startY, stopY);
if (newSeg) seg.refreshLightCapabilities(); // fix for #3403

if (seg.reset && seg.stop == 0) {
if (iAmGroot) suspendStripService = false; // WLEDMM release lock

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
}

Expand Down

0 comments on commit 3eb360d

Please sign in to comment.