Skip to content

Commit 109f88e

Browse files
committed
src:arduino-timer: make ticks calculation optional
Use tick<void>() instead of tick() to avoid calculating the ticks count. loop { timer.tick<void>(); // avoids ticks() calculation }
1 parent fda5ccb commit 109f88e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/arduino-timer.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ class Timer {
9999
/* Ticks the timer forward - call this function in loop() */
100100
unsigned long
101101
tick()
102+
{
103+
tick<void>();
104+
return ticks();
105+
}
106+
107+
template <typename R> void
108+
tick()
102109
{
103110
for (size_t i = 0; i < max_tasks; ++i) {
104111
struct task * const task = &tasks[i];
@@ -115,8 +122,6 @@ class Timer {
115122
}
116123
}
117124
}
118-
119-
return ticks();
120125
}
121126

122127
/* Ticks until the next event */

0 commit comments

Comments
 (0)