- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.cpp
More file actions
Latest commit
32 lines (27 loc) · 536 Bytes
/
Copy pathTimer.cpp
File metadata and controls
32 lines (27 loc) · 536 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
#include"Timer.h"
#include"Arduino.h"
Timer::Timer(callbackType timeout) {
_delay = 0;
_timeout = timeout;
}
voidTimer::repeat(unsignedlong msDelay) {
_delay = msDelay;
_repeat = true;
_last = millis();
}
voidTimer::timeout(unsignedlong msDelay) {
_delay = msDelay;
_repeat = false;
_last = millis();
}
voidTimer::update() {
if (_delay && (millis() - _last > _delay)) {
_last += _delay;
_timeout();
if (!_repeat)
_delay = 0;
}
}
unsignedlongTimer::ms() {
returnmillis() - _last;
}