From def5ddb74735d515b84b78dfd9d2deabe8b3a5c6 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Sat, 30 Nov 2013 23:27:58 +0900 Subject: [PATCH] AP_Notify: disable buzzer along with external leds --- libraries/AP_Notify/Buzzer.cpp | 13 +++++++++++-- libraries/AP_Notify/Buzzer.h | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) 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();