Timer

The Timer class is the most flexible way to use software timers, supporting extended time intervals and delegate callback functions so you can use it with class methods, capturing lambdas, etc.

group timer

Extended timer queue class.

Typedefs

typedef std::function<void()> TimerDelegateStdFunction

Deprecated:

Use TimerDelegate

Functions

void setInterval(TickType interval)
void longTick()
template<class TimerClass>
class OsTimer64Api : public CallbackTimerApi<OsTimer64Api<TimerClass>>
#include <Timer.h>

Class template implementing an extended OS Timer with 64-bit microsecond times and delegate callback support.

template<typename TimerApi>
class DelegateCallbackTimer : public CallbackTimer<TimerApi>
#include <Timer.h>

Class template adding delegate callback method support to the basic CallbackTimer template.

Public Functions

template<TimeType microseconds>
inline DelegateCallbackTimer &initializeUs(TimerDelegate delegateFunction)

Initialise timer in microseconds, with static check.

Template Parameters

microsecondsTimer interval in microseconds

Parameters

delegateFunction – Function to call when timer triggers

Returns

ExtendedCallbackTimer& – Reference to timer

template<uint32_t milliseconds>
inline DelegateCallbackTimer &initializeMs(TimerDelegate delegateFunction)

Initialise hardware timer in milliseconds, with static check.

Template Parameters

millisecondsTimer interval in milliseconds

Parameters

delegateFunction – Function to call when timer triggers

Returns

ExtendedCallbackTimer& – Reference to timer

inline DelegateCallbackTimer &initializeMs(uint32_t milliseconds, TimerDelegate delegateFunction)

Initialise millisecond timer.

Note

Delegate callback method

Parameters
  • milliseconds – Duration of timer in milliseconds

  • delegateFunction – Function to call when timer triggers

inline DelegateCallbackTimer &initializeUs(uint32_t microseconds, TimerDelegate delegateFunction)

Initialise microsecond timer.

Note

Delegate callback method

Parameters
  • microseconds – Duration of timer in milliseconds

  • delegateFunction – Function to call when timer triggers

inline void setCallback(TimerDelegate delegateFunction)

Set timer trigger function using Delegate callback method.

Note

Don’t use this for interrupt timers

Parameters

delegateFunction – Function to be called on timer trigger

class Timer : public DelegateCallbackTimer<OsTimer64Api<Timer>>
#include <Timer.h>

Callback timer class.

Subclassed by Profiling::MinMaxTimes< Timer >

class AutoDeleteTimer : public DelegateCallbackTimer<OsTimer64Api<AutoDeleteTimer>>
#include <Timer.h>

Auto-delete callback timer class.