SSD1306 OLED display driver  1.5.0
This library is developed to control SSD1306/SSD1331 RGB i2c/spi OLED displays and spi PCD8544 LED display
SSD1306/SSD1331/PCD8544 API.

This is SSD1306/SSD1331 OLED display driver implementation for Arduino, AVR, Extensa platforms. The driver supports i2c and spi displays, and is also capable to work with pcd8544 (nokia 5110) LCD over SPI.

SSD1306 OLED display driver

Introduction

SSD1306 OLED display driver is Arduino style library, AND it can be compiled with plain avr-gcc compiler without Arduino libraries. It is intended for use with very small microcontrollers (with a little of SRAM). It was developed to use as few resources as possible. Since ATTiny controllers have no division and multiply operations, the library uses shift operation to speed up calculations.

Key Features

The default i2c pins for embedded implementation can be modified in ssd1306_i2c_conf.h file. For other controllers pins are defined by standard Wire library. The default spi SCLK and MOSI pins are defined by SPI library, and DC, RST, CES pins are configurable through API.

Supported displays:

Supported platforms

The goals of ssd1306 library

Adding new interface

If you need to add new not supported interface for the library, just implement interface specific functions and assign them to function pointers:

void setup()
{
ssd1306_startTransmission = &myStartTransmissionFunc;
ssd1306_endTransmission = &myEndTransmissionFunc;
ssd1306_sendByte = &mySendByteToInterfaceFunc;
ssd1306_commandStart = &myStartCommandModeTransmissionFunc;
ssd1306_dataStart = &myStartDataModeTransmissionFunc;
...
# init your interface here
myInterfaceInit();
}

Refer to SPI, I2C interfaces init function to understand required implementation.

Adding new LCD type to the library

The main requirements for LCD display to use it with this library are:

Each byte, sent to LCD, represents 8 vertical pixels After sending each byte LCD controller shifts GDRAM pointer to the right by 1 pixel LCD width should not exceed 128 pixels

To add new LCD type to the library, implement GDRAM address positioning functions and initialization function for you LCD:

#include "lcd/lcd_common.h"
void myDisplayInit()
{
# Use LCD_TYPE_CUSTOM constant
# Set display size:
# Width should be less or equal to 128
# Height should be less or equal to 128
ssd1306_setRamBlock = &mySetRamBlockFunc;
ssd1306_nextRamPage = &myNextPageFunc;
ssd1306_setRamPos = mySetRamAddressFunc;
# Put you LCD initialization code here
...
}
void setup()
{
# Init the interface here
...
# Call LCD initialization here
myDisplayInit();
}

Refer to SH1106 intialization implementation as reference code.