mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-16 08:29:15 +01:00
LP-339 Only allow switching to AutoTakeOff if disarmed state
This commit is contained in:
parent
298fc947b4
commit
fee9f7e071
@ -230,8 +230,9 @@ static void manualControlTask(void)
|
||||
FlightModeSettingsData modeSettings;
|
||||
FlightModeSettingsGet(&modeSettings);
|
||||
|
||||
static uint8_t lastPosition = 0;
|
||||
uint8_t position = cmd.FlightModeSwitchPosition;
|
||||
uint8_t newMode = flightStatus.FlightMode;
|
||||
uint8_t newMode = flightStatus.FlightMode;
|
||||
uint8_t newAlwaysStabilized = flightStatus.AlwaysStabilizeWhenArmed;
|
||||
uint8_t newFlightModeAssist = flightStatus.FlightModeAssist;
|
||||
uint8_t newAssistedControlState = flightStatus.AssistedControlState;
|
||||
@ -240,6 +241,13 @@ static void manualControlTask(void)
|
||||
newMode = modeSettings.FlightModePosition[position];
|
||||
}
|
||||
|
||||
// Ignore change to AutoTakeOff and keep last flight mode position
|
||||
// if vehicle is already armed and maybe in air...
|
||||
if ((newMode == FLIGHTSTATUS_FLIGHTMODE_AUTOTAKEOFF) && flightStatus.Armed) {
|
||||
newMode = flightStatus.FlightMode;
|
||||
position = lastPosition;
|
||||
}
|
||||
|
||||
// if a mode change occurs we default the assist mode and states here
|
||||
// to avoid having to add it to all of the below modes that are
|
||||
// otherwise unrelated
|
||||
@ -507,6 +515,7 @@ static void manualControlTask(void)
|
||||
flightStatus.AssistedThrottleState = newAssistedThrottleState;
|
||||
FlightStatusSet(&flightStatus);
|
||||
newinit = true;
|
||||
lastPosition = position;
|
||||
}
|
||||
if (handler->handler) {
|
||||
handler->handler(newinit);
|
||||
|
Loading…
x
Reference in New Issue
Block a user