Plane: added arm_motors() and disarm_motors() helper functions

This commit is contained in:
Andrew Tridgell 2015-03-17 10:09:37 +11:00
parent 1f85a087ac
commit dd1059cecf
2 changed files with 41 additions and 0 deletions

View File

@ -151,6 +151,7 @@ static AP_Notify notify;
static void update_events(void);
void gcs_send_text_fmt(const prog_char_t *fmt, ...);
static void print_flight_mode(AP_HAL::BetterStream *port, uint8_t mode);
static bool arm_motors(AP_Arming::ArmingMethod method);
////////////////////////////////////////////////////////////////////////////////
// DataFlash

View File

@ -718,3 +718,43 @@ static void change_arm_state(void)
DataFlash.Log_Write_Mode(control_mode);
}
}
/*
arm motors
*/
static bool arm_motors(AP_Arming::ArmingMethod method)
{
if (!arming.arm(method)) {
return false;
}
//only log if arming was successful
channel_throttle->enable_out();
change_arm_state();
return true;
}
/*
disarm motors
*/
static bool disarm_motors(void)
{
if (!arming.disarm()) {
return false;
}
if (arming.arming_required() == AP_Arming::YES_ZERO_PWM) {
channel_throttle->disable_out();
}
if (control_mode != AUTO) {
// reset the mission on disarm if we are not in auto
mission.reset();
}
// suppress the throttle in auto-throttle modes
throttle_suppressed = auto_throttle_mode;
//only log if disarming was successful
change_arm_state();
return true;
}