From aae18f9eadc237608037eb58ef0142ba58c4b5b8 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Sat, 30 Nov 2013 22:53:40 +0900 Subject: [PATCH] AP_Notify: allow external leds to be disabled --- libraries/AP_Notify/AP_Notify.cpp | 4 +++- libraries/AP_Notify/AP_Notify.h | 7 +++++-- libraries/AP_Notify/ExternalLED.cpp | 10 ++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index afea81066a..b17d4fbcc8 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -20,8 +20,10 @@ struct AP_Notify::notify_type AP_Notify::flags; // initialisation -void AP_Notify::init(void) +void AP_Notify::init(bool enable_external_leds) { + AP_Notify::flags.external_leds = enable_external_leds; + boardled.init(); toshibaled.init(); diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index 467c38ea45..728d15e7f9 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -41,7 +41,10 @@ public: uint16_t esc_calibration : 1; // 1 if calibrating escs uint16_t failsafe_radio : 1; // 1 if radio failsafe uint16_t failsafe_battery : 1; // 1 if battery failsafe - uint16_t failsafe_gps : 1; // 1 if gps failsafe + uint16_t failsafe_gps : 1; // 1 if gps failsafe + + // additional flags + uint16_t external_leds : 1; // 1 if external LEDs are enabled (normally only used for copter) }; // the notify flags are static to allow direct class access @@ -49,7 +52,7 @@ public: static struct notify_type flags; // initialisation - void init(void); + void init(bool enable_external_leds); /// update - allow updates of leds that cannot be updated during a timed interrupt void update(void); diff --git a/libraries/AP_Notify/ExternalLED.cpp b/libraries/AP_Notify/ExternalLED.cpp index 0e777a85e5..33960b75cc 100644 --- a/libraries/AP_Notify/ExternalLED.cpp +++ b/libraries/AP_Notify/ExternalLED.cpp @@ -22,6 +22,11 @@ extern const AP_HAL::HAL& hal; void ExternalLED::init(void) { + // return immediately if disabled + if (!AP_Notify::flags.external_leds) { + return; + } + // setup the main LEDs as outputs hal.gpio->pinMode(EXTERNAL_LED_ARMED, GPIO_OUTPUT); hal.gpio->pinMode(EXTERNAL_LED_GPS, GPIO_OUTPUT); @@ -40,6 +45,11 @@ void ExternalLED::init(void) */ void ExternalLED::update(void) { + // return immediately if disabled + if (!AP_Notify::flags.external_leds) { + return; + } + // reduce update rate from 50hz to 10hz _counter++; if (_counter < 5) {