changed to bool
This commit is contained in:
parent
51d818b774
commit
557a328409
|
@ -86,15 +86,20 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
|
|||
newPercent = std::min(aprox.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100});
|
||||
}
|
||||
|
||||
if (isPowerPresent) {
|
||||
batteryLowNotified = false;
|
||||
}
|
||||
|
||||
if ((isPowerPresent && newPercent > percentRemaining) || (!isPowerPresent && newPercent < percentRemaining) || firstMeasurement) {
|
||||
firstMeasurement = false;
|
||||
lastPercentRemaining = percentRemaining;
|
||||
percentRemaining = newPercent;
|
||||
systemTask->PushMessage(System::Messages::BatteryPercentageUpdated);
|
||||
|
||||
|
||||
// warn about low battery when not charging and below threshold
|
||||
if (!isPowerPresent && BatteryIsLow() && lastPercentRemaining > lowBatteryThreshold) {
|
||||
if (BatteryIsLow() && !isPowerPresent && !batteryLowNotified) {
|
||||
systemTask->PushMessage(System::Messages::LowBattery);
|
||||
batteryLowNotified = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Pinetime {
|
|||
static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7;
|
||||
uint16_t voltage = 0;
|
||||
uint8_t percentRemaining = 0;
|
||||
uint8_t lastPercentRemaining = 0;
|
||||
bool batteryLowNotified = false;
|
||||
|
||||
bool isFull = false;
|
||||
bool isCharging = false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user