avoid updating strip / segments while draving effects (ESP32 only)

💫 this is the way🌟
A new locking mechanism that allows to wait until strip.service() has completed.
This commit is contained in:
Frank
2023-06-01 17:41:36 +02:00
parent e99874159d
commit 0a5bfb656d
7 changed files with 100 additions and 11 deletions

View File

@@ -164,8 +164,17 @@ void WLED::loop()
#ifdef WLED_DEBUG
unsigned long stripMillis = millis();
#endif
if (!offMode || strip.isOffRefreshRequired())
strip.service();
if (!offMode || strip.isOffRefreshRequired()) {
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
strip.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"
}
}
}
#ifdef ESP8266
else if (!noWifiSleep)
delay(1); //required to make sure ESP enters modem sleep (see #1184)