-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Simplify and fix countdown display skipping seconds #94
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* energy: Add a pre-timer to ensure that each tick of the countdown clock happens just after a seconds boundary. This ensures that the displayed number of seconds remaining is both accurate and robust to small system delays that can cause timers to fire a bit later than scheduled. Make countdown timer precise to about 1/30 of a second. Track window visibility and disable drawing and clock updates while the window is closed or hidden. Reduces CPU usage while in the background by at least 20x compared to previous version of the app. Improve battery life by setting a timer tolerance and updating the display less often.
…andle the variance in exact fire times
@robinstewart I like your |
Closed
karbassi
reviewed
Jul 16, 2020
@robinstewart looks good to me as well. Merging |
Thanks! |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was able to fix #90 and also simplify the tick timer code by using round() instead of floor(). Since the UI only allows timers to be set to an integer number of seconds, the exact "seconds remaining" is always near an integer boundary. We can simply use the
round()
function to make sure the nearest integer is displayed, regardless of whether the timer ends up firing slightly before or slightly after.Here is a typical run when I uncomment the print statement:
Fixes #90
Closes #93
Closes #92
Closes #91