From 18c464e524de5e09a4860723f152ec6708910aee Mon Sep 17 00:00:00 2001 From: MalteSchm <88371275+MalteSchm@users.noreply.github.com> Date: Mon, 24 Jul 2023 13:03:12 +0200 Subject: [PATCH] SoC based threshold detection fix (#320) --- src/PowerLimiter.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/PowerLimiter.cpp b/src/PowerLimiter.cpp index 1ac10c74..b84cecc1 100644 --- a/src/PowerLimiter.cpp +++ b/src/PowerLimiter.cpp @@ -587,9 +587,8 @@ bool PowerLimiterClass::isStartThresholdReached(std::shared_ptr 0.0 - && (millis() - Battery.stateOfChargeLastUpdate) < 60000 - && Battery.stateOfCharge >= config.PowerLimiter_BatterySocStartThreshold) { - return true; + && (millis() - Battery.stateOfChargeLastUpdate) < 60000) { + return Battery.stateOfCharge >= config.PowerLimiter_BatterySocStartThreshold; } // Otherwise we use the voltage threshold @@ -608,9 +607,8 @@ bool PowerLimiterClass::isStopThresholdReached(std::shared_ptr // Check if the Battery interface is enabled and the SOC stop threshold is reached if (config.Battery_Enabled && config.PowerLimiter_BatterySocStopThreshold > 0.0 - && (millis() - Battery.stateOfChargeLastUpdate) < 60000 - && Battery.stateOfCharge <= config.PowerLimiter_BatterySocStopThreshold) { - return true; + && (millis() - Battery.stateOfChargeLastUpdate) < 60000) { + return Battery.stateOfCharge <= config.PowerLimiter_BatterySocStopThreshold; } // Otherwise we use the voltage threshold @@ -674,9 +672,8 @@ bool PowerLimiterClass::useFullSolarPassthrough(std::shared_ptr 0.0 - && (millis() - Battery.stateOfChargeLastUpdate) < 60000 - && Battery.stateOfCharge >= config.PowerLimiter_FullSolarPassThroughSoc) { - return true; + && (millis() - Battery.stateOfChargeLastUpdate) < 60000) { + return Battery.stateOfCharge >= config.PowerLimiter_FullSolarPassThroughSoc; } // Otherwise we use the voltage threshold