src/main.cpp

Tue, 11 Oct 2016 21:47:10 +0200

author
David Douard <david.douard@logilab.fr>
date
Tue, 11 Oct 2016 21:47:10 +0200
changeset 14
5dfbcea0ebef
parent 13
0fdeed7c083e
child 17
162fe523c37d
permissions
-rw-r--r--

define HAVE_PC to have a serial (debug) console

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

mercurial