State machine

Dependencies:   mbed Adafruit_GFX BioroboticsMotorControl MODSERIAL BioroboticsEMGFilter

Revision:
4:5a44ab7e94b3
Parent:
3:4b19b6cf6cc7
Child:
5:2632dfc8454c
--- a/Screen.h	Tue Oct 30 11:40:00 2018 +0000
+++ b/Screen.h	Tue Oct 30 11:52:50 2018 +0000
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "mbed.h"
+#include <string>
 
 // Uncomment this in the adafruit config.h to turn off the builtin splash
 //#define NO_SPLASH_ADAFRUIT
@@ -25,7 +26,10 @@
         // according to the spec the max bitrate for the SSD1308 is 400 kbit/s
         i2c.frequency(400000);
 
-        // IMPORTANT! Otherwise nothing will be displayed.
+        clear_display();
+    }
+    
+    void clear_display() {
         oled.clearDisplay();
         display();
     }
@@ -36,6 +40,17 @@
         oled.display();
         oled.display();
     }
+    
+    void display_state_name(string name) {
+        // Clear a previous title.
+        oled.setTextCursor(0, 0);
+        oled.printf("                ");
+        oled.setTextCursor(0, 0);
+        oled.printf("- ");
+        oled.printf(name.c_str());
+        oled.printf(" -");
+        display();
+    }
 
     // Returns a direct handle to the screen.
     // Be carefull while using the handle.