diff options
Diffstat (limited to 'embassy-time/src/timer.rs')
| -rw-r--r-- | embassy-time/src/timer.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs index ad5026e62..07ddf473f 100644 --- a/embassy-time/src/timer.rs +++ b/embassy-time/src/timer.rs | |||
| @@ -133,7 +133,13 @@ impl Ticker { | |||
| 133 | Self { expires_at, duration } | 133 | Self { expires_at, duration } |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | /// Waits for the next tick | 136 | /// Resets the ticker back to its original state. |
| 137 | /// This causes the ticker to go back to zero, even if the current tick isn't over yet. | ||
| 138 | pub fn reset(&mut self) { | ||
| 139 | self.expires_at = Instant::now() + self.duration; | ||
| 140 | } | ||
| 141 | |||
| 142 | /// Waits for the next tick. | ||
| 137 | pub fn next(&mut self) -> impl Future<Output = ()> + '_ { | 143 | pub fn next(&mut self) -> impl Future<Output = ()> + '_ { |
| 138 | poll_fn(|cx| { | 144 | poll_fn(|cx| { |
| 139 | if self.expires_at <= Instant::now() { | 145 | if self.expires_at <= Instant::now() { |
