AP_Relay: added get() method for scripting

This commit is contained in:
Andrew Tridgell 2022-10-10 10:47:42 +11:00
parent 53e0c4175e
commit e7aa868669
1 changed files with 5 additions and 0 deletions

View File

@ -31,6 +31,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; }