class of Buttons -isPressed -wasPressed -notPressed -LongPress (Timer)
Diff: button.h
- Revision:
- 1:e9d0d9b29acc
- Parent:
- 0:8625b4741933
- Child:
- 2:cf58f3863c07
--- a/button.h Fri Nov 30 15:46:00 2018 +0000 +++ b/button.h Tue Dec 04 10:40:33 2018 +0000 @@ -11,23 +11,29 @@ { public: // public - button(PinName pBtn, PinMode pBtnMode); // constructor + 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 isPressed(); // bool value if button is pressed or not bool wasPressed(); // - + bool isLongPress(); private: // private - bool bIsPressed; - bool bWasPressed; + 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 - DigitalIn *pin; + + void setLongPressFlag(); + + DigitalIn *pin; // Input pin for Button + Timeout *timer; // Timer, to set a Flag for secound Mode };