From 69ef1e5058a41075d7122def0d31bf253e6006d1 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Wed, 9 Jun 2021 18:30:59 +0100 Subject: [PATCH] AP_Notify: allow display and oreo leds to be disabled --- libraries/AP_Notify/AP_Notify.cpp | 9 ++++++--- libraries/AP_Notify/Display.cpp | 1 + libraries/AP_Notify/Display.h | 5 ++++- libraries/AP_Notify/OreoLED_I2C.h | 5 ++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index a6d969be58..cbbb3c9aa0 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -150,14 +150,16 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = { // @User: Advanced AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, NOTIFY_LED_OVERRIDE_DEFAULT), +#if HAL_DISPLAY_ENABLED // @Param: DISPLAY_TYPE // @DisplayName: Type of on-board I2C display // @Description: This sets up the type of on-board I2C display. Disabled by default. // @Values: 0:Disable,1:ssd1306,2:sh1106,10:SITL // @User: Advanced AP_GROUPINFO("DISPLAY_TYPE", 3, AP_Notify, _display_type, 0), +#endif -#if !HAL_MINIMIZE_FEATURES +#if HAL_OREO_LED_ENABLED // @Param: OREO_THEME // @DisplayName: OreoLED Theme // @Description: Enable/Disable Solo Oreo LED driver, 0 to disable, 1 for Aircraft theme, 2 for Rover theme @@ -311,7 +313,7 @@ void AP_Notify::add_backends(void) ADD_BACKEND(new ProfiLED()); break; case Notify_LED_OreoLED: -#if !HAL_MINIMIZE_FEATURES +#if HAL_OREO_LED_ENABLED if (_oreo_theme) { ADD_BACKEND(new OreoLED_I2C(0, _oreo_theme)); } @@ -337,9 +339,10 @@ void AP_Notify::add_backends(void) } } - +#if HAL_DISPLAY_ENABLED // Always try and add a display backend ADD_BACKEND(new Display()); +#endif // ChibiOS noise makers #if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS diff --git a/libraries/AP_Notify/Display.cpp b/libraries/AP_Notify/Display.cpp index c253aab0bb..9acfe7e5a7 100644 --- a/libraries/AP_Notify/Display.cpp +++ b/libraries/AP_Notify/Display.cpp @@ -15,6 +15,7 @@ /* Notify display driver for 128 x 64 pixel displays */ #include "Display.h" + #include "Display_SH1106_I2C.h" #include "Display_SSD1306_I2C.h" #include "Display_SITL.h" diff --git a/libraries/AP_Notify/Display.h b/libraries/AP_Notify/Display.h index 25369e1c7d..9b7794f7b7 100644 --- a/libraries/AP_Notify/Display.h +++ b/libraries/AP_Notify/Display.h @@ -2,6 +2,10 @@ #include "NotifyDevice.h" +#ifndef HAL_DISPLAY_ENABLED +#define HAL_DISPLAY_ENABLED !HAL_MINIMIZE_FEATURES && BOARD_FLASH_SIZE > 1024 +#endif + #define ROW(Y) ((Y * 10) + 6) #define COLUMN(X) ((X * 7) + 0) @@ -39,4 +43,3 @@ private: // stop showing text in display after this many millis: const uint16_t _send_text_valid_millis = 20000; }; - diff --git a/libraries/AP_Notify/OreoLED_I2C.h b/libraries/AP_Notify/OreoLED_I2C.h index d1d4e1c652..0f57d3efa6 100644 --- a/libraries/AP_Notify/OreoLED_I2C.h +++ b/libraries/AP_Notify/OreoLED_I2C.h @@ -19,6 +19,10 @@ #include #include "NotifyDevice.h" +#ifndef HAL_OREO_LED_ENABLED +#define HAL_OREO_LED_ENABLED 0 +#endif + #define OREOLED_NUM_LEDS 4 // maximum number of individual LEDs connected to the oreo led cpu #define OREOLED_INSTANCE_ALL 0xff // instance number to indicate all LEDs (used for set_rgb and set_macro) #define OREOLED_BRIGHT 0xff // maximum brightness when flying (disconnected from usb) @@ -196,4 +200,3 @@ private: uint32_t _last_boot_ms; uint32_t _last_sync_ms; }; -