1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 12:25:20 +03:00

Add osd_ah_invert to allow reversing the direction of the OSD artificial horizon

This commit is contained in:
Bruce Luckcuck 2018-11-10 15:28:10 -05:00
parent b58e8f827f
commit b5cb1bf65a
3 changed files with 6 additions and 2 deletions

View file

@ -1024,6 +1024,7 @@ const clivalue_t valueTable[] = {
{ "osd_ah_max_pit", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxPitch) }, { "osd_ah_max_pit", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxPitch) },
{ "osd_ah_max_rol", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxRoll) }, { "osd_ah_max_rol", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxRoll) },
{ "osd_ah_invert", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahInvert) },
{ "osd_tim1", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, timers[OSD_TIMER_1]) }, { "osd_tim1", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, timers[OSD_TIMER_1]) },
{ "osd_tim2", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, timers[OSD_TIMER_2]) }, { "osd_tim2", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, timers[OSD_TIMER_2]) },

View file

@ -755,8 +755,9 @@ static bool osdDrawSingleElement(uint8_t item)
// Get pitch and roll limits in tenths of degrees // Get pitch and roll limits in tenths of degrees
const int maxPitch = osdConfig()->ahMaxPitch * 10; const int maxPitch = osdConfig()->ahMaxPitch * 10;
const int maxRoll = osdConfig()->ahMaxRoll * 10; const int maxRoll = osdConfig()->ahMaxRoll * 10;
const int rollAngle = constrain(attitude.values.roll, -maxRoll, maxRoll); const int ahSign = osdConfig()->ahInvert ? -1 : 1;
int pitchAngle = constrain(attitude.values.pitch, -maxPitch, maxPitch); const int rollAngle = constrain(attitude.values.roll * ahSign, -maxRoll, maxRoll);
int pitchAngle = constrain(attitude.values.pitch * ahSign, -maxPitch, maxPitch);
// Convert pitchAngle to y compensation value // Convert pitchAngle to y compensation value
// (maxPitch / 25) divisor matches previous settings of fixed divisor of 8 and fixed max AHI pitch angle of 20.0 degrees // (maxPitch / 25) divisor matches previous settings of fixed divisor of 8 and fixed max AHI pitch angle of 20.0 degrees
if (maxPitch > 0) { if (maxPitch > 0) {
@ -1244,6 +1245,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
osdConfig->ahMaxPitch = 20; // 20 degrees osdConfig->ahMaxPitch = 20; // 20 degrees
osdConfig->ahMaxRoll = 40; // 40 degrees osdConfig->ahMaxRoll = 40; // 40 degrees
osdConfig->ahInvert = false;
} }
static void osdDrawLogo(int x, int y) static void osdDrawLogo(int x, int y)

View file

@ -205,6 +205,7 @@ typedef struct osdConfig_s {
int16_t esc_rpm_alarm; int16_t esc_rpm_alarm;
int16_t esc_current_alarm; int16_t esc_current_alarm;
uint8_t core_temp_alarm; uint8_t core_temp_alarm;
uint8_t ahInvert; // invert the artificial horizon
} osdConfig_t; } osdConfig_t;
PG_DECLARE(osdConfig_t, osdConfig); PG_DECLARE(osdConfig_t, osdConfig);