Skip to content

Commit 45f1ec7

Browse files
committed
Use RTOS timers for annimation
1 parent 7198b5b commit 45f1ec7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/displayapp/screens/WatchFaceInfineat.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,13 @@ void WatchFaceInfineat::Refresh() {
434434

435435
batteryPercentRemaining = batteryController.PercentRemaining();
436436
isCharging = batteryController.IsCharging();
437-
if (batteryController.IsCharging() && (uint32_t(lv_tick_get() - savedAnimationTick) > 150)) { // Charging battery animation
438-
chargingBatteryPercent += 3; // 100% / pine_small height = 3
437+
if (batteryController.IsCharging() && (xTaskGetTickCount() - chargingAnimationTick > pdMS_TO_TICKS(150))) { // Charging battery animation
438+
chargingBatteryPercent += 100 / lv_obj_get_height(logoPine);
439439
if (chargingBatteryPercent > 100) {
440440
chargingBatteryPercent = batteryPercentRemaining.Get();
441441
}
442442
SetBatteryLevel(chargingBatteryPercent);
443-
savedAnimationTick = lv_tick_get();
443+
chargingAnimationTick = xTaskGetTickCount();
444444
} else if (isCharging.IsUpdated() || batteryPercentRemaining.IsUpdated()) {
445445
chargingBatteryPercent = batteryPercentRemaining.Get();
446446
SetBatteryLevel(chargingBatteryPercent);

src/displayapp/screens/WatchFaceInfineat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ namespace Pinetime {
4646

4747
private:
4848
uint32_t savedTick = 0;
49-
uint32_t savedAnimationTick = 0;
5049
uint8_t chargingBatteryPercent = 101; // not a mistake ;)
50+
TickType_t chargingAnimationTick = 0;
5151

5252
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
5353
Utility::DirtyValue<bool> isCharging {};

0 commit comments

Comments
 (0)