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)
This commit is contained in:
parent
993118a3bc
commit
728da0f4a0
|
|
@ -434,12 +434,15 @@ void WatchFaceInfineat::Refresh() {
|
||||||
|
|
||||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||||
isCharging = batteryController.IsCharging();
|
isCharging = batteryController.IsCharging();
|
||||||
if (batteryController.IsCharging()) { // Charging battery animation
|
// Charging battery animation
|
||||||
chargingBatteryPercent += 1;
|
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) {
|
if (chargingBatteryPercent > 100) {
|
||||||
chargingBatteryPercent = batteryPercentRemaining.Get();
|
chargingBatteryPercent = batteryPercentRemaining.Get();
|
||||||
}
|
}
|
||||||
SetBatteryLevel(chargingBatteryPercent);
|
SetBatteryLevel(chargingBatteryPercent);
|
||||||
|
chargingAnimationTick = xTaskGetTickCount();
|
||||||
} else if (isCharging.IsUpdated() || batteryPercentRemaining.IsUpdated()) {
|
} else if (isCharging.IsUpdated() || batteryPercentRemaining.IsUpdated()) {
|
||||||
chargingBatteryPercent = batteryPercentRemaining.Get();
|
chargingBatteryPercent = batteryPercentRemaining.Get();
|
||||||
SetBatteryLevel(chargingBatteryPercent);
|
SetBatteryLevel(chargingBatteryPercent);
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ namespace Pinetime {
|
||||||
private:
|
private:
|
||||||
uint32_t savedTick = 0;
|
uint32_t savedTick = 0;
|
||||||
uint8_t chargingBatteryPercent = 101; // not a mistake ;)
|
uint8_t chargingBatteryPercent = 101; // not a mistake ;)
|
||||||
|
TickType_t chargingAnimationTick = 0;
|
||||||
|
|
||||||
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
|
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
|
||||||
Utility::DirtyValue<bool> isCharging {};
|
Utility::DirtyValue<bool> isCharging {};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue