diff --git a/libraries/AP_Notify/Buzzer.cpp b/libraries/AP_Notify/Buzzer.cpp index 3940ecaea6..c140a29229 100644 --- a/libraries/AP_Notify/Buzzer.cpp +++ b/libraries/AP_Notify/Buzzer.cpp @@ -23,8 +23,13 @@ extern const AP_HAL::HAL& hal; -bool Buzzer::init() +void Buzzer::init() { + // return immediately if disabled + if (!AP_Notify::flags.external_leds) { + return; + } + // setup the pin and ensure it's off hal.gpio->pinMode(BUZZER_PIN, GPIO_OUTPUT); on(false); @@ -33,12 +38,16 @@ bool Buzzer::init() // warning in plane and rover on every boot _flags.armed = AP_Notify::flags.armed; _flags.failsafe_battery = AP_Notify::flags.failsafe_battery; - return true; } // update - updates led according to timed_updated. Should be called at 50Hz void Buzzer::update() { + // return immediately if disabled + if (!AP_Notify::flags.external_leds) { + return; + } + // reduce 50hz call down to 10hz _counter++; if (_counter < 5) { diff --git a/libraries/AP_Notify/Buzzer.h b/libraries/AP_Notify/Buzzer.h index 120bb39b77..999aa1762c 100644 --- a/libraries/AP_Notify/Buzzer.h +++ b/libraries/AP_Notify/Buzzer.h @@ -22,6 +22,8 @@ # define BUZZER_PIN 63 // pin 63 on APM1 #elif CONFIG_HAL_BOARD == HAL_BOARD_APM2 # define BUZZER_PIN 59 // pin 59 on APM2 +#else + # define BUZZER_PIN 0 // pin undefined on other boards #endif class Buzzer @@ -31,7 +33,7 @@ public: Buzzer() : _counter(0), _pattern(NONE), _pattern_counter(0) {} /// init - initialise the buzzer - bool init(void); + void init(void); /// update - updates buzzer according to timed_updated. Should be called at 50Hz void update();