forked from toniebox-reverse-engineering/hackiebox_cfw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoxTimer.cpp
More file actions
38 lines (32 loc) · 767 Bytes
/
BoxTimer.cpp
File metadata and controls
38 lines (32 loc) · 767 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
35
36
37
38
#include "BoxTimer.h"
void BoxTimer::setTimer(unsigned long milliseconds) {
_currentMillis = millis();
_endMillis = _currentMillis + milliseconds;
_isRunning = true;
_hasChanged = true;
}
void BoxTimer::tick() {
if (!_isRunning) {
_hasChanged = false;
} else {
_currentMillis = millis();
if (_endMillis <= _currentMillis) {
_isRunning = false;
_hasChanged = true;
}
}
}
unsigned long BoxTimer::getTimeTillEnd() {
if (!_isRunning)
return 0;
return _endMillis - _currentMillis;
}
bool BoxTimer::isRunning() {
return _isRunning;
}
bool BoxTimer::wasRunning() {
return !_isRunning && _hasChanged;
}
void BoxTimer::stopTimer() {
_isRunning = false;
}