src/display.cpp

changeset 53
74e85b34d26b
parent 51
d8042bff0e00
child 54
f6774bd0d570
equal deleted inserted replaced
52:098124b730eb 53:74e85b34d26b
178 // flags 178 // flags
179 for (uint8_t l=0; l<(sizeof(flags)/sizeof(flags[0])); ++l) 179 for (uint8_t l=0; l<(sizeof(flags)/sizeof(flags[0])); ++l)
180 { 180 {
181 nbyte = flags[l].flag / 8; 181 nbyte = flags[l].flag / 8;
182 nbit = flags[l].flag % 8; 182 nbit = flags[l].flag % 8;
183 if (flags[l].dimm)
184 color = fgcolor/4;
185 else
186 color = fgcolor;
183 187
184 if (intxt[nbyte] & (1 << nbit)) 188 if (intxt[nbyte] & (1 << nbit))
185 { // draw the flag, possibly reversed fg/bg 189 { // draw the flag, possibly reversed fg/bg
186 foreground(flags[l].reverse ? bgcolor : fgcolor); 190 foreground(flags[l].reverse ? bgcolor : color);
187 background(flags[l].reverse ? fgcolor : bgcolor); 191 background(flags[l].reverse ? color : bgcolor);
188 } 192 }
189 else 193 else
190 { // erase the flag 194 { // erase the flag
191 foreground(bgcolor); 195 foreground(bgcolor);
192 background(bgcolor); 196 background(bgcolor);
235 239
236 240
237 void Display::set_flag(uint8_t flag, bool show, bool dimm) 241 void Display::set_flag(uint8_t flag, bool show, bool dimm)
238 { 242 {
239 uint8_t i; 243 uint8_t i;
240 uint8_t bgcolor = 0x00, fgcolor = 0xFF; 244 uint8_t bgcolor = 0x00, fgcolor = 0x0F;
241 245
242 if (dimm) 246 if (dimm)
243 fgcolor /= 2; 247 fgcolor = fgcolor / 4;
244 248
245 for (uint8_t l=0; l<(sizeof(flags)/sizeof(flags[0])); ++l) 249 for (uint8_t l=0; l<(sizeof(flags)/sizeof(flags[0])); ++l)
246 { 250 {
247 if (flag == flags[l].flag) 251 if (flag == flags[l].flag)
248 { 252 {
249 253 set_font((unsigned char*)Terminal6x8);
254 ::printf(" %s flag %x %s\n", show ? "show": "hide", flag, dimm ? "dimmed":"bright");
250 if (show) 255 if (show)
251 { 256 {
252 foreground(flags[l].reverse ? bgcolor : fgcolor); 257 foreground(flags[l].reverse ? bgcolor : fgcolor);
253 background(flags[l].reverse ? fgcolor : bgcolor); 258 background(flags[l].reverse ? fgcolor : bgcolor);
254 } 259 }
258 background(bgcolor); 263 background(bgcolor);
259 } 264 }
260 if (flags[l].msg != NULL) 265 if (flags[l].msg != NULL)
261 { // flag is a string 266 { // flag is a string
262 locate(flags[l].x, flags[l].y); 267 locate(flags[l].x, flags[l].y);
263 set_font((unsigned char*)Terminal6x8); 268 ::printf("Move cursor at %dx%d\n", flags[l].x, flags[l].y);
269 ::printf(" using fgcolor=%x\n", fgcolor);
264 this->printf(flags[l].msg);} 270 this->printf(flags[l].msg);}
265 else 271 else
266 { // flag is an icon 272 { // flag is an icon
267 Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; 273 Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon};
268 Bitmap_BW(pic, flags[l].x, flags[l].y); 274 Bitmap_BW(pic, flags[l].x, flags[l].y);
303 show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags 309 show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags
304 copy_to_lcd(); 310 copy_to_lcd();
305 ThisThread::sleep_for(3ms); 311 ThisThread::sleep_for(3ms);
306 cls(); 312 cls();
307 printf("TEST DSP #3\r\n"); 313 printf("TEST DSP #3\r\n");
308 314 /*
309 for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++) 315 for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++)
310 { 316 {
311 z = &zones[i]; 317 z = &zones[i];
312 fillrect(z->x0, z->y0, z->x1, z->y1, 4+i); 318 fillrect(z->x0, z->y0, z->x1, z->y1, 4+i);
313 locate(z->x0+1, z->y0+1); 319 locate(z->x0+1, z->y0+1);
314 this->printf("%d", i); 320 this->printf("%d", i);
315 } 321 }
316 322 */
317 /* 323 /*
318 for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++) 324 for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++)
319 { 325 {
320 z = &zones[i]; 326 z = &zones[i];
321 printf("Zone %d [%x]: %d, %d, %d, %d\n", i, z->flag, 327 printf("Zone %d [%x]: %d, %d, %d, %d\n", i, z->flag,

mercurial