FluenTech / embedded-time

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

Expose Timer's Expiration Time #131

Open Felix-El opened 1 year ago

Felix-El commented 1 year ago

After waiting on/polling for a timer's completion, I would want to know which time it is now, without potential overhead of calling try_now() again.

This story actually asks for two instants:

Both instants are available to _is_expired() which serves period_complete of Periodic and is_expired of OneShot.

Considering the Ok result case, instead of returning a bool (expired or not), we should return Option((ideal_instant, actual_instant)). Extracting the ideal_instant from the Periodic timer's period_complete is particularly useful because it gets updated for the next cycle inside this very function and inspecting expired would already contain the next instant (if it was exposed via accessor).