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