FluenTech / embedded-time

Time(ing) library (Instant/Duration/Clock/Timer/Period/Frequency) for bare-metal embedded systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fixed-point Duration with Clock::SCALING_FACTOR

Piroro-hs opened this issue · comments

It's convenient to have fixed-point Durations whose time unit is same as Clock's.

It could be useful for use-case like below.

// assume clock rate is multiple of 3
// this periodic timer runs at exactly 3Hz
let timer = clock.new_timer(3_u32.Hz().to_duration::<ClockDuration<Clock>>().unwrap()).into_periodic();
// while this is not
let timer = clock.new_timer(3_u32.Hz().to_duration::<Milliseconds>().unwrap()).into_periodic();

First, thank you for the suggestion. Second, I'm very sorry for the delay. I do see the value of this. It would, however, need to be a Generic duration which is less efficient, but if needs must.

I will definitely look into this.