From 637fac5ae8d5a045afa5192b54c821aa87b4d2ac Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Mon, 15 Jan 2024 15:36:59 +0100
Subject: [PATCH] Add GUI sensor separators (#20495)
---
CHANGELOG.md | 3 ++-
RELEASENOTES.md | 2 ++
tasmota/include/i18n.h | 1 +
.../xdrv_01_9_webserver.ino | 26 +++++++++++++++++--
.../tasmota_xdrv_driver/xdrv_03_energy.ino | 4 +--
.../xdrv_03_esp32_energy.ino | 4 +--
.../xdrv_86_esp32_sonoff_spm.ino | 4 +--
.../tasmota_xx2c_global/xdrv_interface.ino | 2 ++
.../tasmota_xx2c_global/xsns_interface.ino | 2 ++
9 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63cbba7616af..eac36086e0ef 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,7 +11,8 @@ All notable changes to this project will be documented in this file.
- SML support for IM350 (#20474)
- LVGL `lv.str_arr` (#20480)
- ESP32 MI BLE support for Xiaomi LYWSD02MMC (#20381)
-- LVGL option to add `lv.keyboard` extra widget
+- LVGL option to add `lv.keyboard` extra widget (#20496)
+- GUI sensor separators (#20495)
### Breaking Changed
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 054ec73d30b9..d0afbb744ddf 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -128,6 +128,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Support for pipsolar inverter [#20408](https://github.com/arendst/Tasmota/issues/20408)
- Support for HardwareSerial invert [#15461](https://github.com/arendst/Tasmota/issues/15461)
- SML support for IM350 [#20474](https://github.com/arendst/Tasmota/issues/20474)
+- GUI sensor separators [#20495](https://github.com/arendst/Tasmota/issues/20495)
- ESP32 used UART information
- ESP32 experimental support GPIOViewer when ``define USE_ESP32_GPIO_VIEWER`` is enabled
- ESP32 MI BLE support for Xiaomi LYWSD02MMC [#20381](https://github.com/arendst/Tasmota/issues/20381)
@@ -145,6 +146,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Berry `tasmota.webcolor` [#20454](https://github.com/arendst/Tasmota/issues/20454)
- Berry `debug.caller` [#20470](https://github.com/arendst/Tasmota/issues/20470)
- LVGL `lv.str_arr` [#20480](https://github.com/arendst/Tasmota/issues/20480)
+- LVGL option to add `lv.keyboard` extra widget [#20496](https://github.com/arendst/Tasmota/issues/20496)
- HASPmota `haspmota.page_show()` to change page [#20333](https://github.com/arendst/Tasmota/issues/20333)
- HASPmota type `chart` [#20372](https://github.com/arendst/Tasmota/issues/20372)
- Matter support for password for remote Tasmota devices [#20296](https://github.com/arendst/Tasmota/issues/20296)
diff --git a/tasmota/include/i18n.h b/tasmota/include/i18n.h
index 481456201004..1455dd7f462d 100644
--- a/tasmota/include/i18n.h
+++ b/tasmota/include/i18n.h
@@ -934,6 +934,7 @@ const float kSpeedConversionFactor[] = {1, // none
// xdrv_02_webserver.ino
#ifdef USE_WEBSERVER
// {s} =
, {m} = | , {e} = |
+const char HTTP_SNS_HR[] PROGMEM = " {e}";
const char HTTP_SNS_F_TEMP[] PROGMEM = "{s}%s " D_TEMPERATURE "{m}%*_f " D_UNIT_DEGREE "%c{e}";
const char HTTP_SNS_F_VOLTAGE[] PROGMEM = "{s}%s " D_VOLTAGE "{m}%*_f " D_UNIT_VOLT "{e}";
const char HTTP_SNS_F_CURRENT_MA[] PROGMEM = "{s}%s " D_CURRENT "{m}%*_f " D_UNIT_MILLIAMPERE "{e}";
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
index 69bdaddb2e44..dbcc63fbe477 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
@@ -833,6 +833,8 @@ void _WSContentSendBuffer(bool decimal, const char * formatP, va_list arg) {
int len = strlen(content);
if (0 == len) { return; } // No content
+ WSContentSeparator(2); // Print separator on next WSContentSeparator(1)
+
if (decimal && (D_DECIMAL_SEPARATOR[0] != '.')) {
for (uint32_t i = 0; i < len; i++) {
if ('.' == content[i]) {
@@ -982,6 +984,24 @@ void WSContentSpaceButton(uint32_t title_index, bool show=true) {
WSContentButton(title_index, show);
}
+void WSContentSeparator(uint32_t state) {
+ // Send two column separator
+ static bool request = false;
+ switch (state) {
+ case 0: // Print separator (fall through to WSContentSeparator(1))
+ request = true;
+ case 1: // Print separator if needed
+ if (request) {
+ WSContentSend_P(HTTP_SNS_HR); // |
{e}
+ request = false;
+ }
+ break;
+ case 2: // Print separator on next WSContentSeparator(1)
+ request = true;
+ break;
+ }
+}
+
void WSContentSend_Temp(const char *types, float f_temperature) {
WSContentSend_PD(HTTP_SNS_F_TEMP, types, Settings->flag2.temperature_resolution, &f_temperature, TempUnit());
}
@@ -1467,12 +1487,14 @@ bool HandleRootStatusRefresh(void)
#else
WSContentBegin(200, CT_HTML);
#endif // USE_WEB_SSE
- WSContentSend_P(PSTR("{t}"));
+
+ WSContentSend_P(PSTR("{t}")); //
+ WSContentSeparator(0); // Print separator
if (Settings->web_time_end) {
WSContentSend_P(PSTR("{s}" D_TIMER_TIME "{m}%s{e}"), GetDateAndTime(DT_LOCAL).substring(Settings->web_time_start, Settings->web_time_end).c_str());
+ WSContentSeparator(0); // Print separator
}
XsnsXdrvCall(FUNC_WEB_SENSOR);
-
WSContentSend_P(PSTR(" "));
if (TasmotaGlobal.devices_present) {
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino
index 66bf50acd7bc..a5b0fd3e13d9 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino
@@ -1409,7 +1409,7 @@ void EnergyShow(bool json) {
// {s} | | Head1 | | Head2 | | {e}
// {s} | | Head1 | | Head2 | | Head3 | | {e}
// {s} | | Head1 | | Head2 | | Head3 | | Head4 | | {e}
- WSContentSend_P(PSTR(" {t}{s} | | ")); // First column is empty ({t} = , {s} = )
+ WSContentSend_P(PSTR(" |
---|
{t}{s} | ")); // First column is empty ({t} = , {s} = )
bool label_o = voltage_common;
bool no_label = (1 == Energy->phase_count);
char number[4];
@@ -1448,7 +1448,7 @@ void EnergyShow(bool json) {
WSContentSend_PD(HTTP_SNS_EXPORT_ACTIVE, WebEnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, single));
}
XnrgCall(FUNC_WEB_COL_SENSOR);
- WSContentSend_P(PSTR(" |
---|
{t}")); // {t} = - Define for next FUNC_WEB_SENSOR
+ WSContentSend_P(PSTR("
{t}")); // {t} = - Define for next FUNC_WEB_SENSOR
XnrgCall(FUNC_WEB_SENSOR);
#endif // USE_WEBSERVER
}
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino
index 228e8b9dedd3..a06c7125fc28 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino
@@ -1667,7 +1667,7 @@ void EnergyShow(bool json) {
Energy->gui_count = relay_show - Energy->gui_offset;
if (Energy->gui_count > Energy->Settings.gui_cols) { Energy->gui_count = Energy->Settings.gui_cols; }
- WSContentSend_P(PSTR("
")); // Close current table as we will use different column count
+ WSContentSend_P(PSTR("")); // Close current table as we will use different column count
bool label_o = voltage_common;
if (ENERGY_DISPLAY_TABS == Energy->Settings.gui_display) {
uint32_t tabs = (relay_show -1 + Energy->Settings.gui_cols) / Energy->Settings.gui_cols;
@@ -1731,7 +1731,7 @@ void EnergyShow(bool json) {
}
XnrgCall(FUNC_WEB_COL_SENSOR);
- WSContentSend_P(PSTR("
{t}")); // {t} = - Define for next FUNC_WEB_SENSOR
+ WSContentSend_P(PSTR("
{t}")); // {t} = - Define for next FUNC_WEB_SENSOR
XnrgCall(FUNC_WEB_SENSOR);
}
#endif // USE_WEBSERVER
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_86_esp32_sonoff_spm.ino b/tasmota/tasmota_xdrv_driver/xdrv_86_esp32_sonoff_spm.ino
index e9319da56443..a2fa0abc1eb0 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_86_esp32_sonoff_spm.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_86_esp32_sonoff_spm.ino
@@ -2283,7 +2283,7 @@ void SSPMEnergyShow(bool json) {
uint32_t offset = (Sspm->rotate >> 2) * 4;
uint32_t count = relay_show - offset;
if (count > 4) { count = 4; }
- WSContentSend_P(PSTR("
")); // Close current table as we will use different column count
+ WSContentSend_P(PSTR("")); // Close current table as we will use different column count
if (SPM_DISPLAY_TABS == Sspm->Settings.flag.display) {
uint32_t modules = relay_show / 4;
if (modules > 1) {
@@ -2317,7 +2317,7 @@ void SSPMEnergyShow(bool json) {
WSContentSend_PD(HTTP_SNS_ENERGY_TODAY, SSPMEnergyFormat(value_chr, Sspm->energy_today[0], Settings->flag2.energy_resolution, indirect, offset, count));
WSContentSend_PD(HTTP_SNS_ENERGY_YESTERDAY, SSPMEnergyFormat(value_chr, Sspm->Settings.energy_yesterday[0], Settings->flag2.energy_resolution, indirect, offset, count));
WSContentSend_PD(HTTP_SNS_ENERGY_TOTAL, SSPMEnergyFormat(value_chr, Sspm->energy_total[0], Settings->flag2.energy_resolution, indirect, offset, count));
- WSContentSend_P(PSTR("
{t}")); // {t} = - Define for next FUNC_WEB_SENSOR
+ WSContentSend_P(PSTR("
{t}")); // {t} = - Define for next FUNC_WEB_SENSOR
}
#endif // USE_WEBSERVER
}
diff --git a/tasmota/tasmota_xx2c_global/xdrv_interface.ino b/tasmota/tasmota_xx2c_global/xdrv_interface.ino
index 03ff1b2d9e2e..a1dfceea986b 100644
--- a/tasmota/tasmota_xx2c_global/xdrv_interface.ino
+++ b/tasmota/tasmota_xx2c_global/xdrv_interface.ino
@@ -1147,6 +1147,8 @@ bool XdrvCall(uint32_t function) {
result = xdrv_func_ptr[x](function);
+ if (FUNC_WEB_SENSOR == function) { WSContentSeparator(1); } // Show separator if needed
+
#ifdef USE_PROFILE_FUNCTION
#ifdef XFUNC_PTR_IN_ROM
uint32_t index = pgm_read_byte(kXdrvList + x);
diff --git a/tasmota/tasmota_xx2c_global/xsns_interface.ino b/tasmota/tasmota_xx2c_global/xsns_interface.ino
index 2f020b92d3bd..49f5311eba37 100644
--- a/tasmota/tasmota_xx2c_global/xsns_interface.ino
+++ b/tasmota/tasmota_xx2c_global/xsns_interface.ino
@@ -1130,6 +1130,8 @@ bool XsnsCall(uint32_t function) {
result = xsns_func_ptr[x](function);
+ if (FUNC_WEB_SENSOR == function) { WSContentSeparator(1); } // Show separator if needed
+
#ifdef USE_PROFILE_FUNCTION
#ifdef XFUNC_PTR_IN_ROM
uint32_t index = pgm_read_byte(kXsnsList + x);
---|