diff --git a/ArduPlane/RC_Channel.cpp b/ArduPlane/RC_Channel.cpp index 924060f0e2..dddceb6818 100644 --- a/ArduPlane/RC_Channel.cpp +++ b/ArduPlane/RC_Channel.cpp @@ -96,6 +96,27 @@ void RC_Channel_Plane::do_aux_function_crow_mode(AuxSwitchPos ch_flag) } } +void RC_Channel_Plane::do_aux_function_soaring_3pos(AuxSwitchPos ch_flag) +{ +#if SOARING_ENABLED == ENABLED + 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 +} + void RC_Channel_Plane::init_aux_function(const RC_Channel::aux_func_t ch_option, const RC_Channel::AuxSwitchPos ch_flag) { @@ -184,6 +205,10 @@ void RC_Channel_Plane::do_aux_function(const aux_func_t ch_option, const AuxSwit do_aux_function_change_mode(Mode::Number::TAKEOFF, ch_flag); break; + case AUX_FUNC::SOARING: + do_aux_function_soaring_3pos(ch_flag); + break; + case AUX_FUNC::FLAP: break; // flap input label, nothing to do diff --git a/ArduPlane/RC_Channel.h b/ArduPlane/RC_Channel.h index 89a1580fb7..6bba22252f 100644 --- a/ArduPlane/RC_Channel.h +++ b/ArduPlane/RC_Channel.h @@ -21,6 +21,8 @@ private: void do_aux_function_q_assist_state(AuxSwitchPos ch_flag); void do_aux_function_crow_mode(AuxSwitchPos ch_flag); + + void do_aux_function_soaring_3pos(AuxSwitchPos ch_flag); }; class RC_Channels_Plane : public RC_Channels diff --git a/libraries/RC_Channel/RC_Channel.h b/libraries/RC_Channel/RC_Channel.h index 54d6a34f2d..abbb4a8fb5 100644 --- a/libraries/RC_Channel/RC_Channel.h +++ b/libraries/RC_Channel/RC_Channel.h @@ -185,6 +185,7 @@ public: GENERATOR = 85, // generator control TER_DISABLE = 86, // disable terrain following in CRUISE/FBWB modes CROW_SELECT = 87, // select CROW mode for diff spoilers;high disables,mid forces progressive + SOARING = 88, // three-position switch to set soaring mode // entries from 100 onwards are expected to be developer // options used for testing