displaying on SSD1306, 128x64 pixels OLED

Dependencies:   microbit

Revision:
6:c69f08f464b5
diff -r c6a273f21cb4 -r c69f08f464b5 example_OLED.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example_OLED.cpp	Sun Feb 23 01:57:35 2020 +0000
@@ -0,0 +1,32 @@
+#include "MicroBit.h"
+#include "MicroBitPin.h"
+
+#include "common.h"
+
+
+void  example_OLED() {
+    oled.init();
+    
+    oled.puts("*** VOLTMETER ****\n\n");
+    char spin[] = "|/-\\";
+    uint8_t si=0;
+    float oldVoltage=0;
+    while(true) {
+        uint16_t samples =uBit.io.P0.getAnalogValue();
+        
+        float voltage = 3.3*samples/1023;
+        int8_t dir = voltage - oldVoltage > 0.01 
+            ? 1
+            : voltage - oldVoltage < -0.01
+                ? -1
+                : 0;
+        if (dir) {
+            si = (si+dir) & 3;
+            oldVoltage=voltage;
+            }
+        oled.printf("\r%c %03.2f volt ",spin[si],voltage);
+        
+        }    
+}
+
+