AP_Relay: added get() method for scripting

This commit is contained in:
Andrew Tridgell 2022-10-10 10:47:42 +11:00 committed by Randy Mackay
parent b62e966e97
commit 9366ae9c7e
1 changed files with 5 additions and 0 deletions

View File

@ -32,6 +32,11 @@ public:
// de-activate the relay
void off(uint8_t instance) { set(instance, false); }
// get state of relay
uint8_t get(uint8_t instance) const {
return instance < AP_RELAY_NUM_RELAYS ? _pin_states & (1U<<instance) : 0;
}
// see if the relay is enabled
bool enabled(uint8_t instance) { return instance < AP_RELAY_NUM_RELAYS && _pin[instance] != -1; }