-
Notifications
You must be signed in to change notification settings - Fork 179
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
Implement timer::Cancel trait for CountDownTimer #261
Conversation
Thanks for the PR! Looks good overall, I just have one minor comment: Would it make more sense to call the |
I totally agree, should be changed now. |
On second thought, embedded-hal says that an error will also be returned if the timer was never started and in the non-periodic case when it is already expired (not applicable here). So the more generic Disabled might not be that bad, do you have another suggestion? |
Hmm good question, perhaps |
What do you think of |
I like that option :) Maybe add a doc comment clarifying what it means in case there is any confusion |
I was just going to change it but then I noticed that in this crate the Sorry for the back and forth 😂 I was actually wondering before if there is any reason for the |
Yea, that's a good point. While I am generally a fan of type states, I think it might be a bit strange for this particular use case. I don't quite remember why we changed it from Either way, I think a better approach, might be to get rid of the type state, make timers start stopped, and have errors returned in functions that are only valid during count down. If we wanted to, we could also do 2 timer implementations, one type state based version, and one at runtime. cc: @burrbull (since you authored #95 and may remember some details), @therealprof |
Thanks for the link to the PR, now the design makes a lot more sense. It's not a typestate representing if the countdown is running or not, it's more a typestate in which mode the timer is. As you can go from |
Oh right, yea. I missremembered what the type states did too, I thought there were separate constructors for the pwm etc. traits :) |
I've just rebased the branch to the master, from my side it should be good to be merged. Do you squash the commits on merge? |
Never mind, I've squashed them. |
Lovely, thanks! And yea, I tend to either squash or rebase depending on how well formated the messages are |
Analog to the stm32f4xx-hal