Skip to content

Commit 5f3ab42

Browse files
committed
reduced freeze time when updating presets
postpone suspendStripService until the first segment operation is needed.
1 parent 9fe4d78 commit 5f3ab42

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

wled00/json.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,16 +493,15 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
493493
}
494494
}
495495

496-
#ifdef ARDUINO_ARCH_ESP32
497-
delay(2); // WLEDMM experimental - de-serialize takes time, so allow other tasks to run
498-
#endif
499-
496+
// esp32: suspendStripService is deferred until the first segment operation
497+
#ifndef ARDUINO_ARCH_ESP32
500498
// WLEDMM: before changing strip, make sure our strip is _not_ servicing effects in parallel
501499
suspendStripService = true; // temporarily lock out strip updates
502500
if (strip.isServicing()) {
503501
USER_PRINTLN(F("deserializeState(): strip is still drawing effects."));
504502
strip.waitUntilIdle();
505503
}
504+
#endif
506505

507506
// temporary transition (applies only once)
508507
tr = root[F("tt")] | -1;
@@ -538,6 +537,16 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
538537

539538
if (root[F("psave")].isNull()) doReboot = root[F("rb")] | doReboot;
540539

540+
#ifdef ARDUINO_ARCH_ESP32
541+
// WLEDMM: Acquire strip lock right before segment operations (deferred for better UX)
542+
suspendStripService = true; // temporarily lock out strip updates
543+
delay(2); // WLEDMM experimental - de-serialize takes time, so allow other tasks to run
544+
if (strip.isServicing()) {
545+
USER_PRINTLN(F("deserializeState(): strip is still drawing effects."));
546+
strip.waitUntilIdle();
547+
}
548+
#endif
549+
541550
// do not allow changing main segment while in realtime mode (may get odd results else)
542551
if (!realtimeMode) strip.setMainSegmentId(root[F("mainseg")] | strip.getMainSegmentId()); // must be before realtimeLock() if "live"
543552

0 commit comments

Comments
 (0)