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

Periodic timer - when to start new count down?

Open Molorius opened this issue 2 years ago • 1 comments
trafficstars

I am not sure when to start a new count down when implementing a periodic timer. The documentation currently says, "the timer will start a new count down right after the last one finishes", but I'm not sure if that's after the last successful wait or as soon as the last count down reaches zero.

Say I have a periodic timer set to 1 second. I start it:

timer.start(1.second());

Then do something else for 5 seconds. I then read the timer twice:

block!(timer.wait()).ok();
block!(timer.wait()).ok();

The first block will immediately return because the timer has finished counting down by 1 second. Should the second block return immediately or wait for 1 additional second before returning?

Molorius avatar Feb 26 '23 19:02 Molorius