Main Content

Colour Graphics Library

This is a small colour graphics library for an SPI 96x64 colour OLED display based on an SD1331. It allows you to plot points, lines, filled and open rectangles, and text with small or large characters.

Unlike most other SPI OLED display libraries this one doesn’t require a memory buffer, allowing it to be run on any processor down to an ATtiny85. It also requires only three pins to drive the display, leaving two pins free on an ATtiny85 to interface to other devices, such as I2C sensors.

Introduction
This library is based on a low-cost 96x64 OLED display with 64K colours, and an SPI interface. It’s available from a number of suppliers including Adafruit [1] or Banggood [2].

Most OLED SPI display drivers make a distinction between commands and data. Command bytes configure the operation of the display, such as defining the pixel to write to. Data bytes are written into the display memory. To plot points, draw lines, clear the display, and plot text you have to write data. You identify whether bytes should be interpreted as commands or data by the state of the DC input: low for commands and high for data.

This display is based on the SD1331 driver chip [3], which is unique in having graphics accelerator commands that allow you to draw lines and rectangles without having to write into the graphics data memory. The graphics accelerator commands are really fast; the usual way to clear the screen is to write zeroes into the entire graphics data memory, and a test routine I wrote to do this took 91ms. Using the Clear Window graphics accelerator command took under one millisecond, a factor of 100 faster!

With the graphics accelerator commands it’s possible to make a graphics library that doesn’t actually need to write data directly to the display memory. In addition to being fast, this has the additional advantage of freeing up the DC pin, which can be tied permanently low. So there are now two free pins on the ATtiny85, enough to provide an I2C interface to connect up sensors and other devices.”

Link to article