diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index bf6aeb40cb..56f2a7027f 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -190,9 +190,6 @@ tables: - name: nav_fw_wp_turn_smoothing values: ["OFF", "ON", "ON-CUT"] enum: wpFwTurnSmoothing_e - - name: mixer_switch_on_event - values: ["OFF", "ON", "ON_FS_ONLY"] - enum: mixerProfileSwitchOnEvent_e constants: RPYL_PID_MIN: 0 @@ -1178,16 +1175,14 @@ groups: type: bool - name: mixer_switch_on_rth description: "If set to on, mixer_profile will switch when it is heading home" - default_value: "OFF" + default_value: OFF field: mixer_config.switchOnRTH - table: mixer_switch_on_event - type: uint8_t + type: bool - name: mixer_switch_on_land description: "If set to on, mixer_profile will switch when Landing" - default_value: "OFF" + default_value: OFF field: mixer_config.switchOnLand - table: mixer_switch_on_event - type: uint8_t + type: bool - name: mixer_switch_trans_timer description: "If swith mixer_profile on failsafe is required, Activate MixerTransion mode for this many decisecond(0.1s) before the actual mixer_profile switch" default_value: 0 diff --git a/src/main/flight/mixer_profile.c b/src/main/flight/mixer_profile.c index e264012e8c..044cb027ab 100644 --- a/src/main/flight/mixer_profile.c +++ b/src/main/flight/mixer_profile.c @@ -93,7 +93,7 @@ void mixerConfigInit(void) setConfigProfile(getConfigMixerProfile()); pidInit(); pidInitFilters(); - pidResetErrorAccumulators(); + // pidResetErrorAccumulators(); schedulePidGainsUpdate(); navigationUsePIDs(); // set navigation pid gains } @@ -118,24 +118,16 @@ bool checkMixerATRequired(mixerProfileATRequest_e required_action) return false; } - if ((required_action == MIXERAT_REQUEST_RTH) && (currentMixerConfig.switchOnRTH!=MIXERAT_ON_EVENT_OFF) && STATE(MULTIROTOR)) + if ((required_action == MIXERAT_REQUEST_RTH) && (currentMixerConfig.switchOnRTH) && STATE(MULTIROTOR)) { - if ((currentMixerConfig.switchOnRTH==MIXERAT_ON_EVENT_ON_FS_ONLY) && (!FLIGHT_MODE(FAILSAFE_MODE))) - { - return false; - } - //check next mixer_profile setting is valid - return mixerConfigByIndex(nextProfileIndex)->switchOnRTH == MIXERAT_ON_EVENT_OFF ? true:false; + //check next mixer_profile setting is valid, need to be false + return mixerConfigByIndex(nextProfileIndex)->switchOnRTH? false:true; } - else if ((required_action == MIXERAT_REQUEST_LAND) && (currentMixerConfig.switchOnLand!=MIXERAT_ON_EVENT_OFF) && STATE(AIRPLANE)) + else if ((required_action == MIXERAT_REQUEST_LAND) && (currentMixerConfig.switchOnLand) && STATE(AIRPLANE)) { - if ((currentMixerConfig.switchOnLand==MIXERAT_ON_EVENT_ON_FS_ONLY) && (!FLIGHT_MODE(FAILSAFE_MODE))) - { - return false; - } - //check next mixer_profile setting is valid - return mixerConfigByIndex(nextProfileIndex)->switchOnLand == MIXERAT_ON_EVENT_OFF ? true:false; + //check next mixer_profile setting is valid, need to be false + return mixerConfigByIndex(nextProfileIndex)->switchOnLand? false:true; } return false; } diff --git a/src/main/flight/mixer_profile.h b/src/main/flight/mixer_profile.h index b6016e7286..89d85ae7ab 100644 --- a/src/main/flight/mixer_profile.h +++ b/src/main/flight/mixer_profile.h @@ -9,12 +9,6 @@ #define MAX_MIXER_PROFILE_COUNT 2 #endif -typedef enum { - MIXERAT_ON_EVENT_OFF, //no request, stats checking only - MIXERAT_ON_EVENT_ON, - MIXERAT_ON_EVENT_ON_FS_ONLY, -} mixerProfileSwitchOnEvent_e; - typedef struct mixerConfig_s { int8_t motorDirectionInverted; uint8_t platformType; @@ -23,8 +17,8 @@ typedef struct mixerConfig_s { uint8_t outputMode; bool motorstopOnLow; bool PIDProfileLinking; - mixerProfileSwitchOnEvent_e switchOnRTH; - mixerProfileSwitchOnEvent_e switchOnLand; + bool switchOnRTH; + bool switchOnLand; int16_t switchTransitionTimer; } mixerConfig_t; typedef struct mixerProfile_s { diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index c63504c807..1bed5e11ad 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -982,14 +982,22 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .mwError = MW_NAV_ERROR_NONE, .onEvent = { [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_MIXERAT_IN_PROGRESS, // re-process the state - [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, - [NAV_FSM_EVENT_SWITCH_TO_RTH_HEAD_HOME] = NAV_STATE_RTH_HEAD_HOME, // re-process the state - [NAV_FSM_EVENT_SWITCH_TO_RTH_LANDING] = NAV_STATE_RTH_LANDING, + [NAV_FSM_EVENT_SWITCH_TO_RTH_HEAD_HOME] = NAV_STATE_RTH_HEAD_HOME, //switch to its pending state + [NAV_FSM_EVENT_SWITCH_TO_RTH_LANDING] = NAV_STATE_RTH_LANDING, //switch to its pending state + [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_MIXERAT_ABORT, + [NAV_FSM_EVENT_SWITCH_TO_ALTHOLD] = NAV_STATE_MIXERAT_ABORT, + [NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D] = NAV_STATE_MIXERAT_ABORT, + [NAV_FSM_EVENT_SWITCH_TO_RTH] = NAV_STATE_MIXERAT_ABORT, + [NAV_FSM_EVENT_SWITCH_TO_WAYPOINT] = NAV_STATE_MIXERAT_ABORT, + [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_MIXERAT_ABORT, + [NAV_FSM_EVENT_SWITCH_TO_LAUNCH] = NAV_STATE_MIXERAT_ABORT, + [NAV_FSM_EVENT_SWITCH_TO_COURSE_HOLD] = NAV_STATE_MIXERAT_ABORT, + [NAV_FSM_EVENT_SWITCH_TO_CRUISE] = NAV_STATE_MIXERAT_ABORT, } }, [NAV_STATE_MIXERAT_ABORT] = { .persistentId = NAV_PERSISTENT_ID_MIXERAT_ABORT, - .onEntry = navOnEnteringState_NAV_STATE_MIXERAT_ABORT, + .onEntry = navOnEnteringState_NAV_STATE_MIXERAT_ABORT, //will not switch to its pending state .timeoutMs = 10, .stateFlags = NAV_CTL_ALT | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT, .mapToFlightModes = NAV_ALTHOLD_MODE,