From bd44205b4eb5838d8bda50b6c823bea4787c3624 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Fri, 18 Feb 2022 18:52:44 +0100 Subject: [PATCH] Allow saving preset from IR --- wled00/ir.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wled00/ir.cpp b/wled00/ir.cpp index c241ebda..b3c39d73 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -676,12 +676,18 @@ void decodeIRJson(uint32_t code) if (!cmdStr.startsWith("win&")) { cmdStr = "win&" + cmdStr; } - handleSet(nullptr, cmdStr, false); + handleSet(nullptr, cmdStr, false); // no colorUpdated() call here } - //colorUpdated(CALL_MODE_BUTTON); - } else if (!jsonCmdObj.isNull()) { + } else { // command is JSON object - deserializeState(jsonCmdObj, CALL_MODE_BUTTON_PRESET); + if (jsonCmdObj[F("psave")].isNull()) deserializeState(jsonCmdObj, CALL_MODE_BUTTON_PRESET); + else { + uint8_t psave = jsonCmdObj[F("psave")].as(); + char pname[33]; + sprintf_P(pname, PSTR("IR Preset %d"), psave); + fdo.clear(); + if (psave > 0 && psave < 251) savePreset(psave, true, pname, fdo); + } } releaseJSONBufferLock(); }