distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::SoftwareTimer Class Referenceabstract

SoftwareTimer class is an abstract interface for software timers. More...

#include "distortos/SoftwareTimer.hpp"

Inheritance diagram for distortos::SoftwareTimer:
[legend]

Public Member Functions

virtual ~SoftwareTimer ()=default
 SoftwareTimer's destructor. More...
 
virtual bool isRunning () const =0
 
int start (TickClock::duration duration, TickClock::duration period={})
 Starts the timer. More...
 
template<typename Rep1 , typename Period1 , typename Rep2 = TickClock::rep, typename Period2 = TickClock::period>
int start (const std::chrono::duration< Rep1, Period1 > duration, const std::chrono::duration< Rep2, Period2 > period={})
 Starts the timer. More...
 
virtual int start (TickClock::time_point timePoint, TickClock::duration period={})=0
 Starts the timer. More...
 
template<typename Duration , typename Rep = TickClock::rep, typename Period = TickClock::period>
int start (const std::chrono::time_point< TickClock, Duration > timePoint, const std::chrono::duration< Rep, Period > period={})
 Starts the timer. More...
 
virtual int stop ()=0
 Stops the timer. More...
 

Static Protected Member Functions

static void softwareTimerRunner (SoftwareTimer &softwareTimer)
 Software timer's function runner. More...
 

Private Member Functions

virtual void run ()=0
 "Run" function of software timer More...
 

Detailed Description

SoftwareTimer class is an abstract interface for software timers.

Constructor & Destructor Documentation

◆ ~SoftwareTimer()

virtual distortos::SoftwareTimer::~SoftwareTimer ( )
virtualdefault

SoftwareTimer's destructor.

Member Function Documentation

◆ isRunning()

virtual bool distortos::SoftwareTimer::isRunning ( ) const
pure virtual
Returns
true if the timer is running, false otherwise

Implemented in distortos::SoftwareTimerCommon.

◆ run()

virtual void distortos::SoftwareTimer::run ( )
privatepure virtual

"Run" function of software timer

This should be overridden by derived classes.

Implemented in distortos::StaticSoftwareTimer< Function, Args >, and distortos::DynamicSoftwareTimer.

Here is the caller graph for this function:

◆ softwareTimerRunner()

void distortos::SoftwareTimer::softwareTimerRunner ( SoftwareTimer softwareTimer)
staticprotected

Software timer's function runner.

Parameters
[in]softwareTimeris a reference to SoftwareTimer object that is being run
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start() [1/4]

int distortos::SoftwareTimer::start ( TickClock::duration  duration,
TickClock::duration  period = {} 
)

Starts the timer.

Note
The duration will never be shorter, so one additional tick is always added to the duration.
Parameters
[in]durationis the duration after which the function will be executed
[in]periodis the period used to restart repetitive software timer, 0 for one-shot software timers, default - 0
Returns
0 on success, error code otherwise
Here is the call graph for this function:

◆ start() [2/4]

template<typename Rep1 , typename Period1 , typename Rep2 = TickClock::rep, typename Period2 = TickClock::period>
int distortos::SoftwareTimer::start ( const std::chrono::duration< Rep1, Period1 >  duration,
const std::chrono::duration< Rep2, Period2 >  period = {} 
)
inline

Starts the timer.

Note
The duration must not be shorter, so one additional tick is always added to the duration.
Template Parameters
Rep1is type of tick counter used in duration
Period1is std::ratio type representing the tick period of the clock used in duration, seconds
Rep2is type of tick counter used in period
Period2is std::ratio type representing the tick period of the clock used in period, seconds
Parameters
[in]durationis the duration after which the function will be executed
[in]periodis the period used to restart repetitive software timer, 0 for one-shot software timers, default - 0
Returns
0 on success, error code otherwise

◆ start() [3/4]

virtual int distortos::SoftwareTimer::start ( TickClock::time_point  timePoint,
TickClock::duration  period = {} 
)
pure virtual

Starts the timer.

Parameters
[in]timePointis the time point at which the function will be executed
[in]periodis the period used to restart repetitive software timer, 0 for one-shot software timers, default - 0
Returns
0 on success, error code otherwise

Implemented in distortos::SoftwareTimerCommon.

◆ start() [4/4]

template<typename Duration , typename Rep = TickClock::rep, typename Period = TickClock::period>
int distortos::SoftwareTimer::start ( const std::chrono::time_point< TickClock, Duration >  timePoint,
const std::chrono::duration< Rep, Period >  period = {} 
)
inline

Starts the timer.

Template Parameters
Durationis a std::chrono::duration type used to measure duration
Repis type of tick counter used in period
Periodis std::ratio type representing the tick period of the clock used in period, seconds
Parameters
[in]timePointis the time point at which the function will be executed
[in]periodis the period used to restart repetitive software timer, 0 for one-shot software timers, default - 0
Returns
0 on success, error code otherwise

◆ stop()

virtual int distortos::SoftwareTimer::stop ( )
pure virtual

Stops the timer.

Returns
0 on success, error code otherwise

Implemented in distortos::SoftwareTimerCommon.


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