diff --git a/libraries/RC_Channel/RC_Channel.h b/libraries/RC_Channel/RC_Channel.h index 8de839ee47..377bb957af 100644 --- a/libraries/RC_Channel/RC_Channel.h +++ b/libraries/RC_Channel/RC_Channel.h @@ -511,6 +511,13 @@ public: return rc_channel(0)->run_aux_function(ch_option, pos, source); } + // check if flight mode channel is assigned RC option + // return true if assigned + bool flight_mode_channel_conflicts_with_rc_option(); + + // flight_mode_channel_number must be overridden in vehicle specific code + virtual int8_t flight_mode_channel_number() const = 0; + protected: enum class Option { @@ -542,8 +549,6 @@ private: AP_Int32 _options; AP_Int32 _protocols; - // flight_mode_channel_number must be overridden in vehicle specific code - virtual int8_t flight_mode_channel_number() const = 0; RC_Channel *flight_mode_channel(); // Allow override by default at start diff --git a/libraries/RC_Channel/RC_Channels.cpp b/libraries/RC_Channel/RC_Channels.cpp index cc9ebae850..2ac94a390f 100644 --- a/libraries/RC_Channel/RC_Channels.cpp +++ b/libraries/RC_Channel/RC_Channels.cpp @@ -217,6 +217,17 @@ void RC_Channels::read_mode_switch() c->read_mode_switch(); } +// check if flight mode channel is assigned RC option +// return true if assigned +bool RC_Channels::flight_mode_channel_conflicts_with_rc_option() +{ + RC_Channel *chan = flight_mode_channel(); + if (chan == nullptr) { + return false; + } + return (RC_Channel::aux_func_t)chan->option.get() != RC_Channel::AUX_FUNC::DO_NOTHING; +} + /* get the RC input PWM value given a channel number. Note that channel numbers start at 1, as this API is designed for use in