A derived version of the BSD licensed Adafrut GFX library for the SSD1306 controller for an OLED 128x32 or 128x64 display using SPI or I2C.

Dependents:   servo_sensor ArchPro_TFT BLE_Display SSD1306_demo ... more

Import libraryAdafruit_GFX

A derived version of the BSD licensed Adafrut GFX library for the SSD1306 controller for an OLED 128x32 or 128x64 display using SPI or I2C.

This is an SPI or I2C driver, font, and graphics drawing library as initially provided by Adafruit which has been modified for use in the mbed envionment.

128x32 OLED Display


 *  Copyright (c) 2012 Neal Horman - http://www.wanlink.com
 *  License: MIT open source (http://opensource.org/licenses/MIT)
 *      Summary;
 *      Use / modify / distribute / publish it how you want and 
 *      if you use it, or don't, you can't hold me liable for how
 *      it does or doesn't work.
 *      If it doesn't work how you want, don't use it, or change
 *      it so that it does work.
#include "mbed.h"
#include "Adafruit_SSD1306.h"

DigitalOut myled(LED1);

// an SPI sub-class that provides a constructed default
class SPIPreInit : public SPI
    SPIPreInit(PinName mosi, PinName miso, PinName clk) : SPI(mosi,miso,clk)

// an I2C sub-class that provides a constructed default
class I2CPreInit : public I2C
    I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl)

SPIPreInit gSpi(p5,NC,p7);
Adafruit_SSD1306_Spi gOled1(gSpi,p26,p25,p24);

I2CPreInit gI2C(p9,p10);
Adafruit_SSD1306_I2c gOled2(gI2C,p27);

int main()
{   uint16_t x=0;

    gOled1.printf("%ux%u OLED Display\r\n", gOled1.width(), gOled1.height());
    gOled2.printf("%ux%u OLED Display\r\n", gOled2.width(), gOled2.height());
        myled = !myled;


RevisionDateWhoCommit message
16:7fb1d4d3525d 2014-11-11 JojoS removed test comments default tip
15:77feec1c0684 2014-11-11 JojoS copy in line 211 requires index-1 because x starts at offset 1 and not at 0.
14:edb3c36aa1a7 2014-10-25 nkhorman Code space optimizations;; Make simple set/getter functions inlined.; Fix ifdef around setTextSize() to be either GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT; ifdef drawBitmap() w/ GFX_WANT_ABSTRACTS.;
13:8f03f908f22a 2014-10-21 nkhorman flesh out the config defines
12:7964c2cfdebc 2014-10-21 nkhorman merge documentation
11:86909e6db3c8 2014-10-21 nkhorman Add some documentation
10:d5aee2d2f8dd 2014-10-20 nkhorman fix - missed this in the refactor
9:ddb97c9850a2 2014-10-19 nkhorman c++'ify the SPI vs I2C driver portions, instead of compile time defines.; The SSD1306 driver can now be instantiated multiple times, supporting simultaneous displays of differing dimensions.
8:416b8fe451b3 2014-10-19 nkhorman fix compile warning and error
7:779204e24db4 2014-10-18 Neal Horman missed this define change in the last change set
6:1be3e3b46eb7 2014-10-18 Neal Horman hand merge Alo?s Wolff's i2c additions with a few #define tweaks
5:315de3647c9f 2014-10-16 Neal Horman tweak Christians idea.
4:853097cfa773 2014-04-29 chrta Remove some duplicated code.
3:969ca9fe5e2b 2013-01-23 nkhorman line endings ?
2:7bcea45e60d8 2012-08-19 nkhorman change swap() from a define to a static inline function to quell compiler problems.
1:9db12505727a 2012-07-17 nkhorman change the default background color to black
0:c3dcd4c4983a 2012-07-16 nkhorman add adafruit oled 128x32 display library via spi interface.; display card reader events on the oled