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