1 #include <AP_OSD/AP_OSD_Backend.h>
2 #include <AP_MSP/AP_MSP.h>
4 #if HAL_WITH_MSP_DISPLAYPORT
6 class AP_OSD_MSP_DisplayPort
: public AP_OSD_Backend
8 using AP_OSD_Backend::AP_OSD_Backend
;
10 static AP_OSD_Backend
*probe(AP_OSD
&osd
);
12 //initialize display port and underlying hardware
15 //draw given text to framebuffer
16 void write(uint8_t x
, uint8_t y
, const char* text
) override
;
18 //flush framebuffer to screen
19 void flush() override
;
22 void clear() override
;
24 // copy the backend specific symbol set to the OSD lookup table
25 void init_symbol_set(uint8_t *lookup_table
, const uint8_t size
) override
;
27 // called by the OSD thread once
28 // used to initialize the uart in the correct thread
29 void osd_thread_run_once() override
;
31 // return a correction factor used to display angles correctly
32 float get_aspect_ratio_correction() const override
;
34 bool is_compatible_with_backend_type(AP_OSD::osd_types type
) const override
{
36 case AP_OSD::osd_types::OSD_MSP
:
37 case AP_OSD::osd_types::OSD_MSP_DISPLAYPORT
:
39 case AP_OSD::osd_types::OSD_NONE
:
40 case AP_OSD::osd_types::OSD_TXONLY
:
41 case AP_OSD::osd_types::OSD_MAX7456
:
42 case AP_OSD::osd_types::OSD_SITL
:
48 AP_OSD::osd_types
get_backend_type() const override
{
49 return AP_OSD::osd_types::OSD_MSP_DISPLAYPORT
;
52 uint8_t format_string_for_osd(char* dst
, uint8_t size
, bool decimal_packed
, const char *fmt
, va_list ap
) override
;
55 void setup_defaults(void);
57 AP_MSP_Telem_Backend
* _displayport
;
59 // MSP DisplayPort symbols
60 static const uint8_t SYM_M
= 0x0C;
61 static const uint8_t SYM_KM
= 0x7D;
62 static const uint8_t SYM_FT
= 0x0F;
63 static const uint8_t SYM_MI
= 0x7E;
64 static const uint8_t SYM_ALT_M
= 0x0C;
65 static const uint8_t SYM_ALT_FT
= 0x0F;
66 static const uint8_t SYM_BATT_FULL
= 0x90;
67 static const uint8_t SYM_RSSI
= 0x01;
69 static const uint8_t SYM_VOLT
= 0x06;
70 static const uint8_t SYM_AMP
= 0x9A;
71 static const uint8_t SYM_MAH
= 0x07;
72 static const uint8_t SYM_MS
= 0x9F;
73 static const uint8_t SYM_FS
= 0x99;
74 static const uint8_t SYM_KMH
= 0x9E;
75 static const uint8_t SYM_MPH
= 0x9D;
76 static const uint8_t SYM_DEGR
= 0x08;
77 static const uint8_t SYM_PCNT
= 0x25;
78 static const uint8_t SYM_RPM
= 0x12;
79 static const uint8_t SYM_ASPD
= 0x41;
80 static const uint8_t SYM_GSPD
= 0x47;
81 static const uint8_t SYM_WSPD
= 0x57;
82 static const uint8_t SYM_VSPD
= 0x5E;
83 static const uint8_t SYM_WPNO
= 0x23;
84 static const uint8_t SYM_WPDIR
= 0xE6;
85 static const uint8_t SYM_WPDST
= 0xE7;
86 static const uint8_t SYM_FTMIN
= 0xE8;
87 static const uint8_t SYM_FTSEC
= 0x99;
89 static const uint8_t SYM_SAT_L
= 0x1E;
90 static const uint8_t SYM_SAT_R
= 0x1F;
91 static const uint8_t SYM_HDOP_L
= 0x48;
92 static const uint8_t SYM_HDOP_R
= 0x44;
94 static const uint8_t SYM_HOME
= 0x11;
95 static const uint8_t SYM_WIND
= 0x57;
97 static const uint8_t SYM_ARROW_START
= 0x60;
98 static const uint8_t SYM_ARROW_COUNT
= 16;
99 static const uint8_t SYM_AH_H_START
= 0x80;
100 static const uint8_t SYM_AH_H_COUNT
= 9;
102 static const uint8_t SYM_AH_V_START
= 0x82;
103 static const uint8_t SYM_AH_V_COUNT
= 6;
105 static const uint8_t SYM_AH_CENTER_LINE_LEFT
= 0x84;
106 static const uint8_t SYM_AH_CENTER_LINE_RIGHT
= 0x84;
107 static const uint8_t SYM_AH_CENTER
= 0x2B;
109 static const uint8_t SYM_HEADING_N
= 0x18;
110 static const uint8_t SYM_HEADING_S
= 0x19;
111 static const uint8_t SYM_HEADING_E
= 0x1A;
112 static const uint8_t SYM_HEADING_W
= 0x1B;
113 static const uint8_t SYM_HEADING_DIVIDED_LINE
= 0x1C;
114 static const uint8_t SYM_HEADING_LINE
= 0x1D;
116 static const uint8_t SYM_UP_UP
= 0x68;
117 static const uint8_t SYM_UP
= 0x68;
118 static const uint8_t SYM_DOWN
= 0x60;
119 static const uint8_t SYM_DOWN_DOWN
= 0x60;
121 static const uint8_t SYM_DEGREES_C
= 0x0E;
122 static const uint8_t SYM_DEGREES_F
= 0x0D;
123 static const uint8_t SYM_GPS_LAT
= 0x89;
124 static const uint8_t SYM_GPS_LONG
= 0x98;
125 static const uint8_t SYM_ARMED
= 0x00;
126 static const uint8_t SYM_DISARMED
= 0x2A;
127 static const uint8_t SYM_ROLL0
= 0x2D;
128 static const uint8_t SYM_ROLLR
= 0x64;
129 static const uint8_t SYM_ROLLL
= 0x6C;
130 static const uint8_t SYM_PTCH0
= 0x7C;
131 static const uint8_t SYM_PTCHUP
= 0x68;
132 static const uint8_t SYM_PTCHDWN
= 0x60;
133 static const uint8_t SYM_XERR
= 0x21;
134 static const uint8_t SYM_KN
= 0xF0;
135 static const uint8_t SYM_NM
= 0xF1;
136 static const uint8_t SYM_DIST
= 0x04;
137 static const uint8_t SYM_FLY
= 0x9C;
138 static const uint8_t SYM_EFF
= 0xF2;
139 static const uint8_t SYM_AH
= 0xF3;
140 static const uint8_t SYM_MW
= 0xF4;
141 static const uint8_t SYM_CLK
= 0x08;
142 static const uint8_t SYM_KILO
= 0x4B;
143 static const uint8_t SYM_TERALT
= 0x7F;
144 static const uint8_t SYM_FENCE_ENABLED
= 0xF5;
145 static const uint8_t SYM_FENCE_DISABLED
= 0xF6;
146 static const uint8_t SYM_RNGFD
= 0x7F;
147 static const uint8_t SYM_LQ
= 0xF8;
149 static const uint8_t SYM_SIDEBAR_L_ARROW
= 0x02;
150 static const uint8_t SYM_SIDEBAR_R_ARROW
= 0x03;
151 static const uint8_t SYM_SIDEBAR_A
= 0x13;
152 static const uint8_t SYM_SIDEBAR_B
= SYM_SIDEBAR_A
;
153 static const uint8_t SYM_SIDEBAR_C
= SYM_SIDEBAR_A
;
154 static const uint8_t SYM_SIDEBAR_D
= SYM_SIDEBAR_A
;
155 static const uint8_t SYM_SIDEBAR_E
= SYM_SIDEBAR_A
;
156 static const uint8_t SYM_SIDEBAR_F
= SYM_SIDEBAR_A
;
157 static const uint8_t SYM_SIDEBAR_G
= SYM_SIDEBAR_A
;
158 static const uint8_t SYM_SIDEBAR_H
= SYM_SIDEBAR_A
;
159 static const uint8_t SYM_SIDEBAR_I
= SYM_SIDEBAR_A
;
160 static const uint8_t SYM_SIDEBAR_J
= SYM_SIDEBAR_A
;
163 static constexpr uint8_t symbols
[AP_OSD_NUM_SYMBOLS
] {
203 SYM_AH_CENTER_LINE_LEFT
,
204 SYM_AH_CENTER_LINE_RIGHT
,
210 SYM_HEADING_DIVIDED_LINE
,