-
Notifications
You must be signed in to change notification settings - Fork 0
/
displayfunctions.ino
executable file
·191 lines (179 loc) · 6.76 KB
/
displayfunctions.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// Shows 'Connecting to:' and SSID underneath on startup and connecting to WiFi on power on
void drawConnectingTo() {
String ssidString = String(ssid);
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_10);
display.drawString(0, 0, "Connecting to: ");
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.setFont(ArialMT_Plain_16);
display.drawString(64, 17, ssidString);
display.display();
}
// Shows progress bar when device is attempting to connect to WiFi
void drawProgressBar(int x) {
int progress = x % 100;
// draw the progress bar
display.drawProgressBar(0, 46, 127, 10, progress);
display.display();
}
// Show 'Powered by' loaded letter by letter - intro on power on
void drawPoweredBy() {
const int horalign = 0;
const int veralign = 20;
String poweredByArray [9] = { "o", "w", "e", "r", "e", "d", " ", "b", "y" };
String poweredBy = "P";
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_24);
display.drawString(horalign, veralign, poweredBy);
display.display();
for (String x : poweredByArray) {
delay(50);
poweredBy += x;
display.drawString(horalign, veralign, poweredBy);
display.display();
}
delay(750);
}
// Display Image Prdel Logo after 'Powered on' on power on
void drawPrdelLogo() {
display.clear();
display.drawXbm(0, 0, prdel_width, prdel_height, prdel_bits);
display.display();
}
// Handle displaying default alternating screen
void defaultScreenInfo() {
// If screen is displaying easter egg or if someone is shopping, dont override screen
if (screenStateEasterEgg == true || screenStateShopping == true) {
return;
}
screenStateShouldChange = false;
display.clear();
if (screenStateAlternate == false) {
display.drawXbm(0, 0, iotlogo_width, iotlogo_height, iotlogo_bits);
display.setFont(ArialMT_Plain_10);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 34, "IP:");
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 48 , IpAddressStr);
screenStateAlternate = true;
} else {
display.drawXbm(0, 0, iotlogo_width, iotlogo_height, iotlogo_bits);
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 30, "Pro nákup zvolte");
display.drawXbm(13, 51, hacek_width, hacek_height, hacek_bits);
display.drawString(64, 48, "císlo zákazníka");
screenStateAlternate = false;
}
display.display();
}
// Displays super secret game menu
void gameMenu() {
display.clear();
display.setFont(ArialMT_Plain_10);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 0, "Tajné herní menu");
display.setTextAlignment(TEXT_ALIGN_LEFT);
if (gameMenuSelect == 1) display.drawString(5, 12, ">");
display.drawString(10, 12, "Spustit hru Snake");
if (gameMenuSelect == 2) display.drawString(5, 24, ">");
display.drawString(10, 24, "High scores");
display.setTextAlignment(TEXT_ALIGN_CENTER);
//display.drawString(64, 36, "Storno stiskem #");
//display.drawString(64, 36, "Spust * Storno #");
display.drawString(64, 36, "Potvrdit Návrat #");
display.drawString(64, 48, "2 / 8 pohyb v menu");
display.setFont(ArialMT_Plain_24);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(49, 36, "*");
display.display();
}
// Displays HTTP Request to show customer something is happening
void drawHttpRequest() {
display.clear();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 20, "HTTP dotaz");
display.display();
}
// Displays product choice menu after customer has been set
void drawChooseProduct(bool makeHttpRequest) {
display.clear();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 0, "Zvolte ID produktu");
display.setFont(ArialMT_Plain_10);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 48, "Storno stiskem #");
if (makeHttpRequest) {
// Invokes GET customerName API to retrieve name - webservice may reset everything if customer is not found
display.drawString(0, 36, "Zákazník: ");
display.drawString(48, 36, getCustomerName());
} else {
// If customer name started with '0' do not invoke web request
display.drawString(0, 36, "Zákazník: " + customerNumber);
}
display.display();
}
// Displays customer selection screen
void drawEnterCustomerNumber() {
display.clear();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 0, "ID zákazníka");
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 18, customerNumber);
display.setFont(ArialMT_Plain_10);
display.drawString(0, 36, "Potvrd' stiskem");
display.setFont(ArialMT_Plain_24);
display.drawString(77, 36, "*");
display.setFont(ArialMT_Plain_10);
display.drawString(0, 48, "Storno stiskem #");
display.display();
}
// Displays 'Connected!' when device connects to Wi-fi
void drawWifiConnected() {
display.clear();
display.setFont(ArialMT_Plain_24);
display.drawString(64, 20, "Connected!");
display.display();
}
// Displays 'Customer/Product not found or Product not on stock' when standard API returns 404 return value
void drawApiStandardError(int errorType) {
display.clear();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_CENTER);
if (errorType == 1) {
display.drawString(64, 10, "Zákazník");
display.drawString(64, 30, "nenalezen");
} else if (errorType == 2) {
display.drawString(64, 10, "Produkt");
display.drawString(64, 30, "nenalezen");
} else {
display.drawString(64, 10, "Produkt");
display.drawString(64, 30, "není skladem");
}
display.display();
}
// Displays 'Error' when HTTP Request terminates with non-standard error i.e. website or connection is down
void drawTerminatingError() {
display.clear();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 10, "Hasta");
display.drawString(64, 30, "la vista");
display.display();
}
// Displays success message with product name and price
void drawProductBought(const char* productName, const int productPrice) {
display.clear();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 0, "Zakoupil jste");
display.drawString(64, 20, productName);
display.drawString(64, 40, String(productPrice) + ",-");
display.display();
}