-
-
Notifications
You must be signed in to change notification settings - Fork 984
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
Changes from 1 commit
7198b5b
45f1ec7
de7238a
4c822e8
9a06545
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does appear to provide the expected value. I didn't know if I should type cast the result to an |
||
if (chargingBatteryPercent > 100) { | ||
chargingBatteryPercent = batteryPercentRemaining.Get(); | ||
} | ||
SetBatteryLevel(chargingBatteryPercent); | ||
savedAnimationTick = lv_tick_get(); | ||
} else if (isCharging.IsUpdated() || batteryPercentRemaining.IsUpdated()) { | ||
chargingBatteryPercent = batteryPercentRemaining.Get(); | ||
SetBatteryLevel(chargingBatteryPercent); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ namespace Pinetime { | |
|
||
private: | ||
uint32_t savedTick = 0; | ||
uint32_t savedAnimationTick = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would become I think it would be better if the variable name was specific that it's the charging animation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think/hope the changes I made address this? |
||
uint8_t chargingBatteryPercent = 101; // not a mistake ;) | ||
|
||
Utility::DirtyValue<uint8_t> batteryPercentRemaining {}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though they're the same, for timing it's recommended to use the RTOS tick with
xTaskGetTickCount()
. Additionally no type casts are needed, the overflow semantics of unsigned integers are well defined and subtraction works as expected. i.e justxTaskGetTickCount() - savedAnimationTick > pdMS_TO_TICKS(150)
(ms to ticks is recommended as the tick rate may change in the future)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback @mark9064. I have made the changes and it works as expected in terms of the same timings as the original code and as per the first commit in this PR.