Add default preset name if no name specified

This commit is contained in:
Blaz Kristan 2022-02-19 11:37:48 +01:00
parent 7ebb184c8a
commit 59ce88f044

View File

@ -80,6 +80,7 @@ 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;
bool bufferAllocated = false;
@ -92,7 +93,10 @@ void savePreset(byte index, bool persist, const char* pname, JsonObject saveobj)
sObj = fileDoc->to<JsonObject>();
bufferAllocated = true;
}
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;
sObj.remove(F("psave"));
sObj.remove(F("v"));