Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-rtos X_NUCLEO_IHM02A1
Buttons.cpp@35:758191d5c6e1, 2019-05-05 (annotated)
- Committer:
- hagenrap
- Date:
- Sun May 05 16:18:20 2019 +0000
- Revision:
- 35:758191d5c6e1
- Parent:
- 34:0dee9a606869
- Child:
- 37:a74d377d8f74
V3; ;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scherfa2 | 34:0dee9a606869 | 1 | #include "SETUP.h" |
scherfa2 | 34:0dee9a606869 | 2 | |
hagenrap | 35:758191d5c6e1 | 3 | extern volatile bool buttonSTART_pressed; // Used in the main loop |
scherfa2 | 34:0dee9a606869 | 4 | extern volatile bool buttonSTART_enabled; // Used for debouncing |
hagenrap | 35:758191d5c6e1 | 5 | extern Timeout buttonSTART_timeout; // Used for debouncing |
scherfa2 | 34:0dee9a606869 | 6 | |
hagenrap | 35:758191d5c6e1 | 7 | extern volatile bool buttonAbbruch_pressed; // Used in the main loop |
hagenrap | 35:758191d5c6e1 | 8 | extern volatile bool buttonAbbruch_enabled; // Used for debouncing |
hagenrap | 35:758191d5c6e1 | 9 | extern Timeout buttonAbbruch_timeout; // Used for debouncing |
hagenrap | 35:758191d5c6e1 | 10 | |
hagenrap | 35:758191d5c6e1 | 11 | |
hagenrap | 35:758191d5c6e1 | 12 | |
hagenrap | 35:758191d5c6e1 | 13 | /* --------------------------- START_BUTTON --------------------------------- */ |
scherfa2 | 34:0dee9a606869 | 14 | // Enables button when bouncing is over |
scherfa2 | 34:0dee9a606869 | 15 | void buttonSTART_enabled_cb(void) |
scherfa2 | 34:0dee9a606869 | 16 | { |
scherfa2 | 34:0dee9a606869 | 17 | buttonSTART_enabled = true; |
scherfa2 | 34:0dee9a606869 | 18 | } |
scherfa2 | 34:0dee9a606869 | 19 | void buttonSTART_diable_cb(void) |
scherfa2 | 34:0dee9a606869 | 20 | { |
scherfa2 | 34:0dee9a606869 | 21 | buttonSTART_enabled = false; |
scherfa2 | 34:0dee9a606869 | 22 | } |
scherfa2 | 34:0dee9a606869 | 23 | |
scherfa2 | 34:0dee9a606869 | 24 | // ISR handling button pressed event |
scherfa2 | 34:0dee9a606869 | 25 | void buttonSTART_onpressed_cb(void) |
scherfa2 | 34:0dee9a606869 | 26 | { |
scherfa2 | 34:0dee9a606869 | 27 | if (buttonSTART_enabled) { // Disabled while the button is bouncing |
scherfa2 | 34:0dee9a606869 | 28 | buttonSTART_enabled = false; |
scherfa2 | 34:0dee9a606869 | 29 | buttonSTART_pressed = true; // To be read by the main loop |
scherfa2 | 34:0dee9a606869 | 30 | |
scherfa2 | 34:0dee9a606869 | 31 | buttonSTART_timeout.attach(callback(buttonSTART_enabled_cb), 0.03); // Debounce time 300 ms |
scherfa2 | 34:0dee9a606869 | 32 | } |
scherfa2 | 34:0dee9a606869 | 33 | } |
hagenrap | 35:758191d5c6e1 | 34 | /* ---------------------------------- END ----------------------------------- */ |
scherfa2 | 34:0dee9a606869 | 35 | |
scherfa2 | 34:0dee9a606869 | 36 | |
scherfa2 | 34:0dee9a606869 | 37 | |
scherfa2 | 34:0dee9a606869 | 38 | |
hagenrap | 35:758191d5c6e1 | 39 | /* ------------------------- ABBRUCH_BUTTON --------------------------------- */ |
hagenrap | 35:758191d5c6e1 | 40 | // Enables button when bouncing is over |
hagenrap | 35:758191d5c6e1 | 41 | void buttonAbbruch_enabled_cb(void) |
hagenrap | 35:758191d5c6e1 | 42 | { |
hagenrap | 35:758191d5c6e1 | 43 | buttonAbbruch_enabled = true; |
hagenrap | 35:758191d5c6e1 | 44 | } |
hagenrap | 35:758191d5c6e1 | 45 | void buttonAbbruch_diable_cb(void) |
hagenrap | 35:758191d5c6e1 | 46 | { |
hagenrap | 35:758191d5c6e1 | 47 | buttonAbbruch_enabled = false; |
hagenrap | 35:758191d5c6e1 | 48 | } |
hagenrap | 35:758191d5c6e1 | 49 | |
hagenrap | 35:758191d5c6e1 | 50 | // ISR handling button pressed event |
hagenrap | 35:758191d5c6e1 | 51 | void buttonAbbruch_onpressed_cb(void) |
hagenrap | 35:758191d5c6e1 | 52 | { |
hagenrap | 35:758191d5c6e1 | 53 | if (buttonAbbruch_enabled) { // Disabled while the button is bouncing |
hagenrap | 35:758191d5c6e1 | 54 | buttonAbbruch_enabled = false; |
hagenrap | 35:758191d5c6e1 | 55 | buttonAbbruch_pressed = true; // To be read by the main loop |
hagenrap | 35:758191d5c6e1 | 56 | |
hagenrap | 35:758191d5c6e1 | 57 | buttonAbbruch_timeout.attach(callback(buttonAbbruch_enabled_cb), 0.03); // Debounce time 300 ms |
hagenrap | 35:758191d5c6e1 | 58 | } |
hagenrap | 35:758191d5c6e1 | 59 | } |
hagenrap | 35:758191d5c6e1 | 60 | /* ---------------------------------- END ----------------------------------- */ |
hagenrap | 35:758191d5c6e1 | 61 |