JSON IR improvements

Restored support for "PL=~" mistakenly removed in 2106300
This commit is contained in:
cschwinne 2021-07-04 13:23:45 +02:00
parent 1bb7e36a65
commit c879351063
4 changed files with 26 additions and 7 deletions

View File

@ -2,6 +2,11 @@
### Builds after release 0.12.0
#### Build 2107041
- Restored support for "PL=~" mistakenly removed in 2106300
- JSON IR improvements
#### Build 2107040
- Playlist entries are now more compact

View File

@ -580,13 +580,13 @@ void decodeIRJson(uint32_t code)
{
if (cmdStr.startsWith("!")) {
// call limited set of C functions
if (cmdStr == "!incBrightness") {
if (cmdStr.startsWith(F("!incBri"))) {
lastValidCode = code;
incBrightness();
} else if (cmdStr == "!decBrightness") {
} else if (cmdStr.startsWith(F("!decBri"))) {
lastValidCode = code;
decBrightness();
} else if (cmdStr == "!presetFallback") {
} else if (cmdStr.startsWith(F("!presetF"))) { //!presetFallback
uint8_t p1 = fdo["PL"] ? fdo["PL"] : 1;
uint8_t p2 = fdo["FX"] ? fdo["FX"] : random8(100);
uint8_t p3 = fdo["FP"] ? fdo["FP"] : 0;
@ -598,7 +598,8 @@ void decodeIRJson(uint32_t code)
{
// repeatable action
lastValidCode = code;
} if (effectCurrent == 0 && cmdStr.indexOf("FP=") > -1) {
}
if (effectCurrent == 0 && cmdStr.indexOf("FP=") > -1) {
// setting palette but it wont show because effect is solid
effectCurrent = FX_MODE_GRADIENT;
}
@ -609,7 +610,10 @@ void decodeIRJson(uint32_t code)
}
} else if (!jsonCmdObj.isNull()) {
// command is JSON object
//allow applyPreset() to reuse JSON buffer, or it would alloc. a second buffer and run out of mem.
fileDoc = &irDoc;
deserializeState(jsonCmdObj);
fileDoc = nullptr;
}
}
}

View File

@ -614,9 +614,16 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
pos = req.indexOf(F("PS=")); //saves current in preset
if (pos > 0) savePreset(getNumVal(&req, pos));
pos = req.indexOf(F("P1=")); //sets first preset for cycle
if (pos > 0) presetCycleMin = getNumVal(&req, pos);
pos = req.indexOf(F("P2=")); //sets last preset for cycle
if (pos > 0) presetCycleMax = getNumVal(&req, pos);
//apply preset
pos = req.indexOf(F("PL="));
if (pos > 0) applyPreset(getNumVal(&req, pos));
if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) {
applyPreset(presetCycCurr);
}
//set brightness
updateVal(&req, "&A=", &bri);

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2107040
#define VERSION 2107041
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG
@ -504,6 +504,9 @@ WLED_GLOBAL bool blynkEnabled _INIT(false);
//playlists
WLED_GLOBAL unsigned long presetCycledTime _INIT(0);
WLED_GLOBAL int16_t currentPlaylist _INIT(0);
//still used for "PL=~" HTTP API command
WLED_GLOBAL byte presetCycleMin _INIT(1), presetCycleMax _INIT(5);
WLED_GLOBAL byte presetCycCurr _INIT(presetCycleMin);
// realtime
WLED_GLOBAL byte realtimeMode _INIT(REALTIME_MODE_INACTIVE);