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

@@ -90,6 +90,19 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
// initialize LED pins and lengths prior to other HW (except for ethernet)
JsonObject hw_led = hw["led"];
// WLEDMM: before changing strip, make sure our strip is _not_ servicing effects in parallel
suspendStripService = true; // temporarily lock out strip updates
#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 ..."));
} else {
USER_PRINTLN(F("deserializeConfig(): strip is still drawing effects, waiting ..."));
}
strip.waitUntilIdle();
}
#endif
uint8_t autoWhiteMode = RGBW_MODE_MANUAL_ONLY;
CJSON(strip.ablMilliampsMax, hw_led[F("maxpwr")]);
CJSON(strip.milliampsPerLed, hw_led[F("ledma")]);
@@ -599,6 +612,8 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
needsSave = !usermods.readFromConfig(usermods_settings);
}
suspendStripService = false; // WLEDMM release lock
if (fromFS) return needsSave;
// if from /json/cfg
doReboot = doc[F("rb")] | doReboot;