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: SSD1306_128x64_I2C mbed
Fork of DisplayOled by
Diff: main.cpp
- Revision:
- 0:3b87797f65fc
- Child:
- 1:7195b6d24cf4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue May 16 15:18:54 2017 +0000
@@ -0,0 +1,103 @@
+#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);
+
+int main()
+{
+ uint16_t x=0;
+
+ myOled.begin();
+ myOled.printf("%ux%u Hellow World\r\n", myOled.width(), myOled.height());
+ myOled.display();
+
+ 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);
+ }
+}
+*/
+
+
+
+
