Character only library for OLED display

by fat16lib on Wed Feb 29, 2012 3:15 pm

I wrote a character only library for the Monochrome 128x32 OLED graphic display. It should also work on the 128x64 display but I have not tested it since I don't have this display.

This library is not buffered so it uses about 500 bytes less RAM than the Adafruit graphic library.

This neat tiny display can used in place of a standard LCD in projects that are short of RAM by using this library.

The file is at

Here is the readme file:
SSD1306ASCII is an unbuffered character only library for an Adafruit 1306
OLED display. The SSD1306ASCII library only requires a few bytes of RAM.

SSD1306ASCII implements a small part of the LiquidCrystal API. Implemented
functions include clear(), home(), print(), setCursor(), and write().

It has only been tested with the "Monochrome 128x32 OLED graphic display".

To use this library, copy the SSD1306ASCII folder to your libraries folder.

Edit SSD1306ASCII.h and select your display type. The default is:

// #define SSD1306_128_64
#define SSD1306_128_32

Select the font that will be used by defining FONT_TYPE. The default is:

#define FONT_TYPE 1

This is an 96 character version of the Adafruit glcdfont.

See SSD1306fonts.pdf for a rough representation of other choices.

Try the ssd1306HelloWorld example first.

The ssd1306ShowFont example displays all characters in the font.

The ssd1306FontMap example was used to generate SSD1306fonts.pdf.
Posts: 591
Joined: Wed Dec 24, 2008 12:54 pm

Re: Character only library for OLED display

by Desert_Rat on Fri Apr 13, 2012 4:34 pm

Thank you! Since my little project doesn't require graphics, only text I easily replaced the Adafruit library with this one and not only did it give me a little more RAM, it reduced the program code itself about 2k as well.
This is great for those that don't require fancy graphic capabilities and only use text.
I went from living in a van down by the river to a shack in the desert.
Meh, at least it's an upgrade.
User avatar
Posts: 5
Joined: Sun Mar 18, 2012 4:04 am

Re: Character only library for OLED display

by zulucat on Tue Apr 17, 2012 1:40 am

fat16lib wrote: ... It should also work on the 128x64 display but I have not tested it since I don't have this display ...

I did some quick testing with my 128x64 display. Both HelloWorld and ShowFont examples work with the bigger display.
User avatar
Posts: 27
Joined: Wed Nov 16, 2011 11:43 pm
Location: Southern SoCal

Re: Character only library for OLED display

by davegior on Sat May 05, 2012 7:05 pm

Fantastic. Much easier to use than the sample librarary. Thank you for sharing it with us.
Question: is there a character for Omega? Ω
Posts: 9
Joined: Mon Apr 30, 2012 10:56 am
Location: NYC

Re: Character only library for OLED display

by buton on Wed Feb 27, 2013 9:19 am

just what i was looking for...

Posts: 54
Joined: Fri May 11, 2012 7:06 am

Re: Character only library for OLED display

by nyukin on Sat Jan 04, 2014 7:04 pm

This post may be a couple years old, but this library looks perfect for an application I need. Thanks for sharing. I'm happy my RAM constrained sketch might still run despite swapping a lower res display for the 128 x 64 OLED. Can't wait for it to arrive from Adafruit. 8)

Edit: yep, subbing this library for the PCD8544 with the Nokia 5110 84 x 48 LCD uses exactly 1 more byte of RAM for me. This compares to 84x48/2=504 bytes in the frame buffer for that library and 128x64/8 bytes if we buffer in RAM like with the regular Adafruit graphics library.

Also I fixed a few simple compilation errors that occur with newer versions of avr-gcc like in Arduino 1.03, which I'm using in my linux environment. You can read more at

Each of the font.h files need
Code: Select all
prepending the line that reads
Code: Select all
static unsigned char font[] PROGMEM = {
This is also true for the SSD1306ASCII.cpp file for the two lines reading
Code: Select all
uint8_t *base = font + 5 * c;

Maybe this well help somebody else in a few years? :wink:
Last edited by nyukin on Sat Jan 04, 2014 8:05 pm, edited 2 times in total.
Posts: 8
Joined: Tue Jan 25, 2011 4:25 am