comparison Button.h @ 1:284066a427c8

added flanks detection
author ark
date 2017-01-25 23:12 +0100
parents 968a3e3eb8ef
children b76b999b88c7
comparison
equal deleted inserted replaced
0:968a3e3eb8ef 1:284066a427c8
1 #ifndef Button_h 1 #ifndef Button_h
2 #define Button_h 2 #define Button_h
3
3 4
4 /** 5 /**
5 utility class for debouncing a button based on pin state and time. 6 utility class for debouncing a button based on pin state and time.
6 7
7 notes time of state change. ignores further state changes for 8 notes time of state change. ignores further state changes for
10 (c) 2017 arkadiusz@wobblyhead.net 11 (c) 2017 arkadiusz@wobblyhead.net
11 */ 12 */
12 class Button { 13 class Button {
13 public: 14 public:
14 // stabilised button state 15 // stabilised button state
15 bool isPressed; 16 bool isOn;
16 // millis() time of last state change 17 // millis() time of last state change
17 unsigned long lastChangeMs; 18 unsigned long lastChangeMs;
18 19 // flag, true if state changed to pressed
20 bool isPressed;
21 // flag, true if state changed to off
22 bool isReleased;
23
19 /** 24 /**
20 create an uninitialised Button. 25 create an uninitialised Button.
21 setup() must be called after this to make it usable. 26 setup() must be called after this to make it usable.
22 */ 27 */
23 Button(); 28 Button();