RC_Channel: factor out a do_aux_function_armdisarm method

This commit is contained in:
Peter Barker 2020-01-08 14:42:02 +11:00 committed by Peter Barker
parent a50b777179
commit ac25b90dda
2 changed files with 18 additions and 12 deletions

View File

@ -517,6 +517,22 @@ bool RC_Channel::read_aux()
}
void RC_Channel::do_aux_function_armdisarm(const aux_switch_pos_t ch_flag)
{
// arm or disarm the vehicle
switch (ch_flag) {
case HIGH:
AP::arming().arm(AP_Arming::Method::AUXSWITCH, true);
break;
case MIDDLE:
// nothing
break;
case LOW:
AP::arming().disarm();
break;
}
}
void RC_Channel::do_aux_function_avoid_adsb(const aux_switch_pos_t ch_flag)
{
AP_Avoidance *avoidance = AP::ap_avoidance();
@ -807,18 +823,7 @@ void RC_Channel::do_aux_function(const aux_func_t ch_option, const aux_switch_po
break;
case AUX_FUNC::ARMDISARM:
// arm or disarm the vehicle
switch (ch_flag) {
case HIGH:
AP::arming().arm(AP_Arming::Method::AUXSWITCH, true);
break;
case MIDDLE:
// nothing
break;
case LOW:
AP::arming().disarm();
break;
}
do_aux_function_armdisarm(ch_flag);
break;
case AUX_FUNC::COMPASS_LEARN:

View File

@ -202,6 +202,7 @@ protected:
virtual void init_aux_function(aux_func_t ch_option, aux_switch_pos_t);
virtual void do_aux_function(aux_func_t ch_option, aux_switch_pos_t);
virtual void do_aux_function_armdisarm(const aux_switch_pos_t ch_flag);
void do_aux_function_avoid_adsb(const aux_switch_pos_t ch_flag);
void do_aux_function_avoid_proximity(const aux_switch_pos_t ch_flag);
void do_aux_function_camera_trigger(const aux_switch_pos_t ch_flag);