summaryrefslogtreecommitdiff
path: root/peripheral/libupm/examples
diff options
context:
space:
mode:
Diffstat (limited to 'peripheral/libupm/examples')
-rw-r--r--peripheral/libupm/examples/c++/CMakeLists.txt45
-rw-r--r--peripheral/libupm/examples/c++/a110x-intr.cxx2
-rw-r--r--peripheral/libupm/examples/c++/a110x.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ad8232.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adafruitms1438.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adafruitss.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adc-sensor.cxx80
-rw-r--r--peripheral/libupm/examples/c++/adc121c021.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ads1x15.cxx8
-rw-r--r--peripheral/libupm/examples/c++/adxl335.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adxl345.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adxrs610.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ak8975.cxx2
-rw-r--r--peripheral/libupm/examples/c++/am2315.cxx2
-rw-r--r--peripheral/libupm/examples/c++/apa102.cxx51
-rw-r--r--peripheral/libupm/examples/c++/apds9002.cxx2
-rw-r--r--peripheral/libupm/examples/c++/apds9930.cxx2
-rw-r--r--peripheral/libupm/examples/c++/at42qt1070.cxx2
-rw-r--r--peripheral/libupm/examples/c++/biss0001.cxx2
-rw-r--r--peripheral/libupm/examples/c++/bma220.cxx2
-rw-r--r--peripheral/libupm/examples/c++/bma250e.cxx83
-rw-r--r--peripheral/libupm/examples/c++/bmc150.cxx82
-rw-r--r--peripheral/libupm/examples/c++/bme280.cxx78
-rw-r--r--peripheral/libupm/examples/c++/bmg160.cxx83
-rw-r--r--peripheral/libupm/examples/c++/bmi055.cxx82
-rw-r--r--peripheral/libupm/examples/c++/bmi160.cxx82
-rw-r--r--peripheral/libupm/examples/c++/bmm150.cxx78
-rw-r--r--peripheral/libupm/examples/c++/bmp280.cxx77
-rw-r--r--peripheral/libupm/examples/c++/bmpx8x.cxx2
-rw-r--r--peripheral/libupm/examples/c++/bmx055.cxx89
-rw-r--r--peripheral/libupm/examples/c++/bno055.cxx129
-rw-r--r--peripheral/libupm/examples/c++/buzzer-sound.cxx2
-rw-r--r--peripheral/libupm/examples/c++/cjq4435.cxx2
-rw-r--r--peripheral/libupm/examples/c++/co2-sensor.cxx71
-rw-r--r--peripheral/libupm/examples/c++/curieimu.cxx81
-rw-r--r--peripheral/libupm/examples/c++/cwlsxxa.cxx82
-rw-r--r--peripheral/libupm/examples/c++/dfrph.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ds1307.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ds1808lc.cxx51
-rw-r--r--peripheral/libupm/examples/c++/ds18b20.cxx81
-rw-r--r--peripheral/libupm/examples/c++/ds2413.cxx59
-rw-r--r--peripheral/libupm/examples/c++/e50hx.cxx112
-rw-r--r--peripheral/libupm/examples/c++/eboled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ecs1030.cxx2
-rw-r--r--peripheral/libupm/examples/c++/enc03r.cxx2
-rw-r--r--peripheral/libupm/examples/c++/es08a.cxx2
-rw-r--r--peripheral/libupm/examples/c++/flex.cxx2
-rw-r--r--peripheral/libupm/examples/c++/gp2y0a.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovebutton.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovecircularled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovecollision.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveehr.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveeldriver.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveelectromagnet.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveemg.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovegprs.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovegsr.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveled-multi.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveledbar.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovelight.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovelinefinder.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovemd-stepper.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovemd.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovemoisture.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveo2.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groverelay.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groverotary.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovescam.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveslide.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovespeaker.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovetemp.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveultrasonic.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovevdiv.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovewater.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovewfs.cxx2
-rw-r--r--peripheral/libupm/examples/c++/guvas12d.cxx2
-rw-r--r--peripheral/libupm/examples/c++/h3lis331dl.cxx2
-rw-r--r--peripheral/libupm/examples/c++/h803x.cxx149
-rw-r--r--peripheral/libupm/examples/c++/hcsr04.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hdxxvxta.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hlg150h.cxx51
-rw-r--r--peripheral/libupm/examples/c++/hm11.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hmc5883l.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hmtrp.cxx4
-rw-r--r--peripheral/libupm/examples/c++/hp20x.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ht9170.cxx2
-rw-r--r--peripheral/libupm/examples/c++/htu21d.cxx2
-rw-r--r--peripheral/libupm/examples/c++/humidity-sensor.cxx83
-rw-r--r--peripheral/libupm/examples/c++/hwxpxx.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hx711.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ili9341.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ina132.cxx2
-rw-r--r--peripheral/libupm/examples/c++/isd1820.cxx2
-rw-r--r--peripheral/libupm/examples/c++/itg3200.cxx2
-rw-r--r--peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx2
-rw-r--r--peripheral/libupm/examples/c++/joystick12.cxx2
-rw-r--r--peripheral/libupm/examples/c++/kxcjk1013.cxx14
-rw-r--r--peripheral/libupm/examples/c++/l298-stepper.cxx2
-rw-r--r--peripheral/libupm/examples/c++/l298.cxx2
-rw-r--r--peripheral/libupm/examples/c++/l3gd20.cxx79
-rw-r--r--peripheral/libupm/examples/c++/lcm1602-i2c.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lcm1602-parallel.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ldt0028.cxx2
-rw-r--r--peripheral/libupm/examples/c++/light-controller.cxx98
-rw-r--r--peripheral/libupm/examples/c++/light-sensor.cxx78
-rw-r--r--peripheral/libupm/examples/c++/lm35.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lol.cxx2
-rw-r--r--peripheral/libupm/examples/c++/loudness.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lp8860.cxx52
-rw-r--r--peripheral/libupm/examples/c++/lpd8806.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lsm303.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lsm9ds0.cxx2
-rw-r--r--peripheral/libupm/examples/c++/m24lr64e.cxx2
-rw-r--r--peripheral/libupm/examples/c++/max31723.cxx2
-rw-r--r--peripheral/libupm/examples/c++/max31855.cxx2
-rw-r--r--peripheral/libupm/examples/c++/max44000.cxx2
-rw-r--r--peripheral/libupm/examples/c++/max44009.cxx46
-rw-r--r--peripheral/libupm/examples/c++/max5487.cxx2
-rw-r--r--peripheral/libupm/examples/c++/maxds3231m.cxx2
-rw-r--r--peripheral/libupm/examples/c++/maxsonarez.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mcp9808.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mg811.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mhz16.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mic.cxx2
-rw-r--r--peripheral/libupm/examples/c++/micsv89.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mlx90614.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mma7455.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mma7660.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpl3115a2.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpr121.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpu60x0.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpu9150.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpu9250.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq2.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq3.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq303a.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq4.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq5.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq6.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq7.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq8.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq9.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nlgpio16.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nrf24l01-receiver.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nrf8001-broadcast.cxx4
-rw-r--r--peripheral/libupm/examples/c++/nrf8001-broadcast.hpp (renamed from peripheral/libupm/examples/c++/nrf8001-broadcast.h)0
-rw-r--r--peripheral/libupm/examples/c++/nrf8001-helloworld.cxx4
-rw-r--r--peripheral/libupm/examples/c++/nrf8001-helloworld.hpp (renamed from peripheral/libupm/examples/c++/nrf8001-helloworld.h)0
-rw-r--r--peripheral/libupm/examples/c++/nunchuck.cxx2
-rw-r--r--peripheral/libupm/examples/c++/otp538u.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ozw.cxx2
-rw-r--r--peripheral/libupm/examples/c++/pca9685.cxx2
-rw-r--r--peripheral/libupm/examples/c++/pn532-writeurl.cxx2
-rw-r--r--peripheral/libupm/examples/c++/pn532.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ppd42ns.cxx2
-rw-r--r--peripheral/libupm/examples/c++/pressure-sensor.cxx81
-rw-r--r--peripheral/libupm/examples/c++/pulsensor.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rfr359f.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rgbringcoder.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rhusb.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rotaryencoder.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rpr220-intr.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rpr220.cxx2
-rw-r--r--peripheral/libupm/examples/c++/sainsmartks.cxx2
-rw-r--r--peripheral/libupm/examples/c++/si1132.cxx46
-rw-r--r--peripheral/libupm/examples/c++/si114x.cxx2
-rw-r--r--peripheral/libupm/examples/c++/si7005.cxx51
-rw-r--r--peripheral/libupm/examples/c++/sm130.cxx2
-rw-r--r--peripheral/libupm/examples/c++/smartdrive.cxx75
-rw-r--r--peripheral/libupm/examples/c++/ssd1306-oled.cxx4
-rw-r--r--peripheral/libupm/examples/c++/ssd1308-oled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ssd1327-oled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ssd1351.cxx2
-rw-r--r--peripheral/libupm/examples/c++/st7735.cxx2
-rw-r--r--peripheral/libupm/examples/c++/stepmotor.cxx2
-rw-r--r--peripheral/libupm/examples/c++/sx1276-fsk.cxx2
-rw-r--r--peripheral/libupm/examples/c++/sx1276-lora.cxx2
-rw-r--r--peripheral/libupm/examples/c++/sx6119.cxx2
-rw-r--r--peripheral/libupm/examples/c++/t3311.cxx2
-rw-r--r--peripheral/libupm/examples/c++/t6713.cxx48
-rw-r--r--peripheral/libupm/examples/c++/t8100.cxx117
-rw-r--r--peripheral/libupm/examples/c++/ta12200.cxx2
-rw-r--r--peripheral/libupm/examples/c++/tb7300.cxx124
-rw-r--r--peripheral/libupm/examples/c++/tcs3414cs.cxx2
-rw-r--r--peripheral/libupm/examples/c++/teams.cxx84
-rw-r--r--peripheral/libupm/examples/c++/temperature-sensor.cxx90
-rw-r--r--peripheral/libupm/examples/c++/tex00.cxx91
-rw-r--r--peripheral/libupm/examples/c++/th02.cxx2
-rw-r--r--peripheral/libupm/examples/c++/tm1637.cxx2
-rw-r--r--peripheral/libupm/examples/c++/tp401.cxx2
-rw-r--r--peripheral/libupm/examples/c++/tsl2561.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ttp223.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ublox6.cxx4
-rw-r--r--peripheral/libupm/examples/c++/uln200xa.cxx2
-rw-r--r--peripheral/libupm/examples/c++/urm37-uart.cxx2
-rw-r--r--peripheral/libupm/examples/c++/urm37.cxx2
-rw-r--r--peripheral/libupm/examples/c++/vcap.cxx70
-rw-r--r--peripheral/libupm/examples/c++/waterlevel.cxx2
-rw-r--r--peripheral/libupm/examples/c++/wheelencoder.cxx2
-rw-r--r--peripheral/libupm/examples/c++/wt5001.cxx2
-rw-r--r--peripheral/libupm/examples/c++/xbee.cxx2
-rw-r--r--peripheral/libupm/examples/c++/yg1006.cxx2
-rw-r--r--peripheral/libupm/examples/c++/zfm20-register.cxx2
-rw-r--r--peripheral/libupm/examples/c++/zfm20.cxx2
-rw-r--r--peripheral/libupm/examples/java/AM2315Example.java66
-rw-r--r--peripheral/libupm/examples/java/APA102Sample.java44
-rw-r--r--peripheral/libupm/examples/java/Ad8232Example.java14
-rw-r--r--peripheral/libupm/examples/java/Apds9002.java2
-rw-r--r--peripheral/libupm/examples/java/BMA250E_Example.java64
-rw-r--r--peripheral/libupm/examples/java/BMC150_Example.java61
-rw-r--r--peripheral/libupm/examples/java/BME280_Example.java69
-rw-r--r--peripheral/libupm/examples/java/BMG160_Example.java64
-rw-r--r--peripheral/libupm/examples/java/BMI055_Example.java61
-rw-r--r--peripheral/libupm/examples/java/BMI160_Example.java78
-rw-r--r--peripheral/libupm/examples/java/BMM150_Example.java58
-rw-r--r--peripheral/libupm/examples/java/BMP280_Example.java65
-rw-r--r--peripheral/libupm/examples/java/BMX055_Example.java69
-rw-r--r--peripheral/libupm/examples/java/BNO055_Example.java99
-rw-r--r--peripheral/libupm/examples/java/CMakeLists.txt49
-rw-r--r--peripheral/libupm/examples/java/CWLSXXA_Example.java62
-rw-r--r--peripheral/libupm/examples/java/E50HX_Example.java91
-rw-r--r--peripheral/libupm/examples/java/ECS1030Example.java52
-rw-r--r--peripheral/libupm/examples/java/Gp2y0aExample.java2
-rw-r--r--peripheral/libupm/examples/java/GroveEmg.java2
-rw-r--r--peripheral/libupm/examples/java/GroveGsr.java2
-rw-r--r--peripheral/libupm/examples/java/GroveO2Example.java2
-rw-r--r--peripheral/libupm/examples/java/H803X_Example.java123
-rw-r--r--peripheral/libupm/examples/java/HP20xExample.java2
-rw-r--r--peripheral/libupm/examples/java/MAX31855Example.java56
-rw-r--r--peripheral/libupm/examples/java/MAX5487Example.java71
-rw-r--r--peripheral/libupm/examples/java/MAXds3231mExample.java79
-rw-r--r--peripheral/libupm/examples/java/SM130Example.java69
-rw-r--r--peripheral/libupm/examples/java/T8100_Example.java97
-rw-r--r--peripheral/libupm/examples/java/TB7300_Example.java99
-rw-r--r--peripheral/libupm/examples/java/TEAMS_Example.java64
-rw-r--r--peripheral/libupm/examples/java/TEX00_Example.java71
-rw-r--r--peripheral/libupm/examples/java/Th02Example.java14
-rw-r--r--peripheral/libupm/examples/java/Tsl2561.java61
-rw-r--r--peripheral/libupm/examples/java/VCAP_Example.java60
-rw-r--r--peripheral/libupm/examples/java/WaterLevelSensor.java2
-rw-r--r--peripheral/libupm/examples/javascript/apa102.js44
-rw-r--r--peripheral/libupm/examples/javascript/bma250e.js72
-rw-r--r--peripheral/libupm/examples/javascript/bmc150.js69
-rw-r--r--peripheral/libupm/examples/javascript/bme280.js71
-rw-r--r--peripheral/libupm/examples/javascript/bmg160.js72
-rw-r--r--peripheral/libupm/examples/javascript/bmi055.js69
-rw-r--r--peripheral/libupm/examples/javascript/bmi160.js71
-rw-r--r--peripheral/libupm/examples/javascript/bmm150.js65
-rw-r--r--peripheral/libupm/examples/javascript/bmp280.js67
-rw-r--r--peripheral/libupm/examples/javascript/bmx055.js76
-rw-r--r--peripheral/libupm/examples/javascript/bno055.js117
-rw-r--r--peripheral/libupm/examples/javascript/curieimu.js52
-rw-r--r--peripheral/libupm/examples/javascript/cwlsxxa.js66
-rw-r--r--peripheral/libupm/examples/javascript/ds18b20.js70
-rw-r--r--peripheral/libupm/examples/javascript/ds2413.js55
-rw-r--r--peripheral/libupm/examples/javascript/e50hx.js101
-rw-r--r--peripheral/libupm/examples/javascript/h803x.js115
-rw-r--r--peripheral/libupm/examples/javascript/hmtrp.js2
-rw-r--r--peripheral/libupm/examples/javascript/oled_ssd1306.js2
-rw-r--r--peripheral/libupm/examples/javascript/t8100.js98
-rw-r--r--peripheral/libupm/examples/javascript/tb7300.js102
-rw-r--r--peripheral/libupm/examples/javascript/teams.js70
-rw-r--r--peripheral/libupm/examples/javascript/tex00.js77
-rw-r--r--peripheral/libupm/examples/javascript/ublox6.js2
-rw-r--r--peripheral/libupm/examples/javascript/vcap.js69
-rw-r--r--peripheral/libupm/examples/python/apa102.py48
-rw-r--r--peripheral/libupm/examples/python/bma250e.py66
-rw-r--r--peripheral/libupm/examples/python/bmc150.py65
-rw-r--r--peripheral/libupm/examples/python/bme280.py60
-rw-r--r--peripheral/libupm/examples/python/bmg160.py66
-rw-r--r--peripheral/libupm/examples/python/bmi055.py65
-rw-r--r--peripheral/libupm/examples/python/bmi160.py66
-rw-r--r--peripheral/libupm/examples/python/bmm150.py62
-rw-r--r--peripheral/libupm/examples/python/bmp280.py58
-rw-r--r--peripheral/libupm/examples/python/bmx055.py71
-rw-r--r--peripheral/libupm/examples/python/bno055.py105
-rw-r--r--peripheral/libupm/examples/python/curieimu.py56
-rw-r--r--peripheral/libupm/examples/python/cwlsxxa.py61
-rw-r--r--peripheral/libupm/examples/python/ds18b20.py64
-rw-r--r--peripheral/libupm/examples/python/ds2413.py57
-rw-r--r--peripheral/libupm/examples/python/e50hx.py95
-rw-r--r--peripheral/libupm/examples/python/h803x.py106
-rw-r--r--peripheral/libupm/examples/python/hmtrp.py2
-rw-r--r--peripheral/libupm/examples/python/t8100.py97
-rw-r--r--peripheral/libupm/examples/python/tb7300.py96
-rw-r--r--peripheral/libupm/examples/python/teams.py65
-rw-r--r--peripheral/libupm/examples/python/tex00.py65
-rw-r--r--peripheral/libupm/examples/python/ublox6.py2
-rw-r--r--peripheral/libupm/examples/python/vcap.py67
293 files changed, 8408 insertions, 226 deletions
diff --git a/peripheral/libupm/examples/c++/CMakeLists.txt b/peripheral/libupm/examples/c++/CMakeLists.txt
index b227703..ed367b3 100644
--- a/peripheral/libupm/examples/c++/CMakeLists.txt
+++ b/peripheral/libupm/examples/c++/CMakeLists.txt
@@ -234,12 +234,44 @@ if (MODBUS_FOUND)
include_directories(${MODBUS_INCLUDE_DIRS})
add_example (t3311)
add_example (hwxpxx)
+ add_example (h803x)
endif()
add_example (hdxxvxta)
add_example (rhusb)
add_example (apds9930)
add_example (kxcjk1013)
add_example (ssd1351)
+add_example (ds1808lc)
+add_example (hlg150h)
+add_example (lp8860)
+add_example (max44009)
+add_example (si1132)
+add_example (si7005)
+add_example (t6713)
+add_example (cwlsxxa)
+add_example (teams)
+add_example (apa102)
+add_example (tex00)
+add_example (bmi160)
+add_example (smartdrive)
+if (HAVE_FIRMATA)
+ add_example (curieimu)
+endif ()
+if (BACNET_FOUND)
+ include_directories(${BACNET_INCLUDE_DIRS})
+ # we need access to bacnetmstp headers too
+ include_directories(${PROJECT_SOURCE_DIR}/src/bacnetmstp)
+ add_example (e50hx)
+ add_example (t8100)
+ add_example (tb7300)
+endif()
+add_example (vcap)
+add_example (ds2413)
+add_example (ds18b20)
+add_example (bmp280)
+add_example (bno055)
+add_example (l3gd20)
+add_example (bmx055)
# These are special cases where you specify example binary, source file and module(s)
include_directories (${PROJECT_SOURCE_DIR}/src)
@@ -258,3 +290,16 @@ add_custom_example (ak8975-example ak8975.cxx mpu9150)
add_custom_example (mpu9250-example mpu9250.cxx mpu9150)
add_custom_example (groveledbar-example groveledbar.cxx my9221)
add_custom_example (grovecircularled-example grovecircularled.cxx my9221)
+add_custom_example (temperature-sensor-example temperature-sensor.cxx "si7005;bmpx8x;bme280")
+add_custom_example (humidity-sensor-example humidity-sensor.cxx "si7005;bme280")
+add_custom_example (pressure-sensor-example pressure-sensor.cxx "bmpx8x;bme280")
+add_custom_example (co2-sensor-example co2-sensor.cxx "t6713")
+add_custom_example (adc-example adc-sensor.cxx "ads1x15")
+add_custom_example (light-sensor-example light-sensor.cxx "si1132;max44009")
+add_custom_example (light-controller-example light-controller.cxx "lp8860;ds1808lc;hlg150h")
+add_custom_example (bme280-example bme280.cxx bmp280)
+add_custom_example (bma250e-example bma250e.cxx bmx055)
+add_custom_example (bmg160-example bmg160.cxx bmx055)
+add_custom_example (bmm150-example bmm150.cxx bmx055)
+add_custom_example (bmc150-example bmc150.cxx bmx055)
+add_custom_example (bmi055-example bmi055.cxx bmx055)
diff --git a/peripheral/libupm/examples/c++/a110x-intr.cxx b/peripheral/libupm/examples/c++/a110x-intr.cxx
index 187c2ed..93b2a49 100644
--- a/peripheral/libupm/examples/c++/a110x-intr.cxx
+++ b/peripheral/libupm/examples/c++/a110x-intr.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "a110x.h"
+#include "a110x.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/a110x.cxx b/peripheral/libupm/examples/c++/a110x.cxx
index 30c355d..0344ac3 100644
--- a/peripheral/libupm/examples/c++/a110x.cxx
+++ b/peripheral/libupm/examples/c++/a110x.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "a110x.h"
+#include "a110x.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ad8232.cxx b/peripheral/libupm/examples/c++/ad8232.cxx
index 5d03527..c07094b 100644
--- a/peripheral/libupm/examples/c++/ad8232.cxx
+++ b/peripheral/libupm/examples/c++/ad8232.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ad8232.h"
+#include "ad8232.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx b/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx
index 1bcf75b..41a5f88 100644
--- a/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx
+++ b/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "adafruitms1438.h"
+#include "adafruitms1438.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/adafruitms1438.cxx b/peripheral/libupm/examples/c++/adafruitms1438.cxx
index 8ca184c..1a94e17 100644
--- a/peripheral/libupm/examples/c++/adafruitms1438.cxx
+++ b/peripheral/libupm/examples/c++/adafruitms1438.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "adafruitms1438.h"
+#include "adafruitms1438.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/adafruitss.cxx b/peripheral/libupm/examples/c++/adafruitss.cxx
index f2a7ebf..7e9f68d 100644
--- a/peripheral/libupm/examples/c++/adafruitss.cxx
+++ b/peripheral/libupm/examples/c++/adafruitss.cxx
@@ -33,7 +33,7 @@
*/
#include <iostream>
-#include "adafruitss.h"
+#include "adafruitss.hpp"
#include <unistd.h>
using namespace std;
diff --git a/peripheral/libupm/examples/c++/adc-sensor.cxx b/peripheral/libupm/examples/c++/adc-sensor.cxx
new file mode 100644
index 0000000..b367086
--- /dev/null
+++ b/peripheral/libupm/examples/c++/adc-sensor.cxx
@@ -0,0 +1,80 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "ads1015.hpp"
+#include "mraa/gpio.hpp"
+
+#define EDISON_I2C_BUS 1
+#define FT4222_I2C_BUS 0
+#define EDISON_GPIO_SI7005_CS 20
+
+
+//! [Interesting]
+// Simple example of using IADC to determine
+// which sensor is present and return its name.
+// IADC is then used to get readings from sensor
+
+
+upm::IADC* getADC()
+{
+ upm::IADC* adc = NULL;
+ try {
+ adc = new upm::ADS1015(EDISON_I2C_BUS);
+ mraa::Gpio gpio(EDISON_GPIO_SI7005_CS);
+ gpio.dir(mraa::DIR_OUT_HIGH);
+ return adc;
+ } catch (std::exception& e) {
+ std::cerr << "ADS1015: " << e.what() << std::endl;
+ }
+ return adc;
+}
+
+int main ()
+{
+ upm::IADC* adc = getADC();
+ if (adc == NULL) {
+ std::cout << "ADC not detected" << std::endl;
+ return 1;
+ }
+ std::cout << "ADC " << adc->getModuleName() << " detected. " ;
+ std::cout << adc->getNumInputs() << " inputs available" << std::endl;
+ while (true) {
+ for (unsigned int i=0; i<adc->getNumInputs(); ++i) {
+ std::cout << "Input " << i;
+ try {
+ float voltage = adc->getVoltage(i);
+ std::cout << ": Voltage = " << voltage << "V" << std::endl;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ }
+ sleep(1);
+ }
+ delete adc;
+ return 0;
+}
+
+//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/adc121c021.cxx b/peripheral/libupm/examples/c++/adc121c021.cxx
index 18288ad..7a86c18 100644
--- a/peripheral/libupm/examples/c++/adc121c021.cxx
+++ b/peripheral/libupm/examples/c++/adc121c021.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "adc121c021.h"
+#include "adc121c021.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ads1x15.cxx b/peripheral/libupm/examples/c++/ads1x15.cxx
index 3c5da65..d4196cd 100644
--- a/peripheral/libupm/examples/c++/ads1x15.cxx
+++ b/peripheral/libupm/examples/c++/ads1x15.cxx
@@ -26,8 +26,8 @@
#include <iostream>
#include <unistd.h>
-#include "ads1015.h"
-#include "ads1115.h"
+#include "ads1015.hpp"
+#include "ads1115.hpp"
@@ -286,7 +286,7 @@ int main()
else ads->setCompMode();
break;
case 18:
- cout << ads->getCompLatch() << cout;
+ cout << ads->getCompLatch() << endl;
break;
case 19:
cout << "select one of the following:" << endl;
@@ -296,7 +296,7 @@ int main()
else ads->setCompLatch();
break;
case 20:
- cout << ads->getContinuous() << cout;
+ cout << ads->getContinuous() << endl;
break;
case 21:
cout << "select one of the following:" << endl;
diff --git a/peripheral/libupm/examples/c++/adxl335.cxx b/peripheral/libupm/examples/c++/adxl335.cxx
index 471695d..8152012 100644
--- a/peripheral/libupm/examples/c++/adxl335.cxx
+++ b/peripheral/libupm/examples/c++/adxl335.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "adxl335.h"
+#include "adxl335.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/adxl345.cxx b/peripheral/libupm/examples/c++/adxl345.cxx
index a5bc2cc..851bc77 100644
--- a/peripheral/libupm/examples/c++/adxl345.cxx
+++ b/peripheral/libupm/examples/c++/adxl345.cxx
@@ -23,7 +23,7 @@
*/
#include <unistd.h>
-#include "adxl345.h"
+#include "adxl345.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/adxrs610.cxx b/peripheral/libupm/examples/c++/adxrs610.cxx
index 4ec53ef..f24ccd5 100644
--- a/peripheral/libupm/examples/c++/adxrs610.cxx
+++ b/peripheral/libupm/examples/c++/adxrs610.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "adxrs610.h"
+#include "adxrs610.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ak8975.cxx b/peripheral/libupm/examples/c++/ak8975.cxx
index 1b95ead..c2f8607 100644
--- a/peripheral/libupm/examples/c++/ak8975.cxx
+++ b/peripheral/libupm/examples/c++/ak8975.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mpu9150.h"
+#include "mpu9150.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/am2315.cxx b/peripheral/libupm/examples/c++/am2315.cxx
index 4b95e1c..56f27cc 100644
--- a/peripheral/libupm/examples/c++/am2315.cxx
+++ b/peripheral/libupm/examples/c++/am2315.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "am2315.h"
+#include "am2315.hpp"
volatile int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/apa102.cxx b/peripheral/libupm/examples/c++/apa102.cxx
new file mode 100644
index 0000000..01aa963
--- /dev/null
+++ b/peripheral/libupm/examples/c++/apa102.cxx
@@ -0,0 +1,51 @@
+/*
+ * Author: Yannick Adam <yannick.adam@gmail.com>
+ * Copyright (c) 2016 Yannick Adam
+ *
+ * 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.
+ */
+
+#include "apa102.hpp"
+#include <iostream>
+#include <signal.h>
+#include <unistd.h>
+
+using namespace std;
+
+int
+main(int argc, char** argv)
+{
+ //! [Interesting]
+ // Instantiate a strip of 30 LEDs on SPI bus 0
+ upm::APA102* ledStrip = new upm::APA102(800, 0);
+
+ // Set all LEDs to Red
+ ledStrip->setAllLeds(31, 255, 0, 0);
+
+ // Set a section (10 to 20) to blue
+ ledStrip->setLeds(10, 20, 31, 0, 0, 255);
+
+ // Set a single LED to green
+ ledStrip->setLed(15, 31, 0, 255, 0);
+
+ delete ledStrip;
+ //! [Interesting]
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/apds9002.cxx b/peripheral/libupm/examples/c++/apds9002.cxx
index 87b5070..345f53a 100644
--- a/peripheral/libupm/examples/c++/apds9002.cxx
+++ b/peripheral/libupm/examples/c++/apds9002.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "apds9002.h"
+#include "apds9002.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/apds9930.cxx b/peripheral/libupm/examples/c++/apds9930.cxx
index 8d461c9..6da24a9 100644
--- a/peripheral/libupm/examples/c++/apds9930.cxx
+++ b/peripheral/libupm/examples/c++/apds9930.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "apds9930.h"
+#include "apds9930.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/at42qt1070.cxx b/peripheral/libupm/examples/c++/at42qt1070.cxx
index c22a998..b198649 100644
--- a/peripheral/libupm/examples/c++/at42qt1070.cxx
+++ b/peripheral/libupm/examples/c++/at42qt1070.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "at42qt1070.h"
+#include "at42qt1070.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/biss0001.cxx b/peripheral/libupm/examples/c++/biss0001.cxx
index 1574c2f..2468804 100644
--- a/peripheral/libupm/examples/c++/biss0001.cxx
+++ b/peripheral/libupm/examples/c++/biss0001.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "biss0001.h"
+#include "biss0001.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/bma220.cxx b/peripheral/libupm/examples/c++/bma220.cxx
index a41b81a..9701510 100644
--- a/peripheral/libupm/examples/c++/bma220.cxx
+++ b/peripheral/libupm/examples/c++/bma220.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "bma220.h"
+#include "bma220.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/bma250e.cxx b/peripheral/libupm/examples/c++/bma250e.cxx
new file mode 100644
index 0000000..0391617
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bma250e.cxx
@@ -0,0 +1,83 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+#include "bma250e.hpp"
+
+using namespace std;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate an BMA250E using default I2C parameters
+ upm::BMA250E *sensor = new upm::BMA250E();
+
+ // For SPI, bus 0, you would pass -1 as the address, and a valid pin
+ // for CS: BMA250E(0, -1, 10);
+
+ // now output data every 250 milliseconds
+ while (shouldRun)
+ {
+ float x, y, z;
+
+ sensor->update();
+
+ sensor->getAccelerometer(&x, &y, &z);
+ cout << "Accelerometer x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " g"
+ << endl;
+
+ // we show both C and F for temperature
+ cout << "Compensation Temperature: " << sensor->getTemperature()
+ << " C / " << sensor->getTemperature(true) << " F"
+ << endl;
+
+ cout << endl;
+
+ usleep(250000);
+ }
+
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/bmc150.cxx b/peripheral/libupm/examples/c++/bmc150.cxx
new file mode 100644
index 0000000..4600643
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bmc150.cxx
@@ -0,0 +1,82 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+#include "bmc150.hpp"
+
+using namespace std;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate an BMC150 using default I2C parameters
+ upm::BMC150 *sensor = new upm::BMC150();
+
+ // now output data every 250 milliseconds
+ while (shouldRun)
+ {
+ float x, y, z;
+
+ sensor->update();
+
+ sensor->getAccelerometer(&x, &y, &z);
+ cout << "Accelerometer x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " g"
+ << endl;
+
+ sensor->getMagnetometer(&x, &y, &z);
+ cout << "Magnetometer x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " uT"
+ << endl;
+
+ cout << endl;
+
+ usleep(250000);
+ }
+
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/bme280.cxx b/peripheral/libupm/examples/c++/bme280.cxx
new file mode 100644
index 0000000..12df7a9
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bme280.cxx
@@ -0,0 +1,78 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "bme280.hpp"
+
+using namespace std;
+using namespace upm;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate a BME280 instance using default i2c bus and address
+ upm::BME280 *sensor = new upm::BME280();
+
+ // For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+ // BME280(0, -1, 10);
+
+ while (shouldRun)
+ {
+ // update our values from the sensor
+ sensor->update();
+
+ // we show both C and F for temperature
+ cout << "Compensation Temperature: " << sensor->getTemperature()
+ << " C / " << sensor->getTemperature(true) << " F"
+ << endl;
+ cout << "Pressure: " << sensor->getPressure() << " Pa" << endl;
+ cout << "Computed Altitude: " << sensor->getAltitude() << " m" << endl;
+ cout << "Humidity: " << sensor->getHumidity() << " %RH" << endl;
+
+ cout << endl;
+
+ sleep(1);
+ }
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/bmg160.cxx b/peripheral/libupm/examples/c++/bmg160.cxx
new file mode 100644
index 0000000..c305b27
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bmg160.cxx
@@ -0,0 +1,83 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+#include "bmg160.hpp"
+
+using namespace std;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate an BMG160 using default I2C parameters
+ upm::BMG160 *sensor = new upm::BMG160();
+
+ // For SPI, bus 0, you would pass -1 as the address, and a valid pin
+ // for CS: BMG160(0, -1, 10);
+
+ // now output data every 250 milliseconds
+ while (shouldRun)
+ {
+ float x, y, z;
+
+ sensor->update();
+
+ sensor->getGyroscope(&x, &y, &z);
+ cout << "Gyroscope x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " degrees/s"
+ << endl;
+
+ // we show both C and F for temperature
+ cout << "Compensation Temperature: " << sensor->getTemperature()
+ << " C / " << sensor->getTemperature(true) << " F"
+ << endl;
+
+ cout << endl;
+
+ usleep(250000);
+ }
+
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/bmi055.cxx b/peripheral/libupm/examples/c++/bmi055.cxx
new file mode 100644
index 0000000..e88fe16
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bmi055.cxx
@@ -0,0 +1,82 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+#include "bmi055.hpp"
+
+using namespace std;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate an BMI055 using default I2C parameters
+ upm::BMI055 *sensor = new upm::BMI055();
+
+ // now output data every 250 milliseconds
+ while (shouldRun)
+ {
+ float x, y, z;
+
+ sensor->update();
+
+ sensor->getAccelerometer(&x, &y, &z);
+ cout << "Accelerometer x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " g"
+ << endl;
+
+ sensor->getGyroscope(&x, &y, &z);
+ cout << "Gyroscope x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " degrees/s"
+ << endl;
+
+ cout << endl;
+
+ usleep(250000);
+ }
+
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/bmi160.cxx b/peripheral/libupm/examples/c++/bmi160.cxx
new file mode 100644
index 0000000..6f98556
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bmi160.cxx
@@ -0,0 +1,82 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+#include "bmi160.hpp"
+
+using namespace std;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate a BMI160 instance using default i2c bus and address
+ upm::BMI160 *sensor = new upm::BMI160();
+
+ while (shouldRun)
+ {
+ // update our values from the sensor
+ sensor->update();
+
+ float dataX, dataY, dataZ;
+
+ sensor->getAccelerometer(&dataX, &dataY, &dataZ);
+ cout << "Accelerometer: ";
+ cout << "AX: " << dataX << " AY: " << dataY << " AZ: "
+ << dataZ << endl;
+
+ sensor->getGyroscope(&dataX, &dataY, &dataZ);
+ cout << "Gryoscope: ";
+ cout << "GX: " << dataX << " GY: " << dataY << " GZ: "
+ << dataZ << endl;
+
+ sensor->getMagnetometer(&dataX, &dataY, &dataZ);
+ cout << "Magnetometer: ";
+ cout << "MX: " << dataX << " MY: " << dataY << " MZ: "
+ << dataZ << endl;
+
+ cout << endl;
+
+ usleep(500000);
+ }
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/bmm150.cxx b/peripheral/libupm/examples/c++/bmm150.cxx
new file mode 100644
index 0000000..400f1a9
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bmm150.cxx
@@ -0,0 +1,78 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+#include "bmm150.hpp"
+
+using namespace std;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate an BMM150 using default I2C parameters
+ upm::BMM150 *sensor = new upm::BMM150();
+
+ // For SPI, bus 0, you would pass -1 as the address, and a valid pin
+ // for CS: BMM150(0, -1, 10);
+
+ // now output data every 250 milliseconds
+ while (shouldRun)
+ {
+ float x, y, z;
+
+ sensor->update();
+
+ sensor->getMagnetometer(&x, &y, &z);
+ cout << "Magnetometer x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " uT"
+ << endl;
+
+ cout << endl;
+
+ usleep(250000);
+ }
+
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/bmp280.cxx b/peripheral/libupm/examples/c++/bmp280.cxx
new file mode 100644
index 0000000..101159e
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bmp280.cxx
@@ -0,0 +1,77 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "bmp280.hpp"
+
+using namespace std;
+using namespace upm;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate a BMP280 instance using default i2c bus and address
+ upm::BMP280 *sensor = new upm::BMP280();
+
+ // For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+ // BMP280(0, -1, 10);
+
+ while (shouldRun)
+ {
+ // update our values from the sensor
+ sensor->update();
+
+ // we show both C and F for temperature
+ cout << "Compensation Temperature: " << sensor->getTemperature()
+ << " C / " << sensor->getTemperature(true) << " F"
+ << endl;
+ cout << "Pressure: " << sensor->getPressure() << " Pa" << endl;
+ cout << "Computed Altitude: " << sensor->getAltitude() << " m" << endl;
+
+ cout << endl;
+
+ sleep(1);
+ }
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/bmpx8x.cxx b/peripheral/libupm/examples/c++/bmpx8x.cxx
index 28e5be8..f4ebf7d 100644
--- a/peripheral/libupm/examples/c++/bmpx8x.cxx
+++ b/peripheral/libupm/examples/c++/bmpx8x.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "bmpx8x.h"
+#include "bmpx8x.hpp"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/bmx055.cxx b/peripheral/libupm/examples/c++/bmx055.cxx
new file mode 100644
index 0000000..31626f4
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bmx055.cxx
@@ -0,0 +1,89 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+#include "bmx055.hpp"
+
+using namespace std;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate an BMX055 using default I2C parameters
+ upm::BMX055 *sensor = new upm::BMX055();
+
+ // now output data every 250 milliseconds
+ while (shouldRun)
+ {
+ float x, y, z;
+
+ sensor->update();
+
+ sensor->getAccelerometer(&x, &y, &z);
+ cout << "Accelerometer x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " g"
+ << endl;
+
+ sensor->getGyroscope(&x, &y, &z);
+ cout << "Gyroscope x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " degrees/s"
+ << endl;
+
+ sensor->getMagnetometer(&x, &y, &z);
+ cout << "Magnetometer x: " << x
+ << " y: " << y
+ << " z: " << z
+ << " uT"
+ << endl;
+
+ cout << endl;
+
+ usleep(250000);
+ }
+
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/bno055.cxx b/peripheral/libupm/examples/c++/bno055.cxx
new file mode 100644
index 0000000..b46999e
--- /dev/null
+++ b/peripheral/libupm/examples/c++/bno055.cxx
@@ -0,0 +1,129 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+#include "bno055.hpp"
+
+using namespace std;
+
+int shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+//! [Interesting]
+
+ // Instantiate an BNO055 using default parameters (bus 0, addr
+ // 0x28). The default running mode is NDOF absolute orientation
+ // mode.
+ upm::BNO055 *sensor = new upm::BNO055();
+
+ // First we need to calibrate....
+ cout << "First we need to calibrate. 4 numbers will be output every"
+ << endl;
+ cout << "second for each sensor. 0 means uncalibrated, and 3 means"
+ << endl;
+ cout << "fully calibrated."
+ << endl;
+ cout << "See the UPM documentation on this sensor for instructions on"
+ << endl;
+ cout << "what actions are required to calibrate."
+ << endl;
+ cout << endl;
+
+ // do the calibration...
+ while (shouldRun && !sensor->isFullyCalibrated())
+ {
+ int mag, acc, gyr, sys;
+ sensor->getCalibrationStatus(&mag, &acc, &gyr, &sys);
+
+ cout << "Magnetometer: " << mag
+ << " Accelerometer: " << acc
+ << " Gyroscope: " << gyr
+ << " System: " << sys
+ << endl;
+
+ sleep(1);
+ }
+
+ cout << endl;
+ cout << "Calibration complete." << endl;
+ cout << endl;
+
+ // now output various fusion data every 250 milliseconds
+ while (shouldRun)
+ {
+ float w, x, y, z;
+
+ sensor->update();
+
+ sensor->getEulerAngles(&x, &y, &z);
+ cout << "Euler: Heading: " << x
+ << " Roll: " << y
+ << " Pitch: " << z
+ << " degrees"
+ << endl;
+
+ sensor->getQuaternions(&w, &x, &y, &z);
+ cout << "Quaternion: W: " << w
+ << " X: " << x
+ << " Y: " << y
+ << " Z: " << z
+ << endl;
+
+ sensor->getLinearAcceleration(&x, &y, &z);
+ cout << "Linear Acceleration: X: " << x
+ << " Y: " << y
+ << " Z: " << z
+ << " m/s^2"
+ << endl;
+
+ sensor->getGravityVectors(&x, &y, &z);
+ cout << "Gravity Vector: X: " << x
+ << " Y: " << y
+ << " Z: " << z
+ << " m/s^2"
+ << endl;
+
+ cout << endl;
+ usleep(250000);
+ }
+
+//! [Interesting]
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/buzzer-sound.cxx b/peripheral/libupm/examples/c++/buzzer-sound.cxx
index 1d377ba..604904a 100644
--- a/peripheral/libupm/examples/c++/buzzer-sound.cxx
+++ b/peripheral/libupm/examples/c++/buzzer-sound.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "buzzer.h"
+#include "buzzer.hpp"
int
diff --git a/peripheral/libupm/examples/c++/cjq4435.cxx b/peripheral/libupm/examples/c++/cjq4435.cxx
index f9d84d4..79d3495 100644
--- a/peripheral/libupm/examples/c++/cjq4435.cxx
+++ b/peripheral/libupm/examples/c++/cjq4435.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "cjq4435.h"
+#include "cjq4435.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/co2-sensor.cxx b/peripheral/libupm/examples/c++/co2-sensor.cxx
new file mode 100644
index 0000000..da978ad
--- /dev/null
+++ b/peripheral/libupm/examples/c++/co2-sensor.cxx
@@ -0,0 +1,71 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "t6713.hpp"
+
+#define EDISON_I2C_BUS 1
+#define FT4222_I2C_BUS 0
+
+//! [Interesting]
+// Simple example of using ICO2Sensor to determine
+// which sensor is present and return its name.
+// ICO2Sensor is then used to get readings from sensor
+
+
+upm::ICO2Sensor* getCO2Sensor()
+{
+ upm::ICO2Sensor* cO2Sensor = NULL;
+ try {
+ cO2Sensor = new upm::T6713(mraa_get_sub_platform_id(FT4222_I2C_BUS));
+ return cO2Sensor;
+ } catch (std::exception& e) {
+ std::cerr << "T6713: " << e.what() << std::endl;
+ }
+ return cO2Sensor;
+}
+
+int main ()
+{
+ upm::ICO2Sensor* cO2Sensor = getCO2Sensor();
+ if (cO2Sensor == NULL) {
+ std::cout << "CO2 sensor not detected" << std::endl;
+ return 1;
+ }
+ std::cout << "CO2 sensor " << cO2Sensor->getModuleName() << " detected" << std::endl;
+ while (true) {
+ try {
+ uint16_t value = cO2Sensor->getPpm();
+ std::cout << "CO2 level = " << value << " ppm" << std::endl;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ sleep(1);
+ }
+ delete cO2Sensor;
+ return 0;
+}
+
+//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/curieimu.cxx b/peripheral/libupm/examples/c++/curieimu.cxx
new file mode 100644
index 0000000..c9ff3e6
--- /dev/null
+++ b/peripheral/libupm/examples/c++/curieimu.cxx
@@ -0,0 +1,81 @@
+/*
+ * Author: Brendan Le Foll <brendan.le.foll@intel.com>
+ * Author: Ron Evans (@deadprogram)
+ * Author: Justin Zemlyansky (@JustInDevelopment)
+ * 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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "curieimu.hpp"
+#include "mraa.h"
+#include "mraa/firmata.h"
+#include <math.h>
+
+int
+main(int argc, char **argv)
+{
+ //! [Interesting]
+ mraa_init();
+ mraa_add_subplatform(MRAA_GENERIC_FIRMATA, "/dev/ttyACM0");
+
+ upm::CurieImu* sensor = new upm::CurieImu();
+
+ std::cout << "temperature is: " << (sensor->getTemperature() * pow(0.5, 9) + 23) << std::endl;
+
+ sensor->updateAccel();
+ int x = sensor->getAccelX(),
+ y = sensor->getAccelY(),
+ z = sensor->getAccelZ();
+ printf("accelerometer is: %d, %d, %d\n", x, y, z);
+
+ sensor->updateGyro();
+ int a = sensor->getGyroX(),
+ b = sensor->getGyroY(),
+ c = sensor->getGyroZ();
+ printf("gyroscope is: %d, %d, %d\n", a, b, c);
+
+ int axis, direction;
+ sensor->enableShockDetection(true);
+ for(int i=0; i<300; i++) {
+ if (sensor->isShockDetected()) {
+ sensor->getNextShock();
+ axis = sensor->getAxis();
+ direction = sensor->getDirection();
+ printf("shock data is: %d, %d\n", axis, direction);
+ }
+ usleep(10000);
+ }
+
+ sensor->updateMotion();
+ int m = sensor->getAccelX(),
+ n = sensor->getAccelY(),
+ o = sensor->getAccelZ(),
+ p = sensor->getGyroX(),
+ q = sensor->getGyroY(),
+ r = sensor->getGyroZ();
+ printf("motion is: %d, %d, %d, %d, %d, %d\n", m, n, o, p, q, r);
+
+ delete sensor;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/cwlsxxa.cxx b/peripheral/libupm/examples/c++/cwlsxxa.cxx
new file mode 100644
index 0000000..b96c85e
--- /dev/null
+++ b/peripheral/libupm/examples/c++/cwlsxxa.cxx
@@ -0,0 +1,82 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "cwlsxxa.hpp"
+
+using namespace std;
+
+bool shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+
+//! [Interesting]
+
+ cout << "Initializing..." << endl;
+
+ // Instantiate an CWLSXXA instance, using A0 for CO2, A1 for
+ // humidity and A2 for temperature
+ upm::CWLSXXA *sensor = new upm::CWLSXXA(0, 1, 2);
+
+ // update and print available values every second
+ while (shouldRun)
+ {
+ // update our values from the sensor
+ sensor->update();
+
+ // we show both C and F for temperature
+ cout << "Temperature: " << sensor->getTemperature()
+ << " C / " << sensor->getTemperature(true) << " F"
+ << endl;
+
+ cout << "Humidity: " << sensor->getHumidity()
+ << " %" << endl;
+
+ cout << "CO2: " << sensor->getCO2()
+ << " ppm" << endl;
+
+ cout << endl;
+
+ sleep(1);
+ }
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+//! [Interesting]
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/dfrph.cxx b/peripheral/libupm/examples/c++/dfrph.cxx
index 601fdbf..22d3db5 100644
--- a/peripheral/libupm/examples/c++/dfrph.cxx
+++ b/peripheral/libupm/examples/c++/dfrph.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "dfrph.h"
+#include "dfrph.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ds1307.cxx b/peripheral/libupm/examples/c++/ds1307.cxx
index 44a0b08..0cb0793 100644
--- a/peripheral/libupm/examples/c++/ds1307.cxx
+++ b/peripheral/libupm/examples/c++/ds1307.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "ds1307.h"
+#include "ds1307.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ds1808lc.cxx b/peripheral/libupm/examples/c++/ds1808lc.cxx
new file mode 100644
index 0000000..33e655e
--- /dev/null
+++ b/peripheral/libupm/examples/c++/ds1808lc.cxx
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+#include <string>
+#include "ds1808lc.hpp"
+
+#define EDISON_I2C_BUS 1 // Edison I2C-1
+#define DS1808_GPIO_PWR 15 // Edison GP165
+
+void printState(upm::ILightController *lightController)
+{
+ if (lightController->isPowered())
+ {
+ std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
+ }
+ else
+ {
+ std::cout << "Light is not powered." << std::endl;
+ }
+}
+
+int main( int argc, char **argv )
+{
+ int status = 0;
+ upm::ILightController* lightController;
+
+ try {
+ lightController = new upm::DS1808LC(DS1808_GPIO_PWR, EDISON_I2C_BUS);
+ std::cout << "Existing state: "; printState(lightController);
+ if (argc == 2)
+ {
+ std::string arg = argv[1];
+ int brightness = ::atoi(argv[1]);
+ if (brightness > 0) {
+ lightController->setPowerOn();
+ lightController->setBrightness(brightness);
+ } else
+ lightController->setPowerOff();
+ }
+ std::cout << "Now: ";printState(lightController);
+ } catch (std::exception& e) {
+ std::cout << "Error: " << e.what() << std::endl;
+ status = 1;
+ }
+
+ delete lightController;
+ return status;
+}
+
+
diff --git a/peripheral/libupm/examples/c++/ds18b20.cxx b/peripheral/libupm/examples/c++/ds18b20.cxx
new file mode 100644
index 0000000..f1eaa8c
--- /dev/null
+++ b/peripheral/libupm/examples/c++/ds18b20.cxx
@@ -0,0 +1,81 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "ds18b20.hpp"
+
+using namespace std;
+
+bool shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+
+//! [Interesting]
+
+ cout << "Initializing..." << endl;
+
+ // Instantiate an DS18B20 instance using the default values (uart 0)
+ upm::DS18B20 sensor;
+
+ // locate and setup our devices
+ sensor.init();
+
+ cout << "Found " << sensor.devicesFound() << " device(s)" << endl;
+ cout << endl;
+
+ // bail if we didn't find anything
+ if (!sensor.devicesFound())
+ return 1;
+
+ // update and print available values every second
+ while (shouldRun)
+ {
+ // update our values for the first sensor
+ sensor.update(0);
+
+ // we show both C and F for temperature for the first sensor
+ cout << "Temperature: " << sensor.getTemperature(0)
+ << " C / " << sensor.getTemperature(0, true) << " F"
+ << endl;
+
+ sleep(1);
+ }
+
+ cout << "Exiting..." << endl;
+
+//! [Interesting]
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/ds2413.cxx b/peripheral/libupm/examples/c++/ds2413.cxx
new file mode 100644
index 0000000..04fdcb6
--- /dev/null
+++ b/peripheral/libupm/examples/c++/ds2413.cxx
@@ -0,0 +1,59 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <stdio.h>
+#include "ds2413.hpp"
+
+using namespace std;
+using namespace upm;
+
+int main(int argc, char **argv)
+{
+//! [Interesting]
+ // Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
+ upm::DS2413* sensor = new upm::DS2413(0);
+
+ // find all of the DS2413 devices present on the bus
+ sensor->init();
+
+ // how many devices were found?
+ cout << "Found "<< sensor->devicesFound() << " device(s)" << endl;
+
+ // read the gpio and latch values from the first device
+ // the lower 4 bits are of the form:
+ // <gpioB latch> <gpioB value> <gpioA latch> <gpioA value>
+ cout << "GPIO device 0 values: " << sensor->readGpios(0) << endl;
+
+ // set the gpio latch values of the first device
+ cout << "Setting GPIO latches to on" << endl;
+ sensor->writeGpios(0, 0x03);
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+//! [Interesting]
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/e50hx.cxx b/peripheral/libupm/examples/c++/e50hx.cxx
new file mode 100644
index 0000000..253e089
--- /dev/null
+++ b/peripheral/libupm/examples/c++/e50hx.cxx
@@ -0,0 +1,112 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "e50hx.hpp"
+
+using namespace std;
+using namespace upm;
+
+bool shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+
+//! [Interesting]
+ // You will need to edit this example to conform to your site and your
+ // devices, specifically the Device Object Instance ID passed to the
+ // constructor, and the arguments to initMaster() that are
+ // appropriate for your BACnet network.
+
+ string defaultDev = "/dev/ttyUSB0";
+
+ // if an argument was specified, use it as the device instead
+ if (argc > 1)
+ defaultDev = string(argv[1]);
+
+ cout << "Using device " << defaultDev << endl;
+ cout << "Initializing..." << endl;
+
+ // Instantiate an E50HX object for an E50HX device that has 1075425
+ // as it's unique Device Object Instance ID. NOTE: You will
+ // certainly want to change this to the correct value for your
+ // device(s).
+ E50HX *sensor = new E50HX(1075425);
+
+ // Initialize our BACnet master, if it has not already been
+ // initialized, with the device and baudrate, choosing 1000001 as
+ // our unique Device Object Instance ID, 2 as our MAC address and
+ // using default values for maxMaster and maxInfoFrames
+ sensor->initMaster(defaultDev, 38400, 1000001, 2);
+
+ // Uncomment to enable debugging output
+ // sensor->setDebug(true);
+
+ cout << endl;
+ cout << "Device Description: " << sensor->getDeviceDescription() << endl;
+ cout << "Device Location: " << sensor->getDeviceLocation() << endl;
+ cout << endl;
+
+ // update and print a few values every 5 seconds
+ while (shouldRun)
+ {
+ cout << "System Voltage: "
+ << sensor->getAnalogValue(E50HX::AV_System_Voltage)
+ << " " << sensor->getAnalogValueUnits(E50HX::AV_System_Voltage)
+ << endl;
+
+ cout << "System Type: "
+ << sensor->getAnalogValue(E50HX::AV_System_Type)
+ << endl;
+
+ cout << "Energy Consumption: " << sensor->getAnalogInput(E50HX::AI_Energy)
+ << " " << sensor->getAnalogInputUnits(E50HX::AI_Energy)
+ << endl;
+
+ cout << "Power Up Counter: "
+ << sensor->getAnalogInput(E50HX::AI_Power_Up_Count)
+ << endl;
+
+ cout << endl;
+ sleep(5);
+ }
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+//! [Interesting]
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/eboled.cxx b/peripheral/libupm/examples/c++/eboled.cxx
index c1c281c..0832537 100644
--- a/peripheral/libupm/examples/c++/eboled.cxx
+++ b/peripheral/libupm/examples/c++/eboled.cxx
@@ -23,7 +23,7 @@
*/
#include <iostream>
-#include "eboled.h"
+#include "eboled.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ecs1030.cxx b/peripheral/libupm/examples/c++/ecs1030.cxx
index 40a7dc5..ff87279 100644
--- a/peripheral/libupm/examples/c++/ecs1030.cxx
+++ b/peripheral/libupm/examples/c++/ecs1030.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdlib.h>
-#include "ecs1030.h"
+#include "ecs1030.hpp"
int is_running = 0;
upm::ECS1030 *sensor = NULL;
diff --git a/peripheral/libupm/examples/c++/enc03r.cxx b/peripheral/libupm/examples/c++/enc03r.cxx
index da0db9b..298d7cd 100644
--- a/peripheral/libupm/examples/c++/enc03r.cxx
+++ b/peripheral/libupm/examples/c++/enc03r.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "enc03r.h"
+#include "enc03r.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/es08a.cxx b/peripheral/libupm/examples/c++/es08a.cxx
index 3f7e5c4..c480012 100644
--- a/peripheral/libupm/examples/c++/es08a.cxx
+++ b/peripheral/libupm/examples/c++/es08a.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "es08a.h"
+#include "es08a.hpp"
#include <signal.h>
#include <stdlib.h>
diff --git a/peripheral/libupm/examples/c++/flex.cxx b/peripheral/libupm/examples/c++/flex.cxx
index 5477338..26cdcdd 100644
--- a/peripheral/libupm/examples/c++/flex.cxx
+++ b/peripheral/libupm/examples/c++/flex.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "flex.h"
+#include "flex.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/gp2y0a.cxx b/peripheral/libupm/examples/c++/gp2y0a.cxx
index 0111b17..1a6114b 100644
--- a/peripheral/libupm/examples/c++/gp2y0a.cxx
+++ b/peripheral/libupm/examples/c++/gp2y0a.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "gp2y0a.h"
+#include "gp2y0a.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovebutton.cxx b/peripheral/libupm/examples/c++/grovebutton.cxx
index 7d2d69a..3534d16 100644
--- a/peripheral/libupm/examples/c++/grovebutton.cxx
+++ b/peripheral/libupm/examples/c++/grovebutton.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "grove.h"
+#include "grove.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/grovecircularled.cxx b/peripheral/libupm/examples/c++/grovecircularled.cxx
index 066e017..54af0cf 100644
--- a/peripheral/libupm/examples/c++/grovecircularled.cxx
+++ b/peripheral/libupm/examples/c++/grovecircularled.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovecircularled.h"
+#include "grovecircularled.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovecollision.cxx b/peripheral/libupm/examples/c++/grovecollision.cxx
index 2de7609..e7ad0f8 100644
--- a/peripheral/libupm/examples/c++/grovecollision.cxx
+++ b/peripheral/libupm/examples/c++/grovecollision.cxx
@@ -24,7 +24,7 @@
#include <iostream>
#include <unistd.h>
#include <signal.h>
-#include "grovecollision.h"
+#include "grovecollision.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveehr.cxx b/peripheral/libupm/examples/c++/groveehr.cxx
index b056a15..7377560 100644
--- a/peripheral/libupm/examples/c++/groveehr.cxx
+++ b/peripheral/libupm/examples/c++/groveehr.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "groveehr.h"
+#include "groveehr.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveeldriver.cxx b/peripheral/libupm/examples/c++/groveeldriver.cxx
index 126eaaf..9c1d561 100644
--- a/peripheral/libupm/examples/c++/groveeldriver.cxx
+++ b/peripheral/libupm/examples/c++/groveeldriver.cxx
@@ -24,7 +24,7 @@
#include <iostream>
#include <unistd.h>
#include <signal.h>
-#include "groveeldriver.h"
+#include "groveeldriver.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveelectromagnet.cxx b/peripheral/libupm/examples/c++/groveelectromagnet.cxx
index 386f4de..bbd4d33 100644
--- a/peripheral/libupm/examples/c++/groveelectromagnet.cxx
+++ b/peripheral/libupm/examples/c++/groveelectromagnet.cxx
@@ -24,7 +24,7 @@
#include <iostream>
#include <time.h>
#include <signal.h>
-#include "groveelectromagnet.h"
+#include "groveelectromagnet.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveemg.cxx b/peripheral/libupm/examples/c++/groveemg.cxx
index d06295a..3a049dd 100644
--- a/peripheral/libupm/examples/c++/groveemg.cxx
+++ b/peripheral/libupm/examples/c++/groveemg.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "groveemg.h"
+#include "groveemg.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovegprs.cxx b/peripheral/libupm/examples/c++/grovegprs.cxx
index bc0e3d9..f882cba 100644
--- a/peripheral/libupm/examples/c++/grovegprs.cxx
+++ b/peripheral/libupm/examples/c++/grovegprs.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "grovegprs.h"
+#include "grovegprs.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/grovegsr.cxx b/peripheral/libupm/examples/c++/grovegsr.cxx
index 549e775..6068e79 100644
--- a/peripheral/libupm/examples/c++/grovegsr.cxx
+++ b/peripheral/libupm/examples/c++/grovegsr.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovegsr.h"
+#include "grovegsr.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveled-multi.cxx b/peripheral/libupm/examples/c++/groveled-multi.cxx
index 16a6eba..1a6f8eb 100644
--- a/peripheral/libupm/examples/c++/groveled-multi.cxx
+++ b/peripheral/libupm/examples/c++/groveled-multi.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grove.h"
+#include "grove.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveled.cxx b/peripheral/libupm/examples/c++/groveled.cxx
index 52d5e84..8f7e752 100644
--- a/peripheral/libupm/examples/c++/groveled.cxx
+++ b/peripheral/libupm/examples/c++/groveled.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
-#include "grove.h"
+#include "grove.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/groveledbar.cxx b/peripheral/libupm/examples/c++/groveledbar.cxx
index d86110c..bc51183 100644
--- a/peripheral/libupm/examples/c++/groveledbar.cxx
+++ b/peripheral/libupm/examples/c++/groveledbar.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "groveledbar.h"
+#include "groveledbar.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovelight.cxx b/peripheral/libupm/examples/c++/grovelight.cxx
index 64760c9..18f8f6c 100644
--- a/peripheral/libupm/examples/c++/grovelight.cxx
+++ b/peripheral/libupm/examples/c++/grovelight.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
-#include "grove.h"
+#include "grove.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/grovelinefinder.cxx b/peripheral/libupm/examples/c++/grovelinefinder.cxx
index a8290c5..53b1e6e 100644
--- a/peripheral/libupm/examples/c++/grovelinefinder.cxx
+++ b/peripheral/libupm/examples/c++/grovelinefinder.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovelinefinder.h"
+#include "grovelinefinder.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovemd-stepper.cxx b/peripheral/libupm/examples/c++/grovemd-stepper.cxx
index f65c5e4..ce189d2 100644
--- a/peripheral/libupm/examples/c++/grovemd-stepper.cxx
+++ b/peripheral/libupm/examples/c++/grovemd-stepper.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "grovemd.h"
+#include "grovemd.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovemd.cxx b/peripheral/libupm/examples/c++/grovemd.cxx
index a5c1015..87c3616 100644
--- a/peripheral/libupm/examples/c++/grovemd.cxx
+++ b/peripheral/libupm/examples/c++/grovemd.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "grovemd.h"
+#include "grovemd.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovemoisture.cxx b/peripheral/libupm/examples/c++/grovemoisture.cxx
index 1fee54c..f63a088 100644
--- a/peripheral/libupm/examples/c++/grovemoisture.cxx
+++ b/peripheral/libupm/examples/c++/grovemoisture.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovemoisture.h"
+#include "grovemoisture.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveo2.cxx b/peripheral/libupm/examples/c++/groveo2.cxx
index cc1b240..79741b5 100644
--- a/peripheral/libupm/examples/c++/groveo2.cxx
+++ b/peripheral/libupm/examples/c++/groveo2.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "groveo2.h"
+#include "groveo2.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groverelay.cxx b/peripheral/libupm/examples/c++/groverelay.cxx
index 4366dd6..9297139 100644
--- a/peripheral/libupm/examples/c++/groverelay.cxx
+++ b/peripheral/libupm/examples/c++/groverelay.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "grove.h"
+#include "grove.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/groverotary.cxx b/peripheral/libupm/examples/c++/groverotary.cxx
index 4139242..aa2ee57 100644
--- a/peripheral/libupm/examples/c++/groverotary.cxx
+++ b/peripheral/libupm/examples/c++/groverotary.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <iomanip>
-#include "grove.h"
+#include "grove.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovescam.cxx b/peripheral/libupm/examples/c++/grovescam.cxx
index 6edd85d..6592b33 100644
--- a/peripheral/libupm/examples/c++/grovescam.cxx
+++ b/peripheral/libupm/examples/c++/grovescam.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "grovescam.h"
+#include "grovescam.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/groveslide.cxx b/peripheral/libupm/examples/c++/groveslide.cxx
index 42e975a..04b8bb4 100644
--- a/peripheral/libupm/examples/c++/groveslide.cxx
+++ b/peripheral/libupm/examples/c++/groveslide.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <iostream>
#include <iomanip>
-#include "grove.h"
+#include "grove.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovespeaker.cxx b/peripheral/libupm/examples/c++/grovespeaker.cxx
index 97d6518..4e139e5 100644
--- a/peripheral/libupm/examples/c++/grovespeaker.cxx
+++ b/peripheral/libupm/examples/c++/grovespeaker.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovespeaker.h"
+#include "grovespeaker.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovetemp.cxx b/peripheral/libupm/examples/c++/grovetemp.cxx
index 73de9c7..2a21bc1 100644
--- a/peripheral/libupm/examples/c++/grovetemp.cxx
+++ b/peripheral/libupm/examples/c++/grovetemp.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <iostream>
#include <iomanip>
-#include "grove.h"
+#include "grove.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/groveultrasonic.cxx b/peripheral/libupm/examples/c++/groveultrasonic.cxx
index e054c4c..f23e8f4 100644
--- a/peripheral/libupm/examples/c++/groveultrasonic.cxx
+++ b/peripheral/libupm/examples/c++/groveultrasonic.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <iostream>
-#include "groveultrasonic.h"
+#include "groveultrasonic.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/grovevdiv.cxx b/peripheral/libupm/examples/c++/grovevdiv.cxx
index 40be66c..0f90333 100644
--- a/peripheral/libupm/examples/c++/grovevdiv.cxx
+++ b/peripheral/libupm/examples/c++/grovevdiv.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovevdiv.h"
+#include "grovevdiv.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovewater.cxx b/peripheral/libupm/examples/c++/grovewater.cxx
index 51bfacb..e13f8e7 100644
--- a/peripheral/libupm/examples/c++/grovewater.cxx
+++ b/peripheral/libupm/examples/c++/grovewater.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovewater.h"
+#include "grovewater.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovewfs.cxx b/peripheral/libupm/examples/c++/grovewfs.cxx
index ea819ae..b92ff17 100644
--- a/peripheral/libupm/examples/c++/grovewfs.cxx
+++ b/peripheral/libupm/examples/c++/grovewfs.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovewfs.h"
+#include "grovewfs.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/guvas12d.cxx b/peripheral/libupm/examples/c++/guvas12d.cxx
index 3351741..a0aa740 100644
--- a/peripheral/libupm/examples/c++/guvas12d.cxx
+++ b/peripheral/libupm/examples/c++/guvas12d.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "guvas12d.h"
+#include "guvas12d.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/h3lis331dl.cxx b/peripheral/libupm/examples/c++/h3lis331dl.cxx
index d4a04ca..714d29b 100644
--- a/peripheral/libupm/examples/c++/h3lis331dl.cxx
+++ b/peripheral/libupm/examples/c++/h3lis331dl.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "h3lis331dl.h"
+#include "h3lis331dl.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/h803x.cxx b/peripheral/libupm/examples/c++/h803x.cxx
new file mode 100644
index 0000000..4416439
--- /dev/null
+++ b/peripheral/libupm/examples/c++/h803x.cxx
@@ -0,0 +1,149 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "h803x.hpp"
+
+using namespace std;
+
+bool shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+
+//! [Interesting]
+
+ string defaultDev = "/dev/ttyUSB0";
+
+ // if an argument was specified, use it as the device instead
+ if (argc > 1)
+ defaultDev = string(argv[1]);
+
+ cout << "Using device " << defaultDev << endl;
+ cout << "Initializing..." << endl;
+
+ // Instantiate an H803X instance, using MODBUS slave address 1, and
+ // default comm parameters (9600, 8, N, 2)
+ upm::H803X *sensor = new upm::H803X(defaultDev, 1);
+
+ // output the Slave ID string
+ cout << "Slave ID: " << sensor->getSlaveID() << endl;
+ cout << endl;
+
+ // update and print available values every second
+ while (shouldRun)
+ {
+ // update our values from the sensor
+ sensor->update();
+
+ // H8035 / H8036
+ cout << "Consumption (kWh): " << sensor->getConsumption() << endl;
+ cout << "Real Power (kW): " << sensor->getRealPower() << endl;
+
+ if (sensor->isH8036())
+ {
+ // The H8036 has much more data available...
+
+ cout << "Reactive Power (kVAR): " << sensor->getReactivePower()
+ << endl;
+ cout << "Apparent Power (kVA): " << sensor->getApparentPower()
+ << endl;
+ cout << "Power Factor: " << sensor->getPowerFactor()
+ << endl;
+ cout << "Volts Line to Line: " << sensor->getVoltsLineToLine()
+ << endl;
+ cout << "Volts Line to Neutral: " << sensor->getVoltsLineToNeutral()
+ << endl;
+
+ cout << "Current: " << sensor->getCurrent()
+ << endl;
+
+ cout << "Real Power Phase A (kW): " << sensor->getRealPowerPhaseA()
+ << endl;
+ cout << "Real Power Phase B (kW): " << sensor->getRealPowerPhaseB()
+ << endl;
+ cout << "Real Power Phase C (kW): " << sensor->getRealPowerPhaseC()
+ << endl;
+
+ cout << "Power Factor Phase A: " << sensor->getPowerFactorPhaseA()
+ << endl;
+ cout << "Power Factor Phase B: " << sensor->getPowerFactorPhaseB()
+ << endl;
+ cout << "Power Factor Phase C: " << sensor->getPowerFactorPhaseC()
+ << endl;
+
+ cout << "Volts Phase A to B: " << sensor->getVoltsPhaseAToB()
+ << endl;
+ cout << "Volts Phase B to C: " << sensor->getVoltsPhaseBToC()
+ << endl;
+ cout << "Volts Phase A to C: " << sensor->getVoltsPhaseAToC()
+ << endl;
+ cout << "Volts Phase A to Neutral: "
+ << sensor->getVoltsPhaseAToNeutral()
+ << endl;
+ cout << "Volts Phase B to Neutral: "
+ << sensor->getVoltsPhaseBToNeutral()
+ << endl;
+ cout << "Volts Phase C to Neutral: "
+ << sensor->getVoltsPhaseCToNeutral()
+ << endl;
+
+ cout << "Current Phase A: " << sensor->getCurrentPhaseA()
+ << endl;
+ cout << "Current Phase B: " << sensor->getCurrentPhaseB()
+ << endl;
+ cout << "Current Phase C: " << sensor->getCurrentPhaseC()
+ << endl;
+
+ cout << "Avg Real Power (kW): " << sensor->getAvgRealPower()
+ << endl;
+ cout << "Min Real Power (kW): " << sensor->getMinRealPower()
+ << endl;
+ cout << "Max Real Power (kW): " << sensor->getMaxRealPower()
+ << endl;
+ }
+
+ cout << endl;
+
+ sleep(2);
+ }
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+//! [Interesting]
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/hcsr04.cxx b/peripheral/libupm/examples/c++/hcsr04.cxx
index c0a2725..472c293 100644
--- a/peripheral/libupm/examples/c++/hcsr04.cxx
+++ b/peripheral/libupm/examples/c++/hcsr04.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "hcsr04.h"
+#include "hcsr04.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/hdxxvxta.cxx b/peripheral/libupm/examples/c++/hdxxvxta.cxx
index 2a555f3..c258355 100644
--- a/peripheral/libupm/examples/c++/hdxxvxta.cxx
+++ b/peripheral/libupm/examples/c++/hdxxvxta.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "hdxxvxta.h"
+#include "hdxxvxta.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/hlg150h.cxx b/peripheral/libupm/examples/c++/hlg150h.cxx
new file mode 100644
index 0000000..b4efe33
--- /dev/null
+++ b/peripheral/libupm/examples/c++/hlg150h.cxx
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+#include <string>
+#include "hlg150h.hpp"
+
+#define HLG150H_GPIO_RELAY 21
+#define HLG150H_GPIO_PWM 22
+
+void printState(upm::ILightController *lightController)
+{
+ if (lightController->isPowered())
+ {
+ std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
+ }
+ else
+ {
+ std::cout << "Light is not powered." << std::endl;
+ }
+}
+
+int main( int argc, char **argv )
+{
+ int status = 0;
+ upm::ILightController* lightController;
+
+ try {
+ lightController = new upm::HLG150H(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
+ std::cout << "Existing state: "; printState(lightController);
+ if (argc == 2)
+ {
+ std::string arg = argv[1];
+ int brightness = ::atoi(argv[1]);
+ if (brightness > 0) {
+ lightController->setPowerOn();
+ lightController->setBrightness(brightness);
+ } else
+ lightController->setPowerOff();
+ }
+ std::cout << "Now: ";printState(lightController);
+ delete lightController;
+ } catch (std::exception& e) {
+ std::cout << "Error: " << e.what() << std::endl;
+ status = 1;
+ }
+
+ return status;
+}
+
+
diff --git a/peripheral/libupm/examples/c++/hm11.cxx b/peripheral/libupm/examples/c++/hm11.cxx
index e759804..61b25e5 100644
--- a/peripheral/libupm/examples/c++/hm11.cxx
+++ b/peripheral/libupm/examples/c++/hm11.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "hm11.h"
+#include "hm11.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/hmc5883l.cxx b/peripheral/libupm/examples/c++/hmc5883l.cxx
index dec08ce..7dbf700 100644
--- a/peripheral/libupm/examples/c++/hmc5883l.cxx
+++ b/peripheral/libupm/examples/c++/hmc5883l.cxx
@@ -24,7 +24,7 @@
*/
#include <unistd.h>
-#include "hmc5883l.h"
+#include "hmc5883l.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/hmtrp.cxx b/peripheral/libupm/examples/c++/hmtrp.cxx
index 3d58ba9..f711dd5 100644
--- a/peripheral/libupm/examples/c++/hmtrp.cxx
+++ b/peripheral/libupm/examples/c++/hmtrp.cxx
@@ -26,7 +26,7 @@
#include <string.h>
#include <iostream>
#include <signal.h>
-#include "hmtrp.h"
+#include "hmtrp.hpp"
using namespace std;
@@ -135,7 +135,7 @@ int main (int argc, char **argv)
if (rv > 0)
cout << "Received: " << radioBuffer << endl;
- if (rv < 0) // some sort of read error occured
+ if (rv < 0) // some sort of read error occurred
{
cerr << "Port read error." << endl;
break;
diff --git a/peripheral/libupm/examples/c++/hp20x.cxx b/peripheral/libupm/examples/c++/hp20x.cxx
index 119a449..ff7dd27 100644
--- a/peripheral/libupm/examples/c++/hp20x.cxx
+++ b/peripheral/libupm/examples/c++/hp20x.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "hp20x.h"
+#include "hp20x.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/ht9170.cxx b/peripheral/libupm/examples/c++/ht9170.cxx
index 1be72b6..299c82c 100644
--- a/peripheral/libupm/examples/c++/ht9170.cxx
+++ b/peripheral/libupm/examples/c++/ht9170.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "ht9170.h"
+#include "ht9170.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/htu21d.cxx b/peripheral/libupm/examples/c++/htu21d.cxx
index 63d6fdf..31cec0f 100644
--- a/peripheral/libupm/examples/c++/htu21d.cxx
+++ b/peripheral/libupm/examples/c++/htu21d.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "htu21d.h"
+#include "htu21d.hpp"
volatile int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/humidity-sensor.cxx b/peripheral/libupm/examples/c++/humidity-sensor.cxx
new file mode 100644
index 0000000..8bb7eb4
--- /dev/null
+++ b/peripheral/libupm/examples/c++/humidity-sensor.cxx
@@ -0,0 +1,83 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "si7005.hpp"
+#include "bme280.hpp"
+
+#define EDISON_I2C_BUS 1
+#define FT4222_I2C_BUS 0
+
+ #define EDISON_GPIO_SI7005_CS 20
+
+//! [Interesting]
+// Simple example of using ILightSensor to determine
+// which sensor is present and return its name.
+// ILightSensor is then used to get readings from sensor
+
+
+upm::IHumiditySensor* getHumiditySensor()
+{
+ upm::IHumiditySensor* humiditySensor = NULL;
+
+ try {
+ humiditySensor = new upm::BME280 (mraa_get_sub_platform_id(FT4222_I2C_BUS));
+ return humiditySensor ;
+ } catch (std::exception& e)
+ {
+ std::cerr <<"BME280: "<<e.what() << std::endl;
+ }
+
+ try {
+ humiditySensor = new upm::SI7005(EDISON_I2C_BUS, EDISON_GPIO_SI7005_CS);
+ return humiditySensor;
+ } catch (std::exception& e) {
+ std::cerr << "SI7005: " << e.what() << std::endl;
+ }
+ return humiditySensor;
+}
+
+int main ()
+{
+ upm::IHumiditySensor* humiditySensor = getHumiditySensor();
+ if (humiditySensor == NULL) {
+ std::cout << "Humidity sensor not detected" << std::endl;
+ return 1;
+ }
+ std::cout << "Humidity sensor " << humiditySensor->getModuleName() << " detected" << std::endl;
+ while (true) {
+ try {
+ int value = humiditySensor->getHumidityRelative();
+ std::cout << "Humidity = " << value << "%" << std::endl;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ sleep(1);
+ }
+ delete humiditySensor;
+ return 0;
+}
+
+//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/hwxpxx.cxx b/peripheral/libupm/examples/c++/hwxpxx.cxx
index 1cfdf54..c9d92bf 100644
--- a/peripheral/libupm/examples/c++/hwxpxx.cxx
+++ b/peripheral/libupm/examples/c++/hwxpxx.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "hwxpxx.h"
+#include "hwxpxx.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/hx711.cxx b/peripheral/libupm/examples/c++/hx711.cxx
index 531734b..e894ad8 100644
--- a/peripheral/libupm/examples/c++/hx711.cxx
+++ b/peripheral/libupm/examples/c++/hx711.cxx
@@ -26,7 +26,7 @@
#include <signal.h>
//! [Interesting]
-#include "hx711.h"
+#include "hx711.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/ili9341.cxx b/peripheral/libupm/examples/c++/ili9341.cxx
index 8fe397a..139615c 100644
--- a/peripheral/libupm/examples/c++/ili9341.cxx
+++ b/peripheral/libupm/examples/c++/ili9341.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
-#include "ili9341.h"
+#include "ili9341.hpp"
int main(int argc, char **argv) {
//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/ina132.cxx b/peripheral/libupm/examples/c++/ina132.cxx
index 0c78630..7bc6457 100644
--- a/peripheral/libupm/examples/c++/ina132.cxx
+++ b/peripheral/libupm/examples/c++/ina132.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ina132.h"
+#include "ina132.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/isd1820.cxx b/peripheral/libupm/examples/c++/isd1820.cxx
index 3246808..75d7798 100644
--- a/peripheral/libupm/examples/c++/isd1820.cxx
+++ b/peripheral/libupm/examples/c++/isd1820.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "isd1820.h"
+#include "isd1820.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/itg3200.cxx b/peripheral/libupm/examples/c++/itg3200.cxx
index a1bf8af..a313cb6 100644
--- a/peripheral/libupm/examples/c++/itg3200.cxx
+++ b/peripheral/libupm/examples/c++/itg3200.cxx
@@ -23,7 +23,7 @@
*/
#include <unistd.h>
-#include "itg3200.h"
+#include "itg3200.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx b/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx
index ca2f155..8e7ea03 100644
--- a/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx
+++ b/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "jhd1313m1.h"
+#include "jhd1313m1.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/joystick12.cxx b/peripheral/libupm/examples/c++/joystick12.cxx
index 408ca2a..9e9013b 100644
--- a/peripheral/libupm/examples/c++/joystick12.cxx
+++ b/peripheral/libupm/examples/c++/joystick12.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "joystick12.h"
+#include "joystick12.hpp"
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/kxcjk1013.cxx b/peripheral/libupm/examples/c++/kxcjk1013.cxx
index 3732dbd..7676785 100644
--- a/peripheral/libupm/examples/c++/kxcjk1013.cxx
+++ b/peripheral/libupm/examples/c++/kxcjk1013.cxx
@@ -1,6 +1,6 @@
/*
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
- * Copyright (c) 2015 Intel Corporation.
+ * 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
@@ -22,10 +22,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <unistd.h>
#include <iostream>
+#include <iomanip>
+#include <unistd.h>
#include <signal.h>
-#include "kxcjk1013.h"
+#include "kxcjk1013.hpp"
using namespace std;
@@ -44,8 +45,8 @@ data_callback(char* data)
{
float x, y, z;
accelerometer->extract3Axis(data, &x, &y, &z);
- printf("%.1f %.1f %.1f\n", x, y, z);
- // usleep(100);
+ cout << fixed << setprecision(1);
+ cout << x << '\t' << y << '\t' << z << "[m/s^2]" << endl;
}
int
@@ -55,7 +56,10 @@ main()
//! [Interesting]
// Instantiate a KXCJK1013 Accelerometer Sensor on iio device 0
accelerometer = new upm::KXCJK1013(0);
+ // Available scales are 0.009582(2g), 0.019163(4g), and 0.038326(8g)
accelerometer->setScale(0.019163);
+ // Available sampling frequency are 0.781000, 1.563000, 3.125000, 6.250000, 12.500000, 25, 50,
+ // 100, 200, 400, 800, and 1600
accelerometer->setSamplingFrequency(25.0);
accelerometer->enable3AxisChannel();
accelerometer->installISR(data_callback, NULL);
diff --git a/peripheral/libupm/examples/c++/l298-stepper.cxx b/peripheral/libupm/examples/c++/l298-stepper.cxx
index 8fe2b91..8436175 100644
--- a/peripheral/libupm/examples/c++/l298-stepper.cxx
+++ b/peripheral/libupm/examples/c++/l298-stepper.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "l298.h"
+#include "l298.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/l298.cxx b/peripheral/libupm/examples/c++/l298.cxx
index 8e360b2..ff972ee 100644
--- a/peripheral/libupm/examples/c++/l298.cxx
+++ b/peripheral/libupm/examples/c++/l298.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "l298.h"
+#include "l298.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/l3gd20.cxx b/peripheral/libupm/examples/c++/l3gd20.cxx
new file mode 100644
index 0000000..2795686
--- /dev/null
+++ b/peripheral/libupm/examples/c++/l3gd20.cxx
@@ -0,0 +1,79 @@
+/*
+ * Author: Lay, Kuan Loon <kuan.loon.lay@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.
+ */
+
+#include <iostream>
+#include <iomanip>
+#include <unistd.h>
+#include <signal.h>
+#include "l3gd20.hpp"
+
+using namespace std;
+
+int shouldRun = true;
+upm::L3GD20* gyroscope;
+
+void
+sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+void
+data_callback(char* data)
+{
+ float x, y, z;
+ if (gyroscope->extract3Axis(data, &x, &y, &z)) {
+ cout << fixed << setprecision(1);
+ cout << x << '\t' << y << '\t' << z << "[rad/sec]" << endl;
+ }
+}
+
+int
+main()
+{
+ signal(SIGINT, sig_handler);
+ //! [Interesting]
+ // Instantiate a L3GD20 Gyroscope Sensor on iio device 3
+ gyroscope = new upm::L3GD20(3);
+ // Available scales are 0.000153(250dps), 0.000305(500dps), and 0.001222(2000dps)
+ gyroscope->setScale(0.001222);
+ // Available sampling frequency are 95, 190, 380, and 760
+ gyroscope->setSamplingFrequency(95.0);
+ gyroscope->enable3AxisChannel();
+ gyroscope->installISR(data_callback, NULL);
+ gyroscope->enableBuffer(16);
+
+ while (shouldRun) {
+ sleep(1);
+ }
+ gyroscope->disableBuffer();
+
+ //! [Interesting]
+ cout << "Exiting" << endl;
+
+ delete gyroscope;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/lcm1602-i2c.cxx b/peripheral/libupm/examples/c++/lcm1602-i2c.cxx
index f405f96..66ae8f2 100644
--- a/peripheral/libupm/examples/c++/lcm1602-i2c.cxx
+++ b/peripheral/libupm/examples/c++/lcm1602-i2c.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "lcm1602.h"
+#include "lcm1602.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/lcm1602-parallel.cxx b/peripheral/libupm/examples/c++/lcm1602-parallel.cxx
index 642c6af..d85ab06 100644
--- a/peripheral/libupm/examples/c++/lcm1602-parallel.cxx
+++ b/peripheral/libupm/examples/c++/lcm1602-parallel.cxx
@@ -23,7 +23,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <lcm1602.h>
+#include <lcm1602.hpp>
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/ldt0028.cxx b/peripheral/libupm/examples/c++/ldt0028.cxx
index 8d9c8b7..baaac11 100644
--- a/peripheral/libupm/examples/c++/ldt0028.cxx
+++ b/peripheral/libupm/examples/c++/ldt0028.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <iomanip>
#include <cmath>
-#include "ldt0028.h"
+#include "ldt0028.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/light-controller.cxx b/peripheral/libupm/examples/c++/light-controller.cxx
new file mode 100644
index 0000000..5c734d6
--- /dev/null
+++ b/peripheral/libupm/examples/c++/light-controller.cxx
@@ -0,0 +1,98 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+#include <string>
+#include "lp8860.hpp"
+#include "ds1808lc.hpp"
+#include "hlg150h.hpp"
+
+#define EDISON_I2C_BUS 1 // Edison I2C-1
+#define GPIO_SI7005_CS 20 // Edison GP12
+#define HLG150H_GPIO_RELAY 21
+#define HLG150H_GPIO_PWM 22
+#define LP8860_GPIO_PWR 45 // Edison GP45
+#define DS1808_GPIO_PWR 15 // Edison GP165
+#define DS1808_GPIO_EDISON_LIVE 36 // Edison GP14
+
+//! [Interesting]
+// Simple example of using ILightController to determine
+// which controller is present and return its name.
+// ILightController is then used to get readings from sensor
+
+upm::ILightController* getLightController()
+{
+ upm::ILightController* lightController = NULL;
+ try {
+ lightController = new upm::LP8860(LP8860_GPIO_PWR, EDISON_I2C_BUS);
+ return lightController;
+ } catch (std::exception& e) {
+ std::cerr << "LP8860: " << e.what() << std::endl;
+ }
+ try {
+ lightController = new upm::DS1808LC(DS1808_GPIO_PWR, EDISON_I2C_BUS);
+ return lightController;
+ } catch (std::exception& e) {
+ std::cerr << "DS1808LC: " << e.what() << std::endl;
+ }
+ try {
+ lightController = new upm::HLG150H(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
+ return lightController;
+ } catch (std::exception& e) {
+ std::cerr << "HLG150H: " << e.what() << std::endl;
+ }
+ return lightController;
+}
+
+
+void printState(upm::ILightController *lightController)
+{
+ if (lightController->isPowered())
+ {
+ std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
+ }
+ else
+ {
+ std::cout << "Light is not powered." << std::endl;
+ }
+}
+
+int main( int argc, char **argv )
+{
+ int status = 0;
+ // MraaUtils::setGpio(GPIO_SI7005_CS, 1);
+
+ upm::ILightController *lightController = getLightController();
+ if (lightController != NULL)
+ {
+ std::cout << "Detected light controller " << lightController->getModuleName() << std::endl;
+ }
+ else
+ {
+ std::cerr << "Error. Unsupported platform." << std::endl;
+ return 1;
+ }
+
+ try {
+ std::cout << "Existing state: "; printState(lightController);
+ if (argc == 2)
+ {
+ std::string arg = argv[1];
+ int brightness = ::atoi(argv[1]);
+ if (brightness > 0) {
+ lightController->setPowerOn();
+ lightController->setBrightness(brightness);
+ } else
+ lightController->setPowerOff();
+ }
+ std::cout << "Now: ";printState(lightController);
+ } catch (std::exception& e) {
+ std::cout << "Error: " << e.what() << std::endl;
+ status = 1;
+ }
+
+ delete lightController;
+ return status;
+}
+
+
diff --git a/peripheral/libupm/examples/c++/light-sensor.cxx b/peripheral/libupm/examples/c++/light-sensor.cxx
new file mode 100644
index 0000000..c4b87ea
--- /dev/null
+++ b/peripheral/libupm/examples/c++/light-sensor.cxx
@@ -0,0 +1,78 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "max44009.hpp"
+#include "si1132.hpp"
+
+#define EDISON_I2C_BUS 1
+#define FT4222_I2C_BUS 0
+
+//! [Interesting]
+// Simple example of using ILightSensor to determine
+// which sensor is present and return its name.
+// ILightSensor is then used to get readings from sensor
+
+
+upm::ILightSensor* getLightSensor()
+{
+ upm::ILightSensor* lightSensor = NULL;
+ try {
+ lightSensor = new upm::SI1132(mraa_get_sub_platform_id(FT4222_I2C_BUS));
+ return lightSensor;
+ } catch (std::exception& e) {
+ std::cerr << "SI1132: " << e.what() << std::endl;
+ }
+ try {
+ lightSensor = new upm::MAX44009(EDISON_I2C_BUS);
+ return lightSensor;
+ } catch (std::exception& e) {
+ std::cerr << "MAX44009: " << e.what() << std::endl;
+ }
+ return lightSensor;
+}
+
+int main ()
+{
+ upm::ILightSensor* lightSensor = getLightSensor();
+ if (lightSensor == NULL) {
+ std::cout << "Light sensor not detected" << std::endl;
+ return 1;
+ }
+ std::cout << "Light sensor " << lightSensor->getModuleName() << " detected" << std::endl;
+ while (true) {
+ try {
+ float value = lightSensor->getVisibleLux();
+ std::cout << "Light level = " << value << " lux" << std::endl;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ sleep(1);
+ }
+ delete lightSensor;
+ return 0;
+}
+
+//! [Interesting] \ No newline at end of file
diff --git a/peripheral/libupm/examples/c++/lm35.cxx b/peripheral/libupm/examples/c++/lm35.cxx
index 8930940..abdfd91 100644
--- a/peripheral/libupm/examples/c++/lm35.cxx
+++ b/peripheral/libupm/examples/c++/lm35.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "lm35.h"
+#include "lm35.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/lol.cxx b/peripheral/libupm/examples/c++/lol.cxx
index 9f2943d..9cf71bd 100644
--- a/peripheral/libupm/examples/c++/lol.cxx
+++ b/peripheral/libupm/examples/c++/lol.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "lol.h"
+#include "lol.hpp"
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/loudness.cxx b/peripheral/libupm/examples/c++/loudness.cxx
index 44e62b0..9eaa59b 100644
--- a/peripheral/libupm/examples/c++/loudness.cxx
+++ b/peripheral/libupm/examples/c++/loudness.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "loudness.h"
+#include "loudness.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/lp8860.cxx b/peripheral/libupm/examples/c++/lp8860.cxx
new file mode 100644
index 0000000..81d8629
--- /dev/null
+++ b/peripheral/libupm/examples/c++/lp8860.cxx
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+#include <string>
+#include "lp8860.hpp"
+
+#define EDISON_I2C_BUS 1 // Edison I2C-1
+#define LP8860_GPIO_PWR 45 // Edison GP45
+
+
+void printState(upm::ILightController *lightController)
+{
+ if (lightController->isPowered())
+ {
+ std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
+ }
+ else
+ {
+ std::cout << "Light is not powered." << std::endl;
+ }
+}
+
+int main( int argc, char **argv )
+{
+ int status = 0;
+ upm::LP8860* lightController;
+
+ try {
+ lightController = new upm::LP8860(LP8860_GPIO_PWR, EDISON_I2C_BUS);
+ std::cout << "Existing state: "; printState(lightController);
+ if (argc == 2)
+ {
+ std::string arg = argv[1];
+ int brightness = ::atoi(argv[1]);
+ if (brightness > 0) {
+ lightController->setPowerOn();
+ lightController->setBrightness(brightness);
+ } else
+ lightController->setPowerOff();
+ }
+ std::cout << "Now: ";printState(lightController);
+ delete lightController;
+ } catch (std::exception& e) {
+ std::cout << "Error: " << e.what() << std::endl;
+ status = 1;
+ }
+
+ return status;
+}
+
+
diff --git a/peripheral/libupm/examples/c++/lpd8806.cxx b/peripheral/libupm/examples/c++/lpd8806.cxx
index 8828f07..bc1e17f 100644
--- a/peripheral/libupm/examples/c++/lpd8806.cxx
+++ b/peripheral/libupm/examples/c++/lpd8806.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "lpd8806.h"
+#include "lpd8806.hpp"
#include <signal.h>
void scanner(uint8_t r, uint8_t g, uint8_t b, uint8_t wait);
diff --git a/peripheral/libupm/examples/c++/lsm303.cxx b/peripheral/libupm/examples/c++/lsm303.cxx
index f75fd5b..94e9b7b 100644
--- a/peripheral/libupm/examples/c++/lsm303.cxx
+++ b/peripheral/libupm/examples/c++/lsm303.cxx
@@ -25,7 +25,7 @@
#include <iostream>
//! [Interesting]
-#include "lsm303.h"
+#include "lsm303.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/lsm9ds0.cxx b/peripheral/libupm/examples/c++/lsm9ds0.cxx
index 66644a0..655e02c 100644
--- a/peripheral/libupm/examples/c++/lsm9ds0.cxx
+++ b/peripheral/libupm/examples/c++/lsm9ds0.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "lsm9ds0.h"
+#include "lsm9ds0.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/m24lr64e.cxx b/peripheral/libupm/examples/c++/m24lr64e.cxx
index 6c3aae0..63b186f 100644
--- a/peripheral/libupm/examples/c++/m24lr64e.cxx
+++ b/peripheral/libupm/examples/c++/m24lr64e.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "m24lr64e.h"
+#include "m24lr64e.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/max31723.cxx b/peripheral/libupm/examples/c++/max31723.cxx
index 96082af..4b98310 100644
--- a/peripheral/libupm/examples/c++/max31723.cxx
+++ b/peripheral/libupm/examples/c++/max31723.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "max31723.h"
+#include "max31723.hpp"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/max31855.cxx b/peripheral/libupm/examples/c++/max31855.cxx
index 2390d93..6e72998 100644
--- a/peripheral/libupm/examples/c++/max31855.cxx
+++ b/peripheral/libupm/examples/c++/max31855.cxx
@@ -27,7 +27,7 @@
#include <signal.h>
//! [Interesting]
-#include "max31855.h"
+#include "max31855.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/max44000.cxx b/peripheral/libupm/examples/c++/max44000.cxx
index 404f544..c344bdf 100644
--- a/peripheral/libupm/examples/c++/max44000.cxx
+++ b/peripheral/libupm/examples/c++/max44000.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "max44000.h"
+#include "max44000.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/max44009.cxx b/peripheral/libupm/examples/c++/max44009.cxx
new file mode 100644
index 0000000..bf911cb
--- /dev/null
+++ b/peripheral/libupm/examples/c++/max44009.cxx
@@ -0,0 +1,46 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "max44009.hpp"
+
+#define EDISON_I2C_BUS 1
+
+int main ()
+{
+ try {
+ upm::MAX44009* lightSensor = new upm::MAX44009(EDISON_I2C_BUS);
+ while (true) {
+ float value = lightSensor->getVisibleLux();
+ std::cout << "Light level = " << value << " lux" << std::endl;
+ sleep(1);
+ }
+ delete lightSensor;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ return 1;
+ }
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/max5487.cxx b/peripheral/libupm/examples/c++/max5487.cxx
index 661be05..a13223a 100644
--- a/peripheral/libupm/examples/c++/max5487.cxx
+++ b/peripheral/libupm/examples/c++/max5487.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "max5487.h"
+#include "max5487.hpp"
#include <signal.h>
upm::MAX5487 *sensor = NULL;
diff --git a/peripheral/libupm/examples/c++/maxds3231m.cxx b/peripheral/libupm/examples/c++/maxds3231m.cxx
index e5a6fc1..ef5f95f 100644
--- a/peripheral/libupm/examples/c++/maxds3231m.cxx
+++ b/peripheral/libupm/examples/c++/maxds3231m.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "maxds3231m.h"
+#include "maxds3231m.hpp"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/maxsonarez.cxx b/peripheral/libupm/examples/c++/maxsonarez.cxx
index 3c3d300..5ffb5c1 100644
--- a/peripheral/libupm/examples/c++/maxsonarez.cxx
+++ b/peripheral/libupm/examples/c++/maxsonarez.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "maxsonarez.h"
+#include "maxsonarez.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mcp9808.cxx b/peripheral/libupm/examples/c++/mcp9808.cxx
index ba4e5e4..32076da 100644
--- a/peripheral/libupm/examples/c++/mcp9808.cxx
+++ b/peripheral/libupm/examples/c++/mcp9808.cxx
@@ -1,6 +1,6 @@
#include <iostream>
#include <unistd.h>
-#include "mcp9808.h"
+#include "mcp9808.hpp"
#include "mraa.hpp"
diff --git a/peripheral/libupm/examples/c++/mg811.cxx b/peripheral/libupm/examples/c++/mg811.cxx
index b17423c..3d334c1 100644
--- a/peripheral/libupm/examples/c++/mg811.cxx
+++ b/peripheral/libupm/examples/c++/mg811.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mg811.h"
+#include "mg811.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mhz16.cxx b/peripheral/libupm/examples/c++/mhz16.cxx
index 542dc5f..dae109d 100644
--- a/peripheral/libupm/examples/c++/mhz16.cxx
+++ b/peripheral/libupm/examples/c++/mhz16.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mhz16.h"
+#include "mhz16.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mic.cxx b/peripheral/libupm/examples/c++/mic.cxx
index 8773d71..bb7ae22 100644
--- a/peripheral/libupm/examples/c++/mic.cxx
+++ b/peripheral/libupm/examples/c++/mic.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mic.h"
+#include "mic.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/micsv89.cxx b/peripheral/libupm/examples/c++/micsv89.cxx
index cf1530b..b2e4274 100644
--- a/peripheral/libupm/examples/c++/micsv89.cxx
+++ b/peripheral/libupm/examples/c++/micsv89.cxx
@@ -25,7 +25,7 @@
#include <iostream>
#include <unistd.h>
#include <signal.h>
-#include "micsv89.h"
+#include "micsv89.hpp"
/*
* An example for using the MICSV89 sensor library.
diff --git a/peripheral/libupm/examples/c++/mlx90614.cxx b/peripheral/libupm/examples/c++/mlx90614.cxx
index dbd00f4..c7f2a3f 100644
--- a/peripheral/libupm/examples/c++/mlx90614.cxx
+++ b/peripheral/libupm/examples/c++/mlx90614.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mlx90614.h"
+#include "mlx90614.hpp"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/mma7455.cxx b/peripheral/libupm/examples/c++/mma7455.cxx
index 052919f..0e73233 100644
--- a/peripheral/libupm/examples/c++/mma7455.cxx
+++ b/peripheral/libupm/examples/c++/mma7455.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mma7455.h"
+#include "mma7455.hpp"
#include <signal.h>
#include <pthread.h>
diff --git a/peripheral/libupm/examples/c++/mma7660.cxx b/peripheral/libupm/examples/c++/mma7660.cxx
index c426db5..19e3e02 100644
--- a/peripheral/libupm/examples/c++/mma7660.cxx
+++ b/peripheral/libupm/examples/c++/mma7660.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "mma7660.h"
+#include "mma7660.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mpl3115a2.cxx b/peripheral/libupm/examples/c++/mpl3115a2.cxx
index f9499d1..77890f1 100644
--- a/peripheral/libupm/examples/c++/mpl3115a2.cxx
+++ b/peripheral/libupm/examples/c++/mpl3115a2.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "mpl3115a2.h"
+#include "mpl3115a2.hpp"
volatile int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/mpr121.cxx b/peripheral/libupm/examples/c++/mpr121.cxx
index 7998965..e8aa4b7 100644
--- a/peripheral/libupm/examples/c++/mpr121.cxx
+++ b/peripheral/libupm/examples/c++/mpr121.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "mpr121.h"
+#include "mpr121.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mpu60x0.cxx b/peripheral/libupm/examples/c++/mpu60x0.cxx
index d90a017..63882cd 100644
--- a/peripheral/libupm/examples/c++/mpu60x0.cxx
+++ b/peripheral/libupm/examples/c++/mpu60x0.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mpu9150.h"
+#include "mpu9150.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mpu9150.cxx b/peripheral/libupm/examples/c++/mpu9150.cxx
index d6f5da5..df75057 100644
--- a/peripheral/libupm/examples/c++/mpu9150.cxx
+++ b/peripheral/libupm/examples/c++/mpu9150.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mpu9150.h"
+#include "mpu9150.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mpu9250.cxx b/peripheral/libupm/examples/c++/mpu9250.cxx
index fd093f9..ecd8877 100644
--- a/peripheral/libupm/examples/c++/mpu9250.cxx
+++ b/peripheral/libupm/examples/c++/mpu9250.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mpu9250.h"
+#include "mpu9250.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mq2.cxx b/peripheral/libupm/examples/c++/mq2.cxx
index f3bd9ca..040706e 100644
--- a/peripheral/libupm/examples/c++/mq2.cxx
+++ b/peripheral/libupm/examples/c++/mq2.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq2.h"
+#include "mq2.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq3.cxx b/peripheral/libupm/examples/c++/mq3.cxx
index 9fd3cce..13e7586 100644
--- a/peripheral/libupm/examples/c++/mq3.cxx
+++ b/peripheral/libupm/examples/c++/mq3.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq3.h"
+#include "mq3.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq303a.cxx b/peripheral/libupm/examples/c++/mq303a.cxx
index 4557de0..8a8764d 100644
--- a/peripheral/libupm/examples/c++/mq303a.cxx
+++ b/peripheral/libupm/examples/c++/mq303a.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mq303a.h"
+#include "mq303a.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mq4.cxx b/peripheral/libupm/examples/c++/mq4.cxx
index 686970b..87d5daf 100644
--- a/peripheral/libupm/examples/c++/mq4.cxx
+++ b/peripheral/libupm/examples/c++/mq4.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq4.h"
+#include "mq4.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq5.cxx b/peripheral/libupm/examples/c++/mq5.cxx
index 541bb26..89c0a52 100644
--- a/peripheral/libupm/examples/c++/mq5.cxx
+++ b/peripheral/libupm/examples/c++/mq5.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq5.h"
+#include "mq5.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq6.cxx b/peripheral/libupm/examples/c++/mq6.cxx
index 0a73af1..be25f14 100644
--- a/peripheral/libupm/examples/c++/mq6.cxx
+++ b/peripheral/libupm/examples/c++/mq6.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq6.h"
+#include "mq6.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq7.cxx b/peripheral/libupm/examples/c++/mq7.cxx
index a6279f1..561fde0 100644
--- a/peripheral/libupm/examples/c++/mq7.cxx
+++ b/peripheral/libupm/examples/c++/mq7.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq7.h"
+#include "mq7.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq8.cxx b/peripheral/libupm/examples/c++/mq8.cxx
index eae583f..5f9fb28 100644
--- a/peripheral/libupm/examples/c++/mq8.cxx
+++ b/peripheral/libupm/examples/c++/mq8.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq8.h"
+#include "mq8.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq9.cxx b/peripheral/libupm/examples/c++/mq9.cxx
index b62dad3..f1a8cd3 100644
--- a/peripheral/libupm/examples/c++/mq9.cxx
+++ b/peripheral/libupm/examples/c++/mq9.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq9.h"
+#include "mq9.hpp"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/nlgpio16.cxx b/peripheral/libupm/examples/c++/nlgpio16.cxx
index 44c901e..ecd9f02 100644
--- a/peripheral/libupm/examples/c++/nlgpio16.cxx
+++ b/peripheral/libupm/examples/c++/nlgpio16.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "nlgpio16.h"
+#include "nlgpio16.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx b/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx
index f4a1d21..81c70e0 100644
--- a/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx
+++ b/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx
@@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <iostream>
-#include "nrf24l01.h"
+#include "nrf24l01.hpp"
#include <signal.h>
#include <stdio.h>
#include <vector>
diff --git a/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx b/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx
index 344cb0c..a2430af 100644
--- a/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx
+++ b/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx
@@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <iostream>
-#include "nrf24l01.h"
+#include "nrf24l01.hpp"
#include <signal.h>
int running = 0;
diff --git a/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx b/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx
index 5d9f7cc..d64cf2e 100644
--- a/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx
+++ b/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx
@@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <iostream>
-#include "nrf24l01.h"
+#include "nrf24l01.hpp"
#include <signal.h>
int running = 0;
diff --git a/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx b/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx
index 534e32b..a30e15d 100644
--- a/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx
+++ b/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx
@@ -24,8 +24,8 @@
#include <unistd.h>
#include <iostream>
-#include "nrf8001.h"
-#include "nrf8001-broadcast.h"
+#include "nrf8001.hpp"
+#include "nrf8001-broadcast.hpp"
#include <lib_aci.h>
#include <aci_setup.h>
#include <signal.h>
diff --git a/peripheral/libupm/examples/c++/nrf8001-broadcast.h b/peripheral/libupm/examples/c++/nrf8001-broadcast.hpp
index b6f8cb5..b6f8cb5 100644
--- a/peripheral/libupm/examples/c++/nrf8001-broadcast.h
+++ b/peripheral/libupm/examples/c++/nrf8001-broadcast.hpp
diff --git a/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx b/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx
index 5866a0f..9da070f 100644
--- a/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx
+++ b/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx
@@ -24,8 +24,8 @@
#include <unistd.h>
#include <iostream>
-#include "nrf8001.h"
-#include "nrf8001-helloworld.h"
+#include "nrf8001.hpp"
+#include "nrf8001-helloworld.hpp"
#include <lib_aci.h>
#include <aci_setup.h>
#include <signal.h>
diff --git a/peripheral/libupm/examples/c++/nrf8001-helloworld.h b/peripheral/libupm/examples/c++/nrf8001-helloworld.hpp
index ec566b5..ec566b5 100644
--- a/peripheral/libupm/examples/c++/nrf8001-helloworld.h
+++ b/peripheral/libupm/examples/c++/nrf8001-helloworld.hpp
diff --git a/peripheral/libupm/examples/c++/nunchuck.cxx b/peripheral/libupm/examples/c++/nunchuck.cxx
index 4b9d617..03d2cbb 100644
--- a/peripheral/libupm/examples/c++/nunchuck.cxx
+++ b/peripheral/libupm/examples/c++/nunchuck.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "nunchuck.h"
+#include "nunchuck.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/otp538u.cxx b/peripheral/libupm/examples/c++/otp538u.cxx
index ea6e3b3..914350f 100644
--- a/peripheral/libupm/examples/c++/otp538u.cxx
+++ b/peripheral/libupm/examples/c++/otp538u.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <iomanip>
#include <signal.h>
-#include "otp538u.h"
+#include "otp538u.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ozw.cxx b/peripheral/libupm/examples/c++/ozw.cxx
index 40c30f4..ab9521a 100644
--- a/peripheral/libupm/examples/c++/ozw.cxx
+++ b/peripheral/libupm/examples/c++/ozw.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
-#include "ozw.h"
+#include "ozw.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/pca9685.cxx b/peripheral/libupm/examples/c++/pca9685.cxx
index 0806e40..82f3986 100644
--- a/peripheral/libupm/examples/c++/pca9685.cxx
+++ b/peripheral/libupm/examples/c++/pca9685.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "pca9685.h"
+#include "pca9685.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/pn532-writeurl.cxx b/peripheral/libupm/examples/c++/pn532-writeurl.cxx
index f7fc956..8e63f54 100644
--- a/peripheral/libupm/examples/c++/pn532-writeurl.cxx
+++ b/peripheral/libupm/examples/c++/pn532-writeurl.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "pn532.h"
+#include "pn532.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/pn532.cxx b/peripheral/libupm/examples/c++/pn532.cxx
index d1b7ba0..ea66a02 100644
--- a/peripheral/libupm/examples/c++/pn532.cxx
+++ b/peripheral/libupm/examples/c++/pn532.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "pn532.h"
+#include "pn532.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ppd42ns.cxx b/peripheral/libupm/examples/c++/ppd42ns.cxx
index 38a64e5..8a2a302 100644
--- a/peripheral/libupm/examples/c++/ppd42ns.cxx
+++ b/peripheral/libupm/examples/c++/ppd42ns.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ppd42ns.h"
+#include "ppd42ns.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/pressure-sensor.cxx b/peripheral/libupm/examples/c++/pressure-sensor.cxx
new file mode 100644
index 0000000..891f6a6
--- /dev/null
+++ b/peripheral/libupm/examples/c++/pressure-sensor.cxx
@@ -0,0 +1,81 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "bmpx8x.hpp"
+#include "bme280.hpp"
+
+
+#define EDISON_I2C_BUS 1
+#define FT4222_I2C_BUS 0
+
+//! [Interesting]
+// Simple example of using ILightSensor to determine
+// which sensor is present and return its name.
+// ILightSensor is then used to get readings from sensor
+
+
+upm::IPressureSensor* getPressureSensor()
+{
+ upm::IPressureSensor* pressureSensor = NULL;
+ try {
+ pressureSensor = new upm::BME280 (mraa_get_sub_platform_id(FT4222_I2C_BUS));
+ return pressureSensor ;
+ } catch (std::exception& e)
+ {
+ std::cerr <<"BME280: "<<e.what() << std::endl;
+ }
+
+ try {
+ pressureSensor = new upm::BMPX8X(EDISON_I2C_BUS);
+ return pressureSensor;
+ } catch (std::exception& e) {
+ std::cerr << "BMPX8X: " << e.what() << std::endl;
+ }
+ return pressureSensor;
+}
+
+int main ()
+{
+ upm::IPressureSensor* pressureSensor = getPressureSensor();
+ if (pressureSensor == NULL) {
+ std::cout << "Pressure sensor not detected" << std::endl;
+ return 1;
+ }
+ std::cout << "Pressure sensor " << pressureSensor->getModuleName() << " detected" << std::endl;
+ while (true) {
+ try {
+ int value = pressureSensor->getPressurePa();
+ std::cout << "Pressure = " << value << " Pa" << std::endl;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ sleep(1);
+ }
+ delete pressureSensor;
+ return 0;
+}
+
+//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/pulsensor.cxx b/peripheral/libupm/examples/c++/pulsensor.cxx
index dcb9cba..a2919e9 100644
--- a/peripheral/libupm/examples/c++/pulsensor.cxx
+++ b/peripheral/libupm/examples/c++/pulsensor.cxx
@@ -24,7 +24,7 @@
#include <string.h>
#include <unistd.h>
-#include "pulsensor.h"
+#include "pulsensor.hpp"
#include <signal.h>
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/rfr359f.cxx b/peripheral/libupm/examples/c++/rfr359f.cxx
index b7a8c21..81b2d48 100644
--- a/peripheral/libupm/examples/c++/rfr359f.cxx
+++ b/peripheral/libupm/examples/c++/rfr359f.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "rfr359f.h"
+#include "rfr359f.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rgbringcoder.cxx b/peripheral/libupm/examples/c++/rgbringcoder.cxx
index 52644cd..c648bba 100644
--- a/peripheral/libupm/examples/c++/rgbringcoder.cxx
+++ b/peripheral/libupm/examples/c++/rgbringcoder.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "rgbringcoder.h"
+#include "rgbringcoder.hpp"
#include <signal.h>
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rhusb.cxx b/peripheral/libupm/examples/c++/rhusb.cxx
index 20f12ed..0b14aaa 100644
--- a/peripheral/libupm/examples/c++/rhusb.cxx
+++ b/peripheral/libupm/examples/c++/rhusb.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "rhusb.h"
+#include "rhusb.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rotaryencoder.cxx b/peripheral/libupm/examples/c++/rotaryencoder.cxx
index f6c505e..e211f03 100644
--- a/peripheral/libupm/examples/c++/rotaryencoder.cxx
+++ b/peripheral/libupm/examples/c++/rotaryencoder.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "rotaryencoder.h"
+#include "rotaryencoder.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rpr220-intr.cxx b/peripheral/libupm/examples/c++/rpr220-intr.cxx
index 05a8381..401640c 100644
--- a/peripheral/libupm/examples/c++/rpr220-intr.cxx
+++ b/peripheral/libupm/examples/c++/rpr220-intr.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "rpr220.h"
+#include "rpr220.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rpr220.cxx b/peripheral/libupm/examples/c++/rpr220.cxx
index c9bdf1d..dffffc8 100644
--- a/peripheral/libupm/examples/c++/rpr220.cxx
+++ b/peripheral/libupm/examples/c++/rpr220.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "rpr220.h"
+#include "rpr220.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/sainsmartks.cxx b/peripheral/libupm/examples/c++/sainsmartks.cxx
index 19c8704..8f17033 100644
--- a/peripheral/libupm/examples/c++/sainsmartks.cxx
+++ b/peripheral/libupm/examples/c++/sainsmartks.cxx
@@ -26,7 +26,7 @@
#include <signal.h>
#include <iostream>
-#include "sainsmartks.h"
+#include "sainsmartks.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/si1132.cxx b/peripheral/libupm/examples/c++/si1132.cxx
new file mode 100644
index 0000000..31d5bde
--- /dev/null
+++ b/peripheral/libupm/examples/c++/si1132.cxx
@@ -0,0 +1,46 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "si1132.hpp"
+
+#define FT4222_I2C_BUS 1
+
+int main ()
+{
+ try {
+ upm::SI1132* lightSensor = new upm::SI1132(mraa_get_sub_platform_id(FT4222_I2C_BUS));
+ while (true) {
+ float value = lightSensor->getVisibleLux();
+ std::cout << "Light level = " << value << " lux" << std::endl;
+ sleep(1);
+ }
+ delete lightSensor;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ return 1;
+ }
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/si114x.cxx b/peripheral/libupm/examples/c++/si114x.cxx
index 4c069c9..cf9d168 100644
--- a/peripheral/libupm/examples/c++/si114x.cxx
+++ b/peripheral/libupm/examples/c++/si114x.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "si114x.h"
+#include "si114x.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/si7005.cxx b/peripheral/libupm/examples/c++/si7005.cxx
new file mode 100644
index 0000000..97e013d
--- /dev/null
+++ b/peripheral/libupm/examples/c++/si7005.cxx
@@ -0,0 +1,51 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "si7005.hpp"
+
+#define EDISON_I2C_BUS 1
+#define EDISON_GPIO_SI7005_CS 20
+
+
+int main ()
+{
+ try {
+ upm::SI7005* sensor = new upm::SI7005(EDISON_I2C_BUS, EDISON_GPIO_SI7005_CS);
+ while (true) {
+ int temperature = sensor->getTemperatureCelcius();
+ int humidity = sensor->getHumidityRelative();
+ std::cout << "Temperature = " << temperature << "C" << std::endl;
+ std::cout << "Humidity = " << humidity << "%" << std::endl;
+ sleep(1);
+ }
+ delete sensor;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ return 0;
+}
+
+//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/sm130.cxx b/peripheral/libupm/examples/c++/sm130.cxx
index 3d1e3bd..2712790 100644
--- a/peripheral/libupm/examples/c++/sm130.cxx
+++ b/peripheral/libupm/examples/c++/sm130.cxx
@@ -27,7 +27,7 @@
#include <string>
#include <signal.h>
#include <stdio.h>
-#include "sm130.h"
+#include "sm130.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/smartdrive.cxx b/peripheral/libupm/examples/c++/smartdrive.cxx
new file mode 100644
index 0000000..ab943fd
--- /dev/null
+++ b/peripheral/libupm/examples/c++/smartdrive.cxx
@@ -0,0 +1,75 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Author: Oussema Harbi <oussema.elharbi@gmail.com>
+ * Copyright (c) <2016> <Oussema Harbi>
+ *
+ * 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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "smartdrive.hpp"
+#include <signal.h>
+
+upm::SmartDrive *drive = NULL;
+
+void
+sig_handler(int signo)
+{
+ printf("got signal\n");
+ if (signo == SIGINT) {
+ printf("exiting application\n");
+ if (drive != NULL)
+ delete drive;
+ exit (0);
+ }
+}
+
+int
+main(int argc, char **argv)
+{
+ float voltage = 0;
+
+ std::cout << "SmartDrive demo is starting. Please make sure drive is connected to board" << std::endl;
+ sleep(2); //Wait for 2 seconds in case you want to fix your h/w setup
+
+ //! [Interesting]
+ // Instantiate a SmartDrive connected to /dev/i2c-0 bus, using DefaultAddress
+ drive = new upm::SmartDrive(0);
+
+ std::cout << "Battery Voltage before motor run : " << drive->GetBattVoltage() << std::endl;
+ //Set motor M1 to run for 120 seconds, with speed of 15RPM, waith for it to finish and then Brake It
+ drive->Run_Seconds(SmartDrive_Motor_ID_1, SmartDrive_Dir_Forward, 15, 120, true, SmartDrive_Action_Brake);
+ std::cout << "Battery Voltage after motor run : " << drive->GetBattVoltage() << std::endl;
+ //Rotate motor M2 2270 degrees, in reverse sense, with speed of 10RPM, return immediately from function call
+ drive->Run_Degrees(SmartDrive_Motor_ID_2, SmartDrive_Dir_Reverse, 10, 2270, false, SmartDrive_Action_Float);
+ //While motor is running, Display its status
+ drive->PrintMotorStatus(SmartDrive_Motor_ID_2);
+ sleep(2); //Sleep for 2 seconds
+ //Stop motor M2 and then finish program
+ drive->StopMotor(SmartDrive_Motor_ID_2, SmartDrive_Action_BrakeHold);
+ //! [Interesting]
+
+ std::cout << "Demo complete. GoodBye" << std::endl;
+
+ delete drive;
+ drive = NULL;
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/ssd1306-oled.cxx b/peripheral/libupm/examples/c++/ssd1306-oled.cxx
index 07421e3..c0eef15 100644
--- a/peripheral/libupm/examples/c++/ssd1306-oled.cxx
+++ b/peripheral/libupm/examples/c++/ssd1306-oled.cxx
@@ -26,10 +26,10 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "ssd1306.h"
+#include "ssd1306.hpp"
#define DEVICE_ADDRESS 0x3C
-#define BUS_NUMBER 0x6
+#define BUS_NUMBER 0x0
static uint8_t intel_logo[] = {
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,
diff --git a/peripheral/libupm/examples/c++/ssd1308-oled.cxx b/peripheral/libupm/examples/c++/ssd1308-oled.cxx
index f54169e..c78e8b8 100644
--- a/peripheral/libupm/examples/c++/ssd1308-oled.cxx
+++ b/peripheral/libupm/examples/c++/ssd1308-oled.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "ssd1308.h"
+#include "ssd1308.hpp"
#define DEVICE_ADDRESS 0x3C
#define BUS_NUMBER 0x0
diff --git a/peripheral/libupm/examples/c++/ssd1327-oled.cxx b/peripheral/libupm/examples/c++/ssd1327-oled.cxx
index 73323ec..d087f70 100644
--- a/peripheral/libupm/examples/c++/ssd1327-oled.cxx
+++ b/peripheral/libupm/examples/c++/ssd1327-oled.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "ssd1327.h"
+#include "ssd1327.hpp"
#define DEVICE_ADDRESS 0x3C
#define BUS_NUMBER 0x0
diff --git a/peripheral/libupm/examples/c++/ssd1351.cxx b/peripheral/libupm/examples/c++/ssd1351.cxx
index c0de509..dec565d 100644
--- a/peripheral/libupm/examples/c++/ssd1351.cxx
+++ b/peripheral/libupm/examples/c++/ssd1351.cxx
@@ -2,7 +2,7 @@
#include <iostream>
#include <unistd.h>
-#include "ssd1351.h"
+#include "ssd1351.hpp"
#define BLACK 0x0000
#define WHITE 0xFFFF
diff --git a/peripheral/libupm/examples/c++/st7735.cxx b/peripheral/libupm/examples/c++/st7735.cxx
index 2c14d49..5dedd8b 100644
--- a/peripheral/libupm/examples/c++/st7735.cxx
+++ b/peripheral/libupm/examples/c++/st7735.cxx
@@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <iostream>
-#include "st7735.h"
+#include "st7735.hpp"
#include <signal.h>
int
diff --git a/peripheral/libupm/examples/c++/stepmotor.cxx b/peripheral/libupm/examples/c++/stepmotor.cxx
index 9357d5d..8f4194c 100644
--- a/peripheral/libupm/examples/c++/stepmotor.cxx
+++ b/peripheral/libupm/examples/c++/stepmotor.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "stepmotor.h"
+#include "stepmotor.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/sx1276-fsk.cxx b/peripheral/libupm/examples/c++/sx1276-fsk.cxx
index f63d1bf..c6bf3ad 100644
--- a/peripheral/libupm/examples/c++/sx1276-fsk.cxx
+++ b/peripheral/libupm/examples/c++/sx1276-fsk.cxx
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <iostream>
#include <signal.h>
-#include "sx1276.h"
+#include "sx1276.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/sx1276-lora.cxx b/peripheral/libupm/examples/c++/sx1276-lora.cxx
index 7c45597..6ac3706 100644
--- a/peripheral/libupm/examples/c++/sx1276-lora.cxx
+++ b/peripheral/libupm/examples/c++/sx1276-lora.cxx
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <iostream>
#include <signal.h>
-#include "sx1276.h"
+#include "sx1276.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/sx6119.cxx b/peripheral/libupm/examples/c++/sx6119.cxx
index 2608387..0d1178f 100644
--- a/peripheral/libupm/examples/c++/sx6119.cxx
+++ b/peripheral/libupm/examples/c++/sx6119.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "sx6119.h"
+#include "sx6119.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/t3311.cxx b/peripheral/libupm/examples/c++/t3311.cxx
index 1859dc6..4401a1b 100644
--- a/peripheral/libupm/examples/c++/t3311.cxx
+++ b/peripheral/libupm/examples/c++/t3311.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "t3311.h"
+#include "t3311.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/t6713.cxx b/peripheral/libupm/examples/c++/t6713.cxx
new file mode 100644
index 0000000..c07871a
--- /dev/null
+++ b/peripheral/libupm/examples/c++/t6713.cxx
@@ -0,0 +1,48 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "t6713.hpp"
+
+#define FT4222_I2C_BUS 0
+
+int main ()
+{
+
+ try {
+ upm::T6713* cO2Sensor = new upm::T6713(mraa_get_sub_platform_id(FT4222_I2C_BUS));
+ while (true) {
+ uint16_t value = cO2Sensor->getPpm();
+ std::cout << "CO2 level = " << value << " ppm" << std::endl;
+ sleep(1);
+ }
+ delete cO2Sensor;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ return 1;
+ }
+ return 0;
+}
+
diff --git a/peripheral/libupm/examples/c++/t8100.cxx b/peripheral/libupm/examples/c++/t8100.cxx
new file mode 100644
index 0000000..3cecbac
--- /dev/null
+++ b/peripheral/libupm/examples/c++/t8100.cxx
@@ -0,0 +1,117 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "t8100.hpp"
+
+using namespace std;
+using namespace upm;
+
+bool shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+
+//! [Interesting]
+ // You will need to edit this example to conform to your site and your
+ // devices, specifically the Device Object Instance ID passed to the
+ // constructor, and the arguments to initMaster() that are
+ // appropriate for your BACnet network.
+
+ string defaultDev = "/dev/ttyUSB0";
+
+ // if an argument was specified, use it as the device instead
+ if (argc > 1)
+ defaultDev = string(argv[1]);
+
+ cout << "Using device " << defaultDev << endl;
+ cout << "Initializing..." << endl;
+
+ // Instantiate an T8100 object for an T8100 device that has 568000
+ // as it's unique Device Object Instance ID. NOTE: You will
+ // certainly want to change this to the correct value for your
+ // device(s).
+ T8100 *sensor = new T8100(568000);
+
+ // Initialize our BACnet master, if it has not already been
+ // initialized, with the device and baudrate, choosing 1000001 as
+ // our unique Device Object Instance ID, 2 as our MAC address and
+ // using default values for maxMaster and maxInfoFrames
+ sensor->initMaster(defaultDev, 38400, 1000001, 2);
+
+ // Uncomment to enable debugging output
+ // sensor->setDebug(true);
+
+ cout << endl;
+ cout << "Device Description: " << sensor->getDeviceDescription() << endl;
+ cout << "Device Location: " << sensor->getDeviceLocation() << endl;
+ cout << endl;
+
+ // update and print a few values every 5 seconds
+ while (shouldRun)
+ {
+ // update our values
+ sensor->update();
+
+ cout << "CO2 Concentration: "
+ << sensor->getCO2()
+ << " ppm"
+ << endl;
+
+ // we show both C and F for temperature
+ cout << "Temperature: " << sensor->getTemperature()
+ << " C / "
+ << sensor->getTemperature(true)
+ << " F"
+ << endl;
+
+ cout << "Humidity: " << sensor->getHumidity()
+ << " %RH"
+ << endl;
+
+ cout << "Relay State: " << sensor->getRelayState()
+ << endl;
+
+ cout << endl;
+ sleep(5);
+ }
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+//! [Interesting]
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/ta12200.cxx b/peripheral/libupm/examples/c++/ta12200.cxx
index 5f949a1..8fdffd8 100644
--- a/peripheral/libupm/examples/c++/ta12200.cxx
+++ b/peripheral/libupm/examples/c++/ta12200.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ta12200.h"
+#include "ta12200.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/tb7300.cxx b/peripheral/libupm/examples/c++/tb7300.cxx
new file mode 100644
index 0000000..0aab8ac
--- /dev/null
+++ b/peripheral/libupm/examples/c++/tb7300.cxx
@@ -0,0 +1,124 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "tb7300.hpp"
+
+using namespace std;
+using namespace upm;
+
+bool shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+
+//! [Interesting]
+ // You will need to edit this example to conform to your site and your
+ // devices, specifically the Device Object Instance ID passed to the
+ // constructor, and the arguments to initMaster() that are
+ // appropriate for your BACnet network.
+
+ string defaultDev = "/dev/ttyUSB0";
+
+ // if an argument was specified, use it as the device instead
+ if (argc > 1)
+ defaultDev = string(argv[1]);
+
+ cout << "Using device " << defaultDev << endl;
+ cout << "Initializing..." << endl;
+
+ // Instantiate an TB7300 object for an TB7300 device that has 73001
+ // as it's unique Device Object Instance ID. NOTE: You will
+ // certainly want to change this to the correct value for your
+ // device(s).
+ TB7300 *sensor = new TB7300(73001);
+
+ // Initialize our BACnet master, if it has not already been
+ // initialized, with the device and baudrate, choosing 1000001 as
+ // our unique Device Object Instance ID, 2 as our MAC address and
+ // using default values for maxMaster and maxInfoFrames
+ sensor->initMaster(defaultDev, 38400, 1000001, 2);
+
+ // Uncomment to enable debugging output
+ // sensor->setDebug(true);
+
+ cout << endl;
+ cout << "Device Name: " << sensor->getDeviceName() << endl;
+ cout << "Device Description: " << sensor->getDeviceDescription() << endl;
+ cout << "Device Location: " << sensor->getDeviceLocation() << endl;
+ cout << endl;
+
+ cout << "Fan Mode: "
+ << sensor->getMultiStateValueText(TB7300::MV_Fan_Mode)
+ << endl;
+
+ cout << "Fan Status: "
+ << sensor->getMultiStateValueText(TB7300::MV_Fan_Status)
+ << endl;
+
+ cout << "System Mode: "
+ << sensor->getMultiStateValueText(TB7300::MV_System_Mode)
+ << endl;
+
+ cout << "Service Alarm: "
+ << sensor->getBinaryInputText(TB7300::BI_Service_Alarm)
+ << endl;
+
+ cout << endl;
+
+ // update and print the room temperature every 5 seconds
+ while (shouldRun)
+ {
+ // update our values
+ sensor->update();
+
+ // we show both C and F for temperature
+ cout << "Temperature: " << sensor->getTemperature()
+ << " C / "
+ << sensor->getTemperature(true)
+ << " F"
+ << endl;
+
+ cout << endl;
+ sleep(5);
+ }
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+//! [Interesting]
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/tcs3414cs.cxx b/peripheral/libupm/examples/c++/tcs3414cs.cxx
index 5e6376e..7efcebd 100644
--- a/peripheral/libupm/examples/c++/tcs3414cs.cxx
+++ b/peripheral/libupm/examples/c++/tcs3414cs.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "tcs3414cs.h"
+#include "tcs3414cs.hpp"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/teams.cxx b/peripheral/libupm/examples/c++/teams.cxx
new file mode 100644
index 0000000..40570ad
--- /dev/null
+++ b/peripheral/libupm/examples/c++/teams.cxx
@@ -0,0 +1,84 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "teams.hpp"
+
+using namespace std;
+
+bool shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+
+//! [Interesting]
+
+ cout << "Initializing..." << endl;
+
+ // Instantiate an TEAMS instance, using A0 for temperature, and
+ // 165.0 ohms for the rResistor value (for the libelium 4-20ma
+ // interface)
+ upm::TEAMS *sensor = new upm::TEAMS(0, 165.0);
+
+ // update and print available values every second
+ while (shouldRun)
+ {
+ // update our values from the sensor
+ sensor->update();
+
+ // is the sensor connected? (current >= 4ma)
+ cout << "Is Connected: " << sensor->isConnected() << endl;
+
+ // print computed current on the loop. This includes the offset,
+ // if one was set by setOffsetMilliamps().
+ cout << "Milliamps: " << sensor->getRawMilliamps() << endl;
+
+ // we show both C and F for temperature
+ cout << "Temperature: " << sensor->getTemperature()
+ << " C / " << sensor->getTemperature(true) << " F"
+ << endl;
+
+ cout << endl;
+
+ sleep(1);
+ }
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+//! [Interesting]
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/temperature-sensor.cxx b/peripheral/libupm/examples/c++/temperature-sensor.cxx
new file mode 100644
index 0000000..d613461
--- /dev/null
+++ b/peripheral/libupm/examples/c++/temperature-sensor.cxx
@@ -0,0 +1,90 @@
+/*
+ * Author: Henry Bruce <henry.bruce@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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include "si7005.hpp"
+#include "bmpx8x.hpp"
+#include "bme280.hpp"
+
+#define EDISON_I2C_BUS 1
+#define FT4222_I2C_BUS 0
+
+ #define EDISON_GPIO_SI7005_CS 20
+
+//! [Interesting]
+// Simple example of using ITemperatureSensor to determine
+// which sensor is present and return its name.
+// ITemperatureSensor is then used to get readings from sensor
+
+
+upm::ITemperatureSensor* getTemperatureSensor()
+{
+ upm::ITemperatureSensor* temperatureSensor = NULL;
+
+ try {
+ temperatureSensor = new upm::BME280 (mraa_get_sub_platform_id(FT4222_I2C_BUS));
+ return temperatureSensor;
+ } catch (std::exception& e)
+ {
+ std::cerr <<"BME280: "<<e.what() << std::endl;
+ }
+
+ try {
+ temperatureSensor = new upm::SI7005(EDISON_I2C_BUS, EDISON_GPIO_SI7005_CS);
+ return temperatureSensor;
+ } catch (std::exception& e) {
+ std::cerr << "SI7005: " << e.what() << std::endl;
+ }
+ try {
+ temperatureSensor = new upm::BMPX8X(EDISON_I2C_BUS);
+ return temperatureSensor;
+ } catch (std::exception& e) {
+ std::cerr << "BMPX8X: " << e.what() << std::endl;
+ }
+ return temperatureSensor;
+}
+
+int main ()
+{
+ upm::ITemperatureSensor* temperatureSensor = getTemperatureSensor();
+ if (temperatureSensor == NULL) {
+ std::cout << "Temperature sensor not detected" << std::endl;
+ return 1;
+ }
+ std::cout << "Temperature sensor " << temperatureSensor->getModuleName() << " detected" << std::endl;
+ while (true) {
+ try {
+ int value = temperatureSensor->getTemperatureCelcius();
+ std::cout << "Temperature = " << value << "C" << std::endl;
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ sleep(1);
+ }
+ delete temperatureSensor;
+ return 0;
+}
+
+//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/tex00.cxx b/peripheral/libupm/examples/c++/tex00.cxx
new file mode 100644
index 0000000..8fdb9cb
--- /dev/null
+++ b/peripheral/libupm/examples/c++/tex00.cxx
@@ -0,0 +1,91 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+#include <signal.h>
+
+#include "tex00.hpp"
+
+using namespace std;
+
+bool shouldRun = true;
+
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ shouldRun = false;
+}
+
+int main(int argc, char **argv)
+{
+ signal(SIGINT, sig_handler);
+
+//! [Interesting]
+
+ cout << "Initializing..." << endl;
+
+ // Instantiate an TEX00 instance, using A0 for the analog input. In
+ // this example, we are using a 10K Ohm balance resistor and a TED
+ // (10k type 2) thermistor.
+ upm::TEX00 *sensor = new upm::TEX00(0, 10000,
+ upm::TEX00::STYPE_THERMISTOR_TED);
+
+ cout << "Minimum temperature: " << sensor->getTemperatureRangeMin()
+ << " C" << endl;
+ cout << "Maximum temperature: " << sensor->getTemperatureRangeMax()
+ << " C" << endl;
+ cout << endl;
+
+ // update and print available values every second
+ while (shouldRun)
+ {
+ // update our values from the sensor
+ sensor->update();
+
+ if (sensor->isOutOfRange())
+ {
+ cout << "Temperature out of range" << endl;
+ }
+ else
+ {
+ // we show both C and F for temperature
+ cout << "Temperature: " << sensor->getTemperature()
+ << " C / " << sensor->getTemperature(true) << " F"
+ << endl;
+ }
+
+ cout << endl;
+
+ sleep(1);
+ }
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+//! [Interesting]
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/th02.cxx b/peripheral/libupm/examples/c++/th02.cxx
index cce0367..3079d8d 100644
--- a/peripheral/libupm/examples/c++/th02.cxx
+++ b/peripheral/libupm/examples/c++/th02.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "th02.h"
+#include "th02.hpp"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/tm1637.cxx b/peripheral/libupm/examples/c++/tm1637.cxx
index 235ae50..14ec3a2 100644
--- a/peripheral/libupm/examples/c++/tm1637.cxx
+++ b/peripheral/libupm/examples/c++/tm1637.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "tm1637.h"
+#include "tm1637.hpp"
#include <signal.h>
#include <unistd.h>
#include <sstream>
diff --git a/peripheral/libupm/examples/c++/tp401.cxx b/peripheral/libupm/examples/c++/tp401.cxx
index 255d3f0..4749ea5 100644
--- a/peripheral/libupm/examples/c++/tp401.cxx
+++ b/peripheral/libupm/examples/c++/tp401.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
-#include "tp401.h"
+#include "tp401.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/tsl2561.cxx b/peripheral/libupm/examples/c++/tsl2561.cxx
index 14ddb8a..87f8339 100644
--- a/peripheral/libupm/examples/c++/tsl2561.cxx
+++ b/peripheral/libupm/examples/c++/tsl2561.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
-#include "tsl2561.h"
+#include "tsl2561.hpp"
int main (int argc, char **argv)
{
diff --git a/peripheral/libupm/examples/c++/ttp223.cxx b/peripheral/libupm/examples/c++/ttp223.cxx
index 1d15585..88cbcf0 100644
--- a/peripheral/libupm/examples/c++/ttp223.cxx
+++ b/peripheral/libupm/examples/c++/ttp223.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "ttp223.h"
+#include "ttp223.hpp"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/ublox6.cxx b/peripheral/libupm/examples/c++/ublox6.cxx
index a0cd5f2..2d3d34b 100644
--- a/peripheral/libupm/examples/c++/ublox6.cxx
+++ b/peripheral/libupm/examples/c++/ublox6.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ublox6.h"
+#include "ublox6.hpp"
using namespace std;
@@ -77,7 +77,7 @@ int main (int argc, char **argv)
if (rv > 0)
write(1, nmeaBuffer, rv);
- if (rv < 0) // some sort of read error occured
+ if (rv < 0) // some sort of read error occurred
{
cerr << "Port read error." << endl;
break;
diff --git a/peripheral/libupm/examples/c++/uln200xa.cxx b/peripheral/libupm/examples/c++/uln200xa.cxx
index 53a6958..6a95328 100644
--- a/peripheral/libupm/examples/c++/uln200xa.cxx
+++ b/peripheral/libupm/examples/c++/uln200xa.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "uln200xa.h"
+#include "uln200xa.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/urm37-uart.cxx b/peripheral/libupm/examples/c++/urm37-uart.cxx
index 7a94a1f..0a0ff9c 100644
--- a/peripheral/libupm/examples/c++/urm37-uart.cxx
+++ b/peripheral/libupm/examples/c++/urm37-uart.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "urm37.h"
+#include "urm37.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/urm37.cxx b/peripheral/libupm/examples/c++/urm37.cxx
index 820b2a1..a7a7e24 100644
--- a/peripheral/libupm/examples/c++/urm37.cxx
+++ b/peripheral/libupm/examples/c++/urm37.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "urm37.h"
+#include "urm37.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/vcap.cxx b/peripheral/libupm/examples/c++/vcap.cxx
new file mode 100644
index 0000000..fe0d8a7
--- /dev/null
+++ b/peripheral/libupm/examples/c++/vcap.cxx
@@ -0,0 +1,70 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+#include <unistd.h>
+#include <iostream>
+
+#include "vcap.hpp"
+
+using namespace std;
+
+int main(int argc, char **argv)
+{
+//! [Interesting]
+
+ string defaultDev = "/dev/video0";
+
+ // if an argument was specified, use it as the device instead
+ if (argc > 1)
+ defaultDev = string(argv[1]);
+
+ cout << "Using device " << defaultDev << endl;
+ cout << "Initializing..." << endl;
+
+ // Instantiate an VCAP instance, using the specified video device
+ upm::VCAP *sensor = new upm::VCAP(defaultDev);
+
+ // enable some debug/verbose output
+ sensor->setDebug(true);
+
+ // This is just a hint. The kernel can change this to a lower
+ // resolution that the hardware supports. Use getWidth() and
+ // getHeight() methods to see what the kernel actually chose if you
+ // care.
+ sensor->setResolution(1920, 1080);
+
+ // capture an image
+ sensor->captureImage();
+
+ // convert and save it as a jpeg
+ sensor->saveImage("video-img1.jpg");
+
+ cout << "Exiting..." << endl;
+
+ delete sensor;
+
+//! [Interesting]
+
+ return 0;
+}
diff --git a/peripheral/libupm/examples/c++/waterlevel.cxx b/peripheral/libupm/examples/c++/waterlevel.cxx
index d3a069f..301e489 100644
--- a/peripheral/libupm/examples/c++/waterlevel.cxx
+++ b/peripheral/libupm/examples/c++/waterlevel.cxx
@@ -24,7 +24,7 @@
#include <iostream>
#include <unistd.h>
#include <signal.h>
-#include "waterlevel.h"
+#include "waterlevel.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/wheelencoder.cxx b/peripheral/libupm/examples/c++/wheelencoder.cxx
index 08a7825..1741b97 100644
--- a/peripheral/libupm/examples/c++/wheelencoder.cxx
+++ b/peripheral/libupm/examples/c++/wheelencoder.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "wheelencoder.h"
+#include "wheelencoder.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/wt5001.cxx b/peripheral/libupm/examples/c++/wt5001.cxx
index 317e877..92a6581 100644
--- a/peripheral/libupm/examples/c++/wt5001.cxx
+++ b/peripheral/libupm/examples/c++/wt5001.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "wt5001.h"
+#include "wt5001.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/xbee.cxx b/peripheral/libupm/examples/c++/xbee.cxx
index 834d8bc..d56052e 100644
--- a/peripheral/libupm/examples/c++/xbee.cxx
+++ b/peripheral/libupm/examples/c++/xbee.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "xbee.h"
+#include "xbee.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/yg1006.cxx b/peripheral/libupm/examples/c++/yg1006.cxx
index 07dbfb5..6b94421 100644
--- a/peripheral/libupm/examples/c++/yg1006.cxx
+++ b/peripheral/libupm/examples/c++/yg1006.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "yg1006.h"
+#include "yg1006.hpp"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/zfm20-register.cxx b/peripheral/libupm/examples/c++/zfm20-register.cxx
index fb1292c..c1f68d7 100644
--- a/peripheral/libupm/examples/c++/zfm20-register.cxx
+++ b/peripheral/libupm/examples/c++/zfm20-register.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "zfm20.h"
+#include "zfm20.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/zfm20.cxx b/peripheral/libupm/examples/c++/zfm20.cxx
index a7323b0..1ce6aaf 100644
--- a/peripheral/libupm/examples/c++/zfm20.cxx
+++ b/peripheral/libupm/examples/c++/zfm20.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "zfm20.h"
+#include "zfm20.hpp"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/java/AM2315Example.java b/peripheral/libupm/examples/java/AM2315Example.java
new file mode 100644
index 0000000..3da2ff5
--- /dev/null
+++ b/peripheral/libupm/examples/java/AM2315Example.java
@@ -0,0 +1,66 @@
+/*
+ * Author: Abhishek Malik <abhishek.malik@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_am2315.AM2315;
+
+public class AM2315Example {
+
+ static {
+ try {
+ System.loadLibrary("javaupm_am2315");
+ System.loadLibrary("mraajava");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println(
+ "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
+ e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ //! [Interesting]
+ float humidity = 0;
+ float temperature = 0;
+
+ // Instantiate the sensor
+ AM2315 sensor = new AM2315(0, upm_am2315.javaupm_am2315Constants.AM2315_I2C_ADDRESS);
+ sensor.testSensor();
+
+ while(true){
+ // retrieving the humidity and temperature values
+ humidity = sensor.getHumidity();
+ temperature = sensor.getTemperature();
+
+ System.out.println("Temperature : "+temperature+" Humidity: "+humidity);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ System.out.println("The following exception occurred: "+e.getMessage());
+ }
+ }
+ //! [Interesting]
+ }
+
+}
diff --git a/peripheral/libupm/examples/java/APA102Sample.java b/peripheral/libupm/examples/java/APA102Sample.java
new file mode 100644
index 0000000..4ebbdbf
--- /dev/null
+++ b/peripheral/libupm/examples/java/APA102Sample.java
@@ -0,0 +1,44 @@
+/*
+ * Author: Yannick Adam <yannick.adam@gmail.com>
+ * Copyright (c) 2016 Yannick Adam
+ *
+ * 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 APA102Sample {
+
+ public static void main(String[] args) throws InterruptedException {
+ // ! [Interesting]
+ // Instantiate a strip of 30 LEDs on SPI bus 0
+ upm_apa102.APA102 ledStrip =
+ new upm_apa102.APA102(30, (short)0, false, (byte)-1);
+
+ System.out.println("Set all LEDs to blue");
+ ledStrip.setAllLeds((short)31, (short)0, (short)0, (short)255);
+
+ System.out.println("Set LEDs between 10 and 20 to green");
+ ledStrip.setLeds(10, 20, (short)31, (short)0, (short)255, (short)0);
+
+ System.out.println("Set a single LED to red at index 15");
+ ledStrip.setLed(15, (short)31, (short)255, (short)0, (short)0);
+
+ // ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/Ad8232Example.java b/peripheral/libupm/examples/java/Ad8232Example.java
index 3b6102b..0ee0f2c 100644
--- a/peripheral/libupm/examples/java/Ad8232Example.java
+++ b/peripheral/libupm/examples/java/Ad8232Example.java
@@ -25,18 +25,6 @@ import upm_ad8232.AD8232;
public class Ad8232Example {
- static {
- try {
- System.loadLibrary("javaupm_ad8232");
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
public static void main(String[] args) {
// TODO Auto-generated method stub
//! [Interesting]
@@ -54,7 +42,7 @@ public class Ad8232Example {
Thread.sleep(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following error has occured: "+e.getMessage());
+ System.out.println("The following error has occurred: "+e.getMessage());
}
}
}
diff --git a/peripheral/libupm/examples/java/Apds9002.java b/peripheral/libupm/examples/java/Apds9002.java
index 4bb5de8..0c6b7cb 100644
--- a/peripheral/libupm/examples/java/Apds9002.java
+++ b/peripheral/libupm/examples/java/Apds9002.java
@@ -38,7 +38,7 @@ public class Apds9002 {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occured: "+e.getMessage());
+ System.out.println("The following exception occurred: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/BMA250E_Example.java b/peripheral/libupm/examples/java/BMA250E_Example.java
new file mode 100644
index 0000000..dd138ad
--- /dev/null
+++ b/peripheral/libupm/examples/java/BMA250E_Example.java
@@ -0,0 +1,64 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_bmx055.BMA250E;
+
+public class BMA250E_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // Instantiate a BMA250E instance using default i2c bus and address
+ BMA250E sensor = new BMA250E();
+
+ // For SPI, bus 0, you would pass -1 as the address, and a
+ // valid pin for CS:
+ // BMA250E(0, -1, 10);
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ float dataA[] = sensor.getAccelerometer();
+
+ System.out.println("Accelerometer x: " + dataA[0]
+ + " y: " + dataA[1]
+ + " z: " + dataA[2]
+ + " g");
+
+ System.out.println("Compensation Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ System.out.println();
+ Thread.sleep(250);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/BMC150_Example.java b/peripheral/libupm/examples/java/BMC150_Example.java
new file mode 100644
index 0000000..bcd37af
--- /dev/null
+++ b/peripheral/libupm/examples/java/BMC150_Example.java
@@ -0,0 +1,61 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_bmx055.BMC150;
+
+public class BMC150_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // Instantiate a BMC150 instance using default i2c bus and address
+ BMC150 sensor = new BMC150();
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ float data[] = sensor.getAccelerometer();
+
+ System.out.println("Accelerometer x: " + data[0]
+ + " y: " + data[1]
+ + " z: " + data[2]
+ + " g");
+
+ data = sensor.getMagnetometer();
+
+ System.out.println("Magnetometer x: " + data[0]
+ + " y: " + data[1]
+ + " z: " + data[2]
+ + " uT");
+
+ System.out.println();
+ Thread.sleep(250);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/BME280_Example.java b/peripheral/libupm/examples/java/BME280_Example.java
new file mode 100644
index 0000000..0a627e5
--- /dev/null
+++ b/peripheral/libupm/examples/java/BME280_Example.java
@@ -0,0 +1,69 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.BME280;
+
+public class BME280_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // Instantiate a BME280 instance using default i2c bus and address
+ BME280 sensor = new BME280();
+
+ // 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("Compensation Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ System.out.println("Pressure: "
+ + sensor.getPressure()
+ + " Pa");
+
+ System.out.println("Computed Altitude: "
+ + sensor.getAltitude()
+ + " m");
+
+ System.out.println("Humidity: "
+ + sensor.getHumidity()
+ + " %RH");
+
+ System.out.println();
+ Thread.sleep(1000);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/BMG160_Example.java b/peripheral/libupm/examples/java/BMG160_Example.java
new file mode 100644
index 0000000..09667b9
--- /dev/null
+++ b/peripheral/libupm/examples/java/BMG160_Example.java
@@ -0,0 +1,64 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_bmx055.BMG160;
+
+public class BMG160_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // Instantiate a BMG160 instance using default i2c bus and address
+ BMG160 sensor = new BMG160();
+
+ // For SPI, bus 0, you would pass -1 as the address, and a
+ // valid pin for CS:
+ // BMG160(0, -1, 10);
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ float dataA[] = sensor.getGyroscope();
+
+ System.out.println("Gyroscope x: " + dataA[0]
+ + " y: " + dataA[1]
+ + " z: " + dataA[2]
+ + " degrees/s");
+
+ System.out.println("Compensation Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ System.out.println();
+ Thread.sleep(250);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/BMI055_Example.java b/peripheral/libupm/examples/java/BMI055_Example.java
new file mode 100644
index 0000000..fc11696
--- /dev/null
+++ b/peripheral/libupm/examples/java/BMI055_Example.java
@@ -0,0 +1,61 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_bmx055.BMI055;
+
+public class BMI055_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // Instantiate a BMI055 instance using default i2c bus and address
+ BMI055 sensor = new BMI055();
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ float data[] = sensor.getAccelerometer();
+
+ System.out.println("Accelerometer x: " + data[0]
+ + " y: " + data[1]
+ + " z: " + data[2]
+ + " g");
+
+ data = sensor.getGyroscope();
+
+ System.out.println("Gyroscope x: " + data[0]
+ + " y: " + data[1]
+ + " z: " + data[2]
+ + " degrees/s");
+
+ System.out.println();
+ Thread.sleep(250);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/BMI160_Example.java b/peripheral/libupm/examples/java/BMI160_Example.java
new file mode 100644
index 0000000..6d83e2e
--- /dev/null
+++ b/peripheral/libupm/examples/java/BMI160_Example.java
@@ -0,0 +1,78 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_bmi160.BMI160;
+
+public class BMI160_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+ System.out.println("Initializing...");
+
+ // Instantiate a BMI160 instance using default i2c bus and address
+ BMI160 sensor = new BMI160();
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ float dataA[] = sensor.getAccelerometer();
+
+ System.out.println("Accelerometer: "
+ + "AX: "
+ + dataA[0]
+ + " AY: "
+ + dataA[1]
+ + " AZ: "
+ + dataA[2]);
+
+ float dataG[] = sensor.getGyroscope();
+
+ System.out.println("Gryoscope: "
+ + "GX: "
+ + dataG[0]
+ + " GY: "
+ + dataG[1]
+ + " GZ: "
+ + dataG[2]);
+
+ float dataM[] = sensor.getMagnetometer();
+
+ System.out.println("Magnetometer: "
+ + "MX: "
+ + dataM[0]
+ + " MY: "
+ + dataM[1]
+ + " MZ: "
+ + dataM[2]);
+
+ System.out.println();
+ Thread.sleep(500);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/BMM150_Example.java b/peripheral/libupm/examples/java/BMM150_Example.java
new file mode 100644
index 0000000..fc34ac7
--- /dev/null
+++ b/peripheral/libupm/examples/java/BMM150_Example.java
@@ -0,0 +1,58 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_bmx055.BMM150;
+
+public class BMM150_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // Instantiate a BMM150 instance using default i2c bus and address
+ BMM150 sensor = new BMM150();
+
+ // For SPI, bus 0, you would pass -1 as the address, and a
+ // valid pin for CS:
+ // BMM150(0, -1, 10);
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ float dataA[] = sensor.getMagnetometer();
+
+ System.out.println("Magnetometer x: " + dataA[0]
+ + " y: " + dataA[1]
+ + " z: " + dataA[2]
+ + " uT");
+
+ System.out.println();
+ Thread.sleep(250);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/BMP280_Example.java b/peripheral/libupm/examples/java/BMP280_Example.java
new file mode 100644
index 0000000..6bd600b
--- /dev/null
+++ b/peripheral/libupm/examples/java/BMP280_Example.java
@@ -0,0 +1,65 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.BMP280;
+
+public class BMP280_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // Instantiate a BMP280 instance using default i2c bus and address
+ BMP280 sensor = new BMP280();
+
+ // For SPI, bus 0, you would pass -1 as the address, and a
+ // valid pin for CS:
+ // BMP280(0, -1, 10);
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ System.out.println("Compensation Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ System.out.println("Pressure: "
+ + sensor.getPressure()
+ + " Pa");
+
+ System.out.println("Computed Altitude: "
+ + sensor.getAltitude()
+ + " m");
+
+ System.out.println();
+ Thread.sleep(1000);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/BMX055_Example.java b/peripheral/libupm/examples/java/BMX055_Example.java
new file mode 100644
index 0000000..2abb0da
--- /dev/null
+++ b/peripheral/libupm/examples/java/BMX055_Example.java
@@ -0,0 +1,69 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_bmx055.BMX055;
+
+public class BMX055_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // Instantiate a BMX055 instance using default i2c bus and address
+ BMX055 sensor = new BMX055();
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ float data[] = sensor.getAccelerometer();
+
+ System.out.println("Accelerometer x: " + data[0]
+ + " y: " + data[1]
+ + " z: " + data[2]
+ + " g");
+
+ data = sensor.getGyroscope();
+
+ System.out.println("Gyroscope x: " + data[0]
+ + " y: " + data[1]
+ + " z: " + data[2]
+ + " degrees/s");
+
+
+ data = sensor.getMagnetometer();
+
+ System.out.println("Magnetometer x: " + data[0]
+ + " y: " + data[1]
+ + " z: " + data[2]
+ + " uT");
+
+ System.out.println();
+ Thread.sleep(250);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/BNO055_Example.java b/peripheral/libupm/examples/java/BNO055_Example.java
new file mode 100644
index 0000000..808dbd3
--- /dev/null
+++ b/peripheral/libupm/examples/java/BNO055_Example.java
@@ -0,0 +1,99 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_bno055.BNO055;
+
+public class BNO055_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+ System.out.println("Initializing...");
+
+ // Instantiate an BNO055 using default parameters (bus 0, addr
+ // 0x28). The default running mode is NDOF absolute orientation
+ // mode.
+ BNO055 sensor = new BNO055();
+
+ System.out.println("First we need to calibrate. 4 numbers will be output every");
+ System.out.println("second for each sensor. 0 means uncalibrated, and 3 means");
+ System.out.println("fully calibrated.");
+ System.out.println("See the UPM documentation on this sensor for instructions on");
+ System.out.println("what actions are required to calibrate.");
+ System.out.println("");
+
+ while (!sensor.isFullyCalibrated())
+ {
+ int calData[] = sensor.getCalibrationStatus();
+
+ System.out.println("Magnetometer: " + calData[0]
+ + " Accelerometer: " + calData[1]
+ + " Gyroscope: " + calData[2]
+ + " System: " + calData[3]);
+
+ Thread.sleep(1000);
+
+ }
+
+ System.out.println("");
+ System.out.println("Calibration complete.");
+ System.out.println("");
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ float dataE[] = sensor.getEulerAngles();
+ System.out.println("Euler: Heading: " + dataE[0] +
+ " Roll: " + dataE[1] +
+ " Pitch: " + dataE[2] +
+ " degrees");
+
+ float dataQ[] = sensor.getQuaternions();
+ System.out.println("Quaternion: W: " + dataQ[0] +
+ " X:" + dataQ[1] +
+ " Y: " + dataQ[2] +
+ " Z: " + dataQ[3]);
+
+ float dataL[] = sensor.getLinearAcceleration();
+ System.out.println("Linear Acceleration: X: " + dataL[0] +
+ " Y: " + dataL[1] +
+ " Z: " + dataL[2] +
+ " m/s^2");
+
+ float dataG[] = sensor.getGravityVectors();
+ System.out.println("Gravity Vector: X: " + dataG[0] +
+ " Y: " + dataG[1] +
+ " Z: " + dataG[2] +
+ " m/s^2");
+
+
+ System.out.println();
+ Thread.sleep(250);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/CMakeLists.txt b/peripheral/libupm/examples/java/CMakeLists.txt
index 95d187a..130cc4f 100644
--- a/peripheral/libupm/examples/java/CMakeLists.txt
+++ b/peripheral/libupm/examples/java/CMakeLists.txt
@@ -6,13 +6,15 @@ macro(add_example example_name jar_name)
set(example_jar "${CMAKE_CURRENT_BINARY_DIR}/../../src/${jar_name}/upm_${jar_name}.jar")
add_jar(${example_name} SOURCES ${example_src} INCLUDE_JARS ${example_jar})
+ add_dependencies(${example_name} javaupm_${jar_name})
endmacro()
-macro(add_example_with_path example_name jar_path)
+macro(add_example_with_path example_name jar_path jar_name)
set(example_src "${example_name}.java")
- set(example_jar "${CMAKE_CURRENT_BINARY_DIR}/../../src/${jar_path}")
+ set(example_jar "${CMAKE_CURRENT_BINARY_DIR}/../../src/${jar_path}/upm_${jar_name}.jar")
add_jar(${example_name} SOURCES ${example_src} INCLUDE_JARS ${example_jar})
+ add_dependencies(${example_name} javaupm_${jar_name})
endmacro()
add_example(A110X_intrSample a110x)
@@ -105,12 +107,41 @@ add_example(Ad8232Example ad8232)
add_example(Gp2y0aExample gp2y0a)
add_example(Th02Example th02)
add_example(FlexSensorExample flex)
+add_example(CWLSXXA_Example cwlsxxa)
+add_example(TEAMS_Example teams)
+add_example(APA102Sample apa102)
+add_example(TEX00_Example tex00)
+add_example(BMI160_Example bmi160)
+add_example(Tsl2561 tsl2561)
+add_example(AM2315Example am2315)
+add_example(MAX31855Example max31855)
+add_example(MAX5487Example max5487)
+add_example(MAXds3231mExample maxds3231m)
+add_example(ECS1030Example ecs1030)
+add_example(SM130Example sm130)
+if (MODBUS_FOUND)
+ add_example(H803X_Example h803x)
+endif()
+if (BACNET_FOUND)
+ add_example(E50HX_Example e50hx)
+ add_example(T8100_Example t8100)
+ add_example(TB7300_Example tb7300)
+endif()
+add_example(VCAP_Example vcap)
+add_example(BMP280_Example bmp280)
+add_example(BNO055_Example bno055)
+add_example(BMX055_Example bmx055)
-
-add_example_with_path(Jhd1313m1_lcdSample lcd/upm_i2clcd.jar)
-add_example_with_path(Jhd1313m1Sample lcd/upm_i2clcd.jar)
-add_example_with_path(Lcm1602_i2cSample lcd/upm_i2clcd.jar)
-add_example_with_path(Lcm1602_parallelSample lcd/upm_i2clcd.jar)
-add_example_with_path(SSD1308_oledSample lcd/upm_i2clcd.jar)
-add_example_with_path(SSD1327_oledSample lcd/upm_i2clcd.jar)
+add_example_with_path(Jhd1313m1_lcdSample lcd i2clcd)
+add_example_with_path(Jhd1313m1Sample lcd i2clcd)
+add_example_with_path(Lcm1602_i2cSample lcd i2clcd)
+add_example_with_path(Lcm1602_parallelSample lcd i2clcd)
+add_example_with_path(SSD1308_oledSample lcd i2clcd)
+add_example_with_path(SSD1327_oledSample lcd i2clcd)
+add_example_with_path(BME280_Example bmp280 bmp280)
+add_example_with_path(BMA250E_Example bmx055 bmx055)
+add_example_with_path(BMG160_Example bmx055 bmx055)
+add_example_with_path(BMM150_Example bmx055 bmx055)
+add_example_with_path(BMC150_Example bmx055 bmx055)
+add_example_with_path(BMI055_Example bmx055 bmx055)
diff --git a/peripheral/libupm/examples/java/CWLSXXA_Example.java b/peripheral/libupm/examples/java/CWLSXXA_Example.java
new file mode 100644
index 0000000..e0f3052
--- /dev/null
+++ b/peripheral/libupm/examples/java/CWLSXXA_Example.java
@@ -0,0 +1,62 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_cwlsxxa.CWLSXXA;
+
+public class CWLSXXA_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // Instantiate an CWLSXXA instance, using A0 for CO2, A1 for
+ // humidity and A2 for temperature
+ CWLSXXA sensor = new CWLSXXA(0, 1, 2);
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ // we show both C and F for temperature
+ System.out.println("Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ System.out.println("Humidity: "
+ + sensor.getHumidity()
+ + " %");
+
+ System.out.println("CO2: "
+ + sensor.getCO2()
+ + " ppm");
+
+ Thread.sleep(1000);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/E50HX_Example.java b/peripheral/libupm/examples/java/E50HX_Example.java
new file mode 100644
index 0000000..24b6e3a
--- /dev/null
+++ b/peripheral/libupm/examples/java/E50HX_Example.java
@@ -0,0 +1,91 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_e50hx.E50HX;
+
+public class E50HX_Example
+{
+ private static String defaultDev = "/dev/ttyUSB0";
+
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // You will need to edit this example to conform to your site
+ // and your devices, specifically the Device Object Instance
+ // ID passed to the constructor, and the arguments to
+ // initMaster() that are appropriate for your BACnet network.
+
+ if (args.length > 0)
+ defaultDev = args[0];
+ System.out.println("Using device " + defaultDev);
+ System.out.println("Initializing...");
+
+ // Instantiate an E50HX object for an E50HX device that has
+ // 1075425 as it's unique Device Object Instance ID. NOTE:
+ // You will certainly want to change this to the correct value
+ // for your device(s).
+ E50HX sensor = new E50HX(1075425);
+
+ // Initialize our BACnet master, if it has not already been
+ // initialized, with the device and baudrate, choosing 1000001 as
+ // our unique Device Object Instance ID, 2 as our MAC address and
+ // using default values for maxMaster and maxInfoFrames
+ sensor.initMaster(defaultDev, 38400, 1000001, 2);
+
+ // Uncomment to enable debugging output
+ // sensor.setDebug(true);
+
+ System.out.println();
+ System.out.println("Device Description: "
+ + sensor.getDeviceDescription());
+ System.out.println("Device Location: "
+ + sensor.getDeviceLocation());
+ System.out.println();
+
+ // update and print a few values every 5 seconds
+ while (true)
+ {
+ System.out.println("System Voltage: "
+ + sensor.getAnalogValue(E50HX.ANALOG_VALUES_T.AV_System_Voltage)
+ + " "
+ + sensor.getAnalogValueUnits(E50HX.ANALOG_VALUES_T.AV_System_Voltage));
+
+ System.out.println("System Type: "
+ + sensor.getAnalogValue(E50HX.ANALOG_VALUES_T.AV_System_Type));
+
+ System.out.println("Energy Consumption: "
+ + sensor.getAnalogInput(E50HX.ANALOG_INPUTS_T.AI_Energy)
+ + " "
+ + sensor.getAnalogInputUnits(E50HX.ANALOG_INPUTS_T.AI_Energy));
+
+ System.out.println("Power Up Counter: "
+ + sensor.getAnalogInput(E50HX.ANALOG_INPUTS_T.AI_Power_Up_Count));
+
+ System.out.println();
+ Thread.sleep(5000);
+ }
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/ECS1030Example.java b/peripheral/libupm/examples/java/ECS1030Example.java
new file mode 100644
index 0000000..b922349
--- /dev/null
+++ b/peripheral/libupm/examples/java/ECS1030Example.java
@@ -0,0 +1,52 @@
+/*
+ * Author: Abhishek Malik <abhishek.malik@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_ecs1030.ECS1030;
+
+public class ECS1030Example {
+
+ static {
+ try {
+ System.loadLibrary("javaupm_ecs1030");
+ System.loadLibrary("mraajava");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println(
+ "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
+ e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ //! [Interesting]
+ ECS1030 sensor = new ECS1030((short)0);
+
+ while(true){
+ System.out.println("I = "+sensor.getCurrency_A()+", Power = "+sensor.getPower_A());
+ System.out.println("I = "+sensor.getCurrency_B()+", Power = "+sensor.getPower_B());
+ }
+ //! [Interesting]
+ }
+
+} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/Gp2y0aExample.java b/peripheral/libupm/examples/java/Gp2y0aExample.java
index 0837f55..1501b87 100644
--- a/peripheral/libupm/examples/java/Gp2y0aExample.java
+++ b/peripheral/libupm/examples/java/Gp2y0aExample.java
@@ -59,7 +59,7 @@ public class Gp2y0aExample {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occured: "+e.getMessage());
+ System.out.println("The following exception occurred: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/GroveEmg.java b/peripheral/libupm/examples/java/GroveEmg.java
index eaa8ba0..9827701 100644
--- a/peripheral/libupm/examples/java/GroveEmg.java
+++ b/peripheral/libupm/examples/java/GroveEmg.java
@@ -39,7 +39,7 @@ public class GroveEmg {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occured: "+e.getMessage());
+ System.out.println("The following exception occurred: "+e.getMessage());
}
}
}
diff --git a/peripheral/libupm/examples/java/GroveGsr.java b/peripheral/libupm/examples/java/GroveGsr.java
index 08a04b9..d7e9a69 100644
--- a/peripheral/libupm/examples/java/GroveGsr.java
+++ b/peripheral/libupm/examples/java/GroveGsr.java
@@ -41,7 +41,7 @@ public class GroveGsr {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occured: "+e.getMessage());
+ System.out.println("The following exception occurred: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/GroveO2Example.java b/peripheral/libupm/examples/java/GroveO2Example.java
index fe22b80..6ef0e61 100644
--- a/peripheral/libupm/examples/java/GroveO2Example.java
+++ b/peripheral/libupm/examples/java/GroveO2Example.java
@@ -38,7 +38,7 @@ public class GroveO2Example {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception has occured: "+e.getMessage());
+ System.out.println("The following exception has occurred: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/H803X_Example.java b/peripheral/libupm/examples/java/H803X_Example.java
new file mode 100644
index 0000000..5d4828e
--- /dev/null
+++ b/peripheral/libupm/examples/java/H803X_Example.java
@@ -0,0 +1,123 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_h803x.H803X;
+
+public class H803X_Example
+{
+ private static String defaultDev = "/dev/ttyUSB0";
+
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+ if (args.length > 0)
+ defaultDev = args[0];
+ System.out.println("Using device " + defaultDev);
+ System.out.println("Initializing...");
+
+ // Instantiate an H803X instance, using MODBUS slave address 1, and
+ // default comm parameters (9600, 8, N, 2)
+ H803X sensor = new H803X(defaultDev, 1);
+
+ // output the Slave ID (manufacturer, model, serno)
+ System.out.println("Slave ID: " + sensor.getSlaveID());
+ System.out.println();
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ // H8035 / H8036
+ System.out.println("Consumption (kWh): "
+ + sensor.getConsumption());
+ System.out.println("Real Power (kW): "
+ + sensor.getRealPower());
+
+ if (sensor.isH8036())
+ {
+ // The H8036 has much more data available...
+
+ System.out.println("Reactive Power (kVAR): "
+ + sensor.getReactivePower());
+ System.out.println("Apparent Power (kVA): "
+ + sensor.getApparentPower());
+ System.out.println("Power Factor: "
+ + sensor.getPowerFactor());
+ System.out.println("Volts Line to Line: "
+ + sensor.getVoltsLineToLine());
+ System.out.println("Volts Line to Neutral: "
+ + sensor.getVoltsLineToNeutral());
+
+ System.out.println("Current: " + sensor.getCurrent());
+
+ System.out.println("Real Power Phase A (kW): "
+ + sensor.getRealPowerPhaseA());
+ System.out.println("Real Power Phase B (kW): "
+ + sensor.getRealPowerPhaseB());
+ System.out.println("Real Power Phase C (kW): "
+ + sensor.getRealPowerPhaseC());
+
+ System.out.println("Power Factor Phase A: "
+ + sensor.getPowerFactorPhaseA());
+ System.out.println("Power Factor Phase B: "
+ + sensor.getPowerFactorPhaseB());
+ System.out.println("Power Factor Phase C: "
+ + sensor.getPowerFactorPhaseC());
+
+ System.out.println("Volts Phase A to B: "
+ + sensor.getVoltsPhaseAToB());
+ System.out.println("Volts Phase B to C: "
+ + sensor.getVoltsPhaseBToC());
+ System.out.println("Volts Phase A to C: "
+ + sensor.getVoltsPhaseAToC());
+ System.out.println("Volts Phase A to Neutral: "
+ + sensor.getVoltsPhaseAToNeutral());
+ System.out.println("Volts Phase B to Neutral: "
+ + sensor.getVoltsPhaseBToNeutral());
+ System.out.println("Volts Phase C to Neutral: "
+ + sensor.getVoltsPhaseCToNeutral());
+
+ System.out.println("Current Phase A: "
+ + sensor.getCurrentPhaseA());
+ System.out.println("Current Phase B: "
+ + sensor.getCurrentPhaseB());
+ System.out.println("Current Phase C: "
+ + sensor.getCurrentPhaseC());
+
+ System.out.println("Avg Real Power (kW): "
+ + sensor.getAvgRealPower());
+ System.out.println("Min Real Power (kW): "
+ + sensor.getMinRealPower());
+ System.out.println("Max Real Power (kW): "
+ + sensor.getMaxRealPower());
+ }
+
+ System.out.println();
+ Thread.sleep(2000);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/HP20xExample.java b/peripheral/libupm/examples/java/HP20xExample.java
index 8082031..17e9441 100644
--- a/peripheral/libupm/examples/java/HP20xExample.java
+++ b/peripheral/libupm/examples/java/HP20xExample.java
@@ -42,7 +42,7 @@ public class HP20xExample {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occured: "+e.getMessage());
+ System.out.println("The following exception occurred: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/MAX31855Example.java b/peripheral/libupm/examples/java/MAX31855Example.java
new file mode 100644
index 0000000..1b1127e
--- /dev/null
+++ b/peripheral/libupm/examples/java/MAX31855Example.java
@@ -0,0 +1,56 @@
+/*
+ * Author: Abhishek Malik <abhishek.malik@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_max31855.MAX31855;
+
+public class MAX31855Example {
+
+ static {
+ try {
+ System.loadLibrary("javaupm_max31855");
+ System.loadLibrary("mraajava");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println(
+ "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
+ e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ //! [Interesting]
+ MAX31855 sensor = new MAX31855(0, 8);
+ while(true){
+ System.out.println("Temperature: "+sensor.getTemp());
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ System.out.println("The following exception occured: "+e.getMessage());
+ }
+ }
+ //! [Interesting]
+ }
+
+} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/MAX5487Example.java b/peripheral/libupm/examples/java/MAX5487Example.java
new file mode 100644
index 0000000..92b5331
--- /dev/null
+++ b/peripheral/libupm/examples/java/MAX5487Example.java
@@ -0,0 +1,71 @@
+/*
+ * Author: Abhishek Malik <abhishek.malik@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_max5487.MAX5487;
+
+public class MAX5487Example {
+
+ static {
+ try {
+ System.loadLibrary("javaupm_max5487");
+ System.loadLibrary("mraajava");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println(
+ "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
+ e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ //! [Interesting]
+ MAX5487 sensor = new MAX5487(7);
+
+ // Power LED UP
+ for(int i=0; i<255; i++){
+ sensor.setWiperA((short)i);
+ try {
+ Thread.sleep(5);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ System.out.println("The following Exception occured: "+e.getMessage());
+ }
+ }
+
+ // Power LED DOWN
+ for(int i=0; i<255; i++){
+ sensor.setWiperA((short)(255 - i));
+ try {
+ Thread.sleep(5);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ System.out.println("The following exception occured: "+e.getMessage());
+ }
+ }
+
+ System.out.println("Exiting...");
+ //! [Interesting]
+ }
+
+} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/MAXds3231mExample.java b/peripheral/libupm/examples/java/MAXds3231mExample.java
new file mode 100644
index 0000000..12e6dba
--- /dev/null
+++ b/peripheral/libupm/examples/java/MAXds3231mExample.java
@@ -0,0 +1,79 @@
+/*
+ * Author: Abhishek Malik <abhishek.malik@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_maxds3231m.MAXDS3231M;
+import upm_maxds3231m.Time3231;
+
+public class MAXds3231mExample {
+
+ static {
+ try {
+ System.loadLibrary("javaupm_maxds3231m");
+ System.loadLibrary("mraajava");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println(
+ "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
+ e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ //! [Interesting]
+ MAXDS3231M sensor = new MAXDS3231M(upm_maxds3231m.javaupm_maxds3231mConstants.ADDR);
+ Time3231 t = new Time3231();
+
+ t.setSecond((short)1);
+ t.setMinute((short)3);
+ t.setHour((short)3);
+ t.setDay((short)3);
+ t.setMonth((short)3);
+ t.setYear((short)3);
+ t.setWeekDay((short)3);
+
+ sensor.setDate(t);
+
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ System.out.println("The following exception occured: "+e.getMessage());
+ }
+
+ while(true){
+ if(sensor.getDate(t)){
+ System.out.println(t.getHour()+":"+t.getMinute()+":"+t.getSecond());
+ }
+ System.out.println("Temperature: "+sensor.getTemperature());
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ System.out.println("The following exception occcured: "+e.getMessage());
+ }
+ }
+ //! [Interesting]
+ }
+
+} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/SM130Example.java b/peripheral/libupm/examples/java/SM130Example.java
new file mode 100644
index 0000000..16f056d
--- /dev/null
+++ b/peripheral/libupm/examples/java/SM130Example.java
@@ -0,0 +1,69 @@
+/*
+ * Author: Abhishek Malik <abhishek.malik@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_sm130.SM130;
+
+public class SM130Example {
+
+ static {
+ try {
+ System.loadLibrary("javaupm_sm130");
+ System.loadLibrary("mraajava");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println(
+ "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
+ e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ //! [Interesting]
+ // Instantiate a UART based SM130 RFID Module using defaults
+ SM130 sensor = new SM130();
+
+ // set the baud rate. 19200 baud is the default.
+ if(sensor.setBaudRate(19200) == 1){
+ System.out.println("Failed to set baud rate");
+ return;
+ }
+
+ System.out.println("Resetting...");
+ sensor.reset();
+
+ System.out.println("Firmware revision: "+sensor.getFirmwareVersion());
+ System.out.println("Waiting up to 5 seconds for a tag...");
+
+ if(sensor.waitForTag(5000)){
+ System.out.println("Found tag, UID: "+sensor.string2HexString(sensor.getUID()));
+ System.out.println("Tag Type: "+sensor.tag2String(sensor.getTagType()));
+ }
+ else{
+ // error
+ System.out.println("waitForTag failed: "+sensor.getLastErrorString());
+ }
+ //! [Interesting]
+ }
+
+} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/T8100_Example.java b/peripheral/libupm/examples/java/T8100_Example.java
new file mode 100644
index 0000000..162c23f
--- /dev/null
+++ b/peripheral/libupm/examples/java/T8100_Example.java
@@ -0,0 +1,97 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_t8100.T8100;
+
+public class T8100_Example
+{
+ private static String defaultDev = "/dev/ttyUSB0";
+
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // You will need to edit this example to conform to your site
+ // and your devices, specifically the Device Object Instance
+ // ID passed to the constructor, and the arguments to
+ // initMaster() that are appropriate for your BACnet network.
+
+ if (args.length > 0)
+ defaultDev = args[0];
+ System.out.println("Using device " + defaultDev);
+ System.out.println("Initializing...");
+
+ // Instantiate an T8100 object for an T8100 device that has
+ // 568000 as it's unique Device Object Instance ID. NOTE: You
+ // will certainly want to change this to the correct value for
+ // your device(s).
+ T8100 sensor = new T8100(568000);
+
+ // Initialize our BACnet master, if it has not already been
+ // initialized, with the device and baudrate, choosing 1000001
+ // as our unique Device Object Instance ID, 2 as our MAC
+ // address and using default values for maxMaster and
+ // maxInfoFrames
+ sensor.initMaster(defaultDev, 38400, 1000001, 2);
+
+ // Uncomment to enable debugging output
+ // sensor.setDebug(true);
+
+ System.out.println();
+ System.out.println("Device Description: "
+ + sensor.getDeviceDescription());
+ System.out.println("Device Location: " + sensor.getDeviceLocation());
+ System.out.println();
+
+ // update and print a few values every 5 seconds
+ while (true)
+ {
+ // update our values
+ sensor.update();
+
+ System.out.println("CO2 Concentration: "
+ + sensor.getCO2()
+ + " ppm");
+
+ // we show both C and F for temperature
+ System.out.println("Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ System.out.println("Humidity: "
+ + sensor.getHumidity()
+ + " %RH");
+
+ System.out.println("Relay State: "
+ + sensor.getRelayState());
+
+ System.out.println();
+ Thread.sleep(5000);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/TB7300_Example.java b/peripheral/libupm/examples/java/TB7300_Example.java
new file mode 100644
index 0000000..250dcdf
--- /dev/null
+++ b/peripheral/libupm/examples/java/TB7300_Example.java
@@ -0,0 +1,99 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_tb7300.TB7300;
+
+public class TB7300_Example
+{
+ private static String defaultDev = "/dev/ttyUSB0";
+
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+
+ // You will need to edit this example to conform to your site
+ // and your devices, specifically the Device Object Instance
+ // ID passed to the constructor, and the arguments to
+ // initMaster() that are appropriate for your BACnet network.
+
+ if (args.length > 0)
+ defaultDev = args[0];
+ System.out.println("Using device " + defaultDev);
+ System.out.println("Initializing...");
+
+ // Instantiate an TB7300 object for an TB7300 device that has
+ // 73001 as it's unique Device Object Instance ID. NOTE: You
+ // will certainly want to change this to the correct value for
+ // your device(s).
+ TB7300 sensor = new TB7300(73001);
+
+ // Initialize our BACnet master, if it has not already been
+ // initialized, with the device and baudrate, choosing 1000001
+ // as our unique Device Object Instance ID, 2 as our MAC
+ // address and using default values for maxMaster and
+ // maxInfoFrames
+ sensor.initMaster(defaultDev, 38400, 1000001, 2);
+
+ // Uncomment to enable debugging output
+ // sensor.setDebug(true);
+
+ System.out.println();
+ System.out.println("Device Name: "
+ + sensor.getDeviceName());
+ System.out.println("Device Description: "
+ + sensor.getDeviceDescription());
+ System.out.println("Device Location: " + sensor.getDeviceLocation());
+ System.out.println();
+
+ System.out.println("Fan Mode: "
+ + sensor.getMultiStateValueText(TB7300.MULTISTATE_VALUES_T.MV_Fan_Mode));
+ System.out.println("Fan Status: "
+ + sensor.getMultiStateValueText(TB7300.MULTISTATE_VALUES_T.MV_Fan_Status));
+ System.out.println("System Mode: "
+ + sensor.getMultiStateValueText(TB7300.MULTISTATE_VALUES_T.MV_System_Mode));
+ System.out.println("Service Alarm:"
+ + sensor.getBinaryInputText(TB7300.BINARY_INPUTS_T.BI_Service_Alarm));
+
+ System.out.println();
+
+ // update and print the room temperature every 5 seconds
+ while (true)
+ {
+ // update our values
+ sensor.update();
+
+ // we show both C and F for temperature
+ System.out.println("Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ System.out.println();
+ Thread.sleep(5000);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/TEAMS_Example.java b/peripheral/libupm/examples/java/TEAMS_Example.java
new file mode 100644
index 0000000..caeda6f
--- /dev/null
+++ b/peripheral/libupm/examples/java/TEAMS_Example.java
@@ -0,0 +1,64 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_teams.TEAMS;
+
+public class TEAMS_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+ System.out.println("Initializing...");
+
+ // Instantiate an TEAMS instance, using A0 for temperature, and
+ // 165.0 ohms for the rResistor value (for the libelium 4-20ma
+ // interface)
+ TEAMS sensor = new TEAMS(0, 165.0f);
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ // is the sensor connected? (current >= 4ma)
+ System.out.println("Is Connected: " + sensor.isConnected());
+
+ // print computed current on the loop. This includes
+ // the offset, if one was set by setOffsetMilliamps().
+ System.out.println("Milliamps: " + sensor.getRawMilliamps());
+
+ // we show both C and F for temperature
+ System.out.println("Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ System.out.println();
+ Thread.sleep(1000);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/TEX00_Example.java b/peripheral/libupm/examples/java/TEX00_Example.java
new file mode 100644
index 0000000..b2e307b
--- /dev/null
+++ b/peripheral/libupm/examples/java/TEX00_Example.java
@@ -0,0 +1,71 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_tex00.TEX00;
+
+public class TEX00_Example
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+ System.out.println("Initializing...");
+
+ // Instantiate an TEX00 instance, using A0 for the analog input. In
+ // this example, we are using a 10K Ohm balance resistor and a TED
+ // (10k type 2) thermistor.
+ TEX00 sensor = new TEX00(0, 10000.0f,
+ TEX00.SENSOR_TYPES_T.STYPE_THERMISTOR_TED);
+
+ System.out.println("Minimum temperature: "
+ + sensor.getTemperatureRangeMin());
+ System.out.println("Maximum temperature: "
+ + sensor.getTemperatureRangeMax());
+ System.out.println();
+
+ while (true)
+ {
+ // update our values from the sensor
+ sensor.update();
+
+ if (sensor.isOutOfRange())
+ {
+ System.out.println("Temperature out of range");
+ }
+ else
+ {
+ // we show both C and F for temperature
+ System.out.println("Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+ }
+
+ System.out.println();
+ Thread.sleep(1000);
+ }
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/Th02Example.java b/peripheral/libupm/examples/java/Th02Example.java
index f2a97c4..206f89e 100644
--- a/peripheral/libupm/examples/java/Th02Example.java
+++ b/peripheral/libupm/examples/java/Th02Example.java
@@ -25,18 +25,6 @@ import upm_th02.TH02;
public class Th02Example {
- static {
- try {
- System.loadLibrary("javaupm_th02");
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
public static void main(String[] args) {
// TODO Auto-generated method stub
float temperature = 0;
@@ -51,7 +39,7 @@ public class Th02Example {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception has occured: "+e.getMessage());
+ System.out.println("The following exception has occurred: "+e.getMessage());
}
}
}
diff --git a/peripheral/libupm/examples/java/Tsl2561.java b/peripheral/libupm/examples/java/Tsl2561.java
new file mode 100644
index 0000000..895b2e5
--- /dev/null
+++ b/peripheral/libupm/examples/java/Tsl2561.java
@@ -0,0 +1,61 @@
+/*
+ * Author: Abhishek Malik <abhishek.malik@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_tsl2561.TSL2561;
+
+public class Tsl2561 {
+
+ static {
+ try {
+ System.loadLibrary("javaupm_tsl2561");
+ System.loadLibrary("mraajava");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println(
+ "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
+ e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ //! [Interesting]
+ TSL2561 sensor = null;
+ int loopCount = 100;
+ // Instantiate the sensor object
+ sensor = new TSL2561();
+
+ for (int i=0; i<loopCount; i++){
+ // retrieving and displaying the Lux value
+ System.out.println("Lux: "+sensor.getLux());
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ System.out.println("The following exception occurred: "+e.getMessage());
+ }
+ }
+ //! [Interesting]
+ }
+
+}
diff --git a/peripheral/libupm/examples/java/VCAP_Example.java b/peripheral/libupm/examples/java/VCAP_Example.java
new file mode 100644
index 0000000..73d06ad
--- /dev/null
+++ b/peripheral/libupm/examples/java/VCAP_Example.java
@@ -0,0 +1,60 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.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_vcap.VCAP;
+
+public class VCAP_Example
+{
+ private static String defaultDev = "/dev/video0";
+
+ public static void main(String[] args) throws InterruptedException
+ {
+// ! [Interesting]
+ if (args.length > 0)
+ defaultDev = args[0];
+
+ System.out.println("Using device " + defaultDev);
+ System.out.println("Initializing...");
+
+ // Instantiate an VCAP instance, using the specified video device
+ VCAP sensor = new VCAP(defaultDev);
+
+ // enable some debug/verbose output
+ sensor.setDebug(true);
+
+ // This is just a hint. The kernel can change this to a lower
+ // resolution that the hardware supports. Use getWidth() and
+ // getHeight() methods to see what the kernel actually chose if you
+ // care.
+ sensor.setResolution(1920, 1080);
+
+ // capture an image
+ sensor.captureImage();
+
+ // convert and save it as a jpeg
+ sensor.saveImage("video-img1.jpg");
+
+// ! [Interesting]
+ }
+}
diff --git a/peripheral/libupm/examples/java/WaterLevelSensor.java b/peripheral/libupm/examples/java/WaterLevelSensor.java
index d08aaee..c13ec5b 100644
--- a/peripheral/libupm/examples/java/WaterLevelSensor.java
+++ b/peripheral/libupm/examples/java/WaterLevelSensor.java
@@ -43,7 +43,7 @@ public class WaterLevelSensor {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occured: "+e.getMessage());
+ System.out.println("The following exception occurred: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/javascript/apa102.js b/peripheral/libupm/examples/javascript/apa102.js
new file mode 100644
index 0000000..c8b841f
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/apa102.js
@@ -0,0 +1,44 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+/*
+* Author: Yannick Adam <yannick.adam@gmail.com>
+* Copyright (c) 2016 Yannick Adam
+*
+* 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.
+*/
+
+var lib = require('jsupm_apa102');
+
+// Instantiate a strip of 30 LEDs on SPI Bus 0
+var ledStrip = new lib.APA102(30, 0);
+
+// Set all LEDs to blue
+ledStrip.setAllLeds(31, 0, 0, 255);
+
+// Set a mid-section to red
+ledStrip.setLeds(10,20, 31, 255, 0, 0);
+
+// Set a single led to green
+ledStrip.setLed(15, 31, 0, 255, 0);
+
+
+// Exit
+ledStrip = null;
+process.exit(0);
diff --git a/peripheral/libupm/examples/javascript/bma250e.js b/peripheral/libupm/examples/javascript/bma250e.js
new file mode 100644
index 0000000..55780d7
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bma250e.js
@@ -0,0 +1,72 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+var sensorObj = require('jsupm_bmx055');
+
+// Instantiate a BMA250E instance using default i2c bus and address
+var sensor = new sensorObj.BMA250E();
+
+// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+// BMA250E(0, -1, 10);
+
+var x = new sensorObj.new_floatp();
+var y = new sensorObj.new_floatp();
+var z = new sensorObj.new_floatp();
+
+// now output data every 250 milliseconds
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ sensor.getAccelerometer(x, y, z);
+ console.log("Accelerometer x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " g");
+
+ // we show both C and F for temperature
+ console.log("Compensation Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ console.log();
+
+}, 250);
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/bmc150.js b/peripheral/libupm/examples/javascript/bmc150.js
new file mode 100644
index 0000000..a3e2900
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bmc150.js
@@ -0,0 +1,69 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+var sensorObj = require('jsupm_bmx055');
+
+// Instantiate a BMC150 instance using default i2c bus and address
+var sensor = new sensorObj.BMC150();
+
+var x = new sensorObj.new_floatp();
+var y = new sensorObj.new_floatp();
+var z = new sensorObj.new_floatp();
+
+// now output data every 250 milliseconds
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ sensor.getAccelerometer(x, y, z);
+ console.log("Accelerometer x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " g");
+
+ sensor.getMagnetometer(x, y, z);
+ console.log("Magnetometer x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " uT");
+
+ console.log();
+
+}, 250);
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/bme280.js b/peripheral/libupm/examples/javascript/bme280.js
new file mode 100644
index 0000000..a183c3f
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bme280.js
@@ -0,0 +1,71 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+var sensorObj = require('jsupm_bmp280');
+
+// Instantiate a BME280 instance using default i2c bus and address
+var sensor = new sensorObj.BME280();
+
+// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+// BME280(0, -1, 10);
+
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ console.log("Compensation Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ console.log("Pressure: "
+ + sensor.getPressure()
+ + " Pa");
+
+ console.log("Computed Altitude: "
+ + sensor.getAltitude()
+ + " m");
+
+ console.log("Humidity: "
+ + sensor.getHumidity()
+ + " %RH");
+
+ console.log();
+
+}, 1000);
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/bmg160.js b/peripheral/libupm/examples/javascript/bmg160.js
new file mode 100644
index 0000000..96f46a1
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bmg160.js
@@ -0,0 +1,72 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+var sensorObj = require('jsupm_bmx055');
+
+// Instantiate a BMG160 instance using default i2c bus and address
+var sensor = new sensorObj.BMG160();
+
+// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+// BMG160(0, -1, 10);
+
+var x = new sensorObj.new_floatp();
+var y = new sensorObj.new_floatp();
+var z = new sensorObj.new_floatp();
+
+// now output data every 250 milliseconds
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ sensor.getGyroscope(x, y, z);
+ console.log("Gyroscope x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " degrees/s");
+
+ // we show both C and F for temperature
+ console.log("Compensation Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ console.log();
+
+}, 250);
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/bmi055.js b/peripheral/libupm/examples/javascript/bmi055.js
new file mode 100644
index 0000000..4711071
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bmi055.js
@@ -0,0 +1,69 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+var sensorObj = require('jsupm_bmx055');
+
+// Instantiate a BMI055 instance using default i2c bus and address
+var sensor = new sensorObj.BMI055();
+
+var x = new sensorObj.new_floatp();
+var y = new sensorObj.new_floatp();
+var z = new sensorObj.new_floatp();
+
+// now output data every 250 milliseconds
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ sensor.getAccelerometer(x, y, z);
+ console.log("Accelerometer x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " g");
+
+ sensor.getGyroscope(x, y, z);
+ console.log("Gyroscope x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " degrees/s");
+
+ console.log();
+
+}, 250);
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/bmi160.js b/peripheral/libupm/examples/javascript/bmi160.js
new file mode 100644
index 0000000..4df790e
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bmi160.js
@@ -0,0 +1,71 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_bmi160');
+
+// Instantiate a BMI160 instance using default i2c bus and address
+var sensor = new sensorObj.BMI160();
+
+var x = new sensorObj.new_floatp();
+var y = new sensorObj.new_floatp();
+var z = new sensorObj.new_floatp();
+
+// Output data every half second until interrupted
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ sensor.getAccelerometer(x, y, z);
+ console.log("Accelerometer: AX: " + sensorObj.floatp_value(x) +
+ " AY: " + sensorObj.floatp_value(y) +
+ " AZ: " + sensorObj.floatp_value(z));
+
+ sensor.getGyroscope(x, y, z);
+ console.log("Gyroscope: GX: " + sensorObj.floatp_value(x) +
+ " AY: " + sensorObj.floatp_value(y) +
+ " AZ: " + sensorObj.floatp_value(z));
+
+ sensor.getMagnetometer(x, y, z);
+ console.log("Magnetometer: MX: " + sensorObj.floatp_value(x) +
+ " MY: " + sensorObj.floatp_value(y) +
+ " MZ: " + sensorObj.floatp_value(z));
+
+ console.log();
+
+}, 500);
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/bmm150.js b/peripheral/libupm/examples/javascript/bmm150.js
new file mode 100644
index 0000000..8274aa9
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bmm150.js
@@ -0,0 +1,65 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+var sensorObj = require('jsupm_bmx055');
+
+// Instantiate a BMM150 instance using default i2c bus and address
+var sensor = new sensorObj.BMM150();
+
+// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+// BMM150(0, -1, 10);
+
+var x = new sensorObj.new_floatp();
+var y = new sensorObj.new_floatp();
+var z = new sensorObj.new_floatp();
+
+// now output data every 250 milliseconds
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ sensor.getMagnetometer(x, y, z);
+ console.log("Magnetometer x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " uT");
+
+ console.log();
+
+}, 250);
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/bmp280.js b/peripheral/libupm/examples/javascript/bmp280.js
new file mode 100644
index 0000000..57a9a70
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bmp280.js
@@ -0,0 +1,67 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+var sensorObj = require('jsupm_bmp280');
+
+// Instantiate a BMP280 instance using default i2c bus and address
+var sensor = new sensorObj.BMP280();
+
+// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+// BMP280(0, -1, 10);
+
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ console.log("Compensation Temperature: "
+ + sensor.getTemperature()
+ + " C / "
+ + sensor.getTemperature(true)
+ + " F");
+
+ console.log("Pressure: "
+ + sensor.getPressure()
+ + " Pa");
+
+ console.log("Computed Altitude: "
+ + sensor.getAltitude()
+ + " m");
+
+ console.log();
+
+}, 1000);
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/bmx055.js b/peripheral/libupm/examples/javascript/bmx055.js
new file mode 100644
index 0000000..7b0e9b9
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bmx055.js
@@ -0,0 +1,76 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+var sensorObj = require('jsupm_bmx055');
+
+// Instantiate a BMX055 instance using default i2c bus and address
+var sensor = new sensorObj.BMX055();
+
+var x = new sensorObj.new_floatp();
+var y = new sensorObj.new_floatp();
+var z = new sensorObj.new_floatp();
+
+// now output data every 250 milliseconds
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ sensor.getAccelerometer(x, y, z);
+ console.log("Accelerometer x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " g");
+
+ sensor.getGyroscope(x, y, z);
+ console.log("Gyroscope x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " degrees/s");
+
+ sensor.getMagnetometer(x, y, z);
+ console.log("Magnetometer x: "
+ + sensorObj.floatp_value(x)
+ + " y: " + sensorObj.floatp_value(y)
+ + " z: " + sensorObj.floatp_value(z)
+ + " uT");
+
+ console.log();
+
+}, 250);
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/bno055.js b/peripheral/libupm/examples/javascript/bno055.js
new file mode 100644
index 0000000..b9a9f32
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/bno055.js
@@ -0,0 +1,117 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_bno055');
+
+// Instantiate an BNO055 using default parameters (bus 0, addr
+// 0x28). The default running mode is NDOF absolute orientation
+// mode.
+var sensor = new sensorObj.BNO055();
+
+var mag = new sensorObj.new_intp();
+var acc = new sensorObj.new_intp();
+var gyr = new sensorObj.new_intp();
+var syst = new sensorObj.new_intp();
+
+var w = new sensorObj.new_floatp();
+var x = new sensorObj.new_floatp();
+var y = new sensorObj.new_floatp();
+var z = new sensorObj.new_floatp();
+
+console.log("First we need to calibrate. 4 numbers will be output every");
+console.log("second for each sensor. 0 means uncalibrated, and 3 means");
+console.log("fully calibrated.");
+console.log("See the UPM documentation on this sensor for instructions on");
+console.log("what actions are required to calibrate.");
+console.log("");
+
+// do the calibration...
+var calInterval = setInterval(function()
+{
+ if (sensor.isFullyCalibrated())
+ {
+ clearInterval(calInterval);
+ console.log("");
+ console.log("Calibration complete.");
+ console.log("");
+
+ setInterval(outputData, 250)
+ }
+ else
+ {
+ sensor.getCalibrationStatus(mag, acc, gyr, syst);
+ console.log("Magnetometer: " + sensorObj.intp_value(mag) +
+ " Accelerometer: " + sensorObj.intp_value(acc) +
+ " Gyroscope: " + sensorObj.intp_value(gyr) +
+ " System: " + sensorObj.intp_value(syst));
+ }
+
+}, 1000);
+
+
+// now output various fusion data every 250 milliseconds
+function outputData()
+{
+ sensor.update();
+
+ sensor.getEulerAngles(x, y, z);
+ console.log("Euler: Heading: " + sensorObj.floatp_value(x) +
+ " Roll: " + sensorObj.floatp_value(y) +
+ " Pitch: " + sensorObj.floatp_value(z) +
+ " degrees");
+
+ sensor.getQuaternions(w, x, y, z);
+ console.log("Quaternion: W: " + sensorObj.floatp_value(w) +
+ " X:" + sensorObj.floatp_value(x) +
+ " Y: " + sensorObj.floatp_value(y) +
+ " Z: " + sensorObj.floatp_value(z));
+
+ sensor.getLinearAcceleration(x, y, z);
+ console.log("Linear Acceleration: X: " + sensorObj.floatp_value(x) +
+ " Y: " + sensorObj.floatp_value(y) +
+ " Z: " + sensorObj.floatp_value(z) +
+ " m/s^2");
+
+ sensor.getGravityVectors(x, y, z);
+ console.log("Gravity Vector: X: " + sensorObj.floatp_value(x) +
+ " Y: " + sensorObj.floatp_value(y) +
+ " Z: " + sensorObj.floatp_value(z) +
+ " m/s^2");
+
+ console.log("");
+};
+
+// exit on ^C
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting.");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/curieimu.js b/peripheral/libupm/examples/javascript/curieimu.js
new file mode 100644
index 0000000..72bfea0
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/curieimu.js
@@ -0,0 +1,52 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+/*
+* Author: Ron Evans (@deadprogram)
+* 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.
+*/
+
+var mraa = require('mraa');
+console.log('MRAA Version: ' + mraa.getVersion());
+
+// open connection to Firmata
+mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0");
+
+var curieImu = require('jsupm_curieimu');
+var myCurie = new curieImu.CurieImu();
+
+var outputStr;
+var myInterval = setInterval(function()
+{
+ myCurie.updateAccel();
+ outputStr = "accel: x " + myCurie.getAccelX()
+ + " - y " + myCurie.getAccelY()
+ + " - z " + myCurie.getAccelZ();
+ console.log(outputStr);
+}, 500);
+
+// Print message when exiting
+process.on('SIGINT', function()
+{
+ clearInterval(myInterval);
+ console.log("Exiting");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/cwlsxxa.js b/peripheral/libupm/examples/javascript/cwlsxxa.js
new file mode 100644
index 0000000..46d9fe7
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/cwlsxxa.js
@@ -0,0 +1,66 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_cwlsxxa');
+
+
+/************** Main code **************/
+
+console.log("Initializing...");
+
+// Instantiate an CWLSXXA instance, using A0 for CO2, A1 for
+// humidity and A2 for temperature
+var sensor = new sensorObj.CWLSXXA(0, 1, 2);
+
+// update and print available values every second
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ // we show both C and F for temperature
+ console.log("Temperature:", sensor.getTemperature(),
+ "C /", sensor.getTemperature(true), "F");
+
+ console.log("Humidity:", sensor.getHumidity(), "%");
+
+ console.log("CO2:", sensor.getCO2(), "ppm");
+
+ console.log("");
+
+}, 1000);
+
+
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting...");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/ds18b20.js b/peripheral/libupm/examples/javascript/ds18b20.js
new file mode 100644
index 0000000..3c2835f
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/ds18b20.js
@@ -0,0 +1,70 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_ds18b20');
+
+
+/************** Main code **************/
+
+console.log("Initializing...");
+
+// Instantiate an DS18B20 instance using the default values (uart 0)
+var sensor = new sensorObj.DS18B20(0);
+
+// locate and setup our devices
+sensor.init();
+
+console.log("Found", sensor.devicesFound(), "device(s)");
+console.log("");
+
+if (!sensor.devicesFound())
+{
+ process.exit(1);
+}
+
+// update and print available values every second
+setInterval(function()
+{
+ // update our values for the first sensor
+ sensor.update(0);
+
+ // we show both C and F for temperature for the first sensor
+ console.log("Temperature:", sensor.getTemperature(0),
+ "C /", sensor.getTemperature(0, true), "F");
+
+}, 1000);
+
+
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting...");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/ds2413.js b/peripheral/libupm/examples/javascript/ds2413.js
new file mode 100644
index 0000000..069be3a
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/ds2413.js
@@ -0,0 +1,55 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_ds2413');
+
+
+/************** Main code **************/
+// Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
+var sensor = new sensorObj.DS2413(0);
+
+// find all of the DS2413 devices present on the bus
+sensor.init();
+
+// how many devices were found?
+console.log("Found", sensor.devicesFound(), "device(s)");
+
+// read the gpio and latch values from the first device
+// the lower 4 bits are of the form:
+// <gpioB latch> <gpioB value> <gpioA latch> <gpioA value>
+console.log("GPIO device 0 values:", sensor.readGpios(0));
+
+// set the gpio latch values of the first device
+console.log("Setting GPIO latches to on");;
+sensor.writeGpios(0, 0x03);
+
+sensor = null;
+sensorObj.cleanUp();
+sensorObj = null;
+console.log("Exiting...");
+process.exit(0);
diff --git a/peripheral/libupm/examples/javascript/e50hx.js b/peripheral/libupm/examples/javascript/e50hx.js
new file mode 100644
index 0000000..692d9f5
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/e50hx.js
@@ -0,0 +1,101 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_e50hx');
+
+
+/************** Main code **************/
+
+// You will need to edit this example to conform to your site and your
+// devices, specifically the Device Object Instance ID passed to the
+// constructor, and the arguments to initMaster() that are
+// appropriate for your BACnet network.
+
+var defaultDev = "/dev/ttyUSB0";
+
+// if an argument was specified, use it as the device instead
+if (process.argv.length > 2)
+{
+ defaultDev = process.argv[2];
+}
+
+console.log("Using device " + defaultDev);
+console.log("Initializing...");
+
+// Instantiate an E50HX object for an E50HX device that has 1075425
+// as it's unique Device Object Instance ID. NOTE: You will
+// certainly want to change this to the correct value for your
+// device(s).
+var sensor = new sensorObj.E50HX(1075425);
+
+// Initialize our BACnet master, if it has not already been
+// initialized, with the device and baudrate, choosing 1000001 as
+// our unique Device Object Instance ID, 2 as our MAC address and
+// using default values for maxMaster and maxInfoFrames
+sensor.initMaster(defaultDev, 38400, 1000001, 2);
+
+// Uncomment to enable debugging output
+// sensor.setDebug(true);
+
+console.log("");
+console.log("Device Description:", sensor.getDeviceDescription());
+console.log("Device Location:", sensor.getDeviceLocation());
+console.log("");
+
+// update and print a few values every 5 seconds
+setInterval(function()
+{
+ console.log("System Voltage:",
+ sensor.getAnalogValue(sensorObj.E50HX.AV_System_Voltage),
+ " ",
+ sensor.getAnalogValueUnits(sensorObj.E50HX.AV_System_Voltage));
+
+ console.log("System Type:",
+ sensor.getAnalogValue(sensorObj.E50HX.AV_System_Type));
+
+ console.log("Energy Consumption:",
+ sensor.getAnalogInput(sensorObj.E50HX.AI_Energy),
+ " ",
+ sensor.getAnalogInputUnits(sensorObj.E50HX.AI_Energy));
+
+ console.log("Power Up Counter:",
+ sensor.getAnalogInput(sensorObj.E50HX.AI_Power_Up_Count));
+
+ console.log("");
+
+}, 5000);
+
+
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting...");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/h803x.js b/peripheral/libupm/examples/javascript/h803x.js
new file mode 100644
index 0000000..23fe5d8
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/h803x.js
@@ -0,0 +1,115 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_h803x');
+
+
+/************** Main code **************/
+
+var defaultDev = "/dev/ttyUSB0";
+
+// if an argument was specified, use it as the device instead
+if (process.argv.length > 2)
+{
+ defaultDev = process.argv[2];
+}
+
+console.log("Using device " + defaultDev);
+console.log("Initializing...");
+
+// Instantiate an H803X instance, using MODBUS slave address 1, and
+// default comm parameters (9600, 8, N, 2)
+var sensor = new sensorObj.H803X(defaultDev, 1);
+
+// output the Slave ID (manufacturer, model, serno)
+console.log("Slave ID:", sensor.getSlaveID());
+
+console.log("");
+
+// update and print available values every second
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ // H8035 / H8036
+ console.log("Consumption (kWh):", sensor.getConsumption());
+ console.log("Real Power (kW):", sensor.getRealPower());
+
+ if (sensor.isH8036())
+ {
+ // The H8036 has much more data available...
+
+ console.log("Reactive Power (kVAR):", sensor.getReactivePower());
+ console.log("Apparent Power (kVA):", sensor.getApparentPower());
+ console.log("Power Factor:", sensor.getPowerFactor());
+ console.log("Volts Line to Line:", sensor.getVoltsLineToLine());
+ console.log("Volts Line to Neutral:", sensor.getVoltsLineToNeutral());
+
+ console.log("Current:", sensor.getCurrent());
+
+ console.log("Real Power Phase A (kW):", sensor.getRealPowerPhaseA());
+ console.log("Real Power Phase B (kW):", sensor.getRealPowerPhaseB());
+ console.log("Real Power Phase C (kW):", sensor.getRealPowerPhaseC());
+
+ console.log("Power Factor Phase A:", sensor.getPowerFactorPhaseA());
+ console.log("Power Factor Phase B:", sensor.getPowerFactorPhaseB());
+ console.log("Power Factor Phase C:", sensor.getPowerFactorPhaseC());
+
+ console.log("Volts Phase A to B:", sensor.getVoltsPhaseAToB());
+ console.log("Volts Phase B to C:", sensor.getVoltsPhaseBToC());
+ console.log("Volts Phase A to C:", sensor.getVoltsPhaseAToC());
+ console.log("Volts Phase A to Neutral: ",
+ sensor.getVoltsPhaseAToNeutral());
+ console.log("Volts Phase B to Neutral: ",
+ sensor.getVoltsPhaseBToNeutral());
+ console.log("Volts Phase C to Neutral: ",
+ sensor.getVoltsPhaseCToNeutral());
+
+ console.log("Current Phase A:", sensor.getCurrentPhaseA());
+ console.log("Current Phase B:", sensor.getCurrentPhaseB());
+ console.log("Current Phase C:", sensor.getCurrentPhaseC());
+
+ console.log("Avg Real Power (kW):", sensor.getAvgRealPower());
+ console.log("Min Real Power (kW):", sensor.getMinRealPower());
+ console.log("Max Real Power (kW):", sensor.getMaxRealPower());
+ }
+
+ console.log("");
+
+}, 2000);
+
+
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting...");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/hmtrp.js b/peripheral/libupm/examples/javascript/hmtrp.js
index 3bdd0f2..94a803d 100644
--- a/peripheral/libupm/examples/javascript/hmtrp.js
+++ b/peripheral/libupm/examples/javascript/hmtrp.js
@@ -128,7 +128,7 @@ function runRadio()
console.log("Received: " + resultStr);
}
- if (rv < 0) // some sort of read error occured
+ if (rv < 0) // some sort of read error occurred
{
console.log("Port read error.");
return;
diff --git a/peripheral/libupm/examples/javascript/oled_ssd1306.js b/peripheral/libupm/examples/javascript/oled_ssd1306.js
index b3ceac7..95cc9d8 100644
--- a/peripheral/libupm/examples/javascript/oled_ssd1306.js
+++ b/peripheral/libupm/examples/javascript/oled_ssd1306.js
@@ -90,7 +90,7 @@ function exit()
// Load i2clcd module
var lcdObj = require('jsupm_i2clcd');
-var lcd = new lcdObj.SSD1306(6, 0x3c);
+var lcd = new lcdObj.SSD1306(0, 0x3C);
var next = 0;
lcd.clear();
diff --git a/peripheral/libupm/examples/javascript/t8100.js b/peripheral/libupm/examples/javascript/t8100.js
new file mode 100644
index 0000000..7be2fad
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/t8100.js
@@ -0,0 +1,98 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_t8100');
+
+
+/************** Main code **************/
+
+// You will need to edit this example to conform to your site and your
+// devices, specifically the Device Object Instance ID passed to the
+// constructor, and the arguments to initMaster() that are
+// appropriate for your BACnet network.
+
+var defaultDev = "/dev/ttyUSB0";
+
+// if an argument was specified, use it as the device instead
+if (process.argv.length > 2)
+{
+ defaultDev = process.argv[2];
+}
+
+console.log("Using device " + defaultDev);
+console.log("Initializing...");
+
+// Instantiate an T8100 object for an T8100 device that has 568000
+// as it's unique Device Object Instance ID. NOTE: You will
+// certainly want to change this to the correct value for your
+// device(s).
+var sensor = new sensorObj.T8100(568000);
+
+// Initialize our BACnet master, if it has not already been
+// initialized, with the device and baudrate, choosing 1000001 as
+// our unique Device Object Instance ID, 2 as our MAC address and
+// using default values for maxMaster and maxInfoFrames
+sensor.initMaster(defaultDev, 38400, 1000001, 2);
+
+// Uncomment to enable debugging output
+// sensor.setDebug(true);
+
+console.log("");
+console.log("Device Description:", sensor.getDeviceDescription());
+console.log("Device Location:", sensor.getDeviceLocation());
+console.log("");
+
+// update and print a few values every 5 seconds
+setInterval(function()
+{
+ // update our values
+ sensor.update();
+
+ console.log("CO2 Concentration:", sensor.getCO2(), "ppm");
+
+ // we show both C and F for temperature
+ console.log("Temperature:", sensor.getTemperature(),
+ "C /", sensor.getTemperature(true), "F");
+
+ console.log("Humidity:", sensor.getHumidity(), "%RH");
+
+ console.log("Relay State:", sensor.getRelayState());
+
+ console.log("");
+
+}, 5000);
+
+
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting...");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/tb7300.js b/peripheral/libupm/examples/javascript/tb7300.js
new file mode 100644
index 0000000..8188a86
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/tb7300.js
@@ -0,0 +1,102 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_tb7300');
+
+
+/************** Main code **************/
+
+// You will need to edit this example to conform to your site and your
+// devices, specifically the Device Object Instance ID passed to the
+// constructor, and the arguments to initMaster() that are
+// appropriate for your BACnet network.
+
+var defaultDev = "/dev/ttyUSB0";
+
+// if an argument was specified, use it as the device instead
+if (process.argv.length > 2)
+{
+ defaultDev = process.argv[2];
+}
+
+console.log("Using device " + defaultDev);
+console.log("Initializing...");
+
+// Instantiate an TB7300 object for an TB7300 device that has 73001
+// as it's unique Device Object Instance ID. NOTE: You will
+// certainly want to change this to the correct value for your
+// device(s).
+var sensor = new sensorObj.TB7300(73001);
+
+// Initialize our BACnet master, if it has not already been
+// initialized, with the device and baudrate, choosing 1000001 as
+// our unique Device Object Instance ID, 2 as our MAC address and
+// using default values for maxMaster and maxInfoFrames
+sensor.initMaster(defaultDev, 38400, 1000001, 2);
+
+// Uncomment to enable debugging output
+// sensor.setDebug(true);
+
+console.log("");
+console.log("Device Name:", sensor.getDeviceName());
+console.log("Device Description:", sensor.getDeviceDescription());
+console.log("Device Location:", sensor.getDeviceLocation());
+console.log("");
+
+console.log("Fan Mode:",
+ sensor.getMultiStateValueText(sensorObj.TB7300.MV_Fan_Mode));
+console.log("Fan Status:",
+ sensor.getMultiStateValueText(sensorObj.TB7300.MV_Fan_Status));
+console.log("System Mode:",
+ sensor.getMultiStateValueText(sensorObj.TB7300.MV_System_Mode));
+console.log("Service Alarm:",
+ sensor.getBinaryInputText(sensorObj.TB7300.BI_Service_Alarm));
+console.log("");
+
+// update and print the room temperature every 5 seconds
+setInterval(function()
+{
+ // update our values
+ sensor.update();
+
+ // we show both C and F for temperature
+ console.log("Temperature:", sensor.getTemperature(),
+ "C /", sensor.getTemperature(true), "F");
+ console.log("");
+
+}, 5000);
+
+
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting...");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/teams.js b/peripheral/libupm/examples/javascript/teams.js
new file mode 100644
index 0000000..5c5b883
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/teams.js
@@ -0,0 +1,70 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_teams');
+
+
+/************** Main code **************/
+
+console.log("Initializing...");
+
+// Instantiate an TEAMS instance, using A0 for temperature, and
+// 165.0 ohms for the rResistor value (for the libelium 4-20ma
+// interface)
+var sensor = new sensorObj.TEAMS(0, 165.0);
+
+// update and print available values every second
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ // is the sensor connected? (current >= 4ma)
+ console.log("Is Connected:", sensor.isConnected());
+
+ // print computed current on the loop. This includes the offset,
+ // if one was set by setOffsetMilliamps().
+ console.log("Milliamps:", sensor.getRawMilliamps());
+
+ // we show both C and F for temperature
+ console.log("Temperature:", sensor.getTemperature(),
+ "C /", sensor.getTemperature(true), "F");
+
+ console.log("");
+
+}, 1000);
+
+
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting...");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/tex00.js b/peripheral/libupm/examples/javascript/tex00.js
new file mode 100644
index 0000000..38b2b30
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/tex00.js
@@ -0,0 +1,77 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_tex00');
+
+
+/************** Main code **************/
+
+console.log("Initializing...");
+
+// Instantiate an TEX00 instance, using A0 for the analog input. In
+// this example, we are using a 10K Ohm balance resistor and a TED
+// (10k type 2) thermistor.
+var sensor = new sensorObj.TEX00(0, 10000,
+ sensorObj.TEX00.STYPE_THERMISTOR_TED);
+
+console.log("Minimum temperature:", sensor.getTemperatureRangeMin(),
+ "C");
+console.log("Maximum temperature:", sensor.getTemperatureRangeMax(),
+ "C");
+console.log("");
+
+// update and print available values every second
+setInterval(function()
+{
+ // update our values from the sensor
+ sensor.update();
+
+ if (sensor.isOutOfRange())
+ {
+ console.log("Temperature out of range");
+ }
+ else
+ {
+ // we show both C and F for temperature
+ console.log("Temperature:", sensor.getTemperature(),
+ "C /", sensor.getTemperature(true), "F");
+ }
+
+ console.log("");
+
+}, 1000);
+
+
+process.on('SIGINT', function()
+{
+ sensor = null;
+ sensorObj.cleanUp();
+ sensorObj = null;
+ console.log("Exiting...");
+ process.exit(0);
+});
diff --git a/peripheral/libupm/examples/javascript/ublox6.js b/peripheral/libupm/examples/javascript/ublox6.js
index d68640a..50bad1a 100644
--- a/peripheral/libupm/examples/javascript/ublox6.js
+++ b/peripheral/libupm/examples/javascript/ublox6.js
@@ -66,7 +66,7 @@ function getGPSInfo()
process.stdout.write(GPSData)
}
- if (rv < 0) // some sort of read error occured
+ if (rv < 0) // some sort of read error occurred
{
console.log("Port read error.");
process.exit(0);
diff --git a/peripheral/libupm/examples/javascript/vcap.js b/peripheral/libupm/examples/javascript/vcap.js
new file mode 100644
index 0000000..d198b53
--- /dev/null
+++ b/peripheral/libupm/examples/javascript/vcap.js
@@ -0,0 +1,69 @@
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
+/*jshint unused:true */
+
+/*
+ * Author: Jon Trulson <jtrulson@ics.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.
+ */
+
+
+var sensorObj = require('jsupm_vcap');
+
+
+/************** Main code **************/
+
+var defaultDev = "/dev/video0";
+
+// if an argument was specified, use it as the device instead
+if (process.argv.length > 2)
+{
+ defaultDev = process.argv[2];
+}
+
+console.log("Using device " + defaultDev);
+console.log("Initializing...");
+
+// Instantiate an VCAP instance, using the specified video device
+var sensor = new sensorObj.VCAP(defaultDev);
+
+// enable some debug/verbose output
+sensor.setDebug(true);
+
+// This is just a hint. The kernel can change this to a lower
+// resolution that the hardware supports. Use getWidth() and
+// getHeight() methods to see what the kernel actually chose if you
+// care.
+sensor.setResolution(1920, 1080);
+
+// capture an image
+sensor.captureImage();
+
+// convert and save it as a jpeg
+sensor.saveImage("video-img1.jpg");
+
+// make sure we clean up
+sensor = null;
+sensorObj.cleanUp();
+sensorObj = null;
+console.log("Exiting...");
+process.exit(0);
+
diff --git a/peripheral/libupm/examples/python/apa102.py b/peripheral/libupm/examples/python/apa102.py
new file mode 100644
index 0000000..721d4d4
--- /dev/null
+++ b/peripheral/libupm/examples/python/apa102.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+# Author: Yannick Adam <yannick.adam@gmail.com>
+# Copyright (c) 2016 Yannick Adam
+#
+# 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 time, sys, signal, atexit
+import pyupm_apa102 as mylib
+
+# Instantiate a strip of 30 LEDs on SPI bus 0
+ledStrip = mylib.APA102(30, 0, False)
+
+## Exit handlers ##
+# This stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# Register exit handlers
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+print "Setting all LEDs to Green"
+ledStrip.setAllLeds(31, 0, 255, 0)
+
+print "Setting LEDs between 10 and 20 to Red"
+ledStrip.setLeds(10, 20, 31, 255, 0, 0)
+
+print "Setting LED 15 to Blue"
+ledStrip.setLed(15, 31, 0, 0, 255)
+
+
diff --git a/peripheral/libupm/examples/python/bma250e.py b/peripheral/libupm/examples/python/bma250e.py
new file mode 100644
index 0000000..051273c
--- /dev/null
+++ b/peripheral/libupm/examples/python/bma250e.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bmx055 as sensorObj
+
+# Instantiate a BMP250E instance using default i2c bus and address
+sensor = sensorObj.BMA250E()
+
+# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+# BMA250E(0, -1, 10);
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+x = sensorObj.new_floatp()
+y = sensorObj.new_floatp()
+z = sensorObj.new_floatp()
+
+# now output data every 250 milliseconds
+while (1):
+ sensor.update()
+
+ sensor.getAccelerometer(x, y, z)
+ print "Accelerometer x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " g"
+
+ # we show both C and F for temperature
+ print "Compensation Temperature:", sensor.getTemperature(), "C /",
+ print sensor.getTemperature(True), "F"
+
+ print
+ time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bmc150.py b/peripheral/libupm/examples/python/bmc150.py
new file mode 100644
index 0000000..efb1d99
--- /dev/null
+++ b/peripheral/libupm/examples/python/bmc150.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bmx055 as sensorObj
+
+# Instantiate a BMC150 instance using default i2c bus and address
+sensor = sensorObj.BMC150()
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+x = sensorObj.new_floatp()
+y = sensorObj.new_floatp()
+z = sensorObj.new_floatp()
+
+# now output data every 250 milliseconds
+while (1):
+ sensor.update()
+
+ sensor.getAccelerometer(x, y, z)
+ print "Accelerometer x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " g"
+
+ sensor.getMagnetometer(x, y, z)
+ print "Magnetometer x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " uT"
+
+ print
+ time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bme280.py b/peripheral/libupm/examples/python/bme280.py
new file mode 100644
index 0000000..160a95a
--- /dev/null
+++ b/peripheral/libupm/examples/python/bme280.py
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bmp280 as sensorObj
+
+# Instantiate a BME280 instance using default i2c bus and address
+sensor = sensorObj.BME280()
+
+# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+# BME280(0, -1, 10);
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+while (1):
+ sensor.update()
+
+ print "Compensation Temperature:", sensor.getTemperature(), "C /",
+ print sensor.getTemperature(True), "F"
+
+ print "Pressure: ", sensor.getPressure(), "Pa"
+
+ print "Computed Altitude:", sensor.getAltitude(), "m"
+
+ print "Humidity:", sensor.getHumidity(), "%RH"
+
+ print
+ time.sleep(1)
diff --git a/peripheral/libupm/examples/python/bmg160.py b/peripheral/libupm/examples/python/bmg160.py
new file mode 100644
index 0000000..112e3d6
--- /dev/null
+++ b/peripheral/libupm/examples/python/bmg160.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bmx055 as sensorObj
+
+# Instantiate a BMP250E instance using default i2c bus and address
+sensor = sensorObj.BMG160()
+
+# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+# BMG160(0, -1, 10);
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+x = sensorObj.new_floatp()
+y = sensorObj.new_floatp()
+z = sensorObj.new_floatp()
+
+# now output data every 250 milliseconds
+while (1):
+ sensor.update()
+
+ sensor.getGyroscope(x, y, z)
+ print "Gyroscope x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " degrees/s"
+
+ # we show both C and F for temperature
+ print "Compensation Temperature:", sensor.getTemperature(), "C /",
+ print sensor.getTemperature(True), "F"
+
+ print
+ time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bmi055.py b/peripheral/libupm/examples/python/bmi055.py
new file mode 100644
index 0000000..96ddac2
--- /dev/null
+++ b/peripheral/libupm/examples/python/bmi055.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bmx055 as sensorObj
+
+# Instantiate a BMI055 instance using default i2c bus and address
+sensor = sensorObj.BMI055()
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+x = sensorObj.new_floatp()
+y = sensorObj.new_floatp()
+z = sensorObj.new_floatp()
+
+# now output data every 250 milliseconds
+while (1):
+ sensor.update()
+
+ sensor.getAccelerometer(x, y, z)
+ print "Accelerometer x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " g"
+
+ sensor.getGyroscope(x, y, z)
+ print "Gyroscope x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " degrees/s"
+
+ print
+ time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bmi160.py b/peripheral/libupm/examples/python/bmi160.py
new file mode 100644
index 0000000..f7e7aa1
--- /dev/null
+++ b/peripheral/libupm/examples/python/bmi160.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bmi160 as sensorObj
+
+# Instantiate a BMI160 instance using default i2c bus and address
+sensor = sensorObj.BMI160()
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+x = sensorObj.new_floatp()
+y = sensorObj.new_floatp()
+z = sensorObj.new_floatp()
+
+while (1):
+ sensor.update()
+ sensor.getAccelerometer(x, y, z)
+ print "Accelerometer: AX: ", sensorObj.floatp_value(x),
+ print " AY: ", sensorObj.floatp_value(y),
+ print " AZ: ", sensorObj.floatp_value(z)
+
+ sensor.getGyroscope(x, y, z)
+ print "Gyroscope: GX: ", sensorObj.floatp_value(x),
+ print " GY: ", sensorObj.floatp_value(y),
+ print " GZ: ", sensorObj.floatp_value(z)
+
+ sensor.getMagnetometer(x, y, z)
+ print "Magnetometer: MX: ", sensorObj.floatp_value(x),
+ print " MY: ", sensorObj.floatp_value(y),
+ print " MZ: ", sensorObj.floatp_value(z)
+
+ print
+ time.sleep(.5)
diff --git a/peripheral/libupm/examples/python/bmm150.py b/peripheral/libupm/examples/python/bmm150.py
new file mode 100644
index 0000000..69f36bf
--- /dev/null
+++ b/peripheral/libupm/examples/python/bmm150.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bmx055 as sensorObj
+
+# Instantiate a BMP250E instance using default i2c bus and address
+sensor = sensorObj.BMM150()
+
+# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+# BMM150(0, -1, 10);
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+x = sensorObj.new_floatp()
+y = sensorObj.new_floatp()
+z = sensorObj.new_floatp()
+
+# now output data every 250 milliseconds
+while (1):
+ sensor.update()
+
+ sensor.getMagnetometer(x, y, z)
+ print "Magnetometer x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " uT"
+
+ print
+ time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bmp280.py b/peripheral/libupm/examples/python/bmp280.py
new file mode 100644
index 0000000..899e0a8
--- /dev/null
+++ b/peripheral/libupm/examples/python/bmp280.py
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bmp280 as sensorObj
+
+# Instantiate a BMP280 instance using default i2c bus and address
+sensor = sensorObj.BMP280()
+
+# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
+# BMP280(0, -1, 10);
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+while (1):
+ sensor.update()
+
+ print "Compensation Temperature:", sensor.getTemperature(), "C /",
+ print sensor.getTemperature(True), "F"
+
+ print "Pressure: ", sensor.getPressure(), "Pa"
+
+ print "Computed Altitude:", sensor.getAltitude(), "m"
+
+ print
+ time.sleep(1)
diff --git a/peripheral/libupm/examples/python/bmx055.py b/peripheral/libupm/examples/python/bmx055.py
new file mode 100644
index 0000000..45012cf
--- /dev/null
+++ b/peripheral/libupm/examples/python/bmx055.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bmx055 as sensorObj
+
+# Instantiate a BMX055 instance using default i2c bus and address
+sensor = sensorObj.BMX055()
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+x = sensorObj.new_floatp()
+y = sensorObj.new_floatp()
+z = sensorObj.new_floatp()
+
+# now output data every 250 milliseconds
+while (1):
+ sensor.update()
+
+ sensor.getAccelerometer(x, y, z)
+ print "Accelerometer x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " g"
+
+ sensor.getGyroscope(x, y, z)
+ print "Gyroscope x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " degrees/s"
+
+ sensor.getMagnetometer(x, y, z)
+ print "Magnetometer x:", sensorObj.floatp_value(x),
+ print " y:", sensorObj.floatp_value(y),
+ print " z:", sensorObj.floatp_value(z),
+ print " uT"
+
+ print
+ time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bno055.py b/peripheral/libupm/examples/python/bno055.py
new file mode 100644
index 0000000..6e5a500
--- /dev/null
+++ b/peripheral/libupm/examples/python/bno055.py
@@ -0,0 +1,105 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_bno055 as sensorObj
+
+# Instantiate an BNO055 using default parameters (bus 0, addr
+# 0x28). The default running mode is NDOF absolute orientation
+# mode.
+sensor = sensorObj.BNO055()
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting..."
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+mag = sensorObj.new_intp()
+acc = sensorObj.new_intp()
+gyr = sensorObj.new_intp()
+syst = sensorObj.new_intp()
+
+w = sensorObj.new_floatp()
+x = sensorObj.new_floatp()
+y = sensorObj.new_floatp()
+z = sensorObj.new_floatp()
+
+print "First we need to calibrate. 4 numbers will be output every"
+print "second for each sensor. 0 means uncalibrated, and 3 means"
+print "fully calibrated."
+print "See the UPM documentation on this sensor for instructions on"
+print "what actions are required to calibrate."
+print
+
+while (not sensor.isFullyCalibrated()):
+ sensor.getCalibrationStatus(mag, acc, gyr, syst)
+ print "Magnetometer:", sensorObj.intp_value(mag),
+ print " Accelerometer:", sensorObj.intp_value(acc),
+ print " Gyroscope:", sensorObj.intp_value(gyr),
+ print " System:", sensorObj.intp_value(syst),
+ time.sleep(1)
+
+print
+print "Calibration complete."
+print
+
+# now output various fusion data every 250 milliseconds
+
+while (True):
+ sensor.update()
+
+ sensor.getEulerAngles(x, y, z)
+ print "Euler: Heading:", sensorObj.floatp_value(x),
+ print " Roll:", sensorObj.floatp_value(y),
+ print " Pitch:", sensorObj.floatp_value(z),
+ print " degrees"
+
+ sensor.getQuaternions(w, x, y, z)
+ print "Quaternion: W:", sensorObj.floatp_value(w),
+ print " X:", sensorObj.floatp_value(x),
+ print " Y:", sensorObj.floatp_value(y),
+ print " Z:", sensorObj.floatp_value(z)
+
+ sensor.getLinearAcceleration(x, y, z)
+ print "Linear Acceleration: X:", sensorObj.floatp_value(x),
+ print " Y:", sensorObj.floatp_value(y),
+ print " Z:", sensorObj.floatp_value(z),
+ print " m/s^2"
+
+ sensor.getGravityVectors(x, y, z)
+ print "Gravity Vector: X:", sensorObj.floatp_value(x),
+ print " Y:", sensorObj.floatp_value(y),
+ print " Z:", sensorObj.floatp_value(z),
+ print " m/s^2"
+
+ print
+ time.sleep(.25);
diff --git a/peripheral/libupm/examples/python/curieimu.py b/peripheral/libupm/examples/python/curieimu.py
new file mode 100644
index 0000000..8596fef
--- /dev/null
+++ b/peripheral/libupm/examples/python/curieimu.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+
+# Author: Ron Evans (@deadprogram)
+# 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 mraa
+print (mraa.getVersion())
+
+# open connection to Firmata
+mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0")
+
+import time, sys, signal, atexit
+import pyupm_curieimu as curieimu
+sensor = curieimu.CurieImu()
+
+## Exit handlers ##
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+
+while(1):
+ sensor.updateAccel();
+
+ outputStr = "acc: gX {0} - gY {1} - gZ {2}".format(
+ sensor.getAccelX(), sensor.getAccelY(),
+ sensor.getAccelZ())
+ print outputStr
+
+ time.sleep(1)
diff --git a/peripheral/libupm/examples/python/cwlsxxa.py b/peripheral/libupm/examples/python/cwlsxxa.py
new file mode 100644
index 0000000..da73416
--- /dev/null
+++ b/peripheral/libupm/examples/python/cwlsxxa.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_cwlsxxa as sensorObj
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+print "Initializing..."
+
+# Instantiate an CWLSXXA instance, using A0 for CO2, A1 for
+# humidity and A2 for temperature
+sensor = sensorObj.CWLSXXA(0, 1, 2)
+
+# update and print available values every second
+while (1):
+ # update our values from the sensor
+ sensor.update()
+
+ # we show both C and F for temperature
+ print "Temperature:", sensor.getTemperature(), "C /",
+ print sensor.getTemperature(True), "F"
+
+ print "Humidity:", sensor.getHumidity(), "%"
+
+ print "CO2:", sensor.getCO2(), "ppm"
+
+ print
+ time.sleep(1)
diff --git a/peripheral/libupm/examples/python/ds18b20.py b/peripheral/libupm/examples/python/ds18b20.py
new file mode 100644
index 0000000..d91d33c
--- /dev/null
+++ b/peripheral/libupm/examples/python/ds18b20.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_ds18b20 as sensorObj
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting..."
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+print "Initializing..."
+
+# Instantiate an DS18B20 instance using the default values (uart 0)
+sensor = sensorObj.DS18B20(0)
+
+# locate and setup our devices
+sensor.init()
+
+print "Found", sensor.devicesFound(), "device(s)"
+print
+
+if (not sensor.devicesFound()):
+ sys.exit(1);
+
+# update and print available values every second
+while (1):
+ # update our values for the first sensor
+ sensor.update(0)
+
+ # we show both C and F for temperature for the first sensor
+ print "Temperature:", sensor.getTemperature(0), "C /",
+ print sensor.getTemperature(0, True), "F"
+
+ time.sleep(1)
diff --git a/peripheral/libupm/examples/python/ds2413.py b/peripheral/libupm/examples/python/ds2413.py
new file mode 100644
index 0000000..2dc95d8
--- /dev/null
+++ b/peripheral/libupm/examples/python/ds2413.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_ds2413 as sensorObj
+
+# Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
+sensor = sensorObj.DS2413(0)
+
+## Exit handlers ##
+# This stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting..."
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+# find all of the DS2413 devices present on the bus
+sensor.init();
+
+# how many devices were found?
+print "Found", sensor.devicesFound(), "device(s)"
+
+# read the gpio and latch values from the first device
+# the lower 4 bits are of the form:
+# <gpioB latch> <gpioB value> <gpioA latch> <gpioA value>
+print "GPIO device 0 values:", sensor.readGpios(0)
+
+# set the gpio latch values of the first device
+print "Setting GPIO latches to on"
+sensor.writeGpios(0, 0x03);
diff --git a/peripheral/libupm/examples/python/e50hx.py b/peripheral/libupm/examples/python/e50hx.py
new file mode 100644
index 0000000..a291001
--- /dev/null
+++ b/peripheral/libupm/examples/python/e50hx.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_e50hx as sensorObj
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting..."
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+# You will need to edit this example to conform to your site and your
+# devices, specifically the Device Object Instance ID passed to the
+# constructor, and the arguments to initMaster() that are
+# appropriate for your BACnet network.
+
+defaultDev = "/dev/ttyUSB0"
+
+# if an argument was specified, use it as the device instead
+if (len(sys.argv) > 1):
+ defaultDev = sys.argv[1]
+
+print "Using device", defaultDev
+print "Initializing..."
+
+# Instantiate an E50HX object for an E50HX device that has 1075425
+# as it's unique Device Object Instance ID. NOTE: You will
+# certainly want to change this to the correct value for your
+# device(s).
+sensor = sensorObj.E50HX(1075425)
+
+# Initialize our BACnet master, if it has not already been
+# initialized, with the device and baudrate, choosing 1000001 as
+# our unique Device Object Instance ID, 2 as our MAC address and
+# using default values for maxMaster and maxInfoFrames
+sensor.initMaster(defaultDev, 38400, 1000001, 2)
+
+# Uncomment to enable debugging output
+# sensor.setDebug(True);
+
+# output the serial number and firmware revision
+print
+print "Device Description:", sensor.getDeviceDescription()
+print "Device Location:", sensor.getDeviceLocation()
+print
+
+# update and print available values every second
+while (1):
+ print "System Voltage:",
+ print sensor.getAnalogValue(sensorObj.E50HX.AV_System_Voltage),
+ print " ",
+ print sensor.getAnalogValueUnits(sensorObj.E50HX.AV_System_Voltage)
+
+ print "System Type:",
+ print sensor.getAnalogValue(sensorObj.E50HX.AV_System_Type)
+
+ print "Energy Consumption:",
+ print sensor.getAnalogInput(sensorObj.E50HX.AI_Energy),
+ print " ",
+ print sensor.getAnalogInputUnits(sensorObj.E50HX.AI_Energy)
+
+ print "Power Up Counter:",
+ print sensor.getAnalogInput(sensorObj.E50HX.AI_Power_Up_Count)
+
+ print
+ time.sleep(5)
diff --git a/peripheral/libupm/examples/python/h803x.py b/peripheral/libupm/examples/python/h803x.py
new file mode 100644
index 0000000..4e950e0
--- /dev/null
+++ b/peripheral/libupm/examples/python/h803x.py
@@ -0,0 +1,106 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_h803x as sensorObj
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting..."
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+defaultDev = "/dev/ttyUSB0"
+
+# if an argument was specified, use it as the device instead
+if (len(sys.argv) > 1):
+ defaultDev = sys.argv[1]
+
+print "Using device", defaultDev
+print "Initializing..."
+
+# Instantiate an H803X instance, using MODBUS slave address 1, and
+# default comm parameters (9600, 8, N, 2)
+sensor = sensorObj.H803X(defaultDev, 1)
+
+# output the serial number and firmware revision
+print "Slave ID:", sensor.getSlaveID()
+
+print
+
+# update and print available values every second
+while (1):
+ # update our values from the sensor
+ sensor.update()
+
+ # H8035 / H8036
+ print "Consumption (kWh):", sensor.getConsumption()
+ print "Real Power (kW):", sensor.getRealPower()
+
+ if (sensor.isH8036()):
+ # The H8036 has much more data available...
+
+ print "Reactive Power (kVAR):", sensor.getReactivePower()
+ print "Apparent Power (kVA):", sensor.getApparentPower()
+ print "Power Factor:", sensor.getPowerFactor()
+ print "Volts Line to Line:", sensor.getVoltsLineToLine()
+ print "Volts Line to Neutral:", sensor.getVoltsLineToNeutral()
+
+ print "Current:", sensor.getCurrent()
+
+ print "Real Power Phase A (kW):", sensor.getRealPowerPhaseA()
+ print "Real Power Phase B (kW):", sensor.getRealPowerPhaseB()
+ print "Real Power Phase C (kW):", sensor.getRealPowerPhaseC()
+
+ print "Power Factor Phase A:", sensor.getPowerFactorPhaseA()
+ print "Power Factor Phase B:", sensor.getPowerFactorPhaseB()
+ print "Power Factor Phase C:", sensor.getPowerFactorPhaseC()
+
+ print "Volts Phase A to B:", sensor.getVoltsPhaseAToB()
+ print "Volts Phase B to C:", sensor.getVoltsPhaseBToC()
+ print "Volts Phase A to C:", sensor.getVoltsPhaseAToC()
+ print "Volts Phase A to Neutral: ",
+ print sensor.getVoltsPhaseAToNeutral()
+ print "Volts Phase B to Neutral: ",
+ print sensor.getVoltsPhaseBToNeutral()
+ print "Volts Phase C to Neutral: ",
+ print sensor.getVoltsPhaseCToNeutral()
+
+ print "Current Phase A:", sensor.getCurrentPhaseA()
+ print "Current Phase B:", sensor.getCurrentPhaseB()
+ print "Current Phase C:", sensor.getCurrentPhaseC()
+
+ print "Avg Real Power (kW):", sensor.getAvgRealPower()
+ print "Min Real Power (kW):", sensor.getMinRealPower()
+ print "Max Real Power (kW):", sensor.getMaxRealPower()
+
+ print
+ time.sleep(2)
diff --git a/peripheral/libupm/examples/python/hmtrp.py b/peripheral/libupm/examples/python/hmtrp.py
index dd2298f..9b8fe19 100644
--- a/peripheral/libupm/examples/python/hmtrp.py
+++ b/peripheral/libupm/examples/python/hmtrp.py
@@ -123,7 +123,7 @@ else:
resultStr += radioBuffer.__getitem__(x)
print "Received:", resultStr
- if (rv < 0): # some sort of read error occured
+ if (rv < 0): # some sort of read error occurred
print "Port read error."
sys.exit(0)
myCounter += 1
diff --git a/peripheral/libupm/examples/python/t8100.py b/peripheral/libupm/examples/python/t8100.py
new file mode 100644
index 0000000..2f14651
--- /dev/null
+++ b/peripheral/libupm/examples/python/t8100.py
@@ -0,0 +1,97 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_t8100 as sensorObj
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting..."
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+# You will need to edit this example to conform to your site and your
+# devices, specifically the Device Object Instance ID passed to the
+# constructor, and the arguments to initMaster() that are
+# appropriate for your BACnet network.
+
+defaultDev = "/dev/ttyUSB0"
+
+# if an argument was specified, use it as the device instead
+if (len(sys.argv) > 1):
+ defaultDev = sys.argv[1]
+
+print "Using device", defaultDev
+print "Initializing..."
+
+# Instantiate an T8100 object for an T8100 device that has 568000
+# as it's unique Device Object Instance ID. NOTE: You will
+# certainly want to change this to the correct value for your
+# device(s).
+sensor = sensorObj.T8100(568000)
+
+# Initialize our BACnet master, if it has not already been
+# initialized, with the device and baudrate, choosing 1000001 as
+# our unique Device Object Instance ID, 2 as our MAC address and
+# using default values for maxMaster and maxInfoFrames
+sensor.initMaster(defaultDev, 38400, 1000001, 2)
+
+# Uncomment to enable debugging output
+# sensor.setDebug(True);
+
+# output the serial number and firmware revision
+print
+print "Device Description:", sensor.getDeviceDescription()
+print "Device Location:", sensor.getDeviceLocation()
+print
+
+# update and print available values every 5 seconds
+while (1):
+ # update our values
+ sensor.update();
+
+ print "CO2 Concentration:",
+ print sensor.getCO2(),
+ print "ppm"
+
+ # we show both C and F for temperature
+ print "Temperature:", sensor.getTemperature(),
+ print "C /", sensor.getTemperature(True), "F"
+
+ print "Humidity:",
+ print sensor.getHumidity(),
+ print "%RH"
+
+ print "Relay State:",
+ print sensor.getRelayState()
+
+ print
+ time.sleep(5)
diff --git a/peripheral/libupm/examples/python/tb7300.py b/peripheral/libupm/examples/python/tb7300.py
new file mode 100644
index 0000000..93e879d
--- /dev/null
+++ b/peripheral/libupm/examples/python/tb7300.py
@@ -0,0 +1,96 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_tb7300 as sensorObj
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting..."
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+# You will need to edit this example to conform to your site and your
+# devices, specifically the Device Object Instance ID passed to the
+# constructor, and the arguments to initMaster() that are
+# appropriate for your BACnet network.
+
+defaultDev = "/dev/ttyUSB0"
+
+# if an argument was specified, use it as the device instead
+if (len(sys.argv) > 1):
+ defaultDev = sys.argv[1]
+
+print "Using device", defaultDev
+print "Initializing..."
+
+# Instantiate an TB7300 object for an TB7300 device that has 73001
+# as it's unique Device Object Instance ID. NOTE: You will
+# certainly want to change this to the correct value for your
+# device(s).
+sensor = sensorObj.TB7300(73001)
+
+# Initialize our BACnet master, if it has not already been
+# initialized, with the device and baudrate, choosing 1000001 as
+# our unique Device Object Instance ID, 2 as our MAC address and
+# using default values for maxMaster and maxInfoFrames
+sensor.initMaster(defaultDev, 38400, 1000001, 2)
+
+# Uncomment to enable debugging output
+# sensor.setDebug(True);
+
+# output the serial number and firmware revision
+print
+print "Device Name:", sensor.getDeviceName()
+print "Device Description:", sensor.getDeviceDescription()
+print "Device Location:", sensor.getDeviceLocation()
+print
+
+print "Fan Mode:", sensor.getMultiStateValueText(sensorObj.TB7300.MV_Fan_Mode)
+print "Fan Status:",
+print sensor.getMultiStateValueText(sensorObj.TB7300.MV_Fan_Status)
+print "System Mode:",
+print sensor.getMultiStateValueText(sensorObj.TB7300.MV_System_Mode)
+print "Service Alarm:",
+print sensor.getBinaryInputText(sensorObj.TB7300.BI_Service_Alarm)
+print
+
+# update and print the room temperature every 5 seconds
+while (1):
+ # update our values
+ sensor.update();
+
+ # we show both C and F for temperature
+ print "Temperature:", sensor.getTemperature(),
+ print "C /", sensor.getTemperature(True), "F"
+
+ print
+ time.sleep(5)
diff --git a/peripheral/libupm/examples/python/teams.py b/peripheral/libupm/examples/python/teams.py
new file mode 100644
index 0000000..8acfa09
--- /dev/null
+++ b/peripheral/libupm/examples/python/teams.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_teams as sensorObj
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+print "Initializing..."
+
+# Instantiate an TEAMS instance, using A0 for temperature, and
+# 165.0 ohms for the rResistor value (for the libelium 4-20ma
+# interface)
+sensor = sensorObj.TEAMS(0, 165.0)
+
+# update and print available values every second
+while (1):
+ # update our values from the sensor
+ sensor.update()
+
+ # is the sensor connected? (current >= 4ma)
+ print "Is Connected:", sensor.isConnected()
+
+ # print computed current on the loop. This includes the offset,
+ # if one was set by setOffsetMilliamps().
+ print "Milliamps:", sensor.getRawMilliamps()
+
+ # we show both C and F for temperature
+ print "Temperature:", sensor.getTemperature(), "C /",
+ print sensor.getTemperature(True), "F"
+
+ print
+ time.sleep(1)
diff --git a/peripheral/libupm/examples/python/tex00.py b/peripheral/libupm/examples/python/tex00.py
new file mode 100644
index 0000000..da42796
--- /dev/null
+++ b/peripheral/libupm/examples/python/tex00.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_tex00 as sensorObj
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting"
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+print "Initializing..."
+
+# Instantiate an TEX00 instance, using A0 for the analog input. In
+# this example, we are using a 10K Ohm balance resistor and a TED
+# (10k type 2) thermistor.
+sensor = sensorObj.TEX00(0, 10000, sensorObj.TEX00.STYPE_THERMISTOR_TED)
+
+print "Minimum temperature:", sensor.getTemperatureRangeMin(), "C"
+print "Maximum temperature:", sensor.getTemperatureRangeMax(), "C"
+print
+
+# update and print available values every second
+while (1):
+ # update our values from the sensor
+ sensor.update()
+
+ if (sensor.isOutOfRange()):
+ print "Temperature out of range"
+ else:
+ # we show both C and F for temperature
+ print "Temperature:", sensor.getTemperature(), "C /",
+ print sensor.getTemperature(True), "F"
+
+ print
+ time.sleep(1)
diff --git a/peripheral/libupm/examples/python/ublox6.py b/peripheral/libupm/examples/python/ublox6.py
index bb98d2b..c2e0322 100644
--- a/peripheral/libupm/examples/python/ublox6.py
+++ b/peripheral/libupm/examples/python/ublox6.py
@@ -73,7 +73,7 @@ def getGPSInfo():
GPSData += nmeaBuffer.__getitem__(x)
sys.stdout.write(GPSData)
- if (rv < 0): # some sort of read error occured
+ if (rv < 0): # some sort of read error occurred
print "Port read error."
sys.exit(0)
diff --git a/peripheral/libupm/examples/python/vcap.py b/peripheral/libupm/examples/python/vcap.py
new file mode 100644
index 0000000..dfd23a4
--- /dev/null
+++ b/peripheral/libupm/examples/python/vcap.py
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+# Author: Jon Trulson <jtrulson@ics.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 time, sys, signal, atexit
+import pyupm_vcap as sensorObj
+
+## Exit handlers ##
+# This function stops python from printing a stacktrace when you hit control-C
+def SIGINTHandler(signum, frame):
+ raise SystemExit
+
+# This function lets you run code on exit
+def exitHandler():
+ print "Exiting..."
+ sys.exit(0)
+
+# Register exit handlers
+atexit.register(exitHandler)
+signal.signal(signal.SIGINT, SIGINTHandler)
+
+defaultDev = "/dev/video0"
+
+# if an argument was specified, use it as the device instead
+if (len(sys.argv) > 1):
+ defaultDev = sys.argv[1]
+
+print "Using device", defaultDev
+print "Initializing..."
+
+# Instantiate an VCAP instance, using the specified video device
+sensor = sensorObj.VCAP(defaultDev)
+
+# enable some debug/verbose output
+sensor.setDebug(True);
+
+# This is just a hint. The kernel can change this to a lower
+# resolution that the hardware supports. Use getWidth() and
+# getHeight() methods to see what the kernel actually chose if you
+# care.
+sensor.setResolution(1920, 1080);
+
+# capture an image
+sensor.captureImage();
+
+# convert and save it as a jpeg
+sensor.saveImage("video-img1.jpg");
+