Add Energy->phase_count_virtual

This commit is contained in:
Theo Arends 2023-06-30 11:14:37 +02:00
parent 52392a2b48
commit ca452c5e43
3 changed files with 5 additions and 2 deletions

View File

@ -109,6 +109,7 @@ typedef struct {
uint8_t data_valid[ENERGY_MAX_PHASES];
uint8_t phase_count; // Number of phases active
uint8_t phase_count_virtual; // Number of virtual relays
bool voltage_common; // Use common voltage
bool frequency_common; // Use common frequency
bool use_overtemp; // Use global temperature as overtemp trigger on internal energy monitor hardware

View File

@ -173,6 +173,7 @@ typedef struct {
uint8_t data_valid[ENERGY_MAX_PHASES];
uint8_t phase_count; // Number of phases active
uint8_t phase_count_virtual; // Number of virtual relays
uint8_t fifth_second;
uint8_t command_code;
uint8_t power_steady_counter; // Allow for power on stabilization

View File

@ -148,8 +148,9 @@ bool NrgDummyCommand(void) {
}
void NrgDummyDrvInit(void) {
if (TasmotaGlobal.gpio_optiona.dummy_energy && TasmotaGlobal.devices_present) {
Energy->phase_count = (TasmotaGlobal.devices_present < ENERGY_MAX_PHASES) ? TasmotaGlobal.devices_present : ENERGY_MAX_PHASES;
uint32_t phase_count = (Energy->phase_count_virtual > 0) ? Energy->phase_count_virtual : TasmotaGlobal.devices_present;
if (TasmotaGlobal.gpio_optiona.dummy_energy && phase_count) {
Energy->phase_count = (phase_count < ENERGY_MAX_PHASES) ? phase_count : ENERGY_MAX_PHASES;
if (HLW_PREF_PULSE == EnergyGetCalibration(ENERGY_POWER_CALIBRATION)) {
for (uint32_t i = 0; i < Energy->phase_count; i++) {