/* * Author: Jon Trulson * Copyright (c) 2016-2017 Intel Corporation. * * This program and the accompanying materials are made available under the * terms of the The MIT License which is available at * https://opensource.org/licenses/MIT. * * SPDX-License-Identifier: MIT */ import java.util.AbstractList; import upm_lsm6dsl.*; public class LSM6DSL_Example { public static void main(String[] args) throws InterruptedException { // ! [Interesting] // Instantiate a LSM6DSL instance using default i2c bus and address LSM6DSL sensor = new LSM6DSL(); // For SPI, bus 0, you would pass -1 as the address, and a // valid pin for CS: // LSM6DSL(0, -1, 10); while (true) { // update our values from the sensor sensor.update(); AbstractList data = sensor.getAccelerometer(); System.out.println("Accelerometer x: " + data.get(0) + " y: " + data.get(1) + " z: " + data.get(2) + " g"); data = sensor.getGyroscope(); System.out.println("Gyroscope x: " + data.get(0) + " y: " + data.get(1) + " z: " + data.get(2) + " dps"); System.out.println("Compensation Temperature: " + sensor.getTemperature() + " C / " + sensor.getTemperature(true) + " F"); System.out.println(); Thread.sleep(250); } // ! [Interesting] } }