Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions libraries/AP_Notify/AP_Notify_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +24 to +27

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// allow boards to include only the display drivers they use
#ifndef AP_NOTIFY_DISPLAY_SSD1306_ENABLED
#define AP_NOTIFY_DISPLAY_SSD1306_ENABLED HAL_DISPLAY_ENABLED
#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
Expand Down
13 changes: 13 additions & 0 deletions libraries/AP_Notify/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h>
#include <AP_HAL/I2CDevice.h>
#include <AP_GPS/AP_GPS.h>
#include <AP_BattMonitor/AP_BattMonitor.h>

Expand Down Expand Up @@ -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
Expand All @@ -365,6 +377,7 @@ bool Display::init(void)
#endif
break;
}
#endif // AP_NOTIFY_DISPLAY_SITL_ENABLED
case DISPLAY_OFF:
default:
break;
Expand Down
4 changes: 4 additions & 0 deletions libraries/AP_Notify/Display_SH1106_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
#include "Display_SH1106_I2C.h"

#if AP_NOTIFY_DISPLAY_SH1106_ENABLED

#include <AP_HAL/AP_HAL.h>
#include <AP_HAL/Device.h>

Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions libraries/AP_Notify/Display_SH1106_I2C.h
Original file line number Diff line number Diff line change
@@ -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 <AP_HAL/I2CDevice.h>
Expand Down Expand Up @@ -37,3 +41,5 @@ class Display_SH1106_I2C: public Display_Backend {
bool _need_hw_update;

};

#endif // AP_NOTIFY_DISPLAY_SH1106_ENABLED
8 changes: 6 additions & 2 deletions libraries/AP_Notify/Display_SITL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef WITH_SITL_OSD

#include "Display_SITL.h"

#if AP_NOTIFY_DISPLAY_SITL_ENABLED

#ifdef WITH_SITL_OSD

#include <AP_HAL/AP_HAL.h>
#include <AP_Notify/AP_Notify.h>

Expand Down Expand Up @@ -157,3 +159,5 @@ void Display_SITL::clear_screen()
}

#endif // WITH_SITL_OSD

#endif // AP_NOTIFY_DISPLAY_SITL_ENABLED
6 changes: 6 additions & 0 deletions libraries/AP_Notify/Display_SITL.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#include "AP_Notify_config.h"

#if AP_NOTIFY_DISPLAY_SITL_ENABLED

#ifdef WITH_SITL_OSD

#include "Display.h"
Expand Down Expand Up @@ -49,3 +53,5 @@ class Display_SITL: public Display_Backend {
};

#endif // WITH_SITL_OSD

#endif // AP_NOTIFY_DISPLAY_SITL_ENABLED
4 changes: 4 additions & 0 deletions libraries/AP_Notify/Display_SSD1306_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
#include "Display_SSD1306_I2C.h"

#if AP_NOTIFY_DISPLAY_SSD1306_ENABLED

#include <AP_HAL/AP_HAL.h>
#include <AP_HAL/Device.h>

Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions libraries/AP_Notify/Display_SSD1306_I2C.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#include "AP_Notify_config.h"

#if AP_NOTIFY_DISPLAY_SSD1306_ENABLED

#include "Display.h"
#include "Display_Backend.h"

Expand Down Expand Up @@ -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
Loading