Add default preset name if none specified.
This commit is contained in:
parent
f8bc0bd2b5
commit
05bc81bf4e
@ -53,6 +53,7 @@ bool applyPreset(byte index, byte callMode)
|
|||||||
void savePreset(byte index, bool persist, const char* pname, JsonObject saveobj)
|
void savePreset(byte index, bool persist, const char* pname, JsonObject saveobj)
|
||||||
{
|
{
|
||||||
if (index == 0 || (index > 250 && persist) || (index<255 && !persist)) return;
|
if (index == 0 || (index > 250 && persist) || (index<255 && !persist)) return;
|
||||||
|
char tmp[12];
|
||||||
JsonObject sObj = saveobj;
|
JsonObject sObj = saveobj;
|
||||||
|
|
||||||
const char *filename = persist ? "/presets.json" : "/tmp.json";
|
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;
|
if (!requestJSONBufferLock(10)) return;
|
||||||
#endif
|
#endif
|
||||||
sObj = doc.to<JsonObject>();
|
sObj = doc.to<JsonObject>();
|
||||||
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"));
|
DEBUGFS_PRINTLN(F("Save current state"));
|
||||||
serializeState(sObj, true);
|
serializeState(sObj, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user