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