diff --git a/platformio.ini b/platformio.ini index 66fb6331..d7248e8c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -817,6 +817,7 @@ build_flags_S = -D USERMOD_AUDIOREACTIVE -D UM_AUDIOREACTIVE_USE_NEW_FFT ; use latest (upstream) FFTLib, instead of older library modified by blazoncek. Slightly faster, more accurate, needs 2KB RAM extra -D USERMOD_ARTIFX ; WLEDMM usermod + ; -D WLEDMM_PROTECT_SERVICE ;; WLEDMM experimental feature to prevent crashes when effects are drawing while async_tcp tries to modify segment or strip objects. ; -D WLED_DISABLE_LOXONE ; -D WLED_DISABLE_ALEXA ; -D WLED_DISABLE_HUESYNC diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 60212e93..2bba4088 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -75,10 +75,12 @@ // WLEDMM experimental . this is a "C style" wrapper for strip.waitUntilIdle() // This workaround is just needed for the segment class, that does't know about "strip" void strip_wait_until_idle(String whoCalledMe) { +#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE) // WLEDMM experimental if (strip.isServicing() && (strncmp(pcTaskGetTaskName(NULL), "loopTask", 8) != 0)) { // if we are in looptask (arduino loop), its safe to proceed without waiting - USER_PRINTLN(whoCalledMe + String(": strip is still drawing effects, waiting ...")); + USER_PRINTLN(whoCalledMe + String(": strip is still drawing effects.")); strip.waitUntilIdle(); } +#endif } @@ -1520,7 +1522,7 @@ void WS2812FX::finalizeInit(void) // on 8266 this function does nothing, because we can only do "buisy waiting" on ESP32 #define MAX_IDLE_WAIT_MS 50 // seems to work in most cases void WS2812FX::waitUntilIdle(void) { -#ifdef ARDUINO_ARCH_ESP32 +#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE) if (isServicing()) { unsigned long waitStarted = millis(); do { diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 32231ffd..baa4081b 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -95,9 +95,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { #ifdef ARDUINO_ARCH_ESP32 if (strip.isServicing() && (strncmp(pcTaskGetTaskName(NULL), "loopTask", 8) != 0)) { // if we are in looptask (arduino loop), its safe to proceed without waiting if (fromFS) { - USER_PRINTLN(F("deserializeConfig(fromFS): strip is still drawing effects, waiting ...")); + USER_PRINTLN(F("deserializeConfig(fromFS): strip is still drawing effects.")); } else { - USER_PRINTLN(F("deserializeConfig(): strip is still drawing effects, waiting ...")); + USER_PRINTLN(F("deserializeConfig(): strip is still drawing effects.")); } strip.waitUntilIdle(); } diff --git a/wled00/json.cpp b/wled00/json.cpp index e87fc568..b9b356f2 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -91,7 +91,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId) // WLEDMM: before changing segments, make sure our strip is _not_ servicing effects in parallel suspendStripService = true; // temporarily lock out strip updates if (strip.isServicing()) { - USER_PRINTLN(F("deserializeSegment(): strip is still drawing effects, waiting ...")); + USER_PRINTLN(F("deserializeSegment(): strip is still drawing effects.")); strip.waitUntilIdle(); } @@ -410,7 +410,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) // WLEDMM: before changing strip, make sure our strip is _not_ servicing effects in parallel suspendStripService = true; // temporarily lock out strip updates if (strip.isServicing()) { - USER_PRINTLN(F("deserializeState(): strip is still drawing effects, waiting ...")); + USER_PRINTLN(F("deserializeState(): strip is still drawing effects.")); strip.waitUntilIdle(); } diff --git a/wled00/set.cpp b/wled00/set.cpp index 60ed8ee1..634f071d 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -21,11 +21,11 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) //0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 7: DMX 8: usermods 9: N/A 10: 2D if (subPage <1 || subPage >10 || !correctPIN) return; - // WLEDMM: before changing bus or strip settings, make sure our strip is _not_ servicing effects in parallel - if ((subPage == 2) || (subPage == 10)) { + // WLEDMM: before changing bus, ledmap, strip or 2D settings, make sure our strip is _not_ servicing effects in parallel + if ((subPage == 2) || (subPage == 3) || (subPage == 10)) { suspendStripService = true; // temporarily lock out strip updates if (strip.isServicing()) { - USER_PRINTLN(F("handleSettingsSet(): strip is still drawing effects, waiting ...")); + USER_PRINTLN(F("handleSettingsSet(): strip is still drawing effects.")); strip.waitUntilIdle(); } } @@ -775,7 +775,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) } #endif - if ((subPage == 2) || (subPage == 10)) { + if ((subPage == 2) || (subPage == 3) || (subPage == 10)) { suspendStripService = false; // WLEDMM release lock } @@ -817,7 +817,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) // WLEDMM: before changing segment settings, make sure our strip is _not_ servicing effects in parallel if (strip.isServicing()) { - USER_PRINTLN(F("handleSet(): strip is still drawing effects, waiting ...")); + USER_PRINTLN(F("handleSet(): strip is still drawing effects.")); strip.waitUntilIdle(); } diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 38d38555..5bc97b29 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -165,15 +165,19 @@ void WLED::loop() unsigned long stripMillis = millis(); #endif if (!offMode || strip.isOffRefreshRequired()) { +#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE) // WLEDMM experimental static unsigned long lastTimeService = 0; // WLEMM needed to remove stale lock if (!suspendStripService && !doInitBusses && !loadLedmap) { // WLEDMM prevent effect drawing while strip or segments are being updated +#endif strip.service(); +#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE) lastTimeService = millis(); } else { if (suspendStripService && (millis() - lastTimeService > 1500)) { // WLEDMM remove stale lock after 1.5 seconds USER_PRINTLN("--> looptask: stale suspendStripService lock removed after 1500 ms."); // should not happen - check for missing "suspendStripService = false" } } +#endif } #ifdef ESP8266 else if (!noWifiSleep) diff --git a/wled00/wled.h b/wled00/wled.h index 6bb401f1..be243a8e 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2306010 +#define VERSION 2306011 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG