From 9ae7b86efc7eb5fb1dbff3983e9a01d1fdf258eb Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 25 Mar 2023 11:59:42 +0100 Subject: [PATCH] Save some bytes --- tasmota/tasmota_support/support_command.ino | 8 +++----- tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index 946e8c2aa..f056a971f 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -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("]}")); } } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index 4611a8695..d1e43b694 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -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("]}")); }