AP_Button: added arming check

This commit is contained in:
Andrew Tridgell 2021-07-24 17:07:13 +10:00
parent 45cf726a4b
commit ef93165f28
2 changed files with 18 additions and 0 deletions

View File

@ -368,6 +368,21 @@ void AP_Button::setup_pins(void)
}
}
// check settings are valid
bool AP_Button::arming_checks(size_t buflen, char *buffer) const
{
if (!enable) {
return true;
}
for (uint8_t i=0; i<AP_BUTTON_NUM_PINS; i++) {
if (pin[i] != -1 && !hal.gpio->valid_pin(pin[i])) {
hal.util->snprintf(buffer, buflen, "BTN_PIN%u invalid", i + 1, pin[i]);
return false;
}
}
return true;
}
namespace AP {
AP_Button &button()

View File

@ -45,6 +45,9 @@ public:
// used by scripting
bool get_button_state(uint8_t number);
// check settings are valid
bool arming_checks(size_t buflen, char *buffer) const;
private:
static AP_Button *_singleton;