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

Example

/*
 *  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
{
public:
    SPIPreInit(PinName mosi, PinName miso, PinName clk) : SPI(mosi,miso,clk)
    {
        format(8,3);
        frequency(2000000);
    };
};

// an I2C sub-class that provides a constructed default
class I2CPreInit : public I2C
{
public:
    I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl)
    {
        frequency(400000);
        start();
    };
};

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());
    
    while(1)
    {
        myled = !myled;
        gOled1.printf("%u\r",x);
        gOled1.display();
        gOled2.printf("%u\r",x);
        gOled2.display();
        x++;
        wait(1.0);
    }
}
Committer:
JojoS
Date:
Tue Nov 11 22:08:20 2014 +0000
Revision:
16:7fb1d4d3525d
Parent:
13:8f03f908f22a
removed test comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nkhorman 13:8f03f908f22a 1 #ifndef _ADAFRUIT_GFX_CONFIG_H_
nkhorman 13:8f03f908f22a 2 #define _ADAFRUIT_GFX_CONFIG_H_
nkhorman 13:8f03f908f22a 3
nkhorman 13:8f03f908f22a 4 // Uncomment this to turn off the builtin splash
nkhorman 13:8f03f908f22a 5 //#define NO_SPLASH_ADAFRUIT
nkhorman 13:8f03f908f22a 6
nkhorman 13:8f03f908f22a 7 // Uncomment this to enable all functionality
nkhorman 13:8f03f908f22a 8 //#define GFX_WANT_ABSTRACTS
nkhorman 13:8f03f908f22a 9
nkhorman 13:8f03f908f22a 10 // Uncomment this to enable only runtime font scaling, without all the rest of the Abstracts
nkhorman 13:8f03f908f22a 11 //#define GFX_SIZEABLE_TEXT
nkhorman 13:8f03f908f22a 12
nkhorman 13:8f03f908f22a 13
nkhorman 13:8f03f908f22a 14 #endif