-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlcd.cpp
66 lines (60 loc) · 1.71 KB
/
lcd.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <lcd.hpp>
#include <LiquidCrystal.h>
#include <timestamp.hpp>
#include <alarm.hpp>
void setCurrentTime(struct lcd_t *display, struct timestamp_t *timestamp) {
display->lastRowText = "Current Time";
display->firstRowText = formatTimeText(timestamp);
}
void setAlarmTime(struct lcd_t *display, struct alarm_t *alarm) {
display->lastRowText = "Alarm";
display->firstRowText = formatAlarmText(alarm);
}
void initializeDisplay(struct lcd_t *display, struct timestamp_t *timestamp) {
display->editChoice = 0;
setCurrentTime(display, timestamp);
}
void toggleDisplay(struct lcd_t *display) {
display->displayChoice = !display->displayChoice;
}
void setLCDText(struct lcd_t *display, struct timestamp_t *timestamp, struct alarm_t *alarm) {
display->displayChoice == LOW ? setCurrentTime(display, timestamp) : setAlarmTime(display, alarm);
}
void adjustCurrentlyDisplayedTime(struct lcd_t *display, struct timestamp_t *timestamp, struct alarm_t *alarm) {
if(display->displayChoice == LOW) {
switch(display->editChoice) {
case 0:
break;
case 1:
adjustClockHours(timestamp);
break;
case 2:
adjustClockMinutes(timestamp);
break;
case 3:
adjustClockSeconds(timestamp);
break;
default:
display->editChoice = 0;
break;
}
} else if(display->displayChoice == HIGH) {
switch(display->editChoice) {
case 0:
break;
case 1:
adjustAlarmHours(alarm);
break;
case 2:
adjustAlarmMinutes(alarm);
break;
case 3:
adjustAlarmSeconds(alarm);
break;
default:
saveAlarm(alarm);
display->editChoice = 0;
break;
}
}
}