From 05bc81bf4eeda655a4841380522ecf7f6d8a80e7 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sat, 19 Feb 2022 11:42:59 +0100 Subject: [PATCH] Add default preset name if none specified. --- wled00/presets.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wled00/presets.cpp b/wled00/presets.cpp index de82c939..690a709f 100644 --- a/wled00/presets.cpp +++ b/wled00/presets.cpp @@ -53,6 +53,7 @@ bool applyPreset(byte index, byte callMode) void savePreset(byte index, bool persist, const char* pname, JsonObject saveobj) { if (index == 0 || (index > 250 && persist) || (index<255 && !persist)) return; + char tmp[12]; JsonObject sObj = saveobj; const char *filename = persist ? "/presets.json" : "/tmp.json"; @@ -65,7 +66,11 @@ void savePreset(byte index, bool persist, const char* pname, JsonObject saveobj) if (!requestJSONBufferLock(10)) return; #endif sObj = doc.to(); - if (pname) sObj["n"] = pname; + + if (sObj["n"].isNull() && pname == nullptr) { + sprintf_P(tmp, PSTR("Preset %d"), index); + sObj["n"] = tmp; + } else if (pname) sObj["n"] = pname; DEBUGFS_PRINTLN(F("Save current state")); serializeState(sObj, true);