class of Buttons -isPressed -wasPressed -notPressed -LongPress (Timer)
button.h
- Committer:
- x1dmoesc
- Date:
- 2018-12-13
- Revision:
- 2:cf58f3863c07
- Parent:
- 1:e9d0d9b29acc
- Child:
- 3:68f58a34e627
File content as of revision 2:cf58f3863c07:
#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(int *iNumBtn = NULL); // 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