Skip to content

AP_Notify: allow display drivers to be disabled - #34064

Open
muramura wants to merge 1 commit into
ArduPilot:masterfrom
muramura:ap-notify-display-driver-options
Open

AP_Notify: allow display drivers to be disabled#34064
muramura wants to merge 1 commit into
ArduPilot:masterfrom
muramura:ap-notify-display-driver-options

Conversation

@muramura

Copy link
Copy Markdown
Contributor

Summary

Allow boards to enable only the AP_Notify display drivers they use.

This adds per-display-driver build options for SSD1306, SH1106, and SITL display backends, while keeping the existing default behavior unchanged.

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Built Copter for esp32s3m5stampfly with extra hwdef settings enabling only SSD1306 display support and disabling SH1106 display support. Confirmed the build succeeds, the final ELF contains Display_SSD1306 symbols, and no Display_SH1106 symbols are present.

Also built Copter for esp32s3m5stampfly with extra hwdef settings enabling only SH1106 display support and disabling SSD1306 display support. Confirmed the build succeeds, the final ELF contains Display_SH1106 symbols, and no Display_SSD1306 symbols are present.

Hardware tested on M5StampFly with a Grove SSD1315 OLED display connected to the I2C Grove port. The display works using the SSD1306 driver with NTF_DISPLAY_TYPE=1.

P_20260815_094911

Description

Some small boards only need one AP_Notify display backend. Before this change, Display.cpp referenced SSD1306, SH1106, and SITL display backends directly whenever display support was enabled. That made it difficult for board-specific hwdef files to include only the display backend they actually use.

This change adds:

  • AP_NOTIFY_DISPLAY_SSD1306_ENABLED
  • AP_NOTIFY_DISPLAY_SH1106_ENABLED
  • AP_NOTIFY_DISPLAY_SITL_ENABLED

The defaults preserve current behavior. Boards can override these defines from hwdef to reduce unused display driver code.

@peterbarker peterbarker left a comment

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.

Encase all of the relevant source files in the same defines.

i.e. do not rely on the compiler eliding stuff, it's not entirely reliable and does lead to stuff being included when you really don't want it.

Comment on lines +20 to +23
// 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

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

Comment thread libraries/AP_Notify/AP_Notify_config.h Outdated
#endif

#ifndef AP_NOTIFY_DISPLAY_SH1106_ENABLED
#define AP_NOTIFY_DISPLAY_SH1106_ENABLED HAL_DISPLAY_ENABLED

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
#define AP_NOTIFY_DISPLAY_SH1106_ENABLED HAL_DISPLAY_ENABLED
#define AP_NOTIFY_DISPLAY_SH1106_ENABLED AP_NOTIFY_DISPLAY_BACKEND_DEFAULT_ENABLED

Comment thread libraries/AP_Notify/AP_Notify_config.h Outdated
#endif

#ifndef AP_NOTIFY_DISPLAY_SITL_ENABLED
#define AP_NOTIFY_DISPLAY_SITL_ENABLED (HAL_DISPLAY_ENABLED && (CONFIG_HAL_BOARD == HAL_BOARD_SITL))

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
#define AP_NOTIFY_DISPLAY_SITL_ENABLED (HAL_DISPLAY_ENABLED && (CONFIG_HAL_BOARD == HAL_BOARD_SITL))
#define AP_NOTIFY_DISPLAY_SITL_ENABLED (AP_NOTIFY_DISPLAY_BACKEND_DEFAULT_ENABLED && (CONFIG_HAL_BOARD == HAL_BOARD_SITL))

Comment thread libraries/AP_Notify/Display.cpp Outdated
_driver = probe_i2c_display(i, Display_SH1106_I2C::probe);
break;
}
#endif

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
#endif
#endif // AP_NOTIFY_DISPLAY_SH1106_ENABLED

similarly elswhere

@muramura
muramura force-pushed the ap-notify-display-driver-options branch from 3e935d5 to 8432c69 Compare August 17, 2026 16:40
@muramura

Copy link
Copy Markdown
Contributor Author

@peterbarker san
Updated as requested:

  • Enclosed all display driver source and header files in their respective #if AP_NOTIFY_DISPLAY_... defines.
  • Added AP_NOTIFY_DISPLAY_BACKEND_DEFAULT_ENABLED in AP_Notify_config.h.
  • Added comments to #endif directives in Display.cpp.

Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants