Skip to content

Commit adc1d88

Browse files
authored
Merge pull request #9609 from iNavFlight/MrD_Fix-AHI-when-inverted
Fix ahi pitch when inverted
2 parents 2713a8e + 2c98f3d commit adc1d88

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main/io/osd_canvas.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ static bool osdCanvasDrawArtificialHorizonWidget(displayPort_t *display, display
345345
int ahiWidth = osdConfig()->ahi_width;
346346
int ahiX = (canvas->width - ahiWidth) / 2;
347347
int ahiHeight = osdConfig()->ahi_height;
348-
int ahiY = ((canvas->height - ahiHeight) / 2) + osdConfig()->ahi_vertical_offset;
348+
int ahiY = ((canvas->height - ahiHeight) / 2);
349+
ahiY += osdConfig()->ahi_vertical_offset;
350+
349351
if (ahiY < 0) {
350352
ahiY = 0;
351353
}

src/main/io/osd_common.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "navigation/navigation.h"
4545
#include "sensors/pitotmeter.h"
4646

47-
4847
#if defined(USE_OSD) || defined(USE_DJI_HD_OSD)
4948

5049
PG_REGISTER_WITH_RESET_TEMPLATE(osdCommonConfig_t, osdCommonConfig, PG_OSD_COMMON_CONFIG, 0);
@@ -148,11 +147,17 @@ void osdDrawArtificialHorizon(displayPort_t *display, displayCanvas_t *canvas, c
148147
{
149148
uint8_t gx;
150149
uint8_t gy;
150+
151151
#if defined(USE_CANVAS)
152152
if (canvas) {
153153
osdCanvasDrawArtificialHorizon(display, canvas, p, pitchAngle, rollAngle);
154154
} else {
155155
#endif
156+
// Correct pitch when inverted
157+
if (rollAngle < -1.570796f || rollAngle > 1.570796f) {
158+
pitchAngle = -pitchAngle;
159+
}
160+
156161
osdDrawPointGetGrid(&gx, &gy, display, canvas, p);
157162
osdGridDrawArtificialHorizon(display, gx, gy, pitchAngle, rollAngle);
158163
#if defined(USE_CANVAS)

0 commit comments

Comments
 (0)