@@ -136,7 +136,6 @@ void SystemTask::Work() {
136136 touchPanel.Init ();
137137 dateTimeController.Register (this );
138138 batteryController.Register (this );
139- batteryController.Update ();
140139 motorController.Init ();
141140 motionSensor.SoftReset ();
142141 timerController.Register (this );
@@ -194,6 +193,8 @@ void SystemTask::Work() {
194193 nrf_gpio_cfg_sense_input (PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
195194 }
196195
196+ batteryController.MeasureVoltage ();
197+
197198 idleTimer = xTimerCreate (" idleTimer" , pdMS_TO_TICKS (2000 ), pdFALSE, this , IdleTimerCallback);
198199 dimTimer = xTimerCreate (" dimTimer" , pdMS_TO_TICKS (settingsController.GetScreenTimeOut () - 2000 ), pdFALSE, this , DimTimerCallback);
199200 measureBatteryTimer = xTimerCreate (" measureBattery" , batteryMeasurementPeriod, pdTRUE, this , MeasureBatteryTimerCallback);
@@ -345,22 +346,18 @@ void SystemTask::Work() {
345346 stepCounterMustBeReset = true ;
346347 break ;
347348 case Messages::OnChargingEvent:
348- batteryController.Update ();
349+ batteryController.ReadPowerState ();
349350 motorController.RunForDuration (15 );
350351 ReloadIdleTimer ();
351352 if (isSleeping && !isWakingUp) {
352353 GoToRunning ();
353354 }
354355 break ;
355356 case Messages::MeasureBatteryTimerExpired:
356- sendBatteryNotification = true ;
357- batteryController.Update ();
357+ batteryController.MeasureVoltage ();
358358 break ;
359- case Messages::BatteryMeasurementDone:
360- if (sendBatteryNotification) {
361- sendBatteryNotification = false ;
362- nimbleController.NotifyBatteryLevel (batteryController.PercentRemaining ());
363- }
359+ case Messages::BatteryPercentageUpdated:
360+ nimbleController.NotifyBatteryLevel (batteryController.PercentRemaining ());
364361 break ;
365362
366363 default :
0 commit comments