Plane: add arm/disarm on aux switch

This commit is contained in:
Peter Barker 2018-09-05 14:22:14 +10:00 committed by Andrew Tridgell
parent 93d99dacd1
commit 4ad1869f43
3 changed files with 43 additions and 0 deletions

View File

@ -150,6 +150,7 @@ public:
friend class AP_AdvancedFailsafe_Plane;
friend class AP_Avoidance_Plane;
friend class GCS_Plane;
friend class RC_Channel_Plane;
friend class RC_Channels_Plane;
Plane(void);

View File

@ -26,3 +26,40 @@ bool RC_Channels_Plane::has_valid_input() const
}
return true;
}
void RC_Channel_Plane::init_aux_function(const RC_Channel::aux_func_t ch_option,
const RC_Channel::aux_switch_pos_t ch_flag)
{
switch(ch_option) {
// the following functions do not need to be initialised:
case ARMDISARM:
break;
default:
RC_Channel::init_aux_function(ch_option, ch_flag);
break;
}
}
// do_aux_function - implement the function invoked by auxillary switches
void RC_Channel_Plane::do_aux_function(const aux_func_t ch_option, const aux_switch_pos_t ch_flag)
{
switch(ch_option) {
case ARMDISARM:
// arm or disarm the vehicle
switch (ch_flag) {
case HIGH:
plane.arm_motors(AP_Arming::ArmingMethod::AUXSWITCH, true);
break;
case MIDDLE:
// nothing
break;
case LOW:
plane.disarm_motors();
break;
}
break;
default:
RC_Channel::do_aux_function(ch_option, ch_flag);
break;
}
}

View File

@ -9,6 +9,11 @@ public:
protected:
void init_aux_function(aux_func_t ch_option,
aux_switch_pos_t ch_flag) override;
void do_aux_function(aux_func_t ch_option, aux_switch_pos_t) override;
private:
};