class of Buttons -isPressed -wasPressed -notPressed -LongPress (Timer)
Diff: button.h
- Revision:
- 0:8625b4741933
- Child:
- 1:e9d0d9b29acc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/button.h Fri Nov 30 15:46:00 2018 +0000 @@ -0,0 +1,35 @@ +#ifndef MBED_BUTTON_H +#define MBED_BUTTON_H + +#include "mbed.h" + +#define NUMCYCLE 10 +#define PRESSED 0 +#define NOT_PRESSED 1 + +class button +{ + + public: // public + button(PinName pBtn, PinMode pBtnMode); // constructor + void init(); // initialisation + void polling(); // polls and debounce the button + bool isPressed(); // bool value if button is pressed or not + bool wasPressed(); // + + + + private: // private + bool bIsPressed; + bool bWasPressed; + bool bNewState; // current state/value of button + bool bOldState; // previous state/value of button + bool bBtnNewAction; // flag if an action is occur + int iNumCycle; // cycle counter + + DigitalIn *pin; + +}; + + +#endif