Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::arch::PeriodicTimer< T > Class Template Reference

#include <periodic_timer.hpp>

Public Member Functions

 PeriodicTimer ()
 
 PeriodicTimer (uint32_t period)
 
void restart ()
 
void restart (uint32_t period)
 
void stop ()
 
bool execute ()
 
bool isStopped () const
 

Detailed Description

template<typename T>
class tap::arch::PeriodicTimer< T >

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)

Constructor & Destructor Documentation

◆ PeriodicTimer() [1/2]

template<typename T >
tap::arch::PeriodicTimer< T >::PeriodicTimer ( )
inline

◆ PeriodicTimer() [2/2]

template<typename T >
tap::arch::PeriodicTimer< T >::PeriodicTimer ( uint32_t  period)
inlineexplicit

Member Function Documentation

◆ execute()

template<typename T >
bool tap::arch::PeriodicTimer< T >::execute ( )
inline

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()

◆ isStopped()

template<typename T >
bool tap::arch::PeriodicTimer< T >::isStopped ( ) const
inline
Returns
true if the timer is stopped

◆ restart() [1/2]

template<typename T >
void tap::arch::PeriodicTimer< T >::restart ( )
inline

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

◆ restart() [2/2]

template<typename T >
void tap::arch::PeriodicTimer< T >::restart ( uint32_t  period)
inline

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

Parameters
[in]periodthe new period to use for this PeriodicTimer

◆ stop()

template<typename T >
void tap::arch::PeriodicTimer< T >::stop ( )
inline

Stop the timer.


The documentation for this class was generated from the following file: