mit Buttons/PWM als einzelne cpp und init in main

Dependencies:   mbed mbed-rtos X_NUCLEO_IHM02A1

Committer:
scherfa2
Date:
Wed Apr 24 21:08:27 2019 +0000
Revision:
34:0dee9a606869
asdf

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scherfa2 34:0dee9a606869 1 #include "SETUP.h"
scherfa2 34:0dee9a606869 2
scherfa2 34:0dee9a606869 3 extern volatile bool buttonSTART_pressed; // Used in the main loop
scherfa2 34:0dee9a606869 4 extern volatile bool buttonSTART_enabled; // Used for debouncing
scherfa2 34:0dee9a606869 5 extern Timeout buttonSTART_timeout; // Used for debouncing
scherfa2 34:0dee9a606869 6
scherfa2 34:0dee9a606869 7 // Enables button when bouncing is over
scherfa2 34:0dee9a606869 8 void buttonSTART_enabled_cb(void)
scherfa2 34:0dee9a606869 9 {
scherfa2 34:0dee9a606869 10 buttonSTART_enabled = true;
scherfa2 34:0dee9a606869 11 }
scherfa2 34:0dee9a606869 12 void buttonSTART_diable_cb(void)
scherfa2 34:0dee9a606869 13 {
scherfa2 34:0dee9a606869 14 buttonSTART_enabled = false;
scherfa2 34:0dee9a606869 15 }
scherfa2 34:0dee9a606869 16
scherfa2 34:0dee9a606869 17 // ISR handling button pressed event
scherfa2 34:0dee9a606869 18 void buttonSTART_onpressed_cb(void)
scherfa2 34:0dee9a606869 19 {
scherfa2 34:0dee9a606869 20 if (buttonSTART_enabled) { // Disabled while the button is bouncing
scherfa2 34:0dee9a606869 21 buttonSTART_enabled = false;
scherfa2 34:0dee9a606869 22 buttonSTART_pressed = true; // To be read by the main loop
scherfa2 34:0dee9a606869 23
scherfa2 34:0dee9a606869 24 buttonSTART_timeout.attach(callback(buttonSTART_enabled_cb), 0.03); // Debounce time 300 ms
scherfa2 34:0dee9a606869 25 }
scherfa2 34:0dee9a606869 26 }
scherfa2 34:0dee9a606869 27
scherfa2 34:0dee9a606869 28
scherfa2 34:0dee9a606869 29
scherfa2 34:0dee9a606869 30