added low battery message

This commit is contained in:
minacode
2022-10-03 12:15:37 +02:00
committed by JF
parent 29673892c2
commit ccc8cee07a
4 changed files with 19 additions and 0 deletions

View File

@@ -88,10 +88,16 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
if ((isPowerPresent && newPercent > percentRemaining) || (!isPowerPresent && newPercent < percentRemaining) || firstMeasurement) {
firstMeasurement = false;
lastPercentRemaining = percentRemaining;
percentRemaining = newPercent;
systemTask->PushMessage(System::Messages::BatteryPercentageUpdated);
}
constexpr uint8_t lowBatteryThreshold {50};
if (!isPowerPresent && lastPercentRemaining >= lowBatteryThreshold && percentRemaining < lowBatteryThreshold) {
systemTask->PushMessage(System::Messages::LowBattery);
}
nrfx_saadc_uninit();
isReading = false;
}