-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0OLEDupdates.ino
327 lines (198 loc) · 7.47 KB
/
0OLEDupdates.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
//~~~~~~~~~~~~~~~~~~~~~~~ OLED management Functions~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#### OLED ####~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void oledUpdate( byte colour0, byte colour1, byte colour2, byte colour3) { //colour = 1 white on black // colour = 0 black on white
//if (screenUpdate == true) {
if (strcmp(oledLine0, PoledLine0) != 0) { // If char strings are not equal
strcpy(PoledLine0, oledLine0);
screenUpdate = true;
}
if (strcmp(oledLine1, PoledLine1) != 0) { // If char strings are not equal
strcpy(PoledLine1, oledLine1);
screenUpdate = true;
}
if (strcmp(oledLine2, PoledLine2) != 0) { // If char strings are not equal
strcpy(PoledLine2, oledLine2);
screenUpdate = true;
}
if (strcmp(oledLine3, PoledLine3) != 0) { // If char strings are not equal
strcpy(PoledLine3, oledLine3);
screenUpdate = true;
}
display.setTextColor(colour0, !colour0);
display.setCursor(0, 0);
display.print(oledLine0);
display.setTextColor(colour1, !colour1);
display.setCursor(0, 8);
display.print(oledLine1);
display.setTextColor(colour2, !colour2);
display.setCursor(0, 16);
display.print(oledLine2);
display.setTextColor(colour3, !colour3);
display.setCursor(0, 24);
display.print(oledLine3);
if (screenUpdate == true) {
display.display();
// Serial.print("Oled Updated");
screenUpdate = false;
}
}
void oledChanged() { // returns true if the contents of the OLED buffer have been changed
//for (int i = 0; i < 4; i++) {
// if (strcmp(oledArray[i], PoledArray[i]) != 0) {
screenUpdate = true;
// Serial.print(oledArray[i][j]);
// Serial.print(" NOT EQUAL ");
// Serial.println(PoledArray[i][j]);
// break;
// }
// for (int j = 0; j < 21; j++) {
// }
// Serial.println("Break");
}
void oledTESTPRINT() { // test prints contents of OLED screen buffer to Serial monitor
for (int i = 0; i < 4; i++) { // i < 22 replaced
Serial.println(oledArray[i]);
}
// PoledArray[0] = oledArray[0];
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ These Scripts swap out contents of the screen buffer, ready to print to OLED when function is called
void messageReplace(int lineNumber, char newMessage[23]) { // Replace message in oledArrary[0]-[4] (buffer for oled) - 22 char long with specific 22 char long presaved messages oledLine0[23]
for (int i = 0; i < 21; i++) { // i < 22 replaced
if (lineNumber == 0) { // heading line
oledLine0[i] = newMessage[i];
}
if (lineNumber == 1) {
// if (oledLine1[i] != newMessage[i]) {
oledLine1[i] = newMessage[i];
// screenUpdate = true;
// }
}
if (lineNumber == 2) {
// if (oledLine2[i] != newMessage[i]) {
oledLine2[i] = newMessage[i];
// screenUpdate = true;
// }
}
if (lineNumber == 3) {
/// if (oledLine3[i] != newMessage[i]) {
oledLine3[i] = newMessage[i];
// screenUpdate = true;
/// }
}
// Serial.println("Message Replace");
// screenUpdate = true;
}
}
void line1Replace(byte lineNumber, char slot1[], char slot2[], char slot3[]) { // line 1 is split into 3 spaces. Of 3, 14 and 3 characters send "0" to ignore
// byte linenumber should be 1 for SAS RCS messages
// byte linenumber should be 2 for action messages & gear
if (slot1 != 0) {
for (int i = 0; i < 3; i++) { // this does slot 1
if (lineNumber == 1) {
oledLine1[i] = slot1[i];
} else if (lineNumber == 2) {
oledLine2[i] = slot1[i];
}
}
}
if (slot2 != 0) {
for (int i = 0; i < 14; i++) { // this does slot 2
if (lineNumber == 1) {
oledLine1[i + 4] = slot2[i];
} else if (lineNumber == 2) {
oledLine2[i + 4] = slot2[i];
}
}
}
if (slot3 != 0) {
for (int i = 0; i < 3; i++) { // this does slot 3
if (lineNumber == 1) {
oledLine1[i + 18] = slot3[i];
} else if (lineNumber == 2) {
oledLine2[i + 18] = slot3[i];
}
}
}
// screenUpdate = true;
// Serial.println("line1replace");
}
void lineDualreplace(byte lineNumber, char slot1[], char slot2[]) { // line 1 is split into 2 halves, 9 each with space between them
// byte linenumber should be 1 for SAS RCS messages
// byte linenumber should be 2 for action messages & gear
if (slot1 != 0) {
for (int i = 0; i < 9; i++) { // this does slot 1
if (lineNumber == 1) {
oledLine1[i] = slot1[i];
} else if (lineNumber == 2) {
oledLine2[i] = slot1[i];
} else if (lineNumber == 3) {
oledLine3[i] = slot1[i];
}
}
}
if (slot2 != 0) {
for (int i = 0; i < 9; i++) { // this does slot 2
if (lineNumber == 1) {
oledLine1[i+8] = slot2[i];
} else if (lineNumber == 2) {
oledLine2[i+8] = slot2[i];
} else if (lineNumber == 3) {
oledLine3[i+8] = slot2[i];
}
}
}
// screenUpdate = true;
// Serial.println("line1replace");
}
// This clears messages from the screen after a set amount of time. Only clears entire lines.
void timedMessageClear(int lineNumber) {
if (timedMessageset) {
if (millis() - lastMessage >= messageTimeout) {
messageReplace(lineNumber, lineWipe);
timedMessageset = false;
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ROTARY NAVIGATION SCRIPTS~~~~~~~~~~~~~~~~~~~~~~~~
//----------------------------------Global Page Navigation------------------------------
void globalPageNav() { // Function to select active PAGE NUMBER
// Serial.println(" ");
// Serial.println(pageNumber);
// Serial.println(itemNumber);
// Serial.println(pageScroll);
// Serial.println(" ");
if (itemNumber == 0 && pageScroll == true) { // If Menu Heading item is selected, scroll through pages
if (millis() - lastRotaryfire >= rotaryTimeout) {
if (rotaryCount > prevCount) {
pageNumber++;
}
else if (rotaryCount < prevCount) {
pageNumber--;
}
}
if (pageNumber > 1) {
pageNumber = 0;
} else if (pageNumber < 0) {
pageNumber = 1;
}
// screenUpdate = true;
}
} //-----------------------------------------end of global page nav---------------------------------
/*
Guide for Drawing Shapes
*/
/*
The drawRect(x, y, width, height, color) provides an easy way to draw a rectangle.
The (x, y) coordinates indicate the top left corner of the rectangle.
Then, you need to specify the width, height and color:
display.drawRect(10, 10, 50, 30, WHITE);
You can use the fillRect(x, y, width, height, color)
to draw a filled rectangle.
This method accepts the same arguments as drawRect().
The library also provides methods to displays rectangles with round corners:
drawRoundRect() and fillRoundRect().
These methods accepts the same arguments as previous methods plus the radius of the corner.
For example:
display.drawRoundRect(10, 10, 30, 50, 2, WHITE); // (x , y, width, height, cornerRadius, color)
display.fillRoundRect(10, 10, 30, 50, 2, WHITE); //(x , y, width, height, cornerRadius, color)
*/