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


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


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


This is the native display width and height.


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


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


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

Graphical Configuration using the AdaColorGfxMenuConfig structure

When using this driver, you may well need to change the drawing settings such as font, spacing and colors to suit your display. For Adafruit_GFX this is the configuration type, if you leave the config field blank, the generator will provide a default with name gfxConfig.

AdaColorGfxMenuConfig gfxConfig;

It is probable that you’ll either want to completely override, or make some small adjustments to the graphics configuration. See the graphical configuration section in this rendering guide.

When you don’t choose a graphics configuration by leaving the property blank, the code generator will use a default one on your behalf, by adding it to your <project>_menu.cpp file:

Back to tcMenu main page

Other pages within this category

comments powered by Disqus

We use cookies to analyse traffic and to personalise content. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Please see our privacy policy should you need more information or wish to adjust your settings.

Send a message

This message will be securely transmitted to Nutricherry LTD servers.