2018-04-26 22:01:37 -03:00
|
|
|
#include "Plane.h"
|
|
|
|
|
|
|
|
#include "RC_Channel.h"
|
|
|
|
|
|
|
|
// defining these two macros and including the RC_Channels_VarInfo
|
|
|
|
// header defines the parameter information common to all vehicle
|
|
|
|
// types
|
|
|
|
#define RC_CHANNELS_SUBCLASS RC_Channels_Plane
|
|
|
|
#define RC_CHANNEL_SUBCLASS RC_Channel_Plane
|
|
|
|
|
|
|
|
#include <RC_Channel/RC_Channels_VarInfo.h>
|
|
|
|
|
|
|
|
// note that this callback is not presently used on Plane:
|
|
|
|
int8_t RC_Channels_Plane::flight_mode_channel_number() const
|
|
|
|
{
|
|
|
|
return plane.g.flight_mode_channel.get();
|
|
|
|
}
|
2018-08-03 06:56:58 -03:00
|
|
|
|
|
|
|
bool RC_Channels_Plane::has_valid_input() const
|
|
|
|
{
|
2020-09-25 21:23:23 -03:00
|
|
|
if (plane.rc_failsafe_active() || plane.failsafe.rc_failsafe) {
|
2018-08-03 06:56:58 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (plane.failsafe.throttle_counter != 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2018-09-05 01:22:14 -03:00
|
|
|
|
2020-04-02 17:44:24 -03:00
|
|
|
RC_Channel * RC_Channels_Plane::get_arming_channel(void) const
|
|
|
|
{
|
|
|
|
return plane.channel_rudder;
|
|
|
|
}
|
|
|
|
|
2019-03-19 18:09:56 -03:00
|
|
|
void RC_Channel_Plane::do_aux_function_change_mode(const Mode::Number number,
|
2020-06-02 23:21:50 -03:00
|
|
|
const AuxSwitchPos ch_flag)
|
2019-03-19 18:09:56 -03:00
|
|
|
{
|
|
|
|
switch(ch_flag) {
|
2020-06-02 23:21:50 -03:00
|
|
|
case AuxSwitchPos::HIGH: {
|
2019-03-19 18:09:56 -03:00
|
|
|
// engage mode (if not possible we remain in current flight mode)
|
2021-08-09 11:07:32 -03:00
|
|
|
plane.set_mode_by_number(number, ModeReason::RC_COMMAND);
|
2019-03-19 18:09:56 -03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
// return to flight mode switch's flight mode if we are currently
|
|
|
|
// in this mode
|
|
|
|
if (plane.control_mode->mode_number() == number) {
|
2022-07-13 22:10:43 -03:00
|
|
|
rc().reset_mode_switch();
|
2019-03-19 18:09:56 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
2020-06-02 23:21:50 -03:00
|
|
|
void RC_Channel_Plane::do_aux_function_q_assist_state(AuxSwitchPos ch_flag)
|
2020-01-02 15:06:39 -04:00
|
|
|
{
|
|
|
|
switch(ch_flag) {
|
2020-06-02 23:21:50 -03:00
|
|
|
case AuxSwitchPos::HIGH:
|
2020-01-02 15:06:39 -04:00
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "QAssist: Force enabled");
|
|
|
|
plane.quadplane.set_q_assist_state(plane.quadplane.Q_ASSIST_STATE_ENUM::Q_ASSIST_FORCE);
|
|
|
|
break;
|
|
|
|
|
2020-06-02 23:21:50 -03:00
|
|
|
case AuxSwitchPos::MIDDLE:
|
2020-01-02 15:06:39 -04:00
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "QAssist: Enabled");
|
|
|
|
plane.quadplane.set_q_assist_state(plane.quadplane.Q_ASSIST_STATE_ENUM::Q_ASSIST_ENABLED);
|
|
|
|
break;
|
|
|
|
|
2020-06-02 23:21:50 -03:00
|
|
|
case AuxSwitchPos::LOW:
|
2020-01-02 15:06:39 -04:00
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "QAssist: Disabled");
|
|
|
|
plane.quadplane.set_q_assist_state(plane.quadplane.Q_ASSIST_STATE_ENUM::Q_ASSIST_DISABLED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif // HAL_QUADPLANE_ENABLED
|
2020-01-02 15:06:39 -04:00
|
|
|
|
2020-07-15 16:22:50 -03:00
|
|
|
void RC_Channel_Plane::do_aux_function_crow_mode(AuxSwitchPos ch_flag)
|
|
|
|
{
|
|
|
|
switch(ch_flag) {
|
|
|
|
case AuxSwitchPos::HIGH:
|
|
|
|
plane.crow_mode = Plane::CrowMode::CROW_DISABLED;
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "Crow Flaps Disabled");
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::MIDDLE:
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "Progressive Crow Flaps");
|
|
|
|
plane.crow_mode = Plane::CrowMode::PROGRESSIVE;
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::LOW:
|
|
|
|
plane.crow_mode = Plane::CrowMode::NORMAL;
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "Normal Crow Flaps");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-13 05:45:57 -03:00
|
|
|
void RC_Channel_Plane::do_aux_function_soaring_3pos(AuxSwitchPos ch_flag)
|
|
|
|
{
|
2020-09-23 05:16:45 -03:00
|
|
|
#if HAL_SOARING_ENABLED
|
2020-07-13 05:45:57 -03:00
|
|
|
SoaringController::ActiveStatus desired_state = SoaringController::ActiveStatus::SOARING_DISABLED;
|
|
|
|
|
|
|
|
switch (ch_flag) {
|
|
|
|
case AuxSwitchPos::LOW:
|
|
|
|
desired_state = SoaringController::ActiveStatus::SOARING_DISABLED;
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::MIDDLE:
|
|
|
|
desired_state = SoaringController::ActiveStatus::MANUAL_MODE_CHANGE;
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::HIGH:
|
|
|
|
desired_state = SoaringController::ActiveStatus::AUTO_MODE_CHANGE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
plane.g2.soaring_controller.set_pilot_desired_state(desired_state);
|
|
|
|
#endif
|
|
|
|
}
|
2020-10-02 21:52:56 -03:00
|
|
|
|
|
|
|
void RC_Channel_Plane::do_aux_function_flare(AuxSwitchPos ch_flag)
|
|
|
|
{
|
|
|
|
switch(ch_flag) {
|
|
|
|
case AuxSwitchPos::HIGH:
|
2020-10-14 13:34:12 -03:00
|
|
|
plane.flare_mode = Plane::FlareMode::ENABLED_PITCH_TARGET;
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
2020-10-02 21:52:56 -03:00
|
|
|
plane.quadplane.set_q_assist_state(plane.quadplane.Q_ASSIST_STATE_ENUM::Q_ASSIST_DISABLED);
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif
|
2020-10-02 21:52:56 -03:00
|
|
|
break;
|
|
|
|
case AuxSwitchPos::MIDDLE:
|
2020-10-14 13:34:12 -03:00
|
|
|
plane.flare_mode = Plane::FlareMode::ENABLED_NO_PITCH_TARGET;
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
2020-10-14 13:34:12 -03:00
|
|
|
plane.quadplane.set_q_assist_state(plane.quadplane.Q_ASSIST_STATE_ENUM::Q_ASSIST_DISABLED);
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif
|
2020-10-02 21:52:56 -03:00
|
|
|
break;
|
|
|
|
case AuxSwitchPos::LOW:
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
2020-10-02 21:52:56 -03:00
|
|
|
plane.quadplane.set_q_assist_state(plane.quadplane.Q_ASSIST_STATE_ENUM::Q_ASSIST_ENABLED);
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif
|
2020-10-14 13:34:12 -03:00
|
|
|
plane.flare_mode = Plane::FlareMode::FLARE_DISABLED;
|
2020-10-02 21:52:56 -03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-12 17:50:37 -04:00
|
|
|
|
2018-09-05 01:22:14 -03:00
|
|
|
void RC_Channel_Plane::init_aux_function(const RC_Channel::aux_func_t ch_option,
|
2020-06-02 23:21:50 -03:00
|
|
|
const RC_Channel::AuxSwitchPos ch_flag)
|
2018-09-05 01:22:14 -03:00
|
|
|
{
|
|
|
|
switch(ch_option) {
|
|
|
|
// the following functions do not need to be initialised:
|
2019-10-26 08:35:55 -03:00
|
|
|
case AUX_FUNC::AUTO:
|
|
|
|
case AUX_FUNC::CIRCLE:
|
2021-07-17 21:21:02 -03:00
|
|
|
case AUX_FUNC::ACRO:
|
|
|
|
case AUX_FUNC::TRAINING:
|
2019-12-13 19:25:01 -04:00
|
|
|
case AUX_FUNC::FLAP:
|
2019-10-26 08:35:55 -03:00
|
|
|
case AUX_FUNC::GUIDED:
|
2019-11-09 01:25:27 -04:00
|
|
|
case AUX_FUNC::INVERTED:
|
2019-12-13 19:25:01 -04:00
|
|
|
case AUX_FUNC::LOITER:
|
2019-10-26 08:35:55 -03:00
|
|
|
case AUX_FUNC::MANUAL:
|
2019-03-19 18:09:56 -03:00
|
|
|
case AUX_FUNC::RTL:
|
2019-10-26 08:35:55 -03:00
|
|
|
case AUX_FUNC::TAKEOFF:
|
2020-12-14 23:22:14 -04:00
|
|
|
case AUX_FUNC::FBWA:
|
2023-03-21 15:13:17 -03:00
|
|
|
case AUX_FUNC::AIRBRAKE:
|
2021-11-21 16:43:58 -04:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
case AUX_FUNC::QRTL:
|
2022-12-01 05:14:36 -04:00
|
|
|
case AUX_FUNC::QSTABILIZE:
|
2021-11-21 16:43:58 -04:00
|
|
|
#endif
|
2021-03-12 17:55:31 -04:00
|
|
|
case AUX_FUNC::FBWA_TAILDRAGGER:
|
2020-06-09 19:05:07 -03:00
|
|
|
case AUX_FUNC::FWD_THR:
|
2020-10-02 21:52:56 -03:00
|
|
|
case AUX_FUNC::LANDING_FLARE:
|
2021-03-12 17:53:55 -04:00
|
|
|
case AUX_FUNC::PARACHUTE_RELEASE:
|
2021-03-14 20:42:57 -03:00
|
|
|
case AUX_FUNC::MODE_SWITCH_RESET:
|
2021-08-09 22:54:59 -03:00
|
|
|
case AUX_FUNC::CRUISE:
|
2021-09-13 21:11:36 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
case AUX_FUNC::ARMDISARM_AIRMODE:
|
|
|
|
#endif
|
2023-03-13 22:30:39 -03:00
|
|
|
case AUX_FUNC::PLANE_AUTO_LANDING_ABORT:
|
2021-09-21 18:21:50 -03:00
|
|
|
case AUX_FUNC::TRIM_TO_CURRENT_SERVO_RC:
|
2021-10-24 02:20:43 -03:00
|
|
|
case AUX_FUNC::EMERGENCY_LANDING_EN:
|
2021-11-08 23:31:02 -04:00
|
|
|
case AUX_FUNC::FW_AUTOTUNE:
|
2018-09-05 01:22:14 -03:00
|
|
|
break;
|
2018-11-09 19:00:20 -04:00
|
|
|
|
2020-07-13 05:46:51 -03:00
|
|
|
case AUX_FUNC::SOARING:
|
2021-09-13 21:11:36 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
case AUX_FUNC::Q_ASSIST:
|
2020-07-07 21:22:56 -03:00
|
|
|
case AUX_FUNC::AIRMODE:
|
2022-01-23 18:21:18 -04:00
|
|
|
case AUX_FUNC::WEATHER_VANE_ENABLE:
|
2021-09-13 21:11:36 -03:00
|
|
|
#endif
|
2020-11-24 10:13:10 -04:00
|
|
|
#if AP_AIRSPEED_AUTOCAL_ENABLE
|
|
|
|
case AUX_FUNC::ARSPD_CALIBRATE:
|
|
|
|
#endif
|
2021-04-28 06:13:54 -03:00
|
|
|
case AUX_FUNC::TER_DISABLE:
|
|
|
|
case AUX_FUNC::CROW_SELECT:
|
|
|
|
run_aux_function(ch_option, ch_flag, AuxFuncTriggerSource::INIT);
|
2020-01-02 15:06:39 -04:00
|
|
|
break;
|
|
|
|
|
2019-04-03 13:26:19 -03:00
|
|
|
case AUX_FUNC::REVERSE_THROTTLE:
|
2018-11-09 19:00:20 -04:00
|
|
|
plane.have_reverse_throttle_rc_option = true;
|
|
|
|
// setup input throttle as a range. This is needed as init_aux_function is called
|
|
|
|
// after set_control_channels()
|
|
|
|
if (plane.channel_throttle) {
|
|
|
|
plane.channel_throttle->set_range(100);
|
|
|
|
}
|
|
|
|
// note that we don't call do_aux_function() here as we don't
|
|
|
|
// want to startup with reverse thrust
|
|
|
|
break;
|
|
|
|
|
2018-09-05 01:22:14 -03:00
|
|
|
default:
|
2018-11-09 19:00:20 -04:00
|
|
|
// handle in parent class
|
2018-09-05 01:22:14 -03:00
|
|
|
RC_Channel::init_aux_function(ch_option, ch_flag);
|
|
|
|
break;
|
2020-06-09 19:05:07 -03:00
|
|
|
}
|
2018-09-05 01:22:14 -03:00
|
|
|
}
|
|
|
|
|
2022-01-21 05:09:45 -04:00
|
|
|
// do_aux_function - implement the function invoked by auxiliary switches
|
2021-02-24 05:48:16 -04:00
|
|
|
bool RC_Channel_Plane::do_aux_function(const aux_func_t ch_option, const AuxSwitchPos ch_flag)
|
2018-09-05 01:22:14 -03:00
|
|
|
{
|
|
|
|
switch(ch_option) {
|
2019-04-03 13:26:19 -03:00
|
|
|
case AUX_FUNC::INVERTED:
|
2020-06-02 23:21:50 -03:00
|
|
|
plane.inverted_flight = (ch_flag == AuxSwitchPos::HIGH);
|
2018-08-11 08:12:35 -03:00
|
|
|
break;
|
2018-06-10 03:33:06 -03:00
|
|
|
|
2019-04-03 13:26:19 -03:00
|
|
|
case AUX_FUNC::REVERSE_THROTTLE:
|
2020-06-02 23:21:50 -03:00
|
|
|
plane.reversed_throttle = (ch_flag == AuxSwitchPos::HIGH);
|
2018-11-09 19:00:20 -04:00
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "RevThrottle: %s", plane.reversed_throttle?"ENABLE":"DISABLE");
|
|
|
|
break;
|
2019-03-19 18:09:56 -03:00
|
|
|
|
|
|
|
case AUX_FUNC::AUTO:
|
|
|
|
do_aux_function_change_mode(Mode::Number::AUTO, ch_flag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUX_FUNC::CIRCLE:
|
|
|
|
do_aux_function_change_mode(Mode::Number::CIRCLE, ch_flag);
|
|
|
|
break;
|
2021-07-17 21:21:02 -03:00
|
|
|
|
|
|
|
case AUX_FUNC::ACRO:
|
|
|
|
do_aux_function_change_mode(Mode::Number::ACRO, ch_flag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUX_FUNC::TRAINING:
|
|
|
|
do_aux_function_change_mode(Mode::Number::TRAINING, ch_flag);
|
|
|
|
break;
|
|
|
|
|
2019-11-23 04:08:50 -04:00
|
|
|
case AUX_FUNC::LOITER:
|
|
|
|
do_aux_function_change_mode(Mode::Number::LOITER, ch_flag);
|
|
|
|
break;
|
2019-03-19 18:09:56 -03:00
|
|
|
|
|
|
|
case AUX_FUNC::GUIDED:
|
|
|
|
do_aux_function_change_mode(Mode::Number::GUIDED, ch_flag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUX_FUNC::MANUAL:
|
|
|
|
do_aux_function_change_mode(Mode::Number::MANUAL, ch_flag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUX_FUNC::RTL:
|
|
|
|
do_aux_function_change_mode(Mode::Number::RTL, ch_flag);
|
|
|
|
break;
|
|
|
|
|
2019-10-20 18:40:35 -03:00
|
|
|
case AUX_FUNC::TAKEOFF:
|
|
|
|
do_aux_function_change_mode(Mode::Number::TAKEOFF, ch_flag);
|
|
|
|
break;
|
|
|
|
|
2020-12-14 23:22:14 -04:00
|
|
|
case AUX_FUNC::FBWA:
|
|
|
|
do_aux_function_change_mode(Mode::Number::FLY_BY_WIRE_A, ch_flag);
|
|
|
|
break;
|
|
|
|
|
2021-11-21 16:43:58 -04:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
case AUX_FUNC::QRTL:
|
|
|
|
do_aux_function_change_mode(Mode::Number::QRTL, ch_flag);
|
|
|
|
break;
|
2022-12-01 05:14:36 -04:00
|
|
|
|
|
|
|
case AUX_FUNC::QSTABILIZE:
|
|
|
|
do_aux_function_change_mode(Mode::Number::QSTABILIZE, ch_flag);
|
|
|
|
break;
|
2021-11-21 16:43:58 -04:00
|
|
|
#endif
|
|
|
|
|
2020-07-13 05:45:57 -03:00
|
|
|
case AUX_FUNC::SOARING:
|
|
|
|
do_aux_function_soaring_3pos(ch_flag);
|
|
|
|
break;
|
|
|
|
|
2019-12-13 19:25:01 -04:00
|
|
|
case AUX_FUNC::FLAP:
|
2021-03-12 17:55:31 -04:00
|
|
|
case AUX_FUNC::FBWA_TAILDRAGGER:
|
2022-03-24 11:30:07 -03:00
|
|
|
case AUX_FUNC::AIRBRAKE:
|
2021-03-12 17:55:31 -04:00
|
|
|
break; // input labels, nothing to do
|
2019-10-20 18:40:35 -03:00
|
|
|
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
2020-01-02 15:06:39 -04:00
|
|
|
case AUX_FUNC::Q_ASSIST:
|
|
|
|
do_aux_function_q_assist_state(ch_flag);
|
2020-06-09 19:02:53 -03:00
|
|
|
break;
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif
|
2020-06-09 19:05:07 -03:00
|
|
|
|
|
|
|
case AUX_FUNC::FWD_THR:
|
|
|
|
break; // VTOL forward throttle input label, nothing to do
|
2020-01-02 15:06:39 -04:00
|
|
|
|
2020-07-07 09:25:21 -03:00
|
|
|
case AUX_FUNC::TER_DISABLE:
|
|
|
|
switch (ch_flag) {
|
|
|
|
case AuxSwitchPos::HIGH:
|
|
|
|
plane.non_auto_terrain_disable = true;
|
|
|
|
if (plane.control_mode->allows_terrain_disable()) {
|
|
|
|
plane.set_target_altitude_current();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::MIDDLE:
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::LOW:
|
|
|
|
plane.non_auto_terrain_disable = false;
|
|
|
|
if (plane.control_mode->allows_terrain_disable()) {
|
|
|
|
plane.set_target_altitude_current();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "NON AUTO TERRN: %s", plane.non_auto_terrain_disable?"OFF":"ON");
|
|
|
|
break;
|
|
|
|
|
2020-07-15 16:22:50 -03:00
|
|
|
case AUX_FUNC::CROW_SELECT:
|
|
|
|
do_aux_function_crow_mode(ch_flag);
|
|
|
|
break;
|
2020-07-07 09:25:21 -03:00
|
|
|
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
2020-07-07 21:22:56 -03:00
|
|
|
case AUX_FUNC::AIRMODE:
|
|
|
|
switch (ch_flag) {
|
|
|
|
case AuxSwitchPos::HIGH:
|
|
|
|
plane.quadplane.air_mode = AirMode::ON;
|
2023-02-24 05:13:47 -04:00
|
|
|
plane.quadplane.throttle_wait = false;
|
2020-07-07 21:22:56 -03:00
|
|
|
break;
|
|
|
|
case AuxSwitchPos::MIDDLE:
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::LOW:
|
|
|
|
plane.quadplane.air_mode = AirMode::OFF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif
|
2020-07-07 21:22:56 -03:00
|
|
|
|
2022-03-04 05:43:50 -04:00
|
|
|
case AUX_FUNC::ARSPD_CALIBRATE:
|
2020-11-24 10:13:10 -04:00
|
|
|
#if AP_AIRSPEED_AUTOCAL_ENABLE
|
2022-03-04 05:43:50 -04:00
|
|
|
switch (ch_flag) {
|
2022-03-04 20:20:06 -04:00
|
|
|
case AuxSwitchPos::HIGH:
|
2020-11-24 10:13:10 -04:00
|
|
|
plane.airspeed.set_calibration_enabled(true);
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::MIDDLE:
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::LOW:
|
|
|
|
plane.airspeed.set_calibration_enabled(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
2022-03-04 05:43:50 -04:00
|
|
|
case AUX_FUNC::LANDING_FLARE:
|
|
|
|
do_aux_function_flare(ch_flag);
|
|
|
|
break;
|
2020-10-02 21:52:56 -03:00
|
|
|
|
2021-03-12 17:53:55 -04:00
|
|
|
case AUX_FUNC::PARACHUTE_RELEASE:
|
|
|
|
#if PARACHUTE == ENABLED
|
2021-11-17 04:56:17 -04:00
|
|
|
if (ch_flag == AuxSwitchPos::HIGH) {
|
|
|
|
plane.parachute_manual_release();
|
|
|
|
}
|
2021-03-12 17:53:55 -04:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
2021-03-14 20:42:57 -03:00
|
|
|
case AUX_FUNC::MODE_SWITCH_RESET:
|
2022-07-13 22:10:43 -03:00
|
|
|
rc().reset_mode_switch();
|
2021-03-14 20:42:57 -03:00
|
|
|
break;
|
|
|
|
|
2021-08-09 22:54:59 -03:00
|
|
|
case AUX_FUNC::CRUISE:
|
|
|
|
do_aux_function_change_mode(Mode::Number::CRUISE, ch_flag);
|
|
|
|
break;
|
|
|
|
|
2021-09-13 21:11:36 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
case AUX_FUNC::ARMDISARM_AIRMODE:
|
|
|
|
RC_Channel::do_aux_function_armdisarm(ch_flag);
|
|
|
|
if (plane.arming.is_armed()) {
|
|
|
|
plane.quadplane.air_mode = AirMode::ON;
|
2023-02-24 05:13:47 -04:00
|
|
|
plane.quadplane.throttle_wait = false;
|
2021-09-13 21:11:36 -03:00
|
|
|
}
|
|
|
|
break;
|
2022-01-23 18:21:18 -04:00
|
|
|
|
|
|
|
case AUX_FUNC::WEATHER_VANE_ENABLE: {
|
|
|
|
if (plane.quadplane.weathervane != nullptr) {
|
|
|
|
switch (ch_flag) {
|
|
|
|
case AuxSwitchPos::HIGH:
|
|
|
|
plane.quadplane.weathervane->allow_weathervaning(true);
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::MIDDLE:
|
|
|
|
// nothing
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::LOW:
|
|
|
|
plane.quadplane.weathervane->allow_weathervaning(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2023-03-13 22:30:39 -03:00
|
|
|
#endif
|
2023-03-07 17:17:52 -04:00
|
|
|
|
2023-03-13 22:30:39 -03:00
|
|
|
case AUX_FUNC::PLANE_AUTO_LANDING_ABORT:
|
2023-03-07 17:17:52 -04:00
|
|
|
switch(ch_flag) {
|
|
|
|
case AuxSwitchPos::HIGH:
|
2023-03-13 22:30:39 -03:00
|
|
|
IGNORE_RETURN(plane.trigger_land_abort(0));
|
2023-03-07 17:17:52 -04:00
|
|
|
break;
|
|
|
|
case AuxSwitchPos::MIDDLE:
|
|
|
|
case AuxSwitchPos::LOW:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-09 22:54:59 -03:00
|
|
|
|
2021-09-21 18:21:50 -03:00
|
|
|
case AUX_FUNC::TRIM_TO_CURRENT_SERVO_RC:
|
|
|
|
if (ch_flag == AuxSwitchPos::HIGH) {
|
|
|
|
plane.trim_radio();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-10-24 02:20:43 -03:00
|
|
|
case AUX_FUNC::EMERGENCY_LANDING_EN:
|
|
|
|
switch (ch_flag) {
|
|
|
|
case AuxSwitchPos::HIGH:
|
|
|
|
plane.emergency_landing = true;
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::MIDDLE:
|
|
|
|
break;
|
|
|
|
case AuxSwitchPos::LOW:
|
|
|
|
plane.emergency_landing = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-11-08 23:31:02 -04:00
|
|
|
case AUX_FUNC::FW_AUTOTUNE:
|
2023-01-26 16:59:58 -04:00
|
|
|
if (ch_flag == AuxSwitchPos::HIGH && plane.control_mode->mode_allows_autotuning()) {
|
|
|
|
plane.autotune_enable(true);
|
|
|
|
} else if (ch_flag == AuxSwitchPos::HIGH) {
|
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Autotuning not allowed in this mode!");
|
|
|
|
} else {
|
|
|
|
plane.autotune_enable(false);
|
|
|
|
}
|
2021-11-08 23:31:02 -04:00
|
|
|
break;
|
2021-09-21 18:21:50 -03:00
|
|
|
|
2018-09-05 01:22:14 -03:00
|
|
|
default:
|
2021-02-24 05:48:16 -04:00
|
|
|
return RC_Channel::do_aux_function(ch_option, ch_flag);
|
2018-09-05 01:22:14 -03:00
|
|
|
}
|
2021-02-24 05:48:16 -04:00
|
|
|
|
|
|
|
return true;
|
2018-09-05 01:22:14 -03:00
|
|
|
}
|