semf
semf::SoftwareTimer Class Reference

Software SoftwareTimer which can be added to a TimeBase or used singular. More...

#include <softwaretimer.h>

Inheritance diagram for semf::SoftwareTimer:
Inheritance graph
Collaboration diagram for semf::SoftwareTimer:
Collaboration graph

Public Member Functions

 SoftwareTimer (uint32_t interval=0, bool start=false)
 Constructor using no timebase. More...
 
 SoftwareTimer (app::TimeBase &timeBase, uint32_t interval=0, bool start=false)
 Constructor using no timebase. More...
 
virtual ~SoftwareTimer ()=default
 
void setInterval (uint32_t interval)
 Set the timer interval. More...
 
uint32_t interval () const
 Get the timer interval. More...
 
uint32_t counterValue () const
 Get the current counter value. More...
 
void reset () override
 
void tick () override
 Counting the time. Must be called cyclically by a timer interrupt or similar. More...
 
void start () override
 Start time counting. More...
 
void stop () override
 
bool isRunning () const
 Check if the timer is running. More...
 
- Public Member Functions inherited from semf::app::Timer
virtual ~Timer ()=default
 
virtual void start ()=0
 
virtual void stop ()=0
 
virtual void reset ()=0
 
- Public Member Functions inherited from semf::TickReceiver
virtual ~TickReceiver ()=default
 
virtual void tick ()=0
 Is called by every tick. Is called periodically e.g. by a Timer object. More...
 
- Public Member Functions inherited from semf::LinkedList< T >::Node
virtual ~Node ()=default
 
T * next () const
 Returns a pointer to the next element in a list. More...
 
void setNext (T *next)
 Sets a pointer to the next element in a list. More...
 
T * previous () const
 Returns a pointer to the previous element in a list. More...
 
void setPrevious (T *previous)
 Sets a pointer to the previous element in a list. More...
 
bool isInAList ()
 Returns if a node is part of a LinkedList. More...
 

Additional Inherited Members

- Public Attributes inherited from semf::app::Timer
Signal timeout
 
Signal< Errorerror
 

Detailed Description

Software SoftwareTimer which can be added to a TimeBase or used singular.

For using the object combined with a TimeBase, add the timer to the TimeBase, for the singular usage case, call the count function e.g. in the microcontroller hardware timer interrupt service routine. Setting interval to zero will lead to the same behavior as setting the interval to one.

Definition at line 28 of file softwaretimer.h.

Constructor & Destructor Documentation

◆ SoftwareTimer() [1/2]

semf::SoftwareTimer::SoftwareTimer ( uint32_t  interval = 0,
bool  start = false 
)
explicit

Constructor using no timebase.

Parameters
intervalThe timer interval.
start

Definition at line 16 of file softwaretimer.cpp.

◆ SoftwareTimer() [2/2]

semf::SoftwareTimer::SoftwareTimer ( app::TimeBase timeBase,
uint32_t  interval = 0,
bool  start = false 
)
explicit

Constructor using no timebase.

Parameters
timeBaseThe timebase for the timer.
intervalThe timer interval.
start

Definition at line 22 of file softwaretimer.cpp.

Here is the call graph for this function:

◆ ~SoftwareTimer()

virtual semf::SoftwareTimer::~SoftwareTimer ( )
virtualdefault

Member Function Documentation

◆ counterValue()

uint32_t semf::SoftwareTimer::counterValue ( ) const

Get the current counter value.

Returns
current counter value

Definition at line 39 of file softwaretimer.cpp.

◆ interval()

uint32_t semf::SoftwareTimer::interval ( ) const

Get the timer interval.

Returns
The timer interval.

Definition at line 34 of file softwaretimer.cpp.

Here is the caller graph for this function:

◆ isRunning()

bool semf::SoftwareTimer::isRunning ( ) const

Check if the timer is running.

Returns
  • true: timer is running.
  • false: timer is not running.

Definition at line 76 of file softwaretimer.cpp.

Here is the caller graph for this function:

◆ reset()

void semf::SoftwareTimer::reset ( )
overridevirtual

Restart counting.

Implements semf::app::Timer.

Definition at line 44 of file softwaretimer.cpp.

Here is the caller graph for this function:

◆ setInterval()

void semf::SoftwareTimer::setInterval ( uint32_t  interval)

Set the timer interval.

Parameters
intervalThe timer interval.

Definition at line 29 of file softwaretimer.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

void semf::SoftwareTimer::start ( )
overridevirtual

Start time counting.

Remarks
Do not reset the time counter.

Implements semf::app::Timer.

Definition at line 64 of file softwaretimer.cpp.

Here is the caller graph for this function:

◆ stop()

void semf::SoftwareTimer::stop ( )
overridevirtual

Stop time counting.

Implements semf::app::Timer.

Definition at line 70 of file softwaretimer.cpp.

Here is the caller graph for this function:

◆ tick()

void semf::SoftwareTimer::tick ( )
overridevirtual

Counting the time. Must be called cyclically by a timer interrupt or similar.

Implements semf::TickReceiver.

Definition at line 49 of file softwaretimer.cpp.