Test with EzSbc2 LPC1347 board and Adafruit 0,96" display, connected to i2c

Dependencies:   Adafruit_GFX I2CDevLib MPU9150 SmallGUI USBDevice WeeESP8266 mbed nRF24L01P

main.cpp

Committer:
JojoS
Date:
2014-11-17
Revision:
0:e1e154fcc87e
Child:
2:2eb3f38f9141

File content as of revision 0:e1e154fcc87e:

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

// modified für EzSBC2

DigitalOut ledRed(P1_16);
DigitalOut ledGreen(P1_15);

// an SPI sub-class that provides a constructed default
class SPI2 : public SPI
{
public:
    SPI2(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 I2C2 : public I2C
{
public:
    I2C2(PinName sda, PinName scl) : I2C(sda, scl)
    {
        frequency(400000);
        start();
    };
};
 

I2C2 gI2C(P0_5, P0_4);
Adafruit_SSD1306_I2c gOled2(gI2C, P0_21, 0x78, 64, 128);
// Adafruit_SSD1306_I2c gOled2(gI2C, NC, 0x78, 64, 128);    // works only with mbed libs < version 86
 
int main()
{   
    uint16_t x=0;
 
    //while(1) 
    {
        ledRed = 1;
        ledGreen = 0;
        wait(0.5);

        ledRed = 0;
        ledGreen = 1;
        wait(0.5);
    }

    gOled2.clearDisplay();
    gOled2.display();

    //gOled2.setTextCursor(1, 0);
    gOled2.printf("%ux%u OLED Display\r\n", gOled2.width(), gOled2.height());
    
    while(1)
    {
        ledRed = !ledRed;
        
        gOled2.setTextCursor(0, 10);
        gOled2.printf("%u\r", x);
        gOled2.display();
        
        x++;
        wait(1.0);
    }
// AnalogOut sine(PA_4);

   
}