Update

Dependencies:   mbed mbed-rtos X_NUCLEO_IHM02A1

Revision:
35:758191d5c6e1
Parent:
34:0dee9a606869
Child:
37:a74d377d8f74
--- a/Buttons.cpp	Wed Apr 24 21:08:27 2019 +0000
+++ b/Buttons.cpp	Sun May 05 16:18:20 2019 +0000
@@ -1,9 +1,16 @@
 #include "SETUP.h"
 
-extern volatile bool buttonSTART_pressed; // Used in the main loop
+extern volatile bool buttonSTART_pressed;  // Used in the main loop
 extern volatile bool buttonSTART_enabled;  // Used for debouncing
-extern Timeout buttonSTART_timeout;               // Used for debouncing
+extern Timeout buttonSTART_timeout;        // Used for debouncing
 
+extern volatile bool buttonAbbruch_pressed;  // Used in the main loop
+extern volatile bool buttonAbbruch_enabled;  // Used for debouncing
+extern Timeout buttonAbbruch_timeout;        // Used for debouncing
+
+
+
+/* --------------------------- START_BUTTON --------------------------------- */
 // Enables button when bouncing is over
 void buttonSTART_enabled_cb(void)
 {
@@ -24,7 +31,31 @@
         buttonSTART_timeout.attach(callback(buttonSTART_enabled_cb), 0.03); // Debounce time 300 ms
     }
 }
+/* ---------------------------------- END ----------------------------------- */
 
 
 
 
+/* ------------------------- ABBRUCH_BUTTON --------------------------------- */
+// Enables button when bouncing is over
+void buttonAbbruch_enabled_cb(void)
+{
+    buttonAbbruch_enabled = true;
+}
+void buttonAbbruch_diable_cb(void)
+{
+    buttonAbbruch_enabled = false;
+}
+
+// ISR handling button pressed event
+void buttonAbbruch_onpressed_cb(void)
+{
+    if (buttonAbbruch_enabled) { // Disabled while the button is bouncing
+        buttonAbbruch_enabled = false;
+        buttonAbbruch_pressed = true; // To be read by the main loop
+            
+        buttonAbbruch_timeout.attach(callback(buttonAbbruch_enabled_cb), 0.03); // Debounce time 300 ms
+    }
+}
+/* ---------------------------------- END ----------------------------------- */
+