AP_Relay: added arming_checks

This commit is contained in:
Andrew Tridgell 2021-07-20 14:26:33 +10:00
parent d827b35e57
commit 09ad43dea3
2 changed files with 15 additions and 0 deletions

View File

@ -152,6 +152,18 @@ void AP_Relay::toggle(uint8_t instance)
}
}
// check settings are valid
bool AP_Relay::arming_checks(size_t buflen, char *buffer) const
{
for (uint8_t i=0; i<AP_RELAY_NUM_RELAYS; i++) {
if (_pin[i] != -1 && !hal.gpio->valid_pin(_pin[i])) {
hal.util->snprintf(buffer, buflen, "Relay[%u] pin %d invalid", i + 1, _pin[i]);
return false;
}
}
return true;
}
namespace AP {
AP_Relay *relay()

View File

@ -38,6 +38,9 @@ public:
// toggle the relay status
void toggle(uint8_t instance);
// check settings are valid
bool arming_checks(size_t buflen, char *buffer) const;
static AP_Relay *get_singleton(void) {return singleton; }
static const struct AP_Param::GroupInfo var_info[];