Thu, 12 Nov 2020 20:26:35 +0100
Reorganize the display + improvements for dimmed flags
- the whole upper zone is now dediacated to the main character line
- make sure eash flag has a dedicated non-overlaping area
- improve support for dimmed flags (not yet properly functionning since this
dimm state is actually stateful, so some major refactorings are needed to
properly handle this).
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 | char c; | |
46 | uint8_t len, i, j; | |
47 | // for which we need to look for the entry in the table | |
48 | for (i=0; i<sizeof(table)/sizeof(table[0]); ++i) { | |
49 | 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
|
50 | |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
51 | background(table[i].bgcolor); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
52 | 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
|
53 | 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
|
54 | 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
|
55 | |
44 | 56 | len = strlen(table[i].buffer); |
57 | if (n >= len) | |
58 | 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
|
59 | //::printf("DIMM CHAR %d\n", n); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
60 | //::printf(" in (len=%d) '%s'\n", len, table[i].buffer); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
61 | |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
62 | for (j=0; (j<len); j++) |
44 | 63 | { |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
64 | // 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
|
65 | 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
|
66 | 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
|
67 | // it's a "zero" width char, skip it |
44 | 68 | n++; |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
69 | if (n == 0) |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
70 | { |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
71 | //::printf(" Found at pos %d char '%c'\n", j, c); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
72 | // found it |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
73 | character(c); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
74 | break; |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
75 | } |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
76 | // 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
|
77 | //::printf(" move %d for '%c' [%X]\n", , c, c); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
78 | char_width(c, true); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
79 | n--; |
44 | 80 | } |
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 | { |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
106 | pixel_buffer_mutex.lock(); |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
107 | 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
|
108 | if (table[i].cmd == cmd) { |
44 | 109 | strcpy(txt, intxt); |
110 | txtp = txt; | |
111 | ||
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
112 | bgcolor = table[i].bgcolor; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
113 | fgcolor = table[i].color; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
114 | background(bgcolor); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
115 | foreground(fgcolor); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
116 | 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
|
117 | oldv = table[i].buffer; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
118 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
119 | 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
|
120 | |
44 | 121 | 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
|
122 | { |
44 | 123 | // 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
|
124 | 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
|
125 | { |
44 | 126 | // clear the text area |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
127 | if (table[i].width > 0) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
128 | fillrect(table[i].x0, |
44 | 129 | table[i].y0, |
130 | table[i].x0 + table[i].width, | |
131 | table[i].y0 + table[i].font[2] - 1, | |
132 | bgcolor); | |
133 | // 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
|
134 | 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
|
135 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
136 | if (txtp[k] == 0x00) |
44 | 137 | { // 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
|
138 | this->printf(txtp); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
139 | break; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
140 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
141 | if (txtp[k] == 0x09) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
142 | { // \t is a special char for 'unselected' display value |
44 | 143 | // 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
|
144 | txtp[k] = 0x00; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
145 | this->printf(txtp); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
146 | |
44 | 147 | // 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
|
148 | if (fgcolor == table[i].color) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
149 | fgcolor /= 2; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
150 | else |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
151 | fgcolor = table[i].color; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
152 | foreground(fgcolor); |
44 | 153 | // 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
|
154 | txtp = &(txtp[k+1]); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
155 | k = 0; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
156 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
157 | } |
44 | 158 | must_refresh = 1; |
37
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 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
161 | /* |
44 | 162 | 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
|
163 | // hex |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
164 | 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
|
165 | if (txt[j] == 0x00) |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
166 | break; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
167 | this->printf("%02X ", txt[j]); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
168 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
169 | 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
|
170 | this->printf(" "); |
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 | */ |
44 | 173 | 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
|
174 | { |
44 | 175 | uint8_t nbyte; |
176 | uint8_t nbit; | |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
177 | uint16_t color; |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
178 | // flags |
44 | 179 | 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
|
180 | { |
44 | 181 | nbyte = flags[l].flag / 8; |
182 | nbit = flags[l].flag % 8; | |
53
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
183 | if (flags[l].dimm) |
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
184 | color = fgcolor/4; |
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
185 | else |
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
186 | color = fgcolor; |
44 | 187 | |
188 | if (intxt[nbyte] & (1 << nbit)) | |
189 | { // draw the flag, possibly reversed fg/bg | |
53
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
190 | foreground(flags[l].reverse ? bgcolor : color); |
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
191 | background(flags[l].reverse ? color : bgcolor); |
44 | 192 | } |
193 | else | |
194 | { // erase the flag | |
195 | foreground(bgcolor); | |
196 | background(bgcolor); | |
197 | } | |
198 | if (flags[l].msg != NULL) | |
199 | { // flag is a string | |
200 | locate(flags[l].x, flags[l].y); | |
201 | this->printf(flags[l].msg);} | |
202 | else | |
203 | { // flag is an icon | |
204 | Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; | |
205 | 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
|
206 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
207 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
208 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
209 | // draw frames (Alarm and Channel) |
44 | 210 | 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
|
211 | { |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
212 | nbyte = frames[l].flag / 8; |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
213 | nbit = frames[l].flag % 8; |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
214 | if (intxt[nbyte] & (1 << nbit)) |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
215 | color = fgcolor/6; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
216 | else |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
217 | color = bgcolor; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
218 | 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
|
219 | 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
|
220 | 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
|
221 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
222 | 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
|
223 | 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
|
224 | } |
44 | 225 | 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
|
226 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
227 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
228 | 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
|
229 | oldv[j] = txt[j]; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
230 | break; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
231 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
232 | } |
46
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
233 | pixel_buffer_mutex.unlock(); |
a4a007b3c42e
Fix display of flags and improve dimm char handling
David Douard <david.douard@sdf3.org>
parents:
44
diff
changeset
|
234 | |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
235 | //free(txt); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
236 | //this->copy_to_lcd(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
237 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
238 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
239 | |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
240 | |
51
d8042bff0e00
Add support for dimmed flag display
David Douard <david.douard@sdf3.org>
parents:
46
diff
changeset
|
241 | void Display::set_flag(uint8_t flag, bool show, bool dimm) |
44 | 242 | { |
243 | uint8_t i; | |
53
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
244 | uint8_t bgcolor = 0x00, fgcolor = 0x0F; |
44 | 245 | |
51
d8042bff0e00
Add support for dimmed flag display
David Douard <david.douard@sdf3.org>
parents:
46
diff
changeset
|
246 | if (dimm) |
53
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
247 | fgcolor = fgcolor / 4; |
51
d8042bff0e00
Add support for dimmed flag display
David Douard <david.douard@sdf3.org>
parents:
46
diff
changeset
|
248 | |
44 | 249 | for (uint8_t l=0; l<(sizeof(flags)/sizeof(flags[0])); ++l) |
250 | { | |
251 | if (flag == flags[l].flag) | |
252 | { | |
53
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
253 | set_font((unsigned char*)Terminal6x8); |
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
254 | ::printf(" %s flag %x %s\n", show ? "show": "hide", flag, dimm ? "dimmed":"bright"); |
44 | 255 | if (show) |
256 | { | |
257 | foreground(flags[l].reverse ? bgcolor : fgcolor); | |
258 | background(flags[l].reverse ? fgcolor : bgcolor); | |
259 | } | |
260 | else | |
261 | { | |
262 | foreground(bgcolor); | |
263 | background(bgcolor); | |
264 | } | |
265 | if (flags[l].msg != NULL) | |
266 | { // flag is a string | |
267 | locate(flags[l].x, flags[l].y); | |
53
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
268 | ::printf("Move cursor at %dx%d\n", flags[l].x, flags[l].y); |
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
269 | ::printf(" using fgcolor=%x\n", fgcolor); |
44 | 270 | this->printf(flags[l].msg);} |
271 | else | |
272 | { // flag is an icon | |
273 | Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; | |
274 | Bitmap_BW(pic, flags[l].x, flags[l].y); | |
275 | } | |
276 | } | |
277 | } | |
278 | ||
279 | // draw frames (Alarm and Channel) | |
280 | for (uint8_t l=0; l<(sizeof(frames)/sizeof(frames[0])); ++l) | |
281 | { | |
282 | if (flag == frames[l].flag) | |
283 | { | |
284 | uint16_t color; | |
285 | if (show) | |
286 | color = fgcolor/6; | |
287 | else | |
288 | color = bgcolor; | |
289 | hline(frames[l].x0+1, frames[l].x0+3, frames[l].y0, color); | |
290 | hline(frames[l].x1-3, frames[l].x1-1, frames[l].y0, color); | |
291 | hline(frames[l].x0+1, frames[l].x1-1, frames[l].y1, color); | |
292 | ||
293 | vline(frames[l].x0, frames[l].y0+1, frames[l].y1-1, color); | |
294 | vline(frames[l].x1, frames[l].y0+1, frames[l].y1-1, color); | |
295 | } | |
296 | } | |
297 | must_refresh = 1; | |
298 | } | |
299 | ||
300 | ||
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
301 | void Display::test_dsp() |
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 | const FRAME *z; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
304 | printf("TEST DSP\r\n"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
305 | cls(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
306 | 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
|
307 | 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
|
308 | 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
|
309 | 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
|
310 | copy_to_lcd(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
311 | ThisThread::sleep_for(3ms); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
312 | cls(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
313 | printf("TEST DSP #3\r\n"); |
53
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
314 | /* |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
315 | 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
|
316 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
317 | z = &zones[i]; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
318 | 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
|
319 | 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
|
320 | this->printf("%d", i); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
321 | } |
53
74e85b34d26b
Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents:
51
diff
changeset
|
322 | */ |
37
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
323 | /* |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
324 | 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
|
325 | { |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
326 | z = &zones[i]; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
327 | 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
|
328 | 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
|
329 | must_refresh = z->flag; |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
330 | wait(1); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
331 | } |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
332 | printf("Done\n"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
333 | wait(2); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
334 | printf("Copy ALL\n"); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
335 | copy_to_lcd(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
336 | */ |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
337 | ThisThread::sleep_for(2ms); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
338 | cls(); |
07e8ca2bdf6d
Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff
changeset
|
339 | 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
|
340 | } |