Skip to content

Commit 3ce1c35

Browse files
committed
src:arduino-timer: cancel all version of cancel()
timer.cancel() will cancel all the timer's tasks.
1 parent fda5ccb commit 3ce1c35

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/arduino-timer.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ class Timer {
9696
task = (Task)NULL;
9797
}
9898

99+
/* Cancel all timer tasks */
100+
void
101+
cancel()
102+
{
103+
for (size_t i = 0; i < max_tasks; ++i) {
104+
struct task * const t = &tasks[i];
105+
remove(t);
106+
}
107+
}
108+
99109
/* Ticks the timer forward - call this function in loop() */
100110
unsigned long
101111
tick()

0 commit comments

Comments
 (0)