Skip to content

Commit

Permalink
RC_Channel: put propulsion failure behind a define
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlong13 committed Nov 27, 2023
1 parent eda2a3c commit a272071
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
30 changes: 20 additions & 10 deletions ArduPlane/RC_Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ void RC_Channel_Plane::do_aux_function_flare(AuxSwitchPos ch_flag)
}
}

#if AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
void RC_Channel_Plane::do_aux_function_propulsion_failed(AuxSwitchPos ch_flag)
{
switch(ch_flag) {
case AuxSwitchPos::HIGH:
plane.TECS_controller.set_propulsion_failed_flag(true);
break;
case AuxSwitchPos::MIDDLE:
break;
case AuxSwitchPos::LOW:
plane.TECS_controller.set_propulsion_failed_flag(false);
break;
}
}
#endif

void RC_Channel_Plane::init_aux_function(const RC_Channel::aux_func_t ch_option,
const RC_Channel::AuxSwitchPos ch_flag)
Expand Down Expand Up @@ -177,7 +192,9 @@ void RC_Channel_Plane::init_aux_function(const RC_Channel::aux_func_t ch_option,
case AUX_FUNC::EMERGENCY_LANDING_EN:
case AUX_FUNC::FW_AUTOTUNE:
case AUX_FUNC::VFWD_THR_OVERRIDE:
#if AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
case AUX_FUNC::TECS_PROP_FAILED:
#endif
break;

case AUX_FUNC::SOARING:
Expand Down Expand Up @@ -444,18 +461,11 @@ bool RC_Channel_Plane::do_aux_function(const aux_func_t ch_option, const AuxSwit
}
break;

#if AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
case AUX_FUNC::TECS_PROP_FAILED:
switch (ch_flag) {
case AuxSwitchPos::HIGH:
plane.TECS_controller.set_propulsion_failed_flag(true);
break;
case AuxSwitchPos::MIDDLE:
break;
case AuxSwitchPos::LOW:
plane.TECS_controller.set_propulsion_failed_flag(false);
break;
}
do_aux_function_propulsion_failed(ch_flag);
break;
#endif

default:
return RC_Channel::do_aux_function(ch_option, ch_flag);
Expand Down
4 changes: 4 additions & 0 deletions ArduPlane/RC_Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class RC_Channel_Plane : public RC_Channel

void do_aux_function_flare(AuxSwitchPos ch_flag);

#if AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
void do_aux_function_propulsion_failed(AuxSwitchPos ch_flag);
#endif

};

class RC_Channels_Plane : public RC_Channels
Expand Down
1 change: 1 addition & 0 deletions Tools/scripts/build_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def __init__(self,
Feature('Plane', 'QAUTOTUNE', 'QAUTOTUNE_ENABLED', 'Enable QuadPlane Autotune mode', 0, "QUADPLANE"),
Feature('Plane', 'PLANE_BLACKBOX', 'AP_PLANE_BLACKBOX_LOGGING', 'Enable blackbox logging', 0, None),
Feature('Plane', 'AP_TX_TUNING', 'AP_TUNING_ENABLED', 'Enable TX-based tuning parameter adjustments', 0, None),
Feature('Plane', 'RC_CHANNEL_PROPULSION_FAILED', 'AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED', 'Enable RC channel for manually notifying the TECS of a propulsion failure', 0, None), # NOQA: E501

Feature('RC', 'RC_Protocol', 'AP_RCPROTOCOL_ENABLED', "Enable Serial RC Protocol support", 0, None), # NOQA: E501
Feature('RC', 'RC_CRSF', 'AP_RCPROTOCOL_CRSF_ENABLED', "Enable CRSF RC Protocol", 0, "RC_Protocol"), # NOQA: E501
Expand Down
1 change: 1 addition & 0 deletions Tools/scripts/extract_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def __init__(self, filename, nm="arm-none-eabi-nm", strings="strings"):
('QAUTOTUNE_ENABLED', 'ModeQAutotune::_enter',),
('HAL_SOARING_ENABLED', 'SoaringController::var_info',),
('HAL_LANDING_DEEPSTALL_ENABLED', r'AP_Landing_Deepstall::terminate\b',),
('AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED', r'RC_Channel_Plane::do_aux_function_propulsion_failed\b',),

('AP_GRIPPER_ENABLED', r'AP_Gripper::init\b',),
('HAL_SPRAYER_ENABLED', 'AC_Sprayer::AC_Sprayer',),
Expand Down
2 changes: 1 addition & 1 deletion libraries/RC_Channel/RC_Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class RC_Channel {
CAMERA_IMAGE_TRACKING = 174, // camera image tracking
CAMERA_LENS = 175, // camera lens selection
VFWD_THR_OVERRIDE = 176, // force enabled VTOL forward throttle method
TECS_PROP_FAILED = 177, // tell the TECS controller that propulsion has failed
TECS_PROP_FAILED = 177, // tell the TECS controller that propulsion has failed


// inputs from 200 will eventually used to replace RCMAP
Expand Down
4 changes: 4 additions & 0 deletions libraries/RC_Channel/RC_Channel_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
#ifndef AP_RC_CHANNEL_AUX_FUNCTION_STRINGS_ENABLED
#define AP_RC_CHANNEL_AUX_FUNCTION_STRINGS_ENABLED AP_RC_CHANNEL_ENABLED
#endif

#ifndef AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
#define AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED AP_RC_CHANNEL_ENABLED
#endif

0 comments on commit a272071

Please sign in to comment.