Change limit number of relay/button columns in GUI to 8

Change limit number of relay/button columns in GUI to 8 (#11546)
This commit is contained in:
Theo Arends 2021-04-02 15:33:05 +02:00
parent b0689af803
commit a756c7437e
3 changed files with 27 additions and 8 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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) ? "&#9660;" : "&#9650;") : ((ShutterWebButton>0) ? "&#9650;" : "&#9660;"))),
"");
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("</tr><tr>")); }
}
#ifdef USE_SONOFF_IFAN
}
@ -1249,7 +1263,6 @@ bool HandleRootStatusRefresh(void)
if (TasmotaGlobal.devices_present) {
WSContentSend_P(PSTR("{t}<tr>"));
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("</tr><tr>")); }
}
#ifdef USE_SONOFF_IFAN
}