Skip to content

Commit 1777b9d

Browse files
committed
Don't measure and notify percentage on charging event.
1 parent a9f7153 commit 1777b9d

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/components/battery/BatteryController.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Battery::Battery() {
1313
nrf_gpio_cfg_input(PinMap::Charging, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
1414
}
1515

16-
void Battery::Update() {
16+
void Battery::ReadPowerState() {
1717
isCharging = !nrf_gpio_pin_read(PinMap::Charging);
1818
isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
1919

@@ -22,6 +22,10 @@ void Battery::Update() {
2222
} else if (!isPowerPresent) {
2323
isFull = false;
2424
}
25+
}
26+
27+
void Battery::MeasureVoltage() {
28+
ReadPowerState();
2529

2630
if (isReading) {
2731
return;

src/components/battery/BatteryController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ namespace Pinetime {
1010
public:
1111
Battery();
1212

13-
void Update();
13+
void ReadPowerState();
14+
void MeasureVoltage();
1415
void Register(System::SystemTask* systemTask);
1516

1617
uint8_t PercentRemaining() const {

src/systemtask/SystemTask.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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,11 +346,11 @@ void SystemTask::Work() {
345346
stepCounterMustBeReset = true;
346347
break;
347348
case Messages::OnChargingEvent:
348-
batteryController.Update();
349+
batteryController.ReadPowerState();
349350
motorController.RunForDuration(15);
350351
break;
351352
case Messages::MeasureBatteryTimerExpired:
352-
batteryController.Update();
353+
batteryController.MeasureVoltage();
353354
break;
354355
case Messages::BatteryPercentageUpdated:
355356
nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());

0 commit comments

Comments
 (0)