-
Notifications
You must be signed in to change notification settings - Fork 98
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
hal: Countdown #26
hal: Countdown #26
Conversation
Thanks for the fast PR submission. You bring up some interesting points that I hadn't fully considered yet. Microseconds seems like an acceptable resolution, but it makes working with seconds a bit inconvenient. Hertz conversion is nice to have, but I'm hesitant to add another dependency just for this single use, especially since the Implementing support for those throughout rppal would be useful, but also causes many breaking changes, which I want to hold off on until the current version in development has been released, so I'll add it to the To Do list. I'll also have to do some more research and see how other implementations (and drivers) currently implement and use CountDown. I did find a few implementations that work with hertz as you mentioned (although most seem to be u32 or u64 internally, which limits the timer to <= 1 s). Given the above-mentioned considerations, I'll wait with merging this for now until I have a better picture of how best to work with time units in rppal. Any additional thoughts/comments/suggestions are definitely welcome and appreciated. As for your specific implementation, the one thing I'm curious about is the additional 1 µs sleep after the specified duration has elapsed. Shouldn't that be moved to your own code instead so CountDown remains (more) accurate? Dependencies can be tied to the |
These are some of the related tickets Ive been watching |
I added Second and Millisecond for convenience. Also this guy is in those other threads doing so in an external lib if we want to rely on that instead (though his is u32 to support no_std better I imagine) |
Thanks. I've come across that library as well, and while it's a nice proof of concept, it's not very complete. I wouldn't mind switching to an external crate though once one has matured and is widely used. Currently I prefer the approach I saw in one of the stm32 device crates, which also implements its own types and adds a number of convenience methods to I'm still a bit confused on how driver crates work with different time units used by different implementations, unless It might be a good idea to include your current implementation for now (but without the bitrate dependency, possibly with an additional |
Hrm..Im not sure if I dont rely on a third party hertz implementation in my driver, what a good way to pass it in would be |
That's what I'm confused about as well. The third-party hertz you're using isn't part of the As far as I can tell there are a few options. The driver could be passed a timer that has already been pre-configured, similar to how a GPIO pin is configured for input before it is passed to a driver that needs an InputPin. But then you would only be able to call I've been searching for drivers that use CountDown, but most seem to only call |
I'm going to merge this and then make a few tweaks so I'll have something to experiment with, but we can continue the Time type discussion here to keep all of the comments in one place. |
I've changed the |
I think I read somewhere the reason embedded hal folks dont like duration even though its in core is its u64 and thats costly seeing as how everything embedded is u32 in fairness I think I was using u64 in my hertz code? I cant remember and I pushed over it and am using duration for now and its working nicely... |
Closes #25
My implementation in wiegand is working in milliseconds so I create MicroSeconds because I think thats about the resolution we should be at. Im not sure if we could tick slower reliably on the pi?
Also need to make a decision to use bitrate or something else. There doesnt seem to be a lot of movement on standardizing yet but most of the embedded hal stuff wants to live in Hertz land right now.
Im not sure how to put dependencies behind feature flags for void and bitrate