-
-
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
Add an hour option to the timer application #2243
base: main
Are you sure you want to change the base?
Conversation
Build size and comparison to main:
|
Thanks for the feature! I have a feeling |
@mark9064 After passing the product of |
Well in GetTimeRemaining it also multiplies by 1000 which will cause overflow. Basically all code paths involving it will need to be refactored to make sure they don't multiply tick counts beyond the range of uint32. To fix this one, you could split building the time into milliseconds and seconds (seconds with tick count / tick rate, milliseconds with tick count % tick rate * 1000 / tick rate) |
528f59f
to
00c463e
Compare
I asked about the same thing! |
@codeguylevi About what, the timer limit issue I'm having? |
Yes. |
You mean the timer currently being limited to 59:59 right? |
Also Scott if you'd like me to take a look at the overflow issue I'd be happy to - if so let me know exactly what you've tried so far re removing pdMS_TO_TICKS etc. |
Yup! |
This adds an hours column to the timer app.
Addresses: #1678
Technical Details:
I thought this would be a simple task until I found that
xTimerChangePeriod
doesn't support periods longer than an hour and 10ish minutes (1hr 9m 54s is what I found). So my solution to this was to divide the hours (referred to as intervals in the code) out of the duration given when the timer is started and store it intimerOverflowIntervals
, then set the period inxTimerChangePeriod
to the leftover duration (an hour). Then whenMessages::TimerDone:
is triggered, it checks if any hours/intervals are stored, if there are then it starts a new hour timer and subtracts an hour/interval fromtimerOverflowIntervals
. This allows for setting very large timers (256 hours) with the timer component without making the system hold large tick/millisecond values (however the timer app only allows up to 100 hours).I may also have missed something simple with
xTimerChangePeriod
and way over engineered this, in which case this was a great learning exercise. Anyways, let me know what you think. To code reviewers: I'm a C++ novice so please go easy :).Not sure why the GIF appears sped up, but the timer counts down seconds normally in the simulator.
