bugfix: preset loading should not resets all error

preset loading was always resetting errorFlag to NO_ERROR.
Changed so only preset-related error are reset.
This commit is contained in:
Frank
2024-10-17 12:00:27 +02:00
parent 70ab62ed90
commit 617a98ddd8
2 changed files with 7 additions and 4 deletions

View File

@@ -228,6 +228,7 @@ void handlePresets()
presetToApply = 0; //clear request for preset
callModeToApply = 0;
byte presetErrorFlag = ERR_NONE;
DEBUG_PRINT(F("Applying preset: "));
DEBUG_PRINTLN(tmpPreset);
@@ -235,11 +236,13 @@ void handlePresets()
#ifdef ARDUINO_ARCH_ESP32
if (tmpPreset==255 && tmpRAMbuffer!=nullptr) {
deserializeJson(*fileDoc,tmpRAMbuffer);
errorFlag = ERR_NONE;
if ((errorFlag == ERR_FS_PLOAD) || (errorFlag == ERR_JSON)) errorFlag = ERR_NONE; // WLEDMM only reset our own error
} else
#endif
{
errorFlag = readObjectFromFileUsingId(filename, tmpPreset, fileDoc) ? ERR_NONE : ERR_FS_PLOAD;
presetErrorFlag = readObjectFromFileUsingId(filename, tmpPreset, fileDoc) ? ERR_NONE : ERR_FS_PLOAD;
if ((errorFlag == ERR_FS_PLOAD) || (errorFlag == ERR_JSON)) errorFlag = ERR_NONE; // WLEDMM only reset our own error
if (presetErrorFlag == ERR_FS_PLOAD) errorFlag = presetErrorFlag;
}
fdo = fileDoc->as<JsonObject>();
@@ -258,7 +261,7 @@ void handlePresets()
fdo.remove("ps"); // remove load request for presets to prevent recursive crash (if not called by button and contains preset cycling string "1~5~")
deserializeState(fdo, CALL_MODE_NO_NOTIFY, tmpPreset); // may change presetToApply by calling applyPreset()
}
if (!errorFlag && tmpPreset < 255 && changePreset) currentPreset = tmpPreset;
if (!presetErrorFlag && tmpPreset < 255 && changePreset) currentPreset = tmpPreset;
#if defined(ARDUINO_ARCH_ESP32)
//Aircoookie recommended not to delete buffer

View File

@@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2410080
#define VERSION 2410170
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
#define _MoonModules_WLED_