Tue, 05 Dec 2017 00:59:57 +0100
add hgignore
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 | |
19 | 15 | #include "QEI.h" |
18
4fd621551d55
[full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents:
17
diff
changeset
|
16 | #include "Keypad.h" |
4fd621551d55
[full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents:
17
diff
changeset
|
17 | |
19 | 18 | /******************************************************/ |
19 | /* L432KC */ | |
20 | /******************************************************/ | |
17
162fe523c37d
almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents:
13
diff
changeset
|
21 | #if (defined STM32L432xx) |
8 | 22 | // display |
23 | #define DSP_MOSI PA_7 //A6 | |
19 | 24 | #define DSP_MISO PA_6 //A5 |
8 | 25 | #define DSP_SCLK PA_5 //A4 |
26 | #define DSP_CS PB_0 //D3 | |
27 | #define DSP_RST PB_5 //D11 | |
28 | #define DSP_DC PB_4 //D12 | |
19 | 29 | |
11 | 30 | // UART for RX (CPU->DP) and TX (DP->CPU) combined |
18
4fd621551d55
[full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents:
17
diff
changeset
|
31 | #define HP_TX PA_9 // serial1 TX |
8 | 32 | #define HP_RX PA_10 // serial1 RX |
19 | 33 | |
34 | // RST pin (handle this by hand) | |
35 | #define HP_RST PA_0 | |
36 | ||
8 | 37 | // misc |
19 | 38 | #define DBGPIN NC |
39 | ||
40 | // encoder | |
41 | #define KP_ENC1 PA_8 | |
42 | #define KP_ENC2 PA_11 | |
8 | 43 | |
19 | 44 | // keypad |
45 | #define KP_R0 PA_1 | |
46 | #define KP_R1 PA_3 | |
47 | #define KP_R2 PA_4 | |
48 | #define KP_R3 PA_12 | |
17
162fe523c37d
almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents:
13
diff
changeset
|
49 | |
19 | 50 | #define KP_C0 D4 |
51 | #define KP_C1 D5 | |
52 | #define KP_C2 D6 | |
53 | #define KP_C3 D7 | |
54 | #define KP_C4 D8 | |
55 | ||
56 | /******************************************************/ | |
57 | /* F446RE */ | |
58 | /******************************************************/ | |
8 | 59 | #elif defined STM32F446xx |
19 | 60 | // UART |
61 | // USBTX PA_2 | |
62 | // USBRX PA_3 | |
8 | 63 | // display |
64 | #define DSP_MOSI PB_15 | |
19 | 65 | #define DSP_MISO NC |
8 | 66 | #define DSP_SCLK PB_13 |
67 | #define DSP_CS PB_12 | |
19 | 68 | #define DSP_RST PB_5 |
69 | #define DSP_DC PB_4 | |
70 | ||
8 | 71 | // UART for RX (CPU->DP) |
19 | 72 | #define HP_RX PC_11 // serial3 RX |
73 | #define HP_TX PC_10 // serial3 TX | |
74 | ||
75 | // RST pin (handle this by hand) | |
76 | #define HP_RST PC_12 | |
77 | ||
78 | // encoder | |
79 | #define KP_ENC1 PC_4 | |
80 | #define KP_ENC2 PC_5 | |
81 | ||
82 | // keypad | |
83 | #define KP_R0 PC_0 // I-6 | |
84 | #define KP_R1 PC_1 // II-5 | |
85 | #define KP_R2 PC_2 // I-5 | |
86 | #define KP_R3 PC_3 // II-4 | |
87 | ||
88 | ||
89 | #define KP_C0 PB_0 // I-4 | |
90 | #define KP_C1 PA_6 // I-2 | |
91 | #define KP_C2 PA_7 // I-3 | |
92 | #define KP_C3 PA_5 // I-1 | |
93 | #define KP_C4 PD_2 // II-1 | |
8 | 94 | |
95 | // misc | |
19 | 96 | #define DBGPIN PC_6 |
8 | 97 | |
98 | #endif | |
99 | ||
13
0fdeed7c083e
make USB (debug) serial console depend only on HAVE_PC compile variable
David Douard <david.douard@logilab.fr>
parents:
12
diff
changeset
|
100 | #ifdef HAVE_PC |
0fdeed7c083e
make USB (debug) serial console depend only on HAVE_PC compile variable
David Douard <david.douard@logilab.fr>
parents:
12
diff
changeset
|
101 | Serial pc(USBTX, USBRX); |
0fdeed7c083e
make USB (debug) serial console depend only on HAVE_PC compile variable
David Douard <david.douard@logilab.fr>
parents:
12
diff
changeset
|
102 | #endif |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
103 | |
19 | 104 | SSD1322 *dsp; |
105 | HPSerial *hp; | |
8 | 106 | volatile uint8_t must_refresh; |
107 | Thread tdsp, tloop; | |
19 | 108 | Ticker blinker; |
109 | Timeout rst_delay; | |
110 | Timeout splashscreen_timer; | |
8 | 111 | DigitalOut led(LED1); |
19 | 112 | InterruptIn rst(HP_RST); |
113 | ||
114 | QEI qenc(KP_ENC1, KP_ENC2, NC, 16); | |
115 | volatile uint8_t knob; | |
116 | volatile bool splashscreen; | |
117 | ||
118 | ||
119 | typedef enum { | |
120 | KEY_NONE=0, | |
121 | KEY_PRESSED, | |
122 | KEY_RELEASED | |
123 | } key_event_t; | |
124 | ||
125 | typedef struct keycode { | |
126 | uint8_t row; | |
127 | uint8_t col; | |
128 | key_event_t keyevent; | |
129 | } keycode_t; | |
130 | ||
131 | volatile keycode_t cur_keycode; | |
5 | 132 | |
19 | 133 | PinName kp_rows[] = { |
134 | KP_R0, | |
135 | KP_R1, | |
136 | KP_R2, | |
137 | KP_R3 | |
138 | }; | |
139 | ||
140 | PinName kp_colums[] = { | |
141 | KP_C0, KP_C1, | |
142 | KP_C2, KP_C3, | |
143 | KP_C4 | |
144 | }; | |
18
4fd621551d55
[full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents:
17
diff
changeset
|
145 | |
19 | 146 | DigitalIn kp_in[] = { |
147 | KP_R0, | |
148 | KP_R1, | |
149 | KP_R2, | |
150 | KP_R3 | |
151 | }; | |
152 | ||
153 | DigitalOut kp_out[] = { | |
154 | KP_C0, KP_C1, | |
155 | KP_C2, KP_C3, | |
156 | KP_C4 | |
157 | }; | |
158 | ||
159 | uint8_t kp_nrows = sizeof(kp_in)/sizeof(kp_in[0]); | |
160 | uint8_t kp_ncols = sizeof(kp_out)/sizeof(kp_out[0]); | |
161 | ||
162 | void kp_cb(uint8_t row, uint8_t col); | |
163 | void kr_cb(uint8_t row, uint8_t col); | |
164 | ||
165 | Keypad *kpad; | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
166 | uint8_t curchar; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
167 | uint8_t cmd; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
168 | uint8_t nchars; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
169 | char buffer[MAX_BUFF+1]; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
170 | |
8 | 171 | void timeout_h() { |
172 | led = !led; | |
173 | } | |
174 | ||
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
175 | typedef struct _DSP |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
176 | { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
177 | 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
|
178 | 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
|
179 | 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
|
180 | uint8_t x0; |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
181 | uint8_t y0; |
5 | 182 | 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
|
183 | 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
|
184 | uint8_t width; |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
185 | const unsigned char* font; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
186 | char buffer[MAX_BUFF+1]; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
187 | } DSP; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
188 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
189 | static DSP table[] = |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
190 | { |
5 | 191 | { 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
|
192 | { 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
|
193 | // { 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
|
194 | // { 0x02, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
5 | 195 | { 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
|
196 | // { 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
|
197 | }; |
2 | 198 | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
199 | // 9x10 |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
200 | 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
|
201 | { |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
202 | 0x1c, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
203 | 0x3e, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
204 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
205 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
206 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
207 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
208 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
209 | 0x7f, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
210 | 0xff, 0x80, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
211 | 0x10, 0x0 |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
212 | }; |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
213 | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
214 | 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
|
215 | { |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
216 | 0x80, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
217 | 0x80, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
218 | 0x80, 0x80, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
219 | 0x81, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
220 | 0x9e, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
221 | 0xa0, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
222 | 0xc0, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
223 | 0x80, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
224 | 0x80, 0x0, |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
225 | 0xff, 0x80 |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
226 | }; |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
227 | |
2 | 228 | typedef struct _FLAG |
229 | { | |
230 | uint8_t flag; | |
8 | 231 | uint16_t zone; |
2 | 232 | uint8_t x; |
233 | uint8_t y; | |
234 | 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
|
235 | const unsigned char* icon; |
2 | 236 | } FLAG; |
237 | ||
5 | 238 | typedef struct _FRAME |
239 | { | |
8 | 240 | uint16_t flag; |
5 | 241 | uint8_t x0; |
242 | uint8_t y0; | |
243 | uint8_t x1; | |
244 | uint8_t y1; | |
245 | } FRAME; | |
246 | ||
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
247 | static const FLAG flags[] = |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
248 | { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
249 | // flag, zone, x0, y0, msg, icon |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
250 | // right-side icons area |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
251 | { 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
|
252 | { 0x01, 0x02, 0, 11, NULL, icon_curve}, // F1.2 |
19 | 253 | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
254 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
255 | { 0x03, 0x04, 1, 2, "Channel"}, // F1.4 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
256 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
257 | // col 1 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
258 | { 0x34, 0x10, 0, 0, "MON"}, // F4.5 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
259 | { 0x33, 0x10, 0, 8, "VIEW"}, // F4.4 |
8 | 260 | { 0x35, 0x10, 0, 16, "SCAN"}, // F4.6 |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
261 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
262 | //col 2 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
263 | { 0x32, 0x20, 0, 0, "*"}, // F4.3 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
264 | { 0x36, 0x20, 0, 8, "CFG"}, // F4.7 |
8 | 265 | { 0x27, 0x20, 0, 16, "ERR"}, // F3.8 |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
266 | |
8 | 267 | // col 3 |
268 | { 0x41, 0x040, 0, 0, "ADRS"}, // F4.2 | |
269 | { 0x40, 0x040, 0, 8, "RMT"}, // F4.1 | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
270 | |
8 | 271 | // col 4 |
272 | { 0x26, 0x080, 0, 0, "EXT"}, // F3.7 | |
273 | { 0x25, 0x080, 0, 8, "ONCE"}, // F3.6 | |
19 | 274 | |
8 | 275 | { 0xFF, 0x080, 0, 16, "MEM"}, |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
276 | |
19 | 277 | |
8 | 278 | // col 5 |
279 | { 0x14, 0x100, 0, 0, "4W"}, // F2.5 | |
280 | { 0x15, 0x100, 0, 8, "OC"}, // F2.6 | |
281 | { 0xFF, 0x100, 0, 16, "LST"}, // F3.8? Nope | |
282 | { 0xFF, 0x100, 0, 16, "MIN"}, | |
283 | { 0xFF, 0x100, 0, 16, "MAX"}, | |
284 | { 0xFF, 0x100, 0, 16, "AVG"}, | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
285 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
286 | { 0x05, 0x08, 0, 0, "Alarm"}, // F1.6 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
287 | { 0x06, 0x08, 0, 10, "H"}, // F1.7 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
288 | { 0x13, 0x08, 6, 10, "1"}, // F2.4 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
289 | { 0x10, 0x08, 12, 10, "2"}, // F2.1 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
290 | { 0x12, 0x08, 18, 10, "3"}, // F2.3 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
291 | { 0x11, 0x08, 24, 10, "4"}, // F2.2 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
292 | { 0x04, 0x08, 30, 10, "L"}, // F1.5 |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
293 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
294 | }; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
295 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
296 | static const FRAME zones[] = |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
297 | { |
8 | 298 | { 0x001, 0, 0, 245, 27}, // main display area |
299 | { 0x002, 246, 0, 255, 27}, // right notif area | |
300 | { 0x004, 203, 28, 255, 54}, // channels display area | |
301 | { 0x008, 160, 28, 202, 54}, // alarms area | |
302 | { 0x010, 0, 28, 32, 54}, // flags col1 | |
303 | { 0x020, 33, 28, 70, 54}, // flags col2 | |
304 | { 0x040, 71, 28, 103, 54}, // flags col3 | |
305 | { 0x080, 104, 28, 128, 54}, // flags col4 | |
306 | { 0x100, 129, 28, 159, 54}, // flags col5 | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
307 | |
8 | 308 | { 0x8000, 0, 55, 255, 63}, // flags bits display area |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
309 | }; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
310 | |
5 | 311 | static const FRAME frames[] = |
312 | { | |
8 | 313 | { 0x02, 203, 35, 255, 54}, // F1.3 - channel frame |
314 | { 0x07, 160, 28, 202, 54}, // F1.8 - alarm frame | |
5 | 315 | }; |
316 | ||
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
317 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
318 | #ifdef DEBUG |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
319 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
320 | DigitalOut dbgpin(DBGPIN); |
5 | 321 | 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
|
322 | { |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
323 | dbgpin = 0; |
5 | 324 | wait_us(2); |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
325 | while (count--) |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
326 | { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
327 | dbgpin = 1; |
5 | 328 | wait_us(2); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
329 | dbgpin = 0; |
5 | 330 | wait_us(2); |
331 | } | |
332 | if (stayup) | |
333 | dbgpin = 1; | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
334 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
335 | #else |
5 | 336 | 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
|
337 | {} |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
338 | #endif |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
339 | |
19 | 340 | // callbacks & thread functions |
341 | void loop(); | |
342 | void copy_to_lcd(void); | |
343 | void test_dsp(); | |
344 | void reset(void); | |
345 | void reset_irq(void); | |
346 | void qei_cb(int dir); | |
347 | void end_splashscreen(void); | |
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
|
348 | |
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
|
349 | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
350 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
351 | void setup() { |
8 | 352 | #ifdef HAVE_PC |
353 | pc.baud (115200); | |
354 | #endif | |
19 | 355 | |
356 | printf("\n\nSETUP\n"); | |
357 | printf(" System Core Clock = %.3f MHZ\r\n", | |
8 | 358 | (float)SystemCoreClock/1000000); |
359 | ||
19 | 360 | //printf("Attaching Led 1: %d\n", LED1); |
361 | //blinker.attach(callback(timeout_h), 0.5f); | |
362 | ||
363 | hp = NULL; | |
364 | printf("Setup HP communication pins\n"); | |
365 | printf(" HP_RX=%d\n", HP_RX); | |
366 | DigitalIn(HP_RX).mode(PullDown); | |
367 | printf(" HP_TX=%d\n", HP_TX); | |
368 | DigitalOut(HP_TX).write(1); | |
369 | printf(" HP_RST=%d\n", HP_RST); | |
370 | DigitalIn(HP_RST).mode(PullDown); | |
371 | ||
372 | printf(" setup QEI pins\n"); | |
373 | printf(" ENC1=%d\n", KP_ENC1); | |
374 | DigitalIn(KP_ENC1).mode(PullUp); | |
375 | printf(" ENC2=%d\n", KP_ENC2); | |
376 | DigitalIn(KP_ENC2).mode(PullUp); | |
377 | qenc.attach(&qei_cb); | |
378 | ||
379 | printf(" setup Keypad\n"); | |
380 | cur_keycode.keyevent = KEY_NONE; | |
381 | uint8_t nrows = sizeof(kp_rows)/sizeof(kp_rows[0]); | |
382 | uint8_t ncols = sizeof(kp_colums)/sizeof(kp_colums[0]); | |
383 | ||
384 | kpad = new Keypad(nrows, kp_in, ncols, kp_out); | |
385 | printf(" attach Keypad callbacks\n"); | |
386 | kpad->attach(&kp_cb, &kr_cb); | |
387 | printf(" start Keypad\n"); | |
388 | kpad->start(); | |
389 | ||
390 | printf("Setup OLED display\n"); | |
391 | splashscreen = true; | |
392 | // init the LCD | |
393 | printf(" DSP_MOSI=%d\n", DSP_MOSI); | |
394 | printf(" DSP_MISO=%d\n", DSP_MISO); | |
395 | printf(" DSP_SCLK=%d\n", DSP_SCLK); | |
396 | printf(" DSP_CS=%d\n", DSP_CS); | |
397 | printf(" DSP_RST=%d\n", DSP_RST); | |
398 | printf(" DSP_DC=%d\n", DSP_DC); | |
399 | dsp = new SSD1322(20000000, DSP_MOSI, DSP_MISO, DSP_SCLK, DSP_CS, | |
400 | DSP_RST, DSP_DC, "SSD1322"); | |
401 | //dsp.set_orientation(3); | |
402 | printf(" configure DSP\n"); | |
8 | 403 | // myLCD.set_font((unsigned char*) Terminal6x8); |
404 | // myLCD.claim(stdout); // send stdout to the LCD display | |
405 | // myLCD.claim(stderr); // send stderr to the LCD display | |
406 | dsp->background(Black); // set background to black | |
407 | dsp->foreground(0xF); | |
408 | dsp->cls(); | |
19 | 409 | |
8 | 410 | cmd = 0xFF; |
411 | curchar = 0; | |
412 | nchars = 0; | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
413 | |
8 | 414 | for (uint8_t i=0; i<sizeof(table)/sizeof(table[0]); ++i) |
415 | memset(table[i].buffer, 0, MAX_BUFF+1); | |
19 | 416 | |
417 | printf(" display splash screen\n"); | |
8 | 418 | dsp->locate(30, 10); |
419 | dsp->set_font((unsigned char*)Mono19x27); | |
420 | dsp->printf("HP34970A"); | |
421 | dsp->set_font((unsigned char*)Terminal6x8); | |
422 | dsp->locate(90, 40); | |
423 | dsp->printf("David Douard"); | |
424 | dsp->copy_to_lcd(); | |
19 | 425 | |
426 | printf("Starting LCD thread\n"); | |
427 | tdsp.start(©_to_lcd); | |
428 | ||
429 | printf("Starting Event thread\n"); | |
430 | tloop.start(&loop); | |
431 | ||
432 | printf("Attaching timers\n"); | |
433 | splashscreen_timer.attach(callback(&end_splashscreen), 2); | |
434 | rst.fall(&reset_irq); | |
435 | ||
436 | printf("SETUP DONE\n"); | |
437 | } | |
8 | 438 | |
19 | 439 | void end_splashscreen(void) |
440 | { | |
441 | printf("End of splash screen\n"); | |
442 | splashscreen = false; | |
443 | } | |
444 | ||
445 | void reset_irq(void) | |
446 | { | |
447 | rst_delay.attach(callback(&reset), 0.1); | |
448 | } | |
449 | ||
450 | void reset(void) | |
451 | { | |
452 | if (DigitalIn(HP_RST).read() == 0) { | |
453 | if (hp == NULL) { | |
454 | printf("setup HP communication handler\n"); | |
455 | hp = new HPSerial(HP_TX, HP_RX); | |
456 | } | |
457 | ||
458 | printf("!! RST !! (gstate=%d, state=%d)\n", | |
459 | hp->gstate(), hp->state()); | |
460 | //printf("Value is ... %X\n", hp->search()); | |
461 | hp->startup(); | |
462 | } | |
1
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 | |
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
|
465 | void copy_to_lcd(void) { |
19 | 466 | //uint8_t mask=1; |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
467 | |
5 | 468 | while(1) { |
469 | pulse(0, true); | |
19 | 470 | if ((splashscreen == false) && (must_refresh)) { |
8 | 471 | must_refresh = 0; |
19 | 472 | //Thread::wait(20); // give a bit of time for some more cmds |
8 | 473 | dsp->copy_to_lcd(); |
474 | } | |
475 | ||
476 | /* | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
477 | if (must_refresh & mask) { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
478 | 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
|
479 | if (zones[i].flag == mask) { |
8 | 480 | dsp->copy_to_lcd(zones[i].x0/4, (zones[i].x1+3)/4, |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
481 | zones[i].y0, zones[i].y1); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
482 | must_refresh &= ~mask; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
483 | break; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
484 | } |
5 | 485 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
486 | mask = mask << 1; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
487 | if (mask == 0) { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
488 | mask = 1; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
489 | } |
8 | 490 | */ |
5 | 491 | pulse(0, false); |
8 | 492 | Thread::wait(30); |
5 | 493 | } |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
494 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
495 | |
19 | 496 | void show(uint8_t cmd, const char *intxt, uint8_t nchar=0) { |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
497 | uint8_t i, len; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
498 | uint16_t bgcolor, fgcolor; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
499 | char *oldv; |
19 | 500 | char *txt; |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
501 | |
19 | 502 | |
503 | txt = (char *)malloc(strlen(intxt)+1); | |
504 | strcpy(txt, intxt); | |
5 | 505 | pulse(1, true); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
506 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
507 | len = MAX_BUFF; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
508 | |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
509 | 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
|
510 | if (table[i].cmd == cmd) { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
511 | bgcolor = table[i].bgcolor; |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
512 | fgcolor = table[i].color; |
8 | 513 | dsp->background(bgcolor); |
514 | dsp->foreground(fgcolor); | |
515 | dsp->set_font((unsigned char*) table[i].font); | |
2 | 516 | oldv = table[i].buffer; |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
517 | |
8 | 518 | dsp->locate(table[i].x0, table[i].y0); |
5 | 519 | |
520 | if (table[i].fmt & 0x01 ) { | |
8 | 521 | if (strncmp(oldv, txt, table[i].maxsize) != 0) { |
522 | // ascii | |
523 | if (table[i].width > 0) | |
524 | dsp->fillrect(table[i].x0, table[i].y0, table[i].x0 + table[i].width, table[i].y0 + table[i].font[2], bgcolor); | |
525 | for (uint8_t k=0; ;k++) { | |
526 | if (txt[k] == 0x00) | |
527 | { | |
528 | dsp->printf(txt); | |
529 | break; | |
530 | } | |
531 | if (txt[k] == 0x09) { // \t is a special char for 'unselected' display value | |
532 | txt[k] = 0x00; | |
533 | dsp->printf(txt); | |
19 | 534 | |
8 | 535 | if (fgcolor == table[i].color) |
536 | fgcolor /= 2; | |
537 | else | |
538 | fgcolor = table[i].color; | |
539 | dsp->foreground(fgcolor); | |
540 | txt = &(txt[k+1]); | |
541 | k = 0; | |
5 | 542 | } |
543 | } | |
8 | 544 | if (cmd == 0x00) // main area |
545 | must_refresh |= 0x01; | |
546 | if (cmd == 0x0C) // channels area | |
547 | must_refresh |= 0x04; | |
5 | 548 | } |
549 | } | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
550 | /* |
5 | 551 | if (table[i].fmt & 0x02 ) { |
552 | // hex | |
2 | 553 | for (uint8_t j=0;; j++) { |
554 | if (txt[j] == 0x00) | |
555 | break; | |
8 | 556 | dsp->printf("%02X ", txt[j]); |
2 | 557 | } |
558 | for (uint8_t j=3*strlen(txt); j<table[i].maxsize; j++) | |
8 | 559 | dsp->printf(" "); |
5 | 560 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
561 | */ |
5 | 562 | if (table[i].fmt & 0x04 ) { |
563 | // binary | |
8 | 564 | dsp->foreground(fgcolor); |
565 | dsp->printf(" ["); | |
2 | 566 | for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) { |
567 | if (j>0) { | |
8 | 568 | dsp->foreground(fgcolor); |
569 | dsp->printf(" | "); | |
2 | 570 | } |
571 | for (uint8_t k=0; k<8; k++) { | |
572 | if (txt[j] & (1 << (7-k))) | |
8 | 573 | dsp->foreground(fgcolor); |
2 | 574 | else |
8 | 575 | dsp->foreground(bgcolor); |
576 | dsp->printf("%d", (8-k)); | |
2 | 577 | } |
578 | } | |
8 | 579 | dsp->foreground(fgcolor); |
580 | dsp->printf("]"); | |
581 | must_refresh |= 0x8000; | |
5 | 582 | } |
583 | ||
584 | if (table[i].fmt & 0x08 ) { | |
585 | // flags | |
2 | 586 | for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) { |
587 | for (uint8_t k=0; k<8; k++) { | |
8 | 588 | if (1) {//(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
|
589 | |
2 | 590 | if (txt[j] & (1 << k)) |
8 | 591 | dsp->foreground(fgcolor); |
2 | 592 | else |
8 | 593 | dsp->foreground(bgcolor); |
5 | 594 | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
595 | /* |
5 | 596 | for (uint8_t l=0; |
597 | l<(sizeof(frames)/sizeof(frames[0])); ++l) { | |
598 | if (frames[l].flag & ((j<<4) + k)) | |
8 | 599 | dsp->fillrect(frames[l].x0, frames[l].y0, |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
600 | frames[l].x1, frames[l].y1, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
601 | fgcolor/8); |
5 | 602 | else |
8 | 603 | dsp->fillrect(frames[l].x0, frames[l].y0, |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
604 | frames[l].x1, frames[l].y1, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
605 | bgcolor); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
606 | |
5 | 607 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
608 | */ |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
609 | |
2 | 610 | for (uint8_t l=0; |
611 | l<(sizeof(flags)/sizeof(flags[0])); ++l) { | |
612 | 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
|
613 | 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
|
614 | if (flags[l].zone == zones[m].flag) { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
615 | if (flags[l].msg != NULL) { // a string |
8 | 616 | dsp->locate(flags[l].x + zones[m].x0, |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
617 | flags[l].y + zones[m].y0); |
8 | 618 | dsp->printf(flags[l].msg);} |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
619 | else { // an icon |
8 | 620 | Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; |
621 | dsp->Bitmap_BW(pic, | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
622 | flags[l].x + zones[m].x0, |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
623 | flags[l].y + zones[m].y0); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
624 | } |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
625 | must_refresh |= zones[m].flag; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
626 | break; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
627 | } |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
628 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
629 | break; |
2 | 630 | } |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
631 | } |
2 | 632 | } |
633 | } | |
634 | } | |
635 | } | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
636 | |
5 | 637 | for(uint8_t j=0; j<table[i].maxsize; j++) |
638 | oldv[j] = txt[j]; | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
639 | break; |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
640 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
641 | } |
19 | 642 | free(txt); |
8 | 643 | //dsp->copy_to_lcd(); |
5 | 644 | pulse(1, false); |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
645 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
646 | |
3
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
647 | 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
|
648 | { |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
649 | 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
|
650 | 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
|
651 | show(0x0C, "888", 3); // channel dsp |
5 | 652 | show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags |
8 | 653 | dsp->copy_to_lcd(); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
654 | wait(3); |
8 | 655 | dsp->cls(); |
656 | ||
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
657 | |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
658 | 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
|
659 | { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
660 | z = &zones[i]; |
8 | 661 | dsp->fillrect(z->x0, z->y0, z->x1, z->y1, 4+i); |
662 | dsp->locate(z->x0+1, z->y0+1); | |
663 | dsp->printf("%d", i); | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
664 | } |
8 | 665 | |
666 | /* | |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
667 | 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
|
668 | { |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
669 | z = &zones[i]; |
8 | 670 | printf("Zone %d [%x]: %d, %d, %d, %d\n", i, z->flag, |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
671 | z->x0, z->y0, z->x1, z->y1); |
8 | 672 | must_refresh = z->flag; |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
673 | wait(1); |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
674 | } |
8 | 675 | printf("Done\n"); |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
676 | wait(2); |
8 | 677 | printf("Copy ALL\n"); |
678 | dsp->copy_to_lcd(); | |
679 | */ | |
680 | wait(2); | |
681 | 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
|
682 | } |
a3233abe730e
beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents:
2
diff
changeset
|
683 | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
684 | |
19 | 685 | void loop() |
686 | { // run over and over | |
8 | 687 | unsigned int err[8]; |
688 | for (uint8_t i=0; i<8; i++) | |
689 | err[i] = 0; | |
19 | 690 | int p, pp; |
691 | p=0; | |
692 | pp=0; | |
8 | 693 | while(1) { |
19 | 694 | if (knob != 0) |
695 | { | |
696 | if (hp != NULL) { | |
697 | printf("Sending keycode %X\n", knob); | |
698 | hp->sendkey(knob); | |
699 | printf(" DONE\n"); | |
700 | } | |
701 | knob = 0; | |
702 | } | |
703 | ||
704 | if (cur_keycode.keyevent != KEY_NONE) | |
705 | { | |
706 | printf("Keycode %dx%d: %s\n", | |
707 | cur_keycode.row, cur_keycode.col, | |
708 | cur_keycode.keyevent==KEY_PRESSED?"pressed":"released"); | |
709 | cur_keycode.keyevent = KEY_NONE; | |
710 | } | |
711 | ||
712 | p = qenc.getPulses(); | |
713 | if (p != pp) { | |
714 | printf("Pulses = %d\n", p); | |
715 | pp = p; | |
716 | } | |
717 | if ((hp != NULL) && (hp->cmd_available())) | |
718 | { | |
719 | led = 1; | |
720 | HPSerial::CMD cmd; | |
721 | if (hp->pop(cmd)) | |
722 | { | |
723 | for (uint8_t i=0; i<7; i++) | |
724 | if (hp->nerrors(i) > err[i]) { | |
725 | printf("ERR: %d/%d/%d/%d/%d/%d/%d\n", | |
726 | hp->nerrors(0), | |
727 | hp->nerrors(1), | |
728 | hp->nerrors(2), | |
729 | hp->nerrors(3), | |
730 | hp->nerrors(4), | |
731 | hp->nerrors(5), | |
732 | hp->nerrors(6) | |
733 | ); | |
734 | break; | |
735 | } | |
736 | for (uint8_t i=0; i<7; i++) | |
737 | err[i] = hp->nerrors(i); | |
738 | printf("CMD[%d] %02X", (int)cmd.id, cmd.cmd); | |
739 | ||
740 | if ((cmd.cmd == 0x00) || (cmd.cmd == 0x0C)) | |
741 | printf(": '%s'\n", cmd.value); | |
742 | else { | |
743 | printf(":"); | |
744 | for (uint8_t i=0; i<cmd.size; i++) | |
745 | printf("%02x ", cmd.value[i]); | |
746 | printf("\n"); | |
747 | } | |
748 | show(cmd.cmd, cmd.value, cmd.size); | |
749 | } | |
18
4fd621551d55
[full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents:
17
diff
changeset
|
750 | else |
4fd621551d55
[full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents:
17
diff
changeset
|
751 | printf("\n"); |
19 | 752 | |
18
4fd621551d55
[full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents:
17
diff
changeset
|
753 | show(cmd.cmd, cmd.value, cmd.size); |
19 | 754 | |
8 | 755 | led = 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
|
756 | } |
17
162fe523c37d
almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents:
13
diff
changeset
|
757 | else |
162fe523c37d
almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents:
13
diff
changeset
|
758 | Thread::wait(1); |
5 | 759 | } |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
760 | } |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
761 | |
19 | 762 | void qei_cb(int dir) |
763 | { | |
764 | if(dir == 1) // turn right | |
765 | knob = 0x80; | |
766 | else // turn left | |
767 | knob = 0x83; | |
768 | } | |
769 | ||
770 | void kp_cb(uint8_t row, uint8_t col) | |
771 | { | |
772 | cur_keycode.row = row; | |
773 | cur_keycode.col = col; | |
774 | cur_keycode.keyevent = KEY_PRESSED; | |
775 | } | |
776 | ||
777 | void kr_cb(uint8_t row, uint8_t col) | |
778 | { | |
779 | cur_keycode.row = row; | |
780 | cur_keycode.col = col; | |
781 | cur_keycode.keyevent = KEY_RELEASED; | |
782 | } | |
783 | ||
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
784 | int main() |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
785 | { |
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
786 | setup(); |
19 | 787 | printf("Main loop (noop)\n"); |
788 | while(1) | |
789 | wait(.1); | |
1
3021fc79cc3b
kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff
changeset
|
790 | } |