From a768f059a111b4eb13d658d81bac3f6c6ded360a Mon Sep 17 00:00:00 2001 From: Jordan Silverman Date: Tue, 16 Jun 2020 16:36:20 +0100 Subject: [PATCH] Stop energy counter when disabled --- src/main.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 68b307e..1e7d2fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -138,17 +138,23 @@ void control_thread() // energy + soc calculation must be called exactly once per second #if DT_COMPAT_DCDC - hv_terminal.energy_balance(); + if (dcdc.state != DCDC_STATE_OFF) { + hv_terminal.energy_balance(); + } #endif #if DT_OUTPUTS_PWM_SWITCH_PRESENT - pwm_switch.energy_balance(); + if (pwm_switch.active() == 1) { + pwm_switch.energy_balance(); + } #endif lv_terminal.energy_balance(); #if DT_OUTPUTS_LOAD_PRESENT - load.energy_balance(); + if (load.state == 1) { + load.energy_balance(); + } #endif dev_stat.update_energy();