From ab5208d2165ac99278df25e41db50cbb47fa5b0a Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:06:14 +0100 Subject: [PATCH] Refactor GUI --- .../xdrv_01_9_webserver.ino | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index d0da62759..db4e9540c 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -484,6 +484,8 @@ ESP8266WebServer *Webserver; struct WEB { String chunk_buffer = ""; // Could be max 2 * CHUNKED_BUFFER_SIZE uint32_t upload_size = 0; + uint32_t light_shutter_button_mask; + uint32_t buttons_non_light_non_shutter; uint32_t slider_update_time = 0; int slider[LST_MAX]; int8_t shutter_slider[16]; // MAX_SHUTTERS_ESP32 @@ -1257,9 +1259,9 @@ int32_t IsShutterWebButton(uint32_t idx) { /*-------------------------------------------------------------------------------------------*/ -void WebGetDeviceCounts(uint32_t &buttons_non_light_non_shutter, uint32_t &light_shutter_button_mask) { - buttons_non_light_non_shutter = TasmotaGlobal.devices_present; - light_shutter_button_mask = 0; // Bitmask for each light and/or shutter button +void WebGetDeviceCounts(void) { + Web.buttons_non_light_non_shutter = TasmotaGlobal.devices_present; + Web.light_shutter_button_mask = 0; // Bitmask for each light and/or shutter button #ifdef USE_LIGHT // Chk for reduced toggle buttons used by lights @@ -1268,8 +1270,8 @@ void WebGetDeviceCounts(uint32_t &buttons_non_light_non_shutter, uint32_t &light uint32_t light_device = LightDevice(); uint32_t light_devices = LightDevices(); for (uint32_t button_idx = light_device; button_idx < (light_device + light_devices); button_idx++) { - buttons_non_light_non_shutter--; - light_shutter_button_mask |= (1 << (button_idx -1)); // Set button bit in bitmask + Web.buttons_non_light_non_shutter--; + Web.light_shutter_button_mask |= (1 << (button_idx -1)); // Set button bit in bitmask } } #endif // USE_LIGHT @@ -1280,14 +1282,14 @@ void WebGetDeviceCounts(uint32_t &buttons_non_light_non_shutter, uint32_t &light // Find and skip dedicated shutter buttons for (uint32_t button_idx = 1; button_idx <= TasmotaGlobal.devices_present; button_idx++) { if (IsShutterWebButton(button_idx) != 0) { - buttons_non_light_non_shutter--; - light_shutter_button_mask |= (1 << (button_idx -1)); // Set button bit in bitmask + Web.buttons_non_light_non_shutter--; + Web.light_shutter_button_mask |= (1 << (button_idx -1)); // Set button bit in bitmask } } } #endif // USE_SHUTTER -// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HTP: DP %d, BNLNS %d, SB %08X"), TasmotaGlobal.devices_present, buttons_non_light_non_shutter, light_shutter_button_mask); +// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HTP: DP %d, BNLNS %d, SB %08X"), TasmotaGlobal.devices_present, Web.buttons_non_light_non_shutter, Web.light_shutter_button_mask); } #ifdef USE_LIGHT @@ -1370,12 +1372,10 @@ void HandleRoot(void) { #ifndef FIRMWARE_MINIMAL if (TasmotaGlobal.devices_present) { - uint32_t buttons_non_light_non_shutter; - uint32_t light_shutter_button_mask; - WebGetDeviceCounts(buttons_non_light_non_shutter, light_shutter_button_mask); - uint32_t button_idx = 1; + WebGetDeviceCounts(); - if (buttons_non_light_non_shutter) { // Any non light AND non shutter button - Show toggle buttons + uint32_t button_idx = 1; + if (Web.buttons_non_light_non_shutter) { // Any non light AND non shutter button - Show toggle buttons WSContentSend_P(HTTP_TABLE100); // "