State machine

Dependencies:   mbed Adafruit_GFX BioroboticsMotorControl MODSERIAL BioroboticsEMGFilter

Revision:
3:4b19b6cf6cc7
Parent:
2:141cfcafe72b
Child:
7:e7f808875bc4
diff -r 141cfcafe72b -r 4b19b6cf6cc7 Button.h
--- a/Button.h	Tue Oct 30 11:21:09 2018 +0000
+++ b/Button.h	Tue Oct 30 11:40:00 2018 +0000
@@ -6,27 +6,27 @@
 // 50 ms.
 const float debounce_time = 0.05;
 
-class Button {
+class Button
+{
 private:
     InterruptIn pin;
-    
+
     Timeout debounce_timeout;
-    
+
     volatile bool pressed;
-    
+
     volatile bool just_switched_to_pressed;
     volatile bool just_got_pressed;
-    
+
 public:
     Button(PinName pin_name):
-        pin(pin_name)
-    {
+        pin(pin_name) {
         pin.rise(this, &Button::rise);
         pin.fall(this, &Button::fall);
-        
+
         pressed = false;
     }
-    
+
     void update() {
         if (just_got_pressed) {
             just_got_pressed = false;
@@ -36,23 +36,27 @@
             just_switched_to_pressed = false;
         }
     }
-    
-    bool is_pressed() { return pressed; };
+
+    bool is_pressed() {
+        return pressed;
+    };
     // Only active just after a state change from not pressed to pressed.
     // Get's reset after `update()` is called.
-    bool has_just_been_pressed() { return just_got_pressed; };
+    bool has_just_been_pressed() {
+        return just_got_pressed;
+    };
 private:
     void rise() {
         // Button is now potentially pressed, or is simply bouncing.
         debounce_timeout.detach();
         pressed = false;
     }
-    
+
     void fall() {
         // Button just got released, or bounced up again.
         debounce_timeout.attach(this, &Button::debounce_callback, debounce_time);
     }
-    
+
     void debounce_callback() {
         pressed = true;
         just_switched_to_pressed = true;