-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScreenHandler.h
103 lines (93 loc) · 2.89 KB
/
ScreenHandler.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//Draw main screen
void initiateScreen() {
tft.init();
tft.setRotation(2);
tft.fillScreen(TFT_BLACK);
tft.setCursor(0, 32, 1);
tft.setTextSize(1);
tft.setTextFont(2);
tft.fillRect(0, 0, 240, 16, TFT_BLUE);
tft.drawCentreString(" MacroDeck ", 120, 0, 2);
tft.fillRect(0, 16, 240, 45, TFT_BLUE);
tft.fillRect(0, 70, 240, 320, TFT_WHITE);
}
void clearScreen() {
tft.fillScreen(TFT_WHITE);
tft.setCursor(5, 32, 1);
}
//Shows the local ip address on the screen
void showIpAddress() {
while (WiFi.status() != WL_CONNECTED) {
delay(500);
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.drawCentreString("No WIFI", 30, 0, 2);
}
IPAddress ip = WiFi.localIP();
tft.fillRect(0, 0, 60, 16, TFT_BLUE);
tft.setTextColor(TFT_GREEN, TFT_BLACK);
tft.drawCentreString("WIFI", 30, 0, 2);
while (ip[0] == 0) {
delay(100);
}
String fullIp = String() + "Server: " + ip[0] + "." + ip[1] + "." + ip[2] + "." + ip[3];
//tft.drawString(String() + ESP.getVcc(), 0,18,2);
tft.drawCentreString(fullIp, 120, 18, 2);
}
//Shows currently selected page to the user
void setCurrentBoard() {
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.fillRect(0, 35, 240, 70, TFT_BLUE);
tft.drawCentreString(buttons["pages"][page]["name"].as<char*>(), 120, 36, 2);
}
//Shows all available pages to the user
void interateOverPages() {
tft.setTextColor(TFT_BLACK, TFT_WHITE);
//Reset page by filling in a black rectangle
tft.setCursor(0, 75);
tft.fillRect(0, 70, 240, 320, TFT_WHITE);
for (int i = 1; i <= buttons["pages"].size(); i++) {
tft.print(i);
tft.print(" : ");
tft.println(buttons["pages"][i - 1]["name"].as<String>());
}
tft.setTextColor(TFT_BLUE, TFT_WHITE);
tft.print(16);
tft.print(" : ");
tft.println("Choose different file");
}
//Shows all available buttons to the user
void interateOverButtonsOnPage() {
tft.setTextColor(TFT_BLACK, TFT_WHITE);
//Reset page by filling in a black rectangle
tft.setCursor(0, 75);
tft.fillRect(0, 70, 240, 320, TFT_WHITE);
for (int i = 1; i <= buttons["pages"][page]["buttons"].size(); i++) {
tft.print(i);
tft.print(" : ");
tft.println(buttons["pages"][page]["buttons"][i - 1]["description"].as<String>());
}
tft.setTextColor(TFT_BLUE, TFT_WHITE);
tft.print(16);
tft.print(" : ");
tft.println("Choose different page");
}
//Shows all available files to the user
void interateOverFiles() {
tft.setTextColor(TFT_BLACK, TFT_WHITE);
//Reset page by filling in a black rectangle
tft.setCursor(0, 75);
tft.fillRect(0, 70, 240, 320, TFT_WHITE);
for (int i = 1; i <= amount_of_files; i++) {
tft.print(i);
tft.print(" : ");
tft.println(BUTTON_JSON[i - 1]);
}
tft.setTextColor(TFT_BLUE, TFT_WHITE);
tft.print(16);
tft.print(" : ");
tft.println("Choose different page");
}
void showCalibrationComplete() {
tft.setTextColor(TFT_GREEN, TFT_BLACK);
tft.drawCentreString("Calibration complete", 0, 32, 1);
}