diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index 3526aec65..ec03b9de1 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -1254,7 +1254,7 @@ int32_t IsShutterWebButton(uint32_t idx) { /*-------------------------------------------------------------------------------------------*/ -void WebGetDeviceCounts(uint32_t &buttons_non_light, uint32_t &buttons_non_light_non_shutter, uint32_t &shutter_button) { +void WebGetDeviceCounts(uint32_t &buttons_non_light, uint32_t &buttons_non_light_non_shutter, uint32_t &shutter_button_mask) { buttons_non_light = TasmotaGlobal.devices_present; #ifdef USE_LIGHT @@ -1266,7 +1266,7 @@ void WebGetDeviceCounts(uint32_t &buttons_non_light, uint32_t &buttons_non_light #endif // USE_LIGHT buttons_non_light_non_shutter = buttons_non_light; - shutter_button = 0; // Bitmask for each button + shutter_button_mask = 0; // Bitmask for each button #ifdef USE_SHUTTER // Chk for reduced toggle buttons used by shutters // Find and skip dedicated shutter buttons @@ -1274,7 +1274,7 @@ void WebGetDeviceCounts(uint32_t &buttons_non_light, uint32_t &buttons_non_light for (uint32_t button_idx = 1; button_idx <= buttons_non_light; button_idx++) { if (IsShutterWebButton(button_idx) != 0) { buttons_non_light_non_shutter--; - shutter_button |= (1 << (button_idx -1)); // Set button bit in bitmask + shutter_button_mask |= (1 << (button_idx -1)); // Set button bit in bitmask } } } @@ -1365,12 +1365,11 @@ void HandleRoot(void) { if (TasmotaGlobal.devices_present) { uint32_t buttons_non_light; uint32_t buttons_non_light_non_shutter; - uint32_t shutter_button; - WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, shutter_button); + uint32_t shutter_button_mask; + WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, shutter_button_mask); uint32_t button_idx = 1; - if (buttons_non_light_non_shutter) { // Any non light AND non shutter button - // Display toggle buttons + if (buttons_non_light_non_shutter) { // Any non light AND non shutter button - Show toggle buttons WSContentSend_P(HTTP_TABLE100); // "" WSContentSend_P(PSTR("")); @@ -1398,7 +1397,7 @@ void HandleRoot(void) { for (button_idx = 1; button_idx <= buttons_non_light; button_idx++) { #ifdef USE_SHUTTER - if (bitRead(shutter_button, button_idx -1)) { continue; } // Skip non-sequential shutter button + if (bitRead(shutter_button_mask, button_idx -1)) { continue; } // Skip non-sequential shutter button #endif // USE_SHUTTER bool set_button = ((button_idx <= MAX_BUTTON_TEXT) && strlen(GetWebButton(button_idx -1))); @@ -1417,33 +1416,29 @@ void HandleRoot(void) { } #ifdef USE_SHUTTER - if (shutter_button) { // Any button bit set - WSContentSend_P(HTTP_TABLE100); // "
" - - int32_t ShutterWebButton; - uint32_t shutter_button_idx = 1; + if (TasmotaGlobal.shutters_present) { // Any shutter present - Show shutter buttons and slider + WSContentSend_P(HTTP_TABLE100); // "
" + uint32_t shutter_button_idx; uint32_t shutter_button_idx_temp; - for (uint32_t shutter_idx = 0; shutter_idx < TasmotaGlobal.shutters_present ; shutter_idx++) { - while ((0 == shutter_button & (1 << (shutter_button_idx -1)))) { shutter_button_idx++; } - + for (uint32_t shutter_idx = 0; shutter_idx < TasmotaGlobal.shutters_present; shutter_idx++) { WSContentSend_P(PSTR("")); - shutter_button_idx++; // Left button is next button first (down) + uint32_t shutter_options = ShutterGetOptions(shutter_idx); + shutter_button_idx = ShutterGetStartRelay(shutter_idx) +1; // Left button is next button first (down) for (uint32_t j = 0; j < 2; j++) { - ShutterWebButton = IsShutterWebButton(shutter_button_idx); - shutter_button_idx_temp = ShutterGetOptions(abs(ShutterWebButton)-1) & 1 /* invert index */ ? shutter_button_idx + (j * 2) - 1 : shutter_button_idx; - // AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: j %d, ShutterWebButton %d, shutter_button_idx %d, shutter_idx %d, shutter_button_idx_temp %d"), j, ShutterWebButton, shutter_button_idx, shutter_idx, shutter_button_idx_temp); + shutter_button_idx_temp = (shutter_options & 1) ? shutter_button_idx + (j * 2) - 1 : shutter_button_idx; // Invert index +// AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: j %d, shutter_idx %d, shutter_button_idx %d, shutter_idx %d, shutter_button_idx_temp %d"), j, shutter_idx, shutter_button_idx, shutter_idx, shutter_button_idx_temp); WSContentSend_P(HTTP_DEVICE_CONTROL, 15, shutter_button_idx_temp, shutter_button_idx_temp, - ((ShutterGetOptions(abs(ShutterWebButton)-1) & 2) /* is locked */ ? "-" : - ((ShutterGetOptions(abs(ShutterWebButton)-1) & 1) /* invert web buttons */ ? (j ? "▼" : "▲") : (j ? "▲" : "▼"))), + ((shutter_options & 2) ? "-" : // Is locked + ((shutter_options & 1) ? (j ? "▼" : "▲") : (j ? "▲" : "▼"))), // Invert web buttons ""); - if (1 == j) { break; } + if (1 == j) { break; } // Both buttons shown - shutter_button_idx--; // Right button is previous button (up) + shutter_button_idx--; // Right button is previous button (up) bool set_button = ((shutter_button_idx <= MAX_BUTTON_TEXT) && strlen(GetWebButton(shutter_button_idx -1))); snprintf_P(stemp, sizeof(stemp), PSTR("Shutter %d"), shutter_idx +1); uint32_t shutter_real_to_percent_position = ShutterRealToPercentPosition(-9999, shutter_idx); - Web.shutter_slider[shutter_idx] = (ShutterGetOptions(shutter_idx) & 1) ? (100 - shutter_real_to_percent_position) : shutter_real_to_percent_position; + Web.shutter_slider[shutter_idx] = (shutter_options & 1) ? (100 - shutter_real_to_percent_position) : shutter_real_to_percent_position; WSContentSend_P(HTTP_MSG_SLIDER_SHUTTER, (set_button) ? HtmlEscape(GetWebButton(shutter_button_idx -1)).c_str() : stemp, shutter_idx +1, @@ -1451,20 +1446,18 @@ void HandleRoot(void) { shutter_idx +1); } WSContentSend_P(PSTR("")); - shutter_button_idx += 2; - } WSContentSend_P(PSTR("
")); - if (1 == button_idx) { - button_idx = shutter_button_idx; + if (1 == button_idx) { // No power/display button + button_idx = shutter_button_idx +2; } } #endif // USE_SHUTTER #ifdef USE_LIGHT - if (TasmotaGlobal.light_type) { - WSContentSend_P(HTTP_TABLE100); // "" + if (TasmotaGlobal.light_type) { // Any light - Show light button and slider(s) + WSContentSend_P(HTTP_TABLE100); // "
" uint8_t light_subtype = TasmotaGlobal.light_type &7; if (!Settings->flag3.pwm_multi_channels) { // SetOption68 0 - Enable multi-channels PWM instead of Color PWM @@ -1474,7 +1467,7 @@ void HandleRoot(void) { WebSliderColdWarm(); } - if (light_subtype > 2) { // No W or CW + if (light_subtype > 2) { // No W or CW uint16_t hue; uint8_t sat; LightGetHSB(&hue, &sat, nullptr); @@ -1908,8 +1901,8 @@ bool HandleRootStatusRefresh(void) { uint32_t buttons_non_light; uint32_t buttons_non_light_non_shutter; - uint32_t shutter_button; - WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, shutter_button); + uint32_t shutter_button_mask; + WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, shutter_button_mask); if (buttons_non_light_non_shutter <= 8) { // Any non light AND non shutter button WSContentSend_P(PSTR("{t}")); @@ -1918,7 +1911,7 @@ bool HandleRootStatusRefresh(void) { for (uint32_t idx = 1; idx <= buttons_non_light; idx++) { #ifdef USE_SHUTTER - if (bitRead(shutter_button, idx -1)) { continue; } // Skip non-sequential shutter button + if (bitRead(shutter_button_mask, idx -1)) { continue; } // Skip non-sequential shutter button #endif // USE_SHUTTER snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(TasmotaGlobal.power, idx -1));