Update

Dependencies:   mbed mbed-rtos X_NUCLEO_IHM02A1

Buttons.cpp

Committer:
hagenrap
Date:
2019-05-10
Revision:
37:a74d377d8f74
Parent:
35:758191d5c6e1
Child:
38:3776ee18e56f

File content as of revision 37:a74d377d8f74:

#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

extern volatile bool buttonAbbruch_pressed;  // Used in the main loop
extern volatile bool buttonAbbruch_enabled;  // Used for debouncing
extern Timeout buttonAbbruch_timeout;        // Used for debouncing



/* --------------------------- START_BUTTON --------------------------------- */
// 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.300); // Debounce time 300 ms
    }
}
/* ---------------------------------- END ----------------------------------- */




/* ------------------------- ABBRUCH_BUTTON --------------------------------- */
// Enables button when bouncing is over
void buttonAbbruch_enabled_cb(void)
{
    buttonAbbruch_enabled = true;
}
void buttonAbbruch_diable_cb(void)
{
    buttonAbbruch_enabled = false;
}

// ISR handling button pressed event
void buttonAbbruch_onpressed_cb(void)
{
    if (buttonAbbruch_enabled) { // Disabled while the button is bouncing
        buttonAbbruch_enabled = false;
        buttonAbbruch_pressed = true; // To be read by the main loop
            
        buttonAbbruch_timeout.attach(callback(buttonAbbruch_enabled_cb), 0.300); // Debounce time 300 ms
    }
}
/*
bool Button_2()
{
     if(Button2 == 1)
     {
         wait(0.1);
         if(Button2 == 1)
         {
             retrun true;
         }   
         
     }
     else if(Button2 == 0)
     {
         
     }
}*/
/* ---------------------------------- END ----------------------------------- */