FluenTech / embedded-time

Time(ing) library (Instant/Duration/Clock/Timer/Period/Frequency) for bare-metal embedded systems
Apache License 2.0
90 stars 17 forks source link

Add support for deci/milli/micro hertz for rates slower than 1 hertz. #87

Closed bobmcwhirter closed 3 years ago

bobmcwhirter commented 3 years ago

Adds support for sub-Hertz rates to allow for conversion of durations longer than 1 second to non-0 Hertz values.

e.g.

1 sec -> 1,000 millihertz 2 sec -> 500 millihertz 1,000 sec -> 1 millihertz

bobmcwhirter commented 3 years ago

fwiw, the benefit of this is providing a way for HAL Timer's to cycle at less often than 1 second.

bobmcwhirter commented 3 years ago

Hiya-- just checking in.

PTaylor-us commented 3 years ago

Thanks for this! Honestly, it's been ages since I've had time to look at this code (or any Rust) and been deep in C++ for far too long. I've never dealt with sub-hertz time in embedded applications (I guess I would tend to just switch over to period), and I can't remember off the top of my head whether it's even possible to specify a Timer/Clock period rather than frequency. In any case, I think it would be a good add for consistency alone.

korken89 commented 3 years ago

Ping @PTaylor-us

PTaylor-us commented 3 years ago

@bobmcwhirter Thanks again!