src/display.h

changeset 54
f6774bd0d570
parent 53
74e85b34d26b
equal deleted inserted replaced
53:74e85b34d26b 54:f6774bd0d570
5 #include "Mono19x27.h" 5 #include "Mono19x27.h"
6 #include "Mono15x22.h" 6 #include "Mono15x22.h"
7 #include "Arial12x12.h" 7 #include "Arial12x12.h"
8 #include "SSD1322.h" 8 #include "SSD1322.h"
9 #include "hp34comm.h" 9 #include "hp34comm.h"
10
11 #include <map>
10 12
11 //typedef enum { 13 //typedef enum {
12 #define FMT_ASCII 0x01 14 #define FMT_ASCII 0x01
13 #define FMT_HEX 0x02 15 #define FMT_HEX 0x02
14 #define FMT_BITS 0x04 16 #define FMT_BITS 0x04
30 const unsigned char* font; 32 const unsigned char* font;
31 char buffer[MAX_BUFF+1]; 33 char buffer[MAX_BUFF+1];
32 } DSP; 34 } DSP;
33 35
34 36
35 static DSP table[] =
36 { // cmd, fg, bg, x0, y0, fmt, maxsize, width, font
37 { 0x00, 0xF, 0x0, 0, 0, FMT_ASCII, MAX_BUFF, 255, Mono19x27}, // main display
38 { 0x0C, 0xF, 0x0,194, 38, FMT_ASCII, 3, 45, Mono15x22}, // channels display
39 { 0x0A, 0xF, 0x0, 0, 57, FMT_FLAGS, 4, 0, Terminal6x8}, // flags + bits
40 };
41
42 // 9x10
43 const unsigned char icon_alarm[] __attribute__((aligned (2))) =
44 {
45 0x1c, 0x0,
46 0x3e, 0x0,
47 0x7f, 0x0,
48 0x7f, 0x0,
49 0x7f, 0x0,
50 0x7f, 0x0,
51 0x7f, 0x0,
52 0x7f, 0x0,
53 0xff, 0x80,
54 0x10, 0x0
55 };
56
57 const unsigned char icon_curve[] __attribute__((aligned (2))) =
58 {
59 0x80, 0x0,
60 0x80, 0x0,
61 0x80, 0x80,
62 0x81, 0x0,
63 0x9e, 0x0,
64 0xa0, 0x0,
65 0xc0, 0x0,
66 0x80, 0x0,
67 0x80, 0x0,
68 0xff, 0x80
69 };
70
71 typedef struct _FLAG 37 typedef struct _FLAG
72 { 38 {
73 uint8_t flag; 39 uint8_t x0;
74 uint8_t x; 40 uint8_t y0;
75 uint8_t y; 41 uint8_t x1;
42 uint8_t y1;
76 bool reverse; 43 bool reverse;
77 bool dimm;
78 const char* msg; 44 const char* msg;
79 const unsigned char* icon; 45 const unsigned char* icon;
80 } FLAG; 46 } FLAG;
81 47
82 typedef struct _FRAME 48 typedef std::map<uint8_t, FLAG> flags_map;
83 { 49 typedef std::map<uint8_t, bool> flag_status_map;
84 uint8_t flag;
85 uint8_t x0;
86 uint8_t y0;
87 uint8_t x1;
88 uint8_t y1;
89 } FRAME;
90
91
92
93 static const FLAG flags[] =
94 {
95 // flag, x0, y0, reverse, dimm, msg, icon
96 // right-side icons area
97 // flag is the bit index in the 4 bytes viewed as a 32bits value
98 { 0x00, 246, 27, false, false, NULL, icon_alarm}, // F1.0 01 00 00 00
99 { 0x01, 246, 38, false, false, NULL, icon_curve}, // F1.1 02 00 00 00
100 // F1.2 04 00 00 00 - Channel frame
101 { 0x03, 195, 29, false, false, "CHANNEL"}, // F1.3 08 00 00 00
102 // F1.7 80 00 00 00 - Alarm frame
103 { 0x1c, 0, 38, false, false, "MON"}, // F4.4 00 00 00 10
104 { 0x1b, 0, 47, false, false, "VIEW"}, // F4.3 00 00 00 08
105 { 0x1d, 0, 29, true, false, "SCAN"}, // F4.5 00 00 00 20
106 { 0x1e, 0, 56, true, false, "CONFIG"}, // F4.6 00 00 00 40
107
108 { 0x1a, 40, 56, false, false, "*"}, // F4.2 00 00 00 04
109 { 0x19, 50, 56, false, false, "ADRS"}, // F4.1 00 00 00 02
110 { 0x18, 80, 56, false, false, "RMT"}, // F4.0 00 00 00 01
111 { 0x17, 104, 56, true, false, "ERROR"}, // F3.7 00 00 80 00
112
113 { 0x16, 86, 38, false, false, "EXT"}, // F3.6 00 00 40 00
114 { 0x15, 60, 38, false, false, "ONCE"}, // F3.5 00 00 20 00
115
116 { 0x13, 40, 38, false, false, "MEM"}, // F3.3 00 00 08 00
117
118
119 // col 5
120 { 0x0c, 244, 47, false, false, "4W"}, // F2.4 00 10 00 00
121 { 0x0d, 244, 56, false, false, "OC"}, // F2.5 00 20 00 00
122
123 { 0x12, 40, 47, false, true, "LAST"}, // F3.2 00 00 04 00
124 { 0x11, 66, 47, false, true, "MIN"}, // F3.1 00 00 02 00
125 { 0x10, 86, 47, false, true, "MAX"}, // F3.0 00 00 01 00
126 { 0x0f, 106, 47, false, true, "AVG"}, // F2.7 00 80 00 00
127
128 { 0x05, 152+0, 29, false, false, "Alarm"}, // F1.5 20 00 00 00
129 { 0x08, 152+0, 39, false, false, "H"}, // F1.6 40 00 00 00
130 { 0x07, 152+6, 39, false, false, "1"}, // F2.3 00 08 00 00
131 { 0x06, 152+12, 39, false, false, "2"}, // F2.0 00 01 00 00
132 { 0x04, 152+18, 39, false, false, "3"}, // F2.2 00 04 00 00
133 { 0x09, 152+24, 39, false, false, "4"}, // F2.1 00 02 00 00
134 { 0x0a, 152+30, 39, false, false, "L"}, // F1.4 00 10 00 00
135
136 { 0x80, 152, 56, true, false, "SHIFT"}, // not an actual command, managed by the front panel
137 };
138
139
140 static const FRAME frames[] =
141 {
142 { 0x02, 192, 32, 240, 60}, // F1.2 - channel frame
143 { 0x0b, 149, 32, 190, 50}, // F1.7 - alarm frame
144 };
145
146
147 typedef enum {
148 FLAG_OFF,
149 FLAG_ON,
150 FLAG_DIM
151 } flag_status_t;
152
153 typedef struct _FLAG_STATUS
154 {
155 uint8_t flag;
156 flag_status_t status;
157 } FLAG_STATUS;
158
159 50
160 class Display: public SSD1322 51 class Display: public SSD1322
161 { 52 {
162 public: 53 public:
163 Display(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, 54 Display(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC,
164 const char* name); 55 const char* name);
165 56
166 virtual ~Display(); 57 virtual ~Display();
167 58
168 void test_dsp();
169 void show(uint8_t, const char*, uint8_t); 59 void show(uint8_t, const char*, uint8_t);
170 void dimm_char(uint8_t); 60 void dim_char(uint8_t);
171 void show_splashscreen(); 61 void show_splashscreen();
172 void show_byescreen(); 62 void show_byescreen();
173 void set_flag(uint8_t flag, bool show=true, bool dimm=false);
174 void show_flag(uint8_t flag) {set_flag(flag, true);};
175 void hide_flag(uint8_t flag) {set_flag(flag, false);};
176 void shift_on() {set_flag(0x80, true);};
177 void shift_off() {set_flag(0x80, false);};
178 63
64 void set_flag_status(uint8_t flagid, bool show);
65 void set_flag_dim(uint8_t flagid, bool dim);
66
67 void draw_flag(uint8_t flagid);
179 68
180 private: 69 private:
181 uint8_t must_refresh; 70 uint8_t must_refresh;
71 flag_status_map flags_status;
72 flag_status_map flags_dim;
182 73
183 }; 74 };
184 75
185 #endif 76 #endif

mercurial