You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sold on the extension traits. Whilst it can look nice to magically get this .khz() method on a u32 it's:
Not very discoverable, if you call it without the trait imported, the compiler will most likely throw a fit with a not very clear error message
There are ambiguous types involved when the backing for the type can be a u32 or a u64
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:
pubstructHertz(/* some type here, probably a `HertzU32` from fugit */);implHertz{fnkhz(khz:u32/* unsure of type here, but u32 seems appropriate */) -> Hertz{// internally we can use fugit stuff, like the ext traitsHertz(khz.khz())}}
The difference in use:
Before:
use fugit::ExtRate;// somewhere// ...with_frequency(1000.khz())// ..
After:
use esp_hal::time::Hertz;// somewhere// ...with_frequency(Hertz::khz(1000))// ..
^^ above is just an idea, I'd appreciate thoughts on this going forward.
The text was updated successfully, but these errors were encountered:
Well the structure should probably be called Rate or Frequency, as Hertz is a unit of measurement so Hertz::kHz is already a confusion :)
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 :)
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: