mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00

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>
41 lines
1.1 KiB
Java
41 lines
1.1 KiB
Java
import upm_flex.Flex;
|
|
|
|
public class FlexSensor_Example {
|
|
|
|
static {
|
|
try {
|
|
System.loadLibrary("javaupm_flex");
|
|
System.loadLibrary("mraajava");
|
|
} catch (UnsatisfiedLinkError e) {
|
|
System.err.println(
|
|
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
|
e);
|
|
System.exit(1);
|
|
}
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
// TODO Auto-generated method stub
|
|
//! [Interesting]
|
|
// The was tested with a Spectra Symbol flex sensor.
|
|
// We attached a 22K resistor to a breadboard,
|
|
// with 1 end attached to GND and the other connected to
|
|
// both the flex sensor and A0.
|
|
// The flex sensor was connected on 1 pin to the 22K resistor and A0
|
|
// and on the other pin to 5V.
|
|
|
|
// Instantiate a Flex sensor on analog pin A0
|
|
Flex flex = new Flex(0);
|
|
while(true){
|
|
System.out.println("Flex Sensor value is: "+flex.value());
|
|
try {
|
|
Thread.sleep(1000);
|
|
} catch (InterruptedException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
//! [Interesting]
|
|
}
|
|
|
|
} |