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:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user