From cad58f190f18bc4717d7c1b78e8a5497d5220d9e Mon Sep 17 00:00:00 2001 From: minacode Date: Sun, 9 Oct 2022 21:58:57 +0200 Subject: added message, changed UI --- src/components/battery/BatteryController.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/components/battery/BatteryController.cpp') diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index ca0db79f..49a17da1 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -96,12 +96,11 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) { lastPercentRemaining = percentRemaining; percentRemaining = newPercent; systemTask->PushMessage(System::Messages::BatteryPercentageUpdated); - } - // warn at 20% battery (wrt. rescaling above) - constexpr uint8_t lowBatteryThreshold {20}; - if (!isPowerPresent && lastPercentRemaining >= lowBatteryThreshold && percentRemaining < lowBatteryThreshold) { - systemTask->PushMessage(System::Messages::LowBattery); + // warn at 20% battery (wrt. rescaling above) + if (!isPowerPresent && BatteryIsLow() && lastPercentRemaining > lowBatteryThreshold) { + systemTask->PushMessage(System::Messages::LowBattery); + } } nrfx_saadc_uninit(); -- cgit v1.2.3