Periodic timer - when to start new count down?

Open
#437 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust
Domain
embedded-iot

Research direction

Review the periodic timer documentation and the start() and wait() behavior described in the issue. Decide whether a second wait() returns immediately after the countdown expires or starts a new one, then make the documented semantics unambiguous and verify the behavior against the timer API.

Written by the indexing model from the issue text.

Description

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?

Dominant language
Rust
Stars
2.7k
Forks
282
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-embedded/embedded-hal

All issues in rust-embedded/embedded-hal

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.