segment & bus.show mutex redesign

* separate mutexes for improved performance:
  - busses.show and effect drawing
  - critical changes to segment vector
  - block out critical segment changes while strip.service() loops over segments
* UDP realtime acquires mutex before drawing
  - prevents corrupted outputs, caused by parallel tasks updating pixels while busses.show() runs
This commit is contained in:
Frank
2025-12-21 23:56:09 +01:00
parent c520d75729
commit 30fcd6efad
5 changed files with 90 additions and 76 deletions

View File

@@ -94,7 +94,11 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
// 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()));
if (esp32SemTake(segmentMux, portMAX_DELAY) == pdTRUE) {
// WLEDMM make sure we have exclusive access to the segment list
strip.appendSegment(Segment(0, strip.getLengthTotal()));
esp32SemGive(segmentMux);
}
id = strip.getSegmentsNum()-1; // segments are added at the end of list
newSeg = true;
}