PES_4_Spleisser / Mbed 2 deprecated SpleisserProgramm_v2

Dependencies:   mbed mbed-rtos X_NUCLEO_IHM02A1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Buttons.cpp Source File

Buttons.cpp

00001 #include "SETUP.h"
00002 
00003 extern volatile bool buttonSTART_pressed; // Used in the main loop
00004 extern volatile bool buttonSTART_enabled;  // Used for debouncing
00005 extern Timeout buttonSTART_timeout;               // Used for debouncing
00006 
00007 // Enables button when bouncing is over
00008 void buttonSTART_enabled_cb(void)
00009 {
00010     buttonSTART_enabled = true;
00011 }
00012 void buttonSTART_diable_cb(void)
00013 {
00014     buttonSTART_enabled = false;
00015 }
00016 
00017 // ISR handling button pressed event
00018 void buttonSTART_onpressed_cb(void)
00019 {
00020     if (buttonSTART_enabled) { // Disabled while the button is bouncing
00021         buttonSTART_enabled = false;
00022         buttonSTART_pressed = true; // To be read by the main loop
00023             
00024         buttonSTART_timeout.attach(callback(buttonSTART_enabled_cb), 0.03); // Debounce time 300 ms
00025     }
00026 }
00027 
00028 
00029 
00030