Browse Source

AP_Notify: allow external leds to be disabled

master
Randy Mackay 11 years ago
parent
commit
aae18f9ead
  1. 4
      libraries/AP_Notify/AP_Notify.cpp
  2. 5
      libraries/AP_Notify/AP_Notify.h
  3. 10
      libraries/AP_Notify/ExternalLED.cpp

4
libraries/AP_Notify/AP_Notify.cpp

@ -20,8 +20,10 @@ @@ -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();

5
libraries/AP_Notify/AP_Notify.h

@ -42,6 +42,9 @@ public: @@ -42,6 +42,9 @@ public:
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
// 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: @@ -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);

10
libraries/AP_Notify/ExternalLED.cpp

@ -22,6 +22,11 @@ extern const AP_HAL::HAL& hal; @@ -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) @@ -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) {

Loading…
Cancel
Save