|
@@ -2,10 +2,9 @@
|
2
|
2
|
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
3
|
3
|
* Copyright (c) 2014 Intel Corporation.
|
4
|
4
|
*
|
5
|
|
- * Credits to Adafrut.com
|
6
|
|
- * {Based on,Inspired from} original <libname> from <author>. See original license in <filepath>.
|
7
|
|
-
|
8
|
|
- *
|
|
5
|
+ * Credits to Adafruit.
|
|
6
|
+ * Based on Adafruit ST7735 library, see original license in license.txt file.
|
|
7
|
+ *
|
9
|
8
|
* Permission is hereby granted, free of charge, to any person obtaining
|
10
|
9
|
* a copy of this software and associated documentation files (the
|
11
|
10
|
* "Software"), to deal in the Software without restriction, including
|
|
@@ -87,13 +86,13 @@
|
87
|
86
|
#define ST7735_GMCTRN1 0xE1
|
88
|
87
|
|
89
|
88
|
// Color definitions
|
90
|
|
-#define ST7735_BLACK 0x0000
|
91
|
|
-#define ST7735_BLUE 0x001F
|
92
|
|
-#define ST7735_RED 0xF800
|
93
|
|
-#define ST7735_GREEN 0x07E0
|
|
89
|
+#define ST7735_BLACK 0x0000
|
|
90
|
+#define ST7735_BLUE 0x001F
|
|
91
|
+#define ST7735_RED 0xF800
|
|
92
|
+#define ST7735_GREEN 0x07E0
|
94
|
93
|
#define ST7735_CYAN 0x07FF
|
95
|
94
|
#define ST7735_MAGENTA 0xF81F
|
96
|
|
-#define ST7735_YELLOW 0xFFE0
|
|
95
|
+#define ST7735_YELLOW 0xFFE0
|
97
|
96
|
#define ST7735_WHITE 0xFFFF
|
98
|
97
|
|
99
|
98
|
#define HIGH 1
|
|
@@ -103,7 +102,7 @@
|
103
|
102
|
|
104
|
103
|
namespace upm {
|
105
|
104
|
|
106
|
|
-static const uint8_t Bcmd[] = {
|
|
105
|
+static const uint8_t Bcmd[] = {
|
107
|
106
|
// Initialization commands for 7735B screens
|
108
|
107
|
18, // 18 commands in list:
|
109
|
108
|
ST7735_SWRESET, DELAY, // 1: Software reset, no args, w/delay
|
|
@@ -189,7 +188,7 @@ static const uint8_t Bcmd[] = {
|
189
|
188
|
0x00, // Boost frequency
|
190
|
189
|
ST7735_PWCTR4 , 2 , // 10: Power control, 2 args, no delay:
|
191
|
190
|
0x8A, // BCLK/2, Opamp current small & Medium low
|
192
|
|
- 0x2A,
|
|
191
|
+ 0x2A,
|
193
|
192
|
ST7735_PWCTR5 , 2 , // 11: Power control, 2 args, no delay:
|
194
|
193
|
0x8A, 0xEE,
|
195
|
194
|
ST7735_VMCTR1 , 1 , // 12: Power control, 1 arg, no delay:
|
|
@@ -236,27 +235,285 @@ static const uint8_t Bcmd[] = {
|
236
|
235
|
|
237
|
236
|
#define swap(a, b) { int16_t t = a; a = b; b = t; }
|
238
|
237
|
|
239
|
|
-
|
|
238
|
+const unsigned char font[] = {
|
|
239
|
+ 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
240
|
+ 0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
|
|
241
|
+ 0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
|
|
242
|
+ 0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
|
|
243
|
+ 0x18, 0x3C, 0x7E, 0x3C, 0x18,
|
|
244
|
+ 0x1C, 0x57, 0x7D, 0x57, 0x1C,
|
|
245
|
+ 0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
|
|
246
|
+ 0x00, 0x18, 0x3C, 0x18, 0x00,
|
|
247
|
+ 0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
|
|
248
|
+ 0x00, 0x18, 0x24, 0x18, 0x00,
|
|
249
|
+ 0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
|
|
250
|
+ 0x30, 0x48, 0x3A, 0x06, 0x0E,
|
|
251
|
+ 0x26, 0x29, 0x79, 0x29, 0x26,
|
|
252
|
+ 0x40, 0x7F, 0x05, 0x05, 0x07,
|
|
253
|
+ 0x40, 0x7F, 0x05, 0x25, 0x3F,
|
|
254
|
+ 0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
|
|
255
|
+ 0x7F, 0x3E, 0x1C, 0x1C, 0x08,
|
|
256
|
+ 0x08, 0x1C, 0x1C, 0x3E, 0x7F,
|
|
257
|
+ 0x14, 0x22, 0x7F, 0x22, 0x14,
|
|
258
|
+ 0x5F, 0x5F, 0x00, 0x5F, 0x5F,
|
|
259
|
+ 0x06, 0x09, 0x7F, 0x01, 0x7F,
|
|
260
|
+ 0x00, 0x66, 0x89, 0x95, 0x6A,
|
|
261
|
+ 0x60, 0x60, 0x60, 0x60, 0x60,
|
|
262
|
+ 0x94, 0xA2, 0xFF, 0xA2, 0x94,
|
|
263
|
+ 0x08, 0x04, 0x7E, 0x04, 0x08,
|
|
264
|
+ 0x10, 0x20, 0x7E, 0x20, 0x10,
|
|
265
|
+ 0x08, 0x08, 0x2A, 0x1C, 0x08,
|
|
266
|
+ 0x08, 0x1C, 0x2A, 0x08, 0x08,
|
|
267
|
+ 0x1E, 0x10, 0x10, 0x10, 0x10,
|
|
268
|
+ 0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
|
269
|
+ 0x30, 0x38, 0x3E, 0x38, 0x30,
|
|
270
|
+ 0x06, 0x0E, 0x3E, 0x0E, 0x06,
|
|
271
|
+ 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
272
|
+ 0x00, 0x00, 0x5F, 0x00, 0x00,
|
|
273
|
+ 0x00, 0x07, 0x00, 0x07, 0x00,
|
|
274
|
+ 0x14, 0x7F, 0x14, 0x7F, 0x14,
|
|
275
|
+ 0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
|
276
|
+ 0x23, 0x13, 0x08, 0x64, 0x62,
|
|
277
|
+ 0x36, 0x49, 0x56, 0x20, 0x50,
|
|
278
|
+ 0x00, 0x08, 0x07, 0x03, 0x00,
|
|
279
|
+ 0x00, 0x1C, 0x22, 0x41, 0x00,
|
|
280
|
+ 0x00, 0x41, 0x22, 0x1C, 0x00,
|
|
281
|
+ 0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
|
|
282
|
+ 0x08, 0x08, 0x3E, 0x08, 0x08,
|
|
283
|
+ 0x00, 0x80, 0x70, 0x30, 0x00,
|
|
284
|
+ 0x08, 0x08, 0x08, 0x08, 0x08,
|
|
285
|
+ 0x00, 0x00, 0x60, 0x60, 0x00,
|
|
286
|
+ 0x20, 0x10, 0x08, 0x04, 0x02,
|
|
287
|
+ 0x3E, 0x51, 0x49, 0x45, 0x3E,
|
|
288
|
+ 0x00, 0x42, 0x7F, 0x40, 0x00,
|
|
289
|
+ 0x72, 0x49, 0x49, 0x49, 0x46,
|
|
290
|
+ 0x21, 0x41, 0x49, 0x4D, 0x33,
|
|
291
|
+ 0x18, 0x14, 0x12, 0x7F, 0x10,
|
|
292
|
+ 0x27, 0x45, 0x45, 0x45, 0x39,
|
|
293
|
+ 0x3C, 0x4A, 0x49, 0x49, 0x31,
|
|
294
|
+ 0x41, 0x21, 0x11, 0x09, 0x07,
|
|
295
|
+ 0x36, 0x49, 0x49, 0x49, 0x36,
|
|
296
|
+ 0x46, 0x49, 0x49, 0x29, 0x1E,
|
|
297
|
+ 0x00, 0x00, 0x14, 0x00, 0x00,
|
|
298
|
+ 0x00, 0x40, 0x34, 0x00, 0x00,
|
|
299
|
+ 0x00, 0x08, 0x14, 0x22, 0x41,
|
|
300
|
+ 0x14, 0x14, 0x14, 0x14, 0x14,
|
|
301
|
+ 0x00, 0x41, 0x22, 0x14, 0x08,
|
|
302
|
+ 0x02, 0x01, 0x59, 0x09, 0x06,
|
|
303
|
+ 0x3E, 0x41, 0x5D, 0x59, 0x4E,
|
|
304
|
+ 0x7C, 0x12, 0x11, 0x12, 0x7C,
|
|
305
|
+ 0x7F, 0x49, 0x49, 0x49, 0x36,
|
|
306
|
+ 0x3E, 0x41, 0x41, 0x41, 0x22,
|
|
307
|
+ 0x7F, 0x41, 0x41, 0x41, 0x3E,
|
|
308
|
+ 0x7F, 0x49, 0x49, 0x49, 0x41,
|
|
309
|
+ 0x7F, 0x09, 0x09, 0x09, 0x01,
|
|
310
|
+ 0x3E, 0x41, 0x41, 0x51, 0x73,
|
|
311
|
+ 0x7F, 0x08, 0x08, 0x08, 0x7F,
|
|
312
|
+ 0x00, 0x41, 0x7F, 0x41, 0x00,
|
|
313
|
+ 0x20, 0x40, 0x41, 0x3F, 0x01,
|
|
314
|
+ 0x7F, 0x08, 0x14, 0x22, 0x41,
|
|
315
|
+ 0x7F, 0x40, 0x40, 0x40, 0x40,
|
|
316
|
+ 0x7F, 0x02, 0x1C, 0x02, 0x7F,
|
|
317
|
+ 0x7F, 0x04, 0x08, 0x10, 0x7F,
|
|
318
|
+ 0x3E, 0x41, 0x41, 0x41, 0x3E,
|
|
319
|
+ 0x7F, 0x09, 0x09, 0x09, 0x06,
|
|
320
|
+ 0x3E, 0x41, 0x51, 0x21, 0x5E,
|
|
321
|
+ 0x7F, 0x09, 0x19, 0x29, 0x46,
|
|
322
|
+ 0x26, 0x49, 0x49, 0x49, 0x32,
|
|
323
|
+ 0x03, 0x01, 0x7F, 0x01, 0x03,
|
|
324
|
+ 0x3F, 0x40, 0x40, 0x40, 0x3F,
|
|
325
|
+ 0x1F, 0x20, 0x40, 0x20, 0x1F,
|
|
326
|
+ 0x3F, 0x40, 0x38, 0x40, 0x3F,
|
|
327
|
+ 0x63, 0x14, 0x08, 0x14, 0x63,
|
|
328
|
+ 0x03, 0x04, 0x78, 0x04, 0x03,
|
|
329
|
+ 0x61, 0x59, 0x49, 0x4D, 0x43,
|
|
330
|
+ 0x00, 0x7F, 0x41, 0x41, 0x41,
|
|
331
|
+ 0x02, 0x04, 0x08, 0x10, 0x20,
|
|
332
|
+ 0x00, 0x41, 0x41, 0x41, 0x7F,
|
|
333
|
+ 0x04, 0x02, 0x01, 0x02, 0x04,
|
|
334
|
+ 0x40, 0x40, 0x40, 0x40, 0x40,
|
|
335
|
+ 0x00, 0x03, 0x07, 0x08, 0x00,
|
|
336
|
+ 0x20, 0x54, 0x54, 0x78, 0x40,
|
|
337
|
+ 0x7F, 0x28, 0x44, 0x44, 0x38,
|
|
338
|
+ 0x38, 0x44, 0x44, 0x44, 0x28,
|
|
339
|
+ 0x38, 0x44, 0x44, 0x28, 0x7F,
|
|
340
|
+ 0x38, 0x54, 0x54, 0x54, 0x18,
|
|
341
|
+ 0x00, 0x08, 0x7E, 0x09, 0x02,
|
|
342
|
+ 0x18, 0xA4, 0xA4, 0x9C, 0x78,
|
|
343
|
+ 0x7F, 0x08, 0x04, 0x04, 0x78,
|
|
344
|
+ 0x00, 0x44, 0x7D, 0x40, 0x00,
|
|
345
|
+ 0x20, 0x40, 0x40, 0x3D, 0x00,
|
|
346
|
+ 0x7F, 0x10, 0x28, 0x44, 0x00,
|
|
347
|
+ 0x00, 0x41, 0x7F, 0x40, 0x00,
|
|
348
|
+ 0x7C, 0x04, 0x78, 0x04, 0x78,
|
|
349
|
+ 0x7C, 0x08, 0x04, 0x04, 0x78,
|
|
350
|
+ 0x38, 0x44, 0x44, 0x44, 0x38,
|
|
351
|
+ 0xFC, 0x18, 0x24, 0x24, 0x18,
|
|
352
|
+ 0x18, 0x24, 0x24, 0x18, 0xFC,
|
|
353
|
+ 0x7C, 0x08, 0x04, 0x04, 0x08,
|
|
354
|
+ 0x48, 0x54, 0x54, 0x54, 0x24,
|
|
355
|
+ 0x04, 0x04, 0x3F, 0x44, 0x24,
|
|
356
|
+ 0x3C, 0x40, 0x40, 0x20, 0x7C,
|
|
357
|
+ 0x1C, 0x20, 0x40, 0x20, 0x1C,
|
|
358
|
+ 0x3C, 0x40, 0x30, 0x40, 0x3C,
|
|
359
|
+ 0x44, 0x28, 0x10, 0x28, 0x44,
|
|
360
|
+ 0x4C, 0x90, 0x90, 0x90, 0x7C,
|
|
361
|
+ 0x44, 0x64, 0x54, 0x4C, 0x44,
|
|
362
|
+ 0x00, 0x08, 0x36, 0x41, 0x00,
|
|
363
|
+ 0x00, 0x00, 0x77, 0x00, 0x00,
|
|
364
|
+ 0x00, 0x41, 0x36, 0x08, 0x00,
|
|
365
|
+ 0x02, 0x01, 0x02, 0x04, 0x02,
|
|
366
|
+ 0x3C, 0x26, 0x23, 0x26, 0x3C,
|
|
367
|
+ 0x1E, 0xA1, 0xA1, 0x61, 0x12,
|
|
368
|
+ 0x3A, 0x40, 0x40, 0x20, 0x7A,
|
|
369
|
+ 0x38, 0x54, 0x54, 0x55, 0x59,
|
|
370
|
+ 0x21, 0x55, 0x55, 0x79, 0x41,
|
|
371
|
+ 0x21, 0x54, 0x54, 0x78, 0x41,
|
|
372
|
+ 0x21, 0x55, 0x54, 0x78, 0x40,
|
|
373
|
+ 0x20, 0x54, 0x55, 0x79, 0x40,
|
|
374
|
+ 0x0C, 0x1E, 0x52, 0x72, 0x12,
|
|
375
|
+ 0x39, 0x55, 0x55, 0x55, 0x59,
|
|
376
|
+ 0x39, 0x54, 0x54, 0x54, 0x59,
|
|
377
|
+ 0x39, 0x55, 0x54, 0x54, 0x58,
|
|
378
|
+ 0x00, 0x00, 0x45, 0x7C, 0x41,
|
|
379
|
+ 0x00, 0x02, 0x45, 0x7D, 0x42,
|
|
380
|
+ 0x00, 0x01, 0x45, 0x7C, 0x40,
|
|
381
|
+ 0xF0, 0x29, 0x24, 0x29, 0xF0,
|
|
382
|
+ 0xF0, 0x28, 0x25, 0x28, 0xF0,
|
|
383
|
+ 0x7C, 0x54, 0x55, 0x45, 0x00,
|
|
384
|
+ 0x20, 0x54, 0x54, 0x7C, 0x54,
|
|
385
|
+ 0x7C, 0x0A, 0x09, 0x7F, 0x49,
|
|
386
|
+ 0x32, 0x49, 0x49, 0x49, 0x32,
|
|
387
|
+ 0x32, 0x48, 0x48, 0x48, 0x32,
|
|
388
|
+ 0x32, 0x4A, 0x48, 0x48, 0x30,
|
|
389
|
+ 0x3A, 0x41, 0x41, 0x21, 0x7A,
|
|
390
|
+ 0x3A, 0x42, 0x40, 0x20, 0x78,
|
|
391
|
+ 0x00, 0x9D, 0xA0, 0xA0, 0x7D,
|
|
392
|
+ 0x39, 0x44, 0x44, 0x44, 0x39,
|
|
393
|
+ 0x3D, 0x40, 0x40, 0x40, 0x3D,
|
|
394
|
+ 0x3C, 0x24, 0xFF, 0x24, 0x24,
|
|
395
|
+ 0x48, 0x7E, 0x49, 0x43, 0x66,
|
|
396
|
+ 0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
|
|
397
|
+ 0xFF, 0x09, 0x29, 0xF6, 0x20,
|
|
398
|
+ 0xC0, 0x88, 0x7E, 0x09, 0x03,
|
|
399
|
+ 0x20, 0x54, 0x54, 0x79, 0x41,
|
|
400
|
+ 0x00, 0x00, 0x44, 0x7D, 0x41,
|
|
401
|
+ 0x30, 0x48, 0x48, 0x4A, 0x32,
|
|
402
|
+ 0x38, 0x40, 0x40, 0x22, 0x7A,
|
|
403
|
+ 0x00, 0x7A, 0x0A, 0x0A, 0x72,
|
|
404
|
+ 0x7D, 0x0D, 0x19, 0x31, 0x7D,
|
|
405
|
+ 0x26, 0x29, 0x29, 0x2F, 0x28,
|
|
406
|
+ 0x26, 0x29, 0x29, 0x29, 0x26,
|
|
407
|
+ 0x30, 0x48, 0x4D, 0x40, 0x20,
|
|
408
|
+ 0x38, 0x08, 0x08, 0x08, 0x08,
|
|
409
|
+ 0x08, 0x08, 0x08, 0x08, 0x38,
|
|
410
|
+ 0x2F, 0x10, 0xC8, 0xAC, 0xBA,
|
|
411
|
+ 0x2F, 0x10, 0x28, 0x34, 0xFA,
|
|
412
|
+ 0x00, 0x00, 0x7B, 0x00, 0x00,
|
|
413
|
+ 0x08, 0x14, 0x2A, 0x14, 0x22,
|
|
414
|
+ 0x22, 0x14, 0x2A, 0x14, 0x08,
|
|
415
|
+ 0xAA, 0x00, 0x55, 0x00, 0xAA,
|
|
416
|
+ 0xAA, 0x55, 0xAA, 0x55, 0xAA,
|
|
417
|
+ 0x00, 0x00, 0x00, 0xFF, 0x00,
|
|
418
|
+ 0x10, 0x10, 0x10, 0xFF, 0x00,
|
|
419
|
+ 0x14, 0x14, 0x14, 0xFF, 0x00,
|
|
420
|
+ 0x10, 0x10, 0xFF, 0x00, 0xFF,
|
|
421
|
+ 0x10, 0x10, 0xF0, 0x10, 0xF0,
|
|
422
|
+ 0x14, 0x14, 0x14, 0xFC, 0x00,
|
|
423
|
+ 0x14, 0x14, 0xF7, 0x00, 0xFF,
|
|
424
|
+ 0x00, 0x00, 0xFF, 0x00, 0xFF,
|
|
425
|
+ 0x14, 0x14, 0xF4, 0x04, 0xFC,
|
|
426
|
+ 0x14, 0x14, 0x17, 0x10, 0x1F,
|
|
427
|
+ 0x10, 0x10, 0x1F, 0x10, 0x1F,
|
|
428
|
+ 0x14, 0x14, 0x14, 0x1F, 0x00,
|
|
429
|
+ 0x10, 0x10, 0x10, 0xF0, 0x00,
|
|
430
|
+ 0x00, 0x00, 0x00, 0x1F, 0x10,
|
|
431
|
+ 0x10, 0x10, 0x10, 0x1F, 0x10,
|
|
432
|
+ 0x10, 0x10, 0x10, 0xF0, 0x10,
|
|
433
|
+ 0x00, 0x00, 0x00, 0xFF, 0x10,
|
|
434
|
+ 0x10, 0x10, 0x10, 0x10, 0x10,
|
|
435
|
+ 0x10, 0x10, 0x10, 0xFF, 0x10,
|
|
436
|
+ 0x00, 0x00, 0x00, 0xFF, 0x14,
|
|
437
|
+ 0x00, 0x00, 0xFF, 0x00, 0xFF,
|
|
438
|
+ 0x00, 0x00, 0x1F, 0x10, 0x17,
|
|
439
|
+ 0x00, 0x00, 0xFC, 0x04, 0xF4,
|
|
440
|
+ 0x14, 0x14, 0x17, 0x10, 0x17,
|
|
441
|
+ 0x14, 0x14, 0xF4, 0x04, 0xF4,
|
|
442
|
+ 0x00, 0x00, 0xFF, 0x00, 0xF7,
|
|
443
|
+ 0x14, 0x14, 0x14, 0x14, 0x14,
|
|
444
|
+ 0x14, 0x14, 0xF7, 0x00, 0xF7,
|
|
445
|
+ 0x14, 0x14, 0x14, 0x17, 0x14,
|
|
446
|
+ 0x10, 0x10, 0x1F, 0x10, 0x1F,
|
|
447
|
+ 0x14, 0x14, 0x14, 0xF4, 0x14,
|
|
448
|
+ 0x10, 0x10, 0xF0, 0x10, 0xF0,
|
|
449
|
+ 0x00, 0x00, 0x1F, 0x10, 0x1F,
|
|
450
|
+ 0x00, 0x00, 0x00, 0x1F, 0x14,
|
|
451
|
+ 0x00, 0x00, 0x00, 0xFC, 0x14,
|
|
452
|
+ 0x00, 0x00, 0xF0, 0x10, 0xF0,
|
|
453
|
+ 0x10, 0x10, 0xFF, 0x10, 0xFF,
|
|
454
|
+ 0x14, 0x14, 0x14, 0xFF, 0x14,
|
|
455
|
+ 0x10, 0x10, 0x10, 0x1F, 0x00,
|
|
456
|
+ 0x00, 0x00, 0x00, 0xF0, 0x10,
|
|
457
|
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
458
|
+ 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
|
459
|
+ 0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
|
460
|
+ 0x00, 0x00, 0x00, 0xFF, 0xFF,
|
|
461
|
+ 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
|
462
|
+ 0x38, 0x44, 0x44, 0x38, 0x44,
|
|
463
|
+ 0x7C, 0x2A, 0x2A, 0x3E, 0x14,
|
|
464
|
+ 0x7E, 0x02, 0x02, 0x06, 0x06,
|
|
465
|
+ 0x02, 0x7E, 0x02, 0x7E, 0x02,
|
|
466
|
+ 0x63, 0x55, 0x49, 0x41, 0x63,
|
|
467
|
+ 0x38, 0x44, 0x44, 0x3C, 0x04,
|
|
468
|
+ 0x40, 0x7E, 0x20, 0x1E, 0x20,
|
|
469
|
+ 0x06, 0x02, 0x7E, 0x02, 0x02,
|
|
470
|
+ 0x99, 0xA5, 0xE7, 0xA5, 0x99,
|
|
471
|
+ 0x1C, 0x2A, 0x49, 0x2A, 0x1C,
|
|
472
|
+ 0x4C, 0x72, 0x01, 0x72, 0x4C,
|
|
473
|
+ 0x30, 0x4A, 0x4D, 0x4D, 0x30,
|
|
474
|
+ 0x30, 0x48, 0x78, 0x48, 0x30,
|
|
475
|
+ 0xBC, 0x62, 0x5A, 0x46, 0x3D,
|
|
476
|
+ 0x3E, 0x49, 0x49, 0x49, 0x00,
|
|
477
|
+ 0x7E, 0x01, 0x01, 0x01, 0x7E,
|
|
478
|
+ 0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
|
479
|
+ 0x44, 0x44, 0x5F, 0x44, 0x44,
|
|
480
|
+ 0x40, 0x51, 0x4A, 0x44, 0x40,
|
|
481
|
+ 0x40, 0x44, 0x4A, 0x51, 0x40,
|
|
482
|
+ 0x00, 0x00, 0xFF, 0x01, 0x03,
|
|
483
|
+ 0xE0, 0x80, 0xFF, 0x00, 0x00,
|
|
484
|
+ 0x08, 0x08, 0x6B, 0x6B, 0x08,
|
|
485
|
+ 0x36, 0x12, 0x36, 0x24, 0x36,
|
|
486
|
+ 0x06, 0x0F, 0x09, 0x0F, 0x06,
|
|
487
|
+ 0x00, 0x00, 0x18, 0x18, 0x00,
|
|
488
|
+ 0x00, 0x00, 0x10, 0x10, 0x00,
|
|
489
|
+ 0x30, 0x40, 0xFF, 0x01, 0x01,
|
|
490
|
+ 0x00, 0x1F, 0x01, 0x01, 0x1E,
|
|
491
|
+ 0x00, 0x19, 0x1D, 0x17, 0x12,
|
|
492
|
+ 0x00, 0x3C, 0x3C, 0x3C, 0x3C,
|
|
493
|
+ 0x00, 0x00, 0x00, 0x00, 0x00
|
|
494
|
+};
|
240
|
495
|
|
241
|
496
|
/**
|
242
|
|
- * @brief C++ API for NRF24l01 transceiver module
|
|
497
|
+ * @brief C++ API for ST7735 SPI LCD module
|
243
|
498
|
*
|
244
|
|
- * This file defines the NRF24l01 C++ interface for libnrf24l01
|
|
499
|
+ * This file defines the ST7735 C++ interface for libst7735
|
245
|
500
|
*
|
246
|
|
- * @snippet nrf_receiver.cxx Interesting
|
247
|
|
- * @snippet nrf_transmitter.cxx Interesting
|
|
501
|
+ * @snippet st7735.cxx Interesting
|
248
|
502
|
*/
|
249
|
503
|
class ST7735 : public GFX {
|
250
|
504
|
public:
|
251
|
505
|
/**
|
252
|
|
- * Instanciates a NRF24l01 object
|
|
506
|
+ * Instanciates a ST7735 object
|
253
|
507
|
*
|
254
|
|
- * @param cs chip select pin
|
|
508
|
+ * @param csLCD LCD chip select pin
|
|
509
|
+ * @param cSD SD card chip select pin
|
|
510
|
+ * @param rs data/command pin
|
|
511
|
+ * @param rst reset pin
|
255
|
512
|
*/
|
256
|
513
|
ST7735 (uint8_t csLCD, uint8_t cSD, uint8_t rs, uint8_t rst);
|
257
|
514
|
|
258
|
515
|
/**
|
259
|
|
- * NRF24l01 object destructor
|
|
516
|
+ * ST7735 object destructor
|
260
|
517
|
*/
|
261
|
518
|
~ST7735 ();
|
262
|
519
|
|
|
@@ -269,76 +526,92 @@ class ST7735 : public GFX {
|
269
|
526
|
}
|
270
|
527
|
|
271
|
528
|
/**
|
272
|
|
- *
|
|
529
|
+ * Initialize the modules GPIOs
|
273
|
530
|
*/
|
274
|
531
|
void initModule ();
|
275
|
532
|
|
276
|
533
|
/**
|
277
|
|
- *
|
|
534
|
+ * Configure the chip via SPI interface
|
278
|
535
|
*/
|
279
|
536
|
void configModule ();
|
280
|
|
-
|
|
537
|
+
|
281
|
538
|
/**
|
282
|
|
- *
|
|
539
|
+ * Send command to SPI bus (rs must be LOW)
|
|
540
|
+ *
|
|
541
|
+ * @param value command number
|
283
|
542
|
*/
|
284
|
543
|
void write (uint8_t value);
|
285
|
|
-
|
|
544
|
+
|
286
|
545
|
/**
|
287
|
|
- *
|
|
546
|
+ * Send data to SPI bus (rs must be HIGH)
|
|
547
|
+ *
|
|
548
|
+ * @param value command number
|
288
|
549
|
*/
|
289
|
550
|
void data (uint8_t value);
|
290
|
|
-
|
|
551
|
+
|
291
|
552
|
/**
|
292
|
|
- *
|
|
553
|
+ * Execute set of commands and data
|
|
554
|
+ *
|
|
555
|
+ * @param *addr pointer to start of the commands/data section
|
293
|
556
|
*/
|
294
|
557
|
void executeCMDList (const uint8_t *addr);
|
295
|
|
-
|
|
558
|
+
|
296
|
559
|
/**
|
297
|
|
- *
|
|
560
|
+ * Set the window size inside the screen where the pixels data
|
|
561
|
+ * will be written.
|
|
562
|
+ *
|
|
563
|
+ * @param x0 first coordinate
|
|
564
|
+ * @param y0 first coordinate
|
|
565
|
+ * @param x1 second coordinate
|
|
566
|
+ * @param y1 second coordinate
|
298
|
567
|
*/
|
299
|
568
|
void setAddrWindow (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
|
300
|
|
-
|
|
569
|
+
|
301
|
570
|
/**
|
302
|
|
- *
|
|
571
|
+ * Send pixel collor (RGB) to the chip.
|
|
572
|
+ *
|
|
573
|
+ * @param x axis on horizontal scale
|
|
574
|
+ * @param y axis on vertical scale
|
|
575
|
+ * @param color rgb (16bit) color (R[0-4], G[5-10], B[11-15])
|
303
|
576
|
*/
|
304
|
577
|
void drawPixel (int16_t x, int16_t y, uint16_t color);
|
305
|
|
-
|
|
578
|
+
|
306
|
579
|
/**
|
307
|
|
- *
|
|
580
|
+ * Copy the buffer to the chip via SPI interface.
|
308
|
581
|
*/
|
309
|
582
|
void refresh ();
|
310
|
|
-
|
|
583
|
+
|
311
|
584
|
/**
|
312
|
|
- *
|
|
585
|
+ * LCD chip select LOW.
|
313
|
586
|
*/
|
314
|
587
|
maa_result_t lcdCSOn ();
|
315
|
588
|
|
316
|
589
|
/**
|
317
|
|
- *
|
|
590
|
+ * LCD chip select HIGH.
|
318
|
591
|
*/
|
319
|
592
|
maa_result_t lcdCSOff ();
|
320
|
593
|
|
321
|
594
|
/**
|
322
|
|
- *
|
|
595
|
+ * CD card chip select LOW.
|
323
|
596
|
*/
|
324
|
597
|
maa_result_t sdCSOn ();
|
325
|
598
|
|
326
|
599
|
/**
|
327
|
|
- *
|
|
600
|
+ * CD card select HIGH.
|
328
|
601
|
*/
|
329
|
602
|
maa_result_t sdCSOff ();
|
330
|
|
-
|
|
603
|
+
|
331
|
604
|
/**
|
332
|
|
- *
|
|
605
|
+ * Data select HIGH.
|
333
|
606
|
*/
|
334
|
607
|
maa_result_t rsHIGH ();
|
335
|
608
|
|
336
|
609
|
/**
|
337
|
|
- *
|
|
610
|
+ * Data select LOW.
|
338
|
611
|
*/
|
339
|
612
|
maa_result_t rsLOW ();
|
340
|
|
-
|
341
|
|
- void fill (int col, uint16_t* buff, int len);
|
|
613
|
+
|
|
614
|
+ uint8_t m_map[160 * 128 * 2]; /**< Screens buffer */
|
342
|
615
|
private:
|
343
|
616
|
maa_spi_context m_spi;
|
344
|
617
|
uint8_t m_csLCD;
|
|
@@ -350,8 +623,8 @@ class ST7735 : public GFX {
|
350
|
623
|
maa_gpio_context m_cSDPinCtx;
|
351
|
624
|
maa_gpio_context m_rSTPinCtx;
|
352
|
625
|
maa_gpio_context m_rSPinCtx;
|
353
|
|
-
|
354
|
|
- uint8_t m_spiBuffer[128];
|
|
626
|
+
|
|
627
|
+ uint8_t m_spiBuffer[32];
|
355
|
628
|
|
356
|
629
|
std::string m_name;
|
357
|
630
|
};
|