From d7dac57a07ed2b9697689760e4da1c98cf018e50 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sat, 19 Feb 2022 20:34:37 +0100 Subject: [PATCH] Save a bit of RAM and flash. --- wled00/ir.cpp | 19 +++++-------------- wled00/json.cpp | 2 +- wled00/mqtt.cpp | 2 +- wled00/presets.cpp | 2 +- wled00/udp.cpp | 2 +- wled00/wled.h | 2 +- 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/wled00/ir.cpp b/wled00/ir.cpp index 82886640..88483f22 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -664,20 +664,11 @@ void decodeIRJson(uint32_t code) } } else { // HTTP API command - if (cmdStr.indexOf("~") || fdo["rpt"]) - { - // repeatable action - lastValidCode = code; - } - if (effectCurrent == 0 && cmdStr.indexOf("FP=") > -1) { - // setting palette but it wont show because effect is solid - effectCurrent = FX_MODE_GRADIENT; - } - if (!cmdStr.startsWith("win&")) { - cmdStr = "win&" + cmdStr; - } - fdo.clear(); //clear JSON buffer (it is no longer needed) - handleSet(nullptr, cmdStr, false); // no colorUpdated() call here + String apireq = "win"; apireq += '&'; // reduce flash string usage + if (cmdStr.indexOf("~") || fdo["rpt"]) lastValidCode = code; // repeatable action + if (!cmdStr.startsWith(apireq)) cmdStr = apireq + cmdStr; // if no "win&" prefix + fdo.clear(); // clear JSON buffer (it is no longer needed) + handleSet(nullptr, cmdStr, false); // no colorUpdated() call here } } else { // command is JSON object diff --git a/wled00/json.cpp b/wled00/json.cpp index 9b638ed0..a2bce079 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -365,7 +365,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) //HTTP API commands const char* httpwin = root["win"]; if (httpwin) { - String apireq = "win&"; + String apireq = "win"; apireq += '&'; // reduce flash string usage apireq += httpwin; handleSet(nullptr, apireq, false); } diff --git a/wled00/mqtt.cpp b/wled00/mqtt.cpp index 1a50d49f..ab194168 100644 --- a/wled00/mqtt.cpp +++ b/wled00/mqtt.cpp @@ -96,7 +96,7 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties deserializeJson(doc, payloadStr); deserializeState(doc.as()); } else { //HTTP API - String apireq = "win&"; + String apireq = "win"; apireq += '&'; // reduce flash string usage apireq += (char*)payloadStr; handleSet(nullptr, apireq); } diff --git a/wled00/presets.cpp b/wled00/presets.cpp index c2dcf16c..62f481f6 100644 --- a/wled00/presets.cpp +++ b/wled00/presets.cpp @@ -45,7 +45,7 @@ void handlePresets() //HTTP API commands const char* httpwin = fdo["win"]; if (httpwin) { - String apireq = "win&"; + String apireq = "win"; apireq += '&'; // reduce flash string usage apireq += httpwin; handleSet(nullptr, apireq, false); } else { diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 2861d551..76b576c7 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -514,7 +514,7 @@ void handleNotifications() if (requestJSONBufferLock(18)) { if (udpIn[0] >= 'A' && udpIn[0] <= 'Z') { //HTTP API - String apireq = "win&"; + String apireq = "win"; apireq += '&'; // reduce flash string usage apireq += (char*)udpIn; handleSet(nullptr, apireq); } else if (udpIn[0] == '{') { //JSON API diff --git a/wled00/wled.h b/wled00/wled.h index 46e05ddf..9673e3b0 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2202121 +#define VERSION 2202191 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG