I have just posted a new version of the SSD1306Ascii library on GitHub.
The original version was posted on Google Code in 2012.
There are many existing full featured graphics libraries for these displays. The goal for this library is to only display text with minimum use of RAM and flash.
Here is memory use for the SPI "Hello world!" example:
Sketch uses 2,582 bytes (8%) of program storage space. Maximum
is 32,256 bytes.
Global variables use 52 bytes (2%) of dynamic memory, leaving
1,996 bytes for local variables. Maximum is 2,048 bytes.
// Test for minimum program size.
// pin definitions
#define OLED_DC 9
#define OLED_CS 10
#include <SPI.h>
#include <SSD1306Ascii.h>
#include <SSD1306SpiAscii.h>
SSD1306SpiAscii oled;
//------------------------------------------------------------------------------
void setup() {
oled.begin(&Adafruit128x64, OLED_CS, OLED_DC);
oled.setFont(System5x7);
oled.clear();
oled.print("Hello world!");
}
//------------------------------------------------------------------------------
void loop() {}
Here are key design goals:
Small size is the highest priority. Speed and features are lower priority.
Support multiple fonts. More than 40 fonts are included with this release. Fonts are only loaded if you reference them.
Support fixed width and proportional fonts.
Optionally magnify fonts by a factor of two.
Support 128x32 and 128x64 displays with I2C and SPI interfaces.
Use the standard Wire library for I2C. An optimization option is available to increase I2C performance.
Use the standard SPI library for hardware SPI. An optimization option is available for AVR to increase performance and reduce code size.
Provide software SPI so the display can be connected to any digital pins.
Here are are some development pictures: