Closed andresv closed 2 years ago
Good catch, missed that!
On the other hand, does it make sense? Usually Instants
have the speed of hardware timers which are far and spread.
While for an API Duration
can be used to set the granularity you want in the API.
I have no problem adding the aliases, but I don't think Instant
would see as much use as Duration
.
What are your thoughts? @andresv
Maybe something like this makes more sense?
/// Alias for instants that come from timers with a specific frequency
pub type TimerInstant<T, const FREQ_HZ: u32> = Instant<T, 1, FREQ_HZ>;
/// Alias for instants that come from timers with a specific frequency (`u32` backing storage)
pub type TimerInstantU32<const FREQ_HZ: u32> = Instant<u32, 1, FREQ_HZ>;
/// Alias for instants that come from timers with a specific frequency (`u64` backing storage)
pub type TimerInstantU64<const FREQ_HZ: u32> = Instant<u64, 1, FREQ_HZ>;
const TIMER_FREQ_HZ: u32 = 1000;
// looking this first time might take some time to figure out what is going on here
Instant::<u32, 1, 1_000>
// I think this is more clear for a reader
TimerInstant::<u32, TIMER_FREQ_HZ>
Of course users can defines these aliases by themselves. Maybe there should be just an example in doc that shows it where it makes sense to define your own aliases.
Because indeed Instant
can be what ever depending on hardware. Like Timer4Instant64Khz
or something. So I think you are right and we do not need ready made aliases for them.
Seems to be fixed now.
Currently I have something like this:
I would prefer:
Actually maybe it makes sense to create aliases also for Instants?