Doxygen with github
|
Simple timer class, without using component architecture. More...
#include <ksSimpleTimer.h>
Public Member Functions | |
ksSimpleTimer (uint32_t intervalMs) | |
Constructs timer with interval (milliseconds). | |
void | setInterval (uint32_t intervalMs) |
Sets timer interval (milliseconds) and restarts the timer. | |
void | restart () |
Restarts timer. Will set last trigger time to current time w/o triggering the timer). | |
bool | triggered () |
Checks if timer interval just passed and resets the timer in this case. If timer interval is 0 then always returns false. | |
bool | hasTimePassed () const |
Checks if timer interval just passed. Restarting timer relies on user. If timer interval is 0 then always returns false. | |
Protected Attributes | |
uint32_t | intervalMs {0} |
Timer interval (milliseconds). | |
uint32_t | lastTriggerTimeMs {0} |
Last trigger time (milliseconds). | |
Simple timer class, without using component architecture.
Used to trigger events periodically. Internally checks if timer interval just passed. When interval is 0, never triggers the timer.
There are two ways to use it:
ksf::ksSimpleTimer::ksSimpleTimer | ( | uint32_t | intervalMs | ) |
Constructs timer with interval (milliseconds).
intervalMs | Initial timer interval in milliseconds. |
References intervalMs, and setInterval().
bool ksf::ksSimpleTimer::hasTimePassed | ( | ) | const |
Checks if timer interval just passed. Restarting timer relies on user. If timer interval is 0 then always returns false.
References intervalMs, and lastTriggerTimeMs.
Referenced by ksf::comps::ksMqttConnector::loop(), ksf::comps::ksWifiConnector::loop(), and triggered().
void ksf::ksSimpleTimer::setInterval | ( | uint32_t | intervalMs | ) |
Sets timer interval (milliseconds) and restarts the timer.
intervalMs | Timer interval in milliseconds. If 0 then timer is disabled. |
References intervalMs, and restart().
Referenced by ksSimpleTimer().
bool ksf::ksSimpleTimer::triggered | ( | ) |
Checks if timer interval just passed and resets the timer in this case. If timer interval is 0 then always returns false.
References hasTimePassed(), and restart().
Referenced by ksf::comps::ksDevStatMqttReporter::loop(), ksf::comps::ksWifiConfigurator::loop(), and ksf::comps::ksWifiConnector::loop().