diff --git a/libraries/AP_OSD/AP_OSD.cpp b/libraries/AP_OSD/AP_OSD.cpp index 7e1a3d2aed..c2fdb7bbb1 100644 --- a/libraries/AP_OSD/AP_OSD.cpp +++ b/libraries/AP_OSD/AP_OSD.cpp @@ -90,7 +90,7 @@ const AP_Param::GroupInfo AP_OSD::var_info[] = { // @Param: _OPTIONS // @DisplayName: OSD Options // @Description: This sets options that change the display - // @Bitmask: 0:UseDecimalPack, 1:InvertedWindPointer, 2:InvertedAHRoll, 3:Convert feet to miles at 5280ft instead of 10000ft, 4:DisableCrosshair, 17:wide Sidebar, 18:Two decimal vertical speed, 19:Right justify TUNED_PN element, 20:Prefix LQ with RF Mode, 21:One decimal attitude, 22:One decimal throttle, 23:Shorten Pluscode + // @Bitmask: 0:UseDecimalPack, 1:InvertedWindArrow, 2:InvertedAHRoll, 3:Convert feet to miles at 5280ft instead of 10000ft, 4:DisableCrosshair, 5:TranslateArrows, 17:wide Sidebar, 18:Two decimal vertical speed, 19:Right justify TUNED_PN element, 20:Prefix LQ with RF Mode, 21:One decimal attitude, 22:One decimal throttle, 23:Shorten Pluscode // @User: Standard AP_GROUPINFO("_OPTIONS", 8, AP_OSD, options, OPTION_DECIMAL_PACK | OPTION_ONE_DECIMAL_ATTITUDE | OPTION_RF_MODE_ALONG_WITH_LQ | OPTION_RIGHT_JUSTIFY_TUNED_PN ), diff --git a/libraries/AP_OSD/AP_OSD.h b/libraries/AP_OSD/AP_OSD.h index 11fe4fa77e..3fe7977173 100644 --- a/libraries/AP_OSD/AP_OSD.h +++ b/libraries/AP_OSD/AP_OSD.h @@ -314,11 +314,14 @@ class AP_OSD_Screen : public AP_OSD_AbstractScreen #if HAL_PLUSCODE_ENABLE void draw_pluscode(uint8_t x, uint8_t y); #endif + //helper functions void draw_speed(uint8_t x, uint8_t y, bool available, float magnitude = 0, bool blink = false); void draw_speed_with_arrow(uint8_t x, uint8_t y, float angle_rad, float magnitude, bool blink = false); void draw_distance(uint8_t x, uint8_t y, float distance, bool can_only_be_positive = true, bool available = true); void draw_temperature(uint8_t x, uint8_t y, bool available, float value = 0, bool blink = false); + char get_arrow_font_index (int32_t angle_cd); + #if HAL_WITH_ESC_TELEM void draw_highest_esc_temp(uint8_t x, uint8_t y); void draw_rpm(uint8_t x, uint8_t y, float rpm); // helper @@ -631,6 +634,7 @@ class AP_OSD OPTION_INVERTED_AH_ROLL = 1U<<2, OPTION_IMPERIAL_MILES = 1U<<3, OPTION_DISABLE_CROSSHAIR = 1U<<4, + OPTION_BF_ARROWS = 1U<<5, OPTION_WIDE_SIDEBAR = 1U<<17, OPTION_TWO_DECIMALS_VERTICAL_SPEED = 1U<<18, OPTION_RIGHT_JUSTIFY_TUNED_PN = 1U<<19, diff --git a/libraries/AP_OSD/AP_OSD_MSP_DisplayPort.h b/libraries/AP_OSD/AP_OSD_MSP_DisplayPort.h index 7ac7904dbe..27b72e9475 100644 --- a/libraries/AP_OSD/AP_OSD_MSP_DisplayPort.h +++ b/libraries/AP_OSD/AP_OSD_MSP_DisplayPort.h @@ -56,13 +56,13 @@ class AP_OSD_MSP_DisplayPort : public AP_OSD_Backend static const uint8_t SYM_FS = 0x99; static const uint8_t SYM_KMH = 0x9E; static const uint8_t SYM_MPH = 0x9D; - static const uint8_t SYM_DEGR = 0x1D; + static const uint8_t SYM_DEGR = 0x08; static const uint8_t SYM_PCNT = 0x25; static const uint8_t SYM_RPM = 0x12; static const uint8_t SYM_ASPD = 0x41; - static const uint8_t SYM_GSPD = 0x70; - static const uint8_t SYM_WSPD = 0x1B; - static const uint8_t SYM_VSPD = 0x7F; + static const uint8_t SYM_GSPD = 0x47; + static const uint8_t SYM_WSPD = 0x57; + static const uint8_t SYM_VSPD = 0x5E; static const uint8_t SYM_WPNO = 0x23; static const uint8_t SYM_WPDIR = 0xE6; static const uint8_t SYM_WPDST = 0xE7; @@ -71,10 +71,10 @@ class AP_OSD_MSP_DisplayPort : public AP_OSD_Backend static const uint8_t SYM_SAT_L = 0x1E; static const uint8_t SYM_SAT_R = 0x1F; - static const uint8_t SYM_HDOP_L = 0x11; - static const uint8_t SYM_HDOP_R = 0x08; + static const uint8_t SYM_HDOP_L = 0x48; + static const uint8_t SYM_HDOP_R = 0x44; - static const uint8_t SYM_HOME = 0x05; + static const uint8_t SYM_HOME = 0x11; static const uint8_t SYM_WIND = 0x57; static const uint8_t SYM_ARROW_START = 0x60; @@ -103,30 +103,30 @@ class AP_OSD_MSP_DisplayPort : public AP_OSD_Backend static const uint8_t SYM_DEGREES_C = 0x0E; static const uint8_t SYM_DEGREES_F = 0x0D; - static const uint8_t SYM_GPS_LAT = 0x68; - static const uint8_t SYM_GPS_LONG = 0x6C; - static const uint8_t SYM_ARMED = 0x08; - static const uint8_t SYM_DISARMED = 0x08; + static const uint8_t SYM_GPS_LAT = 0x89; + static const uint8_t SYM_GPS_LONG = 0x98; + static const uint8_t SYM_ARMED = 0x00; + static const uint8_t SYM_DISARMED = 0x2A; static const uint8_t SYM_ROLL0 = 0x2D; static const uint8_t SYM_ROLLR = 0x64; static const uint8_t SYM_ROLLL = 0x6C; static const uint8_t SYM_PTCH0 = 0x7C; static const uint8_t SYM_PTCHUP = 0x68; static const uint8_t SYM_PTCHDWN = 0x60; - static const uint8_t SYM_XERR = 0xEE; + static const uint8_t SYM_XERR = 0x21; static const uint8_t SYM_KN = 0xF0; static const uint8_t SYM_NM = 0xF1; - static const uint8_t SYM_DIST = 0x22; + static const uint8_t SYM_DIST = 0x04; static const uint8_t SYM_FLY = 0x9C; static const uint8_t SYM_EFF = 0xF2; static const uint8_t SYM_AH = 0xF3; static const uint8_t SYM_MW = 0xF4; static const uint8_t SYM_CLK = 0x08; static const uint8_t SYM_KILO = 0x4B; - static const uint8_t SYM_TERALT = 0xEF; + static const uint8_t SYM_TERALT = 0x7F; static const uint8_t SYM_FENCE_ENABLED = 0xF5; static const uint8_t SYM_FENCE_DISABLED = 0xF6; - static const uint8_t SYM_RNGFD = 0x72; + static const uint8_t SYM_RNGFD = 0x7F; static const uint8_t SYM_LQ = 0xF8; static constexpr uint8_t symbols[AP_OSD_NUM_SYMBOLS] { diff --git a/libraries/AP_OSD/AP_OSD_Screen.cpp b/libraries/AP_OSD/AP_OSD_Screen.cpp index 6e20d8a574..2fa53242e1 100644 --- a/libraries/AP_OSD/AP_OSD_Screen.cpp +++ b/libraries/AP_OSD/AP_OSD_Screen.cpp @@ -2202,11 +2202,22 @@ void AP_OSD_Screen::draw_speed(uint8_t x, uint8_t y, bool available, float magni backend->write(x+spaces, y, blink, fmt, magnitude_scaled, u_icon(SPEED)); } +char AP_OSD_Screen::get_arrow_font_index(int32_t angle_cd) +{ + uint32_t interval = 36000 / SYMBOL(SYM_ARROW_COUNT); + angle_cd = wrap_360_cd(angle_cd); + // if using BF font table must translate arrows + if (check_option(AP_OSD::OPTION_BF_ARROWS)) { + angle_cd = angle_cd > 18000? 54000 - angle_cd : 18000- angle_cd; + } + return SYMBOL(SYM_ARROW_START) + ((angle_cd + interval / 2) / interval) % SYMBOL(SYM_ARROW_COUNT); +} + // draw a arrow at the given angle, and print the given magnitude void AP_OSD_Screen::draw_speed_with_arrow(uint8_t x, uint8_t y, float angle_rad, float magnitude, bool blink) { - static const int32_t arrow_interval = 36000 / SYMBOL(SYM_ARROW_COUNT); - char arrow = SYMBOL(SYM_ARROW_START) + ((int32_t(angle_rad*DEGX100) + arrow_interval / 2) / arrow_interval) % SYMBOL(SYM_ARROW_COUNT); + int32_t angle_cd = angle_rad * DEGX100; + char arrow = get_arrow_font_index(angle_cd); backend->write(x, y, false, "%c", arrow); draw_speed(x+1, y, true, magnitude, blink); }