upm/examples/java/BME280_Interface_Example.java

72 lines
2.5 KiB
Java
Raw Normal View History

SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes. * Added java swig interface files for all C++ interfaces to simplify swig javaupm_iADC.i javaupm_iCO2Sensor.i javaupm_iHumiditySensor.i javaupm_iLightController.i javaupm_iLightSensor.i javaupm_iModuleStatus.i javaupm_interfaces.i javaupm_iPressureSensor.i javaupm_iTemperatureSensor.i <example Usage> %include"../interfaces/javaupm_iADC.i" * Modified swig interface files for few sensors that implements interfaces ads1x15 bmp280 bmpx8x ds1808lc hlg150h lp8860 max44009 ms5611 si1132 si7005 t6713 * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance For example class A {}; class B : public A {}; class C : public A {}; class D : public B, public C {}; This can be solved as class A {}; class B : virtual public A {}; class C : virtual public A {}; class D : public B, public C {}; * Modified java interface files to support multiple swig versions * Modified javaupm interface file to support standard auto load library code * Fixed autoloadlibrary tests for interfaces * Created one interface example separately <BME280_InterfaceExample.java>, <example Usage> BME280_InterfaceExample.java since we cann't define swig versions inside java example file. So, instaed added swig versions in Cmake. <example Usage> if (SWIG_VERSION VERSION_GREATER 3.0.8) add_example_with_path(BME280_InterfaceExample bmp280 bmp280) endif() Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-02-06 14:59:00 -08:00
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Author: Sisinty Sasmita Patra <sisinty.s.patra@intel.com>
* Copyright (c) 2016 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_bmp280.*;
import upm_interfaces.*;
SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes. * Added java swig interface files for all C++ interfaces to simplify swig javaupm_iADC.i javaupm_iCO2Sensor.i javaupm_iHumiditySensor.i javaupm_iLightController.i javaupm_iLightSensor.i javaupm_iModuleStatus.i javaupm_interfaces.i javaupm_iPressureSensor.i javaupm_iTemperatureSensor.i <example Usage> %include"../interfaces/javaupm_iADC.i" * Modified swig interface files for few sensors that implements interfaces ads1x15 bmp280 bmpx8x ds1808lc hlg150h lp8860 max44009 ms5611 si1132 si7005 t6713 * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance For example class A {}; class B : public A {}; class C : public A {}; class D : public B, public C {}; This can be solved as class A {}; class B : virtual public A {}; class C : virtual public A {}; class D : public B, public C {}; * Modified java interface files to support multiple swig versions * Modified javaupm interface file to support standard auto load library code * Fixed autoloadlibrary tests for interfaces * Created one interface example separately <BME280_InterfaceExample.java>, <example Usage> BME280_InterfaceExample.java since we cann't define swig versions inside java example file. So, instaed added swig versions in Cmake. <example Usage> if (SWIG_VERSION VERSION_GREATER 3.0.8) add_example_with_path(BME280_InterfaceExample bmp280 bmp280) endif() Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-02-06 14:59:00 -08:00
public class BME280_Interface_Example
SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes. * Added java swig interface files for all C++ interfaces to simplify swig javaupm_iADC.i javaupm_iCO2Sensor.i javaupm_iHumiditySensor.i javaupm_iLightController.i javaupm_iLightSensor.i javaupm_iModuleStatus.i javaupm_interfaces.i javaupm_iPressureSensor.i javaupm_iTemperatureSensor.i <example Usage> %include"../interfaces/javaupm_iADC.i" * Modified swig interface files for few sensors that implements interfaces ads1x15 bmp280 bmpx8x ds1808lc hlg150h lp8860 max44009 ms5611 si1132 si7005 t6713 * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance For example class A {}; class B : public A {}; class C : public A {}; class D : public B, public C {}; This can be solved as class A {}; class B : virtual public A {}; class C : virtual public A {}; class D : public B, public C {}; * Modified java interface files to support multiple swig versions * Modified javaupm interface file to support standard auto load library code * Fixed autoloadlibrary tests for interfaces * Created one interface example separately <BME280_InterfaceExample.java>, <example Usage> BME280_InterfaceExample.java since we cann't define swig versions inside java example file. So, instaed added swig versions in Cmake. <example Usage> if (SWIG_VERSION VERSION_GREATER 3.0.8) add_example_with_path(BME280_InterfaceExample bmp280 bmp280) endif() Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-02-06 14:59:00 -08:00
{
public static void main(String[] args) throws InterruptedException
{
// ! [Interesting]
// Instantiate a BME280 instance using default i2c bus and address
BME280 sensor = new BME280();
iTemperature t_sensor = sensor;
iHumidity h_sensor = sensor;
iPressure p_sensor = sensor;
SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes. * Added java swig interface files for all C++ interfaces to simplify swig javaupm_iADC.i javaupm_iCO2Sensor.i javaupm_iHumiditySensor.i javaupm_iLightController.i javaupm_iLightSensor.i javaupm_iModuleStatus.i javaupm_interfaces.i javaupm_iPressureSensor.i javaupm_iTemperatureSensor.i <example Usage> %include"../interfaces/javaupm_iADC.i" * Modified swig interface files for few sensors that implements interfaces ads1x15 bmp280 bmpx8x ds1808lc hlg150h lp8860 max44009 ms5611 si1132 si7005 t6713 * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance For example class A {}; class B : public A {}; class C : public A {}; class D : public B, public C {}; This can be solved as class A {}; class B : virtual public A {}; class C : virtual public A {}; class D : public B, public C {}; * Modified java interface files to support multiple swig versions * Modified javaupm interface file to support standard auto load library code * Fixed autoloadlibrary tests for interfaces * Created one interface example separately <BME280_InterfaceExample.java>, <example Usage> BME280_InterfaceExample.java since we cann't define swig versions inside java example file. So, instaed added swig versions in Cmake. <example Usage> if (SWIG_VERSION VERSION_GREATER 3.0.8) add_example_with_path(BME280_InterfaceExample bmp280 bmp280) endif() Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-02-06 14:59:00 -08:00
// For SPI, bus 0, you would pass -1 as the address, and a
// valid pin for CS:
// BME280(0, -1, 10);
while (true)
{
// update our values from the sensor
sensor.update();
System.out.println("Calling Interface Functions: ");
System.out.println("Compensation Temperature: "
+ t_sensor.getTemperature()
SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes. * Added java swig interface files for all C++ interfaces to simplify swig javaupm_iADC.i javaupm_iCO2Sensor.i javaupm_iHumiditySensor.i javaupm_iLightController.i javaupm_iLightSensor.i javaupm_iModuleStatus.i javaupm_interfaces.i javaupm_iPressureSensor.i javaupm_iTemperatureSensor.i <example Usage> %include"../interfaces/javaupm_iADC.i" * Modified swig interface files for few sensors that implements interfaces ads1x15 bmp280 bmpx8x ds1808lc hlg150h lp8860 max44009 ms5611 si1132 si7005 t6713 * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance For example class A {}; class B : public A {}; class C : public A {}; class D : public B, public C {}; This can be solved as class A {}; class B : virtual public A {}; class C : virtual public A {}; class D : public B, public C {}; * Modified java interface files to support multiple swig versions * Modified javaupm interface file to support standard auto load library code * Fixed autoloadlibrary tests for interfaces * Created one interface example separately <BME280_InterfaceExample.java>, <example Usage> BME280_InterfaceExample.java since we cann't define swig versions inside java example file. So, instaed added swig versions in Cmake. <example Usage> if (SWIG_VERSION VERSION_GREATER 3.0.8) add_example_with_path(BME280_InterfaceExample bmp280 bmp280) endif() Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-02-06 14:59:00 -08:00
+ " C / ");
System.out.println("Pressure: "
+ p_sensor.getPressure()
SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes. * Added java swig interface files for all C++ interfaces to simplify swig javaupm_iADC.i javaupm_iCO2Sensor.i javaupm_iHumiditySensor.i javaupm_iLightController.i javaupm_iLightSensor.i javaupm_iModuleStatus.i javaupm_interfaces.i javaupm_iPressureSensor.i javaupm_iTemperatureSensor.i <example Usage> %include"../interfaces/javaupm_iADC.i" * Modified swig interface files for few sensors that implements interfaces ads1x15 bmp280 bmpx8x ds1808lc hlg150h lp8860 max44009 ms5611 si1132 si7005 t6713 * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance For example class A {}; class B : public A {}; class C : public A {}; class D : public B, public C {}; This can be solved as class A {}; class B : virtual public A {}; class C : virtual public A {}; class D : public B, public C {}; * Modified java interface files to support multiple swig versions * Modified javaupm interface file to support standard auto load library code * Fixed autoloadlibrary tests for interfaces * Created one interface example separately <BME280_InterfaceExample.java>, <example Usage> BME280_InterfaceExample.java since we cann't define swig versions inside java example file. So, instaed added swig versions in Cmake. <example Usage> if (SWIG_VERSION VERSION_GREATER 3.0.8) add_example_with_path(BME280_InterfaceExample bmp280 bmp280) endif() Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-02-06 14:59:00 -08:00
+ " Pa");
System.out.println("Humidity: "
+ h_sensor.getHumidity()
SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes. * Added java swig interface files for all C++ interfaces to simplify swig javaupm_iADC.i javaupm_iCO2Sensor.i javaupm_iHumiditySensor.i javaupm_iLightController.i javaupm_iLightSensor.i javaupm_iModuleStatus.i javaupm_interfaces.i javaupm_iPressureSensor.i javaupm_iTemperatureSensor.i <example Usage> %include"../interfaces/javaupm_iADC.i" * Modified swig interface files for few sensors that implements interfaces ads1x15 bmp280 bmpx8x ds1808lc hlg150h lp8860 max44009 ms5611 si1132 si7005 t6713 * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance For example class A {}; class B : public A {}; class C : public A {}; class D : public B, public C {}; This can be solved as class A {}; class B : virtual public A {}; class C : virtual public A {}; class D : public B, public C {}; * Modified java interface files to support multiple swig versions * Modified javaupm interface file to support standard auto load library code * Fixed autoloadlibrary tests for interfaces * Created one interface example separately <BME280_InterfaceExample.java>, <example Usage> BME280_InterfaceExample.java since we cann't define swig versions inside java example file. So, instaed added swig versions in Cmake. <example Usage> if (SWIG_VERSION VERSION_GREATER 3.0.8) add_example_with_path(BME280_InterfaceExample bmp280 bmp280) endif() Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-02-06 14:59:00 -08:00
+ " %RH");
System.out.println();
Thread.sleep(1000);
}
// ! [Interesting]
}
}