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

#include <timeout.hpp>

Public Member Functions

 Timeout ()
 
 Timeout (uint32_t timeout)
 
void restart (uint32_t timeout)
 
void stop ()
 
bool isStopped () const
 
bool isExpired () const
 
uint32_t timeRemaining () const
 
bool execute ()
 

Static Public Attributes

static constexpr auto TimeFunc = T
 

Friends

template<typename H >
class PeriodicTimer
 

Detailed Description

template<uint32_t(*)() T>
class tap::arch::Timeout< T >

A class for keeping track of a timer that expires. Template argument expects a function pointer that returns a uin32_t representing some absolute measure of time.

Doesn't start until restart() is called

Constructor & Destructor Documentation

◆ Timeout() [1/2]

template<uint32_t(*)() T>
tap::arch::Timeout< T >::Timeout ( )
inline

◆ Timeout() [2/2]

template<uint32_t(*)() T>
tap::arch::Timeout< T >::Timeout ( uint32_t  timeout)
inlineexplicit

Member Function Documentation

◆ execute()

template<uint32_t(*)() T>
bool tap::arch::Timeout< T >::execute ( )
inline

Returns true on the first call when timer has expired since restart. Use to only catch the timeout expiration once.

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

◆ isExpired()

template<uint32_t(*)() T>
bool tap::arch::Timeout< T >::isExpired ( ) const
inline
Returns
true if the timer has expired (timeout has been reached) and is NOT stopped.

◆ isStopped()

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

◆ restart()

template<uint32_t(*)() T>
void tap::arch::Timeout< T >::restart ( uint32_t  timeout)
inline

Set the timer to expire in timeout units of time.

Parameters
[in]timeoutthe amount of time from when this function is called that the timer should expire.

◆ stop()

template<uint32_t(*)() T>
void tap::arch::Timeout< T >::stop ( )
inline

Stop the timer. If expired, the expiration flags are cleared.

◆ timeRemaining()

template<uint32_t(*)() T>
uint32_t tap::arch::Timeout< T >::timeRemaining ( ) const
inline
Returns
time left in timer if still running and not yet expired

Friends And Related Symbol Documentation

◆ PeriodicTimer

template<uint32_t(*)() T>
template<typename H >
friend class PeriodicTimer
friend

Member Data Documentation

◆ TimeFunc

template<uint32_t(*)() T>
constexpr auto tap::arch::Timeout< T >::TimeFunc = T
staticconstexpr

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