LCOV - code coverage report
Current view: top level - home/pbarker/rc/ardupilot/ArduSub - RC_Channel_Sub.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 17 32 53.1 %
Date: 2026-09-09 11:02:08 Functions: 6 8 75.0 %

          Line data    Source code
       1             : #include "Sub.h"
       2             : 
       3             : #include "RC_Channel_Sub.h"
       4             : #include "config.h"
       5             : 
       6             : // defining these two macros and including the RC_Channels_VarInfo
       7             : // header defines the parameter information common to all vehicle
       8             : // types
       9             : #define RC_CHANNELS_SUBCLASS RC_Channels_Sub
      10             : #define RC_CHANNEL_SUBCLASS RC_Channel_Sub
      11             : 
      12             : #include <RC_Channel/RC_Channels_VarInfo.h>
      13             : 
      14             : 
      15             : #if AP_SUB_RC_ENABLED
      16     2179970 : int8_t RC_Channels_Sub::flight_mode_channel_number() const
      17             : {
      18     2179970 :     return sub.g.flight_mode_chan.get();
      19             : }
      20             : 
      21           0 : void RC_Channel_Sub::mode_switch_changed(modeswitch_pos_t new_pos)
      22             : {
      23           0 :     if (new_pos < 0 || (uint8_t)new_pos >= ARRAY_SIZE(sub.g.flight_modes)) {
      24             :         // should not have been called
      25           0 :         return;
      26             :     }
      27             : 
      28           0 :     if (!sub.set_mode((Mode::Number)sub.g.flight_modes[new_pos].get(), ModeReason::RC_COMMAND)) {
      29           0 :         return;
      30             :     }
      31             : }
      32             : 
      33             : // init_aux_switch_function - initialize aux functions
      34        1328 : void RC_Channel_Sub::init_aux_function(const AUX_FUNC ch_option, const AuxSwitchPos ch_flag)
      35             : {
      36        1328 :     RC_Channel::init_aux_function(ch_option, ch_flag);
      37        1328 : }
      38             : 
      39     3209565 : bool RC_Channels_Sub::in_rc_failsafe() const
      40             : {
      41     3209565 :     return sub.failsafe.radio;
      42             : }
      43             : 
      44     2832607 : bool RC_Channels_Sub::has_valid_input() const
      45             : {
      46     2832607 :     if (in_rc_failsafe()) {
      47         989 :         return false;
      48             :     }
      49     2831618 :     if (sub.failsafe.radio_counter != 0) {
      50           0 :         return false;
      51             :     }
      52     2831618 :     return RC_Channels::has_valid_input();
      53             : }
      54             : 
      55           0 : bool RC_Channels_Sub::has_pilot_input_for_override_clear()
      56             : {
      57           0 :     if (channel_outside_trim_dz(get_forward_channel()) ||
      58           0 :         channel_outside_trim_dz(get_lateral_channel()) ||
      59           0 :         channel_outside_trim_dz(get_yaw_channel())) {
      60           0 :         return true;
      61             :     }
      62             :     // Sub throttle (=vertical) is biased away from trim by the GCS, so use movement-since-override-start
      63           0 :     if (throttle_moved_since_override_start()) {
      64           0 :         return true;
      65             :     }
      66           0 :     return false;
      67             : }
      68             : 
      69             : 
      70             : // do_aux_function - implement the function invoked by auxiliary switches
      71         164 : bool RC_Channel_Sub::do_aux_function(const AuxFuncTrigger &trigger)
      72             : {
      73         164 :    return RC_Channel::do_aux_function(trigger);
      74             : }
      75             : #else
      76             : // note that this callback is not presently used on Plane:
      77             : int8_t RC_Channels_Sub::flight_mode_channel_number() const
      78             : {
      79             :     return 1; // sub does not have a flight mode channel
      80             : }
      81             : #endif
      82             : 
      83             : // returns true if min throttle arming checks should be run
      84          46 : bool RC_Channels_Sub::arming_check_throttle() const {
      85          46 :     if (sub.g.thr_arming_position == WITHIN_THR_TRIM && RC_Channels::arming_check_throttle()) {
      86             :         // center sprung/reversing throttle configured, dont run AP_Arming check for min position
      87             :         // Sub already checks this case in its own arming checks
      88           0 :         return false;
      89             :     }
      90          46 :     return RC_Channels::arming_check_throttle();
      91             : }

Generated by: LCOV version 1.14