diff --git a/docs/Settings.md b/docs/Settings.md index d9b72a058e2..4e644ff8fa3 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -4832,6 +4832,16 @@ To vertically adjust the whole OSD and AHI and scrolling bars --- +### osd_hud_flight_direction + +To 3D-display the moving destination direction in the hud + +| Default | Min | Max | +| --- | --- | --- | +| OFF | OFF | ON | + +--- + ### osd_hud_homepoint To 3D-display the home point location in the hud diff --git a/src/main/cms/cms_menu_osd.c b/src/main/cms/cms_menu_osd.c index 0e85d0e656d..db54fcf966f 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -420,6 +420,7 @@ static const OSD_Entry menuOsdHud2Entries[] = { OSD_SETTING_ENTRY("HOMING ARROWS", SETTING_OSD_HUD_HOMING), OSD_SETTING_ENTRY("HOME POINT", SETTING_OSD_HUD_HOMEPOINT), + OSD_SETTING_ENTRY("FLIGHT DIRECTION", SETTING_OSD_HUD_FLIGHT_DIRECTION), OSD_SETTING_ENTRY("RADAR MAX AIRCRAFT", SETTING_OSD_HUD_RADAR_DISP), OSD_SETTING_ENTRY("RADAR MIN RANGE", SETTING_OSD_HUD_RADAR_RANGE_MIN), OSD_SETTING_ENTRY("RADAR MAX RANGE", SETTING_OSD_HUD_RADAR_RANGE_MAX), diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 74afae23d94..9097d132a76 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -3512,6 +3512,11 @@ groups: default_value: OFF field: hud_homepoint type: bool + - name: osd_hud_flight_direction + description: "To 3D-display the moving destination direction in the hud" + default_value: OFF + field: hud_flight_direction + type: bool - name: osd_hud_radar_disp description: "Maximum count of nearby aircrafts or points of interest to display in the hud, as sent from an ESP32 LoRa module. Set to 0 to disable (show nothing). The nearby aircrafts will appear as markers A, B, C, etc" default_value: 0 diff --git a/src/main/io/osd.c b/src/main/io/osd.c index d44ea0a8988..9f7f339b7d1 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -2754,7 +2754,7 @@ static bool osdDrawSingleElement(uint8_t item) #endif ) && isImuHeadingValid()) { - if (osdConfig()->hud_homepoint || osdConfig()->hud_radar_disp > 0 || osdConfig()->hud_wp_disp > 0) { + if (osdConfig()->hud_homepoint || osdConfig()->hud_radar_disp > 0 || osdConfig()->hud_wp_disp > 0 || osdConfig()->hud_flight_direction) { osdHudClear(); } @@ -2764,6 +2764,18 @@ static bool osdDrawSingleElement(uint8_t item) osdHudDrawPoi(GPS_distanceToHome, GPS_directionToHome, -osdGetAltitude() / 100, 0, SYM_HOME, 0 , 0); } + // -------- POI : Flight direction + + if (osdConfig()->hud_flight_direction) { + int vx = getEstimatedActualVelocity(X); // in cm/s + int vy = getEstimatedActualVelocity(Y); // in cm/s + int vz = getEstimatedActualVelocity(Z); // in cm/s + + float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); + int altitude_relative = (vz / 100); + osdHudDrawPoi(1, (int16_t)direction_deg, altitude_relative, 3, SYM_ALERT, 0, 0); + } + // -------- POI : Nearby aircrafts from ESP32 radar if (osdConfig()->hud_radar_disp > 0) { // Display the POI from the radar @@ -4143,6 +4155,7 @@ PG_RESET_TEMPLATE(osdConfig_t, osdConfig, .hud_margin_v = SETTING_OSD_HUD_MARGIN_V_DEFAULT, .hud_homing = SETTING_OSD_HUD_HOMING_DEFAULT, .hud_homepoint = SETTING_OSD_HUD_HOMEPOINT_DEFAULT, + .hud_flight_direction = SETTING_OSD_HUD_FLIGHT_DIRECTION_DEFAULT, .hud_radar_disp = SETTING_OSD_HUD_RADAR_DISP_DEFAULT, .hud_radar_range_min = SETTING_OSD_HUD_RADAR_RANGE_MIN_DEFAULT, .hud_radar_range_max = SETTING_OSD_HUD_RADAR_RANGE_MAX_DEFAULT, diff --git a/src/main/io/osd.h b/src/main/io/osd.h index b2e94b52729..1ca764cd854 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -429,6 +429,7 @@ typedef struct osdConfig_s { uint8_t hud_margin_v; bool hud_homing; bool hud_homepoint; + bool hud_flight_direction; uint8_t hud_radar_disp; uint16_t hud_radar_range_min; uint16_t hud_radar_range_max; diff --git a/src/main/io/osd_hud.c b/src/main/io/osd_hud.c index 8a6a68f467a..d2432484a98 100644 --- a/src/main/io/osd_hud.c +++ b/src/main/io/osd_hud.c @@ -119,6 +119,7 @@ int8_t radarGetNearestPOI(void) * Type = 0 : Home point * Type = 1 : Radar POI, P1: Relative heading, P2: Signal, P3 Cardinal direction * Type = 2 : Waypoint, P1: WP number, P2: 1=WP+1, 2=WP+2, 3=WP+3 + * Type = 3 : Flight direction */ void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2) { @@ -217,7 +218,7 @@ void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitu // Distance - if (poiType > 0 && + if (poiType > 0 && poiType != 3 && ((millis() / 1000) % (osdConfig()->hud_radar_alt_difference_display_time + osdConfig()->hud_radar_distance_display_time) < (osdConfig()->hud_radar_alt_difference_display_time % (osdConfig()->hud_radar_alt_difference_display_time + osdConfig()->hud_radar_distance_display_time))) ) { // For Radar and WPs, display the difference in altitude, then distance. Time is pilot defined altc = poiAltitude; @@ -287,11 +288,13 @@ void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitu } } - osdHudWrite(poi_x - 1, poi_y + 1, buff[0], 1); - osdHudWrite(poi_x , poi_y + 1, buff[1], 1); - osdHudWrite(poi_x + 1, poi_y + 1, buff[2], 1); - if (poiType == 1) { - osdHudWrite(poi_x + 2, poi_y + 1, buff[3], 1); + if (poiType != 3){ + osdHudWrite(poi_x - 1, poi_y + 1, buff[0], 1); + osdHudWrite(poi_x , poi_y + 1, buff[1], 1); + osdHudWrite(poi_x + 1, poi_y + 1, buff[2], 1); + if (poiType == 1) { + osdHudWrite(poi_x + 2, poi_y + 1, buff[3], 1); + } } }