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

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

View File

@ -24,35 +24,36 @@
//NOT TESTED!!!
public class MHZ16Sample {
static {
try {
System.loadLibrary("javaupm_mhz16");
}catch (UnsatisfiedLinkError e) {
} catch (UnsatisfiedLinkError e) {
System.err.println("error in loading native library");
System.exit(-1);
}
}
public static void main(String[] args) throws InterruptedException {
//! [Interesting]
// ! [Interesting]
int[] gas = new int[1];
int[] temp = new int[1];
// Instantiate a MHZ16 serial CO2 sensor on uart 0.
upm_mhz16.MHZ16 co2 = new upm_mhz16.MHZ16(0);
System.out.println("Make sure that the sensor has had at least 3 minutes to warm up");
System.out.println("or you will not get valid results.");
System.out.println("The temperature reported is not the ambient temperature,");
System.out.println("but rather the temperature of the sensor elements.");
while(true){
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);
}
//! [Interesting]
// ! [Interesting]
}
}