Update
Dependencies: mbed mbed-rtos X_NUCLEO_IHM02A1
Diff: Buttons.cpp
- Revision:
- 38:3776ee18e56f
- Parent:
- 37:a74d377d8f74
- Child:
- 42:0aaa3b282b6e
--- a/Buttons.cpp Fri May 10 17:31:36 2019 +0000 +++ b/Buttons.cpp Mon May 13 10:11:48 2019 +0000 @@ -1,5 +1,11 @@ #include "SETUP.h" + +extern DigitalIn Button1; +extern DigitalIn Button2; + + +/* 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 @@ -8,9 +14,9 @@ extern volatile bool buttonAbbruch_enabled; // Used for debouncing extern Timeout buttonAbbruch_timeout; // Used for debouncing - +*/ -/* --------------------------- START_BUTTON --------------------------------- */ +/* --------------------------- START_BUTTON --------------------------------- // Enables button when bouncing is over void buttonSTART_enabled_cb(void) { @@ -36,7 +42,7 @@ -/* ------------------------- ABBRUCH_BUTTON --------------------------------- */ +/* ------------------------- ABBRUCH_BUTTON --------------------------------- // Enables button when bouncing is over void buttonAbbruch_enabled_cb(void) { @@ -57,22 +63,49 @@ buttonAbbruch_timeout.attach(callback(buttonAbbruch_enabled_cb), 0.300); // Debounce time 300 ms } } -/* -bool Button_2() +*/ + +bool get_Button_1() +{ + if(Button1 == 1) + { + wait(0.01); + if(Button1 == 1) + { + return true; + } + } + else if(Button1 == 0) + { + wait(0.01); + if(Button1 == 0) + { + return false; + } + } + else return false; +} + +bool get_Button_2() { if(Button2 == 1) { - wait(0.1); + wait(0.01); if(Button2 == 1) { - retrun true; + return true; } - } else if(Button2 == 0) { - + wait(0.01); + if(Button2 == 0) + { + return false; + } } -}*/ + else return false; +} + /* ---------------------------------- END ----------------------------------- */