-
Notifications
You must be signed in to change notification settings - Fork 6
/
timers.h
64 lines (45 loc) · 1005 Bytes
/
timers.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef TIMERS_H
#define TIMERS_H
unsigned long TimeLeft;
unsigned long TimeSpent;
unsigned long Steady;
/*
Should be called as much as possible
*/
void TimerRun() {
gCurrentTimeInMS = millis();
if (_seconds != myTimer.readTimer()) {
_seconds = myTimer.readTimer();
TimeSpent++;
Steady++;
if (TimeLeft) {
TimeLeft--;
if (TimeLeft == 5)
BuzzerPlay(BUZZ_TimeOut);
if ((TimeLeft % 60) == 0)
pumpTime++;
}
}
}
void TimerSet(unsigned long seconds) {
Steady = TimeSpent = 0;
TimeLeft = seconds;
}
void TimerShow(unsigned long Time, byte X, byte Y) {
byte Hours = (byte)(Time / 3600);
byte Minutes = (byte)((Time % 3600) / 60);
byte Seconds = (byte)(Time % 60);
lcd.setCursor(X, Y);
if (Hours < 10)
lcd.print("0");
lcd.print(Hours);
lcd.print(F(":"));
if (Minutes < 10)
lcd.print("0");
lcd.print(Minutes);
lcd.print(F(":"));
if (Seconds < 10)
lcd.print("0");
lcd.print(Seconds);
}
#endif