State machine

Dependencies:   mbed Adafruit_GFX BioroboticsMotorControl MODSERIAL BioroboticsEMGFilter

Revision:
3:4b19b6cf6cc7
Child:
4:5a44ab7e94b3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Screen.h	Tue Oct 30 11:40:00 2018 +0000
@@ -0,0 +1,46 @@
+#pragma once
+
+#include "mbed.h"
+
+// Uncomment this in the adafruit config.h to turn off the builtin splash
+//#define NO_SPLASH_ADAFRUIT
+// Uncomment this in the adafruit config.h to enable all functionality
+//#define GFX_WANT_ABSTRACTS
+
+#include "Adafruit_SSD1306.h"
+
+
+class Screen
+{
+private:
+    I2C i2c;
+    Adafruit_SSD1306_I2c oled;
+public:
+    // The screen we use doesn't have a reset pin, but it needs one anyway.
+    // Use a pin we don't use.
+    Screen(PinName sda, PinName scl, PinName reset):
+        i2c(sda, scl),
+        oled(i2c, reset) {
+            
+        // according to the spec the max bitrate for the SSD1308 is 400 kbit/s
+        i2c.frequency(400000);
+
+        // IMPORTANT! Otherwise nothing will be displayed.
+        oled.clearDisplay();
+        display();
+    }
+
+    void display() {
+        // Apparently the display only updates every 2 "display" calls.
+        // This is a bug in the library.
+        oled.display();
+        oled.display();
+    }
+
+    // Returns a direct handle to the screen.
+    // Be carefull while using the handle.
+    Adafruit_SSD1306_I2c get_screen_handle() {
+        return oled;
+    }
+    
+};
\ No newline at end of file