-
Notifications
You must be signed in to change notification settings - Fork 0
/
modtimer.h
46 lines (38 loc) · 862 Bytes
/
modtimer.h
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
39
40
41
42
43
44
45
46
#include<Thread.h>
#include <ThreadController.h>
#define SECOND 1000
int seconds = 0;
int minutes = 0;
int hours = 0;
int days = 0;
ThreadController controll = ThreadController();
Thread* thread_timer = new Thread();
void stopwatch(){
if(seconds > 59){
seconds = 0;
minutes = minutes + 1;
}
if(minutes > 59){
minutes = 0;
hours = hours + 1;
}
if(hours > 24){
days = days + 1;
hours = 0;
minutes = 0;
seconds = 0;
}
seconds = seconds + 1;
}
void createTimer(){
seconds = 0;
minutes = 0;
hours = 0;
days = 0;
thread_timer->onRun(stopwatch);
thread_timer->setInterval(1000);
controll.add(thread_timer);
}
void stopTimer(){
controll.remove(thread_timer);
}