diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index 91fe737d0f..13aaf554e7 100755 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -160,7 +160,8 @@ static const char * const featureNames[] = { "", "TELEMETRY", "CURRENT_METER", "3D", "RX_PARALLEL_PWM", "RX_MSP", "RSSI_ADC", "LED_STRIP", "DASHBOARD", "", "BLACKBOX", "CHANNEL_FORWARDING", "TRANSPONDER", "AIRMODE", - "SUPEREXPO", "VTX", "RX_SPI", "", "PWM_SERVO_DRIVER", "PWM_OUTPUT_ENABLE", "OSD", NULL + "SUPEREXPO", "VTX", "RX_SPI", "", "PWM_SERVO_DRIVER", "PWM_OUTPUT_ENABLE", "OSD", "FW_LAUNCH", NULL + }; /* Sensor names (used in lookup tables for *_hardware settings and in status command output) */ diff --git a/src/main/fc/config.h b/src/main/fc/config.h index d2b0833f28..ae9dc5263e 100644 --- a/src/main/fc/config.h +++ b/src/main/fc/config.h @@ -73,6 +73,7 @@ typedef enum { FEATURE_PWM_SERVO_DRIVER = 1 << 27, FEATURE_PWM_OUTPUT_ENABLE = 1 << 28, FEATURE_OSD = 1 << 29, + FEATURE_FW_LAUNCH = 1 << 30, } features_e; typedef struct systemConfig_s { diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index e48cd66448..5dba486f88 100755 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -188,7 +188,7 @@ static void updateArmingStatus(void) } /* CHECK: pitch / roll sticks centered when NAV_LAUNCH_MODE enabled */ - if (IS_RC_MODE_ACTIVE(BOXNAVLAUNCH)) { + if (isNavLaunchEnabled()) { if ((ABS(rcCommand[ROLL]) > rcControlsConfig()->pos_hold_deadband) || (ABS(rcCommand[PITCH]) > rcControlsConfig()->pos_hold_deadband)) { ENABLE_ARMING_FLAG(ARMING_DISABLED_ROLLPITCH_NOT_CENTERED); } else { diff --git a/src/main/fc/fc_msp_box.c b/src/main/fc/fc_msp_box.c index 934b9d4664..792f330b0d 100644 --- a/src/main/fc/fc_msp_box.c +++ b/src/main/fc/fc_msp_box.c @@ -187,7 +187,9 @@ void initActiveBoxIds(void) if (STATE(FIXED_WING)) { activeBoxIds[activeBoxIdCount++] = BOXMANUAL; - activeBoxIds[activeBoxIdCount++] = BOXNAVLAUNCH; + if (!feature(FEATURE_FW_LAUNCH)) { + activeBoxIds[activeBoxIdCount++] = BOXNAVLAUNCH; + } activeBoxIds[activeBoxIdCount++] = BOXAUTOTRIM; #if defined(AUTOTUNE_FIXED_WING) activeBoxIds[activeBoxIdCount++] = BOXAUTOTUNE; diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index d90c407ac0..517534bfb0 100755 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1232,6 +1232,14 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_LAUNCH_WAIT(navigationF return NAV_FSM_EVENT_SUCCESS; // NAV_STATE_LAUNCH_MOTOR_DELAY } + //allow to leave NAV_LAUNCH_MODE if it has being enabled as feature by moving sticks with low throttle. + if(feature(FEATURE_FW_LAUNCH)){ + throttleStatus_e throttleStatus = calculateThrottleStatus(); + if ((throttleStatus == THROTTLE_LOW) && ((ABS(rcCommand[ROLL]) > rcControlsConfig()->pos_hold_deadband) || (ABS(rcCommand[PITCH]) > rcControlsConfig()->pos_hold_deadband))){ + return NAV_FSM_EVENT_SWITCH_TO_IDLE; + } + } + return NAV_FSM_EVENT_NONE; } @@ -2345,7 +2353,7 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void) // LAUNCH mode has priority over any other NAV mode if (STATE(FIXED_WING)) { - if (IS_RC_MODE_ACTIVE(BOXNAVLAUNCH)) { // FIXME: Only available for fixed wing aircrafts now + if (isNavLaunchEnabled()) { // FIXME: Only available for fixed wing aircrafts now if (canActivateLaunchMode) { canActivateLaunchMode = false; return NAV_FSM_EVENT_SWITCH_TO_LAUNCH; @@ -2404,8 +2412,8 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void) else { canActivateWaypoint = false; - // Launch mode can only be activated if BOX is turned on prior to arming (avoid switching to LAUNCH in flight) - canActivateLaunchMode = IS_RC_MODE_ACTIVE(BOXNAVLAUNCH); + // Launch mode can be activated if feature FW_LAUNCH is enabled or BOX is turned on prior to arming (avoid switching to LAUNCH in flight) + canActivateLaunchMode = isNavLaunchEnabled(); } return NAV_FSM_EVENT_SWITCH_TO_IDLE; @@ -2470,7 +2478,7 @@ int8_t navigationGetHeadingControlState(void) bool navigationBlockArming(void) { const bool navBoxModesEnabled = IS_RC_MODE_ACTIVE(BOXNAVRTH) || IS_RC_MODE_ACTIVE(BOXNAVWP) || IS_RC_MODE_ACTIVE(BOXNAVPOSHOLD); - const bool navLaunchComboModesEnabled = IS_RC_MODE_ACTIVE(BOXNAVLAUNCH) && (IS_RC_MODE_ACTIVE(BOXNAVRTH) || IS_RC_MODE_ACTIVE(BOXNAVWP)); + const bool navLaunchComboModesEnabled = isNavLaunchEnabled() && (IS_RC_MODE_ACTIVE(BOXNAVRTH) || IS_RC_MODE_ACTIVE(BOXNAVWP)); bool shouldBlockArming = false; if (!navConfig()->general.flags.extra_arming_safety) @@ -2701,6 +2709,10 @@ bool navigationRTHAllowsLanding(void) (allow == NAV_RTH_ALLOW_LANDING_FS_ONLY && FLIGHT_MODE(FAILSAFE_MODE)); } +bool isNavLaunchEnabled(void) +{ + return IS_RC_MODE_ACTIVE(BOXNAVLAUNCH) || feature(FEATURE_FW_LAUNCH); +} #else // NAV #ifdef USE_GPS diff --git a/src/main/navigation/navigation.h b/src/main/navigation/navigation.h index 487dbeae7d..f60d756b6b 100755 --- a/src/main/navigation/navigation.h +++ b/src/main/navigation/navigation.h @@ -23,6 +23,8 @@ #include "io/gps.h" +#include "config/feature.h" + /* GPS Home location data */ extern gpsLocation_t GPS_home; extern uint16_t GPS_distanceToHome; // distance to home point in meters @@ -315,6 +317,8 @@ bool navigationIsFlyingAutonomousMode(void); */ bool navigationRTHAllowsLanding(void); +bool isNavLaunchEnabled(void); + /* Compatibility data */ extern navSystemStatus_t NAV_Status;