From 4467929692359ef6225fbcce94af0cde8114acaf Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 5 Jan 2016 18:36:38 -0200 Subject: [PATCH] AP_Notify: add class to turn LED off On early versions of minlure an RGB LED was wrongly placed next to the barometer, causing trouble on it. Additionally depending on the LED intensity it may be a pain to leave it turned on for boards supposed to be used for bench testing. This allows to disable the LED by software so we don't have to remove it. --- libraries/AP_Notify/AP_Notify.cpp | 3 ++- libraries/AP_Notify/RCOutputRGBLed.h | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index 557a80693f..969068f2d0 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -91,7 +91,8 @@ struct AP_Notify::notify_events_type AP_Notify::events; ToneAlarm_Linux tonealarm; NotifyDevice *AP_Notify::_devices[] = {&toshibaled, &tonealarm}; #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_MINLURE - NotifyDevice *AP_Notify::_devices[0]; + RCOutputRGBLedOff led(15, 13, 14, 255); + NotifyDevice *AP_Notify::_devices[] = { &led }; #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI AP_BoardLED boardled; diff --git a/libraries/AP_Notify/RCOutputRGBLed.h b/libraries/AP_Notify/RCOutputRGBLed.h index b6806a3534..b8b3bd535d 100644 --- a/libraries/AP_Notify/RCOutputRGBLed.h +++ b/libraries/AP_Notify/RCOutputRGBLed.h @@ -10,10 +10,26 @@ public: RCOutputRGBLed(uint8_t red_channel, uint8_t green_channel, uint8_t blue_channel); bool hw_init(); - bool hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue); + virtual bool hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue); private: uint8_t _red_channel; uint8_t _green_channel; uint8_t _blue_channel; }; + +class RCOutputRGBLedOff : public RCOutputRGBLed { +public: + RCOutputRGBLedOff(uint8_t red_channel, uint8_t green_channel, + uint8_t blue_channel, uint8_t led_off) + : RCOutputRGBLed(red_channel, green_channel, blue_channel, + led_off, led_off, led_off, led_off) + { } + + /* Override the hw_set_rgb method to turn leds off regardless of the + * values passed */ + bool hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue) override + { + return RCOutputRGBLed::hw_set_rgb(_led_off, _led_off, _led_off); + } +};