LCOV - code coverage report
Current view: top level - home/pbarker/rc/ardupilot/ArduCopter - AP_State.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 35 40 87.5 %
Date: 2026-09-09 11:02:08 Functions: 5 5 100.0 %

          Line data    Source code
       1             : #include "Copter.h"
       2             : 
       3             : // ---------------------------------------------
       4      595291 : void Copter::set_auto_armed(bool b)
       5             : {
       6             :     // if no change, exit immediately
       7      595291 :     if( ap.auto_armed == b )
       8      539119 :         return;
       9             : 
      10       56172 :     ap.auto_armed = b;
      11       56172 :     if(b){
      12       28087 :         LOGGER_WRITE_EVENT(LogEvent::AUTO_ARMED);
      13             :     }
      14             : }
      15             : 
      16             : // ---------------------------------------------
      17             : /**
      18             :  * Set Simple mode
      19             :  *
      20             :  * @param [in] b 0:false or disabled, 1:true or SIMPLE, 2:SUPERSIMPLE
      21             :  */
      22        1029 : void Copter::set_simple_mode(SimpleMode b)
      23             : {
      24        1029 :     if (simple_mode != b) {
      25           8 :         switch (b) {
      26           4 :             case SimpleMode::NONE:
      27           4 :                 LOGGER_WRITE_EVENT(LogEvent::SET_SIMPLE_OFF);
      28           4 :                 gcs().send_text(MAV_SEVERITY_INFO, "SIMPLE mode off");
      29           4 :                 break;
      30           4 :             case SimpleMode::SIMPLE:
      31           4 :                 LOGGER_WRITE_EVENT(LogEvent::SET_SIMPLE_ON);
      32           4 :                 gcs().send_text(MAV_SEVERITY_INFO, "SIMPLE mode on");
      33           4 :                 break;
      34           0 :             case SimpleMode::SUPERSIMPLE:
      35             :                 // initialise super simple heading
      36           0 :                 update_super_simple_bearing(true);
      37           0 :                 LOGGER_WRITE_EVENT(LogEvent::SET_SUPERSIMPLE_ON);
      38           0 :                 gcs().send_text(MAV_SEVERITY_INFO, "SUPERSIMPLE mode on");
      39           0 :                 break;
      40             :         }
      41           8 :         simple_mode = b;
      42             :     }
      43        1029 : }
      44             : 
      45             : // ---------------------------------------------
      46        6283 : void Copter::set_failsafe_radio(bool b)
      47             : {
      48             :     // only act on changes
      49             :     // -------------------
      50        6283 :     if(failsafe.radio != b) {
      51             : 
      52             :         // store the value so we don't trip the gate twice
      53             :         // -----------------------------------------------
      54          54 :         failsafe.radio = b;
      55             : 
      56          54 :         if (failsafe.radio == false) {
      57             :             // We've regained radio contact
      58             :             // ----------------------------
      59          24 :             failsafe_radio_off_event();
      60             :         }else{
      61             :             // We've lost radio contact
      62             :             // ------------------------
      63          30 :             failsafe_radio_on_event();
      64             :         }
      65             : 
      66             :         // update AP_Notify
      67          54 :         AP_Notify::flags.failsafe_radio = b;
      68             :     }
      69        6283 : }
      70             : 
      71             : 
      72             : // ---------------------------------------------
      73          26 : void Copter::set_failsafe_gcs(bool b)
      74             : {
      75          26 :     failsafe.gcs = b;
      76             : 
      77             :     // update AP_Notify
      78          26 :     AP_Notify::flags.failsafe_gcs = b;
      79          26 : }
      80             : 
      81             : // ---------------------------------------------
      82             : 
      83       26913 : void Copter::update_using_interlock()
      84             : {
      85             : #if FRAME_CONFIG == HELI_FRAME
      86             :     // helicopters are always using motor interlock
      87        2343 :     ap.using_interlock = true;
      88             : #else
      89             :     // check if we are using motor interlock control on an aux switch or are in throw mode
      90             :     // which uses the interlock to stop motors while the copter is being thrown
      91       24570 :     ap.using_interlock = rc().find_channel_for_option(RC_Channel::AUX_FUNC::MOTOR_INTERLOCK) != nullptr;
      92             : #endif
      93       26913 : }

Generated by: LCOV version 1.14