diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index 69272c8da..de23ea46c 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -273,6 +273,7 @@ const char HTTP_MSG_SLIDER_GRADIENT[] PROGMEM = "" ""; +// https://stackoverflow.com/questions/4057236/how-to-add-onload-event-to-a-div-element const char HTTP_MSG_EXEC_JAVASCRIPT[] PROGMEM = ""; -//const char HTTP_DEVICE_CONTROL[] PROGMEM = ""; // ?o is related to WebGetArg(PSTR("o"), tmp, sizeof(tmp)) -//const char HTTP_DEVICE_CONTROL[] PROGMEM = ""; // ?o is related to WebGetArg(PSTR("o"), tmp, sizeof(tmp)) const char HTTP_DEVICE_CONTROL[] PROGMEM = ""; // ?o is related to WebGetArg(PSTR("o"), tmp, sizeof(tmp)) - const char HTTP_DEVICE_STATE[] PROGMEM = "%s"; enum ButtonTitle { @@ -467,9 +465,9 @@ ESP8266WebServer *Webserver; struct WEB { String chunk_buffer = ""; // Could be max 2 * CHUNKED_BUFFER_SIZE uint32_t upload_size = 0; + uint32_t slider_update_time = 0; int slider[LST_MAX]; uint16_t upload_error = 0; - uint8_t slider_update[LST_MAX]; uint8_t state = HTTP_OFF; uint8_t upload_file_type; uint8_t config_block_count = 0; @@ -608,7 +606,6 @@ void StartWebserver(int type) for (uint32_t i = 0; i < LST_MAX; i++) { Web.slider[i] = -1; - Web.slider_update[i] = 0; } if (!Webserver) { @@ -1234,8 +1231,11 @@ void HandleRoot(void) { #endif WSContentSend_P(HTTP_SCRIPT_ROOT_PART2); WSContentSendStyle(); + WSContentSend_P(PSTR("
")); +#ifndef FIRMWARE_MINIMAL + if (TasmotaGlobal.devices_present) { uint32_t buttons_non_light = TasmotaGlobal.devices_present; uint32_t button_idx = 1; @@ -1252,8 +1252,7 @@ void HandleRoot(void) { #ifdef USE_SHUTTER // Chk for reduced toggle buttons used by shutters - uint32_t shutter_button = 0; // Bitmask for each button - + uint32_t shutter_button = 0; // Bitmask for each button // Find and skip dedicated shutter buttons if (buttons_non_light && Settings->flag3.shutter_mode) { // SetOption80 - Enable shutter support for (button_idx = 1; button_idx <= buttons_non_light; button_idx++) { @@ -1265,9 +1264,9 @@ void HandleRoot(void) { } #endif // USE_SHUTTER - if (buttons_non_light_non_shutter) { // Any non light AND non shutter button + if (buttons_non_light_non_shutter) { // Any non light AND non shutter button // Display toggle buttons - WSContentSend_P(HTTP_TABLE100); // "" + WSContentSend_P(HTTP_TABLE100); // "
" WSContentSend_P(PSTR("")); #ifdef USE_SONOFF_IFAN @@ -1517,7 +1516,6 @@ void HandleRoot(void) { } WSContentSend_P(PSTR("")); -#ifndef FIRMWARE_MINIMAL XdrvXsnsCall(FUNC_WEB_ADD_MAIN_BUTTON); #endif // Not FIRMWARE_MINIMAL @@ -1558,6 +1556,8 @@ bool HandleRootStatusRefresh(void) return false; } +#ifndef FIRMWARE_MINIMAL + #ifdef USE_SCRIPT_WEB_DISPLAY Script_Check_HTML_Setvars(); #endif @@ -1727,6 +1727,7 @@ bool HandleRootStatusRefresh(void) uint16_t hue; uint8_t sat; int current_value = -1; + uint32_t slider_update_time = millis(); for (uint32_t i = 0; i < LST_MAX; i++) { if (Web.slider[i] != -1) { if (!Settings->flag3.pwm_multi_channels) { // SetOption68 0 - Enable multi-channels PWM instead of Color PWM @@ -1750,12 +1751,13 @@ bool HandleRootStatusRefresh(void) current_value = changeUIntScale(Settings->light_color[i], 0, 255, 0, 100); } if (current_value != Web.slider[i]) { - Web.slider_update[i]++; - if (Web.slider_update[i] > 2) { // Allow two other users screen sync - Web.slider_update[i] = 0; + if (0 == Web.slider_update_time) { + Web.slider_update_time = slider_update_time + Settings->web_refresh; // Allow other users to sync screen + } + else if (slider_update_time > Web.slider_update_time) { + Web.slider_update_time = 1; // Allow multiple updates Web.slider[i] = current_value; } - // https://stackoverflow.com/questions/4057236/how-to-add-onload-event-to-a-div-element if (!msg_exec_javascript) { WSContentSend_P(HTTP_MSG_EXEC_JAVASCRIPT); // "shutter_options[i] & 1) ? D_OPEN : D_CLOSE,(Settings->shutter_options[i] & 1) ? D_CLOSE : D_OPEN, (Settings->shutter_options[i] & 1) ? (100 - ShutterRealToPercentPosition(-9999, i)) : ShutterRealToPercentPosition(-9999, i), i+1); - WSContentSeparator(3); // Don't print separator on next WSContentSeparator(1) - } -} - /*********************************************************************************************\ * Commands \*********************************************************************************************/ @@ -1976,11 +1969,6 @@ bool Xdrv27(uint32_t function) result = true; } break; -#ifdef USE_WEBSERVER - case FUNC_WEB_SENSOR: -// ShutterShow(); - break; -#endif // USE_WEBSERVER case FUNC_ACTIVE: result = true; break; diff --git a/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino b/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino index c98bc46d6..d56f22e4e 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino @@ -292,6 +292,7 @@ struct DALI { uint32_t bit_cycles; uint32_t last_activity; uint32_t received_dali_data; // Data received from DALI bus + uint32_t slider_update_time; uint8_t pin_rx; uint8_t pin_tx; uint8_t max_short_address; @@ -300,7 +301,6 @@ struct DALI { uint8_t last_dimmer; uint8_t dimmer[DALI_MAX_STORED]; uint8_t web_dimmer[DALI_MAX_STORED]; - uint8_t web_update[DALI_MAX_STORED]; uint8_t target; bool allow_light; bool last_power; @@ -1293,20 +1293,25 @@ void DaliShow(bool json) { } else { WSContentSend_P(PSTR("
")); // Terminate current {t} WSContentSend_P(HTTP_MSG_EXEC_JAVASCRIPT); // "sbflag1.dali_light; i <= Settings->mbflag2.dali_group_sliders; i++) { // DaliLight 0/1, DaliGroupSliders WSContentSend_P(PSTR("eb('k75%d').style='background:#%06x';"), i, WebColor((Dali->power[i]) ? COL_BUTTON : COL_FORM)); if (Dali->dimmer[i] != Dali->web_dimmer[i]) { - Dali->web_update[i]++; - if (Dali->web_update[i] > 2) { // Allow two other users screen sync - Dali->web_update[i] = 0; + if (0 == Dali->slider_update_time) { + Dali->slider_update_time = slider_update_time + Settings->web_refresh; // Allow other users to sync screen + } + else if (slider_update_time > Dali->slider_update_time) { + Dali->slider_update_time = 1; // Allow multiple updates Dali->web_dimmer[i] = Dali->dimmer[i]; } WSContentSend_P(PSTR("eb('i75%d').value='%d';"), i, changeUIntScale(Dali->dimmer[i], 0, 254, 0, 100)); - } } + if (1 == Dali->slider_update_time) { + Dali->slider_update_time = 0; + } WSContentSend_P(PSTR("\">{t}")); // Restart {t} = WSContentSeparator(3); // Don't print separator on next WSContentSeparator(1) #endif // USE_WEBSERVER