Sun, 01 Nov 2020 22:21:19 +0100
Many improvements
- add support for dimm-based selection,
- add support for poweroff (at least power thr display off),
- add support for the initial key pressed during initialization sequence,
- fix a race condition (sending a keycode while receiving a message)
- add support for the shift button
- many code cleanups and improvements
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
1 | #include "stdio.h" |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
2 | #include <mbed.h> |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
3 | #include <rtos.h> |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
4 | #include "display.h" |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
5 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
6 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
7 | Display::Display(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
8 | const char* name) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
9 | : SSD1322(Hz, mosi, miso, sclk, CS, reset, DC, name) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
10 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
11 | must_refresh = 0; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
12 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
13 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
14 | Display::~Display() |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
15 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
16 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
17 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
18 | void Display::show_splashscreen() |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
19 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
20 | locate(30, 10); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
21 | set_font((unsigned char*)Mono19x27); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
22 | this->printf("HP34970A"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
23 | set_font((unsigned char*)Terminal6x8); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
24 | locate(90, 40); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
25 | this->printf("David Douard"); |
44 | 26 | copy_to_lcd(); |
27 | } | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
28 | |
44 | 29 | void Display::show_byescreen() |
30 | { | |
31 | cls(); | |
32 | background(0x00); | |
33 | foreground(0xFF); | |
34 | locate(30, 10); | |
35 | set_font((unsigned char*)Mono19x27); | |
36 | this->printf("Bye..."); | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
37 | copy_to_lcd(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
38 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
39 | |
44 | 40 | void Display::dimm_char(uint8_t n) |
41 | { | |
42 | // dimm the char number of the currently displayed string of the main area; | |
43 | // do this by printing a modifed version of the last displayed string | |
44 | // but only alphanumeric chars should be counted (not the punctuation) | |
45 | static char txt[64]; | |
46 | char c; | |
47 | uint8_t len, i, j; | |
48 | // for which we need to look for the entry in the table | |
49 | for (i=0; i<sizeof(table)/sizeof(table[0]); ++i) { | |
50 | if (table[i].cmd == 0x00) { | |
51 | ::printf("DIMM CHAR %d\n", n); | |
52 | ::printf("repl '%s'\n", table[i].buffer); | |
53 | len = strlen(table[i].buffer); | |
54 | if (n >= len) | |
55 | break; // nothing to do | |
56 | strncpy(txt, table[i].buffer, table[i].maxsize); | |
57 | // look for the actual position of the char in the string (only alphanum) | |
58 | // XXX very poor implementation... | |
59 | for (j=0; (j<len)&&(j<=n); j++) | |
60 | { | |
61 | c = txt[j]; | |
62 | if ((c == ',') || (c == '.') || (c == ';') || (c == ':') || (c == ' ')) | |
63 | n++; | |
64 | } | |
65 | // now move the end of the string for char n to steps on the right | |
66 | // so we can insert our 2 '\t' characters before and after the | |
67 | // character to dimm | |
68 | for (j=len; j>n; j--) | |
69 | { | |
70 | txt[j+2] = txt[j]; | |
71 | } | |
72 | txt[n+2] = '\t'; | |
73 | txt[n+1] = txt[n]; | |
74 | txt[n] = '\t'; | |
75 | txt[len+2] = 0x00; // make sure the string will be terminated | |
76 | ||
77 | ::printf("with '%s'\n", txt); | |
78 | // now display this string | |
79 | show(0x00, txt, 0); | |
80 | break; | |
81 | } | |
82 | } | |
83 | } | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
84 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
85 | void Display::show(uint8_t cmd, const char *intxt, uint8_t nchar=0) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
86 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
87 | uint8_t i; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
88 | // uint8_t len; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
89 | uint16_t bgcolor, fgcolor; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
90 | char *oldv; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
91 | // char *txt; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
92 | char *txtp; |
44 | 93 | static char txt[64]; |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
94 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
95 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
96 | if (cmd == 0xFF) // cls |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
97 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
98 | clrbuff(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
99 | } |
44 | 100 | else if (cmd == 0x0D) |
101 | { // dimm a character of the main area | |
102 | dimm_char(intxt[0]); | |
103 | } | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
104 | else |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
105 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
106 | for (i=0; i<sizeof(table)/sizeof(table[0]); ++i) { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
107 | if (table[i].cmd == cmd) { |
44 | 108 | strcpy(txt, intxt); |
109 | txtp = txt; | |
110 | ||
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
111 | bgcolor = table[i].bgcolor; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
112 | fgcolor = table[i].color; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
113 | background(bgcolor); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
114 | foreground(fgcolor); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
115 | set_font((unsigned char*) table[i].font); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
116 | oldv = table[i].buffer; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
117 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
118 | locate(table[i].x0, table[i].y0); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
119 | |
44 | 120 | if (table[i].fmt & FMT_ASCII) // ASCII text |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
121 | { |
44 | 122 | // check if the string has changed since last time |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
123 | if (strncmp(oldv, txt, table[i].maxsize) != 0) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
124 | { |
44 | 125 | // clear the text area |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
126 | if (table[i].width > 0) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
127 | fillrect(table[i].x0, |
44 | 128 | table[i].y0, |
129 | table[i].x0 + table[i].width, | |
130 | table[i].y0 + table[i].font[2] - 1, | |
131 | bgcolor); | |
132 | // draw chars by portions of string separated by \t (highlight) | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
133 | for (uint8_t k=0; ;k++) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
134 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
135 | if (txtp[k] == 0x00) |
44 | 136 | { // end of string, display it |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
137 | this->printf(txtp); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
138 | break; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
139 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
140 | if (txtp[k] == 0x09) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
141 | { // \t is a special char for 'unselected' display value |
44 | 142 | // first disply the beginning of the string |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
143 | txtp[k] = 0x00; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
144 | this->printf(txtp); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
145 | |
44 | 146 | // swap the fg color (dimm/bright) |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
147 | if (fgcolor == table[i].color) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
148 | fgcolor /= 2; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
149 | else |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
150 | fgcolor = table[i].color; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
151 | foreground(fgcolor); |
44 | 152 | // continue on the next with part of the string |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
153 | txtp = &(txtp[k+1]); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
154 | k = 0; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
155 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
156 | } |
44 | 157 | must_refresh = 1; |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
158 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
159 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
160 | /* |
44 | 161 | if (table[i].fmt & FMT_HEX ) { |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
162 | // hex |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
163 | for (uint8_t j=0;; j++) { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
164 | if (txt[j] == 0x00) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
165 | break; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
166 | this->printf("%02X ", txt[j]); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
167 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
168 | for (uint8_t j=3*strlen(txt); j<table[i].maxsize; j++) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
169 | this->printf(" "); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
170 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
171 | */ |
44 | 172 | if (table[i].fmt & FMT_FLAGS ) // flag indicators |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
173 | { |
44 | 174 | uint8_t nbyte; |
175 | uint8_t nbit; | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
176 | // flags |
44 | 177 | for (uint8_t l=0; l<(sizeof(flags)/sizeof(flags[0])); ++l) |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
178 | { |
44 | 179 | nbyte = flags[l].flag / 8; |
180 | nbit = flags[l].flag % 8; | |
181 | ||
182 | if (intxt[nbyte] & (1 << nbit)) | |
183 | { // draw the flag, possibly reversed fg/bg | |
184 | foreground(flags[l].reverse ? bgcolor : fgcolor); | |
185 | background(flags[l].reverse ? fgcolor : bgcolor); | |
186 | } | |
187 | else | |
188 | { // erase the flag | |
189 | foreground(bgcolor); | |
190 | background(bgcolor); | |
191 | } | |
192 | if (flags[l].msg != NULL) | |
193 | { // flag is a string | |
194 | locate(flags[l].x, flags[l].y); | |
195 | this->printf(flags[l].msg);} | |
196 | else | |
197 | { // flag is an icon | |
198 | Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; | |
199 | Bitmap_BW(pic, flags[l].x, flags[l].y); | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
200 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
201 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
202 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
203 | // draw frames (Alarm and Channel) |
44 | 204 | for (uint8_t l=0; l<(sizeof(frames)/sizeof(frames[0])); ++l) |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
205 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
206 | uint16_t color; |
44 | 207 | if (intxt[0] & (1 << frames[l].flag)) // frame flags are on the 1st byte only |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
208 | color = fgcolor/6; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
209 | else |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
210 | color = bgcolor; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
211 | hline(frames[l].x0+1, frames[l].x0+3, frames[l].y0, color); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
212 | hline(frames[l].x1-3, frames[l].x1-1, frames[l].y0, color); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
213 | hline(frames[l].x0+1, frames[l].x1-1, frames[l].y1, color); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
214 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
215 | vline(frames[l].x0, frames[l].y0+1, frames[l].y1-1, color); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
216 | vline(frames[l].x1, frames[l].y0+1, frames[l].y1-1, color); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
217 | } |
44 | 218 | must_refresh = 1; //|= zones[m].flag; |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
219 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
220 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
221 | for(uint8_t j=0; j<table[i].maxsize; j++) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
222 | oldv[j] = txt[j]; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
223 | break; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
224 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
225 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
226 | //free(txt); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
227 | //this->copy_to_lcd(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
228 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
229 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
230 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
231 | |
44 | 232 | void Display::set_flag(uint8_t flag, bool show=true) |
233 | { | |
234 | uint8_t i; | |
235 | uint8_t bgcolor = 0x00, fgcolor = 0xFF; | |
236 | ||
237 | for (uint8_t l=0; l<(sizeof(flags)/sizeof(flags[0])); ++l) | |
238 | { | |
239 | if (flag == flags[l].flag) | |
240 | { | |
241 | ||
242 | if (show) | |
243 | { | |
244 | foreground(flags[l].reverse ? bgcolor : fgcolor); | |
245 | background(flags[l].reverse ? fgcolor : bgcolor); | |
246 | } | |
247 | else | |
248 | { | |
249 | foreground(bgcolor); | |
250 | background(bgcolor); | |
251 | } | |
252 | if (flags[l].msg != NULL) | |
253 | { // flag is a string | |
254 | locate(flags[l].x, flags[l].y); | |
255 | set_font((unsigned char*)Terminal6x8); | |
256 | this->printf(flags[l].msg);} | |
257 | else | |
258 | { // flag is an icon | |
259 | Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; | |
260 | Bitmap_BW(pic, flags[l].x, flags[l].y); | |
261 | } | |
262 | } | |
263 | } | |
264 | ||
265 | // draw frames (Alarm and Channel) | |
266 | for (uint8_t l=0; l<(sizeof(frames)/sizeof(frames[0])); ++l) | |
267 | { | |
268 | if (flag == frames[l].flag) | |
269 | { | |
270 | uint16_t color; | |
271 | if (show) | |
272 | color = fgcolor/6; | |
273 | else | |
274 | color = bgcolor; | |
275 | hline(frames[l].x0+1, frames[l].x0+3, frames[l].y0, color); | |
276 | hline(frames[l].x1-3, frames[l].x1-1, frames[l].y0, color); | |
277 | hline(frames[l].x0+1, frames[l].x1-1, frames[l].y1, color); | |
278 | ||
279 | vline(frames[l].x0, frames[l].y0+1, frames[l].y1-1, color); | |
280 | vline(frames[l].x1, frames[l].y0+1, frames[l].y1-1, color); | |
281 | } | |
282 | } | |
283 | must_refresh = 1; | |
284 | } | |
285 | ||
286 | ||
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
287 | void Display::test_dsp() |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
288 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
289 | const FRAME *z; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
290 | printf("TEST DSP\r\n"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
291 | cls(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
292 | printf("TEST DSP #2\r\n"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
293 | show(0x00, "8g8g8g8g8g8g8", 13); // main dsp |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
294 | show(0x0C, "888", 3); // channel dsp |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
295 | show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
296 | copy_to_lcd(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
297 | ThisThread::sleep_for(3ms); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
298 | cls(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
299 | printf("TEST DSP #3\r\n"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
300 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
301 | for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
302 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
303 | z = &zones[i]; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
304 | fillrect(z->x0, z->y0, z->x1, z->y1, 4+i); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
305 | locate(z->x0+1, z->y0+1); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
306 | this->printf("%d", i); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
307 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
308 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
309 | /* |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
310 | for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
311 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
312 | z = &zones[i]; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
313 | printf("Zone %d [%x]: %d, %d, %d, %d\n", i, z->flag, |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
314 | z->x0, z->y0, z->x1, z->y1); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
315 | must_refresh = z->flag; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
316 | wait(1); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
317 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
318 | printf("Done\n"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
319 | wait(2); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
320 | printf("Copy ALL\n"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
321 | copy_to_lcd(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
322 | */ |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
323 | ThisThread::sleep_for(2ms); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
324 | cls(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
325 | printf("TEST DSP DONE\r\n"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
326 | } |