mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_Relay: add enabled method by function
This commit is contained in:
parent
8ce490d985
commit
8ab6f01942
@ -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);
|
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
|
#if AP_MAVLINK_MSG_RELAY_STATUS_ENABLED
|
||||||
// this method may only return false if there is no space in the
|
// this method may only return false if there is no space in the
|
||||||
// supplied link for the message.
|
// supplied link for the message.
|
||||||
|
@ -57,6 +57,9 @@ public:
|
|||||||
|
|
||||||
void set(AP_Relay_Params::Function function, bool value);
|
void set(AP_Relay_Params::Function function, bool value);
|
||||||
|
|
||||||
|
// see if the relay is enabled
|
||||||
|
bool enabled(AP_Relay_Params::Function function) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static AP_Relay *singleton;
|
static AP_Relay *singleton;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user