diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c5c5d335..0528af007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. - PubSubClient library from EspEasy v2.7.12 to Tasmota v2.8.12 - IRremoteESP8266 library from v2.7.15 to v2.7.16 - ESP32 core library from v1.0.5 to v1.0.6 +- Limit number of relay/button columns in GUI to 8 (#11546) ### Fixed - HC-SR04 on ESP32 release serial interface if not used (#11507) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 98644aa73..e5d4ecf30 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -111,6 +111,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - TuyaMcu dimmer timeout [#11121](https://github.com/arendst/Tasmota/issues/11121) - Rename epaper 42 commands [#11222](https://github.com/arendst/Tasmota/issues/11222) - DeepSleep announcement topic [#11223](https://github.com/arendst/Tasmota/issues/11223) +- Limit number of relay/button columns in GUI to 8 [#11546](https://github.com/arendst/Tasmota/issues/11546) ### Fixed - PN532 on ESP32 Serial flush both Tx and Rx buffers [#10910](https://github.com/arendst/Tasmota/issues/10910) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 7ecf647b4..ac8426388 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -878,6 +878,16 @@ void HandleWifiLogin(void) WSContentStop(); } +uint32_t WebDeviceColumns(void) { + const uint32_t max_columns = 8; + + uint32_t rows = TasmotaGlobal.devices_present / max_columns; + if (TasmotaGlobal.devices_present % max_columns) { rows++; } + uint32_t cols = TasmotaGlobal.devices_present / rows; + if (TasmotaGlobal.devices_present % rows) { cols++; } + return cols; +} + #ifdef USE_LIGHT void WebSliderColdWarm(void) { @@ -1034,21 +1044,25 @@ void HandleRoot(void) } } else { #endif // USE_SONOFF_IFAN + uint32_t cols = WebDeviceColumns(); for (uint32_t idx = 1; idx <= TasmotaGlobal.devices_present; idx++) { bool set_button = ((idx <= MAX_BUTTON_TEXT) && strlen(SettingsText(SET_BUTTON1 + idx -1))); #ifdef USE_SHUTTER int32_t ShutterWebButton; if (ShutterWebButton = IsShutterWebButton(idx)) { - WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / TasmotaGlobal.devices_present, idx, + WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / cols, idx, (set_button) ? SettingsText(SET_BUTTON1 + idx -1) : ((Settings.shutter_options[abs(ShutterWebButton)-1] & 2) /* is locked */ ? "-" : ((Settings.shutter_options[abs(ShutterWebButton)-1] & 8) /* invert web buttons */ ? ((ShutterWebButton>0) ? "▼" : "▲") : ((ShutterWebButton>0) ? "▲" : "▼"))), ""); - continue; + } else { +#endif // USE_SHUTTER + snprintf_P(stemp, sizeof(stemp), PSTR(" %d"), idx); + WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / cols, idx, + (set_button) ? SettingsText(SET_BUTTON1 + idx -1) : (cols < 5) ? PSTR(D_BUTTON_TOGGLE) : "", + (set_button) ? "" : (TasmotaGlobal.devices_present > 1) ? stemp : ""); +#ifdef USE_SHUTTER } #endif // USE_SHUTTER - snprintf_P(stemp, sizeof(stemp), PSTR(" %d"), idx); - WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / TasmotaGlobal.devices_present, idx, - (set_button) ? SettingsText(SET_BUTTON1 + idx -1) : (TasmotaGlobal.devices_present < 5) ? PSTR(D_BUTTON_TOGGLE) : "", - (set_button) ? "" : (TasmotaGlobal.devices_present > 1) ? stemp : ""); + if (0 == idx % cols) { WSContentSend_P(PSTR("")); } } #ifdef USE_SONOFF_IFAN } @@ -1249,7 +1263,6 @@ bool HandleRootStatusRefresh(void) if (TasmotaGlobal.devices_present) { WSContentSend_P(PSTR("{t}")); - uint32_t fsize = (TasmotaGlobal.devices_present < 5) ? 70 - (TasmotaGlobal.devices_present * 8) : 32; #ifdef USE_SONOFF_IFAN if (IsModuleIfan()) { WSContentSend_P(HTTP_DEVICE_STATE, 36, (bitRead(TasmotaGlobal.power, 0)) ? PSTR("bold") : PSTR("normal"), 54, GetStateText(bitRead(TasmotaGlobal.power, 0))); @@ -1258,9 +1271,13 @@ bool HandleRootStatusRefresh(void) WSContentSend_P(HTTP_DEVICE_STATE, 64, (fanspeed) ? PSTR("bold") : PSTR("normal"), 54, (fanspeed) ? svalue : GetStateText(0)); } else { #endif // USE_SONOFF_IFAN + uint32_t cols = WebDeviceColumns(); + uint32_t fontsize = (cols < 5) ? 70 - (cols * 8) : 32; for (uint32_t idx = 1; idx <= TasmotaGlobal.devices_present; idx++) { snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(TasmotaGlobal.power, idx -1)); - WSContentSend_P(HTTP_DEVICE_STATE, 100 / TasmotaGlobal.devices_present, (bitRead(TasmotaGlobal.power, idx -1)) ? PSTR("bold") : PSTR("normal"), fsize, (TasmotaGlobal.devices_present < 5) ? GetStateText(bitRead(TasmotaGlobal.power, idx -1)) : svalue); + WSContentSend_P(HTTP_DEVICE_STATE, 100 / cols, (bitRead(TasmotaGlobal.power, idx -1)) ? PSTR("bold") : PSTR("normal"), fontsize, + (cols < 5) ? GetStateText(bitRead(TasmotaGlobal.power, idx -1)) : svalue); + if (0 == idx % cols) { WSContentSend_P(PSTR("")); } } #ifdef USE_SONOFF_IFAN }