src/main.cpp

Mon, 28 Jan 2019 21:51:45 +0100

author
David Douard <david.douard@logilab.fr>
date
Mon, 28 Jan 2019 21:51:45 +0100
changeset 24
b43536c064f6
parent 23
daf26b083899
child 26
86f099bda525
permissions
-rw-r--r--

Add the (missing?) Keypad lib

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

mercurial