ardupilot/ArduCopter/AP_State.pde

148 lines
3.3 KiB
Plaintext
Raw Normal View History

2012-11-10 01:43:43 -04:00
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
void set_home_is_set(bool b)
{
// if no change, exit immediately
if( ap.home_is_set == b )
return;
2012-11-10 01:43:43 -04:00
ap.home_is_set = b;
if(b) {
Log_Write_Event(DATA_SET_HOME);
}
2012-11-10 01:43:43 -04:00
}
// ---------------------------------------------
void set_auto_armed(bool b)
{
// if no change, exit immediately
if( ap.auto_armed == b )
return;
ap.auto_armed = b;
if(b){
Log_Write_Event(DATA_AUTO_ARMED);
}
2012-11-10 01:43:43 -04:00
}
// ---------------------------------------------
void set_simple_mode(uint8_t b)
2012-11-10 01:43:43 -04:00
{
if(ap.simple_mode != b){
if(b == 0){
Log_Write_Event(DATA_SET_SIMPLE_OFF);
}else if(b == 1){
Log_Write_Event(DATA_SET_SIMPLE_ON);
}else{
Log_Write_Event(DATA_SET_SUPERSIMPLE_ON);
}
ap.simple_mode = b;
}
2012-11-10 01:43:43 -04:00
}
// ---------------------------------------------
static void set_failsafe_radio(bool b)
2012-11-10 01:43:43 -04:00
{
// only act on changes
// -------------------
if(failsafe.radio != b) {
2012-11-10 01:43:43 -04:00
// store the value so we don't trip the gate twice
// -----------------------------------------------
failsafe.radio = b;
2012-11-10 01:43:43 -04:00
if (failsafe.radio == false) {
2012-11-10 01:43:43 -04:00
// We've regained radio contact
// ----------------------------
failsafe_radio_off_event();
2012-11-10 01:43:43 -04:00
}else{
// We've lost radio contact
// ------------------------
failsafe_radio_on_event();
2012-11-10 01:43:43 -04:00
}
// update AP_Notify
AP_Notify::flags.failsafe_radio = b;
2012-11-10 01:43:43 -04:00
}
}
// ---------------------------------------------
void set_low_battery(bool b)
{
2013-10-01 10:34:44 -03:00
failsafe.low_battery = b;
AP_Notify::flags.failsafe_battery = b;
2012-11-10 01:43:43 -04:00
}
// ---------------------------------------------
static void set_failsafe_gps(bool b)
{
failsafe.gps = b;
// update AP_Notify
AP_Notify::flags.failsafe_gps = b;
}
2013-04-29 09:30:22 -03:00
// ---------------------------------------------
static void set_failsafe_gcs(bool b)
2013-04-29 09:30:22 -03:00
{
failsafe.gcs = b;
2013-04-29 09:30:22 -03:00
}
2012-11-10 01:43:43 -04:00
// ---------------------------------------------
void set_takeoff_complete(bool b)
{
// if no change, exit immediately
if( ap.takeoff_complete == b )
return;
if(b){
Log_Write_Event(DATA_TAKEOFF);
}
ap.takeoff_complete = b;
2012-11-10 01:43:43 -04:00
}
// ---------------------------------------------
void set_land_complete(bool b)
{
// if no change, exit immediately
if( ap.land_complete == b )
return;
if(b){
Log_Write_Event(DATA_LAND_COMPLETE);
}else{
Log_Write_Event(DATA_NOT_LANDED);
}
ap.land_complete = b;
2012-11-10 01:43:43 -04:00
}
// ---------------------------------------------
void set_compass_healthy(bool b)
{
if(ap.compass_status != b) {
if(b) {
// compass has just recovered so log to the dataflash
Log_Write_Error(ERROR_SUBSYSTEM_COMPASS,ERROR_CODE_ERROR_RESOLVED);
}else{
// compass has just failed so log an error to the dataflash
Log_Write_Error(ERROR_SUBSYSTEM_COMPASS,ERROR_CODE_COMPASS_FAILED_TO_READ);
}
}
ap.compass_status = b;
2012-11-10 01:43:43 -04:00
}
2013-08-14 00:07:35 -03:00
// ---------------------------------------------
void set_pre_arm_check(bool b)
{
if(ap.pre_arm_check != b) {
ap.pre_arm_check = b;
AP_Notify::flags.pre_arm_check = b;
}
}