Skip to content

Commit 979dd7b

Browse files
SteveAmorBurninTurtles
authored andcommitted
Fix Infineat crash when charging with AOD (InfiniTimeOrg#2256)
Optimise the battery animation to not use 100% CPU (which causes DisplayApp to spin forever with AOD) (DisplayApp also needs to be fixed in the future so it cannot spin infinitely)
1 parent 7e4b075 commit 979dd7b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/displayapp/screens/WatchFaceInfineat.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,15 @@ void WatchFaceInfineat::Refresh() {
435435

436436
batteryPercentRemaining = batteryController.PercentRemaining();
437437
isCharging = batteryController.IsCharging();
438-
if (batteryController.IsCharging()) { // Charging battery animation
439-
chargingBatteryPercent += 1;
438+
// Charging battery animation
439+
if (batteryController.IsCharging() && (xTaskGetTickCount() - chargingAnimationTick > pdMS_TO_TICKS(150))) {
440+
// Dividing 100 by the height gives the battery percentage required to shift the animation by 1 pixel
441+
chargingBatteryPercent += 100 / lv_obj_get_height(logoPine);
440442
if (chargingBatteryPercent > 100) {
441443
chargingBatteryPercent = batteryPercentRemaining.Get();
442444
}
443445
SetBatteryLevel(chargingBatteryPercent);
446+
chargingAnimationTick = xTaskGetTickCount();
444447
} else if (isCharging.IsUpdated() || batteryPercentRemaining.IsUpdated()) {
445448
chargingBatteryPercent = batteryPercentRemaining.Get();
446449
SetBatteryLevel(chargingBatteryPercent);

src/displayapp/screens/WatchFaceInfineat.h

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace Pinetime {
4747
private:
4848
uint32_t savedTick = 0;
4949
uint8_t chargingBatteryPercent = 101; // not a mistake ;)
50+
TickType_t chargingAnimationTick = 0;
5051

5152
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
5253
Utility::DirtyValue<bool> isCharging {};

0 commit comments

Comments
 (0)