Write the OLED(using I2C)

Dependencies:   Adafruit_GFX mbed

main.cpp

Committer:
IOP
Date:
2015-08-05
Revision:
9:a6021ca48d2e
Parent:
8:e61e86355653
Child:
10:abbd34fe7ce1

File content as of revision 9:a6021ca48d2e:

#include "mbed.h"
#include "Adafruit_SSD1306.h"

DigitalOut myled_R(LED1);

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

I2CPreInit myI2C(PA_10,PA_9);
Adafruit_SSD1306_I2c myOled(myI2C,NC,0x78,64,128);

int main()
{   
    uint16_t x=0;
 
    myOled.begin();
    myOled.printf("%ux%u Hellow World\r\n", myOled.width(), myOled.height());
    myOled.display();

    while(1)
    {
        myled_R = !myled_R;
        myOled.printf("%u\r",x);
        myOled.display();
        x = x + 1;                  
        wait(1.0);
    }
}