Small example using ultrasonic

Dependencies:   mbed

Revision:
0:bd7dd6e79e36
Child:
1:8fafe8a483e9
diff -r 000000000000 -r bd7dd6e79e36 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Aug 11 17:36:11 2017 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "Adafruit_SSD1306.h"
+
+// OLED:    SDA       -> Arduino Analog 4
+//          SCL       -> Arduino Analog 5
+
+#define SSD1306_ADDRESS 0x78
+
+// an I2C sub-class that provides a constructed default
+class I2CPreInit : public I2C
+{
+public:
+    I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl)
+    {
+        frequency(400000);
+        start();
+    };
+};
+
+uint8_t led_height = 64;
+uint8_t led_width = 128;
+
+I2CPreInit gI2C(PC_1,PC_0);
+Adafruit_SSD1306_I2c gOled(gI2C,PA_8,SSD1306_ADDRESS,led_height,led_width);
+
+DigitalOut led(LED1);
+
+int main() {
+    gOled.begin();
+    gOled.clearDisplay();
+    gOled.display();
+    wait(0.1);
+    while(1){
+        led = !led;
+        gOled.clearDisplay();
+        gOled.drawPixel(0,0,WHITE);
+        gOled.fillCircle(64, 42, 10, WHITE);
+        gOled.display();
+        wait(0.1);
+    }
+}