Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Adafruit_GFX mbed
main.cpp
- Committer:
- JojoS
- Date:
- 2014-11-17
- Revision:
- 0:e1e154fcc87e
- Child:
- 3:671cc904fce6
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);
   
}