-
Notifications
You must be signed in to change notification settings - Fork 262
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
A time/rate solution #2923
Comments
Well the structure should probably be called We're mostly working with u64 as timestamp, which means using u64 under Duration and Instant is logical. For Rate, I'm not sure, depends whether we want to work with rates faster than 4GHz :) |
Agree with this, thanks for pointing that out. Thanks! I wasn't aware of those. This has been on my mind this past week, and I'm leaning towards new typing fugit with a u64 for I'd appreciate any other input or suggestions here. |
...
I completely agree with this - this should be the road forward |
I think it's a reasonable approach. In the best case, we'll be able to just reexport fugit if it goes stable as is (and since the crate hasn't seen any change in the past 2 years, why would it not?). Worst case, we'll have the compatibility layer in place and we can even decide to move away to some other internal representation. I'm not sure why we'd want to, but we could. |
Thanks for the input, I think we should go ahead with this. It's the last big API change in the 1.0-blockers list, so I think we should try and get this in for the beta. I think we should still be using I have also been debating whether this belongs in The plan
pub struct Rate(fugit::Rate<u32, 1, 1>); // resolution: hz
pub struct Instant(fugit::Instant<u64, 1, 1_000_000>); // resolution: micros
pub struct Duration(fugit::Duration<u64, 1, 1_000_000>); // resolution: micros
I think we want to be really small with the APIs we delegate to initially. I think the following should suffice for
Update: with the discussion below, lets use lowercase for all here, and we'll bikeshed this in the PR.
I think we should adopt the
|
This means milli-hertz, though. The kilo prefix is not capitalized but Mega is to differentiate it from milli. |
Fair enough, I didn't know that was a unit until now :D. Does millihertz make sense as a unit for anything we might want to do? If not I propose we stick the plan and document that it is actually megahertz, this is what they're doing in https://docs.embassy.dev/embassy-stm32/git/stm32f030rc/time/struct.Hertz.html#method.mhz. We can also bikeshed this in the impl PR, my main goal with that comment was consistency, I'm not particularly bothered about the exact route we choose. |
These are globally agreed upon prefixes, and formalized in ISO/IEC 80000. I'd really rather not deviate from that, Embassy is wrong to do so IMO. |
I agree that
👍 |
I don't think anyone uses milli-hertz as a real unit. At that point you count things in seconds, bpm/rpm, or something more natural/intuitive. In general I wouldn't fight for this, but to me there is an appeal to physically correct capitalization, but lower case everything would be equally obvious I think. |
Let's go with lowercase everything for now, and we can bikeshed it in the PR. |
We currently use
fugit
, which has served us well, and works nicely overall. I do see a few issues with it though..khz()
method on a u32 it's:u32
or au64
I'm wondering if we should provide our own time types (which may very well use fugit under the hood), but we'll have more control on what we expose, and what we expect users to do.
For example, whilst it might be a bit more verbose, I think I'd prefer an API that looked like this:
The difference in use:
Before:
After:
^^ above is just an idea, I'd appreciate thoughts on this going forward.
The text was updated successfully, but these errors were encountered: