mirror of https://github.com/ArduPilot/ardupilot
Sub: Enforce configuration of a disarm button
This commit is contained in:
parent
210c2070a1
commit
f3634450d7
|
@ -12,11 +12,45 @@ bool AP_Arming_Sub::rc_calibration_checks(bool display_failure)
|
||||||
return rc_checks_copter_sub(display_failure, channels);
|
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)
|
bool AP_Arming_Sub::pre_arm_checks(bool display_failure)
|
||||||
{
|
{
|
||||||
if (armed) {
|
if (armed) {
|
||||||
return true;
|
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);
|
return AP_Arming::pre_arm_checks(display_failure);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ public:
|
||||||
|
|
||||||
bool rc_calibration_checks(bool display_failure) override;
|
bool rc_calibration_checks(bool display_failure) override;
|
||||||
bool pre_arm_checks(bool display_failure) override;
|
bool pre_arm_checks(bool display_failure) override;
|
||||||
|
const bool has_disarm_function();
|
||||||
|
|
||||||
bool disarm() override;
|
bool disarm() override;
|
||||||
bool arm(AP_Arming::Method method, bool do_arming_checks=true) override;
|
bool arm(AP_Arming::Method method, bool do_arming_checks=true) override;
|
||||||
|
|
Loading…
Reference in New Issue