From fc49f738c9b6a32f922f6d527aaff084402d044f Mon Sep 17 00:00:00 2001 From: timman2er Date: Mon, 27 Aug 2018 11:16:03 +0200 Subject: [PATCH] flip arrow turtle mode --- src/main/cms/cms_menu_osd.c | 1 + src/main/interface/settings.c | 1 + src/main/io/osd.c | 26 ++++++++++++++++++++++++++ src/main/io/osd.h | 1 + src/main/target/BEEBRAIN_V2F/config.c | 1 + 5 files changed, 30 insertions(+) diff --git a/src/main/cms/cms_menu_osd.c b/src/main/cms/cms_menu_osd.c index 95a7e603bd..bfdd5fc56e 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -103,6 +103,7 @@ OSD_Entry menuOsdActiveElemsEntries[] = {"HEADING", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_NUMERICAL_HEADING], 0}, {"VARIO", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_NUMERICAL_VARIO], 0}, {"G-FORCE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_G_FORCE], 0}, + {"FLIP ARROW", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_FLIP_ARROW], 0}, {"BACK", OME_Back, NULL, NULL, 0}, {NULL, OME_END, NULL, NULL, 0} }; diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index 1721ab5d18..17e45a79c9 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -1008,6 +1008,7 @@ const clivalue_t valueTable[] = { { "osd_esc_rpm_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ESC_RPM]) }, { "osd_rtc_date_time_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_RTC_DATETIME]) }, { "osd_adjustment_range_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ADJUSTMENT_RANGE]) }, + { "osd_flip_arrow_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_FLIP_ARROW]) }, #ifdef USE_ADC_INTERNAL { "osd_core_temp_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CORE_TEMPERATURE]) }, #endif diff --git a/src/main/io/osd.c b/src/main/io/osd.c index fdd29e1098..8f05781458 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -64,6 +64,7 @@ #include "fc/core.h" #include "fc/rc_adjustments.h" #include "fc/rc_controls.h" +#include "fc/rc_modes.h" #include "fc/rc.h" #include "fc/runtime_config.h" @@ -204,6 +205,7 @@ static const uint8_t osdElementDisplayOrder[] = { OSD_NUMERICAL_VARIO, OSD_COMPASS_BAR, OSD_ANTI_GRAVITY, + OSD_FLIP_ARROW, #ifdef USE_RTC_TIME OSD_RTC_DATETIME, #endif @@ -472,6 +474,30 @@ static bool osdDrawSingleElement(uint8_t item) char buff[OSD_ELEMENT_BUFFER_LENGTH] = ""; switch (item) { + case OSD_FLIP_ARROW: + { + const int angleR = attitude.values.roll; + const int angleP = attitude.values.pitch; // still gotta update all angleR and angleP pointers. + if (IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) { + if (angleP > 0 && ((angleR > 175 && angleR < 180) || (angleR > -180 && angleR < -175))) { + buff[0] = SYM_ARROW_SOUTH; + } else if (angleP > 0 && angleR > 0 && angleR < 175) { + buff[0] = (SYM_ARROW_EAST + 2); + } else if (angleP > 0 && angleR < 0 && angleR > -175) { + buff[0] = (SYM_ARROW_WEST + 2); + } else if (angleP <= 0 && ((angleR > 175 && angleR < 180) || (angleR > -180 && angleR < -175))) { + buff[0] = SYM_ARROW_NORTH; + } else if (angleP <= 0 && angleR > 0 && angleR < 175) { + buff[0] = (SYM_ARROW_NORTH + 2); + } else if (angleP <= 0 && angleR < 0 && angleR > -175) { + buff[0] = (SYM_ARROW_SOUTH + 2); + } + } else { + buff[0] = ' '; + } + buff[1] = '\0'; + break; + } case OSD_RSSI_VALUE: { uint16_t osdRssi = getRssi() * 100 / 1024; // change range diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 8a0adf3d72..680e596407 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -97,6 +97,7 @@ typedef enum { OSD_ANTI_GRAVITY, OSD_G_FORCE, OSD_LOG_STATUS, + OSD_FLIP_ARROW, OSD_ITEM_COUNT // MUST BE LAST } osd_items_e; diff --git a/src/main/target/BEEBRAIN_V2F/config.c b/src/main/target/BEEBRAIN_V2F/config.c index a81dfac074..ef7573702e 100644 --- a/src/main/target/BEEBRAIN_V2F/config.c +++ b/src/main/target/BEEBRAIN_V2F/config.c @@ -151,6 +151,7 @@ void targetConfiguration(void) osdConfigMutable()->item_pos[OSD_ESC_TMP] &= ~VISIBLE_FLAG; osdConfigMutable()->item_pos[OSD_ESC_RPM] &= ~VISIBLE_FLAG; osdConfigMutable()->item_pos[OSD_G_FORCE] &= ~VISIBLE_FLAG; + osdConfigMutable()->item_pos[OSD_FLIP_ARROW] &= ~VISIBLE_FLAG; modeActivationConditionsMutable(0)->modeId = BOXANGLE; modeActivationConditionsMutable(0)->auxChannelIndex = AUX2 - NON_AUX_CHANNEL_COUNT;