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