Skip to content

Commit deb2278

Browse files
arendsthawa-lc4
authored andcommitted
Add GUI sensor separators (arendst#20495)
1 parent a02a9c5 commit deb2278

File tree

9 files changed

+39
-9
lines changed

9 files changed

+39
-9
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ All notable changes to this project will be documented in this file.
1111
- SML support for IM350 (#20474)
1212
- LVGL `lv.str_arr` (#20480)
1313
- ESP32 MI BLE support for Xiaomi LYWSD02MMC (#20381)
14-
- LVGL option to add `lv.keyboard` extra widget
14+
- LVGL option to add `lv.keyboard` extra widget (#20496)
15+
- GUI sensor separators (#20495)
1516

1617
### Breaking Changed
1718

RELEASENOTES.md

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
128128
- Support for pipsolar inverter [#20408](https://github.com/arendst/Tasmota/issues/20408)
129129
- Support for HardwareSerial invert [#15461](https://github.com/arendst/Tasmota/issues/15461)
130130
- SML support for IM350 [#20474](https://github.com/arendst/Tasmota/issues/20474)
131+
- GUI sensor separators [#20495](https://github.com/arendst/Tasmota/issues/20495)
131132
- ESP32 used UART information
132133
- ESP32 experimental support GPIOViewer when ``define USE_ESP32_GPIO_VIEWER`` is enabled
133134
- 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
145146
- Berry `tasmota.webcolor` [#20454](https://github.com/arendst/Tasmota/issues/20454)
146147
- Berry `debug.caller` [#20470](https://github.com/arendst/Tasmota/issues/20470)
147148
- LVGL `lv.str_arr` [#20480](https://github.com/arendst/Tasmota/issues/20480)
149+
- LVGL option to add `lv.keyboard` extra widget [#20496](https://github.com/arendst/Tasmota/issues/20496)
148150
- HASPmota `haspmota.page_show()` to change page [#20333](https://github.com/arendst/Tasmota/issues/20333)
149151
- HASPmota type `chart` [#20372](https://github.com/arendst/Tasmota/issues/20372)
150152
- Matter support for password for remote Tasmota devices [#20296](https://github.com/arendst/Tasmota/issues/20296)

tasmota/include/i18n.h

+1
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ const float kSpeedConversionFactor[] = {1, // none
934934
// xdrv_02_webserver.ino
935935
#ifdef USE_WEBSERVER
936936
// {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
937+
const char HTTP_SNS_HR[] PROGMEM = "<tr><td colspan=2><hr/>{e}";
937938
const char HTTP_SNS_F_TEMP[] PROGMEM = "{s}%s " D_TEMPERATURE "{m}%*_f " D_UNIT_DEGREE "%c{e}";
938939
const char HTTP_SNS_F_VOLTAGE[] PROGMEM = "{s}%s " D_VOLTAGE "{m}%*_f " D_UNIT_VOLT "{e}";
939940
const char HTTP_SNS_F_CURRENT_MA[] PROGMEM = "{s}%s " D_CURRENT "{m}%*_f " D_UNIT_MILLIAMPERE "{e}";

tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino

+24-2
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,8 @@ void _WSContentSendBuffer(bool decimal, const char * formatP, va_list arg) {
833833
int len = strlen(content);
834834
if (0 == len) { return; } // No content
835835

836+
WSContentSeparator(2); // Print separator on next WSContentSeparator(1)
837+
836838
if (decimal && (D_DECIMAL_SEPARATOR[0] != '.')) {
837839
for (uint32_t i = 0; i < len; i++) {
838840
if ('.' == content[i]) {
@@ -982,6 +984,24 @@ void WSContentSpaceButton(uint32_t title_index, bool show=true) {
982984
WSContentButton(title_index, show);
983985
}
984986

987+
void WSContentSeparator(uint32_t state) {
988+
// Send two column separator
989+
static bool request = false;
990+
switch (state) {
991+
case 0: // Print separator (fall through to WSContentSeparator(1))
992+
request = true;
993+
case 1: // Print separator if needed
994+
if (request) {
995+
WSContentSend_P(HTTP_SNS_HR); // <tr><td colspan=2><hr/>{e}
996+
request = false;
997+
}
998+
break;
999+
case 2: // Print separator on next WSContentSeparator(1)
1000+
request = true;
1001+
break;
1002+
}
1003+
}
1004+
9851005
void WSContentSend_Temp(const char *types, float f_temperature) {
9861006
WSContentSend_PD(HTTP_SNS_F_TEMP, types, Settings->flag2.temperature_resolution, &f_temperature, TempUnit());
9871007
}
@@ -1467,12 +1487,14 @@ bool HandleRootStatusRefresh(void)
14671487
#else
14681488
WSContentBegin(200, CT_HTML);
14691489
#endif // USE_WEB_SSE
1470-
WSContentSend_P(PSTR("{t}"));
1490+
1491+
WSContentSend_P(PSTR("{t}")); // <table style='width:100%'>
1492+
WSContentSeparator(0); // Print separator
14711493
if (Settings->web_time_end) {
14721494
WSContentSend_P(PSTR("{s}" D_TIMER_TIME "{m}%s{e}"), GetDateAndTime(DT_LOCAL).substring(Settings->web_time_start, Settings->web_time_end).c_str());
1495+
WSContentSeparator(0); // Print separator
14731496
}
14741497
XsnsXdrvCall(FUNC_WEB_SENSOR);
1475-
14761498
WSContentSend_P(PSTR("</table>"));
14771499

14781500
if (TasmotaGlobal.devices_present) {

tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ void EnergyShow(bool json) {
14091409
// {s}</th><th></th><th>Head1</th><th></th><th>Head2</th><th></th><td>{e}
14101410
// {s}</th><th></th><th>Head1</th><th></th><th>Head2</th><th></th><th>Head3</th><th></th><td>{e}
14111411
// {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}
1412-
WSContentSend_P(PSTR("</table><hr/>{t}{s}</th><th></th>")); // First column is empty ({t} = <table style='width:100%'>, {s} = <tr><th>)
1412+
WSContentSend_P(PSTR("</table>{t}{s}</th><th></th>")); // First column is empty ({t} = <table style='width:100%'>, {s} = <tr><th>)
14131413
bool label_o = voltage_common;
14141414
bool no_label = (1 == Energy->phase_count);
14151415
char number[4];
@@ -1448,7 +1448,7 @@ void EnergyShow(bool json) {
14481448
WSContentSend_PD(HTTP_SNS_EXPORT_ACTIVE, WebEnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, single));
14491449
}
14501450
XnrgCall(FUNC_WEB_COL_SENSOR);
1451-
WSContentSend_P(PSTR("</table><hr/>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
1451+
WSContentSend_P(PSTR("</table>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
14521452
XnrgCall(FUNC_WEB_SENSOR);
14531453
#endif // USE_WEBSERVER
14541454
}

tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ void EnergyShow(bool json) {
16671667
Energy->gui_count = relay_show - Energy->gui_offset;
16681668
if (Energy->gui_count > Energy->Settings.gui_cols) { Energy->gui_count = Energy->Settings.gui_cols; }
16691669

1670-
WSContentSend_P(PSTR("</table><hr/>")); // Close current table as we will use different column count
1670+
WSContentSend_P(PSTR("</table>")); // Close current table as we will use different column count
16711671
bool label_o = voltage_common;
16721672
if (ENERGY_DISPLAY_TABS == Energy->Settings.gui_display) {
16731673
uint32_t tabs = (relay_show -1 + Energy->Settings.gui_cols) / Energy->Settings.gui_cols;
@@ -1731,7 +1731,7 @@ void EnergyShow(bool json) {
17311731
}
17321732

17331733
XnrgCall(FUNC_WEB_COL_SENSOR);
1734-
WSContentSend_P(PSTR("</table><hr/>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
1734+
WSContentSend_P(PSTR("</table>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
17351735
XnrgCall(FUNC_WEB_SENSOR);
17361736
}
17371737
#endif // USE_WEBSERVER

tasmota/tasmota_xdrv_driver/xdrv_86_esp32_sonoff_spm.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -2283,7 +2283,7 @@ void SSPMEnergyShow(bool json) {
22832283
uint32_t offset = (Sspm->rotate >> 2) * 4;
22842284
uint32_t count = relay_show - offset;
22852285
if (count > 4) { count = 4; }
2286-
WSContentSend_P(PSTR("</table><hr/>")); // Close current table as we will use different column count
2286+
WSContentSend_P(PSTR("</table>")); // Close current table as we will use different column count
22872287
if (SPM_DISPLAY_TABS == Sspm->Settings.flag.display) {
22882288
uint32_t modules = relay_show / 4;
22892289
if (modules > 1) {
@@ -2317,7 +2317,7 @@ void SSPMEnergyShow(bool json) {
23172317
WSContentSend_PD(HTTP_SNS_ENERGY_TODAY, SSPMEnergyFormat(value_chr, Sspm->energy_today[0], Settings->flag2.energy_resolution, indirect, offset, count));
23182318
WSContentSend_PD(HTTP_SNS_ENERGY_YESTERDAY, SSPMEnergyFormat(value_chr, Sspm->Settings.energy_yesterday[0], Settings->flag2.energy_resolution, indirect, offset, count));
23192319
WSContentSend_PD(HTTP_SNS_ENERGY_TOTAL, SSPMEnergyFormat(value_chr, Sspm->energy_total[0], Settings->flag2.energy_resolution, indirect, offset, count));
2320-
WSContentSend_P(PSTR("</table><hr/>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
2320+
WSContentSend_P(PSTR("</table>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
23212321
}
23222322
#endif // USE_WEBSERVER
23232323
}

tasmota/tasmota_xx2c_global/xdrv_interface.ino

+2
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,8 @@ bool XdrvCall(uint32_t function) {
11471147

11481148
result = xdrv_func_ptr[x](function);
11491149

1150+
if (FUNC_WEB_SENSOR == function) { WSContentSeparator(1); } // Show separator if needed
1151+
11501152
#ifdef USE_PROFILE_FUNCTION
11511153
#ifdef XFUNC_PTR_IN_ROM
11521154
uint32_t index = pgm_read_byte(kXdrvList + x);

tasmota/tasmota_xx2c_global/xsns_interface.ino

+2
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,8 @@ bool XsnsCall(uint32_t function) {
11301130

11311131
result = xsns_func_ptr[x](function);
11321132

1133+
if (FUNC_WEB_SENSOR == function) { WSContentSeparator(1); } // Show separator if needed
1134+
11331135
#ifdef USE_PROFILE_FUNCTION
11341136
#ifdef XFUNC_PTR_IN_ROM
11351137
uint32_t index = pgm_read_byte(kXsnsList + x);

0 commit comments

Comments
 (0)