semf
softwaretimer.h
Go to the documentation of this file.
1
10#ifndef SEMF_UTILS_SYSTEM_SOFTWARETIMER_H_
11#define SEMF_UTILS_SYSTEM_SOFTWARETIMER_H_
12
16#include <cstdint>
17
18namespace semf
19{
29{
30public:
36 explicit SoftwareTimer(uint32_t interval = 0, bool start = false);
43 explicit SoftwareTimer(app::TimeBase& timeBase, uint32_t interval = 0, bool start = false);
44 virtual ~SoftwareTimer() = default;
45
50 void setInterval(uint32_t interval);
55 uint32_t interval() const;
60 uint32_t counterValue() const;
62 void reset() override;
64 void tick() override;
69 void start() override;
71 void stop() override;
77 bool isRunning() const;
78
79private:
80 bool m_running;
81 uint32_t m_counter = 0;
82 uint32_t m_interval;
83};
84} /* namespace semf */
85#endif /* SEMF_UTILS_SYSTEM_SOFTWARETIMER_H_ */
Software SoftwareTimer which can be added to a TimeBase or used singular.
Definition: softwaretimer.h:29
bool isRunning() const
Check if the timer is running.
virtual ~SoftwareTimer()=default
SoftwareTimer(uint32_t interval=0, bool start=false)
Constructor using no timebase.
uint32_t interval() const
Get the timer interval.
uint32_t counterValue() const
Get the current counter value.
void setInterval(uint32_t interval)
Set the timer interval.
void tick() override
Counting the time. Must be called cyclically by a timer interrupt or similar.
void start() override
Start time counting.
void stop() override
void reset() override
Interface for all classes receiving ticks like DigitalInPolling or SoftwareTimer.
Definition: tickreceiver.h:29
A TimeBase is the bridge between e.g. a hardware timer (interrupt service routine) and TickReceiver o...
Definition: timebase.h:36
Class for using timer hardware.
Definition: timer.h:24