From aded74d8b1371dc06d98807b5be9105ac4ed81e8 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Sun, 4 Jun 2023 20:30:03 +0200 Subject: [PATCH] suspendStripService improvements * also suspend Transitions, Notifications and Live LED updates while strip or segments are under update from the Web UI. --- wled00/FX_fcn.cpp | 2 +- wled00/wled.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 97da2847..a46e929a 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1527,7 +1527,7 @@ void WS2812FX::waitUntilIdle(void) { if (isServicing()) { unsigned long waitStarted = millis(); do { - delay(1); // Suspending for 1 tick or more gives other tasks a chance to run. + delay(2); // Suspending for 1 tick (or more) gives other tasks a chance to run. //yield(); // seems to be a no-op on esp32 } while (isServicing() && (millis() - waitStarted < MAX_IDLE_WAIT_MS)); USER_PRINTF("strip.waitUntilIdle(): strip %sidle after %d ms. (task %s)\n", isServicing()?"not ":"", int(millis() - waitStarted), pcTaskGetTaskName(NULL)); diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 5bc97b29..ee089439 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -102,8 +102,16 @@ void WLED::loop() #endif handleConnection(); handleSerial(); - handleNotifications(); - handleTransitions(); + + #if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE) // WLEDMM experimental: handleNotifications() calls strip.show(); handleTransitions modifies segments + if (!suspendStripService) { + #endif + handleNotifications(); + handleTransitions(); + #if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE) // WLEDMM end + } + #endif + #ifdef WLED_ENABLE_DMX handleDMX(); #endif @@ -255,6 +263,9 @@ void WLED::loop() } yield(); + #if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE) // WLEDMM experimental: pause handleWs while strip/segment data might be inconsistent + if (!suspendStripService) + #endif handleWs(); handleStatusLED();