From 4aef3274e8c776846694cc6c7285ee5686faa94e Mon Sep 17 00:00:00 2001 From: druckgott Date: Thu, 1 May 2025 12:17:20 +0200 Subject: [PATCH 1/8] init vertical position is on the wrong side for home point and also for direction on my wing. --- docs/Settings.md | 10 ++++++++++ src/main/cms/cms_menu_osd.c | 1 + src/main/fc/settings.yaml | 5 +++++ src/main/io/osd.c | 26 +++++++++++++++++++++++++- src/main/io/osd.h | 1 + 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/Settings.md b/docs/Settings.md index d9b72a058e2..27b1ee1282b 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_flightpoint + +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..da4bf802c07 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 POINT", SETTING_OSD_HUD_FLIGHTPOINT), 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..deb06801faf 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_flightpoint + description: "To 3D-display the moving destination direction in the hud" + default_value: OFF + field: hud_flightpoint + 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..a440cd924ce 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_flightpoint) { osdHudClear(); } @@ -2764,6 +2764,29 @@ static bool osdDrawSingleElement(uint8_t item) osdHudDrawPoi(GPS_distanceToHome, GPS_directionToHome, -osdGetAltitude() / 100, 0, SYM_HOME, 0 , 0); } + // -------- POI : Flight direction + + if (osdConfig()->hud_flightpoint) { + int vx = getEstimatedActualVelocity(X); // in cm/s + int vy = getEstimatedActualVelocity(Y); // in cm/s + int vz = getEstimatedActualVelocity(Z); // in cm/s + + // Nur Richtung anzeigen, keine Vorausschau mehr + float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); + int altitude_relative = -(vz / 100); // als Höhe anzeigen (optional) + + // Flugrichtung nur darstellen, wenn relevante Bewegung vorhanden ist + osdHudDrawPoi( + 0, // Entfernung nicht nötig + (int16_t)direction_deg, // Richtung aus Geschwindigkeit + altitude_relative, // Vertikale Bewegung + 0, + SYM_ALERT, + 0, + 0 + ); + } + // -------- POI : Nearby aircrafts from ESP32 radar if (osdConfig()->hud_radar_disp > 0) { // Display the POI from the radar @@ -4143,6 +4166,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_flightpoint = SETTING_OSD_HUD_FLIGHTPOINT_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..acb72058c79 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_flightpoint; uint8_t hud_radar_disp; uint16_t hud_radar_range_min; uint16_t hud_radar_range_max; From 19b58ccd832029c1893fbad7d96b50f5796687a5 Mon Sep 17 00:00:00 2001 From: druckgott Date: Mon, 19 May 2025 18:13:14 +0200 Subject: [PATCH 2/8] Revert "init" This reverts commit 4aef3274e8c776846694cc6c7285ee5686faa94e. --- docs/Settings.md | 10 ---------- src/main/cms/cms_menu_osd.c | 1 - src/main/fc/settings.yaml | 5 ----- src/main/io/osd.c | 26 +------------------------- src/main/io/osd.h | 1 - 5 files changed, 1 insertion(+), 42 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 27b1ee1282b..d9b72a058e2 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -4832,16 +4832,6 @@ To vertically adjust the whole OSD and AHI and scrolling bars --- -### osd_hud_flightpoint - -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 da4bf802c07..0e85d0e656d 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -420,7 +420,6 @@ 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 POINT", SETTING_OSD_HUD_FLIGHTPOINT), 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 deb06801faf..74afae23d94 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -3512,11 +3512,6 @@ groups: default_value: OFF field: hud_homepoint type: bool - - name: osd_hud_flightpoint - description: "To 3D-display the moving destination direction in the hud" - default_value: OFF - field: hud_flightpoint - 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 a440cd924ce..d44ea0a8988 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 || osdConfig()->hud_flightpoint) { + if (osdConfig()->hud_homepoint || osdConfig()->hud_radar_disp > 0 || osdConfig()->hud_wp_disp > 0) { osdHudClear(); } @@ -2764,29 +2764,6 @@ static bool osdDrawSingleElement(uint8_t item) osdHudDrawPoi(GPS_distanceToHome, GPS_directionToHome, -osdGetAltitude() / 100, 0, SYM_HOME, 0 , 0); } - // -------- POI : Flight direction - - if (osdConfig()->hud_flightpoint) { - int vx = getEstimatedActualVelocity(X); // in cm/s - int vy = getEstimatedActualVelocity(Y); // in cm/s - int vz = getEstimatedActualVelocity(Z); // in cm/s - - // Nur Richtung anzeigen, keine Vorausschau mehr - float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); - int altitude_relative = -(vz / 100); // als Höhe anzeigen (optional) - - // Flugrichtung nur darstellen, wenn relevante Bewegung vorhanden ist - osdHudDrawPoi( - 0, // Entfernung nicht nötig - (int16_t)direction_deg, // Richtung aus Geschwindigkeit - altitude_relative, // Vertikale Bewegung - 0, - SYM_ALERT, - 0, - 0 - ); - } - // -------- POI : Nearby aircrafts from ESP32 radar if (osdConfig()->hud_radar_disp > 0) { // Display the POI from the radar @@ -4166,7 +4143,6 @@ 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_flightpoint = SETTING_OSD_HUD_FLIGHTPOINT_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 acb72058c79..b2e94b52729 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -429,7 +429,6 @@ typedef struct osdConfig_s { uint8_t hud_margin_v; bool hud_homing; bool hud_homepoint; - bool hud_flightpoint; uint8_t hud_radar_disp; uint16_t hud_radar_range_min; uint16_t hud_radar_range_max; From 4208b4651ea39d67522df77971be4fd27be43686 Mon Sep 17 00:00:00 2001 From: druckgott Date: Mon, 19 May 2025 18:51:01 +0200 Subject: [PATCH 3/8] add as extra icon --- docs/OSD.md | 1 + src/main/cms/cms_menu_osd.c | 1 + src/main/io/osd.c | 13 ++++++++++++ src/main/io/osd.h | 1 + src/main/io/osd_dji_hd.c | 1 + src/main/io/osd_hud.c | 40 +++++++++++++++++++++++++++++++++++++ src/main/io/osd_hud.h | 1 + 7 files changed, 58 insertions(+) diff --git a/docs/OSD.md b/docs/OSD.md index 1b86538718b..62580fcbc1a 100644 --- a/docs/OSD.md +++ b/docs/OSD.md @@ -197,6 +197,7 @@ Here are the OSD Elements provided by INAV. | 163 | OSD_COURSE_TO_FENCE | 8.0.0 | | | 164 | OSD_H_DIST_TO_FENCE | 8.0.0 | | | 165 | OSD_V_DIST_TO_FENCE | 8.0.0 | | +| 166 | OSD_FLIGHT_DIR | 9.0.0 | | # Pilot Logos diff --git a/src/main/cms/cms_menu_osd.c b/src/main/cms/cms_menu_osd.c index 0e85d0e656d..d6ed346e48c 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -204,6 +204,7 @@ static const OSD_Entry menuOsdElemsEntries[] = OSD_ELEMENT_ENTRY("BATT % REM", OSD_BATTERY_REMAINING_PERCENT), #ifdef USE_GPS OSD_ELEMENT_ENTRY("HOME DIR", OSD_HOME_DIR), + OSD_ELEMENT_ENTRY("FLIGHT_DIR", OSD_FLIGHT_DIR), OSD_ELEMENT_ENTRY("HOME HEAD. ERR", OSD_HOME_HEADING_ERROR), OSD_ELEMENT_ENTRY("HOME DIST", OSD_HOME_DIST), OSD_ELEMENT_ENTRY("TRIP DIST", OSD_TRIP_DIST), diff --git a/src/main/io/osd.c b/src/main/io/osd.c index d44ea0a8988..26d6e150c29 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1958,6 +1958,18 @@ static bool osdDrawSingleElement(uint8_t item) return true; } + case OSD_FLIGHT_DIR: + { + int16_t vx = getEstimatedActualVelocity(X); // in cm/s + int16_t vy = getEstimatedActualVelocity(Y); // in cm/s + int16_t vz = getEstimatedActualVelocity(Z); // in cm/s + float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); + int16_t altitude_relative = (vz / 100); // in m + //osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0); + osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT); + return true; + } + case OSD_HOME_HEADING_ERROR: { buff[0] = SYM_HOME; @@ -4251,6 +4263,7 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig) // OSD_VARIO_NUM at the right of OSD_VARIO osdLayoutsConfig->item_pos[0][OSD_VARIO_NUM] = OSD_POS(24, 7); osdLayoutsConfig->item_pos[0][OSD_HOME_DIR] = OSD_POS(14, 11); + osdLayoutsConfig->item_pos[0][OSD_FLIGHT_DIR] = OSD_POS(14, 12); osdLayoutsConfig->item_pos[0][OSD_ARTIFICIAL_HORIZON] = OSD_POS(8, 6); osdLayoutsConfig->item_pos[0][OSD_HORIZON_SIDEBARS] = OSD_POS(8, 6); diff --git a/src/main/io/osd.h b/src/main/io/osd.h index b2e94b52729..2605b57adf3 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -169,6 +169,7 @@ typedef enum { OSD_GPS_LON, OSD_GPS_LAT, OSD_HOME_DIR, + OSD_FLIGHT_DIR, OSD_HOME_DIST, OSD_HEADING, OSD_VARIO, diff --git a/src/main/io/osd_dji_hd.c b/src/main/io/osd_dji_hd.c index cf4f5f8872d..c0e12bdea22 100644 --- a/src/main/io/osd_dji_hd.c +++ b/src/main/io/osd_dji_hd.c @@ -190,6 +190,7 @@ const djiOsdMapping_t djiOSDItemIndexMap[] = { { -1, 0 }, // DJI: OSD_MAIN_BATT_USAGE { -1, 0 }, // DJI: OSD_DISARMED { OSD_HOME_DIR, FEATURE_GPS }, // DJI: OSD_HOME_DIR + { OSD_FLIGHT_DIR, FEATURE_GPS }, // DJI: OSD_FLIGHT_DIR { OSD_HOME_DIST, FEATURE_GPS }, // DJI: OSD_HOME_DIST { OSD_HEADING, 0 }, // DJI: OSD_NUMERICAL_HEADING { OSD_VARIO_NUM, 0 }, // DJI: OSD_NUMERICAL_VARIO diff --git a/src/main/io/osd_hud.c b/src/main/io/osd_hud.c index 8a6a68f467a..bb0d9107184 100644 --- a/src/main/io/osd_hud.c +++ b/src/main/io/osd_hud.c @@ -113,6 +113,46 @@ int8_t radarGetNearestPOI(void) return poi; } +void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol) +{ + int poi_x = -1; + int poi_y = -1; + uint8_t center_x, center_y; + + uint8_t minX = osdConfig()->hud_margin_h + 2; + uint8_t maxX = osdGetDisplayPort()->cols - osdConfig()->hud_margin_h - 3; + uint8_t minY = osdConfig()->hud_margin_v; + uint8_t maxY = osdGetDisplayPort()->rows - osdConfig()->hud_margin_v - 2; + + osdCrosshairPosition(¢er_x, ¢er_y); + + if (osdConfig()->pan_servo_pwm2centideg != 0) { + poiDirection += osdGetPanServoOffset(); + } + + int16_t error_x = hudWrap180(poiDirection - DECIDEGREES_TO_DEGREES(osdGetHeading())); + + if ((error_x > -(osdConfig()->camera_fov_h / 2)) && (error_x < osdConfig()->camera_fov_h / 2)) { + // Horizontalposition berechnen + float scaled_x = sin_approx(DEGREES_TO_RADIANS(error_x)) / sin_approx(DEGREES_TO_RADIANS(osdConfig()->camera_fov_h / 2)); + poi_x = center_x + 15 * scaled_x; + + if (poi_x >= minX && poi_x <= maxX) { + // Vertikalposition berechnen + float poi_angle = atan2_approx(-poiAltitude, 1.0f); // Abstand fest auf 1 + poi_angle = RADIANS_TO_DEGREES(poi_angle); + int16_t plane_angle = attitude.values.pitch / 10; + int camera_angle = osdConfig()->camera_uptilt; + int16_t error_y = poi_angle - plane_angle + camera_angle; + float scaled_y = sin_approx(DEGREES_TO_RADIANS(error_y)) / sin_approx(DEGREES_TO_RADIANS(osdConfig()->camera_fov_v / 2)); + poi_y = constrain(center_y + (osdGetDisplayPort()->rows / 2) * scaled_y, minY, maxY - 1); + + // Symbol zeichnen + osdHudWrite(poi_x, poi_y, poiSymbol, 1); + } + } +} + /* * Display a POI as a 3D-marker on the hud * Distance (m), Direction (°), Altitude (relative, m, negative means below), Heading (°), diff --git a/src/main/io/osd_hud.h b/src/main/io/osd_hud.h index b1aa1ab36f9..180336ba5b4 100644 --- a/src/main/io/osd_hud.h +++ b/src/main/io/osd_hud.h @@ -26,5 +26,6 @@ typedef struct displayCanvas_s displayCanvas_t; void osdHudClear(void); void osdHudDrawCrosshair(displayCanvas_t *canvas, uint8_t px, uint8_t py); void osdHudDrawHoming(uint8_t px, uint8_t py); +void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2); int8_t radarGetNearestPOI(void); From 78f574107206e47bc828017a1e946ca98649e460 Mon Sep 17 00:00:00 2001 From: druckgott Date: Sun, 18 May 2025 19:22:36 +0200 Subject: [PATCH 4/8] add extra function with only one symbol, invert vertical --- src/main/io/osd.c | 20 +++++++++++++++++++- src/main/io/osd.h | 1 + src/main/io/osd_hud.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 26d6e150c29..5cd4f60a863 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -2766,7 +2766,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(); } @@ -2776,6 +2776,23 @@ 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 + + // Nur Richtung anzeigen, keine Vorausschau mehr + float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); + int altitude_relative = (vz / 100); + + // Flugrichtung nur darstellen, wenn relevante Bewegung vorhanden ist + //osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0); + osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT); + + } + // -------- POI : Nearby aircrafts from ESP32 radar if (osdConfig()->hud_radar_disp > 0) { // Display the POI from the radar @@ -4155,6 +4172,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 2605b57adf3..c73d45011c3 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -430,6 +430,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.h b/src/main/io/osd_hud.h index 180336ba5b4..61622c9a828 100644 --- a/src/main/io/osd_hud.h +++ b/src/main/io/osd_hud.h @@ -28,4 +28,5 @@ void osdHudDrawCrosshair(displayCanvas_t *canvas, uint8_t px, uint8_t py); void osdHudDrawHoming(uint8_t px, uint8_t py); void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2); +void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); int8_t radarGetNearestPOI(void); From d8853d98de26f030e3253a01fe2282f75f70107b Mon Sep 17 00:00:00 2001 From: druckgott Date: Wed, 21 May 2025 08:10:35 +0200 Subject: [PATCH 5/8] Implementation --- docs/OSD.md | 1 - docs/Settings.md | 10 ++++++++++ src/main/cms/cms_menu_osd.c | 2 +- src/main/fc/settings.yaml | 5 +++++ src/main/io/osd.c | 19 ++----------------- src/main/io/osd.h | 1 - src/main/io/osd_dji_hd.c | 1 - src/main/io/osd_hud.h | 1 - 8 files changed, 18 insertions(+), 22 deletions(-) diff --git a/docs/OSD.md b/docs/OSD.md index 62580fcbc1a..1b86538718b 100644 --- a/docs/OSD.md +++ b/docs/OSD.md @@ -197,7 +197,6 @@ Here are the OSD Elements provided by INAV. | 163 | OSD_COURSE_TO_FENCE | 8.0.0 | | | 164 | OSD_H_DIST_TO_FENCE | 8.0.0 | | | 165 | OSD_V_DIST_TO_FENCE | 8.0.0 | | -| 166 | OSD_FLIGHT_DIR | 9.0.0 | | # Pilot Logos 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 d6ed346e48c..db54fcf966f 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -204,7 +204,6 @@ static const OSD_Entry menuOsdElemsEntries[] = OSD_ELEMENT_ENTRY("BATT % REM", OSD_BATTERY_REMAINING_PERCENT), #ifdef USE_GPS OSD_ELEMENT_ENTRY("HOME DIR", OSD_HOME_DIR), - OSD_ELEMENT_ENTRY("FLIGHT_DIR", OSD_FLIGHT_DIR), OSD_ELEMENT_ENTRY("HOME HEAD. ERR", OSD_HOME_HEADING_ERROR), OSD_ELEMENT_ENTRY("HOME DIST", OSD_HOME_DIST), OSD_ELEMENT_ENTRY("TRIP DIST", OSD_TRIP_DIST), @@ -421,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 5cd4f60a863..44add690f44 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1958,18 +1958,6 @@ static bool osdDrawSingleElement(uint8_t item) return true; } - case OSD_FLIGHT_DIR: - { - int16_t vx = getEstimatedActualVelocity(X); // in cm/s - int16_t vy = getEstimatedActualVelocity(Y); // in cm/s - int16_t vz = getEstimatedActualVelocity(Z); // in cm/s - float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); - int16_t altitude_relative = (vz / 100); // in m - //osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0); - osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT); - return true; - } - case OSD_HOME_HEADING_ERROR: { buff[0] = SYM_HOME; @@ -2782,12 +2770,10 @@ static bool osdDrawSingleElement(uint8_t item) int vx = getEstimatedActualVelocity(X); // in cm/s int vy = getEstimatedActualVelocity(Y); // in cm/s int vz = getEstimatedActualVelocity(Z); // in cm/s - - // Nur Richtung anzeigen, keine Vorausschau mehr + float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); int altitude_relative = (vz / 100); - - // Flugrichtung nur darstellen, wenn relevante Bewegung vorhanden ist + //osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0); osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT); @@ -4281,7 +4267,6 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig) // OSD_VARIO_NUM at the right of OSD_VARIO osdLayoutsConfig->item_pos[0][OSD_VARIO_NUM] = OSD_POS(24, 7); osdLayoutsConfig->item_pos[0][OSD_HOME_DIR] = OSD_POS(14, 11); - osdLayoutsConfig->item_pos[0][OSD_FLIGHT_DIR] = OSD_POS(14, 12); osdLayoutsConfig->item_pos[0][OSD_ARTIFICIAL_HORIZON] = OSD_POS(8, 6); osdLayoutsConfig->item_pos[0][OSD_HORIZON_SIDEBARS] = OSD_POS(8, 6); diff --git a/src/main/io/osd.h b/src/main/io/osd.h index c73d45011c3..1ca764cd854 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -169,7 +169,6 @@ typedef enum { OSD_GPS_LON, OSD_GPS_LAT, OSD_HOME_DIR, - OSD_FLIGHT_DIR, OSD_HOME_DIST, OSD_HEADING, OSD_VARIO, diff --git a/src/main/io/osd_dji_hd.c b/src/main/io/osd_dji_hd.c index c0e12bdea22..cf4f5f8872d 100644 --- a/src/main/io/osd_dji_hd.c +++ b/src/main/io/osd_dji_hd.c @@ -190,7 +190,6 @@ const djiOsdMapping_t djiOSDItemIndexMap[] = { { -1, 0 }, // DJI: OSD_MAIN_BATT_USAGE { -1, 0 }, // DJI: OSD_DISARMED { OSD_HOME_DIR, FEATURE_GPS }, // DJI: OSD_HOME_DIR - { OSD_FLIGHT_DIR, FEATURE_GPS }, // DJI: OSD_FLIGHT_DIR { OSD_HOME_DIST, FEATURE_GPS }, // DJI: OSD_HOME_DIST { OSD_HEADING, 0 }, // DJI: OSD_NUMERICAL_HEADING { OSD_VARIO_NUM, 0 }, // DJI: OSD_NUMERICAL_VARIO diff --git a/src/main/io/osd_hud.h b/src/main/io/osd_hud.h index 61622c9a828..72236606c27 100644 --- a/src/main/io/osd_hud.h +++ b/src/main/io/osd_hud.h @@ -26,7 +26,6 @@ typedef struct displayCanvas_s displayCanvas_t; void osdHudClear(void); void osdHudDrawCrosshair(displayCanvas_t *canvas, uint8_t px, uint8_t py); void osdHudDrawHoming(uint8_t px, uint8_t py); -void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2); void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); int8_t radarGetNearestPOI(void); From 36895b81ee2c6639a45b8c8f2c74a42ae220c0b7 Mon Sep 17 00:00:00 2001 From: druckgott Date: Thu, 1 May 2025 12:17:20 +0200 Subject: [PATCH 6/8] add extra function with only one symbol, invert vertical Revert "init" This reverts commit 4aef3274e8c776846694cc6c7285ee5686faa94e. add as extra icon init vertical position is on the wrong side for home point and also for direction on my wing. --- docs/OSD.md | 1 + src/main/cms/cms_menu_osd.c | 1 + src/main/io/osd.c | 33 +++++++++++++++++++++++++++++- src/main/io/osd.h | 2 ++ src/main/io/osd_dji_hd.c | 1 + src/main/io/osd_hud.c | 40 +++++++++++++++++++++++++++++++++++++ src/main/io/osd_hud.h | 2 ++ 7 files changed, 79 insertions(+), 1 deletion(-) diff --git a/docs/OSD.md b/docs/OSD.md index 1b86538718b..62580fcbc1a 100644 --- a/docs/OSD.md +++ b/docs/OSD.md @@ -197,6 +197,7 @@ Here are the OSD Elements provided by INAV. | 163 | OSD_COURSE_TO_FENCE | 8.0.0 | | | 164 | OSD_H_DIST_TO_FENCE | 8.0.0 | | | 165 | OSD_V_DIST_TO_FENCE | 8.0.0 | | +| 166 | OSD_FLIGHT_DIR | 9.0.0 | | # Pilot Logos diff --git a/src/main/cms/cms_menu_osd.c b/src/main/cms/cms_menu_osd.c index 0e85d0e656d..d6ed346e48c 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -204,6 +204,7 @@ static const OSD_Entry menuOsdElemsEntries[] = OSD_ELEMENT_ENTRY("BATT % REM", OSD_BATTERY_REMAINING_PERCENT), #ifdef USE_GPS OSD_ELEMENT_ENTRY("HOME DIR", OSD_HOME_DIR), + OSD_ELEMENT_ENTRY("FLIGHT_DIR", OSD_FLIGHT_DIR), OSD_ELEMENT_ENTRY("HOME HEAD. ERR", OSD_HOME_HEADING_ERROR), OSD_ELEMENT_ENTRY("HOME DIST", OSD_HOME_DIST), OSD_ELEMENT_ENTRY("TRIP DIST", OSD_TRIP_DIST), diff --git a/src/main/io/osd.c b/src/main/io/osd.c index d44ea0a8988..5cd4f60a863 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1958,6 +1958,18 @@ static bool osdDrawSingleElement(uint8_t item) return true; } + case OSD_FLIGHT_DIR: + { + int16_t vx = getEstimatedActualVelocity(X); // in cm/s + int16_t vy = getEstimatedActualVelocity(Y); // in cm/s + int16_t vz = getEstimatedActualVelocity(Z); // in cm/s + float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); + int16_t altitude_relative = (vz / 100); // in m + //osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0); + osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT); + return true; + } + case OSD_HOME_HEADING_ERROR: { buff[0] = SYM_HOME; @@ -2754,7 +2766,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 +2776,23 @@ 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 + + // Nur Richtung anzeigen, keine Vorausschau mehr + float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); + int altitude_relative = (vz / 100); + + // Flugrichtung nur darstellen, wenn relevante Bewegung vorhanden ist + //osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0); + osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT); + + } + // -------- POI : Nearby aircrafts from ESP32 radar if (osdConfig()->hud_radar_disp > 0) { // Display the POI from the radar @@ -4143,6 +4172,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, @@ -4251,6 +4281,7 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig) // OSD_VARIO_NUM at the right of OSD_VARIO osdLayoutsConfig->item_pos[0][OSD_VARIO_NUM] = OSD_POS(24, 7); osdLayoutsConfig->item_pos[0][OSD_HOME_DIR] = OSD_POS(14, 11); + osdLayoutsConfig->item_pos[0][OSD_FLIGHT_DIR] = OSD_POS(14, 12); osdLayoutsConfig->item_pos[0][OSD_ARTIFICIAL_HORIZON] = OSD_POS(8, 6); osdLayoutsConfig->item_pos[0][OSD_HORIZON_SIDEBARS] = OSD_POS(8, 6); diff --git a/src/main/io/osd.h b/src/main/io/osd.h index b2e94b52729..c73d45011c3 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -169,6 +169,7 @@ typedef enum { OSD_GPS_LON, OSD_GPS_LAT, OSD_HOME_DIR, + OSD_FLIGHT_DIR, OSD_HOME_DIST, OSD_HEADING, OSD_VARIO, @@ -429,6 +430,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_dji_hd.c b/src/main/io/osd_dji_hd.c index cf4f5f8872d..c0e12bdea22 100644 --- a/src/main/io/osd_dji_hd.c +++ b/src/main/io/osd_dji_hd.c @@ -190,6 +190,7 @@ const djiOsdMapping_t djiOSDItemIndexMap[] = { { -1, 0 }, // DJI: OSD_MAIN_BATT_USAGE { -1, 0 }, // DJI: OSD_DISARMED { OSD_HOME_DIR, FEATURE_GPS }, // DJI: OSD_HOME_DIR + { OSD_FLIGHT_DIR, FEATURE_GPS }, // DJI: OSD_FLIGHT_DIR { OSD_HOME_DIST, FEATURE_GPS }, // DJI: OSD_HOME_DIST { OSD_HEADING, 0 }, // DJI: OSD_NUMERICAL_HEADING { OSD_VARIO_NUM, 0 }, // DJI: OSD_NUMERICAL_VARIO diff --git a/src/main/io/osd_hud.c b/src/main/io/osd_hud.c index 8a6a68f467a..bb0d9107184 100644 --- a/src/main/io/osd_hud.c +++ b/src/main/io/osd_hud.c @@ -113,6 +113,46 @@ int8_t radarGetNearestPOI(void) return poi; } +void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol) +{ + int poi_x = -1; + int poi_y = -1; + uint8_t center_x, center_y; + + uint8_t minX = osdConfig()->hud_margin_h + 2; + uint8_t maxX = osdGetDisplayPort()->cols - osdConfig()->hud_margin_h - 3; + uint8_t minY = osdConfig()->hud_margin_v; + uint8_t maxY = osdGetDisplayPort()->rows - osdConfig()->hud_margin_v - 2; + + osdCrosshairPosition(¢er_x, ¢er_y); + + if (osdConfig()->pan_servo_pwm2centideg != 0) { + poiDirection += osdGetPanServoOffset(); + } + + int16_t error_x = hudWrap180(poiDirection - DECIDEGREES_TO_DEGREES(osdGetHeading())); + + if ((error_x > -(osdConfig()->camera_fov_h / 2)) && (error_x < osdConfig()->camera_fov_h / 2)) { + // Horizontalposition berechnen + float scaled_x = sin_approx(DEGREES_TO_RADIANS(error_x)) / sin_approx(DEGREES_TO_RADIANS(osdConfig()->camera_fov_h / 2)); + poi_x = center_x + 15 * scaled_x; + + if (poi_x >= minX && poi_x <= maxX) { + // Vertikalposition berechnen + float poi_angle = atan2_approx(-poiAltitude, 1.0f); // Abstand fest auf 1 + poi_angle = RADIANS_TO_DEGREES(poi_angle); + int16_t plane_angle = attitude.values.pitch / 10; + int camera_angle = osdConfig()->camera_uptilt; + int16_t error_y = poi_angle - plane_angle + camera_angle; + float scaled_y = sin_approx(DEGREES_TO_RADIANS(error_y)) / sin_approx(DEGREES_TO_RADIANS(osdConfig()->camera_fov_v / 2)); + poi_y = constrain(center_y + (osdGetDisplayPort()->rows / 2) * scaled_y, minY, maxY - 1); + + // Symbol zeichnen + osdHudWrite(poi_x, poi_y, poiSymbol, 1); + } + } +} + /* * Display a POI as a 3D-marker on the hud * Distance (m), Direction (°), Altitude (relative, m, negative means below), Heading (°), diff --git a/src/main/io/osd_hud.h b/src/main/io/osd_hud.h index b1aa1ab36f9..61622c9a828 100644 --- a/src/main/io/osd_hud.h +++ b/src/main/io/osd_hud.h @@ -26,5 +26,7 @@ typedef struct displayCanvas_s displayCanvas_t; void osdHudClear(void); void osdHudDrawCrosshair(displayCanvas_t *canvas, uint8_t px, uint8_t py); void osdHudDrawHoming(uint8_t px, uint8_t py); +void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2); +void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); int8_t radarGetNearestPOI(void); From c8b728471578457bf5617a35561564fea2eb72a8 Mon Sep 17 00:00:00 2001 From: druckgott Date: Wed, 21 May 2025 08:10:35 +0200 Subject: [PATCH 7/8] Implementation --- docs/OSD.md | 1 - docs/Settings.md | 10 ++++++++++ src/main/cms/cms_menu_osd.c | 2 +- src/main/fc/settings.yaml | 5 +++++ src/main/io/osd.c | 19 ++----------------- src/main/io/osd.h | 1 - src/main/io/osd_dji_hd.c | 1 - src/main/io/osd_hud.h | 1 - 8 files changed, 18 insertions(+), 22 deletions(-) diff --git a/docs/OSD.md b/docs/OSD.md index 62580fcbc1a..1b86538718b 100644 --- a/docs/OSD.md +++ b/docs/OSD.md @@ -197,7 +197,6 @@ Here are the OSD Elements provided by INAV. | 163 | OSD_COURSE_TO_FENCE | 8.0.0 | | | 164 | OSD_H_DIST_TO_FENCE | 8.0.0 | | | 165 | OSD_V_DIST_TO_FENCE | 8.0.0 | | -| 166 | OSD_FLIGHT_DIR | 9.0.0 | | # Pilot Logos 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 d6ed346e48c..db54fcf966f 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -204,7 +204,6 @@ static const OSD_Entry menuOsdElemsEntries[] = OSD_ELEMENT_ENTRY("BATT % REM", OSD_BATTERY_REMAINING_PERCENT), #ifdef USE_GPS OSD_ELEMENT_ENTRY("HOME DIR", OSD_HOME_DIR), - OSD_ELEMENT_ENTRY("FLIGHT_DIR", OSD_FLIGHT_DIR), OSD_ELEMENT_ENTRY("HOME HEAD. ERR", OSD_HOME_HEADING_ERROR), OSD_ELEMENT_ENTRY("HOME DIST", OSD_HOME_DIST), OSD_ELEMENT_ENTRY("TRIP DIST", OSD_TRIP_DIST), @@ -421,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 5cd4f60a863..44add690f44 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1958,18 +1958,6 @@ static bool osdDrawSingleElement(uint8_t item) return true; } - case OSD_FLIGHT_DIR: - { - int16_t vx = getEstimatedActualVelocity(X); // in cm/s - int16_t vy = getEstimatedActualVelocity(Y); // in cm/s - int16_t vz = getEstimatedActualVelocity(Z); // in cm/s - float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); - int16_t altitude_relative = (vz / 100); // in m - //osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0); - osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT); - return true; - } - case OSD_HOME_HEADING_ERROR: { buff[0] = SYM_HOME; @@ -2782,12 +2770,10 @@ static bool osdDrawSingleElement(uint8_t item) int vx = getEstimatedActualVelocity(X); // in cm/s int vy = getEstimatedActualVelocity(Y); // in cm/s int vz = getEstimatedActualVelocity(Z); // in cm/s - - // Nur Richtung anzeigen, keine Vorausschau mehr + float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); int altitude_relative = (vz / 100); - - // Flugrichtung nur darstellen, wenn relevante Bewegung vorhanden ist + //osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0); osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT); @@ -4281,7 +4267,6 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig) // OSD_VARIO_NUM at the right of OSD_VARIO osdLayoutsConfig->item_pos[0][OSD_VARIO_NUM] = OSD_POS(24, 7); osdLayoutsConfig->item_pos[0][OSD_HOME_DIR] = OSD_POS(14, 11); - osdLayoutsConfig->item_pos[0][OSD_FLIGHT_DIR] = OSD_POS(14, 12); osdLayoutsConfig->item_pos[0][OSD_ARTIFICIAL_HORIZON] = OSD_POS(8, 6); osdLayoutsConfig->item_pos[0][OSD_HORIZON_SIDEBARS] = OSD_POS(8, 6); diff --git a/src/main/io/osd.h b/src/main/io/osd.h index c73d45011c3..1ca764cd854 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -169,7 +169,6 @@ typedef enum { OSD_GPS_LON, OSD_GPS_LAT, OSD_HOME_DIR, - OSD_FLIGHT_DIR, OSD_HOME_DIST, OSD_HEADING, OSD_VARIO, diff --git a/src/main/io/osd_dji_hd.c b/src/main/io/osd_dji_hd.c index c0e12bdea22..cf4f5f8872d 100644 --- a/src/main/io/osd_dji_hd.c +++ b/src/main/io/osd_dji_hd.c @@ -190,7 +190,6 @@ const djiOsdMapping_t djiOSDItemIndexMap[] = { { -1, 0 }, // DJI: OSD_MAIN_BATT_USAGE { -1, 0 }, // DJI: OSD_DISARMED { OSD_HOME_DIR, FEATURE_GPS }, // DJI: OSD_HOME_DIR - { OSD_FLIGHT_DIR, FEATURE_GPS }, // DJI: OSD_FLIGHT_DIR { OSD_HOME_DIST, FEATURE_GPS }, // DJI: OSD_HOME_DIST { OSD_HEADING, 0 }, // DJI: OSD_NUMERICAL_HEADING { OSD_VARIO_NUM, 0 }, // DJI: OSD_NUMERICAL_VARIO diff --git a/src/main/io/osd_hud.h b/src/main/io/osd_hud.h index 61622c9a828..72236606c27 100644 --- a/src/main/io/osd_hud.h +++ b/src/main/io/osd_hud.h @@ -26,7 +26,6 @@ typedef struct displayCanvas_s displayCanvas_t; void osdHudClear(void); void osdHudDrawCrosshair(displayCanvas_t *canvas, uint8_t px, uint8_t py); void osdHudDrawHoming(uint8_t px, uint8_t py); -void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2); void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); int8_t radarGetNearestPOI(void); From 27f8cba5c98d4d6f9700555a796de53ab02b7f90 Mon Sep 17 00:00:00 2001 From: druckgott Date: Fri, 23 May 2025 12:42:54 +0200 Subject: [PATCH 8/8] implement flight direction, add type 3 for osdHudDrawPoi without any text output --- src/main/io/osd.c | 5 +--- src/main/io/osd_hud.c | 55 +++++++------------------------------------ src/main/io/osd_hud.h | 1 - 3 files changed, 10 insertions(+), 51 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 44add690f44..9f7f339b7d1 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -2773,10 +2773,7 @@ static bool osdDrawSingleElement(uint8_t item) float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx)); int altitude_relative = (vz / 100); - - //osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0); - osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT); - + osdHudDrawPoi(1, (int16_t)direction_deg, altitude_relative, 3, SYM_ALERT, 0, 0); } // -------- POI : Nearby aircrafts from ESP32 radar diff --git a/src/main/io/osd_hud.c b/src/main/io/osd_hud.c index bb0d9107184..d2432484a98 100644 --- a/src/main/io/osd_hud.c +++ b/src/main/io/osd_hud.c @@ -113,52 +113,13 @@ int8_t radarGetNearestPOI(void) return poi; } -void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol) -{ - int poi_x = -1; - int poi_y = -1; - uint8_t center_x, center_y; - - uint8_t minX = osdConfig()->hud_margin_h + 2; - uint8_t maxX = osdGetDisplayPort()->cols - osdConfig()->hud_margin_h - 3; - uint8_t minY = osdConfig()->hud_margin_v; - uint8_t maxY = osdGetDisplayPort()->rows - osdConfig()->hud_margin_v - 2; - - osdCrosshairPosition(¢er_x, ¢er_y); - - if (osdConfig()->pan_servo_pwm2centideg != 0) { - poiDirection += osdGetPanServoOffset(); - } - - int16_t error_x = hudWrap180(poiDirection - DECIDEGREES_TO_DEGREES(osdGetHeading())); - - if ((error_x > -(osdConfig()->camera_fov_h / 2)) && (error_x < osdConfig()->camera_fov_h / 2)) { - // Horizontalposition berechnen - float scaled_x = sin_approx(DEGREES_TO_RADIANS(error_x)) / sin_approx(DEGREES_TO_RADIANS(osdConfig()->camera_fov_h / 2)); - poi_x = center_x + 15 * scaled_x; - - if (poi_x >= minX && poi_x <= maxX) { - // Vertikalposition berechnen - float poi_angle = atan2_approx(-poiAltitude, 1.0f); // Abstand fest auf 1 - poi_angle = RADIANS_TO_DEGREES(poi_angle); - int16_t plane_angle = attitude.values.pitch / 10; - int camera_angle = osdConfig()->camera_uptilt; - int16_t error_y = poi_angle - plane_angle + camera_angle; - float scaled_y = sin_approx(DEGREES_TO_RADIANS(error_y)) / sin_approx(DEGREES_TO_RADIANS(osdConfig()->camera_fov_v / 2)); - poi_y = constrain(center_y + (osdGetDisplayPort()->rows / 2) * scaled_y, minY, maxY - 1); - - // Symbol zeichnen - osdHudWrite(poi_x, poi_y, poiSymbol, 1); - } - } -} - /* * Display a POI as a 3D-marker on the hud * Distance (m), Direction (°), Altitude (relative, m, negative means below), Heading (°), * 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) { @@ -257,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; @@ -327,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); + } } } diff --git a/src/main/io/osd_hud.h b/src/main/io/osd_hud.h index 72236606c27..b1aa1ab36f9 100644 --- a/src/main/io/osd_hud.h +++ b/src/main/io/osd_hud.h @@ -27,5 +27,4 @@ void osdHudClear(void); void osdHudDrawCrosshair(displayCanvas_t *canvas, uint8_t px, uint8_t py); void osdHudDrawHoming(uint8_t px, uint8_t py); void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2); -void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol); int8_t radarGetNearestPOI(void);