java: Added java samples and applied coding style rules to all previous samples

Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Stefan Andritoiu
2015-10-08 14:30:12 +03:00
committed by Mihai Tudor Panu
parent 27f34face1
commit e34863f223
71 changed files with 2433 additions and 649 deletions

View File

@ -27,33 +27,36 @@ public class MPU9150Sample {
static {
try {
System.loadLibrary("upm_mpu9150");
}catch (UnsatisfiedLinkError e) {
System.loadLibrary("javaupm_mpu9150");
} catch (UnsatisfiedLinkError e) {
System.err.println("error in loading native library");
System.exit(-1);
}
}
public static void main(String[] args) throws InterruptedException {
//! [Interesting]
// ! [Interesting]
upm_mpu9150.MPU9150 sensor = new upm_mpu9150.MPU9150();
sensor.init();
while(true){
while (true) {
sensor.update();
float[] accel = sensor.getAccelerometer();
System.out.println("Accelerometer: " + "AX: " + accel[0] + " AY: " + accel[1] + " AZ: " + accel[2] );
System.out.println("Accelerometer: " + "AX: " + accel[0] + " AY: " + accel[1] + " AZ: "
+ accel[2]);
float[] gyro = sensor.getGyroscope();
System.out.println("Gryoscope: " + "GX: " + gyro[0] + " GY: " + gyro[1] + " GZ: " + gyro[2] );
System.out.println("Gryoscope: " + "GX: " + gyro[0] + " GY: " + gyro[1] + " GZ: "
+ gyro[2]);
float[] magn = sensor.getMagnetometer();
System.out.println("Magnetometer: " + "MX: " + magn[0] + " MY: " + magn[1] + " MZ: " + magn[2] );
System.out.println("Magnetometer: " + "MX: " + magn[0] + " MY: " + magn[1] + " MZ: "
+ magn[2]);
Thread.sleep(1000);
}
//! [Interesting]
// ! [Interesting]
}
}