Fix Energy Frequency display

This commit is contained in:
Theo Arends 2020-05-23 12:15:14 +02:00
parent a411a51923
commit d0de78352f
3 changed files with 7 additions and 6 deletions

View File

@ -97,7 +97,8 @@ struct ENERGY {
uint8_t data_valid[3] = { 0, 0, 0 };
uint8_t phase_count = 1; // Number of phases active
bool voltage_common = false; // Use single voltage and frequency
bool voltage_common = false; // Use single voltage
bool frequency_common = false; // Use single frequency
bool kWhtoday_offset_init = false;
bool voltage_available = true; // Enable if voltage is measured
@ -1036,7 +1037,7 @@ void EnergyShow(bool json)
}
if (!isnan(Energy.frequency[0])) {
ResponseAppend_P(PSTR(",\"" D_JSON_FREQUENCY "\":%s"),
EnergyFormat(value_chr, frequency_chr[0], json, Energy.voltage_common));
EnergyFormat(value_chr, frequency_chr[0], json, Energy.frequency_common));
}
}
if (Energy.voltage_available) {
@ -1103,7 +1104,7 @@ void EnergyShow(bool json)
}
if (!isnan(Energy.frequency[0])) {
WSContentSend_PD(PSTR("{s}" D_FREQUENCY "{m}%s " D_UNIT_HERTZ "{e}"),
EnergyFormat(value_chr, frequency_chr[0], json, Energy.voltage_common));
EnergyFormat(value_chr, frequency_chr[0], json, Energy.frequency_common));
}
}
WSContentSend_PD(HTTP_ENERGY_SNS2, energy_daily_chr, energy_yesterday_chr, energy_total_chr);

View File

@ -209,10 +209,9 @@ void Ade7953DrvInit(void)
}
I2cSetActiveFound(ADE7953_ADDR, "ADE7953");
Ade7953.init_step = 2;
Energy.phase_count = 2; // Handle two channels as two phases
Energy.voltage_common = true; // Use common voltage and frequency
Energy.voltage_common = true; // Use common voltage
Energy.frequency_common = true; // Use common frequency
energy_flg = XNRG_07;
}
}

View File

@ -203,6 +203,7 @@ void Sdm630SnsInit(void)
if (result) {
if (2 == result) { ClaimSerial(); }
Energy.phase_count = 3;
Energy.frequency_common = true; // Use common frequency
} else {
energy_flg = ENERGY_NONE;
}