aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-time/src/timer.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs
index daa4c1699..d6d0a46e2 100644
--- a/embassy-time/src/timer.rs
+++ b/embassy-time/src/timer.rs
@@ -190,6 +190,18 @@ impl Ticker {
190 self.expires_at = Instant::now() + self.duration; 190 self.expires_at = Instant::now() + self.duration;
191 } 191 }
192 192
193 /// Reset the ticker at the deadline.
194 /// If the deadline is in the past, the ticker will fire instantly.
195 pub fn reset_at(&mut self, deadline: Instant) {
196 self.expires_at = deadline + self.duration;
197 }
198
199 /// Resets the ticker, after the specified duration has passed.
200 /// If the specified duration is zero, the next tick will be after the duration of the ticker.
201 pub fn reset_after(&mut self, after: Duration) {
202 self.expires_at = Instant::now() + after + self.duration;
203 }
204
193 /// Waits for the next tick. 205 /// Waits for the next tick.
194 pub fn next(&mut self) -> impl Future<Output = ()> + '_ { 206 pub fn next(&mut self) -> impl Future<Output = ()> + '_ {
195 poll_fn(|cx| { 207 poll_fn(|cx| {