From a4384bd340cde2fc28526327156ead52fb7a93fe Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 11 Mar 2024 17:59:13 +0100 Subject: [PATCH] Simpler boot preset save - fixes #3806 --- wled00/data/index.css | 3 +-- wled00/data/index.js | 13 ++++++++++--- wled00/json.cpp | 1 + wled00/presets.cpp | 7 +++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/wled00/data/index.css b/wled00/data/index.css index abbb76e04..fa6e20077 100644 --- a/wled00/data/index.css +++ b/wled00/data/index.css @@ -1227,7 +1227,6 @@ TD .checkmark, TD .radiomark { text-align: left; transition: background-color .5s; border-radius: 21px; - width: 99%; } .seg { @@ -1291,6 +1290,7 @@ TD .checkmark, TD .radiomark { margin: 0 auto 12px; min-height: 40px; border: 1px solid var(--c-2); + width: 100%; } /* Simplify segments */ @@ -1421,7 +1421,6 @@ dialog { .presin { padding: 8px; position: relative; - width: calc(100% - 16px); } .btn-s, diff --git a/wled00/data/index.js b/wled00/data/index.js index 7889e3b34..36c3eb1b9 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -618,7 +618,7 @@ function populatePresets(fromls) cn += `
`; if (cfg.comp.pid) cn += `
${i}
`; - cn += `
${isPlaylist(i)?"":""}${pName(i)} + cn += `
${i==lastinfo.leds.bootps?"":""}${isPlaylist(i)?"":""}${pName(i)}
@@ -1959,6 +1959,7 @@ function plR(p) function makeP(i,pl) { var content = ""; + const bps = lastinfo.leds.bootps; if (pl) { if (i===0) plJson[0] = { ps: [1], @@ -2024,6 +2025,11 @@ ${makePlSel(plJson[i].end?plJson[i].end:0, true)}
API command
${content}
+
Save to ID 0)?i:getLowestUnusedP()}>
@@ -2445,8 +2451,9 @@ function saveP(i,pl) if (gId(`p${i}lmp`) && gId(`p${i}lmp`).value!=="") obj.ledmap = parseInt(gId(`p${i}lmp`).value); } } - - obj.psave = pI; obj.n = pN; + if (gId(`p${i}bps`).checked) obj.bootps = pI; + obj.psave = pI; + obj.n = pN; var pQN = gId(`p${i}ql`).value; if (pQN.length > 0) obj.ql = pQN; diff --git a/wled00/json.cpp b/wled00/json.cpp index b79da8d90..389dc8ae5 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -628,6 +628,7 @@ void serializeInfo(JsonObject root) leds[F("maxseg")] = strip.getMaxSegments(); //leds[F("actseg")] = strip.getActiveSegmentsNum(); //leds[F("seglock")] = false; //might be used in the future to prevent modifications to segment config + leds[F("bootps")] = bootPreset; #ifndef WLED_DISABLE_2D if (strip.isMatrix) { diff --git a/wled00/presets.cpp b/wled00/presets.cpp index 72833a97c..7fbe49eb8 100644 --- a/wled00/presets.cpp +++ b/wled00/presets.cpp @@ -224,6 +224,13 @@ void savePreset(byte index, const char* pname, JsonObject sObj) if (sObj[F("ql")].is()) strlcpy(quickLoad, sObj[F("ql")].as(), 9); // client limits QL to 2 chars, buffer for 8 bytes to allow unicode else quickLoad[0] = 0; + const char *bootPS = PSTR("bootps"); + if (!sObj[FPSTR(bootPS)].isNull()) { + bootPreset = sObj[FPSTR(bootPS)] | bootPreset; + sObj.remove(FPSTR(bootPS)); + doSerializeConfig = true; + } + if (sObj.size()==0 || sObj["o"].isNull()) { // no "o" means not a playlist or custom API call, saving of state is async (not immediately) includeBri = sObj["ib"].as() || sObj.size()==0 || index==255; // temporary preset needs brightness segBounds = sObj["sb"].as() || sObj.size()==0 || index==255; // temporary preset needs bounds