upm/examples/java/LSM303DLH_Example.java
Noel Eck c54d6de054 JAVA: Unified Java Example names
Unified all Java examples to *match* <LIBRARY>[_otherstuf]_Example.java.
Note, a handful of the examples have a pseudo-random string for the
first component (see FlexSensor_Example.java, ideally this would be
Flex_Example.java).

This commit allows for quick development on a single sensor library
since a -DMODULE_LIST=mysensorlib now works with Java examples
(previously Java examples would fail generation when using
MODULE_LIST).

    * Renamed examples
    * Updated class names
    * Updated library descriptor .json files
    * Updated sample mapping file

TODO: Make this work like the C/C++ examples - grab the target library
name from the filename and grab all dependencies from that target
library.  Fix the handful of example names which don't conform.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-02-27 15:28:48 -08:00

60 lines
2.4 KiB
Java

/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//NOT TESTED!!!
public class LSM303DLH_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate LSM303DLH compass on I2C
upm_lsm303dlh.LSM303DLH sensor = new upm_lsm303dlh.LSM303DLH(0);
// Get the coordinate data
sensor.getCoordinates();
short[] coor = sensor.getRawCoorData(); // in XYZ order.
// The sensor returns XZY, but the driver compensates and makes it XYZ
// Print out the X, Y, and Z coordinate data using two different methods
System.out.println("coor: rX " + coor[0] + " - rY " + coor[1] + " - rZ " + coor[2]);
System.out.println("coor: gX " + sensor.getCoorX() + " - gY " + sensor.getCoorY()
+ " - gZ " + sensor.getCoorZ());
// Get and print out the heading
System.out.println("heading: " + sensor.getHeading());
// Get the acceleration
sensor.getAcceleration();
short[] accel = sensor.getRawAccelData();
// Print out the X, Y, and Z acceleration data using two different
// methods
System.out.println("acc: rX " + accel[0] + " - rY " + accel[1] + " - rZ " + accel[2]);
System.out.println("acc: gX " + sensor.getAccelX() + " - gY " + sensor.getAccelY()
+ " - gZ " + sensor.getAccelZ());
// ! [Interesting]
}
}