forked from methoxid/mySight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Timer.pde
37 lines (31 loc) · 807 Bytes
/
Timer.pde
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
class Timer {
int savedTime; // When Timer started
int totalTime; // How long Timer should last
boolean timerRunning = false;
Timer(int tempTotalTime) {
totalTime = tempTotalTime;
}
// Starting the timer
void start() {
// When the timer starts it stores the current time in milliseconds.
savedTime = millis();
timerRunning = true;
}
void stop() {
timerRunning = false;
}
// The function isFinished() returns true if 5,000 ms have passed.
// The work of the timer is farmed out to this method.
boolean isFinished() {
if (!timerRunning) {
return true;
}
// Check how much time has passed
int passedTime = millis()- savedTime;
if (passedTime > totalTime) {
return true;
} else {
return false;
}
}
}