-
Notifications
You must be signed in to change notification settings - Fork 1
/
gestureHandler.h
52 lines (42 loc) · 1007 Bytes
/
gestureHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef gesturehandler_h
#define gesturehandler_h
#include "Arduino.h"
#define GESTURE_COOLDOWN 1000 //in [ms]
#define GESTURE_TIMEOUT 20 //in [ms]
class GestureHandler {
private:
/*gesture codes:
* xxx ... pin3, pin6, pin7
* flick WE: 001
* flick EW: 010
* flick SN: 011
* flick NS: 100
*/
unsigned long cooldown = 0;
unsigned long timeOut = 0;
bool newCode = 0;
uint8_t gestureCode = 0;
bool cleanFlag_gC = 0;
public:
inline void clear_gC () {
gestureCode = 0;
}
inline bool gC_isClean () {
return cleanFlag_gC;
}
inline void set_cleanFlag_gC (const bool &val) {
cleanFlag_gC = val;
}
inline uint8_t getGestureCode() {
return gestureCode;
}
void checkTimeout ();
inline unsigned long getCooldown () {
return cooldown;
}
inline void setCooldown () {
cooldown = millis() + GESTURE_COOLDOWN;
}
void setGestureBit (const uint8_t &pin);
};
#endif