FastLED 3.9.3
Loading...
Searching...
No Matches
timer.h
1#pragma once
2
3#include <stdint.h>
4
5class Timer {
6 public:
7 Timer() : start_time(0), duration(0), running(false) {}
8 void start(uint32_t now, uint32_t duration) {
9 start_time = now;
10 this->duration = duration;
11 running = true;
12 }
13 bool update(uint32_t now) {
14 if (!running) {
15 return false;
16 }
17 uint32_t elapsed = now - start_time;
18 if (elapsed > duration) {
19 running = false;
20 return false;
21 }
22 return true;
23 }
24
25 private:
26 uint32_t start_time;
27 uint32_t duration;
28 bool running;
29};
Definition timer.h:5