2016-01-14 15:30:56 -04:00
|
|
|
#include "Sub.h"
|
2015-12-30 18:57:56 -04:00
|
|
|
|
|
|
|
// set_home_state - update home state
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::set_home_state(enum HomeState new_home_state)
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
|
|
|
// if no change, exit immediately
|
2017-02-03 17:33:27 -04:00
|
|
|
if (ap.home_state == new_home_state) {
|
2015-12-30 18:57:56 -04:00
|
|
|
return;
|
2017-02-03 17:33:27 -04:00
|
|
|
}
|
2015-12-30 18:57:56 -04:00
|
|
|
|
|
|
|
// update state
|
|
|
|
ap.home_state = new_home_state;
|
|
|
|
|
|
|
|
// log if home has been set
|
|
|
|
if (new_home_state == HOME_SET_NOT_LOCKED || new_home_state == HOME_SET_AND_LOCKED) {
|
|
|
|
Log_Write_Event(DATA_SET_HOME);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// home_is_set - returns true if home positions has been set (to GPS location, armed location or EKF origin)
|
2016-01-14 15:30:56 -04:00
|
|
|
bool Sub::home_is_set()
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
|
|
|
return (ap.home_state == HOME_SET_NOT_LOCKED || ap.home_state == HOME_SET_AND_LOCKED);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::set_auto_armed(bool b)
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
|
|
|
// if no change, exit immediately
|
2017-02-03 17:33:27 -04:00
|
|
|
if (ap.auto_armed == b) {
|
2015-12-30 18:57:56 -04:00
|
|
|
return;
|
2017-02-03 17:33:27 -04:00
|
|
|
}
|
2015-12-30 18:57:56 -04:00
|
|
|
|
|
|
|
ap.auto_armed = b;
|
2017-02-03 17:33:27 -04:00
|
|
|
if (b) {
|
2015-12-30 18:57:56 -04:00
|
|
|
Log_Write_Event(DATA_AUTO_ARMED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::set_simple_mode(uint8_t b)
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
2017-02-03 17:33:27 -04:00
|
|
|
if (ap.simple_mode != b) {
|
|
|
|
if (b == 0) {
|
2015-12-30 18:57:56 -04:00
|
|
|
Log_Write_Event(DATA_SET_SIMPLE_OFF);
|
2017-02-14 01:51:38 -04:00
|
|
|
gcs().send_statustext(MAV_SEVERITY_INFO, 0XFF, "SIMPLE mode off");
|
2017-02-03 17:33:27 -04:00
|
|
|
} else if (b == 1) {
|
2015-12-30 18:57:56 -04:00
|
|
|
Log_Write_Event(DATA_SET_SIMPLE_ON);
|
2017-02-14 01:51:38 -04:00
|
|
|
gcs().send_statustext(MAV_SEVERITY_INFO, 0XFF, "SIMPLE mode on");
|
2017-02-03 17:33:27 -04:00
|
|
|
} else {
|
2015-12-30 18:57:56 -04:00
|
|
|
// initialise super simple heading
|
|
|
|
update_super_simple_bearing(true);
|
|
|
|
Log_Write_Event(DATA_SET_SUPERSIMPLE_ON);
|
2017-02-14 01:51:38 -04:00
|
|
|
gcs().send_statustext(MAV_SEVERITY_INFO, 0XFF, "SUPERSIMPLE mode on");
|
2015-12-30 18:57:56 -04:00
|
|
|
}
|
|
|
|
ap.simple_mode = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::set_failsafe_battery(bool b)
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
|
|
|
failsafe.battery = b;
|
|
|
|
AP_Notify::flags.failsafe_battery = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
|
|
|
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::set_pre_arm_check(bool b)
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
2017-02-03 17:33:27 -04:00
|
|
|
if (ap.pre_arm_check != b) {
|
2015-12-30 18:57:56 -04:00
|
|
|
ap.pre_arm_check = b;
|
|
|
|
AP_Notify::flags.pre_arm_check = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::set_pre_arm_rc_check(bool b)
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
2017-02-03 17:33:27 -04:00
|
|
|
if (ap.pre_arm_rc_check != b) {
|
2015-12-30 18:57:56 -04:00
|
|
|
ap.pre_arm_rc_check = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::update_using_interlock()
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
2016-11-25 20:25:35 -04:00
|
|
|
// check if we are using motor interlock control on an aux switch
|
|
|
|
ap.using_interlock = check_if_auxsw_mode_used(AUXSW_MOTOR_INTERLOCK);
|
2015-12-30 18:57:56 -04:00
|
|
|
}
|
|
|
|
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::set_motor_emergency_stop(bool b)
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
2017-02-03 17:33:27 -04:00
|
|
|
if (ap.motor_emergency_stop != b) {
|
2015-12-30 18:57:56 -04:00
|
|
|
ap.motor_emergency_stop = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Log new status
|
2017-02-03 17:33:27 -04:00
|
|
|
if (ap.motor_emergency_stop) {
|
2015-12-30 18:57:56 -04:00
|
|
|
Log_Write_Event(DATA_MOTORS_EMERGENCY_STOPPED);
|
|
|
|
} else {
|
|
|
|
Log_Write_Event(DATA_MOTORS_EMERGENCY_STOP_CLEARED);
|
|
|
|
}
|
|
|
|
}
|