Copter: Do not switch into a disabled flight mode
This commit is contained in:
parent
489551c9a4
commit
8e143aa637
@ -232,6 +232,7 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
||||
break;
|
||||
|
||||
case AUXSW_RTL:
|
||||
#if MODE_RTL_ENABLED == ENABLED
|
||||
if (ch_flag == AUX_SWITCH_HIGH) {
|
||||
// engage RTL (if not possible we remain in current flight mode)
|
||||
set_mode(RTL, MODE_REASON_TX_COMMAND);
|
||||
@ -241,6 +242,7 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
||||
reset_control_switch();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AUXSW_SAVE_TRIM:
|
||||
@ -249,8 +251,8 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
||||
}
|
||||
break;
|
||||
|
||||
#if MODE_AUTO_ENABLED == ENABLED
|
||||
case AUXSW_SAVE_WP:
|
||||
#if MODE_AUTO_ENABLED == ENABLED
|
||||
// save waypoint when switch is brought high
|
||||
if (ch_flag == AUX_SWITCH_HIGH) {
|
||||
|
||||
@ -302,14 +304,29 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
||||
Log_Write_Event(DATA_SAVEWP_ADD_WP);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AUXSW_MISSION_RESET:
|
||||
#if MODE_AUTO_ENABLED == ENABLED
|
||||
if (ch_flag == AUX_SWITCH_HIGH) {
|
||||
mission.reset();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AUXSW_AUTO:
|
||||
#if MODE_AUTO_ENABLED == ENABLED
|
||||
if (ch_flag == AUX_SWITCH_HIGH) {
|
||||
set_mode(AUTO, MODE_REASON_TX_COMMAND);
|
||||
} else {
|
||||
// return to flight mode switch's flight mode if we are currently in AUTO
|
||||
if (control_mode == AUTO) {
|
||||
reset_control_switch();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AUXSW_CAMERA_TRIGGER:
|
||||
#if CAMERA == ENABLED
|
||||
@ -385,17 +402,6 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AUXSW_AUTO:
|
||||
if (ch_flag == AUX_SWITCH_HIGH) {
|
||||
set_mode(AUTO, MODE_REASON_TX_COMMAND);
|
||||
} else {
|
||||
// return to flight mode switch's flight mode if we are currently in AUTO
|
||||
if (control_mode == AUTO) {
|
||||
reset_control_switch();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUXSW_AUTOTUNE:
|
||||
#if AUTOTUNE_ENABLED == ENABLED
|
||||
// turn on auto tuner
|
||||
@ -534,6 +540,7 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
||||
break;
|
||||
|
||||
case AUXSW_BRAKE:
|
||||
#if MODE_BRAKE_ENABLED == ENABLED
|
||||
// brake flight mode
|
||||
if (ch_flag == AUX_SWITCH_HIGH) {
|
||||
set_mode(BRAKE, MODE_REASON_TX_COMMAND);
|
||||
@ -543,6 +550,7 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
||||
reset_control_switch();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AUXSW_THROW:
|
||||
@ -612,6 +620,7 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
||||
break;
|
||||
|
||||
case AUXSW_SMART_RTL:
|
||||
#if MODE_SMARTRTL_ENABLED == ENABLED
|
||||
if (ch_flag == AUX_SWITCH_HIGH) {
|
||||
// engage SmartRTL (if not possible we remain in current flight mode)
|
||||
set_mode(SMART_RTL, MODE_REASON_TX_COMMAND);
|
||||
@ -621,8 +630,9 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
||||
reset_control_switch();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
||||
case AUXSW_INVERTED:
|
||||
#if FRAME_CONFIG == HELI_FRAME
|
||||
switch (ch_flag) {
|
||||
|
Loading…
Reference in New Issue
Block a user