Improve battery percentage calculation and reporting
While charging, percentage should only go up, and while discharging, percentage should only go down.
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Pinetime {
|
||||
SetOffAlarm,
|
||||
StopRinging,
|
||||
MeasureBatteryTimerExpired,
|
||||
BatteryMeasurementDone,
|
||||
BatteryPercentageUpdated,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -349,14 +349,10 @@ void SystemTask::Work() {
|
||||
motorController.RunForDuration(15);
|
||||
break;
|
||||
case Messages::MeasureBatteryTimerExpired:
|
||||
sendBatteryNotification = true;
|
||||
batteryController.Update();
|
||||
break;
|
||||
case Messages::BatteryMeasurementDone:
|
||||
if (sendBatteryNotification) {
|
||||
sendBatteryNotification = false;
|
||||
nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());
|
||||
}
|
||||
case Messages::BatteryPercentageUpdated:
|
||||
nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -133,14 +133,12 @@ namespace Pinetime {
|
||||
TimerHandle_t dimTimer;
|
||||
TimerHandle_t idleTimer;
|
||||
TimerHandle_t measureBatteryTimer;
|
||||
bool sendBatteryNotification = false;
|
||||
bool doNotGoToSleep = false;
|
||||
|
||||
void GoToRunning();
|
||||
void UpdateMotion();
|
||||
bool stepCounterMustBeReset = false;
|
||||
static constexpr TickType_t batteryMeasurementPeriod = pdMS_TO_TICKS(10 * 60 * 1000);
|
||||
TickType_t lastBatteryNotificationTime = 0;
|
||||
|
||||
#if configUSE_TRACE_FACILITY == 1
|
||||
SystemMonitor<FreeRtosMonitor> monitor;
|
||||
|
Reference in New Issue
Block a user