Author: Steveis <SteveAmor@users.noreply.github.com>
Fix Infineat crash when charging with AOD (#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)
src/displayapp/screens/WatchFaceInfineat.cpp | 7 +++++-- src/displayapp/screens/WatchFaceInfineat.h | 1 +
diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index 4c6fc196ac80e5473c49d2308c0314a40a0a288b..40f2abbbbc40d101ad44cd2e592840a46c002354 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -434,12 +434,15 @@ } batteryPercentRemaining = batteryController.PercentRemaining(); isCharging = batteryController.IsCharging(); - if (batteryController.IsCharging()) { // Charging battery animation - chargingBatteryPercent += 1; + // Charging battery animation + if (batteryController.IsCharging() && (xTaskGetTickCount() - chargingAnimationTick > pdMS_TO_TICKS(150))) { + // Dividing 100 by the height gives the battery percentage required to shift the animation by 1 pixel + chargingBatteryPercent += 100 / lv_obj_get_height(logoPine); if (chargingBatteryPercent > 100) { chargingBatteryPercent = batteryPercentRemaining.Get(); } SetBatteryLevel(chargingBatteryPercent); + chargingAnimationTick = xTaskGetTickCount(); } else if (isCharging.IsUpdated() || batteryPercentRemaining.IsUpdated()) { chargingBatteryPercent = batteryPercentRemaining.Get(); SetBatteryLevel(chargingBatteryPercent); diff --git a/src/displayapp/screens/WatchFaceInfineat.h b/src/displayapp/screens/WatchFaceInfineat.h index 55c43f98e0bc596262a9b2662d57e7c4be5f1ed1..78d020f10b3f875fb6f0278f10b82b5a7d76c649 100644 --- a/src/displayapp/screens/WatchFaceInfineat.h +++ b/src/displayapp/screens/WatchFaceInfineat.h @@ -47,6 +47,7 @@ private: uint32_t savedTick = 0; uint8_t chargingBatteryPercent = 101; // not a mistake ;) + TickType_t chargingAnimationTick = 0; Utility::DirtyValue<uint8_t> batteryPercentRemaining {}; Utility::DirtyValue<bool> isCharging {};