mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-01 21:48:28 -04:00
Copter: override do_aux_function_armdisarm method to set armed_with_switch
As well as removing the code duplication, this only sets the flag if arming was actually successful. armed-with-switch is used when setting various state, and it isn't entirely clear that we only use it when armed. This would seem to be a safer option.
This commit is contained in:
parent
ac25b90dda
commit
eb452478ac
@ -142,6 +142,16 @@ void RC_Channel_Copter::do_aux_function_change_mode(const Mode::Number mode,
|
||||
}
|
||||
}
|
||||
|
||||
void RC_Channel_Copter::do_aux_function_armdisarm(const aux_switch_pos_t ch_flag)
|
||||
{
|
||||
RC_Channel::do_aux_function_armdisarm(ch_flag);
|
||||
if (copter.arming.is_armed()) {
|
||||
// remember that we are using an arming switch, for use by
|
||||
// set_throttle_zero_flag
|
||||
copter.ap.armed_with_switch = true;
|
||||
}
|
||||
}
|
||||
|
||||
// do_aux_function - implement the function invoked by auxiliary switches
|
||||
void RC_Channel_Copter::do_aux_function(const aux_func_t ch_option, const aux_switch_pos_t ch_flag)
|
||||
{
|
||||
@ -380,23 +390,6 @@ void RC_Channel_Copter::do_aux_function(const aux_func_t ch_option, const aux_sw
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AUX_FUNC::ARMDISARM:
|
||||
// arm or disarm the vehicle
|
||||
switch (ch_flag) {
|
||||
case HIGH:
|
||||
copter.arming.arm(AP_Arming::Method::AUXSWITCH);
|
||||
// remember that we are using an arming switch, for use by set_throttle_zero_flag
|
||||
copter.ap.armed_with_switch = true;
|
||||
break;
|
||||
case MIDDLE:
|
||||
// nothing
|
||||
break;
|
||||
case LOW:
|
||||
copter.arming.disarm();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUX_FUNC::SMART_RTL:
|
||||
#if MODE_SMARTRTL_ENABLED == ENABLED
|
||||
do_aux_function_change_mode(Mode::Number::SMART_RTL, ch_flag);
|
||||
|
@ -15,6 +15,7 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
void do_aux_function_armdisarm(const aux_switch_pos_t ch_flag) override;
|
||||
void do_aux_function_change_mode(const Mode::Number mode,
|
||||
const aux_switch_pos_t ch_flag);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user