Doxygen with github
Loading...
Searching...
No Matches
ksSimpleTimer.h
1/*
2 * Copyright (c) 2021-2025, Krzysztof Strehlau
3 *
4 * This file is a part of the ksIotFramework library.
5 * All licensing information can be found inside LICENSE.md file.
6 *
7 * https://github.com/cziter15/ksIotFrameworkLib/blob/master/LICENSE
8 */
9
10#pragma once
11
12#include <stdint.h>
13
14namespace ksf::misc
15{
27 {
28 protected:
29 uint32_t intervalMs{0};
30 uint32_t lastTriggerTimeMs{0};
31
32 public:
37 ksSimpleTimer(uint32_t intervalMs);
38
42 virtual ~ksSimpleTimer();
43
48 void setInterval(uint32_t intervalMs);
49
53 void restart();
54
60 bool triggered();
61
67 bool hasTimePassed() const;
68 };
69}
A simple timer class that does not rely on component architecture.
Definition ksSimpleTimer.h:27
void setInterval(uint32_t intervalMs)
Sets timer interval (milliseconds) and restarts the timer.
Definition ksSimpleTimer.cpp:23
bool hasTimePassed() const
Checks if timer interval just passed. Restarting timer relies on user. If timer interval is 0 then al...
Definition ksSimpleTimer.cpp:29
uint32_t lastTriggerTimeMs
Last trigger time (milliseconds).
Definition ksSimpleTimer.h:30
bool triggered()
Checks if timer interval just passed and resets the timer in this case. If timer interval is 0 then a...
Definition ksSimpleTimer.cpp:34
void restart()
Restarts timer. Will set last trigger time to current time w/o triggering the timer).
Definition ksSimpleTimer.cpp:45
uint32_t intervalMs
Timer interval (milliseconds).
Definition ksSimpleTimer.h:29
virtual ~ksSimpleTimer()
Destructs timer.
ksSimpleTimer(uint32_t intervalMs)
Constructs timer with interval (milliseconds).
Definition ksSimpleTimer.cpp:16