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:
Riku Isokoski
2021-10-04 01:41:38 +03:00
parent b84a546920
commit a9f7153fdf
5 changed files with 14 additions and 14 deletions

View File

@@ -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: