src/main.cpp

Tue, 11 Oct 2016 21:44:56 +0200

author
David Douard <david.douard@logilab.fr>
date
Tue, 11 Oct 2016 21:44:56 +0200
changeset 11
09ae4cac6649
parent 10
01515349b30e
child 12
38cd6267c919
permissions
-rw-r--r--

HP_TX is now useless

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

mercurial