-
Notifications
You must be signed in to change notification settings - Fork 0
/
LCD.ino
80 lines (72 loc) · 1.75 KB
/
LCD.ino
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
void updateDisplay() {
// Use a pot to scan screens like a radio
short newScreen = (analogRead(SCREEN_PIN) * MAX_SCREENS) / (MAX_ANALOG + 1);
// When we change screen do a full clear
if (currentScreen != newScreen) {
lcd.clear();
}
// Update the current screen
switch (newScreen) {
case 0:
temperatureScreen();
break;
case 1:
runtimeScreen();
break;
case 2:
recordsScreen();
break;
}
currentScreen = newScreen;
}
void temperatureScreen() {
lcd.setCursor(0, 0);
lcd.print("Current Temperature");
lcd.setCursor(0, 1);
lcd.print(currentTemperature);
lcd.setCursor(0, 2);
lcd.print("Target Temperature");
lcd.setCursor(0, 3);
lcd.print(targetTemperature);
}
void runtimeScreen() {
unsigned long now = (millis() / 1000);
unsigned short seconds = now % 60;
unsigned short minutes = (now / 60) % 60;
unsigned short hours = (now / 3600) % 24;
unsigned short days = now / 86400;
lcd.setCursor(0, 0);
lcd.print("Current Runtime");
lcd.setCursor(0, 1);
lcd.print(makeRuntimeString(days));
lcd.print(":");
lcd.print(makeRuntimeString(hours));
lcd.print(":");
lcd.print(makeRuntimeString(minutes));
lcd.print(":");
lcd.print(makeRuntimeString(seconds));
lcd.setCursor(0, 2);
lcd.print("Relay state: ");
if (digitalRead(RELAY_PIN)) {
lcd.print("on ");
} else {
lcd.print("off");
}
}
void recordsScreen() {
lcd.setCursor(0, 0);
lcd.print("Temperature Records");
lcd.setCursor(0, 1);
lcd.print("High: ");
lcd.print(allTimeHigh);
lcd.setCursor(0, 2);
lcd.print("Low: ");
lcd.print(allTimeLow);
}
String makeRuntimeString(unsigned short value) {
if (value < 10) {
return "0" + String(value);
} else {
return String(value);
}
}