-
Notifications
You must be signed in to change notification settings - Fork 17
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 Timer
type
#21
Add Timer
type
#21
Conversation
Disclaimer: I did not look very thoroughly. Anyway a few thoughts: I like the type-based configuration/state keeping. However, I noticed one issue: Something that stroke me on first sight is the unwrapping of I think it would indeed be pretty straight forward to offer a non-blocking interface as suggested in #26 with this new pub fn wait(self) -> nb::Result<(), Infallible> {
// since the timer is running, _is_expired() will return a value
if !self._is_expired() {
Err(nb::Error::WouldBlock)
} else {
Ok(())
}
} Regarding external RTC devices:
|
Thank you so much for the feedback and pointing out areas that need to be addressed.
There are two
That interface is already there with the
I think this new use case does require a change. Certainly if you are using multiple I2C peripheral clocks/timers, all using the same driver, you must be able to create multiple instances of the
I'm definitely going to look into this. There are a number of places where a panic could happen in the code right now. I feel like I could handle those situations without panicking, it just may get a little hairy with the error handling. |
Sorry I misread the code there and thought it just returned itself in the
My point is rather the standardization around non-blocking method signatures/mechanics. At the moment in embedded-hal that is returning About unwrapping/ |
Thank you for clarifying, I'm a huge proponent for avoiding misunderstandings 😃 . That is certainly something I could implement either alongside or instead of the current polling functions. Personally, I find the
I had to add the I know that
To clarify, are you saying that the To make sure I understand, when you say "implement X on top of Y", do you mean the implementation of X using Y? |
At this moment I see the priorities as follows:
|
Yes, the non-blocking narrative can be a bit unintuitive in the beginning. As I understand it "I'm trying to blocking-wait on this timer, but if for some reason, I can't, I receive an error." still holds, because
Ah, yes. I missed the restarting part. The scheduling is an interesting possibility but it might be a bit of a stretch, or rather, independently implementable on top of/using a
Sorry let me clarify that: The fact that the
Yes. Let's clarify: I mean struct Z { y: Y }
impl X for Z {
// use methods from Y
} |
I suppose I could completely remove the |
I split all of the scheduling features off into a different branch. Now we just have one type, |
This functionality is now handled by `Timer`. BREAKING CHANGE: `Clock::delay()` replaced with `Timer::wait()`
…timer docs(Clock,Timer): Remove links to private items
Return a TimerBuilder<OneShot, Armed, ...>
Switch from using system clock for delays to manually advancing clock ticks using multiple threads
The
Timer
type supports one-shot and periodic time functionality.