Fri, 23 Sep 2016 21:12:43 +0200
attempt to update display by bloc
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
1 | #include "stdio.h" |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
2 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
3 | #include "mbed.h" |
5 | 4 | #include "rtos.h" |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
5 | #include "string" |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
6 | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
7 | #include "Terminal6x8.h" |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
8 | #include "Mono19x27.h" |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
9 | #include "Mono15x22.h" |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
10 | #include "Arial12x12.h" |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
11 | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
12 | #include "SSD1322.h" |
5 | 13 | #include "hp34comm.h" |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
14 | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
15 | Serial pc(USBTX, USBRX); |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
16 | |
5 | 17 | #define DEBUG |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
18 | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
19 | SSD1322 dsp(SPI_8, 20000000, PB_15, PB_14, PB_13, PB_12, D11, D12, "SSD1322", 256, 64); |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
20 | |
5 | 21 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
22 | uint8_t curchar; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
23 | uint8_t cmd; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
24 | uint8_t nchars; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
25 | char buffer[MAX_BUFF+1]; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
26 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
27 | typedef struct _DSP |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
28 | { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
29 | uint8_t cmd; |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
30 | uint8_t color; |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
31 | uint8_t bgcolor; |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
32 | uint8_t x0; |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
33 | uint8_t y0; |
5 | 34 | uint8_t fmt; // 0x01=>ascii, 0x02=>hex, 0x04=>bits, 0x08=>flags, 0x80=>ignore |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
35 | uint8_t maxsize; |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
36 | uint8_t width; |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
37 | const unsigned char* font; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
38 | char buffer[MAX_BUFF+1]; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
39 | } DSP; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
40 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
41 | static DSP table[] = |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
42 | { |
5 | 43 | { 0x00, 0xF, 0x0, 0, 0, 0x01, MAX_BUFF, 245, Mono19x27}, // main display |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
44 | { 0x0C, 0xF, 0x0,204, 38, 0x01, 3, 45, Mono15x22}, // channels display |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
45 | // { 0x01, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
46 | // { 0x02, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
5 | 47 | { 0x0A, 0xF, 0x0, 0, 57, 0x0C, 4, 0, Terminal6x8}, // flags + bits |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
48 | // { 0xFF, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
49 | }; |
2 | 50 | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
51 | // 9x10 |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
52 | const unsigned char icon_alarm[] __attribute__((aligned (2))) = |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
53 | { |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
54 | 0x1c, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
55 | 0x3e, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
56 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
57 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
58 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
59 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
60 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
61 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
62 | 0xff, 0x80, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
63 | 0x10, 0x0 |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
64 | }; |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
65 | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
66 | const unsigned char icon_curve[] __attribute__((aligned (2))) = |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
67 | { |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
68 | 0x80, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
69 | 0x80, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
70 | 0x80, 0x80, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
71 | 0x81, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
72 | 0x9e, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
73 | 0xa0, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
74 | 0xc0, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
75 | 0x80, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
76 | 0x80, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
77 | 0xff, 0x80 |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
78 | }; |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
79 | |
2 | 80 | typedef struct _FLAG |
81 | { | |
82 | uint8_t flag; | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
83 | uint8_t zone; |
2 | 84 | uint8_t x; |
85 | uint8_t y; | |
86 | const char* msg; | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
87 | const unsigned char* icon; |
2 | 88 | } FLAG; |
89 | ||
5 | 90 | typedef struct _FRAME |
91 | { | |
92 | uint8_t flag; | |
93 | uint8_t x0; | |
94 | uint8_t y0; | |
95 | uint8_t x1; | |
96 | uint8_t y1; | |
97 | } FRAME; | |
98 | ||
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
99 | static const FLAG flags[] = |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
100 | { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
101 | // flag, zone, x0, y0, msg, icon |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
102 | // right-side icons area |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
103 | { 0x00, 0x02, 0, 0, NULL, icon_alarm}, // F1.1 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
104 | { 0x01, 0x02, 0, 11, NULL, icon_curve}, // F1.2 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
105 | { 0x14, 0x02, 0, 22, "4W"}, // F2.5 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
106 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
107 | { 0x03, 0x04, 1, 2, "Channel"}, // F1.4 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
108 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
109 | // col 1 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
110 | { 0x34, 0x10, 0, 0, "MON"}, // F4.5 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
111 | { 0x33, 0x10, 0, 8, "VIEW"}, // F4.4 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
112 | { 0x35, 0x10, 0, 16, "SCAN"}, // F4.6 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
113 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
114 | //col 2 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
115 | { 0x32, 0x20, 0, 0, "*"}, // F4.3 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
116 | { 0x36, 0x20, 0, 8, "CFG"}, // F4.7 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
117 | { 0xFF, 0x20, 0, 16, "ERROR"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
118 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
119 | /* |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
120 | { 0xFF, 0, 0, "ADRS"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
121 | { 0xFF, 0, 0, "RMT"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
122 | { 0xFF, 0, 0, "EXT"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
123 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
124 | { 0xFF, 0, 0, "ONCE"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
125 | { 0xFF, 0, 0, "AUTO"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
126 | { 0xFF, 0, 0, "MEM"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
127 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
128 | { 0xFF, 0, 0, "LAST"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
129 | { 0xFF, 0, 0, "MIN"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
130 | { 0xFF, 0, 0, "MAX"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
131 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
132 | { 0xFF, 0, 0, "AVG"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
133 | { 0xFF, 0, 0, "OC"}, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
134 | */ |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
135 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
136 | { 0x05, 0x08, 0, 0, "Alarm"}, // F1.6 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
137 | { 0x06, 0x08, 0, 10, "H"}, // F1.7 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
138 | { 0x13, 0x08, 6, 10, "1"}, // F2.4 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
139 | { 0x10, 0x08, 12, 10, "2"}, // F2.1 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
140 | { 0x12, 0x08, 18, 10, "3"}, // F2.3 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
141 | { 0x11, 0x08, 24, 10, "4"}, // F2.2 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
142 | { 0x04, 0x08, 30, 10, "L"}, // F1.5 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
143 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
144 | }; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
145 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
146 | static const FRAME zones[] = |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
147 | { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
148 | { 0x01, 0, 0, 245, 27}, // main display area |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
149 | { 0x02, 246, 0, 255, 27}, // right notif area |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
150 | { 0x04, 203, 28, 255, 54}, // channels display area |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
151 | { 0x08, 160, 28, 202, 54}, // alarms area |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
152 | { 0x10, 0, 28, 32, 54}, // flags col1 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
153 | { 0x20, 33, 28, 70, 54}, // flags col2 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
154 | { 0x40, 71, 28, 159, 54}, // flags col3 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
155 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
156 | { 0x80, 0, 55, 255, 63}, // flags bits display area |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
157 | }; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
158 | |
5 | 159 | static const FRAME frames[] = |
160 | { | |
161 | { 0x02, 203, 35, 248, 55}, // F1.3 | |
162 | }; | |
163 | ||
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
164 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
165 | #ifdef DEBUG |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
166 | #define DBGPIN PC_0 |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
167 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
168 | DigitalOut dbgpin(DBGPIN); |
5 | 169 | inline void pulse(uint8_t count=1, bool stayup=false) |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
170 | { |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
171 | dbgpin = 0; |
5 | 172 | wait_us(2); |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
173 | while (count--) |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
174 | { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
175 | dbgpin = 1; |
5 | 176 | wait_us(2); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
177 | dbgpin = 0; |
5 | 178 | wait_us(2); |
179 | } | |
180 | if (stayup) | |
181 | dbgpin = 1; | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
182 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
183 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
184 | #else |
5 | 185 | inline void pulse(uint8_t count=1, bool stayup=false) |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
186 | {} |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
187 | #endif |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
188 | |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
189 | |
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
190 | HPSerial hp; |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
191 | volatile uint8_t must_refresh; |
5 | 192 | Thread tdsp, tloop; |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
193 | |
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
194 | void copy_to_lcd(void); |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
195 | void test_dsp(); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
196 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
197 | void setup() { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
198 | // init the LCD |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
199 | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
200 | //dsp.set_orientation(3); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
201 | pc.baud (115200); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
202 | pc.printf("\n\nSystem Core Clock = %.3f MHZ\r\n", |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
203 | (float)SystemCoreClock/1000000); |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
204 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
205 | // myLCD.set_font((unsigned char*) Terminal6x8); |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
206 | // myLCD.claim(stdout); // send stdout to the LCD display |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
207 | // myLCD.claim(stderr); // send stderr to the LCD display |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
208 | dsp.background(Black); // set background to black |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
209 | dsp.foreground(0xF); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
210 | dsp.cls(); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
211 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
212 | cmd = 0xFF; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
213 | curchar = 0; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
214 | nchars = 0; |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
215 | |
5 | 216 | for (uint8_t i=0; i<sizeof(table)/sizeof(table[0]); ++i) |
217 | memset(table[i].buffer, 0, MAX_BUFF+1); | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
218 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
219 | dsp.locate(30, 10); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
220 | dsp.set_font(Mono19x27); |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
221 | dsp.printf("HP34970A"); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
222 | dsp.set_font(Terminal6x8); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
223 | dsp.locate(90, 40); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
224 | dsp.printf("David Douard"); |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
225 | dsp.copy_to_lcd(); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
226 | wait(2); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
227 | dsp.cls(); |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
228 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
229 | |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
230 | void copy_to_lcd(void) { |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
231 | uint8_t mask=1; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
232 | |
5 | 233 | while(1) { |
234 | pulse(0, true); | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
235 | if (must_refresh & mask) { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
236 | for(uint8_t i=0; i<sizeof(zones)/sizeof(zones[0]); i++) |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
237 | if (zones[i].flag == mask) { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
238 | dsp.copy_to_lcd(zones[i].x0/4, (zones[i].x1+3)/4, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
239 | zones[i].y0, zones[i].y1); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
240 | must_refresh &= ~mask; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
241 | break; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
242 | } |
5 | 243 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
244 | mask = mask << 1; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
245 | if (mask == 0) { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
246 | mask = 1; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
247 | } |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
248 | |
5 | 249 | pulse(0, false); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
250 | Thread::wait(10); |
5 | 251 | } |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
252 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
253 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
254 | void show(uint8_t cmd, char *txt, uint8_t nchar=0) { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
255 | uint8_t i, len; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
256 | uint16_t bgcolor, fgcolor; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
257 | char *oldv; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
258 | |
5 | 259 | pulse(1, true); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
260 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
261 | len = MAX_BUFF; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
262 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
263 | for (i=0; i<sizeof(table)/sizeof(table[0]); ++i) { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
264 | if (table[i].cmd == cmd) { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
265 | bgcolor = table[i].bgcolor; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
266 | fgcolor = table[i].color; |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
267 | dsp.background(bgcolor); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
268 | dsp.foreground(fgcolor); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
269 | dsp.set_font((unsigned char*) table[i].font); |
2 | 270 | oldv = table[i].buffer; |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
271 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
272 | dsp.locate(table[i].x0, table[i].y0); |
5 | 273 | |
274 | if (table[i].fmt & 0x01 ) { | |
275 | // ascii | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
276 | if (table[i].width > 0) |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
277 | dsp.fillrect(table[i].x0, table[i].y0, table[i].x0 + table[i].width, table[i].y0 + table[i].font[2], bgcolor); |
5 | 278 | for (uint8_t k=0; ;k++) { |
279 | if (txt[k] == 0x00) | |
280 | { | |
281 | dsp.printf(txt); | |
282 | break; | |
283 | } | |
284 | if (txt[k] == 0x09) { // \t is a special char for 'unselected' display value | |
285 | txt[k] = 0x00; | |
286 | dsp.printf(txt); | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
287 | |
5 | 288 | if (fgcolor == table[i].color) |
289 | fgcolor /= 2; | |
290 | else | |
291 | fgcolor = table[i].color; | |
292 | dsp.foreground(fgcolor); | |
293 | txt = &(txt[k+1]); | |
294 | k = 0; | |
295 | } | |
296 | } | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
297 | if (cmd == 0x00) // main area |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
298 | must_refresh |= 0x01; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
299 | if (cmd == 0x0C) // channels area |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
300 | must_refresh |= 0x04; |
5 | 301 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
302 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
303 | /* |
5 | 304 | if (table[i].fmt & 0x02 ) { |
305 | // hex | |
2 | 306 | for (uint8_t j=0;; j++) { |
307 | if (txt[j] == 0x00) | |
308 | break; | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
309 | dsp.printf("%02X ", txt[j]); |
2 | 310 | } |
311 | for (uint8_t j=3*strlen(txt); j<table[i].maxsize; j++) | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
312 | dsp.printf(" "); |
5 | 313 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
314 | */ |
5 | 315 | if (table[i].fmt & 0x04 ) { |
316 | // binary | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
317 | dsp.foreground(fgcolor); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
318 | dsp.printf(" ["); |
2 | 319 | for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) { |
320 | if (j>0) { | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
321 | dsp.foreground(fgcolor); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
322 | dsp.printf(" | "); |
2 | 323 | } |
324 | for (uint8_t k=0; k<8; k++) { | |
325 | if (txt[j] & (1 << (7-k))) | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
326 | dsp.foreground(fgcolor); |
2 | 327 | else |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
328 | dsp.foreground(bgcolor); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
329 | dsp.printf("%d", (8-k)); |
2 | 330 | } |
331 | } | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
332 | dsp.foreground(fgcolor); |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
333 | dsp.printf("]"); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
334 | must_refresh |= 0x80; |
5 | 335 | } |
336 | ||
337 | if (table[i].fmt & 0x08 ) { | |
338 | // flags | |
2 | 339 | for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) { |
340 | for (uint8_t k=0; k<8; k++) { | |
341 | if ((txt[j] & (1 << k) ) != (oldv[j] & (1 << k))) { | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
342 | |
2 | 343 | if (txt[j] & (1 << k)) |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
344 | dsp.foreground(fgcolor); |
2 | 345 | else |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
346 | dsp.foreground(bgcolor); |
5 | 347 | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
348 | /* |
5 | 349 | for (uint8_t l=0; |
350 | l<(sizeof(frames)/sizeof(frames[0])); ++l) { | |
351 | if (frames[l].flag & ((j<<4) + k)) | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
352 | dsp.fillrect(frames[l].x0, frames[l].y0, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
353 | frames[l].x1, frames[l].y1, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
354 | fgcolor/8); |
5 | 355 | else |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
356 | dsp.fillrect(frames[l].x0, frames[l].y0, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
357 | frames[l].x1, frames[l].y1, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
358 | bgcolor); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
359 | |
5 | 360 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
361 | */ |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
362 | |
2 | 363 | for (uint8_t l=0; |
364 | l<(sizeof(flags)/sizeof(flags[0])); ++l) { | |
365 | if (flags[l].flag == ((j<<4) + k)) { | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
366 | for (uint8_t m=0; m<(sizeof(zones)/sizeof(zones[0])); m++) { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
367 | if (flags[l].zone == zones[m].flag) { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
368 | if (flags[l].msg != NULL) { // a string |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
369 | dsp.locate(flags[l].x + zones[m].x0, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
370 | flags[l].y + zones[m].y0); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
371 | dsp.printf(flags[l].msg);} |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
372 | else { // an icon |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
373 | Bitmap_s pic = {9, 10, 2, flags[l].icon}; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
374 | dsp.Bitmap_BW(pic, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
375 | flags[l].x + zones[m].x0, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
376 | flags[l].y + zones[m].y0); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
377 | } |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
378 | must_refresh |= zones[m].flag; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
379 | break; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
380 | } |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
381 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
382 | break; |
2 | 383 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
384 | } |
2 | 385 | } |
386 | } | |
387 | } | |
388 | } | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
389 | |
5 | 390 | for(uint8_t j=0; j<table[i].maxsize; j++) |
391 | oldv[j] = txt[j]; | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
392 | break; |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
393 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
394 | } |
5 | 395 | |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
396 | //dsp.copy_to_lcd(); |
5 | 397 | pulse(1, false); |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
398 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
399 | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
400 | void test_dsp() |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
401 | { |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
402 | const FRAME *z; |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
403 | show(0x00, "8g8g8g8g8g8g8", 13); // main dsp |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
404 | show(0x0C, "888", 3); // channel dsp |
5 | 405 | show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
406 | dsp.copy_to_lcd(); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
407 | wait(3); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
408 | dsp.cls(); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
409 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
410 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
411 | for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++) |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
412 | { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
413 | z = &zones[i]; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
414 | dsp.fillrect(z->x0, z->y0, z->x1, z->y1, 4+i); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
415 | dsp.locate(z->x0+1, z->y0+1); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
416 | dsp.printf("%d", i); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
417 | } |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
418 | for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++) |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
419 | { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
420 | z = &zones[i]; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
421 | pc.printf("Zone %d [%x]: %d, %d, %d, %d\n", i, z->flag, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
422 | z->x0, z->y0, z->x1, z->y1); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
423 | must_refresh = z->flag; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
424 | wait(1); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
425 | } |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
426 | pc.printf("Done\n"); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
427 | wait(2); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
428 | pc.printf("Copy ALL\n"); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
429 | dsp.copy_to_lcd(); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
430 | wait(2); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
431 | dsp.cls(); |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
432 | } |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
433 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
434 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
435 | void loop() { // run over and over |
5 | 436 | while(1){ |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
437 | if (hp.cmd_available()) |
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
438 | { |
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
439 | HPSerial::CMD cmd; |
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
440 | if (hp.pop(cmd)) |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
441 | {/* |
5 | 442 | pc.printf("CMD[%s:%d %d/%d/%d/%d/%d/%d/%d] %X\n", (cmd.direction==HPSerial::Rx)?"Rx":"Tx", cmd.id, |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
443 | hp.nerrors(0), |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
444 | hp.nerrors(1), |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
445 | hp.nerrors(2), |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
446 | hp.nerrors(3), |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
447 | hp.nerrors(4), |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
448 | hp.nerrors(5), |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
449 | hp.nerrors(6), |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
450 | cmd.cmd); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
451 | */ |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
452 | if (cmd.direction == HPSerial::Rx) { |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
453 | // if ((cmd.cmd == 0x00) || (cmd.cmd == 0x0C)) |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
454 | // pc.printf(" data=%s\n", cmd.value); |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
455 | show(cmd.cmd, cmd.value, cmd.size); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
456 | |
4
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
457 | } |
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
458 | } |
219766126afb
another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents:
3
diff
changeset
|
459 | } |
5 | 460 | Thread::wait(0.01); |
461 | } | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
462 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
463 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
464 | int main() |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
465 | { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
466 | setup(); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
467 | |
5 | 468 | tdsp.start(copy_to_lcd); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
469 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
470 | test_dsp(); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
471 | wait(5); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
472 | dsp.cls(); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
473 | |
5 | 474 | tloop.start(loop); |
475 | while(1); | |
476 | //loop(); | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
477 | } |