Skip to content

Commit

Permalink
AP_OSD: fix arrow for home distance and waypoint for DJI O3
Browse files Browse the repository at this point in the history
  • Loading branch information
mfoo authored and shellixyz committed Dec 31, 2023
1 parent f45350d commit 34ab839
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions libraries/AP_OSD/AP_OSD_Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 34ab839

Please sign in to comment.