another attempt to prevent glitches caused by file access

wait for LEDs send out to finish, then access presets.json
This commit is contained in:
Frank
2026-01-05 11:22:53 +01:00
parent f9c7828eeb
commit 586d3c2732
2 changed files with 18 additions and 0 deletions

View File

@@ -547,6 +547,12 @@ bool handleFileRead(AsyncWebServerRequest* request, String path){
}
#endif
// wait for strip to finish updating, accessing FS during sendout causes glitches
#ifdef ARDUINO_ARCH_ESP32
unsigned wait_start = millis();
while (strip.isUpdating() && (millis() - wait_start < 40)) delay(1); // wait max 40ms
#endif
if(WLED_FS.exists(path) || WLED_FS.exists(path + ".gz")) {
request->send(WLED_FS, path, String(), request->hasArg(F("download")));
return true;

View File

@@ -49,6 +49,12 @@ static void doSaveState() {
return;
}
// wait for strip to finish updating, accessing FS during sendout causes glitches
#ifdef ARDUINO_ARCH_ESP32
unsigned wait_start = millis();
while (strip.isUpdating() && (millis() - wait_start < 40)) delay(1); // wait max 40ms
#endif
initPresetsFile(); // just in case if someone deleted presets.json using /edit
JsonObject sObj = doc.to<JsonObject>();
@@ -357,6 +363,12 @@ void savePreset(byte index, const char* pname, JsonObject sObj)
sObj.remove(F("psave"));
if (sObj["n"].isNull()) sObj["n"] = saveName;
// wait for strip to finish updating, accessing FS during sendout causes glitches
#ifdef ARDUINO_ARCH_ESP32
unsigned wait_start = millis();
while (strip.isUpdating() && (millis() - wait_start < 40)) delay(1); // wait max 40ms
#endif
initPresetsFile(); // just in case if someone deleted presets.json using /edit
writeObjectToFileUsingId(getFileName(index<255), index, fileDoc);