Mon, 11 Mar 2024 15:35:36 +0100
Add links to sr.ht repos and add an image in the README file
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 | |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
7 | static DSP table[] = |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
8 | { // cmd, fg, bg, x0, y0, fmt, maxsize, width, font |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
9 | { 0x00, 0xF, 0x0, 0, 0, FMT_ASCII, MAX_BUFF, 255, Mono19x27}, // main display |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
10 | { 0x0C, 0xF, 0x0,194, 38, FMT_ASCII, 3, 45, Mono15x22}, // channels display |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
11 | { 0x0A, 0xF, 0x0, 0, 57, FMT_FLAGS, 4, 0, Terminal6x8}, // flags + bits |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
12 | }; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
13 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
14 | // 9x10 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
15 | const unsigned char icon_alarm[] __attribute__((aligned (2))) = |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
16 | { |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
17 | 0x1c, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
18 | 0x3e, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
19 | 0x7f, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
20 | 0x7f, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
21 | 0x7f, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
22 | 0x7f, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
23 | 0x7f, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
24 | 0x7f, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
25 | 0xff, 0x80, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
26 | 0x10, 0x0 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
27 | }; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
28 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
29 | const unsigned char icon_curve[] __attribute__((aligned (2))) = |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
30 | { |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
31 | 0x80, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
32 | 0x80, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
33 | 0x80, 0x80, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
34 | 0x81, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
35 | 0x9e, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
36 | 0xa0, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
37 | 0xc0, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
38 | 0x80, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
39 | 0x80, 0x0, |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
40 | 0xff, 0x80 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
41 | }; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
42 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
43 | static const flags_map flags = { |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
44 | // id x0 y0 rev. msg icon |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
45 | { 0x00, {246, 27, 0, 0, false, NULL, icon_alarm}}, // F1.0 01 00 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
46 | { 0x01, {246, 38, 0, 0, false, NULL, icon_curve}}, // F1.1 02 00 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
47 | { 0x02, {192, 32, 240, 60, false, NULL, NULL}}, // F1.2 04 00 00 00 - Channel frame |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
48 | { 0x03, {195, 29, 0, 0, false, "CHANNEL", NULL}}, // F1.3 08 00 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
49 | { 0x1c, {0, 38, 0, 0, false, "MON", NULL}}, // F4.4 00 00 00 10 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
50 | { 0x1b, {0, 47, 0, 0, false, "VIEW", NULL}}, // F4.3 00 00 00 08 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
51 | { 0x1d, {0, 29, 0, 0, true, "SCAN", NULL}}, // F4.5 00 00 00 20 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
52 | { 0x1e, {0, 56, 0, 0, true, "CONFIG", NULL}}, // F4.6 00 00 00 40 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
53 | { 0x1a, {40, 56, 0, 0, false, "*", NULL}}, // F4.2 00 00 00 04 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
54 | { 0x19, {50, 56, 0, 0, false, "ADRS", NULL}}, // F4.1 00 00 00 02 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
55 | { 0x18, {80, 56, 0, 0, false, "RMT", NULL}}, // F4.0 00 00 00 01 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
56 | { 0x17, {104, 56, 0, 0, true, "ERROR", NULL}}, // F3.7 00 00 80 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
57 | { 0x16, {86, 38, 0, 0, false, "EXT", NULL}}, // F3.6 00 00 40 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
58 | { 0x15, {60, 38, 0, 0, false, "ONCE", NULL}}, // F3.5 00 00 20 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
59 | { 0x13, {40, 38, 0, 0, false, "MEM", NULL}}, // F3.3 00 00 08 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
60 | { 0x0c, {244, 47, 0, 0, false, "4W", NULL}}, // F2.4 00 10 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
61 | { 0x0d, {244, 56, 0, 0, false, "OC", NULL}}, // F2.5 00 20 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
62 | { 0x12, {40, 47, 0, 0, false, "LAST", NULL}}, // F3.2 00 00 04 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
63 | { 0x11, {66, 47, 0, 0, false, "MIN", NULL}}, // F3.1 00 00 02 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
64 | { 0x10, {86, 47, 0, 0, false, "MAX", NULL}}, // F3.0 00 00 01 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
65 | { 0x0f, {106, 47, 0, 0, false, "AVG", NULL}}, // F2.7 00 80 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
66 | { 0x05, {152, 29, 0, 0, false, "Alarm", NULL}}, // F1.5 20 00 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
67 | { 0x08, {152, 39, 0, 0, false, "H", NULL}}, // F1.6 40 00 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
68 | { 0x07, {158, 39, 0, 0, false, "1", NULL}}, // F2.3 00 08 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
69 | { 0x06, {164, 39, 0, 0, false, "2", NULL}}, // F2.0 00 01 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
70 | { 0x04, {170, 39, 0, 0, false, "3", NULL}}, // F2.2 00 04 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
71 | { 0x09, {176, 39, 0, 0, false, "4", NULL}}, // F2.1 00 02 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
72 | { 0x0a, {182, 39, 0, 0, false, "L", NULL}}, // F1.4 00 10 00 00 |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
73 | { 0x0b, {149, 32, 190, 50, false, NULL, NULL}}, // F1.7 - alarm frame |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
74 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
75 | { 0x0e, {152, 56, 0, 0, true, "SHIFT", NULL}}, // not an actual command, managed by the front panel |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
76 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
77 | { 0x14, {0xFF, 0xFF, 0xFF, 0xFF, false, NULL, NULL}}, // not an actual command, for the sake of completeness |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
78 | { 0x1f, {0xFF, 0xFF, 0xFF, 0xFF, false, NULL, NULL}}, // not an actual command, for the sake of completeness |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
79 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
80 | }; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
81 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
82 | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
83 | 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
|
84 | const char* name) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
85 | : 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
|
86 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
87 | must_refresh = 0; |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
88 | for (flags_map::const_iterator it=flags.cbegin(); it!=flags.cend(); ++it) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
89 | { |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
90 | flags_status[it->first] = false; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
91 | flags_dim[it->first] = false; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
92 | } |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
93 | } |
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 | Display::~Display() |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
96 | { |
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 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
99 | void Display::show_splashscreen() |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
100 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
101 | locate(30, 10); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
102 | set_font((unsigned char*)Mono19x27); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
103 | this->printf("HP34970A"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
104 | set_font((unsigned char*)Terminal6x8); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
105 | locate(90, 40); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
106 | this->printf("David Douard"); |
44 | 107 | copy_to_lcd(); |
108 | } | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
109 | |
44 | 110 | void Display::show_byescreen() |
111 | { | |
112 | cls(); | |
113 | background(0x00); | |
114 | foreground(0xFF); | |
115 | locate(30, 10); | |
116 | set_font((unsigned char*)Mono19x27); | |
117 | this->printf("Bye..."); | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
118 | copy_to_lcd(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
119 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
120 | |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
121 | void Display::dim_char(uint8_t n) |
44 | 122 | { |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
123 | // dim the char number of the currently displayed string of the main area; |
44 | 124 | // do this by printing a modifed version of the last displayed string |
125 | // but only alphanumeric chars should be counted (not the punctuation) | |
126 | char c; | |
127 | uint8_t len, i, j; | |
128 | // for which we need to look for the entry in the table | |
129 | for (i=0; i<sizeof(table)/sizeof(table[0]); ++i) { | |
130 | if (table[i].cmd == 0x00) { | |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
131 | |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
132 | background(table[i].bgcolor); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
133 | foreground(table[i].color / 2); // dimmed |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
134 | set_font((unsigned char*) table[i].font); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
135 | locate(table[i].x0, table[i].y0); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
136 | |
44 | 137 | len = strlen(table[i].buffer); |
138 | if (n >= len) | |
139 | break; // nothing to do | |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
140 | |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
141 | for (j=0; (j<len); j++) |
44 | 142 | { |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
143 | // advae the location up to the char to dimm |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
144 | c = table[i].buffer[j]; |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
145 | if ((c == ',') || (c == '.') || (c == ';') || (c == ':')) |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
146 | // it's a "zero" width char, skip it |
44 | 147 | n++; |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
148 | if (n == 0) |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
149 | { |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
150 | // found it |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
151 | character(c); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
152 | break; |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
153 | } |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
154 | // otherwise, just advance the char_x |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
155 | char_width(c, true); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
156 | n--; |
44 | 157 | } |
158 | } | |
159 | } | |
160 | } | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
161 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
162 | 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
|
163 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
164 | uint8_t i; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
165 | // uint8_t len; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
166 | uint16_t bgcolor, fgcolor; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
167 | char *oldv; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
168 | // char *txt; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
169 | char *txtp; |
44 | 170 | static char txt[64]; |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
171 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
172 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
173 | if (cmd == 0xFF) // cls |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
174 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
175 | clrbuff(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
176 | } |
44 | 177 | else if (cmd == 0x0D) |
178 | { // dimm a character of the main area | |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
179 | dim_char(intxt[0]); |
44 | 180 | } |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
181 | else |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
182 | { |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
183 | pixel_buffer_mutex.lock(); |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
184 | 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
|
185 | if (table[i].cmd == cmd) { |
44 | 186 | strcpy(txt, intxt); |
187 | txtp = txt; | |
188 | ||
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
189 | bgcolor = table[i].bgcolor; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
190 | fgcolor = table[i].color; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
191 | background(bgcolor); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
192 | foreground(fgcolor); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
193 | 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
|
194 | oldv = table[i].buffer; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
195 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
196 | 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
|
197 | |
44 | 198 | 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
|
199 | { |
44 | 200 | // check if the string has changed since last time |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
201 | if (true) //(strncmp(oldv, txt, table[i].maxsize) != 0) |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
202 | { |
44 | 203 | // clear the text area |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
204 | if (table[i].width > 0) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
205 | fillrect(table[i].x0, |
44 | 206 | table[i].y0, |
207 | table[i].x0 + table[i].width, | |
208 | table[i].y0 + table[i].font[2] - 1, | |
209 | bgcolor); | |
210 | // 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
|
211 | 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
|
212 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
213 | if (txtp[k] == 0x00) |
44 | 214 | { // 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
|
215 | this->printf(txtp); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
216 | break; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
217 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
218 | if (txtp[k] == 0x09) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
219 | { // \t is a special char for 'unselected' display value |
44 | 220 | // 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
|
221 | txtp[k] = 0x00; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
222 | this->printf(txtp); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
223 | |
44 | 224 | // 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
|
225 | if (fgcolor == table[i].color) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
226 | fgcolor /= 2; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
227 | else |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
228 | fgcolor = table[i].color; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
229 | foreground(fgcolor); |
44 | 230 | // 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
|
231 | txtp = &(txtp[k+1]); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
232 | k = 0; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
233 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
234 | } |
44 | 235 | must_refresh = 1; |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
236 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
237 | } |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
238 | |
44 | 239 | 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
|
240 | { |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
241 | uint8_t id; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
242 | uint8_t c; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
243 | id = 0; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
244 | for (uint8_t nc=0; nc<4; nc++) |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
245 | { |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
246 | c = intxt[nc]; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
247 | for (uint8_t nb=0; nb<8; nb++) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
248 | { |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
249 | if (c & (0x01 << nb)) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
250 | set_flag_status(id, true); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
251 | else |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
252 | set_flag_status(id, false); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
253 | draw_flag(id); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
254 | id++; |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
255 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
256 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
257 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
258 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
259 | 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
|
260 | oldv[j] = txt[j]; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
261 | break; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
262 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
263 | } |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
264 | pixel_buffer_mutex.unlock(); |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
265 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
266 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
267 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
268 | |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
269 | void Display::set_flag_status(uint8_t flagid, bool show) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
270 | { |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
271 | flags_status[flagid] = show; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
272 | } |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
273 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
274 | void Display::set_flag_dim(uint8_t flagid, bool dim) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
275 | { |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
276 | flags_dim[flagid] = dim; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
277 | } |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
278 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
279 | void Display::draw_flag(uint8_t flagid) |
44 | 280 | { |
53
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
281 | uint8_t bgcolor = 0x00, fgcolor = 0x0F; |
44 | 282 | |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
283 | ::printf(" FLAG %X:", flagid); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
284 | const FLAG flag = flags.at(flagid); // can't use the [] operator on a const map... |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
285 | if (flag.msg != NULL) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
286 | ::printf("%s ", flag.msg); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
287 | else if (flag.icon != NULL) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
288 | ::printf("ICN "); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
289 | else if (flag.x0 > 0) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
290 | ::printf("FR[%dx%d] ", flag.x0, flag.y0); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
291 | else |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
292 | ::printf(" WTF? "); |
51
d8042bff0e00
Add support for dimmed flag display
David Douard <david.douard@sdf3.org>
parents:
46
diff
changeset
|
293 | |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
294 | if (flags_status[flagid]) |
44 | 295 | { |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
296 | if (flags_dim[flagid]) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
297 | ::printf(" DIM\n"); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
298 | else |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
299 | ::printf(" ON\n"); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
300 | } |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
301 | else |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
302 | ::printf(" OFF\n"); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
303 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
304 | if ((flag.msg == NULL) && (flag.icon == NULL) && (flag.x0 == 0xFF) && (flag.y0 == 0xFF)) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
305 | // noop command |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
306 | return; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
307 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
308 | if (flags_dim[flagid]) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
309 | fgcolor = fgcolor / 4; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
310 | else if ((flag.msg == NULL) && (flag.icon == NULL)) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
311 | fgcolor = fgcolor / 6; // it's a frame |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
312 | |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
313 | if (flags_status[flagid]) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
314 | { |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
315 | foreground(flag.reverse ? bgcolor : fgcolor); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
316 | background(flag.reverse ? fgcolor : bgcolor); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
317 | } |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
318 | else |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
319 | { |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
320 | foreground(bgcolor); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
321 | background(bgcolor); |
44 | 322 | } |
323 | ||
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
324 | if (flag.msg != NULL) |
44 | 325 | { |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
326 | set_font((unsigned char*)Terminal6x8); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
327 | locate(flag.x0, flag.y0); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
328 | this->printf(flag.msg); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
329 | } |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
330 | else if (flag.icon != NULL) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
331 | { // flag is an icon |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
332 | Bitmap_s pic = {9, 10, 2, (char*) flag.icon}; |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
333 | Bitmap_BW(pic, flag.x0, flag.y0); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
334 | } |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
335 | else |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
336 | { // draw frames (Alarm and Channel) |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
337 | hline(flag.x0+1, flag.x0+3, flag.y0, foreground()); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
338 | hline(flag.x1-3, flag.x1-1, flag.y0, foreground()); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
339 | hline(flag.x0+1, flag.x1-1, flag.y1, foreground()); |
44 | 340 | |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
341 | vline(flag.x0, flag.y0+1, flag.y1-1, foreground()); |
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
342 | vline(flag.x1, flag.y0+1, flag.y1-1, foreground()); |
44 | 343 | } |
54
f6774bd0d570
Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents:
53
diff
changeset
|
344 | |
44 | 345 | must_refresh = 1; |
346 | } |