class of Buttons -isPressed -wasPressed -notPressed -LongPress (Timer)
button.h
- Committer:
- x1dmoesc
- Date:
- 2018-12-04
- Revision:
- 1:e9d0d9b29acc
- Parent:
- 0:8625b4741933
- Child:
- 2:cf58f3863c07
File content as of revision 1:e9d0d9b29acc:
#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, float Time = 0); // constructor void init(); // initialisation void polling(); // polls and debounce the button bool isPressed(); // bool value if button is pressed or not bool wasPressed(); // bool isLongPress(); private: // private bool bIsPressed; // current pressing state bool bWasPressed; // last pressenig state bool bLongPress; // if current pressing state is an long press 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 float fTime; // if constructor creates an timer, this flag is set high void setLongPressFlag(); DigitalIn *pin; // Input pin for Button Timeout *timer; // Timer, to set a Flag for secound Mode }; #endif