From 9eea69367948494a9d617bc1a1ce20feafca3b24 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 7 Jun 2023 13:38:30 +1000 Subject: [PATCH] AP_Notify: tidy defines --- libraries/AP_Notify/AP_Notify.cpp | 25 ++++++++++++++----------- libraries/AP_Notify/AP_Notify.h | 10 ++++++++++ libraries/AP_Notify/AP_Notify_config.h | 13 +++++++++++++ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index edb349b70f..a04dbef242 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -74,6 +74,11 @@ AP_Notify *AP_Notify::_singleton; // all I2C_LEDS #define I2C_LEDS (ALL_TOSHIBALED_I2C | ALL_NCP5623_I2C | ALL_LP5562_I2C) +#if AP_NOTIFY_DRONECAN_LED_ENABLED +#define DRONECAN_LEDS Notify_LED_DroneCAN +#else +#define DRONECAN_LEDS 0 +#endif #ifndef DEFAULT_NTF_LED_TYPES #if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS @@ -90,7 +95,7 @@ AP_Notify *AP_Notify::_singleton; #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE #define DEFAULT_NTF_LED_TYPES (Notify_LED_Board | I2C_LEDS |\ - Notify_LED_DroneCAN) + DRONECAN_LEDS) #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET || \ @@ -346,30 +351,28 @@ void AP_Notify::add_backends(void) ADD_BACKEND(new ProfiLED_SPI()); break; #endif - case Notify_LED_OreoLED: #if AP_NOTIFY_OREOLED_ENABLED + case Notify_LED_OreoLED: if (_oreo_theme) { ADD_BACKEND(new OreoLED_I2C(0, _oreo_theme)); } -#endif break; +#endif +#if AP_NOTIFY_DRONECAN_LED_ENABLED case Notify_LED_DroneCAN: -#if HAL_ENABLE_DRONECAN_DRIVERS ADD_BACKEND(new DroneCAN_RGB_LED()); -#endif // HAL_ENABLE_DRONECAN_DRIVERS break; - +#endif // AP_NOTIFY_DRONECAN_LED_ENABLED +#if AP_NOTIFY_SCRIPTING_LED_ENABLED case Notify_LED_Scripting: -#if AP_SCRIPTING_ENABLED ADD_BACKEND(new ScriptingLED()); -#endif break; - +#endif +#if AP_NOTIFY_DSHOT_LED_ENABLED case Notify_LED_DShot: -#if HAL_SUPPORT_RCOUT_SERIAL ADD_BACKEND(new DShotLED()); -#endif break; +#endif #if AP_NOTIFY_LP5562_ENABLED case Notify_LED_LP5562_I2C_External: FOREACH_I2C_EXTERNAL(b) { diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index 4d8f3395a4..23f5e5f2c2 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -68,8 +68,12 @@ public: #if AP_NOTIFY_PCA9685_ENABLED Notify_LED_PCA9685LED_I2C_External = (1 << 3), // External PCA9685_I2C #endif +#if AP_NOTIFY_OREOLED_ENABLED Notify_LED_OreoLED = (1 << 4), // Oreo +#endif +#if AP_NOTIFY_DRONECAN_LED_ENABLED Notify_LED_DroneCAN = (1 << 5), // UAVCAN RGB LED +#endif #if AP_NOTIFY_NCP5623_ENABLED Notify_LED_NCP5623_I2C_External = (1 << 6), // External NCP5623 Notify_LED_NCP5623_I2C_Internal = (1 << 7), // Internal NCP5623 @@ -80,9 +84,15 @@ public: #if AP_NOTIFY_PROFILED_ENABLED Notify_LED_ProfiLED = (1 << 9), // ProfiLED #endif +#if AP_NOTIFY_SCRIPTING_LED_ENABLED Notify_LED_Scripting = (1 << 10),// Colour accessor for scripting +#endif +#if AP_NOTIFY_DSHOT_LED_ENABLED Notify_LED_DShot = (1 << 11),// Use dshot commands to set ESC LEDs +#endif +#if AP_NOTIFY_PROFILED_ENABLED Notify_LED_ProfiLED_SPI = (1 << 12), // ProfiLED +#endif #if AP_NOTIFY_LP5562_ENABLED Notify_LED_LP5562_I2C_External = (1 << 13), // LP5562 Notify_LED_LP5562_I2C_Internal = (1 << 14), // LP5562 diff --git a/libraries/AP_Notify/AP_Notify_config.h b/libraries/AP_Notify/AP_Notify_config.h index 85fbf2ac3b..73b5f7cc90 100644 --- a/libraries/AP_Notify/AP_Notify_config.h +++ b/libraries/AP_Notify/AP_Notify_config.h @@ -7,11 +7,20 @@ #include #endif #include +#include #ifndef HAL_DISPLAY_ENABLED #define HAL_DISPLAY_ENABLED 1 #endif +#ifndef AP_NOTIFY_DRONECAN_LED_ENABLED +#define AP_NOTIFY_DRONECAN_LED_ENABLED HAL_ENABLE_DRONECAN_DRIVERS +#endif + +#ifndef AP_NOTIFY_DSHOT_LED_ENABLED +#define AP_NOTIFY_DSHOT_LED_ENABLED HAL_SUPPORT_RCOUT_SERIAL +#endif + #ifndef AP_NOTIFY_LP5562_ENABLED #define AP_NOTIFY_LP5562_ENABLED 1 #endif @@ -36,6 +45,10 @@ #define AP_NOTIFY_PROFILED_SPI_ENABLED 0 // requires hwdef to have SPI line #endif +#ifndef AP_NOTIFY_SCRIPTING_LED_ENABLED +#define AP_NOTIFY_SCRIPTING_LED_ENABLED AP_SCRIPTING_ENABLED +#endif + #ifndef AP_NOTIFY_SERIALLED_ENABLED #define AP_NOTIFY_SERIALLED_ENABLED AP_SERIALLED_ENABLED #endif