From d5ae1468aa4a7586bd73a7234478e634eea7ef0f Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Sat, 25 Apr 2026 10:39:33 +0200 Subject: [PATCH] add placeholder to keep custom palette ID's consistent --- wled00/colors.cpp | 5 ++++- wled00/data/index.js | 2 ++ wled00/json.cpp | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wled00/colors.cpp b/wled00/colors.cpp index dc15b24676..32fc521045 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -269,7 +269,10 @@ void loadCustomPalettes() { char fileName[32]; sprintf_P(fileName, PSTR("/palette%d.json"), index); if (WLED_FS.exists(fileName)) { - emptyPaletteGap = 0; // reset gap counter if file exists + // add gray placeholders to preserve palette IDs for subsequent slots (is omitted in UI but shown in cpal.htm) + for (unsigned g = 0; g < emptyPaletteGap; g++) + customPalettes.push_back(CRGBPalette16(CRGB(128, 128, 128))); + emptyPaletteGap = 0; // reset gap counter if file exists DEBUGFX_PRINTF_P(PSTR("Reading palette from %s\n"), fileName); if (readObjectFromFile(fileName, nullptr, &pDoc)) { JsonArray pal = pDoc[F("palette")]; diff --git a/wled00/data/index.js b/wled00/data/index.js index a3545981ba..023c2f00ab 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -993,6 +993,8 @@ function populatePalettes() let li = lastinfo; if (!isEmpty(li) && li.cpalcount) { for (let j = 0; j e[1] === 128 && e[2] === 128 && e[3] === 128)) continue; // skip all gray gap-placeholder entries let div = d.createElement("div"); gId('pallist').appendChild(div); div.outerHTML = generateListItemHtml( diff --git a/wled00/json.cpp b/wled00/json.cpp index 366c74e6d4..b8f29e08d6 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -774,7 +774,7 @@ void serializeInfo(JsonObject root) root[F("fxcount")] = strip.getModeCount(); root[F("palcount")] = getPaletteCount(); - root[F("cpalcount")] = customPalettes.size(); // number of custom palettes + root[F("cpalcount")] = customPalettes.size(); // number of custom palettes (includes gray placeholders) root[F("cpalmax")] = WLED_MAX_CUSTOM_PALETTES; // maximum number of custom palettes JsonArray ledmaps = root.createNestedArray(F("maps"));