From c16b33ae3112646c6a32e7048f0e81dbfc58f747 Mon Sep 17 00:00:00 2001 From: Serban Waltter Date: Thu, 21 Jun 2018 16:49:42 +0300 Subject: [PATCH] Updated Java CMake and examples to comply with the new interfaces. Signed-off-by: Serban Waltter Signed-off-by: Mihai Tudor Panu --- examples/c++/CMakeLists.txt | 4 +- examples/java/BME280_Interface_Example.java | 14 ++--- examples/java/BMPX8X_Example.java | 2 - examples/java/CMakeLists.txt | 62 ++++++++++----------- examples/java/HCSR04_Example.java | 2 +- examples/java/Moisture_Example.java | 2 +- 6 files changed, 41 insertions(+), 45 deletions(-) diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt index 0fa132ba..57e6a596 100644 --- a/examples/c++/CMakeLists.txt +++ b/examples/c++/CMakeLists.txt @@ -4,9 +4,9 @@ file (GLOB example_src_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cxx") # - Handle special cases here -------------------------------------------------- # Test temperature interface for 2 sensor libraries -add_example(iTemperature-sample.cxx TARGETS lm35 abp) +add_example(iTemperature_sample.cxx TARGETS new_interfaces lm35 abp) # Test light interface for 3 sensor libraries -add_example(iLight-sample.cxx TARGETS apds9002 bh1750 max44009) +add_example(iLight_sample.cxx TARGETS new_interfaces apds9002 bh1750 max44009) # - Create an executable for all other src files in this directory ------------- foreach (_example_src ${example_src_list}) diff --git a/examples/java/BME280_Interface_Example.java b/examples/java/BME280_Interface_Example.java index e3940d2a..fb0c487c 100644 --- a/examples/java/BME280_Interface_Example.java +++ b/examples/java/BME280_Interface_Example.java @@ -24,7 +24,7 @@ */ import upm_bmp280.*; -import upm_interfaces.*; +import upm_new_interfaces.*; public class BME280_Interface_Example { @@ -35,9 +35,9 @@ public class BME280_Interface_Example // Instantiate a BME280 instance using default i2c bus and address BME280 sensor = new BME280(); - ITemperatureSensor t_sensor = sensor; - IHumiditySensor h_sensor = sensor; - IPressureSensor p_sensor = sensor; + iTemperature t_sensor = sensor; + iHumidity h_sensor = sensor; + iPressure p_sensor = sensor; // For SPI, bus 0, you would pass -1 as the address, and a // valid pin for CS: @@ -51,15 +51,15 @@ public class BME280_Interface_Example System.out.println("Calling Interface Functions: "); System.out.println("Compensation Temperature: " - + t_sensor.getTemperatureCelsius() + + t_sensor.getTemperature() + " C / "); System.out.println("Pressure: " - + p_sensor.getPressurePa() + + p_sensor.getPressure() + " Pa"); System.out.println("Humidity: " - + h_sensor.getHumidityRelative() + + h_sensor.getHumidity() + " %RH"); System.out.println(); diff --git a/examples/java/BMPX8X_Example.java b/examples/java/BMPX8X_Example.java index 12a930d8..5e1f463e 100644 --- a/examples/java/BMPX8X_Example.java +++ b/examples/java/BMPX8X_Example.java @@ -35,8 +35,6 @@ public class BMPX8X_Example { // temperature values every .5 seconds while (true) { - sensor.update(); - System.out.println("Pressure: " + sensor.getPressure() + " Pa, Temperature: " diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt index 2841eabd..5670ec73 100644 --- a/examples/java/CMakeLists.txt +++ b/examples/java/CMakeLists.txt @@ -64,43 +64,41 @@ function(add_example example_class_name dependency_list) add_dependencies(${example_class_name} ${java_targets_list}) endfunction() -add_example(A110X_Example a110x) -add_example(A110X_intr_Example a110x) +add_example(A110X_Example "a110x;new_interfaces") +add_example(A110X_intr_Example "a110x;new_interfaces") add_example(Ad8232_Example ad8232) add_example(ADC121C021_Example adc121c021) add_example(Ads1015_Example "ads1x15;interfaces") add_example(Ads1115_Example ads1x15) add_example(Adxl345_Example adxl345) -add_example(AM2315_Example am2315) +add_example(AM2315_Example "am2315;new_interfaces") add_example(APA102_Example apa102) -add_example(Apds9002_Example apds9002) -add_example(BH1749_Example bh1749) -add_example(BH1750_Example bh1750) -add_example(BH1792_Example bh1792) -add_example(BISS0001_Example biss0001) +add_example(Apds9002_Example "apds9002;new_interfaces") +add_example(BH1750_Example "bh1750;new_interfaces") +add_example(BISS0001_Example "biss0001;new_interfaces") add_example(BMA250E_Example bma250e) add_example(BMC150_Example bmx055) -add_example(BME280_Example "bmp280;interfaces") +add_example(BME280_Example "bmp280;new_interfaces") add_example(BMG160_Example bmg160) add_example(BMI055_Example bmx055) add_example(BMI160_Example bmi160) add_example(BMM150_Example bmm150) -add_example(BMP280_Example "bmp280;interfaces") -add_example(BMPX8X_Example "bmpx8x;interfaces") +add_example(BMP280_Example "bmp280;new_interfaces") +add_example(BMPX8X_Example "bmpx8x;new_interfaces") add_example(BMX055_Example bmx055) add_example(BNO055_Example bno055) add_example(Button_Example button) add_example(Button_intr_Example button) add_example(Buzzer_Example buzzer) add_example(CJQ4435_Example cjq4435) -add_example(Collision_Example collision) +add_example(Collision_Example "collision;new_interfaces") add_example(CWLSXXA_Example cwlsxxa) add_example(DFREC_Example dfrec) add_example(DFRORP_Example dfrorp) add_example(DS1307_Example ds1307) add_example(ECEZO_Example ecezo) add_example(ECS1030_Example ecs1030) -add_example(EHR_Example ehr) +add_example(EHR_Example "ehr;;new_interfaces") add_example(Emg_Example emg) add_example(ENC03R_Example enc03r) add_example(ES08A_Example "servo;interfaces") @@ -108,16 +106,16 @@ add_example(FlexSensor_Example flex) add_example(Gp2y0a_Example gp2y0a) add_example(GroveButton_Example grove) add_example(GroveButton_intr_Example grove) -add_example(GroveEHR_Example groveehr) +add_example(GroveEHR_Example "groveehr;new_interfaces") add_example(GroveEmg_Example groveemg) add_example(GroveGsr_Example grovegsr) add_example(GroveLEDBar_Example my9221) add_example(GroveLED_Example grove) add_example(GroveLed_multi_Example grove) -add_example(GroveLight_Example grove) +add_example(GroveLight_Example "grove;new_interfaces") add_example(GroveLineFinder_Example grovelinefinder) add_example(GroveMD_Example grovemd) -add_example(GroveMoisture_Example grovemoisture) +add_example(GroveMoisture_Example "grovemoisture;new_interfaces") add_example(GroveMQ3_Example gas) add_example(GroveMQ9_Example gas) add_example(GroveO2_Example groveo2) @@ -127,20 +125,20 @@ add_example(GroveRotary_Example grove) add_example(GROVESCAM_Example grovescam) add_example(GroveSlide_Example grove) add_example(GroveSpeaker_Example grovespeaker) -add_example(GroveTemp_Example grove) +add_example(GroveTemp_Example "grove;new_interfaces") add_example(GroveVDiv_Example grovevdiv) add_example(GroveWater_Example grovewater) add_example(GroveWFS_Example grovewfs) add_example(Gsr_Example gsr) add_example(GUVAS12D_Example guvas12d) add_example(H3LIS331DL_Example h3lis331dl) -add_example(HCSR04_Example hcsr04) +add_example(HCSR04_Example "hcsr04;new_interfaces") add_example(HKA5_Example hka5) add_example(HM11_Example hm11) add_example(Hmc5883l_Example hmc5883l) add_example(HMTRP_Example hmtrp) -add_example(HP20x_Example hp20x) -add_example(HTU21D_Example htu21d) +add_example(HP20x_Example "hp20x;new_interfaces") +add_example(HTU21D_Example "htu21d;new_interfaces") add_example(Itg3200_Example itg3200) add_example(Jhd1313m1_Example jhd1313m1) add_example(Jhd1313m1_lcd_Example jhd1313m1) @@ -152,7 +150,7 @@ add_example(Lcm1602_parallel_Example lcm1602) add_example(LDT0028_Example ldt0028) add_example(LE910_Example uartat) add_example(LED_Example led) -add_example(Light_Example light) +add_example(Light_Example "light;new_interfaces") add_example(LineFinder_Example linefinder) add_example(LIS2DS12_Example lis2ds12) add_example(LoL_Example lol) @@ -167,7 +165,7 @@ add_example(MAX31855_Example max31855) add_example(MAX44000_Example max44000) add_example(MAX5487_Example max5487) add_example(MAXds3231m_Example maxds3231m) -add_example(MB704X_Example mb704x) +add_example(MB704X_Example "mb704x;new_interfaces") add_example(MCP2515_Example mcp2515) add_example(MCP2515_TXRX_Example mcp2515) add_example(MD_Example md) @@ -176,14 +174,14 @@ add_example(Microphone_Example mic) add_example(MMA7361_Example mma7361) add_example(MMA7455_Example mma7455) add_example(MMA7660_Example mma7660) -add_example(Moisture_Example moisture) -add_example(MPL3115A2_Example mpl3115a2) +add_example(Moisture_Example "moisture;new_interfaces") +add_example(MPL3115A2_Example "mpl3115a2;new_interfaces") add_example(MPR121_Example mpr121) add_example(MPU9150_Example mpu9150) add_example(MQ2_Example gas) add_example(MQ303A_Example mq303a) add_example(MQ5_Example gas) -add_example(MS5803_Example ms5803) +add_example(MS5803_Example "ms5803;new_interfaces") add_example(NMEAGPS_Example nmea_gps) add_example(NMEAGPS_I2C_Example nmea_gps) add_example(NRF24L01_receiver_Example nrf24l01) @@ -195,7 +193,7 @@ add_example(P9813_Example p9813) add_example(PPD42NS_Example ppd42ns) add_example(Pulsensor_Example pulsensor) add_example(Relay_Example relay) -add_example(RFR359F_Example rfr359f) +add_example(RFR359F_Example "rfr359f;new_interfaces") add_example(RN2903_Example rn2903) add_example(RN2903_P2P_RX_Example rn2903) add_example(RN2903_P2P_TX_Example rn2903) @@ -205,7 +203,7 @@ add_example(RPR220_Example rpr220) add_example(RPR220_intr_Example rpr220) add_example(SCAM_Example scam) add_example(SensorTemplate_Example sensortemplate) -add_example(SHT1X_Example sht1x) +add_example(SHT1X_Example "sht1x;new_interfaces") add_example(Slide_Example slide) add_example(SM130_Example sm130) add_example(Speaker_Example speaker) @@ -216,10 +214,10 @@ add_example(ST7735_Example st7735) add_example(TEAMS_Example teams) add_example(Temperature_Example temperature) add_example(TEX00_Example tex00) -add_example(Th02_Example th02) +add_example(Th02_Example "th02;new_interfaces") add_example(TM1637_Example tm1637) add_example(TP401_Example gas) -add_example(TSL2561_Example tsl2561) +add_example(TSL2561_Example "tsl2561;new_interfaces") add_example(TTP223_Example ttp223) add_example(ULN200XA_Example uln200xa) add_example(VDiv_Example vdiv) @@ -232,9 +230,9 @@ add_example(YG1006_Example yg1006) add_example(ZFM20_Example zfm20) if(SWIG_VERSION VERSION_GREATER 3.0.8) - add_example(BME280_Interface_Example "bmp280;interfaces") - add_example(IMS_Example "ims;interfaces") - add_example(RHUSB_Example "rhusb;interfaces") + add_example(BME280_Interface_Example "bmp280;new_interfaces") + add_example(IMS_Example "ims;new_interfaces") + add_example(RHUSB_Example "rhusb;new_interfaces") endif() if (OPENZWAVE_FOUND) diff --git a/examples/java/HCSR04_Example.java b/examples/java/HCSR04_Example.java index 9798d4e5..fdc2ff3e 100644 --- a/examples/java/HCSR04_Example.java +++ b/examples/java/HCSR04_Example.java @@ -35,7 +35,7 @@ public class HCSR04_Example { while (true) { System.out.println("Get distance"); - double distance = sonar.getDistance(HCSR04_U.swigToEnum(0)); + double distance = sonar.getDistance(); System.out.println("Distance: " + distance); Thread.sleep(5000); diff --git a/examples/java/Moisture_Example.java b/examples/java/Moisture_Example.java index 0437ab3c..06023f30 100644 --- a/examples/java/Moisture_Example.java +++ b/examples/java/Moisture_Example.java @@ -28,7 +28,7 @@ public class Moisture_Example { upm_moisture.Moisture gm = new upm_moisture.Moisture(1); while (true) { - int moisture_val = gm.value(); + int moisture_val = gm.getMoisture(); String result; if (moisture_val >= 0 && moisture_val < 300)