diff --git a/libraries/AP_Notify/AP_Notify_config.h b/libraries/AP_Notify/AP_Notify_config.h index ee7d739a05ba3f..b3f7a8e30a9790 100644 --- a/libraries/AP_Notify/AP_Notify_config.h +++ b/libraries/AP_Notify/AP_Notify_config.h @@ -17,6 +17,23 @@ #define HAL_DISPLAY_ENABLED 1 #endif +#ifndef AP_NOTIFY_DISPLAY_BACKEND_DEFAULT_ENABLED +#define AP_NOTIFY_DISPLAY_BACKEND_DEFAULT_ENABLED HAL_DISPLAY_ENABLED +#endif + +// allow boards to include only the display drivers they use +#ifndef AP_NOTIFY_DISPLAY_SSD1306_ENABLED +#define AP_NOTIFY_DISPLAY_SSD1306_ENABLED AP_NOTIFY_DISPLAY_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_NOTIFY_DISPLAY_SH1106_ENABLED +#define AP_NOTIFY_DISPLAY_SH1106_ENABLED AP_NOTIFY_DISPLAY_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_NOTIFY_DISPLAY_SITL_ENABLED +#define AP_NOTIFY_DISPLAY_SITL_ENABLED (AP_NOTIFY_DISPLAY_BACKEND_DEFAULT_ENABLED && (CONFIG_HAL_BOARD == HAL_BOARD_SITL)) +#endif + #ifndef AP_NOTIFY_DRONECAN_LED_ENABLED #define AP_NOTIFY_DRONECAN_LED_ENABLED HAL_ENABLE_DRONECAN_DRIVERS #endif diff --git a/libraries/AP_Notify/Display.cpp b/libraries/AP_Notify/Display.cpp index ed7ba0c3eea2f3..654116e803b545 100644 --- a/libraries/AP_Notify/Display.cpp +++ b/libraries/AP_Notify/Display.cpp @@ -20,13 +20,20 @@ #include "Display.h" +#if AP_NOTIFY_DISPLAY_SH1106_ENABLED #include "Display_SH1106_I2C.h" +#endif // AP_NOTIFY_DISPLAY_SH1106_ENABLED +#if AP_NOTIFY_DISPLAY_SSD1306_ENABLED #include "Display_SSD1306_I2C.h" +#endif // AP_NOTIFY_DISPLAY_SSD1306_ENABLED +#if AP_NOTIFY_DISPLAY_SITL_ENABLED #include "Display_SITL.h" +#endif // AP_NOTIFY_DISPLAY_SITL_ENABLED #include "AP_Notify.h" #include +#include #include #include @@ -349,14 +356,19 @@ bool Display::init(void) // initialise driver FOREACH_I2C(i) { switch (pNotify->_display_type) { +#if AP_NOTIFY_DISPLAY_SSD1306_ENABLED case DISPLAY_SSD1306: { _driver = probe_i2c_display(i, Display_SSD1306_I2C::probe); break; } +#endif // AP_NOTIFY_DISPLAY_SSD1306_ENABLED +#if AP_NOTIFY_DISPLAY_SH1106_ENABLED case DISPLAY_SH1106: { _driver = probe_i2c_display(i, Display_SH1106_I2C::probe); break; } +#endif // AP_NOTIFY_DISPLAY_SH1106_ENABLED +#if AP_NOTIFY_DISPLAY_SITL_ENABLED case DISPLAY_SITL: { #ifdef WITH_SITL_OSD _driver = Display_SITL::probe(); // never fails @@ -365,6 +377,7 @@ bool Display::init(void) #endif break; } +#endif // AP_NOTIFY_DISPLAY_SITL_ENABLED case DISPLAY_OFF: default: break; diff --git a/libraries/AP_Notify/Display_SH1106_I2C.cpp b/libraries/AP_Notify/Display_SH1106_I2C.cpp index 3ee5a3719d373a..0a49dd4dabdb5e 100644 --- a/libraries/AP_Notify/Display_SH1106_I2C.cpp +++ b/libraries/AP_Notify/Display_SH1106_I2C.cpp @@ -14,6 +14,8 @@ */ #include "Display_SH1106_I2C.h" +#if AP_NOTIFY_DISPLAY_SH1106_ENABLED + #include #include @@ -128,3 +130,5 @@ void Display_SH1106_I2C::clear_screen() { memset(_displaybuffer, 0, SH1106_COLUMNS * SH1106_ROWS_PER_PAGE); } + +#endif // AP_NOTIFY_DISPLAY_SH1106_ENABLED diff --git a/libraries/AP_Notify/Display_SH1106_I2C.h b/libraries/AP_Notify/Display_SH1106_I2C.h index d805d814365434..9daa40315b9cae 100644 --- a/libraries/AP_Notify/Display_SH1106_I2C.h +++ b/libraries/AP_Notify/Display_SH1106_I2C.h @@ -1,5 +1,9 @@ #pragma once +#include "AP_Notify_config.h" + +#if AP_NOTIFY_DISPLAY_SH1106_ENABLED + #include "Display.h" #include "Display_Backend.h" #include @@ -37,3 +41,5 @@ class Display_SH1106_I2C: public Display_Backend { bool _need_hw_update; }; + +#endif // AP_NOTIFY_DISPLAY_SH1106_ENABLED diff --git a/libraries/AP_Notify/Display_SITL.cpp b/libraries/AP_Notify/Display_SITL.cpp index 0d9206d032824f..cbf4dd2891f73b 100644 --- a/libraries/AP_Notify/Display_SITL.cpp +++ b/libraries/AP_Notify/Display_SITL.cpp @@ -12,10 +12,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef WITH_SITL_OSD - #include "Display_SITL.h" +#if AP_NOTIFY_DISPLAY_SITL_ENABLED + +#ifdef WITH_SITL_OSD + #include #include @@ -157,3 +159,5 @@ void Display_SITL::clear_screen() } #endif // WITH_SITL_OSD + +#endif // AP_NOTIFY_DISPLAY_SITL_ENABLED diff --git a/libraries/AP_Notify/Display_SITL.h b/libraries/AP_Notify/Display_SITL.h index 25bc89fc18ac0c..543fb80e5a435b 100644 --- a/libraries/AP_Notify/Display_SITL.h +++ b/libraries/AP_Notify/Display_SITL.h @@ -1,5 +1,9 @@ #pragma once +#include "AP_Notify_config.h" + +#if AP_NOTIFY_DISPLAY_SITL_ENABLED + #ifdef WITH_SITL_OSD #include "Display.h" @@ -49,3 +53,5 @@ class Display_SITL: public Display_Backend { }; #endif // WITH_SITL_OSD + +#endif // AP_NOTIFY_DISPLAY_SITL_ENABLED diff --git a/libraries/AP_Notify/Display_SSD1306_I2C.cpp b/libraries/AP_Notify/Display_SSD1306_I2C.cpp index 56b7e2ef159031..71228839fe0b7d 100644 --- a/libraries/AP_Notify/Display_SSD1306_I2C.cpp +++ b/libraries/AP_Notify/Display_SSD1306_I2C.cpp @@ -14,6 +14,8 @@ */ #include "Display_SSD1306_I2C.h" +#if AP_NOTIFY_DISPLAY_SSD1306_ENABLED + #include #include @@ -143,3 +145,5 @@ void Display_SSD1306_I2C::clear_screen() { memset(_displaybuffer, 0, SSD1306_COLUMNS * SSD1306_ROWS_PER_PAGE); } + +#endif // AP_NOTIFY_DISPLAY_SSD1306_ENABLED diff --git a/libraries/AP_Notify/Display_SSD1306_I2C.h b/libraries/AP_Notify/Display_SSD1306_I2C.h index 665bc26846f8c2..05f1ca2a37708b 100644 --- a/libraries/AP_Notify/Display_SSD1306_I2C.h +++ b/libraries/AP_Notify/Display_SSD1306_I2C.h @@ -1,5 +1,9 @@ #pragma once +#include "AP_Notify_config.h" + +#if AP_NOTIFY_DISPLAY_SSD1306_ENABLED + #include "Display.h" #include "Display_Backend.h" @@ -37,3 +41,5 @@ class Display_SSD1306_I2C: public Display_Backend { uint8_t _displaybuffer[SSD1306_COLUMNS * SSD1306_ROWS_PER_PAGE]; bool _need_hw_update; }; + +#endif // AP_NOTIFY_DISPLAY_SSD1306_ENABLED