From 34ab839c251c472d6a0cbd0537e11ae07ed1c51b Mon Sep 17 00:00:00 2001 From: mfoo Date: Sat, 30 Dec 2023 10:16:58 +0100 Subject: [PATCH] AP_OSD: fix arrow for home distance and waypoint for DJI O3 --- libraries/AP_OSD/AP_OSD_Screen.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libraries/AP_OSD/AP_OSD_Screen.cpp b/libraries/AP_OSD/AP_OSD_Screen.cpp index 2fa53242e1..fcfc198528 100644 --- a/libraries/AP_OSD/AP_OSD_Screen.cpp +++ b/libraries/AP_OSD/AP_OSD_Screen.cpp @@ -2376,13 +2376,12 @@ void AP_OSD_Screen::draw_home(uint8_t x, uint8_t y) if (home_is_set) { // const Location &home_loc = ahrs.get_home(); float distance = home_loc.get_distance(loc); - int32_t angle = wrap_360_cd(loc.get_bearing_to(home_loc) - yaw_sensor); - int32_t interval = 36000 / SYMBOL(SYM_ARROW_COUNT); + int32_t angle_cd = loc.get_bearing_to(home_loc) - yaw_sensor; if (distance < 2.0f) { //avoid fast rotating arrow at small distances - angle = 0; + angle_cd = 0; } - char arrow = SYMBOL(SYM_ARROW_START) + ((angle + interval / 2) / interval) % SYMBOL(SYM_ARROW_COUNT); + char arrow = get_arrow_font_index(angle_cd); backend->write(x, y, false, "%c%c", SYMBOL(SYM_HOME), arrow); draw_distance(x+2, y, distance, true); } else { @@ -2948,13 +2947,13 @@ void AP_OSD_Screen::draw_waypoint(uint8_t x, uint8_t y) WITH_SEMAPHORE(ahrs.get_semaphore()); yaw_sensor = ahrs.yaw_sensor; } - int32_t angle = wrap_360_cd(osd->nav_info.wp_bearing - yaw_sensor); - int32_t interval = 36000 / SYMBOL(SYM_ARROW_COUNT); + + int32_t angle_cd = osd->nav_info.wp_bearing - yaw_sensor; if (osd->nav_info.wp_distance < 2.0f) { //avoid fast rotating arrow at small distances - angle = 0; + angle_cd = 0; } - char arrow = SYMBOL(SYM_ARROW_START) + ((angle + interval / 2) / interval) % SYMBOL(SYM_ARROW_COUNT); + char arrow = get_arrow_font_index(angle_cd); backend->write(x,y, false, "%c%2u%c",SYMBOL(SYM_WPNO), osd->nav_info.wp_number, arrow); draw_distance(x+4, y, osd->nav_info.wp_distance, true); }