High Speed SSD1306 Library

[Lewin] wrote in to tell us about a high speed library for Arduino Due that he helped develop which allows interfacing OLED displays that use the SSD1306 display controller, using DMA routines for faster display refresh time.

Typically, displays such as the Monochrome 1.3″ 128×64 OLED graphic display , are interfaced with an Arduino board via the SPI or I2C bus. The Adafruit_SSD1306 library written by [Limor Fried] makes it simple to use these displays with a variety of Arduinos, using either software or hardware SPI. With standard settings using hardware SPI, calls to display() take about 2ms on the Due.

[Lewin] wanted to make it faster, and the SAM3X8E on the Due seemed like it could deliver. He first did a search to find out if this was already done, but came up blank. He did find [Marek Buriak]’s library for ILI9341-based TFT screens. [Marek] used code from [William Greiman], who developed SD card libraries for the Arduino. [William] had taken advantage of the SAM3X8E’s DMA capabilities to enable faster SD card transfers, and [Marek] then adapted this code to allow faster writes to ILI9341-based screens. All [Lewin] had to do was to find the code that sent a buffer out over SPI using DMA in Marek’s code, and adapt that to the Adafruit library for the SSD1306.

There is a caveat though: using this library will likely cause trouble if you are also using SPI to interface to other hardware, since the regular SPI.h library will no longer work in tandem with [Lewin]’s library. He offers some tips on how to overcome these issues, and would welcome any feedback or testing to help improve the code. The speed improvement is substantial. Up to 4 times quicker using standard SPI clock, or 8 times if you increase SPI clock speed. The code is available on his Github repo.

8 thoughts on “High Speed SSD1306 Library

    1. The idea definitely will but I don’t know if the SAM3X8E DMA engine works the same way. You’d probably want to go look at the OctoWS2811 for how the DMA works on the 3.

    2. The Teensy 3 has DMA of a form; people have used these features to speed up writes to other types of screen. However, this library is specific to the Arduino Due with its SAM3X8E. The Teensy uses a different processor, and this library uses processor-specific functions, so it won’t work with the Teensy.

      A good place to start would be to look at SSD1306 implementations on the Teensy, and look at implementations of DMA on the Teensy, and see if you could stick those together. It can be tough to understand in the beginning, but three weeks ago, I didn’t think I could do this, and I got there, so I’m sure you can make it too!

  1. I’m sure Paul Stoffegren would say otherwise about its performance relative the Teensy. Good try hackaday, though I don’t see any sales conversion on Arduinos and the other sponsors that fund you.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.