Merge pull request #7072 from etracer65/osd_ah_invert
Add osd_ah_invert to allow reversing the direction of the OSD artificial horizon
This commit is contained in:
commit
ebeb473761
|
@ -1022,6 +1022,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_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_tim2", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, timers[OSD_TIMER_2]) },
|
||||
|
|
|
@ -755,8 +755,9 @@ static bool osdDrawSingleElement(uint8_t item)
|
|||
// Get pitch and roll limits in tenths of degrees
|
||||
const int maxPitch = osdConfig()->ahMaxPitch * 10;
|
||||
const int maxRoll = osdConfig()->ahMaxRoll * 10;
|
||||
const int rollAngle = constrain(attitude.values.roll, -maxRoll, maxRoll);
|
||||
int pitchAngle = constrain(attitude.values.pitch, -maxPitch, maxPitch);
|
||||
const int ahSign = osdConfig()->ahInvert ? -1 : 1;
|
||||
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
|
||||
// (maxPitch / 25) divisor matches previous settings of fixed divisor of 8 and fixed max AHI pitch angle of 20.0 degrees
|
||||
if (maxPitch > 0) {
|
||||
|
@ -1244,6 +1245,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
|
||||
osdConfig->ahMaxPitch = 20; // 20 degrees
|
||||
osdConfig->ahMaxRoll = 40; // 40 degrees
|
||||
osdConfig->ahInvert = false;
|
||||
}
|
||||
|
||||
static void osdDrawLogo(int x, int y)
|
||||
|
|
|
@ -205,6 +205,7 @@ typedef struct osdConfig_s {
|
|||
int16_t esc_rpm_alarm;
|
||||
int16_t esc_current_alarm;
|
||||
uint8_t core_temp_alarm;
|
||||
uint8_t ahInvert; // invert the artificial horizon
|
||||
} osdConfig_t;
|
||||
|
||||
PG_DECLARE(osdConfig_t, osdConfig);
|
||||
|
|
Loading…
Reference in New Issue