Template Class PeriodicTimer

Class Documentation

template<typename T>
class PeriodicTimer

A timer class which unlike the Timeout class will restart when execute is called and returns that the timer has expired. Keeps its expire times aligned with the given timeout period (i.e.: the timeout time will always be a multiple of the period it is constructed to timeout in +/- some constant due to program startup time)

Public Functions

inline PeriodicTimer()
inline explicit PeriodicTimer(uint32_t period)
inline void restart()

Set the timer to expire period units of time away from the time at which this function was called.

inline void restart(uint32_t period)

Similar to restart() but redefine the period of the timer.

Parameters:

period[in] the new period to use for this PeriodicTimer

inline void stop()

Stop the timer.

inline bool execute()

Returns true on the first call when timer has expired since restart(). If timer is checked and has expired, next expiration time is set to the closest time which is an integer product of the period away from the time this timer expired.

Returns:

true the first time the timer has expired (timeout has been reached) since last restart()

inline bool isStopped() const
Returns:

true if the timer is stopped