From 62950169f7d60dc2f4d423431989828374c59a8e Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 14 Sep 2023 12:00:30 +1000 Subject: [PATCH] AP_Notify: tidy use of DiscreteRGB --- libraries/AP_Notify/AP_Notify.cpp | 4 ---- libraries/AP_Notify/AP_Notify.h | 2 ++ libraries/AP_Notify/AP_Notify_config.h | 4 ++++ libraries/AP_Notify/DiscreteRGBLed.cpp | 6 ++++++ libraries/AP_Notify/DiscreteRGBLed.h | 6 ++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index 5819142c10..a4d3cd0b6e 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -155,10 +155,6 @@ AP_Notify *AP_Notify::_singleton; #define DEFAULT_BUZZ_ON_LVL 1 #endif -#ifndef AP_NOTIFY_DISCRETE_RGB_ENABLED -#define AP_NOTIFY_DISCRETE_RGB_ENABLED 0 -#endif - // table of user settable parameters const AP_Param::GroupInfo AP_Notify::var_info[] = { diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index a847233d1f..8ca1e2e76c 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -94,7 +94,9 @@ public: Notify_LED_IS31FL3195_I2C_External = (1 << 15), // IS31FL3195 Notify_LED_IS31FL3195_I2C_Internal = (1 << 16), // IS31FL3195 #endif +#if AP_NOTIFY_DISCRETE_RGB_ENABLED Notify_LED_DiscreteRGB = (1 << 17), // DiscreteRGB +#endif Notify_LED_MAX }; diff --git a/libraries/AP_Notify/AP_Notify_config.h b/libraries/AP_Notify/AP_Notify_config.h index 2c759ae016..7adcab2b62 100644 --- a/libraries/AP_Notify/AP_Notify_config.h +++ b/libraries/AP_Notify/AP_Notify_config.h @@ -9,6 +9,10 @@ #include #include +#ifndef AP_NOTIFY_DISCRETE_RGB_ENABLED +#define AP_NOTIFY_DISCRETE_RGB_ENABLED 0 +#endif + #ifndef HAL_DISPLAY_ENABLED #define HAL_DISPLAY_ENABLED 1 #endif diff --git a/libraries/AP_Notify/DiscreteRGBLed.cpp b/libraries/AP_Notify/DiscreteRGBLed.cpp index d47773e01e..dbe0948b10 100644 --- a/libraries/AP_Notify/DiscreteRGBLed.cpp +++ b/libraries/AP_Notify/DiscreteRGBLed.cpp @@ -11,6 +11,10 @@ along with this program. If not, see . */ +#include "AP_Notify_config.h" + +#if AP_NOTIFY_DISCRETE_RGB_ENABLED + #include "DiscreteRGBLed.h" #include @@ -55,3 +59,5 @@ bool DiscreteRGBLed::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue) return true; } + +#endif // AP_NOTIFY_DISCRETE_RGB_ENABLED diff --git a/libraries/AP_Notify/DiscreteRGBLed.h b/libraries/AP_Notify/DiscreteRGBLed.h index b0169a5a9e..ba1a2183a4 100644 --- a/libraries/AP_Notify/DiscreteRGBLed.h +++ b/libraries/AP_Notify/DiscreteRGBLed.h @@ -18,6 +18,10 @@ #pragma once +#include "AP_Notify_config.h" + +#if AP_NOTIFY_DISCRETE_RGB_ENABLED + #include "RGBLed.h" class DiscreteRGBLed: public RGBLed { @@ -35,3 +39,5 @@ private: uint16_t red_pin_number, green_pin_number, blue_pin_number; }; + +#endif // AP_NOTIFY_DISCRETE_RGB_ENABLED