SSD1306 OLED Display

SSD1306 OLED Display Driver for BeagleBone

Today, we can see a lot of products using the OLED display technology such as TV’s, cell phones etc. A very common example I can give you is the smartwatches and fitness bands. One such display is the SSD1306. The SSD1306 is small, consumes less power and has a crisp display.

The SSD1306 along with the BeagleBone is a great option for those who are looking for a high processing capacity with a small and low-cost display. However, If one is looking to develop an HMI for industrial applications, then the Touch Screen Displays by 4D Systems is a great option.

The cost of 4D touchscreen displays are slightly expensive but is well suited for controlling machines. I have shown how to use these displays with the BeagleBone using Qt in my previous posts. To know more, you can start from here.

1. SSD1306 OLED Driver Components

The SSD1306 Library was ported to C from the C++ libraries written by Adafruit for the Arduino/Atmel MCU’s. After understanding the architecture of Adafruit’s C++ libraries, I realized there are 3 components:

  1. The low-level I2C component that is responsible for enabling communication between the MCU and the Display.
  2. The control component that is responsible to send the control and data commands from the MCU to the Display. For e.g. Invert the display.
  3. The Graphics component that is responsible for displaying bitmaps, drawing figures, printing texts, numbers etc.

Before starting the development and porting, I architected the driver such that it will just have 2 components to minimize the number of files and complexity. One is the I2C component and the second component is a merge of both i.e. Control and Graphics Components. And of course,  C language lacks features such as virtual functions, function overloading, function overriding etc which are basically present in  C++. But, however, since I develop most of the applications in C, I decided to go with it. If required, one can easily port this Library to C++ as well.

2. SSD1306 OLED Library

This library comprises of five files. They are as follows:

To include the library in your project, simply include and compile the above source files in your project. You can download the Library from my Github or clone it using the below command.

3. SSD1306 OLED Library Usage and Demo

In the Github repository, you can find two source files within the Example directory. They are as follows:

The example_app.c shows examples of how to use the SSD1306 API’s. To run the example, compile the example_app.c and Main.c along with the SSD1306 Library files. And then run the generated bin file.

The above video shows the example code running on the BeagleBone and displaying graphics on the SSD1306 OLED Display.

Leave a Reply

Your email address will not be published. Required fields are marked *