Add command `SetOption138 1`

Add command ``SetOption138 1`` to switch GUI energy multi-column layout from left/center (0) to right (1) align (#15342)
This commit is contained in:
Theo Arends 2022-04-12 10:22:32 +02:00
parent 089ace9d35
commit a4cf023357
4 changed files with 21 additions and 11 deletions

View File

@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
## [11.0.0.7] ## [11.0.0.7]
### Added ### Added
- HX711 command ``Sensor34 10 0|1|<weight in gram>`` to set HX711 fixed tare (0 = use auto tare, 1 = use calibrated tare, Any other value is user selected tare) - HX711 command ``Sensor34 10 0|1|<weight in gram>`` to set HX711 fixed tare (0 = use auto tare, 1 = use calibrated tare, Any other value is user selected tare)
- Command ``SetOption138 1`` to switch GUI energy multi-column layout from left/center (0) to right (1) align (#15342)
### Changed ### Changed
- HX711 commands ``Sensor34 11 <valueA>`` and ``Sensor34 12 <valueB>`` to use HX711 absolute weight conversion (#15292) - HX711 commands ``Sensor34 11 <valueA>`` and ``Sensor34 12 <valueB>`` to use HX711 absolute weight conversion (#15292)
@ -31,6 +32,7 @@ All notable changes to this project will be documented in this file.
- Support for improv as used by esp-web-tools - Support for improv as used by esp-web-tools
- Command ``IfxSensor 1`` to send non-teleperiod data to influxdb - Command ``IfxSensor 1`` to send non-teleperiod data to influxdb
- ESP32 Support for OpenHASP v1.0 by Stephan Hadinger (#15307) - ESP32 Support for OpenHASP v1.0 by Stephan Hadinger (#15307)
- Command ``SetOption137 1`` to avoid MQTT publish of defined Tuya CMDs if SO66 is active (#15267)
### Changed ### Changed
- Remove support for Internet Explorer by allowing ECMAScript6 syntax using less JavaScript code bytes (#15280) - Remove support for Internet Explorer by allowing ECMAScript6 syntax using less JavaScript code bytes (#15280)

View File

@ -107,6 +107,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
### Added ### Added
- Command ``SetOption135 1`` to disable LVGL splash screen - Command ``SetOption135 1`` to disable LVGL splash screen
- Command ``SetOption136 1`` to disable single sensor reports from Tuya devices while keeping teleperiod reports [#15216](https://github.com/arendst/Tasmota/issues/15216) - Command ``SetOption136 1`` to disable single sensor reports from Tuya devices while keeping teleperiod reports [#15216](https://github.com/arendst/Tasmota/issues/15216)
- Command ``SetOption137 1`` to avoid MQTT publish of defined Tuya CMDs if SO66 is active [#15267](https://github.com/arendst/Tasmota/issues/15267)
- Command ``SetOption138 1`` to switch GUI energy multi-column layout from left/center (0) to right (1) align [#15342](https://github.com/arendst/Tasmota/issues/15342)
- Command ``SspmMap 0`` to reset Sonoff SPM default mapping - Command ``SspmMap 0`` to reset Sonoff SPM default mapping
- Command ``TcpConnect <port><ip_address>`` to add client connection mode [#14874](https://github.com/arendst/Tasmota/issues/14874) - Command ``TcpConnect <port><ip_address>`` to add client connection mode [#14874](https://github.com/arendst/Tasmota/issues/14874)
- Command ``RfTimeout 100..60000`` to disable duplicate RfReceive. Default 1000 [#15061](https://github.com/arendst/Tasmota/issues/15061) - Command ``RfTimeout 100..60000`` to disable duplicate RfReceive. Default 1000 [#15061](https://github.com/arendst/Tasmota/issues/15061)
@ -132,6 +134,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
- ESP32 TasmotaSerial uart mapping to support multiple ``begin()`` and implement ``getUart()`` [#14981](https://github.com/arendst/Tasmota/issues/14981) - ESP32 TasmotaSerial uart mapping to support multiple ``begin()`` and implement ``getUart()`` [#14981](https://github.com/arendst/Tasmota/issues/14981)
### Breaking Changed ### Breaking Changed
- Remove support for Internet Explorer by allowing ECMAScript6 syntax using less JavaScript code bytes [#15280](https://github.com/arendst/Tasmota/issues/15280)
### Changed ### Changed
- Adafruit BusIO library from v1.0.10 to v1.11.0 - Adafruit BusIO library from v1.0.10 to v1.11.0
@ -139,7 +142,6 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
- Sonoff SPM increase max number of relays supported to 32 (8 SPM-4Relay modules) - Sonoff SPM increase max number of relays supported to 32 (8 SPM-4Relay modules)
- Extent number of pulsetimers from 8 to 32 [#8266](https://github.com/arendst/Tasmota/issues/8266) - Extent number of pulsetimers from 8 to 32 [#8266](https://github.com/arendst/Tasmota/issues/8266)
- Consolidate three RTC chip drivers (DS3231, BM8563, PCF85363) into one driver updating RTC as soon as possible after restart - Consolidate three RTC chip drivers (DS3231, BM8563, PCF85363) into one driver updating RTC as soon as possible after restart
- Remove support for Internet Explorer by allowing ECMAScript6 syntax using less JavaScript code bytes [#15280](https://github.com/arendst/Tasmota/issues/15280)
- DS3231 I2C address define ``USE_RTC_ADDR`` into ``DS3231_ADDRESS`` - DS3231 I2C address define ``USE_RTC_ADDR`` into ``DS3231_ADDRESS``
- Display of energy values in GUI use columns when define ``USE_ENERGY_COLUMN_GUI`` is enabled (default) - Display of energy values in GUI use columns when define ``USE_ENERGY_COLUMN_GUI`` is enabled (default)
- ESP8266 Shrinked tasmota-minimal.bin by removing all commands except ``Upgrade``, ``Upload``, ``OtaUrl``, ``Seriallog``, ``Weblog`` and ``Restart`` - ESP8266 Shrinked tasmota-minimal.bin by removing all commands except ``Upgrade``, ``Upload``, ``OtaUrl``, ``Seriallog``, ``Weblog`` and ``Restart``

View File

@ -167,7 +167,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t display_no_splash : 1; // bit 21 (v11.0.0.2) - SetOption135 - (Display & LVGL) forece disbabling default splash screen uint32_t display_no_splash : 1; // bit 21 (v11.0.0.2) - SetOption135 - (Display & LVGL) forece disbabling default splash screen
uint32_t tuyasns_no_immediate : 1; // bit 22 (v11.0.0.4) - SetOption136 - (TuyaSNS) When ON disable publish single SNS value on Tuya Receive (keep Teleperiod) uint32_t tuyasns_no_immediate : 1; // bit 22 (v11.0.0.4) - SetOption136 - (TuyaSNS) When ON disable publish single SNS value on Tuya Receive (keep Teleperiod)
uint32_t tuya_exclude_from_mqtt : 1; // bit 23 (v11.0.0.5) - SetOption137 - (Tuya) When Set, avoid the (MQTT-) publish of defined Tuya CMDs (see xdrv_16_tuyamcu.ino) if SetOption66 is active uint32_t tuya_exclude_from_mqtt : 1; // bit 23 (v11.0.0.5) - SetOption137 - (Tuya) When Set, avoid the (MQTT-) publish of defined Tuya CMDs (see xdrv_16_tuyamcu.ino) if SetOption66 is active
uint32_t spare24 : 1; // bit 24 uint32_t gui_table_align : 1; // bit 24 (v11.0.0.7) - SetOption138 - (GUI) Align (energy) table values left (0) or right (1)
uint32_t spare25 : 1; // bit 25 uint32_t spare25 : 1; // bit 25
uint32_t spare26 : 1; // bit 26 uint32_t spare26 : 1; // bit 26
uint32_t spare27 : 1; // bit 27 uint32_t spare27 : 1; // bit 27

View File

@ -178,13 +178,21 @@ char* WebEnergyFormat(char* result, float* input, uint32_t resolution, uint32_t
} }
} }
#ifdef USE_ENERGY_COLUMN_GUI #ifdef USE_ENERGY_COLUMN_GUI
ext_snprintf_P(result, TOPSZ *2, PSTR("</td>")); // Skip first column ext_snprintf_P(result, TOPSZ *2, PSTR("</td>")); // Skip first column
if ((Energy.phase_count > 1) && single) { // Need to set colspan so need a new column if ((Energy.phase_count > 1) && single) { // Need to set colspan so need new columns
// ext_snprintf_P(result, TOPSZ *2, PSTR("%s<td colspan='%d' style='text-align:center'>%*_f</td><td>&nbsp;</td>"), result, (Energy.phase_count *2) -1, resolution, &input[0]); // </td><td colspan='3' style='text-align:right'>1.23</td><td>&nbsp;</td><td>
ext_snprintf_P(result, TOPSZ *2, PSTR("%s<td colspan='%d' style='text-align:right'>%*_f</td><td>&nbsp;</td>"), result, (Energy.phase_count *2) -1, resolution, &input[0]); // </td><td colspan='5' style='text-align:right'>1.23</td><td>&nbsp;</td><td>
// </td><td colspan='7' style='text-align:right'>1.23</td><td>&nbsp;</td><td>
ext_snprintf_P(result, TOPSZ *2, PSTR("%s<td colspan='%d' style='text-align:%s'>%*_f</td><td>&nbsp;</td>"),
result, (Energy.phase_count *2) -1, (Settings->flag5.gui_table_align)?PSTR("right"):PSTR("center"), resolution, &input[0]);
} else { } else {
// </td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td>
// </td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td>
// </td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td>
// </td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td style='text-align:right'>1.23</td><td>&nbsp;</td><td>
for (uint32_t i = 0; i < Energy.phase_count; i++) { for (uint32_t i = 0; i < Energy.phase_count; i++) {
ext_snprintf_P(result, TOPSZ *2, PSTR("%s<td style='text-align:right'>%*_f</td><td>&nbsp;</td>"), result, resolution, &input[i]); ext_snprintf_P(result, TOPSZ *2, PSTR("%s<td style='text-align:%s'>%*_f</td><td>&nbsp;</td>"),
result, (Settings->flag5.gui_table_align)?PSTR("right"):PSTR("left"), resolution, &input[i]);
} }
} }
ext_snprintf_P(result, TOPSZ *2, PSTR("%s<td>"), result); ext_snprintf_P(result, TOPSZ *2, PSTR("%s<td>"), result);
@ -1234,19 +1242,17 @@ void EnergyShow(bool json) {
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
} else { } else {
#ifdef USE_ENERGY_COLUMN_GUI #ifdef USE_ENERGY_COLUMN_GUI
// Need a new table supporting more columns // Need a new table supporting more columns using empty columns (with &nbsp; in data rows) as easy column spacing
// {s}</th><th></th><th>Head1</th><th></th><td>{e} // {s}</th><th></th><th>Head1</th><th></th><td>{e}
// {s}</th><th></th><th>Head1</th><th></th><th>Head2</th><th></th><td>{e} // {s}</th><th></th><th>Head1</th><th></th><th>Head2</th><th></th><td>{e}
// {s}</th><th></th><th>Head1</th><th></th><th>Head2</th><th></th><th>Head3</th><th></th><td>{e} // {s}</th><th></th><th>Head1</th><th></th><th>Head2</th><th></th><th>Head3</th><th></th><td>{e}
// {s}</th><th></th><th>Head1</th><th></th><th>Head2</th><th></th><th>Head3</th><th></th><th>Head4</th><th></th><td>{e}
WSContentSend_P(PSTR("</table>{t}{s}</th><th></th>")); // First column is empty ({t} = <table style='width:100%'>, {s} = <tr><th>) WSContentSend_P(PSTR("</table>{t}{s}</th><th></th>")); // First column is empty ({t} = <table style='width:100%'>, {s} = <tr><th>)
bool no_label = Energy.voltage_common || (1 == Energy.phase_count); bool no_label = Energy.voltage_common || (1 == Energy.phase_count);
for (uint32_t i = 0; i < Energy.phase_count; i++) { for (uint32_t i = 0; i < Energy.phase_count; i++) {
WSContentSend_P(PSTR("<th style='text-align:center'>%s%s<th></th>"), (no_label)?"":"L", (no_label)?"":itoa(i +1, value_chr, 10)); WSContentSend_P(PSTR("<th style='text-align:center'>%s%s<th></th>"), (no_label)?"":"L", (no_label)?"":itoa(i +1, value_chr, 10));
} }
WSContentSend_P(PSTR("<td>{e}")); // Last column is units ({e} = </td></tr>) WSContentSend_P(PSTR("<td>{e}")); // Last column is units ({e} = </td></tr>)
#endif // USE_ENERGY_COLUMN_GUI #endif // USE_ENERGY_COLUMN_GUI
if (Energy.voltage_available) { if (Energy.voltage_available) {
WSContentSend_PD(HTTP_SNS_VOLTAGE, WebEnergyFormat(value_chr, Energy.voltage, Settings->flag2.voltage_resolution, Energy.voltage_common)); WSContentSend_PD(HTTP_SNS_VOLTAGE, WebEnergyFormat(value_chr, Energy.voltage, Settings->flag2.voltage_resolution, Energy.voltage_common));