mirror of
https://github.com/wled/WLED.git
synced 2025-07-17 15:56:31 +00:00
Merge pull request #2170 from scottrbailey/error-12-fix
Fix error 12 issues
This commit is contained in:
commit
8d4636bbab
@ -215,6 +215,7 @@
|
|||||||
#define ERR_FS_BEGIN 10 // Could not init filesystem (no partition?)
|
#define ERR_FS_BEGIN 10 // Could not init filesystem (no partition?)
|
||||||
#define ERR_FS_QUOTA 11 // The FS is full or the maximum file size is reached
|
#define ERR_FS_QUOTA 11 // The FS is full or the maximum file size is reached
|
||||||
#define ERR_FS_PLOAD 12 // It was attempted to load a preset that does not exist
|
#define ERR_FS_PLOAD 12 // It was attempted to load a preset that does not exist
|
||||||
|
#define ERR_FS_IRLOAD 13 // It was attempted to load an IR JSON cmd, but the "ir.json" file does not exist
|
||||||
#define ERR_FS_GENERAL 19 // A general unspecified filesystem error occured
|
#define ERR_FS_GENERAL 19 // A general unspecified filesystem error occured
|
||||||
#define ERR_OVERTEMP 30 // An attached temperature sensor has measured above threshold temperature (not implemented)
|
#define ERR_OVERTEMP 30 // An attached temperature sensor has measured above threshold temperature (not implemented)
|
||||||
#define ERR_OVERCURRENT 31 // An attached current sensor has measured a current above the threshold (not implemented)
|
#define ERR_OVERCURRENT 31 // An attached current sensor has measured a current above the threshold (not implemented)
|
||||||
|
@ -71,9 +71,11 @@ void decBrightness()
|
|||||||
// apply preset or fallback to a effect and palette if it doesn't exist
|
// apply preset or fallback to a effect and palette if it doesn't exist
|
||||||
void presetFallback(uint8_t presetID, uint8_t effectID, uint8_t paletteID)
|
void presetFallback(uint8_t presetID, uint8_t effectID, uint8_t paletteID)
|
||||||
{
|
{
|
||||||
|
byte prevError = errorFlag;
|
||||||
if (!applyPreset(presetID, CALL_MODE_BUTTON)) {
|
if (!applyPreset(presetID, CALL_MODE_BUTTON)) {
|
||||||
effectCurrent = effectID;
|
effectCurrent = effectID;
|
||||||
effectPalette = paletteID;
|
effectPalette = paletteID;
|
||||||
|
errorFlag = prevError; //clear error 12 from non-existent preset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,14 +574,18 @@ void decodeIRJson(uint32_t code)
|
|||||||
|
|
||||||
sprintf(objKey, "\"0x%X\":", code);
|
sprintf(objKey, "\"0x%X\":", code);
|
||||||
|
|
||||||
errorFlag = readObjectFromFile("/ir.json", objKey, &irDoc) ? ERR_NONE : ERR_FS_PLOAD;
|
readObjectFromFile("/ir.json", objKey, &irDoc);
|
||||||
fdo = irDoc.as<JsonObject>();
|
fdo = irDoc.as<JsonObject>();
|
||||||
lastValidCode = 0;
|
lastValidCode = 0;
|
||||||
if (!errorFlag)
|
if (fdo.isNull()) {
|
||||||
{
|
//the received code does not exist
|
||||||
cmd = fdo["cmd"];
|
if (!WLED_FS.exists("/ir.json")) errorFlag = ERR_FS_IRLOAD; //warn if IR file itself doesn't exist
|
||||||
cmdStr = String(cmd);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
jsonCmdObj = fdo["cmd"];
|
jsonCmdObj = fdo["cmd"];
|
||||||
|
cmdStr = String(jsonCmdObj);
|
||||||
|
|
||||||
if (!cmdStr.isEmpty())
|
if (!cmdStr.isEmpty())
|
||||||
{
|
{
|
||||||
if (cmdStr.startsWith("!")) {
|
if (cmdStr.startsWith("!")) {
|
||||||
@ -592,7 +598,7 @@ void decodeIRJson(uint32_t code)
|
|||||||
decBrightness();
|
decBrightness();
|
||||||
} else if (cmdStr.startsWith(F("!presetF"))) { //!presetFallback
|
} else if (cmdStr.startsWith(F("!presetF"))) { //!presetFallback
|
||||||
uint8_t p1 = fdo["PL"] ? fdo["PL"] : 1;
|
uint8_t p1 = fdo["PL"] ? fdo["PL"] : 1;
|
||||||
uint8_t p2 = fdo["FX"] ? fdo["FX"] : random8(100);
|
uint8_t p2 = fdo["FX"] ? fdo["FX"] : random8(MODE_COUNT);
|
||||||
uint8_t p3 = fdo["FP"] ? fdo["FP"] : 0;
|
uint8_t p3 = fdo["FP"] ? fdo["FP"] : 0;
|
||||||
presetFallback(p1, p2, p3);
|
presetFallback(p1, p2, p3);
|
||||||
}
|
}
|
||||||
@ -620,7 +626,6 @@ void decodeIRJson(uint32_t code)
|
|||||||
fileDoc = nullptr;
|
fileDoc = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void initIR()
|
void initIR()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user