Sub: Enforce configuration of a disarm button

This commit is contained in:
Justin 2019-07-08 12:44:25 -07:00 committed by Jacob Walser
parent 210c2070a1
commit f3634450d7
2 changed files with 35 additions and 0 deletions

View File

@ -12,11 +12,45 @@ bool AP_Arming_Sub::rc_calibration_checks(bool display_failure)
return rc_checks_copter_sub(display_failure, channels);
}
const bool AP_Arming_Sub::has_disarm_function () {
bool has_shift_function = false;
// make sure the craft has a disarm button assigned before it is armed
// check all the standard btn functions
for (uint8_t i = 0; i < 16; i++) {
switch (sub.get_button(i)->function(false)) {
case JSButton::k_shift :
has_shift_function = true;
break;
case JSButton::k_arm_toggle :
return true;
case JSButton::k_disarm :
return true;
}
}
// check all the shift functions if there's shift assigned
if (has_shift_function) {
for (uint8_t i = 0; i < 16; i++) {
switch (sub.get_button(i)->function(true)) {
case JSButton::k_arm_toggle :
case JSButton::k_disarm :
return true;
}
}
}
return false;
}
bool AP_Arming_Sub::pre_arm_checks(bool display_failure)
{
if (armed) {
return true;
}
// don't allow arming unless there is a disarm button configured
if (!has_disarm_function()) {
check_failed(ARMING_CHECK_NONE, display_failure, "Must assign a disarm or arm_toggle button");
return false;
}
return AP_Arming::pre_arm_checks(display_failure);
}

View File

@ -13,6 +13,7 @@ public:
bool rc_calibration_checks(bool display_failure) override;
bool pre_arm_checks(bool display_failure) override;
const bool has_disarm_function();
bool disarm() override;
bool arm(AP_Arming::Method method, bool do_arming_checks=true) override;