-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreen.cpp
88 lines (69 loc) · 1.57 KB
/
Screen.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "Screen.h"
#include "custom-characters.h"
Screen::Screen(LiquidCrystal& LCD) {
this->LCD = LCD;
status = ScreenStatus::AWAKE;
defineCustomChars();
}
void Screen::begin() {
LCD.begin(16, 2);
authorGreeting();
}
void Screen::sleep() {
status = ScreenStatus::SLEEP;
}
void Screen::wakeUp() {
status = ScreenStatus::AWAKE;
}
void Screen::setState(bool state) {
state ? wakeUp() : sleep();
}
void Screen::authorGreeting() {
LCD.clear();
LCD.print("Hi...");
delay(2000);
LCD.clear();
LCD.print("Created by n1md7");
LCD.setCursor(2, 2);
LCD.print("03.07.2017");
delay(2000);
LCD.clear();
}
void Screen::defineCustomChars() {
// Define custom characters for LCD.
// Max chars are restricted to 8.
LCD.createChar(1, C);
LCD.createChar(2, a);
LCD.createChar(3, r);
LCD.createChar(4, T);
LCD.createChar(5, u);
LCD.createChar(6, l);
LCD.createChar(7, i);
}
void Screen::print(String time, bool isActive) {
LCD.setCursor(0, 0);
isActive ? printDeviceIsOn() : printDeviceIsPaused();
LCD.print(time);
LCD.setCursor(2, 1);
isActive ? printStatusIsOn() : printStatusIsOff();
}
void Screen::printDeviceIsOn() {
// Print: "ჩართულია" on the LCD Screen
LCD.print(char(1));
LCD.print(char(2));
LCD.print(char(3));
LCD.print(char(4));
LCD.print(char(5));
LCD.print(char(6));
LCD.print(char(7));
LCD.print(char(2));
}
void Screen::printDeviceIsPaused() {
LCD.print("Paused: ");
}
void Screen::printStatusIsOn() {
LCD.print(" Status: ON");
}
void Screen::printStatusIsOff() {
LCD.print("Status: OFF");
}