From bdf405fb7b706e10f93faca311d3ac1791215daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Thu, 14 Jan 2021 13:59:07 +0100 Subject: [PATCH] Load: Clear ERR_LOAD_BUS_SRC_CURRENT if current is available again Previously, the error was never cleared after it was set, which is obviously a bad idea. --- src/load.cpp | 4 ++++ src/power_port.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/load.cpp b/src/load.cpp index 8d6f8c6..6ccb2b9 100644 --- a/src/load.cpp +++ b/src/load.cpp @@ -125,6 +125,10 @@ void LoadOutput::control() flags_clear(&error_flags, ERR_LOAD_OVERVOLTAGE); } + if (flags_check(&error_flags, ERR_LOAD_BUS_SRC_CURRENT) && bus->src_current_margin < 0) { + flags_clear(&error_flags, ERR_LOAD_BUS_SRC_CURRENT); + } + if (flags_check(&error_flags, ERR_LOAD_SHORT_CIRCUIT) && enable == false) { // stay here until the charge controller is reset or load is manually switched off flags_clear(&error_flags, ERR_LOAD_SHORT_CIRCUIT); diff --git a/src/power_port.h b/src/power_port.h index 0bc0233..2c26e23 100644 --- a/src/power_port.h +++ b/src/power_port.h @@ -84,6 +84,10 @@ public: /** * Available additional current from the DC bus until limits of the connected ports are reached * (has a negative sign) + * + * If for example a battery connected to the bus is not allowed to be discharged anymore, but + * we still get power via solar, current up to the amount of solar input can be diverted into + * the load (until the margin gets 0 and the battery would be discharged). */ float src_current_margin;