Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents blocking when Infineat watchface is charging #2256

Merged
merged 5 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/displayapp/screens/WatchFaceInfineat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,15 @@ void WatchFaceInfineat::Refresh() {

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);
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/WatchFaceInfineat.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace Pinetime {
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 {};
Expand Down