diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 57e4f62df..f7a78c179 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -462,7 +462,9 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len) uint16_t index; uint32_t address; +#ifdef USE_DEBUG_DRIVER ShowFreeMem(PSTR("MqttDataHandler")); +#endif strlcpy(topicBuf, topic, sizeof(topicBuf)); for (i = 0; i < data_len; i++) { @@ -1595,7 +1597,9 @@ void ExecuteCommand(char *cmnd, int source) char *start; char *token; +#ifdef USE_DEBUG_DRIVER ShowFreeMem(PSTR("ExecuteCommand")); +#endif ShowSource(source); token = strtok(cmnd, " "); diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 7c69405ad..9d96c480c 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -283,37 +283,6 @@ const char HTTP_MSG_SLIDER2[] PROGMEM = const char HTTP_MSG_RSTRT[] PROGMEM = "
" D_DEVICE_WILL_RESTART "

"; -const char HTTP_BTN_CONF[] PROGMEM = - "
" - "
"; -const char HTTP_BTN_MENU1[] PROGMEM = -#ifndef FIRMWARE_MINIMAL - "

" -#endif - "
" - "

"; -const char HTTP_BTN_RSTRT[] PROGMEM = - "
"; - -const char HTTP_BTN_MENU_MODULE[] PROGMEM = - "

" - "

"; -const char HTTP_BTN_MENU4[] PROGMEM = - "

" - "

" - "

"; - -const char HTTP_BTN_RESET[] PROGMEM = - "
" - "
"; -const char HTTP_BTN_MENU5[] PROGMEM = - "

" - "

"; - -const char HTTP_BTN_MAIN[] PROGMEM = - "
" - "
"; - const char HTTP_FORM_LOGIN[] PROGMEM = "
" "
" @@ -418,6 +387,20 @@ const char HTTP_END[] PROGMEM = const char HTTP_DEVICE_CONTROL[] PROGMEM = ""; // ?o is related to WebGetArg("o", tmp, sizeof(tmp)); const char HTTP_DEVICE_STATE[] PROGMEM = "%s%s"; // {c} = %'>

"), + GetTextIndexed(action, sizeof(action), title_index, kButtonAction), + GetTextIndexed(confirm, sizeof(confirm), title_index, kButtonConfirm), + (!title_index) ? "rst" : "non", + GetTextIndexed(title, sizeof(title), title_index, kButtonTitle)); + } else { + WSContentSend_P(PSTR("

"), + GetTextIndexed(action, sizeof(action), title_index, kButtonAction), + GetTextIndexed(title, sizeof(title), title_index, kButtonTitle)); + } +} + +void WSContentSpaceButton(uint8_t title_index) +{ + WSContentSend_P(PSTR("
")); // 5px padding + WSContentButton(title_index); +} + void WSContentEnd(void) { if (WifiIsInManagerMode()) { @@ -762,7 +772,7 @@ void WebRestart(uint8_t type) if (HTTP_MANAGER == webserver_state || reset_only) { webserver_state = HTTP_ADMIN; } else { - WSContentSend_P(HTTP_BTN_MAIN); + WSContentSpaceButton(BUTTON_MAIN); } WSContentEnd(); @@ -779,10 +789,9 @@ void HandleWifiLogin(void) WSContentSend_P(HTTP_FORM_LOGIN); if (HTTP_MANAGER_RESET_ONLY == webserver_state) { - WSContentSend_P(PSTR("
")); - WSContentSend_P(HTTP_BTN_RSTRT); + WSContentSpaceButton(BUTTON_RESTART); #ifndef FIRMWARE_MINIMAL - WSContentSend_P(HTTP_BTN_RESET); + WSContentSpaceButton(BUTTON_RESET_CONFIGURATION); #endif // FIRMWARE_MINIMAL } @@ -793,7 +802,7 @@ void HandleRoot(void) { if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the page. - if (WebServer->hasArg("rstrt")) { + if (WebServer->hasArg("rst")) { WebRestart(0); return; } @@ -870,13 +879,15 @@ void HandleRoot(void) #endif // Not FIRMWARE_MINIMAL if (HTTP_ADMIN == webserver_state) { -#ifndef FIRMWARE_MINIMAL - WSContentSend_P(HTTP_BTN_CONF); +#ifdef FIRMWARE_MINIMAL + WSContentSpaceButton(BUTTON_FIRMWARE_UPGRADE); #else - WSContentSend_P(PSTR("
")); + WSContentSpaceButton(BUTTON_CONFIGURATION); + WSContentButton(BUTTON_INFORMATION); + WSContentButton(BUTTON_FIRMWARE_UPGRADE); #endif // Not FIRMWARE_MINIMAL - WSContentSend_P(HTTP_BTN_MENU1); - WSContentSend_P(HTTP_BTN_RSTRT); + WSContentButton(BUTTON_CONSOLE); + WSContentButton(BUTTON_RESTART); } WSContentEnd(); } @@ -972,15 +983,22 @@ void HandleConfiguration(void) WSContentStart_P(S_CONFIGURATION); WSContentSendStyle(); - WSContentSend_P(HTTP_BTN_MENU_MODULE); + + WSContentButton(BUTTON_MODULE); + WSContentButton(BUTTON_WIFI); XdrvCall(FUNC_WEB_ADD_BUTTON); XsnsCall(FUNC_WEB_ADD_BUTTON); - WSContentSend_P(HTTP_BTN_MENU4); - WSContentSend_P(HTTP_BTN_RESET); - WSContentSend_P(HTTP_BTN_MENU5); - WSContentSend_P(HTTP_BTN_MAIN); + WSContentButton(BUTTON_LOGGING); + WSContentButton(BUTTON_OTHER); + WSContentButton(BUTTON_TEMPLATE); + + WSContentSpaceButton(BUTTON_RESET_CONFIGURATION); + WSContentButton(BUTTON_BACKUP); + WSContentButton(BUTTON_RESTORE); + + WSContentSpaceButton(BUTTON_MAIN); WSContentEnd(); } @@ -1067,7 +1085,7 @@ void HandleTemplateConfiguration(void) WSContentSend_P(HTTP_FORM_TEMPLATE_FLAG); WSContentSend_P(HTTP_FORM_END); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); } @@ -1174,7 +1192,7 @@ void HandleModuleConfiguration(void) } WSContentSend_P(PSTR("")); WSContentSend_P(HTTP_FORM_END); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); } @@ -1310,13 +1328,12 @@ void HandleWifiConfiguration(void) } if (WifiIsInManagerMode()) { - WSContentSend_P(PSTR("
")); - WSContentSend_P(HTTP_BTN_RSTRT); + WSContentSpaceButton(BUTTON_RESTART); #ifndef FIRMWARE_MINIMAL - WSContentSend_P(HTTP_BTN_RESET); + WSContentSpaceButton(BUTTON_RESET_CONFIGURATION); #endif // FIRMWARE_MINIMAL } else { - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); } WSContentEnd(); } @@ -1376,7 +1393,7 @@ void HandleLoggingConfiguration(void) } WSContentSend_P(HTTP_FORM_LOG2, Settings.syslog_host, Settings.syslog_port, Settings.tele_period); WSContentSend_P(HTTP_FORM_END); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); } @@ -1452,7 +1469,7 @@ void HandleOtherConfiguration(void) #endif // USE_EMULATION WSContentSend_P(HTTP_FORM_END); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); } @@ -1548,7 +1565,7 @@ void HandleResetConfiguration(void) WSContentSendStyle(); WSContentSend_P(PSTR("
" D_CONFIGURATION_RESET "
")); WSContentSend_P(HTTP_MSG_RSTRT); - WSContentSend_P(HTTP_BTN_MAIN); + WSContentSpaceButton(BUTTON_MAIN); WSContentEnd(); char command[CMDSZ]; @@ -1566,7 +1583,7 @@ void HandleRestoreConfiguration(void) WSContentSendStyle(); WSContentSend_P(HTTP_FORM_RST); WSContentSend_P(HTTP_FORM_RST_UPG, D_RESTORE); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); upload_error = 0; @@ -1668,7 +1685,7 @@ void HandleInformation(void) WSContentSend_P(PSTR("" "
")); // WSContentSend_P(PSTR("
")); - WSContentSend_P(HTTP_BTN_MAIN); + WSContentSpaceButton(BUTTON_MAIN); WSContentEnd(); } #endif // Not FIRMWARE_MINIMAL @@ -1685,7 +1702,7 @@ void HandleUpgradeFirmware(void) WSContentSendStyle(); WSContentSend_P(HTTP_FORM_UPG, Settings.ota_url); WSContentSend_P(HTTP_FORM_RST_UPG, D_UPGRADE); - WSContentSend_P(HTTP_BTN_MAIN); + WSContentSpaceButton(BUTTON_MAIN); WSContentEnd(); upload_error = 0; @@ -1713,7 +1730,7 @@ void HandleUpgradeFirmwareStart(void) WSContentSendStyle(); WSContentSend_P(PSTR("
" D_UPGRADE_STARTED " ...
")); WSContentSend_P(HTTP_MSG_RSTRT); - WSContentSend_P(HTTP_BTN_MAIN); + WSContentSpaceButton(BUTTON_MAIN); WSContentEnd(); snprintf_P(command, sizeof(command), PSTR(D_CMND_UPGRADE " 1")); @@ -1760,7 +1777,7 @@ void HandleUploadDone(void) } SettingsBufferFree(); WSContentSend_P(PSTR("
")); - WSContentSend_P(HTTP_BTN_MAIN); + WSContentSpaceButton(BUTTON_MAIN); WSContentEnd(); } @@ -2039,7 +2056,7 @@ void HandleConsole(void) WSContentSend_P(HTTP_SCRIPT_CONSOL, Settings.web_refresh); WSContentSendStyle(); WSContentSend_P(HTTP_FORM_CMND); - WSContentSend_P(HTTP_BTN_MAIN); + WSContentSpaceButton(BUTTON_MAIN); WSContentEnd(); } diff --git a/sonoff/xdrv_02_mqtt.ino b/sonoff/xdrv_02_mqtt.ino index b79f6a866..ba3dabc09 100644 --- a/sonoff/xdrv_02_mqtt.ino +++ b/sonoff/xdrv_02_mqtt.ino @@ -281,7 +281,9 @@ void MqttPublishDirect(const char* topic, bool retained) char sretained[CMDSZ]; char slog_type[10]; +#ifdef USE_DEBUG_DRIVER ShowFreeMem(PSTR("MqttPublishDirect")); +#endif sretained[0] = '\0'; snprintf_P(slog_type, sizeof(slog_type), PSTR(D_LOG_RESULT)); @@ -931,7 +933,7 @@ void HandleMqttConfiguration(void) MQTT_FULLTOPIC, MQTT_FULLTOPIC, Settings.mqtt_fulltopic); WSContentSend_P(HTTP_FORM_END); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); } diff --git a/sonoff/xdrv_07_domoticz.ino b/sonoff/xdrv_07_domoticz.ino index 490c2e00d..0bd275d7c 100644 --- a/sonoff/xdrv_07_domoticz.ino +++ b/sonoff/xdrv_07_domoticz.ino @@ -482,7 +482,7 @@ void HandleDomoticzConfiguration(void) WSContentSend_P(HTTP_FORM_DOMOTICZ_TIMER, Settings.domoticz_update_timer); WSContentSend_P(PSTR("")); WSContentSend_P(HTTP_FORM_END); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); } diff --git a/sonoff/xdrv_09_timers.ino b/sonoff/xdrv_09_timers.ino index e8de5effa..9a85ad3c4 100644 --- a/sonoff/xdrv_09_timers.ino +++ b/sonoff/xdrv_09_timers.ino @@ -720,7 +720,7 @@ void HandleTimerConfiguration(void) #endif // USE_SUNRISE WSContentSend_P(HTTP_FORM_TIMER4); WSContentSend_P(HTTP_FORM_END); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); } diff --git a/sonoff/xdrv_10_rules.ino b/sonoff/xdrv_10_rules.ino index 4422d92b3..4d13bf6b9 100644 --- a/sonoff/xdrv_10_rules.ino +++ b/sonoff/xdrv_10_rules.ino @@ -387,7 +387,9 @@ bool RulesProcessEvent(char *json_event) { bool serviced = false; +#ifdef USE_DEBUG_DRIVER ShowFreeMem(PSTR("RulesProcessEvent")); +#endif String event_saved = json_event; event_saved.toUpperCase(); diff --git a/sonoff/xdrv_11_knx.ino b/sonoff/xdrv_11_knx.ino index 6f4a5b96d..5ab0c7c88 100644 --- a/sonoff/xdrv_11_knx.ino +++ b/sonoff/xdrv_11_knx.ino @@ -933,7 +933,7 @@ void HandleKNXConfiguration(void) } WSContentSend_P(PSTR("")); WSContentSend_P(HTTP_FORM_END); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); } diff --git a/sonoff/xdrv_13_display.ino b/sonoff/xdrv_13_display.ino index 3f779b821..f14680939 100644 --- a/sonoff/xdrv_13_display.ino +++ b/sonoff/xdrv_13_display.ino @@ -695,7 +695,9 @@ void DisplayJsonValue(const char* topic, const char* device, const char* mkey, c char source[Settings.display_cols[0] - Settings.display_cols[1]]; char svalue[Settings.display_cols[1] +1]; +#ifdef USE_DEBUG_DRIVER ShowFreeMem(PSTR("DisplayJsonValue")); +#endif memset(spaces, 0x20, sizeof(spaces)); spaces[sizeof(spaces) -1] = '\0'; diff --git a/sonoff/xdrv_interface.ino b/sonoff/xdrv_interface.ino index 7afea8531..7de5e1bb5 100644 --- a/sonoff/xdrv_interface.ino +++ b/sonoff/xdrv_interface.ino @@ -207,6 +207,7 @@ bool XdrvRulesProcess(void) return XdrvCall(FUNC_RULES_PROCESS); } +#ifdef USE_DEBUG_DRIVER void ShowFreeMem(const char *where) { char stemp[20]; @@ -214,6 +215,7 @@ void ShowFreeMem(const char *where) XdrvMailbox.data = stemp; XdrvCall(FUNC_FREE_MEM); } +#endif /*********************************************************************************************\ * Function call to all xdrv diff --git a/sonoff/xsns_34_hx711.ino b/sonoff/xsns_34_hx711.ino index 3405b377b..2072dc496 100644 --- a/sonoff/xsns_34_hx711.ino +++ b/sonoff/xsns_34_hx711.ino @@ -433,7 +433,7 @@ void HandleHxAction(void) dtostrfd((float)Settings.weight_item / 10000, 4, stemp2); WSContentSend_P(HTTP_FORM_HX711, stemp1, stemp2); WSContentSend_P(HTTP_FORM_END); - WSContentSend_P(HTTP_BTN_CONF); + WSContentSpaceButton(BUTTON_CONFIGURATION); WSContentEnd(); }