Skip to content

Commit

Permalink
AP_OSD:add Aviation style AH option
Browse files Browse the repository at this point in the history
  • Loading branch information
Hwurzburg authored and tridge committed Sep 12, 2023
1 parent 2365f5c commit 63136e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libraries/AP_OSD/AP_OSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const AP_Param::GroupInfo AP_OSD::var_info[] = {
// @Param: _OPTIONS
// @DisplayName: OSD Options
// @Description: This sets options that change the display
// @Bitmask: 0:UseDecimalPack, 1:InvertedWindArrow, 2:InvertedAHRoll, 3:Convert feet to miles at 5280ft instead of 10000ft, 4:DisableCrosshair, 5:TranslateArrows
// @Bitmask: 0:UseDecimalPack, 1:InvertedWindArrow, 2:InvertedAHRoll, 3:Convert feet to miles at 5280ft instead of 10000ft, 4:DisableCrosshair, 5:TranslateArrows, 6:AviationStyleAH
// @User: Standard
AP_GROUPINFO("_OPTIONS", 8, AP_OSD, options, OPTION_DECIMAL_PACK),

Expand Down
1 change: 1 addition & 0 deletions libraries/AP_OSD/AP_OSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ class AP_OSD
OPTION_IMPERIAL_MILES = 1U<<3,
OPTION_DISABLE_CROSSHAIR = 1U<<4,
OPTION_BF_ARROWS = 1U<<5,
OPTION_AVIATION_AH = 1U<<6,
};

enum {
Expand Down
16 changes: 12 additions & 4 deletions libraries/AP_OSD/AP_OSD_Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1573,10 +1573,18 @@ void AP_OSD_Screen::draw_horizon(uint8_t x, uint8_t y)
WITH_SEMAPHORE(ahrs.get_semaphore());
float roll;
float pitch;
bool inverted = false;
AP::vehicle()->get_osd_roll_pitch_rad(roll,pitch);
pitch *= -1;

//inverted roll AH
// Are we inverted? then flash horizon line
if (abs(roll) >= radians(90)) {
inverted = true;
}
// Aviation style AH instead of Betaflight FPV style
if (inverted && check_option(AP_OSD::OPTION_AVIATION_AH)) {
pitch = -pitch;
}
//inverted roll AH (Russian HUD emulation)
if (check_option(AP_OSD::OPTION_INVERTED_AH_ROLL)) {
roll = -roll;
}
Expand All @@ -1595,7 +1603,7 @@ void AP_OSD_Screen::draw_horizon(uint8_t x, uint8_t y)
//chars in font in reversed order
c = SYMBOL(SYM_AH_H_START) + ((SYMBOL(SYM_AH_H_COUNT) - 1) - c);
if (dy >= -4 && dy <= 4) {
backend->write(x + dx, y - dy, false, "%c", c);
backend->write(x + dx, y - dy, inverted, "%c", c);
}
}
} else {
Expand All @@ -1605,7 +1613,7 @@ void AP_OSD_Screen::draw_horizon(uint8_t x, uint8_t y)
char c = (fx - dx) * SYMBOL(SYM_AH_V_COUNT);
c = SYMBOL(SYM_AH_V_START) + c;
if (dx >= -4 && dx <=4) {
backend->write(x + dx, y - dy, false, "%c", c);
backend->write(x + dx, y - dy, inverted, "%c", c);
}
}
}
Expand Down

0 comments on commit 63136e9

Please sign in to comment.