semf
|
A TimeBase
is the bridge between e.g. a hardware timer (interrupt service routine) and TickReceiver
objects like /c SoftwareTimer. Multiple timers can be added to one TimeBase
object, but one TickReceiver
object can only be added to a single TimeBase
. It's also not possible to add a TickReceiver
object twice to a TimeBase
.
More...
#include <timebase.h>
Public Member Functions | |
TimeBase (app::Timer &timer, bool enable=false) | |
Constructor. More... | |
TimeBase (const TimeBase &other)=delete | |
void | add (TickReceiver &tickReceiver) override |
Adds e.g. a timer to this TimeBase . More... | |
void | remove (TickReceiver &tickReceiver) override |
Removes e.g. a timer from this TimeBase . More... | |
void | enable (bool enable=true) override |
Enables the TimeBase . More... | |
void | disable (bool disable=true) override |
Disables the TimeBase . More... | |
bool | isEnabled () const override |
Returns if the TimeBase is enabled. More... | |
Public Member Functions inherited from semf::app::TimeBase | |
virtual | ~TimeBase ()=default |
virtual void | add (TickReceiver &tickReceiver)=0 |
Adds e.g. a timer to this timebase. More... | |
virtual void | remove (TickReceiver &tickReceiver)=0 |
Removes e.g. a timer from this timebase. More... | |
virtual void | enable (bool enable=true)=0 |
Enables the TimeBase . More... | |
virtual void | disable (bool disable=true)=0 |
Disables the TimeBase . More... | |
virtual bool | isEnabled () const =0 |
Returns if the TimeBase is enabled. More... | |
A TimeBase
is the bridge between e.g. a hardware timer (interrupt service routine) and TickReceiver
objects like /c SoftwareTimer. Multiple timers can be added to one TimeBase
object, but one TickReceiver
object can only be added to a single TimeBase
. It's also not possible to add a TickReceiver
object twice to a TimeBase
.
When e.g. the hardware timer interrupt elapses, the count function of every previously added TickReceiver
will be called in the order, the SoftwareTimer
objects were added.
A TimeBase
can easily be enabled
or disabled
. A disabled TimeBase
does not call the timers count functions until it's enabled again.
count
function must be called cyclically e.g. by a the interrupt service routine of a microcontroller. Definition at line 23 of file timebase.h.
|
explicit |
Constructor.
timer | Timer interface (e.g. hardware timer). |
enable | Enables the TimeBase . |
Definition at line 15 of file timebase.cpp.
|
explicitdelete |
|
overridevirtual |
Adds e.g. a timer to this TimeBase
.
tickReceiver | e.g. /c SoftwareTimer or /c DigitalInPolling to add. |
Implements semf::app::TimeBase.
Definition at line 22 of file timebase.cpp.
|
overridevirtual |
Disables the TimeBase
.
disable | true disables the TimeBase . |
Implements semf::app::TimeBase.
Definition at line 37 of file timebase.cpp.
|
overridevirtual |
Enables the TimeBase
.
enable | true enables the TimeBase . |
Implements semf::app::TimeBase.
Definition at line 32 of file timebase.cpp.
|
overridevirtual |
Returns if the TimeBase
is enabled.
Only a enabled timebase's timers count and elapse.
true
for TimeBase
enabled, otherwise false
. Implements semf::app::TimeBase.
Definition at line 42 of file timebase.cpp.
|
overridevirtual |
Removes e.g. a timer from this TimeBase
.
tickReceiver | e.g. /c SoftwareTimer or /c DigitalInPolling to remove. |
Implements semf::app::TimeBase.
Definition at line 27 of file timebase.cpp.