From 663fa2addd30463328f6186e14f98680b4a35c9b Mon Sep 17 00:00:00 2001
From: Frostie314159 <iam.an.programmer@gmail.com>
Date: Mon, 11 Dec 2023 13:27:55 +0100
Subject: [PATCH 1/3] Introduce reset_{at|after} functions for Ticker.

---
 embassy-time/src/timer.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs
index 574d715da..3444d3e24 100644
--- a/embassy-time/src/timer.rs
+++ b/embassy-time/src/timer.rs
@@ -184,6 +184,16 @@ impl Ticker {
         self.expires_at = Instant::now() + self.duration;
     }
 
+    /// Reset the ticker to fire for the next time on the deadline.
+    pub fn reset_at(&mut self, deadline: Instant) {
+        self.expires_at = deadline;
+    }
+
+    /// Resets the ticker, after the specified duration has passed.
+    pub fn reset_after(&mut self, after: Duration) {
+        self.expires_at = Instant::now() + after;
+    }
+
     /// Waits for the next tick.
     pub fn next(&mut self) -> impl Future<Output = ()> + '_ {
         poll_fn(|cx| {

From 8707462ec23807782796fbac4295bc5bce9ff136 Mon Sep 17 00:00:00 2001
From: Frostie314159 <iam.an.programmer@gmail.com>
Date: Mon, 11 Dec 2023 16:11:57 +0100
Subject: [PATCH 2/3] Adjusted documentation and reset_after behaviour.

---
 embassy-time/src/timer.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs
index 3444d3e24..fe0e93951 100644
--- a/embassy-time/src/timer.rs
+++ b/embassy-time/src/timer.rs
@@ -185,13 +185,15 @@ impl Ticker {
     }
 
     /// Reset the ticker to fire for the next time on the deadline.
+    /// If the deadline is in the past, the ticker will fire instantly.
     pub fn reset_at(&mut self, deadline: Instant) {
         self.expires_at = deadline;
     }
 
     /// Resets the ticker, after the specified duration has passed.
+    /// If the specified duration is zero, the next tick will be after the duration of the ticker.
     pub fn reset_after(&mut self, after: Duration) {
-        self.expires_at = Instant::now() + after;
+        self.expires_at = Instant::now() + after + self.duration;
     }
 
     /// Waits for the next tick.

From 2ea1040e073a54d2a97f75c7d68d0d9a230d15c8 Mon Sep 17 00:00:00 2001
From: Frostie314159 <iam.an.programmer@gmail.com>
Date: Fri, 22 Mar 2024 08:50:56 +0100
Subject: [PATCH 3/3] Adjusted behavior.

---
 embassy-time/src/timer.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs
index 763bfdeeb..d6d0a46e2 100644
--- a/embassy-time/src/timer.rs
+++ b/embassy-time/src/timer.rs
@@ -190,10 +190,10 @@ impl Ticker {
         self.expires_at = Instant::now() + self.duration;
     }
 
-    /// Reset the ticker to fire for the next time on the deadline.
+    /// Reset the ticker at the deadline.
     /// If the deadline is in the past, the ticker will fire instantly.
     pub fn reset_at(&mut self, deadline: Instant) {
-        self.expires_at = deadline;
+        self.expires_at = deadline + self.duration;
     }
 
     /// Resets the ticker, after the specified duration has passed.