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

@@ -769,6 +769,7 @@ WLED_GLOBAL volatile bool OTAisRunning _INIT(false); // WLEDMM temporaril
// WLEDMM prevent concurrent strip.show() and strip.service() -> for DDP over ws, and other background tasks
#ifdef ARDUINO_ARCH_ESP32
WLED_GLOBAL SemaphoreHandle_t busDrawMux _INIT(nullptr);
WLED_GLOBAL SemaphoreHandle_t segmentMux _INIT(nullptr);
#define esp32SemTake(mux,timeout) xSemaphoreTakeRecursive(mux, timeout) // convenience macro that expands to xSemaphoreTakeRecursive
#define esp32SemGive(mux) xSemaphoreGiveRecursive(mux) // convenience macro that expands to xSemaphoreGiveRecursive
#else