-
Notifications
You must be signed in to change notification settings - Fork 1
/
flick_example.cpp
127 lines (118 loc) · 3.28 KB
/
flick_example.cpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "flick.h"
#include <stdio.h>
#include <unistd.h>
void onTouchCb( FlickTouch_t touch, uint16_t period ){
switch (touch){
case TOUCH_SOUTH_ELECTRODE:
printf("TOUCH_SOUTH_ELECTRODE: %d, %d \n", touch, period);
break;
case TOUCH_WEST_ELECTRODE:
printf("TOUCH_WEST_ELECTRODE: %d, %d \n", touch, period);
break;
case TOUCH_NORTH_ELECTRODE:
printf("TOUCH_NORTH_ELECTRODE: %d, %d \n", touch, period);
break;
case TOUCH_EAST_ELECTRODE:
printf("TOUCH_EAST_ELECTRODE: %d, %d \n", touch, period);
break;
case TOUCH_CENTER_ELECTRODE:
printf("TOUCH_CENTER_ELECTRODE: %d, %d \n", touch, period);
break;
case TAP_SOUTH_ELECTRODE:
printf("TAP_SOUTH_ELECTRODE: %d, %d \n", touch, period);
break;
case TAP_WEST_ELECTRODE:
printf("TAP_WEST_ELECTRODE: %d, %d \n", touch, period);
break;
case TAP_NORTH_ELECTRODE:
printf("TAP_NORTH_ELECTRODE: %d, %d \n", touch, period);
break;
case TAP_EAST_ELECTRODE:
printf("TAP_EAST_ELECTRODE: %d, %d \n", touch, period);
break;
case TAP_CENTER_ELECTRODE:
printf("TAP_CENTER_ELECTRODE: %d, %d \n", touch, period);
break;
case DOUBLE_TAP_SOUTH_ELECTRODE:
printf("DOUBLE_TAP_SOUTH_ELECTRODE: %d, %d \n", touch, period);
break;
case DOUBLE_TAP_WEST_ELECTRODE:
printf("DOUBLE_TAP_WEST_ELECTRODE: %d, %d \n", touch, period);
break;
case DOUBLE_TAP_NORTH_ELECTRODE:
printf("DOUBLE_TAP_NORTH_ELECTRODE: %d, %d \n", touch, period);
break;
case DOUBLE_TAP_EAST_ELECTRODE:
printf("DOUBLE_TAP_EAST_ELECTRODE: %d, %d \n", touch, period);
break;
case DOUBLE_TAP_CENTER_ELECTRODE:
printf("DOUBLE_TAP_CENTER_ELECTRODE: %d, %d \n", touch, period);
break;
default:
printf("Not defined touch: %d, %d \n", touch, period);
}
}
void airwheelCb(int32_t a) {
printf("Angle: %d \n", a);
}
void onGestureCb(FlickGesture_t gesture, FlickGestureClass_t gestClass, bool isEdgeFlick, bool inProgress){
const char *g, *cl;
switch (gesture){
case GESTURE_GARBAGE_MODEL:
g = "GARBAGE_MODEL";
break;
case FLICK_WEST_TO_EAST:
g = "FLICK_WEST_TO_EAST";
break;
case FLICK_EAST_TO_WEST:
g = "FLICK_EAST_TO_WEST";
break;
case FLICK_SOUTH_TO_NORTH:
g = "FLICK_SOUTH_TO_NORTH";
break;
case FLICK_NORTH_TO_SOUTH:
g = "FLICK_NORTH_TO_SOUTH";
break;
case CIRCLE_CLOCKWISE:
g = "CIRCLE_CLOCKWISE";
break;
case CIRCLE_COUNTER_CLOCKWISE:
g = "CIRCLE_COUNTER_CLOCKWISE";
break;
default:
g = "NO_GESTURE";
}
switch (gestClass){
case GESTURE_CLASS_GARBAGE_MODEL:
cl = "GARBAGE_MODEL";
break;
case FLICK_GESTURE:
cl = "FLICK_GESTURE";
break;
case CIRCULAR_GESTURE:
cl = "CIRCULAR_GESTURE";
break;
default:
cl = "UNKNOWN";
}
printf("Gesture: %s, class: %s, edge flick: %s, in progress: %s \n", g, cl, isEdgeFlick?"yes":"no", inProgress?"yes":"no" );
}
void onXYZCb(uint16_t x, uint16_t y, uint16_t z){
printf("x: %d, y: %d, z: %d \n", x, y, z);
}
int main(void) {
Flick flick(34, 33);
flick.touchCallback = onTouchCb;
flick.airWheelCallback = airwheelCb;
flick.xyzCallback = onXYZCb;
flick.gestureCallback = onGestureCb;
usleep(250000);
int ret = flick.SetRuntimeParameter(0xa1, 0x1f, 0xFFFFFFFF); // lock data output <-----
ret = flick.SetRuntimeParameter(0x80, 0x1b, 0x1F); // disable calibration
//printf("ret: %d \n", ret);
while (1) {
flick.Poll();
usleep(5000);
}
return 0;
}