-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEagleOS.ino
500 lines (456 loc) · 31 KB
/
EagleOS.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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SD.h>
#include <SPI.h>
#include <ArduinoSTL.h>
#include <system_configuration.h>
#include <time.h>
#include <unwind-cxx.h>
#include <vector>
static const PROGMEM uint16_t background[] = {
0x20, 0x841, 0x861, 0x1082, 0x10a2, 0x18c3, 0x18e3, 0x2104, 0x2124, 0x2945, 0x2965, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x41e8, 0x4208, 0x4a29, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0x841, 0x841, 0x1062, 0x10a2, 0x18c3, 0x18c3, 0x2104, 0x2104, 0x2925, 0x2945, 0x3166, 0x3186, 0x31a6, 0x39c7, 0x41e8, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x7bef, 0x8430, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0x841, 0x1062, 0x1082, 0x18a3, 0x18c3, 0x20e4, 0x2104, 0x2124, 0x2945, 0x2965, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b4d, 0x738e, 0x73ae, 0x73ae, 0x7bcf, 0x8410, 0x8410, 0x8c51, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0x1062, 0x1082, 0x18a3, 0x18c3, 0x20e4, 0x2104, 0x2124, 0x2945, 0x2965, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5acb, 0x62ec, 0x632c, 0x6b2d, 0x6b6d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0x1082, 0x10a2, 0x18c3, 0x18e3, 0x2104, 0x2124, 0x2945, 0x2965, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a49, 0x4a69, 0x528a, 0x5aab, 0x5acb, 0x5aeb, 0x630c, 0x6b2d, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xa554, 0x10a2, 0x18c3, 0x18e3, 0x2104, 0x2124, 0x2945, 0x2965, 0x3166, 0x31a6, 0x39a7, 0x39e7, 0x4208, 0x4208, 0x4a29, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c51, 0x9492, 0x94b2, 0x94d2, 0x9cf3, 0x9d13, 0xa534, 0xa554, 0xad55, 0x18c3, 0x18c3, 0x2104, 0x2124, 0x2945, 0x2965, 0x3186, 0x3186, 0x39c7, 0x39c7, 0x41e8, 0x4208, 0x4a29, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x8c71, 0x94b2, 0x94d2, 0x9cf3, 0x9d13, 0xa514, 0xa554, 0xad55, 0xad75, 0x18c3, 0x20e4, 0x2104, 0x2925, 0x2945, 0x3166, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b2d, 0x6b4d, 0x738e, 0x73ae, 0x7bcf, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94d2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0x20e4, 0x2104, 0x2124, 0x2945, 0x2965, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5aab, 0x5acb, 0x62ec, 0x632c, 0x6b4d, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xa554, 0xad55, 0xb596, 0xb596, 0x2104, 0x2124, 0x2945, 0x2965, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5aab, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x94d2, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad55, 0xad75, 0xb5b6, 0xb5b6, 0x2124, 0x2925, 0x2965, 0x3186, 0x3186, 0x39a7, 0x39e7, 0x41e8, 0x4228, 0x4a29, 0x4a69, 0x528a, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0x9d13, 0xa514, 0xa554, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0x2925, 0x2945, 0x2965, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4a29, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8430, 0x8c71, 0x9492, 0x94b2, 0x94d2, 0x9cf3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0x2965, 0x2965, 0x3186, 0x39a7, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b2d, 0x6b4d, 0x738e, 0x73ae, 0x73ae, 0x7bcf, 0x8410, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0x2965, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5aab, 0x5acb, 0x630c, 0x632c, 0x6b2d, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xb5d6, 0xbdd7, 0xbe17, 0xc638, 0x3186, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a49, 0x528a, 0x528a, 0x5aab, 0x5acb, 0x62ec, 0x630c, 0x6b4d, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0x31a6, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x94d2, 0x9cf3, 0x9d13, 0xa534, 0xa554, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0xce59, 0x39c7, 0x39c7, 0x41e8, 0x4208, 0x4a29, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0xce59, 0xce79, 0x39c7, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b2d, 0x6b4d, 0x738e, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xb5d6, 0xbdf7, 0xc618, 0xc638, 0xc638, 0xce79, 0xce79, 0x39e7, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b4d, 0x6b6d, 0x73ae, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xb5d6, 0xbdf7, 0xbe17, 0xc638, 0xc638, 0xce59, 0xce99, 0xd69a, 0x4208, 0x4228, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5acb, 0x62ec, 0x630c, 0x6b2d, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0x9d13, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xb5b6, 0xbdd7, 0xbdf7, 0xc638, 0xc638, 0xce59, 0xce79, 0xd69a, 0xd6ba, 0x4228, 0x4a29, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0x9d13, 0xa514, 0xa554, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0xce59, 0xce79, 0xd69a, 0xd6ba, 0xdedb, 0x4a29, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x9492, 0x94b2, 0x9cf3, 0x9d13, 0xa534, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0xce59, 0xce79, 0xd69a, 0xd6ba, 0xdedb, 0xdefb, 0x4a49, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bcf, 0x8410, 0x8410, 0x8c51, 0x8c51, 0x9492, 0x94b2, 0x94b2, 0x9cd3, 0x9d13, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0xc658, 0xce79, 0xd69a, 0xd6ba, 0xd6da, 0xdefb, 0xdf1b, 0x4a69, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b2d, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xb5d6, 0xbdf7, 0xc618, 0xc638, 0xc638, 0xce59, 0xce99, 0xd6ba, 0xd6ba, 0xdedb, 0xdf1b, 0xe73c, 0x528a, 0x52aa, 0x5acb, 0x5aeb, 0x62ec, 0x630c, 0x6b2d, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xa554, 0xad75, 0xad75, 0xb5b6, 0xb5d6, 0xbdf7, 0xbe17, 0xc638, 0xc638, 0xce59, 0xce79, 0xd69a, 0xd6ba, 0xdedb, 0xdefb, 0xe71c, 0xe73c, 0x52aa, 0x52aa, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x9492, 0x94d2, 0x9cf3, 0x9cf3, 0xa514, 0xa554, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0xce59, 0xce79, 0xd69a, 0xd6ba, 0xdedb, 0xdefb, 0xdf1b, 0xe73c, 0xe75c, 0x5aab, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0xce59, 0xce79, 0xd69a, 0xd6ba, 0xdedb, 0xdefb, 0xdf1b, 0xe73c, 0xe75c, 0xef7d, 0x5acb, 0x5aeb, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8430, 0x8c51, 0x9492, 0x94b2, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0xce59, 0xce79, 0xce99, 0xd6ba, 0xd6da, 0xdefb, 0xdf1b, 0xe73c, 0xe75c, 0xef7d, 0xef9d, 0x5aeb, 0x62ec, 0x632c, 0x6b4d, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xad55, 0xad75, 0xb596, 0xb596, 0xbdd7, 0xbdf7, 0xbe17, 0xc638, 0xc658, 0xce79, 0xce99, 0xd69a, 0xd6ba, 0xdedb, 0xdefb, 0xe71c, 0xe73c, 0xef5d, 0xef7d, 0xf79e, 0x62ec, 0x630c, 0x6b2d, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0x9d13, 0xa534, 0xad55, 0xad55, 0xad75, 0xb5b6, 0xb5b6, 0xbdf7, 0xbdf7, 0xc618, 0xc638, 0xce59, 0xce79, 0xd69a, 0xd6ba, 0xdedb, 0xdefb, 0xe71c, 0xe73c, 0xef5d, 0xef7d, 0xf79e, 0xf7be, 0x630c, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8430, 0x8c51, 0x8c71, 0x9492, 0x94b2, 0x9cd3, 0x9cf3, 0xa514, 0xa534, 0xa554, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbe17, 0xc618, 0xc638, 0xce59, 0xce79, 0xd69a, 0xd6ba, 0xdedb, 0xdefb, 0xdf1b, 0xe73c, 0xef5d, 0xef7d, 0xef9d, 0xf7be, 0xf7de, 0x632c, 0x6b4d, 0x6b6d, 0x738e, 0x73ae, 0x7bcf, 0x7bef, 0x8410, 0x8410, 0x8430, 0x8c71, 0x9492, 0x9492, 0x94d2, 0x9cf3, 0x9d13, 0xa534, 0xa534, 0xad55, 0xad75, 0xb596, 0xb5b6, 0xbdd7, 0xbdf7, 0xc618, 0xc638, 0xce59, 0xce79, 0xd69a, 0xd6ba, 0xdedb, 0xdefb, 0xdf1b, 0xe73c, 0xe75c, 0xef7d, 0xef9d, 0xf7be, 0xf7de, 0xffff};
static const PROGMEM uint16_t file[] = {
0x528a, 0xff90, 0xff90, 0xf794, 0x5a66, 0x5a69, 0x4a6a, 0x5269, 0x5249, 0x528a, 0x5a6a, 0x5a66, 0x4a6d, 0x4a4b, 0xff71, 0xff90, 0xf7b1, 0xf752, 0xf792, 0xef91, 0xf7b0, 0xf7b0, 0xf7b1, 0xf773, 0xf772, 0x52a9, 0x4a6a, 0xff91, 0xff70, 0xf771, 0xff72, 0xff71, 0xff52, 0xff72, 0xff72, 0xff71, 0xff72, 0xff92, 0x4a49, 0x52a9, 0xff71, 0xff71, 0xffd2, 0xff31, 0xff91, 0xff92, 0xff52, 0xff52, 0xff92, 0xff91, 0xf750, 0x5aab, 0x4a89, 0xff71, 0xff71, 0xf771, 0xff91, 0xff8f, 0xff90, 0xff91, 0xff70, 0xff90, 0xff6f, 0xffb0, 0x4a49, 0x4a69, 0xff92, 0xffb2, 0xf771, 0xff92, 0xff71, 0xf772, 0xff93, 0xff93, 0xf792, 0xff51, 0xffb2, 0x4a6a, 0x528a, 0xff51, 0xff50, 0xffb1, 0xff51, 0xffb1, 0xff91, 0xf770, 0xf770, 0xffb1, 0xff92, 0xf771, 0x5289, 0x4a6a, 0xff91, 0xff90, 0xff91, 0xff72, 0xff72, 0xff72, 0xff71, 0xff71, 0xff71, 0xff72, 0xff72, 0x5269, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x4a69};
static const PROGMEM uint16_t text_file[] = {
0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0xad75, 0x7411, 0xffff, 0xffff, 0xffff, 0xffff, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0xffff, 0xffff, 0xffff, 0xffff, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0xffff, 0xffff, 0xffff, 0xffff, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0xffff, 0xffff, 0xffff, 0xffff, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411};
static const PROGMEM uint16_t unknown_file[] = {
0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0xad75, 0x7411, 0xffff, 0xffff, 0xffff, 0xffff, 0x7411, 0x7411, 0xffff, 0x707f, 0x707f, 0x707f, 0x7411, 0x7411, 0xffff, 0xffff, 0xffff, 0x707f, 0x7411, 0x7411, 0xffff, 0x707f, 0x707f, 0x707f, 0x7411, 0x7411, 0xffff, 0x707f, 0xffff, 0xffff, 0x7411, 0x7411, 0xffff, 0xffff, 0xffff, 0xffff, 0x7411, 0x7411, 0xffff, 0x707f, 0xffff, 0xffff, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411, 0x7411};
static const PROGMEM uint16_t clock_icon[] = {
0xa815, 0xa815, 0x0, 0x0, 0x0, 0x0, 0xa815, 0xa815, 0xa815, 0x0, 0xffff, 0xffff, 0xffff, 0xffff, 0x0, 0xa815, 0x0, 0xffff, 0xffff, 0x0, 0xffff, 0xffff, 0xffff, 0x0, 0x0, 0xffff, 0xffff, 0x0, 0xffff, 0xffff, 0xffff, 0x0, 0x0, 0xffff, 0xffff, 0x0, 0x0, 0xffff, 0xffff, 0x0, 0x0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0, 0xa815, 0x0, 0xffff, 0xffff, 0xffff, 0xffff, 0x0, 0xa815, 0xa815, 0xa815, 0x0, 0x0, 0x0, 0x0, 0xa815, 0xa815};
static const PROGMEM uint16_t serialPhoto_icon[] = {
0xa815, 0xa815, 0xa815, 0xa815, 0xa815, 0xa815, 0xa815, 0xa815, 0x0, 0xe7e1, 0x0, 0xe7e1, 0x0, 0xe7e1, 0x0, 0xe7e1, 0xe7e1, 0xc7f, 0xc7f, 0xc7f, 0xc7f, 0xc7f, 0xc7f, 0x0, 0x0, 0xc7f, 0xc7f, 0xc7f, 0xc7f, 0x3ba5, 0x3ba5, 0xe7e1, 0xe7e1, 0xc7f, 0x3ba5, 0x3ba5, 0x3ba5, 0x3ba5, 0x3ba5, 0x0, 0x0, 0x3ba5, 0x3ba5, 0x3ba5, 0x3ba5, 0x3ba5, 0x3ba5, 0xe7e1, 0xe7e1, 0x0, 0xe7e1, 0x0, 0xe7e1, 0x0, 0xe7e1, 0x0, 0xa815, 0xa815, 0xa815, 0xa815, 0xa815, 0xa815, 0xa815, 0xa815};
#define TFT_DC PA0
#define TFT_CS PA1
#define TFT_RST PA2
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
#define BOARD_LED PC13
//Inputs
#define RIGHT PB5
bool lastRIGHTstate = false;
bool currentRIGHTstate = false;
#define LEFT PB4
bool lastLEFTstate = false;
bool currentLEFTstate = false;
#define A PA8
bool lastAstate = false;
bool currentAstate = false;
#define B PA15
bool lastBstate = false;
bool currentBstate = false;
#define START PB15
bool lastSTARTstate = false;
bool currentSTARTstate = false;
#define SD_CS PB0
File root;
int timezoneOffset = 2; //TODO: Make this changable
time_t unixtimestamp = 0;
struct Folder {
String name;
std::vector<String> contents;
Folder() {
name = "!!!!";
}
Folder(String x) {
name = x;
};
String getFileName(int index) {
return contents[index].substring(contents[index].indexOf("[") + 1, contents[index].indexOf("]"));
}
String getFileContents(int index) {
if (contents[index].substring(contents[index].indexOf("]") + 1) != "{SD}"){
return contents[index].substring(contents[index].indexOf("]") + 1);
}
else { //This is a file on the SD card
File reader = SD.open(contents[index].substring(1,contents[index].indexOf("]")));
Serial.println("Reading: " + contents[index].substring(1,contents[index].indexOf("]")));
if (reader/* && contents[index].substring(1,contents[index].indexOf("]")) != "SYSTEM~1"*/) {
String fileDat = "";
uint16_t chars = 0;
while (reader.available()) {
char character = reader.read();
chars++;
fileDat += character;
if (chars > 5000) {
Serial.println("File too big");
fileDat += "\n\n[FILE TOO BIG]";
reader.close();
return fileDat;
}
}
reader.close();
return fileDat;
}
else {
return "[Error reading file]";
}
}
}
};
std::vector<Folder> folders{Folder("%SYS"), Folder("%DAT")};
void drawBMPCustom(uint16_t x, uint16_t y, uint16_t w, uint16_t sf, const uint16_t *bitmp, size_t len, uint16_t stp) {
for (int i = 0; i < len / sizeof(pgm_read_word(bitmp)); i++) {
tft.fillRect(x + (i % w) * sf, y + floor(i / w) * sf, sf, sf, pgm_read_word_near(bitmp + i));
if (i > stp && stp > 0) { //Break after stp pixels
break;
}
}
}
void drawBMPCustomTransparency(uint16_t x, uint16_t y, uint16_t w, uint16_t sf, const uint16_t *bitmp, size_t len, uint16_t stp) {
for (int i = 0; i < len / sizeof(pgm_read_word(bitmp)); i++) {
if (pgm_read_word_near(bitmp + i) == 0xA815) { //Skips over #B000B0
continue;
}
tft.fillRect(x + (i % w) * sf, y + floor(i / w) * sf, sf, sf, pgm_read_word_near(bitmp + i));
if (i > stp && stp > 0) { //Break after stp pixels
break;
}
}
}
void drawBackground(uint16_t stp) {
drawBMPCustom(0, 2, 40, 4, background, sizeof(background), stp); //Background
for (int i = 0; i < folders.size(); i++) {
drawBMPCustom(10 + (i % 4 * 18 * 2), 20 + 34 * floor(i / 4), 13, 2, file, sizeof(file), 0); //Draw file icon
tft.setCursor(11 + (i % 4 * 18 * 2), 40 + 32 * floor(i / 4));
tft.print(folders[i].name);
}
}
void drawTaskbar(int index) {
tft.fillRect(0, 110, 160, 18, 0x1B7F); //Task Bar
tft.fillRect(1 + index * 18, 110, 18, 18, 0x8F5F);
drawBMPCustomTransparency(2, 111, 8, 2, clock_icon, sizeof(clock_icon), 0);
drawBMPCustomTransparency(20, 111, 8, 2, serialPhoto_icon, sizeof(serialPhoto_icon), 0);
}
void fpsCounter(double fps) {
tft.fillRect(0, 0, 38, 10, 0);
tft.setCursor(2, 2);
tft.print(fps);
//Serial.println(fps);
}
void drawFileSelection(int num) {
tft.drawFastVLine(7 + num % 4 * 18 * 2, 16 + 34 * floor(num / 4), 34, 0x8F5F);
tft.drawFastVLine(37 + num % 4 * 18 * 2, 16 + 34 * floor(num / 4), 34, 0x8F5F);
tft.drawFastHLine(7 + num % 4 * 18 * 2, 16 + 34 * floor(num / 4), 6, 0x8F5F);
tft.drawFastHLine(31 + num % 4 * 18 * 2, 16 + 34 * floor(num / 4), 6, 0x8F5F);
tft.drawFastHLine(7 + num % 4 * 18 * 2, 16 + 34 + 34 * floor(num / 4), 6, 0x8F5F);
tft.drawFastHLine(31 + num % 4 * 18 * 2, 16 + 33 + 34 * floor(num / 4), 6, 0x8F5F);
}
void showDesktop() {
drawBackground(0);
drawTaskbar(-1);
drawClock(unixtimestamp + millis() / 1000);
}
void drawFolderView(int insideFolder, int currentlySelected) {
tft.fillScreen(0xAD55);
for (int i = 0; i < folders[insideFolder].contents.size(); i++) {
////Serial.println(folders[insideFolder].getFileName(i).substring(folders[insideFolder].getFileName(i).indexOf(".") + 1, folders[insideFolder].getFileName(i).indexOf("]")));
if (folders[insideFolder].getFileName(i).substring(folders[insideFolder].getFileName(i).indexOf(".") + 1, folders[insideFolder].getFileName(i).indexOf("]")) == "TXT") {
drawBMPCustom(16 + (i % 4 * 18 * 2), 20 + 34 * floor(i / 4), 6, 2, text_file, sizeof(text_file), 0); //Draw file icon
tft.setCursor(11 + (i % 4 * 18 * 2), 40 + 32 * floor(i / 4));
tft.print(folders[insideFolder].getFileName(i).substring(folders[insideFolder].getFileName(i).indexOf("[") + 1, folders[insideFolder].getFileName(i).indexOf(".")));
} else {
drawBMPCustom(16 + (i % 4 * 18 * 2), 20 + 34 * floor(i / 4), 6, 2, unknown_file, sizeof(unknown_file), 0);
tft.setCursor(11 + (i % 4 * 18 * 2), 40 + 32 * floor(i / 4));
tft.print(folders[insideFolder].getFileName(i).substring(folders[insideFolder].getFileName(i).indexOf("[") + 1, folders[insideFolder].getFileName(i).indexOf(".")));
}
drawFileSelection(currentlySelected);
}
drawClock(unixtimestamp + millis() / 1000);
}
void drawClock(time_t currentTimestamp) {
struct tm *tmp = gmtime(¤tTimestamp);
tft.fillRect(56, 1, 5 * 6 + 20, 9, 0);
tft.setTextColor(0xFFFF);
tft.setCursor(64, 2);
String currentHour = String((tmp->tm_hour + timezoneOffset) % 12) + ":" + String("0").substring(0, 1 - (tmp->tm_min > 9)) + String(tmp->tm_min);
if (tmp->tm_hour + timezoneOffset > 12) {
currentHour += "PM";
} else {
currentHour += "AM";
}
tft.println(currentHour);
}
time_t lastTime = 0;
void drawClockApp() {
time_t currentTime = unixtimestamp + millis() / 1000;
struct tm *tmp = gmtime(¤tTime);
if (lastTime == currentTime) {
return;
}
tft.fillRect(25, 10, 110, 96, 0);
tft.drawCircle(60, 45, 30, 0xFFFF); //TODO: Make this prettier
double s = ((tmp->tm_sec - 0) * (TWO_PI - 0) / (60 - 0) + 0) - HALF_PI; //
double m = ((tmp->tm_min - 0) * (TWO_PI - 0) / (60 - 0) + 0) - HALF_PI; // This section calculates the rotation of the hands of the clock
double h = (((tmp->tm_hour + timezoneOffset) % 12 - 0) * (TWO_PI - 0) / (12 - 0) + 0) - HALF_PI; //
float secondHandLength = 27;
float minuteHandLength = 20;
float hourHandLength = 15;
tft.drawLine(60, 45, 60 + cos(s) * secondHandLength, 45 + sin(s) * secondHandLength, 0xF800);
tft.drawLine(60, 45, 60 + cos(m) * minuteHandLength, 45 + sin(m) * minuteHandLength, 0xFFFF);
tft.drawLine(60, 45, 60 + cos(h) * hourHandLength, 45 + sin(h) * hourHandLength, 0xFFFF);
std::vector<String> months{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
tft.setCursor(25, 80);
tft.println(String(tmp->tm_mday) + " of " + months.at(tmp->tm_mon) + " " + String(tmp->tm_year + 1900));
tft.setCursor(25, 88);
tft.println(String(tmp->tm_hour + timezoneOffset) + ":" + String("0").substring(0, 1 - (tmp->tm_min > 9)) + String(tmp->tm_min) + ":" + String("0").substring(0, 1 - (tmp->tm_sec > 9)) + String(tmp->tm_sec));
lastTime = currentTime;
}
char inputChar = 0;
String inputString = "";
uint16_t pix = 0;
bool displayingImage = false;
void serialPhoto() {
int width = 128;
if (!displayingImage) {
tft.fillRect(16, 16, 128, 82, 0);
Serial.println("serialPhoto");
}
if (Serial.available() > 0) {
displayingImage = true;
inputChar = Serial.read();
inputString += inputChar;
inputChar = 0;
}
if (inputString.length() >= 6) {
uint16_t color = strtoul(inputString.c_str(), NULL, 16);
//Serial.println(color,16);
inputString = "";
tft.drawPixel(16 + (pix % width), 16 + floor(pix / width), color);
//tft.fillRect(16 + (pix % width)*4, 16 + floor(pix / width)*4, 4, 4, color);
////tft.fillRect(16,16,128,72,color);
pix++;
}
if (inputString[0] == 's') {
pix = 0;
inputString = "";
}
if (inputString[0] != '0' && inputString.length() != 0) {
Serial.println(inputString);
inputString = "";
tft.setCursor(16, 88);
tft.print("ERROR");
}
currentAstate = digitalRead(A);
if (currentAstate != lastAstate && !currentAstate) {
displayingImage = false;
pix = 0;
inputString = "";
}
lastAstate = currentAstate;
}
void setup() {
#if defined BOARD_LED
pinMode(BOARD_LED, OUTPUT);
digitalWrite(BOARD_LED, HIGH);
#endif
Serial.begin(230400);
tft.initR(INITR_BLACKTAB);
pinMode(RIGHT, INPUT_PULLUP);
pinMode(LEFT, INPUT_PULLUP);
pinMode(A, INPUT_PULLUP);
pinMode(B, INPUT_PULLUP);
pinMode(START, INPUT_PULLUP);
Serial.println(F("Initialized"));
tft.fillScreen(0);
tft.setRotation(1);
tft.setTextColor(0xFFFF);
tft.setTextWrap(true);
tft.fillRect(0, 0, 160, 5, 0);
folders[0].contents.push_back("[READ.TXT]Congratulations! \n\nYou managed to get the OS to work! \n\nTry creating a text file, or load one from an SD \ncard or something.");
char inputChar = 0;
String time;
tft.setCursor(2, 3);
tft.println("Loading data from PC...");
tft.setCursor(2, 11);
tft.println("Press A to skip");
while (digitalRead(A)) {
if (millis() >= 2000) {
tft.setCursor(2, 19);
tft.println("FAILED!");
delay(100);
break;
}
if (Serial.available() > 0) {
inputChar = Serial.read();
if (inputChar != 's') {
time += inputChar;
inputChar = 0;
} else {
for (int i = 0; i < time.length(); i++) {
char c = time.charAt(i);
Serial.println(c);
if (c < '0' || c > '9') {
break;
}
unixtimestamp *= 10;
unixtimestamp += (c - '0');
}
struct tm *tmp = gmtime(&unixtimestamp);
Serial.println(String(tmp->tm_hour + timezoneOffset) + ":" + String(tmp->tm_min));
tft.println(time);
tft.println(String(tmp->tm_hour + timezoneOffset) + ":" + String(tmp->tm_min));
tft.println(String(tmp->tm_mday) + "/" + String(tmp->tm_mon + 1) + "/" + String(tmp->tm_year + 1900));
inputChar = 0;
}
}
} //Wait for A to be pressed
tft.println("Initializing SD card");
if (!SD.begin(SD_CS)) {
Serial.println("Failed to initialze SD card! Is it wired correctly? Is an SD card inserted?");
} else {
Serial.println("Successful init of SD card");
folders.push_back(Folder("%SD"));
root = SD.open("/");
while (true) {
File entry = root.openNextFile();
if (!entry) {
break; //No more files
}
Serial.println(entry.name());
String fileDat = "";
fileDat += "[";
fileDat += entry.name();
fileDat += "]{SD}";
folders[folders.size()-1].contents.push_back(fileDat);
}
}
drawBackground(0);
drawTaskbar(-1);
drawFileSelection(0);
}
int currentlySelected = 0;
int insideFolder = -1;
bool viewingFile = false;
bool taskbarFocus = false;
int currentlyOpenApp = -1;
int currentScroll = 0;
String fileContents = "";
uint32_t execTime = 0;
void loop() {
// put your main code here, to run repeatedly:
execTime = millis();
currentRIGHTstate = digitalRead(RIGHT);
currentLEFTstate = digitalRead(LEFT);
currentAstate = digitalRead(A);
currentBstate = digitalRead(B);
currentSTARTstate = digitalRead(START);
if (insideFolder >= 0) { //If this is true then we must be inside a folder
//TODO: Add support for nested folders.
if (currentRIGHTstate != lastRIGHTstate && !currentRIGHTstate && currentlySelected + 1 < folders[insideFolder].contents.size() && !viewingFile) { //Move selection to the right
currentlySelected++;
drawFolderView(insideFolder, currentlySelected);
}
if (currentLEFTstate != lastLEFTstate && !currentLEFTstate && currentlySelected > 0 && !viewingFile) { //Move selection to the left
currentlySelected--;
drawFolderView(insideFolder, currentlySelected);
}
if (currentAstate != lastAstate && !currentAstate) { //Open file
//TODO: add support for image files.
viewingFile = true;
tft.fillScreen(ST7735_WHITE);
tft.setCursor(2, 8);
tft.setTextColor(0);
fileContents = folders[insideFolder].getFileContents(currentlySelected);
tft.print(folders[insideFolder].getFileContents(currentlySelected));
}
if (currentBstate != lastBstate && !currentBstate) {
if (viewingFile) {
tft.setTextColor(ST7735_WHITE);
viewingFile = false;
currentScroll = 0;
fileContents = "";
drawFolderView(insideFolder, currentlySelected);
} else {
currentlySelected = insideFolder;
insideFolder = -1;
showDesktop();
drawFileSelection(currentlySelected);
}
}
if (currentRIGHTstate != lastRIGHTstate && !currentRIGHTstate && viewingFile) {
currentScroll -= 8;
tft.fillScreen(ST7735_WHITE);
tft.setCursor(2, 8 + currentScroll);
tft.setTextColor(0);
tft.print(fileContents);
}
if (currentLEFTstate != lastLEFTstate && !currentLEFTstate && viewingFile) {
currentScroll += 8;
tft.fillScreen(ST7735_WHITE);
tft.setCursor(2, 8 + currentScroll);
tft.setTextColor(0);
tft.print(fileContents);
}
} else { //We must be on the desktop
if (currentRIGHTstate != lastRIGHTstate && !currentRIGHTstate && currentlySelected + 1 < folders.size() && !taskbarFocus) { //Move selection to the right
currentlySelected++;
showDesktop();
drawFileSelection(currentlySelected);
}
if (currentLEFTstate != lastLEFTstate && !currentLEFTstate && currentlySelected > 0 && !taskbarFocus) { //Move selection to the left
currentlySelected--;
showDesktop();
drawFileSelection(currentlySelected);
}
if (currentSTARTstate != lastSTARTstate && !currentSTARTstate && !taskbarFocus) { //Switch to taskbar
drawBackground(0);
drawTaskbar(-1);
drawClock(unixtimestamp + millis() / 1000);
taskbarFocus = true;
currentlySelected = 0;
drawTaskbar(currentlySelected);
lastSTARTstate = currentSTARTstate;
}
}
if (currentAstate != lastAstate && !currentAstate && insideFolder == -1 && !taskbarFocus) { //Enter folder/open file
insideFolder = currentlySelected;
currentlySelected = 0;
drawFolderView(insideFolder, currentlySelected);
}
if (taskbarFocus) {
int numberOfApps = 2; //TODO: Make this dynamic rather than a number I have to update
if (currentRIGHTstate != lastRIGHTstate && !currentRIGHTstate && currentlySelected + 1 < numberOfApps) {
currentlySelected++;
drawTaskbar(currentlySelected);
}
if (currentLEFTstate != lastLEFTstate && !currentLEFTstate && currentlySelected > 0) {
currentlySelected--;
drawTaskbar(currentlySelected);
}
if (currentAstate != lastAstate && !currentAstate) {
currentlyOpenApp = currentlySelected;
}
if (currentBstate != lastBstate && !currentBstate) {
currentlyOpenApp = -1;
showDesktop();
drawTaskbar(currentlySelected);
}
if (currentSTARTstate != lastSTARTstate && !currentSTARTstate && currentlyOpenApp <= -1) {
taskbarFocus = false;
currentlySelected = 0;
showDesktop();
drawFileSelection(currentlySelected);
}
}
switch (currentlyOpenApp) { //Every loop, runs program
case 0:
drawClockApp();
break;
case 1:
serialPhoto();
break;
default:
break;
}
lastRIGHTstate = currentRIGHTstate;
lastLEFTstate = currentLEFTstate;
lastAstate = currentAstate;
lastBstate = currentBstate;
lastSTARTstate = currentSTARTstate;
time_t currentTimestamp = unixtimestamp + millis() / 1000;
if (currentTimestamp % 60 == 0 || millis() < 10000) {
drawClock(currentTimestamp);
}
////double fps = pow(((millis() - execTime) * 0.001), -1);
////fpsCounter(fps);
////delay((millis() - execTime) * 2); //* Wait for twice as long as it took to draw the frame.
}