Consolidate Energy Column Gui

This commit is contained in:
Theo Arends 2023-03-25 15:16:06 +01:00
parent 9ae7b86efc
commit 1e1c536a50
9 changed files with 0 additions and 49 deletions

View File

@ -824,7 +824,6 @@
// -- Power monitoring sensors --------------------
#define USE_ENERGY_SENSOR // Add support for Energy Monitors (+14k code)
#define USE_ENERGY_COLUMN_GUI // Add support for column display in GUI (+0k5 code)
#define USE_ENERGY_MARGIN_DETECTION // Add support for Energy Margin detection (+1k6 code)
#define USE_ENERGY_POWER_LIMIT // Add additional support for Energy Power Limit detection (+1k2 code)
#define USE_ENERGY_DUMMY // Add support for dummy Energy monitor allowing user values (+0k7 code)

View File

@ -215,7 +215,6 @@ char* WebEnergyFmt(float* input, uint32_t resolution, uint32_t single) {
single = 0;
}
}
#ifdef USE_ENERGY_COLUMN_GUI
ext_snprintf_P(Energy->value, GUISZ, PSTR("</td>")); // Skip first column
if ((Energy->phase_count > 1) && single) { // Need to set colspan so need new columns
// </td><td colspan='3' style='text-align:right'>1.23</td><td>&nbsp;</td><td>
@ -234,13 +233,6 @@ char* WebEnergyFmt(float* input, uint32_t resolution, uint32_t single) {
}
}
ext_snprintf_P(Energy->value, GUISZ, PSTR("%s<td>"), Energy->value);
#else // not USE_ENERGY_COLUMN_GUI
uint32_t index = (single) ? 1 : Energy->phase_count; // 1,2,3
Energy->value[vidx][0] = '\0';
for (uint32_t i = 0; i < index; i++) {
ext_snprintf_P(Energy->value, GUISZ, PSTR("%s%s%*_f"), Energy->value, (i)?" / ":"", resolution, &input[i]);
}
#endif // USE_ENERGY_COLUMN_GUI
return Energy->value;
}
#endif // USE_WEBSERVER
@ -1389,7 +1381,6 @@ void EnergyShow(bool json) {
#endif // USE_KNX
#ifdef USE_WEBSERVER
} else {
#ifdef USE_ENERGY_COLUMN_GUI
// 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><th>Head2</th><th></th><td>{e}
@ -1403,7 +1394,6 @@ void EnergyShow(bool json) {
WSContentSend_P(PSTR("<th style='text-align:center'>%s%s<th></th>"), (no_label)?"":(label_o)?"O":"L", (no_label)?"":itoa(i +1, number, 10));
}
WSContentSend_P(PSTR("<td>{e}")); // Last column is units ({e} = </td></tr>)
#endif // USE_ENERGY_COLUMN_GUI
if (Energy->voltage_available) {
WSContentSend_PD(HTTP_SNS_VOLTAGE, WebEnergyFmt(Energy->voltage, Settings->flag2.voltage_resolution, voltage_common));
}
@ -1431,10 +1421,8 @@ void EnergyShow(bool json) {
uint32_t single = (!isnan(Energy->export_active[1]) && !isnan(Energy->export_active[2])) ? 2 : 1;
WSContentSend_PD(HTTP_SNS_EXPORT_ACTIVE, WebEnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, single));
}
#ifdef USE_ENERGY_COLUMN_GUI
XnrgCall(FUNC_WEB_COL_SENSOR);
WSContentSend_P(PSTR("</table><hr/>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
#endif // USE_ENERGY_COLUMN_GUI
XnrgCall(FUNC_WEB_SENSOR);
#endif // USE_WEBSERVER
}

View File

@ -442,7 +442,6 @@ char* WebEnergyFmt(float* input, uint32_t resolution, uint32_t single) {
single = 0;
}
}
#ifdef USE_ENERGY_COLUMN_GUI
ext_snprintf_P(Energy->value, GUISZ, PSTR("</td>")); // Skip first column
if ((Energy->gui_count > 1) && single) { // Need to set colspan so need new columns
// </td><td colspan='3' style='text-align:right'>1.23</td><td>&nbsp;</td><td>
@ -461,13 +460,6 @@ char* WebEnergyFmt(float* input, uint32_t resolution, uint32_t single) {
}
}
ext_snprintf_P(Energy->value, GUISZ, PSTR("%s<td>"), Energy->value);
#else // not USE_ENERGY_COLUMN_GUI
uint32_t index = (single) ? 1 : Energy->phase_count; // 1,2,3
Energy->value[0] = '\0';
for (uint32_t i = 0; i < index; i++) {
ext_snprintf_P(Energy->value, GUISZ, PSTR("%s%s%*_f"), Energy->value, (i)?" / ":"", resolution, &input[i]);
}
#endif // USE_ENERGY_COLUMN_GUI
return Energy->value;
}
#endif // USE_WEBSERVER
@ -1622,7 +1614,6 @@ void EnergyShow(bool json) {
#endif // USE_KNX
#ifdef USE_WEBSERVER
} else {
#ifdef USE_ENERGY_COLUMN_GUI
uint8_t relays[ENERGY_MAX_PHASES];
uint32_t relay_show = 0;
power_t power = TasmotaGlobal.power;
@ -1683,7 +1674,6 @@ void EnergyShow(bool json) {
(no_label) ? "" : itoa(relays[Energy->gui_offset +i], number, 10));
}
WSContentSend_P(PSTR("<td>{e}")); // Last column is units ({e} = </td></tr>)
#endif // USE_ENERGY_COLUMN_GUI
if (Energy->voltage_available) {
WSContentSend_PD(HTTP_SNS_VOLTAGE, WebEnergyFmt(Energy->voltage, Settings->flag2.voltage_resolution, voltage_common));
}
@ -1712,10 +1702,8 @@ void EnergyShow(bool json) {
WSContentSend_PD(HTTP_SNS_EXPORT_ACTIVE, WebEnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, single));
}
#ifdef USE_ENERGY_COLUMN_GUI
XnrgCall(FUNC_WEB_COL_SENSOR);
WSContentSend_P(PSTR("</table><hr/>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
#endif // USE_ENERGY_COLUMN_GUI
XnrgCall(FUNC_WEB_SENSOR);
#endif // USE_WEBSERVER
}

View File

@ -236,11 +236,7 @@ bool Xnrg08(uint32_t function)
Sdm220Show(1);
break;
#ifdef USE_WEBSERVER
#ifdef USE_ENERGY_COLUMN_GUI
case FUNC_WEB_COL_SENSOR:
#else // not USE_ENERGY_COLUMN_GUI
case FUNC_WEB_SENSOR:
#endif // USE_ENERGY_COLUMN_GUI
Sdm220Show(0);
break;
#endif // USE_WEBSERVER

View File

@ -264,11 +264,7 @@ bool Xnrg13(uint32_t function)
FifLEShow(1);
break;
#ifdef USE_WEBSERVER
#ifdef USE_ENERGY_COLUMN_GUI
case FUNC_WEB_COL_SENSOR:
#else // not USE_ENERGY_COLUMN_GUI
case FUNC_WEB_SENSOR:
#endif // USE_ENERGY_COLUMN_GUI
FifLEShow(0);
break;
#endif // USE_WEBSERVER

View File

@ -183,11 +183,7 @@ bool Xnrg18(uint32_t function)
Sdm72Show(1);
break;
#ifdef USE_WEBSERVER
#ifdef USE_ENERGY_COLUMN_GUI
case FUNC_WEB_COL_SENSOR:
#else // not USE_ENERGY_COLUMN_GUI
case FUNC_WEB_SENSOR:
#endif // USE_ENERGY_COLUMN_GUI
Sdm72Show(0);
break;
#endif // USE_WEBSERVER

View File

@ -248,11 +248,7 @@ bool Xnrg21(uint32_t function)
Sdm230Show(1);
break;
#ifdef USE_WEBSERVER
#ifdef USE_ENERGY_COLUMN_GUI
case FUNC_WEB_COL_SENSOR:
#else // not USE_ENERGY_COLUMN_GUI
case FUNC_WEB_SENSOR:
#endif // USE_ENERGY_COLUMN_GUI
Sdm230Show(0);
break;
#endif // USE_WEBSERVER

View File

@ -773,11 +773,7 @@ bool Xnrg23(uint32_t function) {
Ade7880Show(1);
break;
#ifdef USE_WEBSERVER
#ifdef USE_ENERGY_COLUMN_GUI
case FUNC_WEB_COL_SENSOR:
#else // not USE_ENERGY_COLUMN_GUI
case FUNC_WEB_SENSOR:
#endif // USE_ENERGY_COLUMN_GUI
Ade7880Show(0);
break;
#endif // USE_WEBSERVER

View File

@ -859,11 +859,7 @@ bool Xnrg29(uint32_t function) {
EnergyModbusShow(1);
break;
#ifdef USE_WEBSERVER
#ifdef USE_ENERGY_COLUMN_GUI
case FUNC_WEB_COL_SENSOR:
#else // not USE_ENERGY_COLUMN_GUI
case FUNC_WEB_SENSOR:
#endif // USE_ENERGY_COLUMN_GUI
EnergyModbusShow(0);
break;
#endif // USE_WEBSERVER