-
Notifications
You must be signed in to change notification settings - Fork 0
/
Convert.pde
69 lines (61 loc) · 2.53 KB
/
Convert.pde
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
//convert all axis
int minAngle = 0;
int maxAngle = 360;
void convert() {
/* convert the gyro x-axis */
if (stringGyroX != null) {
// trim off any whitespace:
stringGyroX = trim(stringGyroX);
// convert to an float and map to the screen height, then save in buffer:
gyroX[gyroX.length-1] = map(float(stringGyroX), minAngle, maxAngle, 0, height);
}
/* convert the gyro y-axis */
if (stringGyroY != null) {
// trim off any whitespace:
stringGyroY = trim(stringGyroY);
// convert to an float and map to the screen height, then save in buffer:
gyroY[gyroY.length-1] = map(float(stringGyroY), minAngle, maxAngle, 0, height);
}
/* convert the accelerometer x-axis */
if (stringAccX != null) {
// trim off any whitespace:
stringAccX = trim(stringAccX);
// convert to an float and map to the screen height, then save in buffer:
accX[accX.length-1] = map(float(stringAccX), minAngle, maxAngle, 0, height);
}
/* convert the accelerometer y-axis */
if (stringAccY != null) {
// trim off any whitespace:
stringAccY = trim(stringAccY);
// convert to an float and map to the screen height, then save in buffer:
accY[accY.length-1] = map(float(stringAccY), minAngle, maxAngle, 0, height);
}
/* convert the complementary filter x-axis */
if (stringCompX != null) {
// trim off any whitespace:
stringCompX = trim(stringCompX);
// convert to an float and map to the screen height, then save in buffer:
compX[compX.length-1] = map(float(stringCompX), minAngle, maxAngle, 0, height);
}
/* convert the complementary filter x-axis */
if (stringCompY != null) {
// trim off any whitespace:
stringCompY = trim(stringCompY);
// convert to an float and map to the screen height, then save in buffer:
compY[compY.length-1] = map(float(stringCompY), minAngle, maxAngle, 0, height);
}
/* convert the kalman filter x-axis */
if (stringKalmanX != null) {
// trim off any whitespace:
stringKalmanX = trim(stringKalmanX);
// convert to an float and map to the screen height, then save in buffer:
kalmanX[kalmanX.length-1] = map(float(stringKalmanX), minAngle, maxAngle, 0, height);
}
/* convert the kalman filter y-axis */
if (stringKalmanY != null) {
// trim off any whitespace:
stringKalmanY = trim(stringKalmanY);
// convert to an float and map to the screen height, then save in buffer:
kalmanY[kalmanY.length-1] = map(float(stringKalmanY), minAngle, maxAngle, 0, height);
}
}