Add SetOption150

Add SetOption150 - (Energy) Force no voltage/frequency common allowing individual voltage channel calibration.
This commit is contained in:
Theo Arends 2023-01-31 22:30:50 +01:00
parent 438b235dc8
commit db581b15c7
4 changed files with 22 additions and 15 deletions

View File

@ -183,7 +183,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t mqtt_disable_sserialrec : 1; // bit 1 (v12.1.1.2) - SetOption147 - (MQTT) Disable publish SSerialReceived MQTT messages, you must use event trigger rules instead.
uint32_t artnet_autorun : 1; // bit 2 (v12.2.0.4) - SetOption148 - (Light) start DMX ArtNet at boot, listen to UDP port as soon as network is up
uint32_t dns_ipv6_priority : 1; // bit 3 (v12.2.0.6) - SetOption149 - (Wifi) prefer IPv6 DNS resolution to IPv4 address when available. Requires `#define USE_IPV6`
uint32_t spare04 : 1; // bit 4
uint32_t no_voltage_common : 1; // bit 4 (v12.3.1.5) - SetOption150 - (Energy) Force no voltage/frequency common
uint32_t spare05 : 1; // bit 5
uint32_t spare06 : 1; // bit 6
uint32_t spare07 : 1; // bit 7

View File

@ -1200,7 +1200,10 @@ const char HTTP_ENERGY_SNS3[] PROGMEM =
#endif // USE_WEBSERVER
void EnergyShow(bool json) {
if (Energy->voltage_common) {
bool voltage_common = (Settings->flag6.no_voltage_common) ? false : Energy->voltage_common;
bool frequency_common = (Settings->flag6.no_voltage_common) ? false : Energy->frequency_common;
if (voltage_common) {
for (uint32_t i = 0; i < Energy->phase_count; i++) {
Energy->voltage[i] = Energy->voltage[0];
}
@ -1333,12 +1336,12 @@ void EnergyShow(bool json) {
}
if (!isnan(Energy->frequency[0])) {
ResponseAppend_P(PSTR(",\"" D_JSON_FREQUENCY "\":%s"),
EnergyFormat(value_chr, Energy->frequency, Settings->flag2.frequency_resolution, Energy->frequency_common));
EnergyFormat(value_chr, Energy->frequency, Settings->flag2.frequency_resolution, frequency_common));
}
}
if (Energy->voltage_available) {
ResponseAppend_P(PSTR(",\"" D_JSON_VOLTAGE "\":%s"),
EnergyFormat(value_chr, Energy->voltage, Settings->flag2.voltage_resolution, Energy->voltage_common));
EnergyFormat(value_chr, Energy->voltage, Settings->flag2.voltage_resolution, voltage_common));
}
if (Energy->current_available) {
ResponseAppend_P(PSTR(",\"" D_JSON_CURRENT "\":%s"),
@ -1397,7 +1400,7 @@ void EnergyShow(bool json) {
// {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><hr/>{t}{s}</th><th></th>")); // First column is empty ({t} = <table style='width:100%'>, {s} = <tr><th>)
bool label_o = Energy->voltage_common;
bool label_o = voltage_common;
bool no_label = (1 == Energy->phase_count);
for (uint32_t i = 0; i < Energy->phase_count; i++) {
WSContentSend_P(PSTR("<th style='text-align:center'>%s%s<th></th>"), (no_label)?"":(label_o)?"O":"L", (no_label)?"":itoa(i +1, value_chr, 10));
@ -1405,12 +1408,12 @@ void EnergyShow(bool json) {
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, 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, voltage_common));
}
if (!Energy->type_dc) {
if (!isnan(Energy->frequency[0])) {
WSContentSend_PD(PSTR("{s}" D_FREQUENCY "{m}%s " D_UNIT_HERTZ "{e}"),
WebEnergyFormat(value_chr, Energy->frequency, Settings->flag2.frequency_resolution, Energy->frequency_common));
WebEnergyFormat(value_chr, Energy->frequency, Settings->flag2.frequency_resolution, frequency_common));
}
}
if (Energy->current_available) {

View File

@ -1416,7 +1416,10 @@ const char HTTP_ENERGY_SNS3[] PROGMEM =
#endif // USE_WEBSERVER
void EnergyShow(bool json) {
if (Energy->voltage_common) {
bool voltage_common = (Settings->flag6.no_voltage_common) ? false : Energy->voltage_common;
bool frequency_common = (Settings->flag6.no_voltage_common) ? false : Energy->frequency_common;
if (voltage_common) {
for (uint32_t i = 0; i < Energy->phase_count; i++) {
Energy->voltage[i] = Energy->voltage[0];
}
@ -1549,12 +1552,12 @@ void EnergyShow(bool json) {
}
if (!isnan(Energy->frequency[0])) {
ResponseAppend_P(PSTR(",\"" D_JSON_FREQUENCY "\":%s"),
EnergyFormat(value_chr, Energy->frequency, Settings->flag2.frequency_resolution, Energy->frequency_common));
EnergyFormat(value_chr, Energy->frequency, Settings->flag2.frequency_resolution, frequency_common));
}
}
if (Energy->voltage_available) {
ResponseAppend_P(PSTR(",\"" D_JSON_VOLTAGE "\":%s"),
EnergyFormat(value_chr, Energy->voltage, Settings->flag2.voltage_resolution, Energy->voltage_common));
EnergyFormat(value_chr, Energy->voltage, Settings->flag2.voltage_resolution, voltage_common));
}
if (Energy->current_available) {
ResponseAppend_P(PSTR(",\"" D_JSON_CURRENT "\":%s"),
@ -1636,7 +1639,7 @@ void EnergyShow(bool json) {
if (Energy->gui_count > Energy->Settings.gui_cols) { Energy->gui_count = Energy->Settings.gui_cols; }
WSContentSend_P(PSTR("</table><hr/>")); // Close current table as we will use different column count
bool label_o = Energy->voltage_common;
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;
if (tabs > 1) {
@ -1668,12 +1671,12 @@ void EnergyShow(bool json) {
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, 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, voltage_common));
}
if (!Energy->type_dc) {
if (!isnan(Energy->frequency[0])) {
WSContentSend_PD(PSTR("{s}" D_FREQUENCY "{m}%s " D_UNIT_HERTZ "{e}"),
WebEnergyFormat(value_chr, Energy->frequency, Settings->flag2.frequency_resolution, Energy->frequency_common));
WebEnergyFormat(value_chr, Energy->frequency, Settings->flag2.frequency_resolution, frequency_common));
}
}
if (Energy->current_available) {

View File

@ -205,7 +205,8 @@ a_setoption = [[
"(MQTT) Disable publish SSerialReceived MQTT messages, you must use event trigger rules instead",
"(Light) start DMX ArtNet at boot, listen to UDP port as soon as network is up",
"(Wifi) prefer IPv6 DNS resolution to IPv4 address when available. Requires `#define USE_IPV6`",
"","","","",
"(Energy) Force no voltage/frequency common",
"","","",
"","","","",
"","","","",
"","","","",
@ -322,7 +323,7 @@ else:
obj = json.load(fp)
def StartDecode():
print ("\n*** decode-status.py v12.3.1.2 by Theo Arends and Jacek Ziolkowski ***")
print ("\n*** decode-status.py v12.3.1.5 by Theo Arends and Jacek Ziolkowski ***")
# print("Decoding\n{}".format(obj))