mit Buttons/PWM als einzelne cpp und init in main

Dependencies:   mbed mbed-rtos X_NUCLEO_IHM02A1

Revision:
34:0dee9a606869
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Buttons.cpp	Wed Apr 24 21:08:27 2019 +0000
@@ -0,0 +1,30 @@
+#include "SETUP.h"
+
+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
+
+// Enables button when bouncing is over
+void buttonSTART_enabled_cb(void)
+{
+    buttonSTART_enabled = true;
+}
+void buttonSTART_diable_cb(void)
+{
+    buttonSTART_enabled = false;
+}
+
+// ISR handling button pressed event
+void buttonSTART_onpressed_cb(void)
+{
+    if (buttonSTART_enabled) { // Disabled while the button is bouncing
+        buttonSTART_enabled = false;
+        buttonSTART_pressed = true; // To be read by the main loop
+            
+        buttonSTART_timeout.attach(callback(buttonSTART_enabled_cb), 0.03); // Debounce time 300 ms
+    }
+}
+
+
+
+