Tiny Graphics Library

This small graphics library provides point, line, and character plotting commands for use with an I2C 128x64 OLED display on an ATtiny85.

It supports processors with limited RAM by avoiding the need for a display buffer, and works with I2C OLED displays based on the SH1106 driver chip. These are available for a few dollars from a number of Chinese suppliers.

To demonstrate the graphics library I’ve written a simple application to measure the temperature every 15 minutes over a 24-hour period and display it as a live chart.

The monochrome OLED graphics displays are accessed a byte at a time, and each byte represents 8 pixels; to plot a point you need to change just one pixel leaving the others unaffected, so you need to know what the previous contents of the byte were.

The usual way to implement graphics commands on this type of display is to use a RAM buffer, and do all the drawing into the buffer. You then copy the entire buffer to the display when you want to update the display. This is the approach taken by Adafruit in their SSD1306 library [1]. However, a 128x64 monochrome display requires a 1024-byte buffer, which rules out the ATtiny85 because it only has 512 bytes of RAM. The largest display the ATtiny85 can support this way is 64x48, as in my ATtiny85 Graphics Display.

The OLED displays available from Chinese suppliers tend to be based on the SH1106 driver chip rather than the SSD1306 used in the displays sold by Adafruit. While browsing the SH1106 datasheet [2] I noticed that the I2C interface not only supports writing data to the display, but also reading data back from the display, making it possible to have a full 128x64 graphics display without needing any RAM buffer. This allows you to provide a full graphics display to projects based on the ATtiny85, and the other ATtiny processors.”


Related Content