-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTime.cpp
45 lines (40 loc) · 890 Bytes
/
Time.cpp
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
#include "Time.h"
#include "Arduino.h"
bool setTime(unsigned long& timeMark) {
if(timeMark == 0) {
timeMark = millis();
return 1;
}
else {
return 0;
}
}
bool countSeconds(unsigned long seconds, unsigned long& timeMark) {
unsigned long t = millis();
if(t - timeMark > seconds * 1000) {
return 1;
}
else {
return 0;
}
}
bool checkTimeMinutes(unsigned long count, unsigned long& timeMark) {
unsigned long currentTime = millis();
if(currentTime - timeMark >= count * 60000) {
timeMark = 0;
return 1;
}
else {
return 0;
}
}
bool checkTimeSeconds(unsigned long count, unsigned long& timeMark) {
unsigned long currentTime = millis();
if(currentTime - timeMark >= count * 1000) {
timeMark = 0;
return 1;
}
else {
return 0;
}
}