By dave | September 10, 2020

TcMenu - Using Adafruit_GFX mbed to render menus

In this guide we show how to use the Adafruit_GFX library for mbed RTOS to renderer menu items with tcMenu. This rendering driver for Adafruit_GFX is built into the core menu designer download, meaning it’s available out of the box when MBED_RTOS is selected.

We maintain a fork of Adafruit_GFX library for mbed that currently supports OLED displays only. Therefore, at the moment all options are memory buffered.

Before proceeding, you’ll need to make sure you’ve installed the Adafruit_GFX for mbed library and the library; which also contains the OLED drivers. I’d recommend taking a read through the Adafruit_GFX library documentation if you’re not familiar with the library already. We’ll also assume you’ve got a menu structure already prepared in the menu designer UI.

Related documentation:

Plugin and Library details

Configuring the rendering for your display

First, ensure your menu structure is saved and then choose Code -> Generate Code from the menu. Once the code generation dialog appears, change the current display by either pressing on the image (or on older UIs a button named “Change”). From this menu select the Adafruit mbed driver.

Adafruit_GFX mbed fork option
Image showing Adafruit_GFX mbed fork choice

Once you’ve chosen this display type, the following properties will be added to the table at the bottom:

Property Choices for this renderer
Image showing property choices for Adafruit_GFX mbed rendering

DISPLAY_VARIABLE property

This is variable name that the designer should generate on your behalf, it will export the variable ready for use.

DISPLAY_TYPE property

We support either SSD_1306 and SH_1106 OLED displays at the moment.

DISPLAY_WIDTH and DISPLAY_HEIGHT

This is the native display width and height.

SERIAL_BUS_TYPE

This is the serial bus type that your display is on either I2C or SPI.

BUS_REFERENCE

The variable you’ve created that represents the serial bus. EG an I2C or SPI reference.

RESET_PIN

Optionally, the reset pin for the device

CS and RS (data register select)

Optionally the RS and CS pins when using SPI

Display Rotation

The rotation of the display between 0 and 3, 0 for regular

Updates per second

How many times the menu structure should be scanned for changes and redrawn if needed. TcMenu tries to minimise redraws where reasonably possible.

Back to tcMenu main page

Other pages within this category

This site uses cookies to analyse traffic, and to record consent. We also embed Twitter and Youtube content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.