diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index bce6f644a8..c78ac6a88e 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -168,6 +168,11 @@ void pidSetItermAccelerator(float newItermAccelerator) itermAccelerator = newItermAccelerator; } +float pidItermAccelerator(void) +{ + return itermAccelerator; +} + void pidStabilisationState(pidStabilisationState_e pidControllerState) { pidStabilisationEnabled = (pidControllerState == PID_STABILISATION_ON) ? true : false; diff --git a/src/main/flight/pid.h b/src/main/flight/pid.h index 51a42e833e..37bba45d76 100644 --- a/src/main/flight/pid.h +++ b/src/main/flight/pid.h @@ -151,6 +151,7 @@ extern pt1Filter_t throttleLpf; void pidResetITerm(void); void pidStabilisationState(pidStabilisationState_e pidControllerState); void pidSetItermAccelerator(float newItermAccelerator); +float pidItermAccelerator(void); void pidInitFilters(const pidProfile_t *pidProfile); void pidInitConfig(const pidProfile_t *pidProfile); void pidInit(const pidProfile_t *pidProfile); diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index 78c63e19d8..d0b0366d07 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -839,6 +839,7 @@ const clivalue_t valueTable[] = { { "osd_tim_2_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ITEM_TIMER_2]) }, { "osd_remaining_time_estimate_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_REMAINING_TIME_ESTIMATE]) }, { "osd_flymode_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_FLYMODE]) }, + { "osd_anti_gravity_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ANTI_GRAVITY]) }, { "osd_throttle_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_THROTTLE_POS]) }, { "osd_vtx_channel_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_VTX_CHANNEL]) }, { "osd_crosshairs_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CROSSHAIRS]) }, diff --git a/src/main/io/osd.c b/src/main/io/osd.c index a0b5d9723d..5915fdf538 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -520,6 +520,15 @@ static bool osdDrawSingleElement(uint8_t item) break; } + case OSD_ANTI_GRAVITY: + { + if (pidItermAccelerator() > 1.0f) { + strcpy(buff, "AG"); + } + + break; + } + case OSD_CRAFT_NAME: // This does not strictly support iterative updating if the craft name changes at run time. But since the craft name is not supposed to be changing this should not matter, and blanking the entire length of the craft name string on update will make it impossible to configure elements to be displayed on the right hand side of the craft name. //TODO: When iterative updating is implemented, change this so the craft name is only printed once whenever the OSD 'flight' screen is entered. @@ -887,6 +896,7 @@ static void osdDrawElements(void) osdDrawSingleElement(OSD_NUMERICAL_HEADING); osdDrawSingleElement(OSD_NUMERICAL_VARIO); osdDrawSingleElement(OSD_COMPASS_BAR); + osdDrawSingleElement(OSD_ANTI_GRAVITY); #ifdef USE_GPS if (sensors(SENSOR_GPS)) { diff --git a/src/main/io/osd.h b/src/main/io/osd.h index c2798bda60..b98d9859cc 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -47,6 +47,8 @@ extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES]; #define OSD_TIMER_PRECISION(timer) ((timer >> 4) & 0x0F) #define OSD_TIMER_ALARM(timer) ((timer >> 8) & 0xFF) +// NB: to ensure backwards compatibility, new enum values must be appended at the end but before the OSD_XXXX_COUNT entry. + typedef enum { OSD_RSSI_VALUE, OSD_MAIN_BATT_VOLTAGE, @@ -89,6 +91,7 @@ typedef enum { OSD_RTC_DATETIME, OSD_ADJUSTMENT_RANGE, OSD_CORE_TEMPERATURE, + OSD_ANTI_GRAVITY, OSD_ITEM_COUNT // MUST BE LAST } osd_items_e; diff --git a/src/test/unit/osd_unittest.cc b/src/test/unit/osd_unittest.cc index d087cc269f..85e5147630 100644 --- a/src/test/unit/osd_unittest.cc +++ b/src/test/unit/osd_unittest.cc @@ -1020,4 +1020,6 @@ extern "C" { bool isFlipOverAfterCrashMode(void) { return false; } + + float pidItermAccelerator(void) { return 1.0; } }