embedded-time icon indicating copy to clipboard operation
embedded-time copied to clipboard

Fixed-point Duration with Clock::SCALING_FACTOR

Open Piroro-hs opened this issue 5 years ago • 1 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();

Piroro-hs avatar Nov 25 '20 09:11 Piroro-hs

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.

PTaylor-us avatar Aug 29 '21 15:08 PTaylor-us