Save some bytes

This commit is contained in:
Theo Arends 2023-03-25 11:59:42 +01:00
parent b32a093c0c
commit 9ae7b86efc
2 changed files with 5 additions and 8 deletions

View File

@ -2156,13 +2156,11 @@ void CmndSwitchMode(void) {
Settings->switchmode[i] = XdrvMailbox.payload;
}
}
char stemp[MAX_SWITCHES_SET * 4];
stemp[0] = '\0';
Response_P(PSTR("{\"%s\":["), XdrvMailbox.command);
for (uint32_t i = 0; i < MAX_SWITCHES_SET; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%s%s%d" ), stemp, (i > 0 ? "," : "["), Settings->switchmode[i]);
ResponseAppend_P(PSTR("%s%d"), (i>0)?",":"", Settings->switchmode[i]);
}
strcat(stemp, "]");
Response_P(S_JSON_COMMAND_XVALUE, XdrvMailbox.command, stemp);
ResponseAppend_P(PSTR("]}"));
}
}

View File

@ -3631,10 +3631,9 @@ void CmndWebColor(void)
#endif // FIRMWARE_MINIMAL
}
}
Response_P(PSTR("{\"" D_CMND_WEBCOLOR "\":["));
Response_P(PSTR("{\"%s\":["), XdrvMailbox.command);
for (uint32_t i = 0; i < COL_LAST; i++) {
if (i) { ResponseAppend_P(PSTR(",")); }
ResponseAppend_P(PSTR("\"#%06x\""), WebColor(i));
ResponseAppend_P(PSTR("%s\"#%06x\""), (i>0)?",":"", WebColor(i));
}
ResponseAppend_P(PSTR("]}"));
}