-
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtimerMinim.h
More file actions
34 lines (29 loc) · 1001 Bytes
/
timerMinim.h
File metadata and controls
34 lines (29 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class timerMinim
{
public:
timerMinim(uint32_t interval); // объявление таймера с указанием интервала
void setInterval(uint32_t interval); // установка интервала работы таймера
boolean isReady(); // возвращает true, когда пришло время. Сбрасывается в false сам (AUTO) или вручную (MANUAL)
void reset(); // ручной сброс таймера на установленный интервал
private:
uint32_t _timer = 0;
uint32_t _interval = 0;
};
timerMinim::timerMinim(uint32_t interval) {
_interval = interval;
_timer = millis();
}
void timerMinim::setInterval(uint32_t interval) {
_interval = interval;
}
boolean timerMinim::isReady() {
if (millis() - _timer >= _interval) {
_timer = millis();
return true;
} else {
return false;
}
}
void timerMinim::reset() {
_timer = millis();
}