src/display.h

Fri, 13 Nov 2020 19:35:46 +0100

author
David Douard <david.douard@sdf3.org>
date
Fri, 13 Nov 2020 19:35:46 +0100
changeset 54
f6774bd0d570
parent 53
74e85b34d26b
permissions
-rw-r--r--

Refactor the flag display system

make it stateful

37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
1 #ifndef DISPLAY_H
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
2 #define DISPLAY_H
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
3
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
4 #include "Terminal6x8.h"
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
5 #include "Mono19x27.h"
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
6 #include "Mono15x22.h"
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
7 #include "Arial12x12.h"
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
8 #include "SSD1322.h"
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
9 #include "hp34comm.h"
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
10
54
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
11 #include <map>
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
12
44
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
13 //typedef enum {
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
14 #define FMT_ASCII 0x01
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
15 #define FMT_HEX 0x02
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
16 #define FMT_BITS 0x04
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
17 #define FMT_FLAGS 0x08
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
18 #define FMT_IGNORE 0x80
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
19 //} dsp_format_t;
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
20
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
21
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
22 typedef struct _DSP
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
23 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
24 uint8_t cmd;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
25 uint8_t color;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
26 uint8_t bgcolor;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
27 uint8_t x0;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
28 uint8_t y0;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
29 uint8_t fmt; // 0x01=>ascii, 0x02=>hex, 0x04=>bits, 0x08=>flags, 0x80=>ignore
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
30 uint8_t maxsize;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
31 uint8_t width;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
32 const unsigned char* font;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
33 char buffer[MAX_BUFF+1];
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
34 } DSP;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
35
44
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
36
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
37 typedef struct _FLAG
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 uint8_t x0;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
40 uint8_t y0;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
41 uint8_t x1;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
42 uint8_t y1;
54
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
43 bool reverse;
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
44 const char* msg;
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
45 const unsigned char* icon;
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
46 } FLAG;
53
74e85b34d26b Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents: 51
diff changeset
47
54
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
48 typedef std::map<uint8_t, FLAG> flags_map;
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
49 typedef std::map<uint8_t, bool> flag_status_map;
53
74e85b34d26b Reorganize the display + improvements for dimmed flags
David Douard <david.douard@sdf3.org>
parents: 51
diff changeset
50
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
51 class Display: public SSD1322
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
52 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
53 public:
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
54 Display(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC,
54
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
55 const char* name);
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
56
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
57 virtual ~Display();
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
58
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
59 void show(uint8_t, const char*, uint8_t);
54
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
60 void dim_char(uint8_t);
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
61 void show_splashscreen();
44
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
62 void show_byescreen();
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
63
54
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
64 void set_flag_status(uint8_t flagid, bool show);
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
65 void set_flag_dim(uint8_t flagid, bool dim);
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
66
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
67 void draw_flag(uint8_t flagid);
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
68
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
69 private:
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
70 uint8_t must_refresh;
54
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
71 flag_status_map flags_status;
f6774bd0d570 Refactor the flag display system
David Douard <david.douard@sdf3.org>
parents: 53
diff changeset
72 flag_status_map flags_dim;
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
73
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
74 };
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
75
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
76 #endif

mercurial