Prusa3d Marlin fork
Public Member Functions | Protected Member Functions | List of all members
Timer< T > Class Template Reference

simple timer More...

#include <Timer.h>

Public Member Functions

void start ()
 Start timer.
 
void stop ()
 
bool running () const
 
bool expired (T msPeriod)
 Timer has expired. More...
 
elapsed ()
 Ticks since the timer was started. More...
 
bool expired_cont (T msPeriod)
 

Protected Member Functions

started () const
 

Detailed Description

template<class T>
class Timer< T >

Simple and memory saving implementation. Should handle timer register wrap around well. Resolution is one millisecond. To save memory, doesn't store timer period. If you wish timer which is storing period, derive from this.

Member Function Documentation

◆ elapsed()

template<typename T >
T Timer< T >::elapsed

This function returns 0 if the timer is not started. Otherwise, it returns the time in milliseconds since the timer was started. This function is expected to handle wrap around of time register well. The maximum elapsed time is dictated by the template type

◆ expired()

template<typename T >
bool Timer< T >::expired ( msPeriod)

Timer is considered expired after msPeriod has passed from time the timer was started. Timer is stopped after expiration. This function must be called at least each (T maximum value - msPeriod) milliseconds to be sure to catch first expiration. This function is expected to handle wrap around of time register well.

Parameters
msPeriodTime interval in milliseconds. Do not omit "ul" when using constant literal with LongTimer.
Return values
trueTimer has expired
falseTimer not expired yet, or is not running, or time window in which is timer considered expired passed.

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