1 unstable release
0.1.0 | May 23, 2023 |
---|
#20 in #accurate
8KB
58 lines
wait_timer
Crate for more accurate wait times than Delay
using rp2040_hal::timer::Timer
.
In addition to wait
function that waits for a specified number of seconds,
gate
function is implemented that keeps the time until it is re-executed constant.
How to use
- Create
rp2040_hal::timer::Timer
.
let timer = hal::timer::Timer::new(pac.TIMER, &mut pac.RESETS);
- Create
wait_timer::Wait
.
let wait = Wait::new(&timer);
- Use
wait
and/orgate
methods.
Methods
wait
functions
More accurate waiting times than Delay.
wait.wait_us(1_000_000);
wait.wait_ms(1_000);
wait.wait_sec(1);
gate
functions
Wait a specified number of seconds since the last execution.
loop {
wait.gate_sec(1); // A
// ...
wait.gate_ms(500); // B
// ...
}
- A is ignored the first time.
- The process from A to B is executed in 500 milliseconds.
- Processes from B onwards (B to A) are executed in a second.
Dependencies
~7MB
~144K SLoC