![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Oled I2C SSD1306
Dependencies: SSD1306_128x64_I2C mbed
Fork of DisplayOled1 by
Diff: main.cpp
- Revision:
- 1:7195b6d24cf4
- Parent:
- 0:3b87797f65fc
- Child:
- 2:ebb4b427aecc
--- a/main.cpp Tue May 16 15:18:54 2017 +0000 +++ b/main.cpp Tue May 23 18:39:12 2017 +0000 @@ -1,103 +1,22 @@ -#include "mbed.h" -#include "Adafruit_SSD1306.h" - -DigitalOut led1(LED_RED); - -// SPI sub-class that provides a constructed default -class I2CPreInit : public I2C -{ -public: - I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) - { - //frequency(400000); - frequency(100000); - start(); - }; -}; - -I2CPreInit myI2C(PTE0,PTE1); -Adafruit_SSD1306_I2c myOled(myI2C,NC,0x78,64,128); + #include "mbed.h" + #include "SSD1306.h" -int main() -{ - uint16_t x=0; + #define D_SDA PTE25 + #define D_SCL PTE24 + I2C i2c(D_SDA, D_SCL); + + SSD1306 oled = SSD1306(i2c, SSD1308_SA0); - myOled.begin(); - myOled.printf("%ux%u Hellow World\r\n", myOled.width(), myOled.height()); - myOled.display(); + int main() { + oled.writeString(0, 0, "Universidad Distrital"); + // oled.printf("Hello World !"); + wait(1); + + oled.writeString(0, 0, "2017 Digitales II"); - while(1) - { - led1 = !led1; - myOled.printf("%u\r",x); - myOled.display(); - x = x + 1; - wait(1.0); - } -} + - - + } -/* -#include "mbed.h" -#include "Adafruit_SSD1306.h" - -class I2CPreInit : public I2C -{ -public: - I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) - { - frequency(100000); - start(); - }; -}; - -I2CPreInit myI2C(PTE0,PTE1); -Adafruit_SSD1306_I2c myOled(myI2C,NC,0x78,64,128); - -int main() -{ - - uint16_t x=0; - - myOled.begin(); - myOled.clearDisplay(); - myOled.display(); - wait(0.1); - - myOled.fillCircle(64, 42, 10, 1); - myOled.display(); - wait(1); - myOled.fillCircle(64, 42, 5, 0); - myOled.display(); - wait(1); - - myOled.clearDisplay(); - myOled.display(); - wait(0.1); - - myOled.printf("\r\n OLED %ux%u \r\n\r\n Hello World\r\n\n", myOled.width(), myOled.height()); - - myOled.drawRect(0, 0, 128, 64,1); - myOled.display(); - wait(0.5); - while(1) - { - - myOled.printf("%u\r ",x); - - myOled.drawRect(0, 0, 128, 64,1); - - myOled.display(); - x = x + 1; - wait(0.01); - } -} -*/ - - - -