mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 17:30:01 +03:00
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:
parent
27f34face1
commit
e34863f223
55
examples/java/ADC121C021Sample.java
Normal file
55
examples/java/ADC121C021Sample.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 ADC121C021Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_adc121c021");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate an ADC121C021 on I2C bus 0
|
||||
upm_adc121c021.ADC121C021 adc = new upm_adc121c021.ADC121C021(0);
|
||||
|
||||
// An analog sensor, such as a Grove light sensor,
|
||||
// must be attached to the adc·
|
||||
// Prints the value and corresponding voltage every 50 milliseconds
|
||||
while (true) {
|
||||
int val = adc.value();
|
||||
|
||||
System.out.println("ADC value: " + val + "Volts = " + adc.valueToVolts(val));
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,9 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class Adxl345Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_adxl345");
|
||||
@ -32,22 +34,25 @@ public class Adxl345Sample {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws InterruptedException {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Note: Sensor only works at 3.3V on the Intel Edison with Arduino breakout
|
||||
upm_adxl345.Adxl345 obj = new upm_adxl345.Adxl345(0);
|
||||
int[] raw = new int[3];
|
||||
float[] accel = new float[3];
|
||||
short[] val;
|
||||
float[] accel;
|
||||
|
||||
// Note: Sensor only works at 3.3V on the Intel Edison with Arduino
|
||||
// breakout
|
||||
upm_adxl345.Adxl345 sensor = new upm_adxl345.Adxl345(0);
|
||||
|
||||
while (true) {
|
||||
obj.update();
|
||||
raw = obj.getRawValues();
|
||||
accel = obj.getAcceleration();
|
||||
sensor.update();
|
||||
val = sensor.getRawValues();
|
||||
accel = sensor.getAcceleration();
|
||||
|
||||
System.out.println("raw data: " + raw[0] + " " + raw[1] + " " +
|
||||
raw[2]);
|
||||
System.out.println("accel data: " + accel[0] + " " + accel[1] + " "
|
||||
+ accel[2]);
|
||||
System.out.println("Current scale: " + sensor.getScale());
|
||||
System.out.println("Raw Values: X: " + val[0] + " Y: " + val[1]
|
||||
+ " Z: " + val[2]);
|
||||
System.out.println("Acceleration: X: " + accel[0] + "g Y: "
|
||||
+ accel[1] + "g Z: " + accel[2] + "g");
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class BMPX8XSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_bmpx8x");
|
||||
System.loadLibrary("javaupm_bmpx8x");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
@ -44,7 +44,8 @@ public class BMPX8XSample {
|
||||
while (true) {
|
||||
System.out.println("Pressure: " + sensor.getPressure());
|
||||
System.out.println("Altitude: " + sensor.getAltitude());
|
||||
System.out.println("Sealevel pressure: " + sensor.getSealevelPressure());
|
||||
System.out.println("Sealevel pressure: "
|
||||
+ sensor.getSealevelPressure());
|
||||
System.out.println("Temperature: " + sensor.getTemperature());
|
||||
System.out.println();
|
||||
|
||||
|
64
examples/java/BuzzerSample.java
Normal file
64
examples/java/BuzzerSample.java
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public class BuzzerSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_buzzer");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
int chord[] = {
|
||||
upm_buzzer.javaupm_buzzer.DO,
|
||||
upm_buzzer.javaupm_buzzer.RE,
|
||||
upm_buzzer.javaupm_buzzer.MI,
|
||||
upm_buzzer.javaupm_buzzer.FA,
|
||||
upm_buzzer.javaupm_buzzer.SOL,
|
||||
upm_buzzer.javaupm_buzzer.LA,
|
||||
upm_buzzer.javaupm_buzzer.SI};
|
||||
|
||||
// Instantiate a buzzer on digital pin D5
|
||||
upm_buzzer.Buzzer sound = new upm_buzzer.Buzzer(5);
|
||||
|
||||
// print sensor name
|
||||
System.out.println(sound.name());
|
||||
|
||||
for (int i = 0; i < chord.length; i++) {
|
||||
// play each note for one second
|
||||
int note = sound.playSound(chord[i], 1000000);
|
||||
System.out.println(note);
|
||||
|
||||
Thread.sleep(100);
|
||||
}
|
||||
// ! [Interesting]
|
||||
sound.stopSound();
|
||||
}
|
||||
|
||||
}
|
@ -34,7 +34,6 @@ public class CJQ4435Sample{
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
|
||||
upm_cjq4435.CJQ4435 mosfet = new upm_cjq4435.CJQ4435(3);
|
||||
|
||||
@ -57,7 +56,6 @@ public class CJQ4435Sample{
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
|
||||
}
|
83
examples/java/DS1307Sample.java
Normal file
83
examples/java/DS1307Sample.java
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 DS1307Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_ds1307");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
static private void printTime(upm_ds1307.DS1307 rtc) {
|
||||
System.out.print("The time is: " + rtc.getMonth() + "/" + rtc.getDayOfMonth() + "/"
|
||||
+ rtc.getYear() + " " + rtc.getHours() + ":" + rtc.getMinutes() + ":"
|
||||
+ rtc.getSeconds());
|
||||
|
||||
if (rtc.getAmPmMode()) {
|
||||
if (rtc.getAmPmMode())
|
||||
System.out.print(" PM");
|
||||
else
|
||||
System.out.print(" AM");
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
|
||||
if (rtc.getAmPmMode())
|
||||
System.out.println("Clock is in AM/PM mode");
|
||||
else
|
||||
System.out.println("Clock is in 24h mode");
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a DS1037 on I2C bus 0
|
||||
upm_ds1307.DS1307 rtc = new upm_ds1307.DS1307(0);
|
||||
|
||||
// always do this first
|
||||
System.out.println("Loading the current time...");
|
||||
if (!rtc.loadTime()) {
|
||||
System.err.println("rtc->loadTime() failed.");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
printTime(rtc);
|
||||
|
||||
// set the year as an example
|
||||
System.out.println("setting the year to 50");
|
||||
rtc.setYear(50);
|
||||
rtc.setTime();
|
||||
|
||||
// reload the time and print it
|
||||
rtc.loadTime();
|
||||
printTime(rtc);
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -22,8 +22,6 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//import upm_servo.ES08A;
|
||||
|
||||
public class ES08ASample {
|
||||
static {
|
||||
try {
|
||||
|
@ -22,8 +22,6 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//import upm_guvas12d.GUVAS12D;
|
||||
|
||||
public class GUVAS12DSample {
|
||||
// analog voltage, usually 3.3 or 5.0
|
||||
private static final float GUVAS12D_AREF = 5;
|
||||
@ -46,7 +44,8 @@ public class GUVAS12DSample{
|
||||
while (true) {
|
||||
float value = volts.value(GUVAS12D_AREF, SAMPLES_PER_QUERY);
|
||||
|
||||
System.out.println("AREF: " + GUVAS12D_AREF + ", Voltage value (higher means more UV): " + value );
|
||||
System.out.println("AREF: " + GUVAS12D_AREF
|
||||
+ ", Voltage value (higher means more UV): " + value);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
65
examples/java/GroveButton_intrSample.java
Normal file
65
examples/java/GroveButton_intrSample.java
Normal file
@ -0,0 +1,65 @@
|
||||
import upm_grove.IsrCallback;
|
||||
|
||||
/*
|
||||
* 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 GroveButton_intrSample {
|
||||
|
||||
public static int counter = 0;
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grove");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_grove.GroveButton b = new upm_grove.GroveButton(2);
|
||||
|
||||
IsrCallback callback = new ButtonISR();
|
||||
b.installISR(0, callback);
|
||||
|
||||
while (true) {
|
||||
System.out.println("Counter: " + counter);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
||||
|
||||
class ButtonISR extends IsrCallback {
|
||||
public ButtonISR() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
GroveButton_intrSample.counter++;
|
||||
System.out.println("+++++++++");
|
||||
}
|
||||
}
|
54
examples/java/GroveLed_multiSample.java
Normal file
54
examples/java/GroveLed_multiSample.java
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 GroveLed_multiSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grove");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a grove LED on D2. Here we are controlling a Grove
|
||||
// Multi-color flash LED. We just just need to turn it on - it will
|
||||
// then cycle through various colors (red, green, blue, purple) on it's
|
||||
// own until turned off.
|
||||
upm_grove.GroveLed led = new upm_grove.GroveLed(2);
|
||||
|
||||
// start the light show
|
||||
led.on();
|
||||
|
||||
// just sleep until interrupted
|
||||
while (true) {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -42,8 +42,7 @@ public class GroveLineFinderSample{
|
||||
boolean val = finder.whiteDetected();
|
||||
if (val) {
|
||||
System.out.println("White detected");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
System.out.println("Black detected");
|
||||
}
|
||||
|
||||
|
@ -36,23 +36,27 @@ public class GroveMDSample{
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate an I2C Grove Motor Driver on I2C bus 0
|
||||
upm_grovemd.GroveMD motors = new upm_grovemd.GroveMD();
|
||||
|
||||
// set direction to clockwise (CW) and set speed to 50%
|
||||
System.out.println("Spin M1 and M2 at half speed for 3 seconds");
|
||||
motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW, upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW );
|
||||
motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW,
|
||||
upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW);
|
||||
motors.setMotorSpeeds(speed50, speed50);
|
||||
Thread.sleep(3000);
|
||||
|
||||
// counter clockwise (CCW)
|
||||
System.out.println("Reversing M1 and M2 for 3 seconds");
|
||||
motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW, upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW );
|
||||
motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW,
|
||||
upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW);
|
||||
Thread.sleep(3000);
|
||||
|
||||
// stop motors
|
||||
System.out.println("Stopping motors");
|
||||
motors.setMotorSpeeds(speed0, speed0);
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -45,8 +45,10 @@ public class GroveRotarySample{
|
||||
float rel_deg = knob.rel_deg(); // Relative degrees
|
||||
float rel_rad = knob.rel_rad(); // Relative radians
|
||||
|
||||
System.out.println( "Absolute: " + abs_value + " raw, " + abs_deg + " deg, " + abs_rad + " rad" );
|
||||
System.out.println( "Relative: " + rel_value + " raw, " + rel_deg + " deg, " + rel_rad + " rad" );
|
||||
System.out.println("Absolute: " + abs_value + " raw, " + abs_deg + " deg, " + abs_rad
|
||||
+ " rad");
|
||||
System.out.println("Relative: " + rel_value + " raw, " + rel_deg + " deg, " + rel_rad
|
||||
+ " rad");
|
||||
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class GroveVDivSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_grovevdiv");
|
||||
System.loadLibrary("javaupm_grovevdiv");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
@ -48,7 +48,8 @@ public class GroveVDivSample {
|
||||
float gain3val = vDiv.computedValue(gain3, val);
|
||||
float gain10val = vDiv.computedValue(gain10, val);
|
||||
|
||||
System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: " + gain10val);
|
||||
System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: "
|
||||
+ gain10val);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ public class GroveWaterSample{
|
||||
boolean val = water.isWet();
|
||||
if (val) {
|
||||
System.out.println("Sensor is wet");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
System.out.println("Sensor is dry");
|
||||
}
|
||||
|
||||
@ -52,5 +51,4 @@ public class GroveWaterSample{
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
|
||||
}
|
76
examples/java/HCSR04Sample.java
Normal file
76
examples/java/HCSR04Sample.java
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import upm_hcsr04.IsrCallback;
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class HCSR04Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_hcsr04");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// ! [Interesting]
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
HCSR04ISR callback = new HCSR04ISR();
|
||||
|
||||
upm_hcsr04.HCSR04 sonar = new upm_hcsr04.HCSR04((short) 5, (short) 6, callback);
|
||||
callback.setSonar(sonar);
|
||||
Thread.sleep(1000);
|
||||
|
||||
while (true) {
|
||||
System.out.println("Get distance");
|
||||
double distance = sonar.getDistance(upm_hcsr04.javaupm_hcsr04Constants.CM);
|
||||
System.out.println("Distance: " + distance);
|
||||
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class HCSR04ISR extends IsrCallback {
|
||||
|
||||
private upm_hcsr04.HCSR04 sonar = null;
|
||||
|
||||
public HCSR04ISR() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setSonar(upm_hcsr04.HCSR04 sonar) {
|
||||
this.sonar = sonar;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (sonar != null)
|
||||
sonar.ackEdgeDetected();
|
||||
else
|
||||
System.out.println("No HCSR04ISR instance given to callback");
|
||||
}
|
||||
}
|
||||
// ! [Interesting]
|
105
examples/java/HM11Sample.java
Normal file
105
examples/java/HM11Sample.java
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 HM11Sample {
|
||||
|
||||
private static final int BUFSIZ = 1024;
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_hm11");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void printUsage() {
|
||||
System.out.println("Usage: java HM11Sample [AT command]");
|
||||
|
||||
System.out.println("If an argument is supplied on the command line, that argument is");
|
||||
System.out.println("sent to the module and the response is printed out.");
|
||||
System.out.println("If no argument is used, then the address and PIN of the module");
|
||||
System.out.println("are queried and the results printed out.");
|
||||
|
||||
}
|
||||
|
||||
private static void sendCommand(upm_hm11.HM11 ble, byte[] cmd) {
|
||||
byte[] buffer = new byte[BUFSIZ];
|
||||
ble.writeData(cmd);
|
||||
|
||||
// wait up to 1 second
|
||||
if (ble.dataAvailable(1000)) {
|
||||
ble.readData(buffer);
|
||||
} else {
|
||||
System.err.println("Timed out waiting for response");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a HM11 BLE Module on UART 0
|
||||
upm_hm11.HM11 ble = new upm_hm11.HM11(0);
|
||||
|
||||
// make sure port is initialized properly. 9600 baud is the default.
|
||||
if (!ble.setupTty()) {
|
||||
System.err.println("Failed to setup tty port parameters");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
printUsage();
|
||||
|
||||
if (args.length > 0) {
|
||||
System.out.println("Sending command line argument (" + args[0] + ")...");
|
||||
sendCommand(ble, args[0].getBytes());
|
||||
} else {
|
||||
// query the module address
|
||||
String addr = "AT+ADDR?";
|
||||
System.out.println("Querying module address (" + addr + ")...");
|
||||
sendCommand(ble, addr.getBytes());
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
// query the module address
|
||||
String pin = "AT+PASS?";
|
||||
System.out.println("Querying module pin (" + pin + ")...");
|
||||
sendCommand(ble, pin.getBytes());
|
||||
|
||||
// Other potentially useful commands are:
|
||||
//
|
||||
// AT+VERS? - query module version
|
||||
// AT+ROLE0 - set as slave
|
||||
// AT+ROLE1 - set as master
|
||||
// AT+CLEAR - clear all previous settings
|
||||
// AT+RESET - restart the device
|
||||
//
|
||||
// A comprehensive list is available from the datasheet at:
|
||||
// http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf
|
||||
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
131
examples/java/HMTRPSample.java
Normal file
131
examples/java/HMTRPSample.java
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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 HMTRPSample {
|
||||
|
||||
static private final int bufferLength = 255;
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_hmtrp");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void printUsage() {
|
||||
System.out.println("Usage:");
|
||||
System.out.println("Pass a commandline argument (any argument) to this program");
|
||||
System.out.println("to query the radio configuration and output it. NOTE: the");
|
||||
System.out.println("radio must be in CONFIG mode for this to work.");
|
||||
System.out.println("Running this program without arguments will simply transmit");
|
||||
System.out.println("'Hello World!' every second, and output any data received from");
|
||||
System.out.println("another radio.");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a HMTRP radio device on uart 0
|
||||
upm_hmtrp.HMTRP radio = new upm_hmtrp.HMTRP(0);
|
||||
|
||||
// make sure port is initialized properly. 9600 baud is the default.
|
||||
if (!radio.setupTty()) {
|
||||
System.err.println("Failed to setup tty port parameters");
|
||||
System.exit(-1);
|
||||
}
|
||||
printUsage();
|
||||
|
||||
// By default, this radio simply transmits data sent via writeData()
|
||||
// and reads any available data via readData().
|
||||
|
||||
// It can be placed into a configuration mode by grounding the
|
||||
// CONFIG pin on the module. When this is done, the various
|
||||
// configuration query and config methods can be used. In this
|
||||
// example, by default, we just read any data available fom the
|
||||
// device, and periodically transmit "Hello World".
|
||||
|
||||
// If any argument was specified on the command line, do a simple
|
||||
// configuration query and output the results. The radio must be in·
|
||||
// CONFIG mode for this to work.
|
||||
|
||||
if (args.length > 0) {
|
||||
// config mode
|
||||
long[] freq = {0};
|
||||
long[] dataRate = {0};
|
||||
int[] rxBandwidth = {0};
|
||||
short[] modulation = {0};
|
||||
short[] txPower = {0};
|
||||
long[] uartBaud = {0};
|
||||
|
||||
if (radio.getConfig(freq, dataRate, rxBandwidth, modulation, txPower, uartBaud)) {
|
||||
System.out.println("Radio configuration:");
|
||||
System.out.println("freq: " + freq[0] + " dataRate: " + dataRate[0]
|
||||
+ " rxBandwidth: " + rxBandwidth[0] + "Khz");
|
||||
System.out.println("modulation: " + modulation[0] + "Khz txPower: " + txPower[0]
|
||||
+ " uartBaud: " + uartBaud[0]);
|
||||
} else {
|
||||
System.err.println("getConfig() failed. Make sure the radio is in CONFIG mode.");
|
||||
}
|
||||
} else {
|
||||
// normal read/write mode
|
||||
byte[] radioBuffer = new byte[bufferLength];
|
||||
byte[] hello = "Hello World".getBytes();
|
||||
int counter = 0;
|
||||
|
||||
System.out.println("Running in normal read/write mode.");
|
||||
|
||||
while (true) {
|
||||
// we don't want the read to block in this example, so always
|
||||
// check to see if data is available first.
|
||||
if (radio.dataAvailable()) {
|
||||
int rv = radio.readData(radioBuffer);
|
||||
|
||||
if (rv > 0) {
|
||||
System.out.print("Received: ");
|
||||
for (int i = 0; i < radioBuffer.length; i++)
|
||||
System.out.print((char) radioBuffer[i]);
|
||||
System.out.println();
|
||||
} else {
|
||||
System.err.println("Port read error.");
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
counter++;
|
||||
// every second, transmit "Hello World!"
|
||||
if (counter > 10) {
|
||||
System.out.println("Transmitting hello world...");
|
||||
radio.writeData(hello);
|
||||
counter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -1,5 +1,28 @@
|
||||
import upm_htu21d.javaupm_htu21dConstants;
|
||||
/*
|
||||
* 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 HTU21DSample {
|
||||
|
||||
static {
|
||||
@ -12,11 +35,12 @@ public class HTU21DSample{
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
float humidity = 0;
|
||||
float temperature = 0;
|
||||
float compRH = 0;
|
||||
|
||||
upm_htu21d.HTU21D sensor = new upm_htu21d.HTU21D(1);
|
||||
upm_htu21d.HTU21D sensor = new upm_htu21d.HTU21D(0);
|
||||
sensor.testSensor();
|
||||
|
||||
while (true) {
|
||||
@ -24,10 +48,12 @@ public class HTU21DSample{
|
||||
humidity = sensor.getHumidity();
|
||||
temperature = sensor.getTemperature();
|
||||
|
||||
System.out.println( "Humidity: " + humidity + ", Temperature: " + temperature + ", compensated RH: " + compRH);
|
||||
System.out.println("Humidity: " + humidity + ", Temperature: " + temperature
|
||||
+ ", compensated RH: " + compRH);
|
||||
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,6 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class Hmc5883lSample {
|
||||
|
||||
static {
|
||||
@ -49,10 +48,11 @@ public class Hmc5883lSample {
|
||||
compas.update();
|
||||
|
||||
pos = compas.coordinates();
|
||||
System.out.println("Coor: " + pos[0] + " " + pos[1] + " " + pos[2]);
|
||||
System.out.println("Heading: " + compas.heading() + " Direction:" + compas.heading());
|
||||
System.out.println("Coor: " + (short) pos[0] + " " + (short) pos[1] + " "
|
||||
+ (short) pos[2]);
|
||||
System.out.println("Heading: " + compas.heading() + " Direction:" + compas.direction());
|
||||
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
@ -48,7 +48,8 @@ public class Itg3200Sample {
|
||||
ang = gyro.getRotation();
|
||||
|
||||
System.out.println("Raw Values: X: " + rot[0] + " Y: " + rot[1] + " Z: " + rot[2]);
|
||||
System.out.println( "Angular Velocities: X: " + ang[0] + " Y: " + ang[1] + " Z: " + ang[2]);
|
||||
System.out.println("Angular Velocities: X: " + ang[0] + " Y: " + ang[1] + " Z: "
|
||||
+ ang[2]);
|
||||
|
||||
System.out.println("Temp: " + gyro.getTemperature() + ", Raw: " + gyro.getRawTemp());
|
||||
|
||||
|
51
examples/java/Jhd1313m1Sample.java
Normal file
51
examples/java/Jhd1313m1Sample.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public class Jhd1313m1Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_i2clcd");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_i2clcd.Jhd1313m1 lcd = new upm_i2clcd.Jhd1313m1(0);
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.write("Hello World");
|
||||
lcd.setCursor(1, 2);
|
||||
lcd.write("Hello World");
|
||||
|
||||
System.out.println("Sleeping for 5 seconds");
|
||||
Thread.sleep(5000);
|
||||
lcd.clear();
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ public class LSM303Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_lsm303");
|
||||
System.loadLibrary("javaupm_lsm303");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
@ -46,7 +46,8 @@ public class LSM303Sample {
|
||||
|
||||
// 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());
|
||||
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());
|
||||
@ -55,9 +56,11 @@ public class LSM303Sample {
|
||||
sensor.getAcceleration();
|
||||
int[] accel = sensor.getRawAccelData();
|
||||
|
||||
// Print out the X, Y, and Z acceleration data using two different methods
|
||||
// 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());
|
||||
System.out.println("acc: gX " + sensor.getAccelX() + " - gY " + sensor.getAccelY()
|
||||
+ " - gZ " + sensor.getAccelZ());
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
58
examples/java/Lcm1602_i2cSample.java
Normal file
58
examples/java/Lcm1602_i2cSample.java
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 Lcm1602_i2cSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_i2clcd");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_i2clcd.Lcm1602 lcd = new upm_i2clcd.Lcm1602(0, 0x27);
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.write("Hello World");
|
||||
Thread.sleep(3000);
|
||||
|
||||
lcd.setCursor(1, 2);
|
||||
lcd.write("Hello World");
|
||||
Thread.sleep(3000);
|
||||
|
||||
lcd.setCursor(2, 4);
|
||||
lcd.write("Hello World");
|
||||
Thread.sleep(3000);
|
||||
|
||||
lcd.setCursor(3, 6);
|
||||
lcd.write("Hello World");
|
||||
Thread.sleep(3000);
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
61
examples/java/Lcm1602_parallelSample.java
Normal file
61
examples/java/Lcm1602_parallelSample.java
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 Lcm1602_parallelSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_i2clcd");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// LCD connection:
|
||||
// LCD RS pin to digital pin 8
|
||||
// LCD Enable pin to digital pin 13
|
||||
// LCD D4 pin to digital pin 2
|
||||
// LCD D5 pin to digital pin 3
|
||||
// LCD D6 pin to digital pin 4
|
||||
// LCD D7 pin to digital pin 5
|
||||
// LCD R/W pin to ground
|
||||
// 10K trimmer potentiometer:
|
||||
// ends to +5V and ground
|
||||
// wiper to LCD VO pin (pin 3)
|
||||
upm_i2clcd.Lcm1602 lcd = new upm_i2clcd.Lcm1602(8, 13, 2, 3, 4, 5, 20, 2);
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.write("Hello World");
|
||||
lcd.setCursor(1, 2);
|
||||
lcd.write("Hello World");
|
||||
|
||||
System.out.println("Sleeping for 5 seconds");
|
||||
Thread.sleep(5000);
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
58
examples/java/LoL_exampleSample.java
Normal file
58
examples/java/LoL_exampleSample.java
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 LoL_exampleSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_lol");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_lol.LoL sensor = new upm_lol.LoL();
|
||||
|
||||
int x = 0, y = 0;
|
||||
while (true) {
|
||||
// revert pixel
|
||||
short pixel = sensor.getPixel(x, y);
|
||||
pixel = (short) ((pixel == 0) ? 1 : 0);
|
||||
sensor.setPixel(x, y, pixel);
|
||||
|
||||
if (++x == 13) {
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
if (y == 9)
|
||||
y = 0;
|
||||
Thread.sleep(10);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
64
examples/java/M24LR64ESample.java
Normal file
64
examples/java/M24LR64ESample.java
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 M24LR64ESample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_m24lr64e");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate an M24LR64E on I2C bus 0
|
||||
upm_m24lr64e.M24LR64E nfcTag = new upm_m24lr64e.M24LR64E(0);
|
||||
|
||||
// This example accesses the device in the 'user' (default) mode,
|
||||
// reads the last byte of data in the EEPROM, inverts it, writes
|
||||
// it back, and then re-reads it.
|
||||
|
||||
// Read the last byte of the EEPROM area
|
||||
int addr = upm_m24lr64e.M24LR64E.EEPROM_I2C_LENGTH - 1;
|
||||
System.out.println("Address: " + addr);
|
||||
short read = nfcTag.readByte(addr);
|
||||
System.out.println("Read: " + read);
|
||||
|
||||
// Now change it to it's opposite and write it
|
||||
read = (short) (~read & 0xff);
|
||||
nfcTag.writeByte(addr, read);
|
||||
System.out.println("Wrote: " + read);
|
||||
|
||||
// Now read it back
|
||||
read = nfcTag.readByte(addr);
|
||||
System.out.println("Read: " + read);
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ public class MAX44000Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_max44000");
|
||||
System.loadLibrary("javaupm_max44000");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
|
@ -49,7 +49,8 @@ public class MHZ16Sample {
|
||||
|
||||
while (true) {
|
||||
co2.getData(gas, temp);
|
||||
System.out.println("CO2 concentration: " + gas[0] + "PPM, Temperature (in C): " + temp[0]);
|
||||
System.out.println("CO2 concentration: " + gas[0] + "PPM, Temperature (in C): "
|
||||
+ temp[0]);
|
||||
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
51
examples/java/MMA7455Sample.java
Normal file
51
examples/java/MMA7455Sample.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 MMA7455Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_mma7455");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_mma7455.MMA7455 sensor = new upm_mma7455.MMA7455(0);
|
||||
short[] val;
|
||||
|
||||
while (true) {
|
||||
val = sensor.readData();
|
||||
System.out.println("Accelerometer X: " + val[0] + ", Y: " + val[1] + ", Z: " + val[2]);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -50,10 +50,12 @@ public class MMA7660Sample {
|
||||
|
||||
while (true) {
|
||||
int[] rawValues = accel.getRawValues();
|
||||
System.out.println("Raw Values: x = " + rawValues[0] + " y = " + rawValues[1] + " x = " + rawValues[2]);
|
||||
System.out.println("Raw Values: x = " + rawValues[0] + " y = " + rawValues[1] + " x = "
|
||||
+ rawValues[2]);
|
||||
|
||||
float[] acceleration = accel.getAcceleration();
|
||||
System.out.println("Raw Values: x = " + acceleration[0] + " y = " + acceleration[1] + " x = " + acceleration[2]);
|
||||
System.out.println("Raw Values: x = " + acceleration[0] + " y = " + acceleration[1]
|
||||
+ " x = " + acceleration[2]);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class MPL3115A2Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_mpl3115a2");
|
||||
System.loadLibrary("javaupm_mpl3115a2");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
|
@ -27,7 +27,7 @@ public class MPU9150Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_mpu9150");
|
||||
System.loadLibrary("javaupm_mpu9150");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
@ -44,13 +44,16 @@ public class MPU9150Sample {
|
||||
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);
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ public class MQ303ASample{
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate an mq303a sensor on analog pin A0
|
||||
|
||||
// This device uses a heater powered from an analog I/O pin.·
|
||||
@ -58,7 +57,6 @@ public class MQ303ASample{
|
||||
|
||||
mq303a.heaterEnable(false);
|
||||
System.out.println("Exiting");
|
||||
//! [Interesting]
|
||||
}
|
||||
|
||||
}
|
48
examples/java/MY9221Sample.java
Normal file
48
examples/java/MY9221Sample.java
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public class MY9221Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_my9221");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// Instantiate a Grove LED Bar, with Data pin D8 and Clock pin D9
|
||||
upm_my9221.MY9221 bar = new upm_my9221.MY9221((short) 8, (short) 9);
|
||||
|
||||
while (true) {
|
||||
for (short idx = 1; idx < 11; idx++) {
|
||||
bar.setBarLevel(idx);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -55,7 +55,8 @@ public class MicrophoneSample{
|
||||
int thresh = sensor.findThreshold(ctx, 30, buffer);
|
||||
sensor.printGraph(ctx);
|
||||
if (thresh != 0) {
|
||||
System.out.println("---Threshold reached--- " + ctx.getRunningAverage() + " " + ctx.getAverageReading());
|
||||
System.out.println("---Threshold reached--- " + ctx.getRunningAverage() + " "
|
||||
+ ctx.getAverageReading());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
84
examples/java/NRF24L01_receiverSample.java
Normal file
84
examples/java/NRF24L01_receiverSample.java
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import upm_nrf24l01.Callback;
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class NRF24L01_receiverSample {
|
||||
|
||||
static private final byte[] local_address = {0x01, 0x01, 0x01, 0x01, 0x01};
|
||||
static private final byte[] broadcast_address = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
|
||||
(byte) 0xFF, (byte) 0xFF};
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_nrf24l01");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_nrf24l01.NRF24L01 comm = new upm_nrf24l01.NRF24L01((short) 7, (short) 8);
|
||||
|
||||
Callback callback = new ReceiverCallback(comm);
|
||||
|
||||
comm.setSourceAddress(local_address);
|
||||
comm.setDestinationAddress(broadcast_address);
|
||||
comm.setPayload((short) upm_nrf24l01.javaupm_nrf24l01Constants.MAX_BUFFER);
|
||||
comm.configure();
|
||||
comm.setSpeedRate(upm_nrf24l01.speed_rate_t.NRF_250KBPS);
|
||||
comm.setChannel((short) 99);
|
||||
comm.setDataReceivedHandler(callback);
|
||||
|
||||
while (true) {
|
||||
comm.pollListener();
|
||||
}
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
||||
|
||||
class ReceiverCallback extends Callback {
|
||||
|
||||
private upm_nrf24l01.NRF24L01 comm = null;
|
||||
|
||||
public ReceiverCallback(upm_nrf24l01.NRF24L01 comm) {
|
||||
super();
|
||||
this.comm = comm;
|
||||
}
|
||||
public void run() {
|
||||
if (comm != null) {
|
||||
short[] rx_buffer = comm.getM_rxBuffer();
|
||||
System.out.print("Received: ");
|
||||
for (int i = 0; i < rx_buffer.length; i++)
|
||||
System.out.print(rx_buffer[i]);
|
||||
System.out.println();
|
||||
} else {
|
||||
System.out.println("No NRF24L01 instance given to callback");
|
||||
}
|
||||
}
|
||||
}
|
75
examples/java/NRF24L01_transmitterSample.java
Normal file
75
examples/java/NRF24L01_transmitterSample.java
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import upm_nrf24l01.Callback;
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class NRF24L01_transmitterSample {
|
||||
|
||||
static private final byte[] destAddress = {0x01, 0x01, 0x01, 0x01, 0x01};
|
||||
static private final byte[] srcAddress = {0x01, 0x01, 0x01, 0x01, 0x01};
|
||||
static private byte[] tx_buffer = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
|
||||
0x00};
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_nrf24l01");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_nrf24l01.NRF24L01 comm = new upm_nrf24l01.NRF24L01((short) 7, (short) 8);
|
||||
|
||||
Callback callback = new TransmitterCallback();
|
||||
|
||||
comm.setSourceAddress(srcAddress);
|
||||
comm.setDestinationAddress(destAddress);
|
||||
comm.setPayload((short) upm_nrf24l01.javaupm_nrf24l01Constants.MAX_BUFFER);
|
||||
comm.setChannel((short) 99);
|
||||
comm.configure();
|
||||
comm.setDataReceivedHandler(callback);
|
||||
|
||||
while (true) {
|
||||
comm.send(tx_buffer);
|
||||
System.out.println("devi2 :: sending data ....");
|
||||
for (int i = 0; i < tx_buffer.length; i++)
|
||||
System.out.print(tx_buffer[i]);
|
||||
System.out.println();
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
||||
|
||||
class TransmitterCallback extends Callback {
|
||||
public TransmitterCallback() {
|
||||
super();
|
||||
}
|
||||
public void run() {
|
||||
}
|
||||
}
|
@ -47,9 +47,10 @@ public class NUNCHUCKSample{
|
||||
|
||||
while (true) {
|
||||
nunchuck.update();
|
||||
System.out.println( "stickX: " + nunchuck.getStickX() + ", stickY: " + nunchuck.getStickY() );
|
||||
System.out.println( "accelX: " + nunchuck.getAccelX() + ", accelY: " + nunchuck.getAccelY()
|
||||
+", accelZ: " + nunchuck.getAccelZ());
|
||||
System.out.println("stickX: " + nunchuck.getStickX() + ", stickY: "
|
||||
+ nunchuck.getStickY());
|
||||
System.out.println("accelX: " + nunchuck.getAccelX() + ", accelY: "
|
||||
+ nunchuck.getAccelY() + ", accelZ: " + nunchuck.getAccelZ());
|
||||
|
||||
if (nunchuck.getButtonC())
|
||||
System.out.println("Button C pressed");
|
||||
|
@ -37,7 +37,8 @@ public class OTP538USample{
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a OTP538U on analog pins A0 and A1
|
||||
// A0 is used for the Ambient Temperature and A1 is used for the Object temperature.
|
||||
// A0 is used for the Ambient Temperature and A1 is used for the Object
|
||||
// temperature.
|
||||
upm_otp538u.OTP538U temps = new upm_otp538u.OTP538U(0, 1, OTP538U_AREF);
|
||||
|
||||
while (true) {
|
||||
|
@ -22,7 +22,6 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class PPD42NSSample {
|
||||
|
||||
static {
|
||||
|
@ -41,8 +41,7 @@ public class RFR359FSample{
|
||||
while (true) {
|
||||
if (dInterruptor.objectDetected()) {
|
||||
System.out.println("Object detected");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
System.out.println("Area is clear!");
|
||||
}
|
||||
|
||||
|
98
examples/java/SSD1308_oledSample.java
Normal file
98
examples/java/SSD1308_oledSample.java
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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 SSD1308_oledSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_i2clcd");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
static private final int[] IntelLogo = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 192,
|
||||
192, 192, 224, 224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60,
|
||||
60, 62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, 30, 62, 62, 62, 62,
|
||||
126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240, 224, 224, 224, 192, 128, 128,
|
||||
128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1,
|
||||
1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 192,
|
||||
192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195, 195, 7, 15, 15, 63, 127,
|
||||
255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 192, 240,
|
||||
248, 124, 124, 60, 0, 0, 0, 0, 159, 159, 159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 0, 0, 0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128,
|
||||
128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128, 128, 128,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 3, 7, 3, 3,
|
||||
3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255, 255, 255, 0, 0, 224, 248, 252, 252,
|
||||
255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||
0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255,
|
||||
255, 255, 255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15,
|
||||
15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143, 135, 135, 143,
|
||||
159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 224, 248, 248, 255, 255, 255, 255,
|
||||
255, 127, 15, 255, 255, 255, 255, 255, 255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255, 255, 255, 255,
|
||||
231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231, 231, 231, 199, 135, 0, 0,
|
||||
0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 224, 240, 248, 248, 252, 254,
|
||||
255, 255, 255, 127, 63, 63, 31, 15, 7, 7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255,
|
||||
240, 192, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7, 7, 7,
|
||||
3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7, 7, 3, 3, 3, 1, 1,
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15, 31, 127, 127, 127, 255, 255,
|
||||
252, 252, 252, 248, 240, 240, 240, 224, 224, 224, 192, 192, 192, 192, 128, 128, 128,
|
||||
128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192,
|
||||
192, 192, 192, 224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252,
|
||||
252, 254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 15,
|
||||
15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127, 127, 127, 255, 255, 255, 255, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127,
|
||||
127, 127, 127, 127, 63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7,
|
||||
3, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0};
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_i2clcd.SSD1308 lcd = new upm_i2clcd.SSD1308(0);
|
||||
|
||||
byte[] image = new byte[IntelLogo.length];
|
||||
for (int i = 0; i < IntelLogo.length; i++)
|
||||
image[i] = (byte) IntelLogo[i];
|
||||
|
||||
lcd.clear();
|
||||
lcd.draw(image);
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
144
examples/java/SSD1327_oledSample.java
Normal file
144
examples/java/SSD1327_oledSample.java
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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 SSD1327_oledSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_i2clcd");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
static private final int[] SeeedLogo = new int[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
|
||||
0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x03,
|
||||
0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xC0, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x07, 0x80, 0x01, 0xE0, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x20, 0x0F, 0x80, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x30, 0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F,
|
||||
0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01,
|
||||
0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x38, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x80, 0x01, 0xE0, 0x38, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3C, 0x0F, 0x80, 0x01, 0xE0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x0F, 0x80, 0x03, 0xE0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x07,
|
||||
0x80, 0x03, 0xE0, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x07, 0x80, 0x03,
|
||||
0xE0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x07, 0x80, 0x03, 0xC1, 0xF0,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x87, 0xC0, 0x07, 0xC1, 0xF0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0F, 0x83, 0xC0, 0x07, 0x83, 0xE0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0F, 0xC3, 0xC0, 0x07, 0x87, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x07, 0xE1, 0xE0, 0x07, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF0,
|
||||
0xE0, 0x0F, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF8, 0xF0, 0x0E,
|
||||
0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF8, 0x70, 0x1C, 0x3F, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x30, 0x18, 0x7E, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x18, 0x30, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x88, 0x21, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x0F, 0xC4, 0x47, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
|
||||
0xE0, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x3E,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x06, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
|
||||
0x06, 0x00, 0x00, 0x60, 0x00, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xDF, 0xE1,
|
||||
0x9F, 0xEC, 0x7E, 0xE6, 0x73, 0x9C, 0xE7, 0x39, 0xCE, 0x1C, 0xDF, 0xE1, 0xB9, 0xEC,
|
||||
0xE7, 0xE0, 0x61, 0xD8, 0x66, 0x1B, 0x86, 0x1C, 0x06, 0x61, 0xB0, 0x6D, 0xC3, 0x7C,
|
||||
0x7F, 0xFF, 0xFF, 0xFF, 0x06, 0x0F, 0x86, 0x61, 0xB0, 0x6D, 0x83, 0x3E, 0x7F, 0xFF,
|
||||
0xFF, 0xFF, 0x06, 0x07, 0xC6, 0x61, 0xB0, 0x6D, 0x83, 0xC3, 0x61, 0x18, 0x46, 0x03,
|
||||
0x86, 0x18, 0x66, 0x61, 0xB0, 0x6D, 0xC3, 0xFE, 0x7F, 0x9F, 0xE7, 0xF9, 0xFE, 0x1F,
|
||||
0xE6, 0x3F, 0x9F, 0xEC, 0xFE, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xC6, 0x3F,
|
||||
0x9F, 0xEC, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x20, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x44, 0x00, 0x00, 0x20, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C,
|
||||
0xF3, 0xCF, 0x70, 0x9E, 0x79, 0xE7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x9E, 0x68,
|
||||
0x20, 0xB2, 0xC8, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x9E, 0x6F, 0x20, 0xB2,
|
||||
0xF9, 0xE7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x46, 0x9A, 0x61, 0x20, 0xB2, 0xCB, 0x60,
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xF3, 0xCF, 0x30, 0x9E, 0x79, 0xE7, 0x90, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7C, 0x02, 0x00, 0x00, 0x82, 0x60, 0x00, 0x00, 0xF8, 0x00, 0x00,
|
||||
0x40, 0x40, 0x02, 0x00, 0x00, 0x83, 0x60, 0x00, 0x00, 0x8C, 0x00, 0x00, 0x40, 0x60,
|
||||
0xB7, 0x79, 0xE7, 0x81, 0xC7, 0x92, 0x70, 0x89, 0xE7, 0x9E, 0x78, 0x7C, 0xE2, 0xC9,
|
||||
0x2C, 0x81, 0xCC, 0xD2, 0x40, 0xFB, 0x21, 0xB2, 0x48, 0x40, 0x62, 0xF9, 0x2C, 0x80,
|
||||
0x8C, 0xD2, 0x40, 0x8B, 0xE7, 0xB0, 0x48, 0x40, 0xE2, 0xC9, 0x2C, 0x80, 0x84, 0xD2,
|
||||
0x40, 0x8B, 0x2D, 0x92, 0x48, 0x7D, 0xB3, 0x79, 0x27, 0x80, 0x87, 0x9E, 0x40, 0x8D,
|
||||
0xE7, 0x9E, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_i2clcd.SSD1327 lcd = new upm_i2clcd.SSD1327(0);
|
||||
|
||||
// If you don't set the display to be white, the seeed logo will appear
|
||||
// jagged
|
||||
lcd.setGrayLevel((short) 12);
|
||||
|
||||
byte[] image = new byte[SeeedLogo.length];
|
||||
for (int i = 0; i < SeeedLogo.length; i++)
|
||||
image[i] = (byte) SeeedLogo[i];
|
||||
|
||||
lcd.draw(image);
|
||||
|
||||
// Simple print hello world
|
||||
for (short i = 0; i < 12; i++) {
|
||||
lcd.setCursor(i, 0);
|
||||
lcd.setGrayLevel(i);
|
||||
lcd.write("Hello World");
|
||||
}
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
86
examples/java/ST7735Sample.java
Normal file
86
examples/java/ST7735Sample.java
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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 ST7735Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_st7735");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_st7735.ST7735 lcd = new upm_st7735.ST7735((short) 7, (short) 4, (short) 9, (short) 8);
|
||||
|
||||
lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_RED);
|
||||
lcd.refresh();
|
||||
|
||||
lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_CYAN);
|
||||
lcd.refresh();
|
||||
|
||||
lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_BLACK);
|
||||
lcd.refresh();
|
||||
|
||||
lcd.drawLine((short) 10, (short) 10, (short) 10, (short) 100,
|
||||
upm_st7735.javaupm_st7735Constants.ST7735_MAGENTA);
|
||||
lcd.drawLine((short) 20, (short) 20, (short) 10, (short) 100,
|
||||
upm_st7735.javaupm_st7735Constants.ST7735_YELLOW);
|
||||
lcd.drawLine((short) 30, (short) 30, (short) 50, (short) 100,
|
||||
upm_st7735.javaupm_st7735Constants.ST7735_WHITE);
|
||||
lcd.refresh();
|
||||
|
||||
lcd.drawPixel((short) 20, (short) 20, upm_st7735.javaupm_st7735Constants.ST7735_GREEN);
|
||||
lcd.refresh();
|
||||
|
||||
lcd.drawTriangle((short) 50, (short) 50, (short) 80, (short) 80, (short) 60, (short) 90,
|
||||
upm_st7735.javaupm_st7735Constants.ST7735_GREEN);
|
||||
lcd.refresh();
|
||||
|
||||
lcd.drawCircle((short) 100, (short) 110, (short) 10,
|
||||
upm_st7735.javaupm_st7735Constants.ST7735_BLUE);
|
||||
lcd.refresh();
|
||||
|
||||
lcd.setTextWrap((short) 0);
|
||||
|
||||
lcd.setCursor((short) 0, (short) 30);
|
||||
lcd.setTextColor(upm_st7735.javaupm_st7735Constants.ST7735_RED,
|
||||
upm_st7735.javaupm_st7735Constants.ST7735_RED);
|
||||
lcd.setTextSize((short) 1);
|
||||
lcd.print("Hello World!");
|
||||
|
||||
lcd.setCursor((short) 10, (short) 50);
|
||||
lcd.setTextColor(upm_st7735.javaupm_st7735Constants.ST7735_RED,
|
||||
upm_st7735.javaupm_st7735Constants.ST7735_YELLOW);
|
||||
lcd.setTextSize((short) 2);
|
||||
lcd.print("BIG");
|
||||
|
||||
lcd.refresh();
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
62
examples/java/StepMotorSample.java
Normal file
62
examples/java/StepMotorSample.java
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 StepMotorSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_stepmotor");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_stepmotor.StepMotor sensor = new upm_stepmotor.StepMotor(4, 6);
|
||||
|
||||
while (true) {
|
||||
sensor.setSpeed(500);
|
||||
sensor.stepForward(500);
|
||||
Thread.sleep(10);
|
||||
sensor.stepBackwards(500);
|
||||
Thread.sleep(10);
|
||||
|
||||
sensor.setSpeed(750);
|
||||
sensor.stepForward(500);
|
||||
Thread.sleep(10);
|
||||
sensor.stepBackwards(500);
|
||||
Thread.sleep(10);
|
||||
|
||||
sensor.setSpeed(1000);
|
||||
sensor.stepForward(500);
|
||||
Thread.sleep(10);
|
||||
sensor.stepBackwards(500);
|
||||
Thread.sleep(10);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -33,10 +33,14 @@ public class TP401Sample{
|
||||
}
|
||||
|
||||
private static String airQuality(int value) {
|
||||
if(value < 50) return "Fresh Air";
|
||||
if(value < 200) return "Normal Indoor Air";
|
||||
if(value < 400) return "Low Pollution";
|
||||
if(value < 600) return "High Pollution - Action Recommended";
|
||||
if (value < 50)
|
||||
return "Fresh Air";
|
||||
if (value < 200)
|
||||
return "Normal Indoor Air";
|
||||
if (value < 400)
|
||||
return "Low Pollution";
|
||||
if (value < 600)
|
||||
return "High Pollution - Action Recommended";
|
||||
return "Very High Pollution - Take Action Immediately";
|
||||
}
|
||||
|
||||
@ -58,7 +62,8 @@ public class TP401Sample{
|
||||
|
||||
while (true) {
|
||||
int value = airSensor.getSample(); // Read raw value
|
||||
float ppm = airSensor.getPPM(); // Read CO ppm (can vary slightly from previous read)
|
||||
float ppm = airSensor.getPPM(); // Read CO ppm (can vary slightly
|
||||
// from previous read)
|
||||
|
||||
System.out.println("raw: " + value + " ppm: " + ppm + " " + airQuality(value));
|
||||
|
||||
@ -67,5 +72,4 @@ public class TP401Sample{
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
|
||||
}
|
49
examples/java/TSL2561Sample.java
Normal file
49
examples/java/TSL2561Sample.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public class TSL2561Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_tsl2561");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a TSL2561 Digital Light Sensor on I2C
|
||||
upm_tsl2561.TSL2561 sensor = new upm_tsl2561.TSL2561();
|
||||
|
||||
while (true) {
|
||||
System.out.println("Lux = " + sensor.getLux());
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
121
examples/java/WT5001Sample.java
Normal file
121
examples/java/WT5001Sample.java
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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 WT5001Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_wt5001");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
static private void printUsage() {
|
||||
System.out.println("Usage: java WT5001Sample <command>");
|
||||
System.out.println("Commands:");
|
||||
System.out.println("0 - stop playing");
|
||||
System.out.println("1 - start playing track 1");
|
||||
System.out.println("2 - pause/un-pause playback");
|
||||
System.out.println("3 - next track");
|
||||
System.out.println("4 - previous track");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a WT5001 serial MP3 player on uart 0
|
||||
upm_wt5001.WT5001 mp3 = new upm_wt5001.WT5001(0);
|
||||
|
||||
int cmd = -1;
|
||||
if (args.length > 0)
|
||||
cmd = Integer.parseInt(args[0]);
|
||||
|
||||
// make sure port is initialized properly. 9600 baud is the default
|
||||
if (!mp3.setupTty()) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case 0 :
|
||||
mp3.stop();
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
mp3.play(upm_wt5001.WT5001.WT5001_PLAYSOURCE_T.SD, 1);
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
mp3.pause();
|
||||
break;
|
||||
|
||||
case 3 :
|
||||
mp3.next();
|
||||
break;
|
||||
|
||||
case 4 :
|
||||
mp3.previous();
|
||||
break;
|
||||
|
||||
default :
|
||||
// nothing, just output usage, and info below
|
||||
printUsage();
|
||||
break;
|
||||
}
|
||||
|
||||
// print out some information
|
||||
short vol[] = new short[1];
|
||||
if (mp3.getVolume(vol))
|
||||
System.out.println("The current volume is: " + vol[0]);
|
||||
|
||||
short ps[] = new short[1];
|
||||
if (mp3.getPlayState(ps))
|
||||
System.out.println("The current play state is: " + ps[0]);
|
||||
|
||||
int numf[] = new int[1];
|
||||
if (mp3.getNumFiles(upm_wt5001.WT5001.WT5001_PLAYSOURCE_T.SD, numf))
|
||||
System.out.println("The number of files on the SD card is: " + numf[0]);
|
||||
|
||||
int curf[] = new int[1];
|
||||
if (mp3.getCurrentFile(curf))
|
||||
System.out.println("The current file is: " + curf[0]);
|
||||
|
||||
int year[] = new int[1];
|
||||
short month[] = new short[1];
|
||||
short day[] = new short[1];
|
||||
if (mp3.getDate(year, month, day))
|
||||
System.out.println("The device date is: " + year[0] + "/" + month[0] + "/" + day[0]);
|
||||
|
||||
short hour[] = new short[1];
|
||||
short minute[] = new short[1];
|
||||
short second[] = new short[1];
|
||||
if (mp3.getTime(hour, minute, second))
|
||||
System.out
|
||||
.println("The device time is: " + hour[0] + ":" + minute[0] + ":" + second[0]);
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -42,8 +42,7 @@ public class YG1006Sample{
|
||||
boolean val = flame.flameDetected();
|
||||
if (val) {
|
||||
System.out.println("Flame detected");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
System.out.println("No flame detected");
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,7 @@ public class ZFM20Sample {
|
||||
// will be ignored, so we just bail.
|
||||
if (fp.verifyPassword()) {
|
||||
System.out.println("Password verified.");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
System.err.println("Password verification failed.");
|
||||
System.exit(-1);
|
||||
}
|
||||
@ -84,8 +83,7 @@ public class ZFM20Sample {
|
||||
if (rv == upm_zfm20.ZFM20.ZFM20_ERRORS_T.ERR_FP_NOTFOUND.swigValue()) {
|
||||
System.out.println("Fingerprint not found");
|
||||
System.exit(0);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
System.err.println("Search failed with error code " + rv);
|
||||
System.exit(-1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user