LCOV - code coverage report
Current view: top level - AP_OSD - AP_OSD_MSP_DisplayPort.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 6 9 66.7 %
Date: 2026-09-09 11:02:08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #include <AP_OSD/AP_OSD_Backend.h>
       2             : #include <AP_MSP/AP_MSP.h>
       3             : 
       4             : #if HAL_WITH_MSP_DISPLAYPORT
       5             : 
       6             : #define DISPLAYPORT_WRITE_BUFFER_MAX_LEN 30
       7             : 
       8             : class AP_OSD_MSP_DisplayPort : public AP_OSD_Backend
       9             : {
      10             :     using AP_OSD_Backend::AP_OSD_Backend;
      11             : public:
      12             :     static AP_OSD_Backend *probe(AP_OSD &osd);
      13             : 
      14             :     //initialize display port and underlying hardware
      15             :     bool init() override;
      16             : 
      17             :     //draw given text to framebuffer
      18             :     void write(uint8_t x, uint8_t y, const char* text) override;
      19             :     
      20             :     //draw given text to framebuffer using INAV fonts
      21             :     void write_INAV(uint8_t x, uint8_t y, const char* text);
      22             : 
      23             :     //flush framebuffer to screen
      24             :     void flush() override;
      25             : 
      26             :     //clear framebuffer
      27             :     void clear() override;
      28             : 
      29             :     // copy the backend specific symbol set to the OSD lookup table
      30             :     void init_symbol_set(uint8_t *lookup_table, const uint8_t size) override;
      31             : 
      32             :     // called by the OSD thread once
      33             :     // used to initialize the uart in the correct thread
      34             :     void osd_thread_run_once() override;
      35             : 
      36             :     // return a correction factor used to display angles correctly
      37             :     float get_aspect_ratio_correction() const override;
      38             :     
      39           2 :     bool is_compatible_with_backend_type(AP_OSD::osd_types type) const override {
      40           2 :         switch(type) {
      41           0 :         case AP_OSD::osd_types::OSD_MSP:
      42             :         case AP_OSD::osd_types::OSD_MSP_DISPLAYPORT:
      43           0 :             return false;
      44           2 :         case AP_OSD::osd_types::OSD_NONE:
      45             :         case AP_OSD::osd_types::OSD_TXONLY:
      46             :         case AP_OSD::osd_types::OSD_MAX7456:
      47             :         case AP_OSD::osd_types::OSD_SITL:
      48           2 :             return true;
      49             :         }
      50           0 :         return false;
      51             :     }
      52             : 
      53         548 :     AP_OSD::osd_types get_backend_type() const override {
      54         548 :         return AP_OSD::osd_types::OSD_MSP_DISPLAYPORT;
      55             :     }
      56             : protected:
      57             :     uint8_t format_string_for_osd(char* dst, uint8_t size, bool decimal_packed, const char *fmt, va_list ap) override;
      58             : 
      59             : private:
      60             :     void setup_defaults(void);
      61             :     char displayport_write_buffer[DISPLAYPORT_WRITE_BUFFER_MAX_LEN]; // terminator
      62             : 
      63             :     AP_MSP_Telem_Backend* _displayport;
      64             : 
      65             :     // MSP DisplayPort symbols
      66             :     static const uint8_t SYM_M = 0x0C;
      67             :     static const uint8_t SYM_KM = 0x7D;
      68             :     static const uint8_t SYM_FT = 0x0F;
      69             :     static const uint8_t SYM_MI = 0x7E;
      70             :     static const uint8_t SYM_ALT_M = 0x0C;
      71             :     static const uint8_t SYM_ALT_FT = 0x0F;
      72             :     static const uint8_t SYM_BATT_FULL = 0x90;
      73             :     static const uint8_t SYM_RSSI = 0x01;
      74             : 
      75             :     static const uint8_t SYM_VOLT = 0x06;
      76             :     static const uint8_t SYM_AMP = 0x9A;
      77             :     static const uint8_t SYM_MAH = 0x07;
      78             :     static const uint8_t SYM_MS = 0x9F;
      79             :     static const uint8_t SYM_FS = 0x99;
      80             :     static const uint8_t SYM_KMH = 0x9E;
      81             :     static const uint8_t SYM_MPH = 0x9D;
      82             :     static const uint8_t SYM_DEGR = 0x08;
      83             :     static const uint8_t SYM_PCNT = 0x25;
      84             :     static const uint8_t SYM_RPM = 0x12;
      85             :     static const uint8_t SYM_ASPD = 0x41;
      86             :     static const uint8_t SYM_GSPD = 0x47;
      87             :     static const uint8_t SYM_WSPD = 0x57;
      88             :     static const uint8_t SYM_VSPD = 0x5E;
      89             :     static const uint8_t SYM_WPNO = 0x23;
      90             :     static const uint8_t SYM_WPDIR = 0xE6;
      91             :     static const uint8_t SYM_WPDST = 0xE7;
      92             :     static const uint8_t SYM_FTMIN = 0xE8;
      93             :     static const uint8_t SYM_FTSEC = 0x99;
      94             : 
      95             :     static const uint8_t SYM_SAT_L = 0x1E;
      96             :     static const uint8_t SYM_SAT_R = 0x1F;
      97             :     static const uint8_t SYM_HDOP_L = 0x48;
      98             :     static const uint8_t SYM_HDOP_R = 0x44;
      99             : 
     100             :     static const uint8_t SYM_HOME = 0x11;
     101             :     static const uint8_t SYM_WIND = 0x57;
     102             : 
     103             :     static const uint8_t SYM_ARROW_START = 0x60;
     104             :     static const uint8_t SYM_ARROW_COUNT = 16;
     105             :     static const uint8_t SYM_AH_H_START = 0x80;
     106             :     static const uint8_t SYM_AH_H_COUNT = 9;
     107             : 
     108             :     static const uint8_t SYM_AH_V_START = 0x82;
     109             :     static const uint8_t SYM_AH_V_COUNT = 6;
     110             : 
     111             :     static const uint8_t SYM_AH_CENTER_LINE_LEFT = 0x84;
     112             :     static const uint8_t SYM_AH_CENTER_LINE_RIGHT = 0x84;
     113             :     static const uint8_t SYM_AH_CENTER = 0x2B;
     114             : 
     115             :     static const uint8_t SYM_HEADING_N = 0x18;
     116             :     static const uint8_t SYM_HEADING_S = 0x19;
     117             :     static const uint8_t SYM_HEADING_E = 0x1A;
     118             :     static const uint8_t SYM_HEADING_W = 0x1B;
     119             :     static const uint8_t SYM_HEADING_DIVIDED_LINE = 0x1C;
     120             :     static const uint8_t SYM_HEADING_LINE = 0x1D;
     121             : 
     122             :     static const uint8_t SYM_UP_UP = 0x68;
     123             :     static const uint8_t SYM_UP = 0x68;
     124             :     static const uint8_t SYM_DOWN = 0x60;
     125             :     static const uint8_t SYM_DOWN_DOWN = 0x60;
     126             : 
     127             :     static const uint8_t SYM_DEGREES_C = 0x0E;
     128             :     static const uint8_t SYM_DEGREES_F = 0x0D;
     129             :     static const uint8_t SYM_GPS_LAT = 0x89;
     130             :     static const uint8_t SYM_GPS_LONG = 0x98;
     131             :     static const uint8_t SYM_ARMED = 0x00;
     132             :     static const uint8_t SYM_DISARMED = 0x2A;
     133             :     static const uint8_t SYM_ROLL0 = 0x2D;
     134             :     static const uint8_t SYM_ROLLR = 0x64;
     135             :     static const uint8_t SYM_ROLLL = 0x6C;
     136             :     static const uint8_t SYM_PTCH0 = 0x7C;
     137             :     static const uint8_t SYM_PTCHUP = 0x68;
     138             :     static const uint8_t SYM_PTCHDWN = 0x60;
     139             :     static const uint8_t SYM_XERR = 0x21;
     140             :     static const uint8_t SYM_KN = 0xF0;
     141             :     static const uint8_t SYM_NM = 0xF1;
     142             :     static const uint8_t SYM_DIST = 0x71;
     143             :     static const uint8_t SYM_FLY = 0x9C;
     144             :     static const uint8_t SYM_EFF = 0xF2;
     145             :     static const uint8_t SYM_AH = 0xF3;
     146             :     static const uint8_t SYM_MW = 0xF4;
     147             :     static const uint8_t SYM_CLK = 0x08;
     148             :     static const uint8_t SYM_KILO = 0x4B;
     149             :     static const uint8_t SYM_TERALT = 0x7F;
     150             :     static const uint8_t SYM_FENCE_ENABLED = 0xF5;
     151             :     static const uint8_t SYM_FENCE_DISABLED = 0xF6;
     152             :     static const uint8_t SYM_RNGFD = 0x7F;
     153             :     static const uint8_t SYM_LQ = 0x7B;
     154             : 
     155             :     static const uint8_t SYM_SIDEBAR_L_ARROW = 0x02;
     156             :     static const uint8_t SYM_SIDEBAR_R_ARROW = 0x03;
     157             :     static const uint8_t SYM_SIDEBAR_A = 0x13;
     158             :     static const uint8_t SYM_SIDEBAR_B = SYM_SIDEBAR_A;
     159             :     static const uint8_t SYM_SIDEBAR_C = SYM_SIDEBAR_A;
     160             :     static const uint8_t SYM_SIDEBAR_D = SYM_SIDEBAR_A;
     161             :     static const uint8_t SYM_SIDEBAR_E = SYM_SIDEBAR_A;
     162             :     static const uint8_t SYM_SIDEBAR_F = SYM_SIDEBAR_A;
     163             :     static const uint8_t SYM_SIDEBAR_G = SYM_SIDEBAR_A;
     164             :     static const uint8_t SYM_SIDEBAR_H = SYM_SIDEBAR_A;
     165             :     static const uint8_t SYM_SIDEBAR_I = SYM_SIDEBAR_A;
     166             :     static const uint8_t SYM_SIDEBAR_J = SYM_SIDEBAR_A;
     167             : 
     168             : 
     169             :     static constexpr uint8_t symbols[AP_OSD_NUM_SYMBOLS] {
     170             :         SYM_M,
     171             :         SYM_KM,
     172             :         SYM_FT,
     173             :         SYM_MI,
     174             :         SYM_ALT_M,
     175             :         SYM_ALT_FT,
     176             :         SYM_BATT_FULL,
     177             :         SYM_RSSI,
     178             :         SYM_VOLT,
     179             :         SYM_AMP,
     180             :         SYM_MAH,
     181             :         SYM_MS,
     182             :         SYM_FS,
     183             :         SYM_KMH,
     184             :         SYM_MPH,
     185             :         SYM_DEGR,
     186             :         SYM_PCNT,
     187             :         SYM_RPM,
     188             :         SYM_ASPD,
     189             :         SYM_GSPD,
     190             :         SYM_WSPD,
     191             :         SYM_VSPD,
     192             :         SYM_WPNO,
     193             :         SYM_WPDIR,
     194             :         SYM_WPDST,
     195             :         SYM_FTMIN,
     196             :         SYM_FTSEC,
     197             :         SYM_SAT_L,
     198             :         SYM_SAT_R,
     199             :         SYM_HDOP_L,
     200             :         SYM_HDOP_R,
     201             :         SYM_HOME,
     202             :         SYM_WIND,
     203             :         SYM_ARROW_START,
     204             :         SYM_ARROW_COUNT,
     205             :         SYM_AH_H_START,
     206             :         SYM_AH_H_COUNT,
     207             :         SYM_AH_V_START,
     208             :         SYM_AH_V_COUNT,
     209             :         SYM_AH_CENTER_LINE_LEFT,
     210             :         SYM_AH_CENTER_LINE_RIGHT,
     211             :         SYM_AH_CENTER,
     212             :         SYM_HEADING_N,
     213             :         SYM_HEADING_S,
     214             :         SYM_HEADING_E,
     215             :         SYM_HEADING_W,
     216             :         SYM_HEADING_DIVIDED_LINE,
     217             :         SYM_HEADING_LINE,
     218             :         SYM_UP_UP,
     219             :         SYM_UP,
     220             :         SYM_DOWN,
     221             :         SYM_DOWN_DOWN,
     222             :         SYM_DEGREES_C,
     223             :         SYM_DEGREES_F,
     224             :         SYM_GPS_LAT,
     225             :         SYM_GPS_LONG,
     226             :         SYM_ARMED,
     227             :         SYM_DISARMED,
     228             :         SYM_ROLL0,
     229             :         SYM_ROLLR,
     230             :         SYM_ROLLL,
     231             :         SYM_PTCH0,
     232             :         SYM_PTCHUP,
     233             :         SYM_PTCHDWN,
     234             :         SYM_XERR,
     235             :         SYM_KN,
     236             :         SYM_NM,
     237             :         SYM_DIST,
     238             :         SYM_FLY,
     239             :         SYM_EFF,
     240             :         SYM_AH,
     241             :         SYM_MW,
     242             :         SYM_CLK,
     243             :         SYM_KILO,
     244             :         SYM_TERALT,
     245             :         SYM_FENCE_ENABLED,
     246             :         SYM_FENCE_DISABLED,
     247             :         SYM_RNGFD,
     248             :         SYM_LQ,
     249             :         SYM_SIDEBAR_L_ARROW,
     250             :         SYM_SIDEBAR_R_ARROW,
     251             :         SYM_SIDEBAR_A,
     252             :         SYM_SIDEBAR_B,
     253             :         SYM_SIDEBAR_C,
     254             :         SYM_SIDEBAR_D,
     255             :         SYM_SIDEBAR_E,
     256             :         SYM_SIDEBAR_F,
     257             :         SYM_SIDEBAR_G,
     258             :         SYM_SIDEBAR_H,
     259             :         SYM_SIDEBAR_I,
     260             :         SYM_SIDEBAR_J,
     261             :     };
     262             : #if AP_MSP_INAV_FONTS_ENABLED
     263             :     static const uint8_t ap_to_inav_symbols_map[256][2];
     264             : #endif //AP_MSP_INAV_FONTS_ENABLED
     265             :     bool _blink_on;
     266             : };
     267             : #endif

Generated by: LCOV version 1.14