Doxygen with github
Loading...
Searching...
No Matches
ksSimpleTimer.h
1/*
2 * Copyright (c) 2021-2023, 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
15{
27 {
28 protected:
29 uint32_t intervalMs{0};
30 uint32_t lastTriggerTimeMs{0};
31
32 public:
37 ksSimpleTimer(uint32_t intervalMs);
38
43 void setInterval(uint32_t intervalMs);
44
48 void restart();
49
55 bool triggered();
56
62 bool hasTimePassed() const;
63 };
64}
Simple timer class, without using component architecture.
Definition ksSimpleTimer.h:27
uint32_t intervalMs
Timer interval (milliseconds).
Definition ksSimpleTimer.h:29
void setInterval(uint32_t intervalMs)
Sets timer interval (milliseconds) and restarts the timer.
Definition ksSimpleTimer.cpp:21
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:32
void restart()
Restarts timer. Will set last trigger time to current time w/o triggering the timer).
Definition ksSimpleTimer.cpp:43
ksSimpleTimer(uint32_t intervalMs)
Constructs timer with interval (milliseconds).
Definition ksSimpleTimer.cpp:16
bool hasTimePassed() const
Checks if timer interval just passed. Restarting timer relies on user. If timer interval is 0 then al...
Definition ksSimpleTimer.cpp:27
uint32_t lastTriggerTimeMs
Last trigger time (milliseconds).
Definition ksSimpleTimer.h:30