From 7198b5b6672bc240f2042ff61267c51bad92d2dd Mon Sep 17 00:00:00 2001 From: Steve Amor Date: Wed, 19 Feb 2025 17:49:25 +0000 Subject: [PATCH 1/5] Prevent blocking when Infineat watchface is charging --- src/displayapp/screens/WatchFaceInfineat.cpp | 5 +++-- src/displayapp/screens/WatchFaceInfineat.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index 4c6fc196ac..b241c1f520 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -434,12 +434,13 @@ void WatchFaceInfineat::Refresh() { batteryPercentRemaining = batteryController.PercentRemaining(); isCharging = batteryController.IsCharging(); - if (batteryController.IsCharging()) { // Charging battery animation - chargingBatteryPercent += 1; + if (batteryController.IsCharging() && (uint32_t(lv_tick_get() - savedAnimationTick) > 150)) { // Charging battery animation + chargingBatteryPercent += 3; // 100% / pine_small height = 3 if (chargingBatteryPercent > 100) { chargingBatteryPercent = batteryPercentRemaining.Get(); } SetBatteryLevel(chargingBatteryPercent); + savedAnimationTick = lv_tick_get(); } 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 55c43f98e0..eb1d61e9bb 100644 --- a/src/displayapp/screens/WatchFaceInfineat.h +++ b/src/displayapp/screens/WatchFaceInfineat.h @@ -46,6 +46,7 @@ namespace Pinetime { private: uint32_t savedTick = 0; + uint32_t savedAnimationTick = 0; uint8_t chargingBatteryPercent = 101; // not a mistake ;) Utility::DirtyValue batteryPercentRemaining {}; From 45f1ec7a71974a8142fca5e9c2319774f6283933 Mon Sep 17 00:00:00 2001 From: Steve Amor Date: Sun, 23 Feb 2025 20:59:30 +0000 Subject: [PATCH 2/5] Use RTOS timers for annimation --- src/displayapp/screens/WatchFaceInfineat.cpp | 6 +++--- src/displayapp/screens/WatchFaceInfineat.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index b241c1f520..e9b107f463 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -434,13 +434,13 @@ void WatchFaceInfineat::Refresh() { batteryPercentRemaining = batteryController.PercentRemaining(); isCharging = batteryController.IsCharging(); - if (batteryController.IsCharging() && (uint32_t(lv_tick_get() - savedAnimationTick) > 150)) { // Charging battery animation - chargingBatteryPercent += 3; // 100% / pine_small height = 3 + if (batteryController.IsCharging() && (xTaskGetTickCount() - chargingAnimationTick > pdMS_TO_TICKS(150))) { // Charging battery animation + chargingBatteryPercent += 100 / lv_obj_get_height(logoPine); if (chargingBatteryPercent > 100) { chargingBatteryPercent = batteryPercentRemaining.Get(); } SetBatteryLevel(chargingBatteryPercent); - savedAnimationTick = lv_tick_get(); + 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 eb1d61e9bb..78d020f10b 100644 --- a/src/displayapp/screens/WatchFaceInfineat.h +++ b/src/displayapp/screens/WatchFaceInfineat.h @@ -46,8 +46,8 @@ namespace Pinetime { private: uint32_t savedTick = 0; - uint32_t savedAnimationTick = 0; uint8_t chargingBatteryPercent = 101; // not a mistake ;) + TickType_t chargingAnimationTick = 0; Utility::DirtyValue batteryPercentRemaining {}; Utility::DirtyValue isCharging {}; From de7238abcca09726d24f7fb6ce654ed5524d15f2 Mon Sep 17 00:00:00 2001 From: Steve Amor Date: Mon, 24 Feb 2025 14:51:14 +0000 Subject: [PATCH 3/5] Adds comment on height of animation --- src/displayapp/screens/WatchFaceInfineat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index e9b107f463..e13bdcc915 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -435,7 +435,7 @@ void WatchFaceInfineat::Refresh() { batteryPercentRemaining = batteryController.PercentRemaining(); isCharging = batteryController.IsCharging(); if (batteryController.IsCharging() && (xTaskGetTickCount() - chargingAnimationTick > pdMS_TO_TICKS(150))) { // Charging battery animation - chargingBatteryPercent += 100 / lv_obj_get_height(logoPine); + chargingBatteryPercent += 100 / lv_obj_get_height(logoPine); // Dividing 100 by the height gives the battery percentage required to shift the animation by 1 pixel if (chargingBatteryPercent > 100) { chargingBatteryPercent = batteryPercentRemaining.Get(); } From 4c822e87acf0f824fdb7d117388840eaa3840451 Mon Sep 17 00:00:00 2001 From: Steve Amor Date: Mon, 24 Feb 2025 14:55:16 +0000 Subject: [PATCH 4/5] Fixes clang formatting error for comment --- src/displayapp/screens/WatchFaceInfineat.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index e13bdcc915..9ee8ae2484 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -435,7 +435,9 @@ void WatchFaceInfineat::Refresh() { batteryPercentRemaining = batteryController.PercentRemaining(); isCharging = batteryController.IsCharging(); if (batteryController.IsCharging() && (xTaskGetTickCount() - chargingAnimationTick > pdMS_TO_TICKS(150))) { // Charging battery animation - chargingBatteryPercent += 100 / lv_obj_get_height(logoPine); // Dividing 100 by the height gives the battery percentage required to shift the animation by 1 pixel + chargingBatteryPercent += + 100 / + lv_obj_get_height(logoPine); // Dividing 100 by the height gives the battery percentage required to shift the animation by 1 pixel if (chargingBatteryPercent > 100) { chargingBatteryPercent = batteryPercentRemaining.Get(); } From 9a06545ab523f666b1e00fca69175b9118820e60 Mon Sep 17 00:00:00 2001 From: Steve Amor Date: Mon, 24 Feb 2025 18:55:29 +0000 Subject: [PATCH 5/5] Fixes comments --- src/displayapp/screens/WatchFaceInfineat.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index 9ee8ae2484..40f2abbbbc 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -434,10 +434,10 @@ void WatchFaceInfineat::Refresh() { batteryPercentRemaining = batteryController.PercentRemaining(); isCharging = batteryController.IsCharging(); - if (batteryController.IsCharging() && (xTaskGetTickCount() - chargingAnimationTick > pdMS_TO_TICKS(150))) { // Charging battery animation - chargingBatteryPercent += - 100 / - lv_obj_get_height(logoPine); // Dividing 100 by the height gives the battery percentage required to shift the animation by 1 pixel + // 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(); }