diff --git a/libraries/AP_Relay/AP_Relay.cpp b/libraries/AP_Relay/AP_Relay.cpp index 4ffe1d3562..e5cdde29c0 100644 --- a/libraries/AP_Relay/AP_Relay.cpp +++ b/libraries/AP_Relay/AP_Relay.cpp @@ -299,6 +299,18 @@ bool AP_Relay::enabled(uint8_t instance) const return (instance < AP_RELAY_NUM_RELAYS) && (_params[instance].pin != -1) && (_params[instance].function == AP_Relay_Params::Function::relay); } +// see if the relay is enabled +bool AP_Relay::enabled(AP_Relay_Params::Function function) const +{ + bool valid = false; + for (uint8_t instance = 0; instance < AP_RELAY_NUM_RELAYS; instance++) { + if ((_params[instance].function == function) && (_params[instance].pin != -1)) { + valid = true; + } + } + return valid; +} + #if AP_MAVLINK_MSG_RELAY_STATUS_ENABLED // this method may only return false if there is no space in the // supplied link for the message. diff --git a/libraries/AP_Relay/AP_Relay.h b/libraries/AP_Relay/AP_Relay.h index 5a5237d18c..a668e9144c 100644 --- a/libraries/AP_Relay/AP_Relay.h +++ b/libraries/AP_Relay/AP_Relay.h @@ -57,6 +57,9 @@ public: void set(AP_Relay_Params::Function function, bool value); + // see if the relay is enabled + bool enabled(AP_Relay_Params::Function function) const; + private: static AP_Relay *singleton;