Skip to content

Commit 5db9896

Browse files
committed
implement flight direction, add type 3 for osdHudDrawPoi without any text output
1 parent 73dd921 commit 5db9896

File tree

3 files changed

+11
-51
lines changed

3 files changed

+11
-51
lines changed

src/main/io/osd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,9 +2774,7 @@ static bool osdDrawSingleElement(uint8_t item)
27742774
float direction_deg = RADIANS_TO_DEGREES(atan2f((float)vy, (float)vx));
27752775
int altitude_relative = (vz / 100);
27762776

2777-
//osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 0, SYM_ALERT, 0, 0);
2778-
osdHudDrawDirection((int16_t)direction_deg, altitude_relative, SYM_ALERT);
2779-
2777+
osdHudDrawPoi(0, (int16_t)direction_deg, altitude_relative, 3, SYM_ALERT, 0, 0);
27802778
}
27812779

27822780
// -------- POI : Nearby aircrafts from ESP32 radar

src/main/io/osd_hud.c

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -113,52 +113,13 @@ int8_t radarGetNearestPOI(void)
113113
return poi;
114114
}
115115

116-
void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol)
117-
{
118-
int poi_x = -1;
119-
int poi_y = -1;
120-
uint8_t center_x, center_y;
121-
122-
uint8_t minX = osdConfig()->hud_margin_h + 2;
123-
uint8_t maxX = osdGetDisplayPort()->cols - osdConfig()->hud_margin_h - 3;
124-
uint8_t minY = osdConfig()->hud_margin_v;
125-
uint8_t maxY = osdGetDisplayPort()->rows - osdConfig()->hud_margin_v - 2;
126-
127-
osdCrosshairPosition(&center_x, &center_y);
128-
129-
if (osdConfig()->pan_servo_pwm2centideg != 0) {
130-
poiDirection += osdGetPanServoOffset();
131-
}
132-
133-
int16_t error_x = hudWrap180(poiDirection - DECIDEGREES_TO_DEGREES(osdGetHeading()));
134-
135-
if ((error_x > -(osdConfig()->camera_fov_h / 2)) && (error_x < osdConfig()->camera_fov_h / 2)) {
136-
// Horizontalposition berechnen
137-
float scaled_x = sin_approx(DEGREES_TO_RADIANS(error_x)) / sin_approx(DEGREES_TO_RADIANS(osdConfig()->camera_fov_h / 2));
138-
poi_x = center_x + 15 * scaled_x;
139-
140-
if (poi_x >= minX && poi_x <= maxX) {
141-
// Vertikalposition berechnen
142-
float poi_angle = atan2_approx(-poiAltitude, 1.0f); // Abstand fest auf 1
143-
poi_angle = RADIANS_TO_DEGREES(poi_angle);
144-
int16_t plane_angle = attitude.values.pitch / 10;
145-
int camera_angle = osdConfig()->camera_uptilt;
146-
int16_t error_y = poi_angle - plane_angle + camera_angle;
147-
float scaled_y = sin_approx(DEGREES_TO_RADIANS(error_y)) / sin_approx(DEGREES_TO_RADIANS(osdConfig()->camera_fov_v / 2));
148-
poi_y = constrain(center_y + (osdGetDisplayPort()->rows / 2) * scaled_y, minY, maxY - 1);
149-
150-
// Symbol zeichnen
151-
osdHudWrite(poi_x, poi_y, poiSymbol, 1);
152-
}
153-
}
154-
}
155-
156116
/*
157117
* Display a POI as a 3D-marker on the hud
158118
* Distance (m), Direction (°), Altitude (relative, m, negative means below), Heading (°),
159119
* Type = 0 : Home point
160120
* Type = 1 : Radar POI, P1: Relative heading, P2: Signal, P3 Cardinal direction
161121
* Type = 2 : Waypoint, P1: WP number, P2: 1=WP+1, 2=WP+2, 3=WP+3
122+
* Type = 3 : Flight direction
162123
*/
163124
void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2)
164125
{
@@ -257,7 +218,7 @@ void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitu
257218

258219
// Distance
259220

260-
if (poiType > 0 &&
221+
if (poiType > 0 && poiType != 3 &&
261222
((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)))
262223
) { // For Radar and WPs, display the difference in altitude, then distance. Time is pilot defined
263224
altc = poiAltitude;
@@ -289,7 +250,7 @@ void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitu
289250
}
290251

291252
buff[0] = (poiAltitude >= 0) ? SYM_AH_DECORATION_UP : SYM_AH_DECORATION_DOWN;
292-
} else { // Display the distance by default
253+
} else { // Display the distance by default
293254
switch ((osd_unit_e)osdConfig()->units) {
294255
case OSD_UNIT_UK:
295256
FALLTHROUGH;
@@ -327,11 +288,13 @@ void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitu
327288
}
328289
}
329290

330-
osdHudWrite(poi_x - 1, poi_y + 1, buff[0], 1);
331-
osdHudWrite(poi_x , poi_y + 1, buff[1], 1);
332-
osdHudWrite(poi_x + 1, poi_y + 1, buff[2], 1);
333-
if (poiType == 1) {
334-
osdHudWrite(poi_x + 2, poi_y + 1, buff[3], 1);
291+
if (poiType != 3){
292+
osdHudWrite(poi_x - 1, poi_y + 1, buff[0], 1);
293+
osdHudWrite(poi_x , poi_y + 1, buff[1], 1);
294+
osdHudWrite(poi_x + 1, poi_y + 1, buff[2], 1);
295+
if (poiType == 1) {
296+
osdHudWrite(poi_x + 2, poi_y + 1, buff[3], 1);
297+
}
335298
}
336299
}
337300

src/main/io/osd_hud.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ void osdHudClear(void);
2727
void osdHudDrawCrosshair(displayCanvas_t *canvas, uint8_t px, uint8_t py);
2828
void osdHudDrawHoming(uint8_t px, uint8_t py);
2929
void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2);
30-
void osdHudDrawDirection(int16_t poiDirection, int32_t poiAltitude, uint16_t poiSymbol);
3130
int8_t radarGetNearestPOI(void);

0 commit comments

Comments
 (0)