-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.java
35 lines (30 loc) · 1.12 KB
/
Example.java
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
import joshua.green.phyphox.PhyphoxClient;
import joshua.green.phyphox.sensors.PhyphoxSensors;
import joshua.green.phyphox.sensors.PhyphoxAccelerometer;
import joshua.green.phyphox.sensors.PhyphoxGyroscope;
import java.io.IOException;
public class PhyphoxClientTest {
public static void main(String[] args) throws IOException {
PhyphoxClient client = PhyphoxClient.connect("192.168.0.1", 8080);
var acc = (PhyphoxAccelerometer) client.registerSensor(PhyphoxSensors.ACCELEROMETER);
assert acc != null;
acc.include("x");
var gyr = (PhyphoxGyroscope) client.registerSensor(PhyphoxSensors.GYROSCOPE);
assert gyr != null;
gyr.include("x");
gyr.include("y");
gyr.include("z");
client.start();
if (client.update()) {
System.out.println(
"\naccX: " + acc.getX() +
"\naccY: " + acc.getY() +
"\naccZ: " + acc.getZ() +
"\ngyrX: " + gyr.getX() +
"\ngyrY: " + gyr.getY() +
"\ngyrZ: " + gyr.getZ()
);
}
client.stop();
}
}