Compare commits

..

408 Commits

Author SHA1 Message Date
f1f9d9ec2e upm: version 0.5.1
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 18:08:35 -08:00
74d625c797 a110x: trigger ISR on both edges
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 18:07:28 -08:00
2695ef3361 itg3200: fixed calibration off by one
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 18:00:45 -08:00
a9548f3ff4 adafruitms1438: stop RPATH being added in CMakeLists.txt
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 17:23:32 -08:00
3ed0e14487 h3lis331dl: Fix sensor init
Signed-off-by: Alexandru Palalau <alexandru.palalau@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 15:38:52 -08:00
1a80400fa9 my9221: java: CMakelists: remove MY9221* add GroveLEDBar
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:52:32 -08:00
9845b24dea my9221: java: rename example from MY9221_ledbarSample to GroveLEDBar
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:51:50 -08:00
af7f544387 my9221: fixup groveledbar java example
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:51:07 -08:00
ac5c20afad my9221: remove duplicate MY9221Sample.java example
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:50:26 -08:00
9f3557aa20 my9221: remove old grovecircularled driver
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:49:46 -08:00
d112266170 my9221: python: rename example from my9221 to groveledbar
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:49:00 -08:00
94fdd86896 my9221: fixup groveledbar python example
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:48:18 -08:00
c0c99fd87a my9221: fixup grovecircularled python example
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:47:37 -08:00
684919f069 my9221: fixup grovecircularled JS example
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:46:56 -08:00
37add7eb33 my9221: JS: rename example from my9221 to groveledbar
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:46:16 -08:00
e17dc9a22e my9221: fixup JS example and interface files
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:45:32 -08:00
84c3445412 my9221: fixup example CMakelists after upstream rebase
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:44:48 -08:00
6b2850557e my9221: remove old ledbar example
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:44:04 -08:00
f94ee6a388 my9221: rename my9221-updown example to groveledbar
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:43:18 -08:00
cbb289438e my9221: rewrite to include new functionality and serve as a base class
This driver has been rewritten to support some new functionality, be
more generic and fix up some old bugs.  Multiple MY9221's can now be
chained together and are supported by the MY9221 base class.

In addition, the Grove LED Bar and Grove Circular LED drivers have
been incoporated into the my9221 library, using the new MY9221 class
as their base class.  Examples have been fixed to work with the new
library, and renamed where needed.

The current grovecircularled driver has been removed as it is now a
part of the my9221 library.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 11:42:21 -08:00
71b0791239 java: Corrected Java button sample and added it to auto build examples
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 10:56:50 -08:00
757a2ce342 docs: Modified building_java_bindings guide to use Runnables instead of IsrCallbacks
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 10:49:35 -08:00
3fab5625c7 java: Updated install path for Java library file
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-16 10:35:45 -08:00
5324808e82 docs: minor doc, image and example fixes for some lcds
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-10 12:58:23 -08:00
7d64e5458f docs: added new sensor images
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-10 10:59:42 -08:00
ab15d1e98f ads1015: fixed sensor typo in doxygen tags
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-08 14:09:26 -08:00
d9b761469d jhd1313m1: renamed node and python examples to match class name
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-08 13:12:18 -08:00
2098449c56 upm: sync build requirements with new MRAA version
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-08 12:41:03 -08:00
63c75be370 docs: fixed manufacturer name for ak8975 & groveultrasonic
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-08 12:07:47 -08:00
03b4d24e64 upm: version 0.5.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-01 17:03:11 -08:00
9d1afd35f8 docs: minor adjustments to doxygen tag instructions
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-01 15:36:37 -08:00
022b546003 mic: changed doxygen @sensor tag to match class name
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-01 15:24:39 -08:00
1d085362d9 kxcjk1013: updated iio calls to match API and disabled Java ISR
ISR support for Java bindings needs iio.c Runnable implementation in MRAA. Might be possible to leverage working implementation for GPIO.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-01 15:12:16 -08:00
3504dc7246 kxcjk1013: Initial implementation
Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-01 15:12:09 -08:00
5b7522bec4 apds9930: updated java bindings and iio calls to match API
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-01 15:11:59 -08:00
828a9ce7d8 apds9930: Initial implementation
Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-01 13:33:52 -08:00
8cec2ad473 knownlimitations: merged duplicate entry
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-02-01 11:37:44 -08:00
c3e3a6bb17 upm: bump MRAA dependency to 0.9.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 17:28:37 -08:00
11b5d3bc58 knownlimitations: updated list with JHD1313 and TSL2561
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 17:26:49 -08:00
3522e4ee8f eboled: updated python sample and function description for refresh()
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 16:56:07 -08:00
0f548d367b adxrs610: fixed typo in documentation
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 16:43:57 -08:00
1786017006 st7735: expose base class python wrappers too and avoid name collision
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 16:39:25 -08:00
2d68d707f6 ili9341: added java bindings plus minor fix on python wrap and GFX class collision
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 16:22:25 -08:00
d7f4b76ed0 ili9341: Initial implementation
This driver provides support for the ILI9341 LCD driver via SPI (e.g.
Adafruit 2.8" TFT LCD).

It was implemented and tested on the Edison.

Signed-off-by: Shawn Hymel
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 16:21:57 -08:00
4a1b4f1dd4 nlgpio16: C++11 incompatibility fixes
Signed-off-by: Eugene Bolshakov <pub@relvarsoft.com>

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 11:15:19 -08:00
ec75790516 sx1276 and adxrs610: C++11 incompatibility fixes
Signed-off-by: Eugene Bolshakov <pub@relvarsoft.com>

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 11:15:00 -08:00
fad4f72357 t3311: Added libmodbus linkage for Java build
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-29 11:14:42 -08:00
b3db180ffb doc: Added ds1307 to knownlimitations list
The Grove RTC (DS1307) does not work on the Intel Edison Arduino
board but will work with the mini-breakout.  Updated the list of
known limitations in docs.  Updated the ADXL345 to show 16g, and
fixed one line which went over 80 chars.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-01-28 16:27:36 -08:00
a4f41c7cb5 java: In java examples build, changed path to needed jars, to not depend on build folder name.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-28 16:13:47 -08:00
40f9135412 java: Added sanity checks and integrated them in CMake. Updated sample names and sample mapping.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-28 16:13:37 -08:00
46996e5251 java: updated samples that use interrupts with Runnable implementation
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-28 15:37:31 -08:00
2cd043c2a1 java: Use Runnables instead of IsrCallbacks in Java
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-28 13:42:38 -08:00
e1c66c351a rhusb: Initial implementation
The driver implements support for the Omega RH-USB Humidity Probe with
Temperature sensor.  It connects via an integrated USB cable, and
appears as a serial port.

It does not currently work with Edison (as of this date) due to
missing ftdi_sio and usbserial kernel support.

It was implemented and tested on the Galileo 2.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-28 13:31:01 -08:00
a5fd4a2c10 hwxpxx: Initial implementation
This module implements support for the Veris HWXPHTX Hardware Protocol
Humidity and Temperature Sensor family.  It uses MODBUS over an RS485
interface.

This module was developed using libmodbus 3.1.2, and the Veris HWXPHTX.

This sensor supports humidity, and optionally, temperature, slider
switch, and override switch reporting.  The HWXPHTX used to develop
this driver did not include the optional slider or override switches,
however support for them is provided.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-28 13:26:05 -08:00
fc7bfc113a hdxxvxta: Initial implementation
This driver was developed using the Veris HD2NVSTA1 humidity
transmitter.  The 'T' variant supports a temperature transmitter as
well.  Both signals are provided by the device as analog 0-5Vdc or
0-10Vdc outputs.

The A1 variant supports a temperature range of -40C-50C, while the A2
variant supports a range of 0C-50C.  Humidity ranges for all devices
in this device family range from 0% to 100% (non-condensing).

Temperature measurement can be disabled by passing -1 as the
temperature analog pin to the constructor.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-28 13:25:51 -08:00
bf82beaf9c t3311: Initial implementation
This module implements support for the Comet System T3311 Temperature
and Humidity transmitter.  It uses MODBUS over an RS232 serial port.

You must have libmodbus v3.1.2 (or greater) installed to compile and
use this driver.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-26 16:32:22 -08:00
5e37830bb7 pulsensor: updated header to include namespace and generate proper html/xml with doxygen
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-11 16:45:57 -08:00
4ff722ed2e ads1x15: changed description text to UTF-8 for compatibility with doxy2swig
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-04 12:56:45 -08:00
52b0ef4b28 nlgpio16: include documentation generated by doxy2swig for python
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-04 12:36:34 -08:00
930ff6734d ads1x15: include documentation generated by doxy2swig for python
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-04 11:21:24 -08:00
40be9b68a5 ads1x15: updated doxygen tags to match existing groups
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-23 17:03:33 -08:00
4259aeab7b ads1x15: initial commit for ads1x15 adc
Initial commit of ADS1x15 adc converter. Support for both ADS1015 12 bit
and ADS1115 16 bit  adc.
--signoff
Signed-off-by: Marc Graham <marc@m2ag.net>

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-23 16:47:52 -08:00
d0cb2a032c nlgpio16: Initial implementation
This is a USB device from Numato Labs that is accessed via a UART.  It
provides 16 GPIO's, 7 of which can be configured as analog inputs.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-23 16:02:19 -08:00
4dc679af70 stepmotor: made some small API changes for consistency and usability
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-22 15:24:11 -08:00
091bd9b381 stepmotor: clock_gettime needs lrt with older gcc/glib2 versions
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-22 14:08:11 -08:00
d04f93ffca mhz16: fixed JS/Python examples to match driver API
Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:51:19 -08:00
66aaa97955 swig: rename funcs that caused overload errors in python for hmtrp, wt5001
Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:47:57 -08:00
387b2b86b0 swig: ensure that all uint*_t passed in have the correct type.
Otherwise, we generate an exception.  This should fix Issue #172:

https://github.com/intel-iot-devkit/upm/issues/172

Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:36:31 -08:00
e003a11723 cmake: added doxygen doc content to python sensor modules
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:20:15 -08:00
d0504bb65b cmake: Use include/lib paths from MRAA pkgconfig for cmake
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:10:02 -08:00
669fd317b6 README: added reference to "Creating Java Bindings Guide"
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:04:38 -08:00
af7d1d2611 java: Added "Creating Java Bindings guide" to docs
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:04:28 -08:00
1cbb486330 travis: added java examples to Travis CI
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:04:16 -08:00
9516e0720c java: added auto build java examples in cmake
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:04:05 -08:00
8273556539 java: fix Java IsrCallback crash
The director now uses a GlobalRef instead of a WeakRef to the IsrCallback object

Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 16:03:51 -08:00
5bc9353bb4 stepmotor: updated Java example, added python & node.js examples
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-21 14:57:04 -08:00
c8e80bf6a3 stepmotor: made significant changes to stepper driver
Fun to work on, I have maybe 3 different implementations for this one now.
Submitted version uses GPIOs only, no more PWM thus enhancing compatibility.
Fast writes and busy-wait delays ensure accuracy to a few μs when generating
the step pulses.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-18 16:53:27 -08:00
74691914fb upm: version 0.4.1
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-07 16:24:52 -08:00
9bf184129e java: removed loadLibrary preamble from examples
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-04 17:41:26 -08:00
1667569560 java: Added "automatic load library" code for new sensors
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-04 17:40:56 -08:00
01119436a9 docs: Update knownlimitations.md
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-04 17:40:19 -08:00
344a52ae97 sx1276: changed function parameter name, so that predefined SWIG typemaps automatically apply. In the SWIG inerface, ignored some functions that have more user-friendly wrappers over them.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-04 17:39:47 -08:00
1accafa145 hcsr04: Made ISR be used internally and not be exposed to the user. Changed access modifier to private. Removed passing ISR to constructor.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-04 17:38:57 -08:00
e54f5e21c3 examples: synced c++ CMakeLists.txt file for examples in new format
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-04 17:01:20 -08:00
01700b0d49 c++ examples: cmake now honors MODULE_LIST
If MODULE_LIST is set, cmake will only create examples that can be built
with avaialble modules. There has been significant change to cmake file.
Comments show you how to add new examples.

Signed-off-by: Henry Bruce <henry.bruce@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-04 16:25:05 -08:00
a96a2ff44c travis: adding java builds to Travis CI
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-12-01 11:32:47 -08:00
cc7930caf3 mpu9250: propagated new constructor flag for i2c bypass
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-30 14:56:07 -08:00
ac21c9336b mpu9150: option to disable I2C bypass setting
The existing hardcoded logic enables i2c bypass mode for AK8975.
This can cause the accelerometer to disappear on I2C bus. We add
a new member as a switch that can be used to disable bypass.

Change-Id: I2c61f4910d46ffb5940bb3c14b58bc65984fd12e
Signed-off-by: Jianxun Zhang <jianxun.zhang@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-30 14:54:06 -08:00
fd509c7d79 ozw: Initial implementation
This module was developed using the OpenZWave library (v1.3):

http://www.openzwave.com/

It was developed using a collection of devices (switches and a
multi-sensor) connected via an Aeon Z-Stick Gen5 USB dongle.

It can be used to query (and, where appropriate, set) Values on Nodes
connected to the ZWave network.

Checks are made in src/ozw/CMakeLists.txt to ensure that the
libopenzwave library is installed (via pkg-config).  If not present,
then neither the module, nor the example will be built.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-25 13:55:19 -08:00
287250b32d hcsr04: Pass reference to current object to ISR.
This will allow users to call ackEdgeDetected() on the object passed into the function pointer, instead of requiring them to have a global reference to the object.

Signed-off-by: JJ Robertson <jjrob13@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-25 11:45:20 -08:00
758b49f51d sx1276: removed unused ISR and array typemaps from java interface
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 15:42:26 -08:00
2a1af1399a sx1276: Initial implementation
This driver was developed using an SX1276 based shield on the Galileo
G2.  It requires 3.3v of operation.  It does not work with Edison, due
to SPI issues.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2015-11-24 14:58:40 -08:00
4de9734f0a hmtrp: Added functions that throw exceptions when failing to read from sensors, and added java exception handling.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:36:29 -08:00
9bfda4219d groveButton: Corrected GroveButtonSample and GroveButton_intrSample
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:36:24 -08:00
dddba3e8a4 java: Added auto load library code in upm SWIG interfaces
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:36:17 -08:00
500e14663b lol: Added exception when invalid argument is passed to method
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:36:09 -08:00
fcb36276b7 wt5001: Added functions that throw exceptions when failing to read from sensors. Added java exception handling, and modified examples.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:36:04 -08:00
7f7fdb8441 mhz16: Split the getData(int* gas, int *temp) function into two separate functions and updated the C++ an Java examples
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:35:59 -08:00
f8a105adbf java: removed commented code in SWIG interface files
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:35:55 -08:00
ba43986f82 java: converted all int16_t* to short[] and updated examples
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:35:50 -08:00
6e2355ce9a cmake: use cmake libdir
Signed-off-by: Kevron Rees <kevron.m.rees@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:35:45 -08:00
4a90e2c4be cmake: more robust swig version checking based on build options
Python and Java bindings will build with SWIG 2.x but Node requires at least SWIG 3.0.5. Subject to change when SWIG 3 becomes standard in all major distros.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 14:35:28 -08:00
1adea8ecf1 cmake: changes for nodejs 4.1.1 - resubmit
Signed-off-by: Eugene Bolshakov <pub@relvarsoft.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-24 11:31:55 -08:00
011013e800 travis: updated travis.yml to reflect new .pc file location
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-23 18:12:33 -08:00
b4d4a215a2 groveultrasonic: made a few changes to code, example and documentation
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-23 17:49:35 -08:00
2eb6ebd3bd groveultrasonic: Initial implementation
This module was developed and tested on a Grove Ultrasonic Ranger module.

http://www.seeedstudio.com/wiki/Grove_-_Ultrasonic_Ranger

Signed-off-by: Jun Kato <i@junkato.jp>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-11-23 15:47:55 -08:00
dc97adf578 eboled: Call refresh() to actually put the text on the display. Use
reasonable coordinates for text.

Signed-off-by: Sergey Kiselev <sergey.kiselev@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-29 10:33:34 -07:00
181b5f17ea grovecircularled: fix up a missing mraa::DATA_OUT and formatting
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-29 10:15:31 -07:00
90bf469245 mcp9808: updated doxygen tags and formatted sources
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-29 09:57:11 -07:00
85b5c8a64e mcp9808: Initial commit for MCP9808 precision temperature sensor.
Add support for MCP9808 precision temp sensor. Implements all features
except for TCrit and TUpper and TLower locking. Functionality includes
alert, interrupt, resolution and hysteresis control.

Signed-off-by: Marc Graham <marc@m2ag.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-29 09:38:46 -07:00
422592f993 Grove O2 Sensor: Correcting Sensor Voltage Calculation
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:09:42 -07:00
fa1c1f3aa4 Java: Adding example for Grove O2 Sensor
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:09:37 -07:00
b11ad2d170 Java: Adding example for Grove Barometer (High Accuracy)
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:09:32 -07:00
d62d9f22cd Java: Adding example for Grove Luminance Sensor
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:09:27 -07:00
dec976e971 Java: Adding an example for Grove GSR Sensor
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:09:22 -07:00
fcf2278553 Java: Adding an example for Grove EMG Sensor
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:09:17 -07:00
b3300d5724 Java: Adding example for Water Level Sensor
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:09:12 -07:00
003ca2169f Java: Added missing header comment for MQ3 and MQ9 Gas Sensors
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:09:06 -07:00
0586775ffc Java: Adding example for Grove MQ9 Gas Sensor
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:09:02 -07:00
053cf15495 Java: Adding example for MQ3 Gas Sensor
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:57 -07:00
3d8b732158 Cleaned up code.
Removed some unneeded calls in update function. Changed call in
micsv89.js sample file to use update instead of start.

Tested with UPM. 4.0. The micsv89 is sensitive to other devices pulling
the I2c bus up, so it is not likely to work on the Arduino breakout.
I2c 1 on mini breakout works fine.

—Signed-off-by Marc Graham <marc@m2ag.net>

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:52 -07:00
db3b0c39bf Fixing an incorrect accelerometer address
Signed-off-by: Eugene Bolshakov <pub@relvarsoft.com>

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:47 -07:00
d2c4747251 Java: Adding an example for the Grove Q-Touch sensor (v 1.0)
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:42 -07:00
8b5cdae4ca Java: Adding an example for the Grove Collision Sensor
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:37 -07:00
2384fbb218 java: Corrected mistake in RotaryEncoderSample comments
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:32 -07:00
212c67fdd0 java: Corrected mistake in sample
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:28 -07:00
ca15860cc3 java: Added sample for Pulsensor
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:22 -07:00
cce8ab43e6 naming.md: updated e-mail addresses
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-27 17:08:18 -07:00
255d6cbe86 dfrph: Initial implementation
The driver implements support for the DFRobot pH sensors.  It was
tested with both the standard and Pro versions, calibrated with
standard buffer solutions at pH 4.01 and pH 7.0.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:13 -07:00
db721845db bma220: Initial implementation
This driver was developed based on the DFRobot Triple Axis
accelerometer BMA220 (Tiny):

http://www.dfrobot.com/index.php?route=product/product&product_id=1085

This device can only run at 3.3v DC.  Do not connect to 5v.

Added a private function definition for the installISR function. Done because C++
wasn't able to find the function definition for the java bindings.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:08:08 -07:00
53bc249b75 adxrs610: Initial implementation
This module was developed and tested on a ADXRS610 Gyro Beakout
board.

http://www.dfrobot.com/index.php?route=product/product&product_id=642

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:07:51 -07:00
639f99691b urm37: Initial implementation
This driver was tested with the DFRobot URM37 Ultrasonic Ranger, V4.
Both UART and analog access modes are supported.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:02:47 -07:00
6e095826d3 xbee: Initial implementation
This is a basic serial module that allows access to various XBee
devices via a UART port.  It was tested with the XBee S6B WiFi Module
and the XBee S1 802.14.4 module.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2015-10-27 17:02:10 -07:00
0d2541270e java: Modified path of javac and jar
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-08 12:32:54 -07:00
e34863f223 java: Added java samples and applied coding style rules to all previous samples
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-08 12:31:50 -07:00
27f34face1 st7735: removed unused variables and updated initialization list
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-07 14:26:27 -07:00
563c72be2c bmpx8x: initialize i2c address in constructor
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-07 14:26:13 -07:00
9bd5e78472 micsv89: updated to new mraa I2C API and added exceptions
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-06 13:05:24 -07:00
81c5962220 micsv89: made few aesthetic formatting changes and renamed update function
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-06 12:13:18 -07:00
bf856c5fca micsv89: Initial support for MICSV89
Signed off by: Marc Graham <marc@m2ag.net>

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-06 11:32:19 -07:00
1040b4e51f lcm1602: small patches to comments and examples
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 17:18:32 -07:00
1713d44a4b lcm1602: Add support for various LCD configurations / sizes
Signed-off-by: Sergey Kiselev <sergey.kiselev@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 14:47:52 -07:00
5ff625eaf4 java: Added java examples for some sensors
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 10:52:09 -07:00
9d63545d44 zfm20: fix clang compiler warnings regarding |/& precedence
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 10:51:56 -07:00
06b9e7b6f2 xfm20: remove unused setTtyFd() call causing compiler warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 10:51:45 -07:00
45773fac80 wt5001: remove unused setTtyFd() call causing compiler warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 10:51:32 -07:00
ee4efb3d6a ublox6: remove unused setTtyFd() call causing compiler warnings
Fixes Issue #276

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 10:51:21 -07:00
abced2fdbb mhz16: remove unused setTtyFd() call causing compiler warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 10:51:10 -07:00
537f7e111d hm11: remove unused setTtyFd() call causing compiler warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 10:50:58 -07:00
8b49943025 grovescam: remove unused setTtyFd() call causing compiler warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-10-05 10:50:49 -07:00
a6f517d2c1 java: Enabled directors feature where needed
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-30 10:45:57 -07:00
d26bde1825 docs: Sync sensor library names in documentation with the actual library names
Signed-off-by: Mircea Bardac <mircea.bardac@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-09-30 09:55:48 +01:00
ef30ab6fb2 docs: changed libmraa references to MRAA
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-24 17:00:37 -07:00
9206480b9c docs: few more typos and links fixed
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-24 16:39:53 -07:00
d81639d715 docs: fixed links and minor typos in index files
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-24 16:19:03 -07:00
08451d98cd docs: updated some links in index files
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-24 15:38:26 -07:00
ad81ea55e1 docs: increased heading sizes for changelog and known limitations
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-24 15:31:58 -07:00
bd8e22f125 docs: updated IDE sections in index pages
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-24 15:30:37 -07:00
04dc6df429 upm: version 0.4.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 17:45:27 -07:00
453a6eae0e upm: require mraa 0.8.0 for proper building of new APIs
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 17:36:41 -07:00
d325ae1fda docs: fixed mispelled cmake variable and improved java doxyfile
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 17:33:24 -07:00
98ea1c615a docs: separated readme.md between github and c++ documentation
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 15:06:54 -07:00
511d796fc2 docs: added headings to changelog and known limitations in main readme
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 14:45:28 -07:00
58888fc49b docs: updated index files for node and python with links to java documentation
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 14:41:25 -07:00
19bf570561 docs: updated java index link and doxygen configuration
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 12:46:38 -07:00
922c8f628c docs: update path to java index in doxygen configuration file
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 12:24:11 -07:00
3b6812ff36 java: updated paths to image files in index
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 12:02:06 -07:00
e3dde0e390 ssd1306: remove unprintable characters from header file
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 11:59:03 -07:00
68f54d1c59 docs: added java button image for documentation
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 11:39:04 -07:00
5f4e8b18e5 upm: removed extra comma in new package.json format
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 11:35:35 -07:00
5d356917cc java: Updated README for the Java documentation
Signed-off-by: Mircea Bardac <mircea.bardac@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 11:33:38 -07:00
1ceb784252 doxy: Changed some mapping for doxyport and updated the filenames for some samples
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-23 11:32:57 -07:00
e9679e0982 upm: updated package.json fields with required and extra details for npm publication
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 17:33:43 -07:00
c6386269ef pn532: fixed uninitialized variable and URL buffer
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 16:55:21 -07:00
f03f967a38 nrf24l01: limit data reads/writes to max buffer size
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 16:13:30 -07:00
5fda514544 java: Add Java Doxygen files
Signed-off-by: Mircea Bardac <mircea.bardac@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 13:49:58 -07:00
9fe9d4aec2 loudness: merge groveloudness and hyld9767 into a single driver
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 13:24:38 -07:00
cd7815aa07 mq6: Initial implementation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 12:34:21 -07:00
1563c71c5f mq4: Initial implementation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 12:33:39 -07:00
3b7eb9afc2 mq8: Initial implementation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 12:32:57 -07:00
d7bc084565 mq7: Initial implementation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 12:32:13 -07:00
3d702a6e64 gas: switch to mraa c++ Aio API
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 12:31:27 -07:00
cd30c7d71f java: Added Java Examples for a couple of sensors
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 11:20:50 -07:00
ed71aa029d max44000: Added device address as default argument in class constructor
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 11:20:10 -07:00
7ffe895374 grovevdiv: Function's return value is input for another function, so it should be the same type
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 11:19:36 -07:00
a427d6ebe5 eboled: Solved compilation warnings
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-22 11:18:59 -07:00
83e62aabba grovemd: add support for 'mode1' stepping and add stepper examples
The current grovemd driver supported 'mode2' stepping, where the
driver simply passed various stepper commands to the board for it to
carry out on it's own.

This doesn't work very well (or at all if you have old/buggy firmware)
so add a new 'mode1' stepper capability.  This mode lets the driver
manually control the stepping operation without requiring special
firmware.

This is now the default and recommended mode to use for stepper motors
on this device.  It is also more flexible in terms of the maximum
number of steps you can do (mode2 was limited to 254 steps max).

This was tested using a bipolar NEMA-17 stepper motor with an
external 12v power supply.

Note: 'Mode1' and 'Mode2' are the Seeed Studio terms for these different
stepping modes.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-21 17:17:29 -07:00
d94a6d00fb docs: C++ to Java mapping of sample files for documentation
Signed-off-by: Mircea Bardac <mircea.bardac@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-21 16:17:39 -07:00
14a3924fb2 eboled: Sparkfun OLED Block Improvements
Signed-off-by: Tyler Gibson <tgibson@microsoft.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-21 16:08:44 -07:00
7935ef1622 lm35: Initial implementation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-21 15:13:57 -07:00
a0af1c01bd grovegprs: updated to C++ mraa result in example
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-21 13:03:17 -07:00
7ce8dc3434 upm: added Travis CI file with build job
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 16:43:11 -07:00
33c123420a pulsensor: updated example and fixed variable in new API
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 16:21:16 -07:00
21eb2de086 nrf24l01: updated receive/transmit examples to match new C++ API
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 16:21:07 -07:00
5e72c4febd misc: Minor fixes due to previous rebase
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 10:26:37 -07:00
428bac360b mma7660: free resources in JNI wrapper
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 10:26:21 -07:00
a0518976c6 ttp223: add Java isr callbacks
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 10:26:07 -07:00
bdacb6c640 nrf24l01: Added callback functionality for Java
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 10:25:53 -07:00
ce6a095079 misc: Removed mraa_init and mraa::init
This change is due to commit 35760929dbb912fc3dfc738fee67c4f0dd63d55f
from MRAA.

Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 10:25:39 -07:00
701a25261f java/pulsensor: Changed to C++ types and added callback functionality for Java
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 10:25:23 -07:00
6719168a20 grove: add callback to GroveButton
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 10:25:09 -07:00
2002904faa grove: mraa_init is done at mraa module or library load
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 10:24:55 -07:00
7d0dccf9ed IsrCallback.h: check for NULL callback
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-18 10:24:41 -07:00
bfe548ac45 upm.i: mraa type mapping needs to be done for all languages
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:28:06 -07:00
3c36aa1624 zfm20: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:22:57 -07:00
64777bd0ef wt5001: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:22:45 -07:00
1fefdcbdf1 waterlevel: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:22:34 -07:00
8765416016 tm1637: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:22:22 -07:00
26317cbd2a th02: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:22:10 -07:00
f358b2e16d ta12200: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:21:59 -07:00
619da95553 sx6119: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:21:47 -07:00
3585761ecf stepmotor: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:21:36 -07:00
ca04996524 st7735: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:21:24 -07:00
6b19482ceb si114x: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:21:13 -07:00
d3bfebeca0 servo: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:21:02 -07:00
60a3f6cd7e pulsesensor: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:20:51 -07:00
5e9d9f4e66 pn532: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:20:40 -07:00
a56485f288 pca9685: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:20:29 -07:00
d0b5a98952 nrf8001: throw exception(s) on fatal errors
This isn't really a C++ library, though it is compiled as one.  We
throw exceptions in the hal_init function on startup if there are
issues initializing SPI or the various GPIO's, but that's it.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:20:18 -07:00
36cbca05bb nrf24l01: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:20:07 -07:00
f6ab1fb451 mpu9150: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:19:56 -07:00
9c4a4d0ff0 ak8975: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:19:45 -07:00
5cc8c90251 mpu9150: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:19:34 -07:00
a24f8209bc mpl3115a2: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:19:23 -07:00
e8823dd74e mma7455: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:19:11 -07:00
b8ee0cf22d mic: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:19:00 -07:00
14fc909400 mhz16: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:18:49 -07:00
0db47c7528 maxsonarez: add missing stdexcept header
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:18:38 -07:00
aeb120c284 maxsonarez: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:18:27 -07:00
ab20e34c59 max44000: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:18:17 -07:00
d0d89b579d max31855: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:18:06 -07:00
6db7dfd3d9 m24lr64e: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:17:55 -07:00
36237ae596 lsm9ds0: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:17:44 -07:00
9e20268bb8 lsm303: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:17:02 -07:00
77abd94682 lol: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:10:26 -07:00
7323b58b61 ssd1327: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:10:16 -07:00
cb6427b22e ssd1308: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:10:05 -07:00
fe133d7454 l298: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:09:55 -07:00
52274d8b10 itg3200: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:09:45 -07:00
0af62a6992 isd1820: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:09:35 -07:00
6a6eaa1b71 ina132: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:09:25 -07:00
3fc672a19f htu21d: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:09:14 -07:00
69bd77dd30 ht9170: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:09:04 -07:00
9421cdaf30 hp20x: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:08:54 -07:00
fb779ecd6a hmtrp: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:08:44 -07:00
3cd61b56f8 hm11: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:08:34 -07:00
56ddb441d4 grovescam: throw exception(s) on fatal read() as well
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:08:23 -07:00
8d38bd0bcc hcsr04: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:08:13 -07:00
1f1c303937 h3lis331dl: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:08:02 -07:00
f567f282ae grovescam: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:07:52 -07:00
5ab01e5a65 groveo2: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:07:42 -07:00
b56095a3ff grovemd: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:07:31 -07:00
b20a5f1d68 grovegsr: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:07:21 -07:00
c3297bcc55 groveemg: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:07:11 -07:00
4513a8ad09 groveelectromagnet: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:07:01 -07:00
ae60a92963 groveeldriver: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:06:51 -07:00
eba82a1c73 groveehr: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:06:42 -07:00
b7dda9021f grovecollision: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:06:32 -07:00
d7b8fac41b grovecircularled: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:06:22 -07:00
1079baf2fd gp2y0a: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:06:12 -07:00
b925f13bac flex: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:06:02 -07:00
78d940aaf5 ds1307: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:05:52 -07:00
3d837284fd bmpx8x: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:05:42 -07:00
b8af35a797 at42qt1070: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:05:33 -07:00
1eb9e7b9dc apds9002: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:05:23 -07:00
1617b03d3d am2315: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:05:13 -07:00
da49741527 adxl345: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:05:03 -07:00
f86e812f13 adxl335: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:04:54 -07:00
f84973b0e4 adis16448: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:04:44 -07:00
b0ac4b5da2 adc121c021: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:04:34 -07:00
0566b4f995 adafruitss: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:04:24 -07:00
a1db1b423b ldt0028: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:04:14 -07:00
f29141087e lcm1602,jhd1313m1: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:04:03 -07:00
fbbc0de6fb ttp223: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:03:53 -07:00
427dd6e851 mma7660: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:03:43 -07:00
4f5b4d5886 groveloudness: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:03:32 -07:00
8345687ab9 buzzer: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:03:22 -07:00
bea94a70b2 uln200xa: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:03:12 -07:00
a4db81c15f cjq4435: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:03:02 -07:00
c7aa1b1f8a nunchuck: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:02:51 -07:00
8e54381216 grovevdiv: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:02:41 -07:00
9081c35f53 grovelinefinder: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:02:31 -07:00
88c11fb1cf hmc5883l: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:02:21 -07:00
9e3c72a547 enc03r: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:02:11 -07:00
2f2b502813 joystick12: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:02:00 -07:00
6b4a3e1fd0 a110x: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:01:50 -07:00
c50dd16d82 rfr359f: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:01:39 -07:00
7866e54e8d mq303a: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:01:28 -07:00
b00e81dfce mpr121: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:01:18 -07:00
cc6ba3be6d ublox6: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:01:08 -07:00
a564258fb0 biss0001: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:00:57 -07:00
03cb2ec362 grovewfs: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:00:47 -07:00
f4e5a5109f my9221: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:00:36 -07:00
dc49f36e83 guvas12d: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:00:25 -07:00
5516faca38 tsl2561: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:00:15 -07:00
74cbc25f21 ppd42ns: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 17:00:04 -07:00
1ea36c6f89 grovewater: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 16:59:54 -07:00
38351cbe6e grove: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 16:59:44 -07:00
d4d29307a2 rotaryencoder: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 16:59:34 -07:00
b4e4e9ae89 otp538u: throw exception(s) on fatal errors.
In addition, throw out_of_range() exceptions in
object/ambientTemperature() methods when they occur instead of just
returning 0, which is a valid temperature return value.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 16:59:24 -07:00
a2855c5e72 rpr220: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 16:59:13 -07:00
667a8fdb49 yg1006: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 16:59:03 -07:00
04e91db166 grovespeaker: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 16:58:53 -07:00
6c8f82901c grovemoisture: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 16:58:43 -07:00
5f27c5515f gas: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-17 16:58:33 -07:00
48e6d4bcfa grovemd: uncommented mraa_i2c_frequency() call since driver only works at 100kHz
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-16 10:19:28 -07:00
4e70ed4973 ssd1306: updated to C++ types and new exceptions, fixed repeated call to i2cfrequency
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 18:27:09 -07:00
3159005aa3 ssd1306: initial implementation
Signed-off-by: Marc Graham <marc@m2ag.net>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 18:20:45 -07:00
5a62602a11 hcsr04: fixes driver and addresses issue #207
Signed-off-by: Rafael Neri <rafael.neri@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 18:14:03 -07:00
0bc1930cf5 java: Added [Interesting] delimiters for snippets of code to be inserted in the documentation
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 18:06:31 -07:00
ef74a7b137 java: Eliminated double definition of SWIGJAVA and the need for "#undefine SWIGJAVA"
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/CMakeLists.txt
2015-09-15 17:58:22 -07:00
f991bcf915 java: Corrected typo in ublox6
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 17:51:10 -07:00
6cbddff31a java: solved some SWIGTYPE issues
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/mma7455/mma7455.cxx
	src/mma7455/mma7455.h
2015-09-15 17:45:09 -07:00
ff42bd390f nrf24l01: removed declared and undefined destructor
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 17:39:05 -07:00
b4d2a2e1f2 grovegprs: updated new implementation to C++ types
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 17:33:22 -07:00
b44995da74 sm130: updated new implementation to C++ types
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 17:27:25 -07:00
3af7cccb93 java: added java samples
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 17:20:54 -07:00
021c003ca8 java: corrected typo and documentation
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 17:14:36 -07:00
2e5fbd0d54 java: ignoring BasicFonts matrix
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 17:08:48 -07:00
2cab79b4c2 java: Changed size_t and unsigned int to int in array declarations. Renamed buf to buffer where necesarry. Moved most Java array typemaps to java_buffer.i. Fixed some String buffers.
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/upm.i
2015-09-15 17:01:39 -07:00
ab730038fd java: changed some C types to C++ types
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/mma7455/mma7455.cxx
	src/mma7455/mma7455.h
	src/sm130/sm130.cxx
	src/sm130/sm130.h
2015-09-15 16:52:36 -07:00
b8835958e2 java: now using the C++ style types from mraa defined in types.hpp
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 16:44:18 -07:00
ea1df1b178 upm: bump mraa requirement to 0.7.6 for java bindings
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-15 16:32:40 -07:00
85c602d524 grovegprs: Initial implementation
This driver provides support for the Grove GPRS shield, V2:

http://www.seeedstudio.com/wiki/GPRS_Shield_V2.0

It provides a simple interface whereby a user can send and receive
commands and data from the device.  It is controlled by a standardized
set of "AT" commands.  A full description of these commands is
available here:

http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2015-09-08 13:39:19 -07:00
8147a89cb7 upm: updated list of known limitations
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-08 13:39:12 -07:00
20d5c50725 buzzer: fix double space in description
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-08 13:39:06 -07:00
138c5af5f8 doxygen: Modified header files to show detail description from doxygen
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-09-08 13:38:59 -07:00
6793c892ed sm130: Complete rewrite
This is a rewrite of the existing SM130 driver which was incomplete
and non-functional.

It was implemented using a Sparkfun SM130 module:

https://www.sparkfun.com/products/10126

... using a Sparkfun RFID Evaluation Shield:

https://www.sparkfun.com/products/10406

It operates in UART mode only.  A port to support I2C communications
(requires a encrypted firmware reflash from SonMicro) should be
fairly trivial, if you have one of those.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-08 13:38:42 -07:00
76f7abb112 mpu9250: Initial implementation
This driver was implemented using a Grove IMU 9DOF V2.0 (mpu9250).

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-09-04 19:37:34 -07:00
1e5b755b99 doxygen: generate tar archive out of doxygen xml output
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 17:08:14 -07:00
a79d8abfcd rotaryencoder: changed access modifier for internal isr to private
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 14:47:36 -07:00
4b8b75b19b grovewfs: isr is used internally, changed access modifier to private
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 14:45:18 -07:00
2bae3931b9 groveehr: isr is used internally thus changed access modifier to private
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 14:44:09 -07:00
5fd2d9c439 zfm20: removed misleading checksum notation
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 14:39:37 -07:00
c45e493b1b mma7455: fixed typo and minor documentation improvements
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 14:32:29 -07:00
4985cf4b00 java: leave mraa_result_t typemap in upm.i for non-java bindings
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:52:25 -07:00
7afd1f3fc1 java: fix return types and arrays for mpu60x0 and mpu9150
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:52:19 -07:00
83cb6dc2fd java: fix Java arrays for mma7455
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:52:12 -07:00
dc7e33558e java: fix Java arrays for m24lr64e
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:52:05 -07:00
0406258466 java: fix Java arrays for ds1307
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:51:59 -07:00
2ceb6a9d8d java: fix Java arrays for lcd modules
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:51:52 -07:00
fbf68d1dd8 java: fix some cast issues with adxl345, free arrays
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:51:46 -07:00
a5a66e9e17 java: fix Java types for MPR121
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:51:40 -07:00
07f6ffb0a4 java: fix Java types for mic and gas sensors
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:51:33 -07:00
ebdb4f10d1 java: fix Java types for ZFM20
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:51:26 -07:00
3d74ea9820 java: in methods taking buffers as arguments, changed buffer type from short[] to byte[]
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:51:19 -07:00
f6c56be5e4 java: convert (uint8_t *buffer, size_t len) to byte[] for grovescam
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:51:13 -07:00
cfe63bf7b6 java: convert (uint8_t *buffer, int len) to byte[] for nunchuck
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:51:06 -07:00
1f82757c64 java: convert (char *buffer, size_t len) to byte[] for ublox6
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:50:59 -07:00
be2e8d7c76 java: convert (uint8_t* buf, int len) to byte[] in Java for lsm9ds0, free resources
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:50:53 -07:00
3aad8e367f java: fix C types for readBytes in nunchuck
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:50:47 -07:00
45b83502a1 java: delete allocated array in JNI wrapper
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:50:40 -07:00
9cfd1a9679 java: fix Java return types in h3lis331dl
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:50:33 -07:00
fb6627083b java: map C buffer pointer and length to Java array for Ublox6
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:50:26 -07:00
42c59e98ab java: fix Java return types in lsm9ds0
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:50:19 -07:00
ea669ddfc6 java: fix Java return type for readData in MMA7455
Signed-off-by: Petre <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:50:12 -07:00
4f30959a43 java: fix Java return types in ADXL355
Signed-off-by: Petre <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:50:04 -07:00
2455938691 java: added some Java examples
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:49:56 -07:00
5e3263e2e2 java: ignored return i2cContext method, in java bindings
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:49:49 -07:00
58846ba68a java: fix Java return types in MMA7660
Signed-off-by: Petre <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:49:42 -07:00
a21db7ca78 java: fix SWIGJAVA build errors
Signed-off-by: Petre <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:49:36 -07:00
40fb6f5d75 java: changed name of the MRAA package on which UPM depends
This change is necessary due to commits d547cda and
af533de from mraa.

Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:49:28 -07:00
2595c0b623 java: added examples and solved some issues with the naming convention
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:49:21 -07:00
c7185739dc java: ignored Interrupt Service Routines, that are installed by start/constructor methods, and cannot be changed
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:49:13 -07:00
945a6d4828 java: code cleanup to enable comment parsing with external tools.
Using an external code parsing library we discovered that there are
non-printable characters in some source files which break the parser.
This commit removes these characters and rewrites a type definition
which was also breaking the parser.

Signed-off-by: Mircea Bardac <mircea.bardac@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:49:06 -07:00
19bcbc7c42 java: solved callbacks
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:48:59 -07:00
323905a215 java: added callback functionality
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:48:50 -07:00
3e59323abb java: solved SWIGTYPE_* issues
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:48:41 -07:00
59c6b28cdd java: fixed IPK's target_arch
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:48:32 -07:00
b17a3b34b7 java: solved issue regarding .jar file naming
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:48:25 -07:00
8b9267c253 java: eliminated SWIGTYPE_p_mraa_result_t
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:48:19 -07:00
78a159594b java: solved SWIGTYPE_p_int and SWIGTYPE_p_float
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:48:11 -07:00
8eed56fda0 java: added lib prefix to dynamic shared library
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:48:05 -07:00
647d9b44a9 java: changed install path of jar and library files for Java bindings
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:47:58 -07:00
749952f7e3 java: added Java binding for new sensor
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:47:51 -07:00
d3e0ae5771 java: fixed grove API and added some examples
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:47:45 -07:00
a81b1836a3 java: eliminated SWIGTYPE_speed_t and corrected typo
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:47:38 -07:00
c7389d0cb6 upm: bumped require mraa to 0.7.2
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-04 13:38:25 -07:00
fb86dc5cec Revert "grovegprs: Initial implementation"
This reverts commit 98f400e326.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-03 16:10:27 -07:00
98f400e326 grovegprs: Initial implementation
This driver provides support for the Grove GPRS shield, V2:

http://www.seeedstudio.com/wiki/GPRS_Shield_V2.0

It provides a simple interface whereby a user can send and receive
commands and data from the device.  It is controlled by a standardized
set of "AT" commands.  A full description of these commands is
available here:

http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-09-03 13:36:54 -07:00
b0625e11f1 wheelencoder: Initial implementation
This driver was developed for the DFRobot Wheel Encoder, though it
could be used for any counting time-based task using a digital i/o pin
to generate interrupts.

http://www.dfrobot.com/index.php?route=product/product&product_id=98

If you want to use more than one encoder, simply create a class
instance for each one.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-08-31 11:58:49 -07:00
60cfe88e37 mg811: Initial implementation
This driver was developed on a DFRobot CO2 sensor based on the MG811:
http://www.dfrobot.com/index.php?route=product/product&product_id=1023

It seems to *require* very precise calibration at 400ppm and 1000ppm
to be accurate.  It also gets pretty hot (due to the heater) and
consumes significant current.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-08-27 10:21:37 -07:00
ad1cc81c0d hyld9767: Initial implementation
This driver was developed using the DFRobot Loudness sensor

http://www.dfrobot.com/index.php?route=product/product&product_id=83

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Sisinty Sasmita Patra<sisinty.s.patra@intel.com>
2015-08-24 17:31:25 -07:00
4a6492af0a pca9685: fix problem where setting pwm accidentally cleared full bits
When setting the On or Off times, the FullOn or FullOff control bits
would be improperly masked and therefore not preserved.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Sisinty Sasmita Patra<sisinty.s.patra@intel.com>
2015-08-21 14:54:39 -07:00
488ea234d5 adafruitms1438: fix a bug in PWM handling for DC motors
Eric Hubert reported a bug in that no matter what setting he used to
control the speed of a DC motor, it was always running at full speed.

There was a bug in the setMotorSpeed() method that did not clear the
'FullOn' bit in the register used for PWM, causing full power to be
applied all the time no matter the PWM duty cycle setting.

This patch corrects that issue.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
signed-off-by: Sisinty Sasmita Patra<sisinty.s.patra@intel.com>
2015-08-21 14:20:33 -07:00
fba8139416 pca9685: Add i2c raw bus option
Signed-off-by: Kevron Rees <kevron.m.rees@intel.com>
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-08-20 12:48:56 -07:00
45738d0b93 ublox6: interface file fix for python Grove GPS example
Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-08-20 12:45:16 -07:00
52810cef77 java: fixed install targets for java libraries
File name mismatch on generated .jar files

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-14 17:40:11 -07:00
f02fa1fdf1 servo: added definitions for ES9257 servo
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-14 17:38:22 -07:00
f8766cccdc java: added java interfaces for sparkfun sensor blocks
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 16:38:40 -07:00
4bea93163d Added Java bindings for the remaining sensors
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 16:26:18 -07:00
8b0d1b2b3d Added some examples for Java
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 16:26:07 -07:00
7e2ae96c1f Added Java support and bindings
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 16:25:54 -07:00
181823cb20 readme: added full library name to title
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 16:22:32 -07:00
11f9154ce0 grovescam: made file path constant to remove compiler warnings
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 15:18:43 -07:00
018e09e5b2 sm130: remove bogus use of 'this' pointer
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:54:41 -07:00
984391eb64 sm130: remove custom exception and use standard ones
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:54:29 -07:00
9bf954071b th02: remove custom exception and use standard ones
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:54:15 -07:00
448ee39c7f tcs3414cs: remove custom exception and use standard ones
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:53:59 -07:00
8dac9f7356 mlx90614: remove custom exception and use standard ones
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:53:44 -07:00
fcca8ada45 maxds3231m: remove custom exception and use standard ones
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:53:29 -07:00
2e0efd6690 max5487: remove custom exception and use standard ones
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:53:16 -07:00
c878283c44 max31723: remove custom exception and use standard ones
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:53:01 -07:00
b81be93411 lsm9ds0: include stdexcept, remove extraneoous error output
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:52:48 -07:00
3ad25f65c8 lpd8806: remove custom exception and use a standard one
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:52:36 -07:00
97e7f74a8f hx711: remove custom exception and use a standard one
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:52:24 -07:00
66d688bc90 ecs1030: remove custom exception and use a standard one
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:52:12 -07:00
84f795e453 upm: add facility for exception handling in upm
We add a new src/upm_exception.i interface file for SWIG to catch
common exceptions and propagate them through SWIG.

src/upm.i is modified to include this interface file, so all UPM
drivers have it.

In theory, this should be language agnostic - if the target language
supports exceptions, then it should just work.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-13 14:52:01 -07:00
874 changed files with 45062 additions and 3928 deletions

21
.travis.yml Normal file
View File

@ -0,0 +1,21 @@
language: cpp
compiler:
- gcc
- clang
install:
- sudo add-apt-repository --yes ppa:kalakris/cmake
- sudo add-apt-repository --yes ppa:fenics-packages/fenics-exp/swig
- sudo apt-get update -qq
- sudo apt-get install -y -qq swig3.0 python git cmake
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
- sudo update-java-alternatives -s java-8-oracle
before_script:
- if [ "$CC" = "gcc" ]; then export BUILDJAVA=ON; else export BUILDJAVA=OFF; fi
- export JAVA_HOME=/usr/lib/jvm/java-8-oracle
script:
- git clone --branch=master https://github.com/intel-iot-devkit/mraa.git
- cd mraa && mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=. -DNODE_ROOT_DIR:PATH=/home/travis/.nvm/v0.10.36/include .. && make && make install
- export PKG_CONFIG_PATH=$PWD/lib/pkgconfig:$PWD/lib/x86_64-linux-gnu/pkgconfig
- export CPLUS_INCLUDE_PATH=$PWD/include
- export LIBRARY_PATH=$PWD/lib:$PWD/lib/x86_64-linux-gnu
- cd ../.. && mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DNODE_ROOT_DIR:PATH=/home/travis/.nvm/v0.10.36/include -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA .. && make

View File

@ -5,22 +5,17 @@ if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message("WARNING: building into sources dir can be risky, prefer other directory") message("WARNING: building into sources dir can be risky, prefer other directory")
endif () endif ()
find_package (SWIG)
if (SWIG_FOUND)
include (${SWIG_USE_FILE})
endif ()
find_package (Threads REQUIRED) find_package (Threads REQUIRED)
find_package (PkgConfig REQUIRED) find_package (PkgConfig REQUIRED)
# force a libmraa search and minimum required version every time a config is generated # Force a libmraa search and minimum required version every time a config is generated
unset(MRAA_FOUND CACHE) unset(MRAA_FOUND CACHE)
pkg_check_modules (MRAA REQUIRED mraa>=0.6.2) pkg_check_modules (MRAA REQUIRED mraa>=0.9.1)
message (INFO " found libmraa version: ${MRAA_VERSION}") message (INFO " found mraa version: ${MRAA_VERSION}")
# Appends the cmake/modules path to MAKE_MODULE_PATH variable. # Appends the cmake/modules path to MAKE_MODULE_PATH variable.
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
set (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries") set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
# Set CMAKE_LIB_INSTALL_DIR if not defined # Set CMAKE_LIB_INSTALL_DIR if not defined
include(GNUInstallDirs) include(GNUInstallDirs)
@ -28,14 +23,14 @@ include(GNUInstallDirs)
# Make a version file containing the current version from git. # Make a version file containing the current version from git.
include (GetGitRevisionDescription) include (GetGitRevisionDescription)
git_describe (VERSION "--tags") git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND") if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
message (WARNING " - Install git to compile a production UPM!") message (WARNING " - Install git to compile a production UPM!")
set (VERSION "v0.3.2-dirty") set (VERSION "v0.5.1-dirty")
endif () endif ()
message (INFO " - UPM Version ${VERSION}") message (INFO " - UPM Version ${VERSION}")
#parse the version information into pieces. # Parse the version information into pieces.
string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}") string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
string (REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}") string (REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}") string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
@ -58,33 +53,52 @@ option (BUILDSWIG "Build swig modules." ON)
option (BUILDSWIGPYTHON "Build swig python modules." ON) option (BUILDSWIGPYTHON "Build swig python modules." ON)
option (BUILDSWIGNODE "Build swig node modules." ON) option (BUILDSWIGNODE "Build swig node modules." ON)
option (BUILDEXAMPLES "Build C++ example binaries" OFF) option (BUILDEXAMPLES "Build C++ example binaries" OFF)
option (BUILDJAVAEXAMPLES "Build java example jars" OFF)
option (BUILDSWIGJAVA "Build swig java modules" OFF)
option (IPK "Generate IPK using CPack" OFF) option (IPK "Generate IPK using CPack" OFF)
option (RPM "Generate RPM using CPack" OFF) option (RPM "Generate RPM using CPack" OFF)
option (BUILDTESTS "Generate check-ups for upm" OFF)
# detect arch # Find swig
if (BUILDSWIG)
if (BUILDSWIGNODE)
find_package (SWIG 3.0.5 REQUIRED)
else ()
find_package (SWIG REQUIRED)
endif ()
if (SWIG_FOUND)
include (${SWIG_USE_FILE})
endif ()
endif ()
# Detect arch
include (TargetArch) include (TargetArch)
target_architecture (DETECTED_ARCH) target_architecture (DETECTED_ARCH)
message( INFO " - Target arch is ${DETECTED_ARCH}") message( INFO " - Target arch is ${DETECTED_ARCH}")
if (BUILDDOC) if (BUILDDOC)
# add a target to generate API documentation with Doxygen # Add a target to generate API documentation with Doxygen
find_package (Doxygen) find_package (Doxygen)
if (DOXYGEN_FOUND) if (DOXYGEN_FOUND)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
if (BUILDSWIGJAVA)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.java.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-java @ONLY)
endif()
file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/icons/*.png) file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/icons/*.png)
foreach(PNG_FILE ${PNG_FILES}) foreach(PNG_FILE ${PNG_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY)
endforeach() endforeach()
add_custom_target (doc add_custom_target (doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND tar -czf html/xml.tar.gz -C xml .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM COMMENT "Generating API documentation with Doxygen" VERBATIM
) )
endif (DOXYGEN_FOUND) endif (DOXYGEN_FOUND)
# check if Sphinx is installed and add target to generate API documentation # Check if Sphinx is installed and add target to generate API documentation
find_package (Sphinx) find_package (Sphinx)
if(SPHINX_FOUND AND BUILDSWIG AND BUILDSWIGPYTHON) if(SPHINX_FOUND AND BUILDSWIG AND BUILDSWIGPYTHON)
# python required for Sphinx build # Python required for Sphinx build
find_package (PythonLibs) find_package (PythonLibs)
string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING}) string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR) list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
@ -97,7 +111,7 @@ if (BUILDDOC)
COMMAND find ${CMAKE_BINARY_DIR}/src -name "_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \; COMMAND find ${CMAKE_BINARY_DIR}/src -name "_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
COMMAND find ${CMAKE_BINARY_DIR}/src -name "pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \; COMMAND find ${CMAKE_BINARY_DIR}/src -name "pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
COMMAND ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/pyupm COMMAND ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/pyupm
# todo: use a separate cmake FILE module for string replacement instead # TODO: use a separate cmake FILE module for string replacement instead
COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python
COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html
COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html
@ -106,10 +120,10 @@ if (BUILDDOC)
COMMENT "Generating API documentation with Sphinx" VERBATIM COMMENT "Generating API documentation with Sphinx" VERBATIM
) )
endif () endif ()
# check if Yuidoc is installed and add target for API documentation # Check if Yuidoc is installed and add target for API documentation
find_package(Yuidoc) find_package(Yuidoc)
if(YUIDOC_FOUND AND BUILDSWIGNODE) if(YUIDOC_FOUND AND BUILDSWIGNODE)
# node required for Yuidoc documentation # Node required for Yuidoc documentation
find_package(Node) find_package(Node)
file(GLOB_RECURSE JSDOC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/doxy/node doxy/node/*) file(GLOB_RECURSE JSDOC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/doxy/node doxy/node/*)
foreach(JSDOC_FILE ${JSDOC_FILES}) foreach(JSDOC_FILE ${JSDOC_FILES})
@ -127,9 +141,23 @@ if (BUILDDOC)
endif() endif()
if (IPK) if (IPK)
message (INFO " - IPK packaging enabled for ${DETECTED_ARCH}")
# Get target package arch from Yocto ADT sysroot if set or host OS, mapping to Ubuntu name if necessary
if (DEFINED ENV{OECORE_TARGET_SYSROOT})
GET_FILENAME_COMPONENT (DETECTED_SYSROOT $ENV{OECORE_TARGET_SYSROOT} NAME)
string (REGEX REPLACE "-poky-linux" "" TARGET_ARCH "${DETECTED_SYSROOT}")
else ()
# Debian uses amd64 to denote x86_64
if (DETECTED_ARCH STREQUAL "x86_64")
set (TARGET_ARCH "amd64")
else ()
set (TARGET_ARCH ${DETECTED_ARCH})
endif ()
endif ()
message (INFO " - Package arch is ${TARGET_ARCH}")
set(CPACK_GENERATOR "DEB" "TGZ") set(CPACK_GENERATOR "DEB" "TGZ")
set(OPKG_ARCH ${DETECTED_ARCH}) set(OPKG_ARCH ${TARGET_ARCH})
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR}) set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
set(upm_PACKAGE_ON_TAG ".") set(upm_PACKAGE_ON_TAG ".")
@ -140,9 +168,9 @@ if (IPK)
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}") "${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
set(CPACK_PACKAGE_NAME "upm") set(CPACK_PACKAGE_NAME "upm")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs") set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH}) set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${TARGET_ARCH})
set(CPACK_SYSTEM_NAME ${DETECTED_ARCH}) set(CPACK_SYSTEM_NAME ${TARGET_ARCH})
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libmraa0 (>= ${MRAA_VERSION})") set(CPACK_DEBIAN_PACKAGE_DEPENDS "mraa (>= ${MRAA_VERSION})")
set(CPACK_DEBIAN_PACKAGE_PROVIDES "upm-dev, upm-dbg, upm-doc") set(CPACK_DEBIAN_PACKAGE_PROVIDES "upm-dev, upm-dbg, upm-doc")
set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES}) set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES}) set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
@ -160,7 +188,7 @@ if (RPM)
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}-${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}") "${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}-${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit") set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit") set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
set(CPACK_RPM_PACKAGE_REQUIRES "libmraa0 >= ${MRAA_VERSION}") set(CPACK_RPM_PACKAGE_REQUIRES "mraa >= ${MRAA_VERSION}")
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel") set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
EXECUTE_PROCESS(COMMAND rpm --showrc EXECUTE_PROCESS(COMMAND rpm --showrc
COMMAND grep -E "dist[[:space:]]*\\." COMMAND grep -E "dist[[:space:]]*\\."
@ -177,3 +205,15 @@ add_subdirectory (src)
if(BUILDEXAMPLES) if(BUILDEXAMPLES)
add_subdirectory (examples/c++) add_subdirectory (examples/c++)
endif() endif()
if(BUILDJAVAEXAMPLES)
add_subdirectory (examples/java)
endif()
if(BUILDTESTS)
find_package (PythonInterp REQUIRED)
if (${PYTHONINTERP_FOUND})
enable_testing ()
add_subdirectory (tests)
endif ()
endif()

View File

@ -1,8 +1,8 @@
UPM - Sensor/Actuator repository for libmraa UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
============== ==============
UPM is a high level repository for sensors that use libmraa. Each sensor links UPM is a high level repository for sensors that use MRAA. Each sensor links
to libmraa and are not meant to be interlinked although some groups of sensors to MRAA and are not meant to be interlinked although some groups of sensors
may be. Each sensor contains a header which allows to interface with it. may be. Each sensor contains a header which allows to interface with it.
Typically a sensor is represented as a class and instantiated. Typically a sensor is represented as a class and instantiated.
@ -14,8 +14,42 @@ sensor in order to reduce load when doing multiple reads to sensor data.
### Example ### Example
A sensor/actuator is expected to work as such (here is the servo ES08A API): A sensor/actuator is expected to work as such (here is the MMA7660 accelerometer API):
@snippet es08a.cxx Interesting ```C++
// Instantiate an MMA7660 on I2C bus 0
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_I2C_BUS,
MMA7660_DEFAULT_I2C_ADDR);
// place device in standby mode so we can write registers
accel->setModeStandby();
// enable 64 samples per second
accel->setSampleRate(upm::MMA7660::AUTOSLEEP_64);
// place device into active mode
accel->setModeActive();
while (shouldRun)
{
int x, y, z;
accel->getRawValues(&x, &y, &z);
cout << "Raw values: x = " << x
<< " y = " << y
<< " z = " << z
<< endl;
float ax, ay, az;
accel->getAcceleration(&ax, &ay, &az);
cout << "Acceleration: x = " << ax
<< "g y = " << ay
<< "g z = " << az
<< "g" << endl;
usleep(500000);
}
```
However implementation and API design is completely up to the developer, some However implementation and API design is completely up to the developer, some
enumerable sensors for example may provide much clever instantiation. Displays enumerable sensors for example may provide much clever instantiation. Displays
@ -34,27 +68,30 @@ You can also refer to the [Intel® IoT Developer Zone](https://software.intel.co
### IDE Integration ### IDE Integration
If you would like to create Eclipse IDE projects using the UPM C++ samples, If you would like to create projects and run the UPM samples using an Intel recommended IDE,
please follow the instructions posted [here](https://software.intel.com/en-us/node/551014). please refer to the Intel Developer Zone IDE page.
This will show you how to import the code and configure your project.
<a href="https://software.intel.com/iot/software/ide"><img src="docs/icons/allides.png"/></a>
### Building UPM ### Building UPM
See @ref building [here](docs/building.md). See building documentation [here](docs/building.md).
### Making your own UPM module ### Making your own UPM module
@ref porting [link](docs/porting.md) has more information on making new UPM modules. Porting [link](docs/porting.md) has more information on making new UPM modules.
There is also an example available for @ref max31855 [sensor](docs/max31855.md). There is also an example available for max31855 [sensor](docs/max31855.md).
Guide on creating Java [bindings](docs/creating_java_bindings.md).
### Naming conventions and rules for new UPM contributions ### Naming conventions and rules for new UPM contributions
Before you begin development, take a look at our @ref naming [conventions](docs/naming.md). Before you begin development, take a look at our naming [conventions](docs/naming.md).
Also, please read the guidelines for @ref contributions [to UPM](docs/contributions.md). Also, please read the guidelines for contributions [to UPM](docs/contributions.md).
Don't forget to check the @ref documentation [section](docs/documentation.md). Don't forget to check the documentation [section](docs/documentation.md).
Make sure you add yourself as an author on every new code file submitted. Make sure you add yourself as an author on every new code file submitted.
If you are providing a fix with significant changes, feel free to add yourself If you are providing a fix with significant changes, feel free to add yourself
@ -63,14 +100,13 @@ as a contributor. Signing-off your commits is mandatory.
API Documentation API Documentation
============== ==============
@htmlonly <a href="http://iotdk.intel.com/docs/master/upm"><img src="docs/icons/c++.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="docs/icons/java.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="docs/icons/c++.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a> <a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a> <a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
@endhtmlonly ### Changelog
Version changelog [here](docs/changelog.md).
Version @ref changelog [here](docs/changelog.md). ### Known Limitations
List of known limitations [here](docs/knownlimitations.md).
List of @ref knownlimitations [here](docs/knownlimitations.md).

View File

@ -0,0 +1,25 @@
# this toolchain file comes from gnuradio project
set( CMAKE_SYSTEM_NAME Linux )
#set( CMAKE_C_COMPILER $ENV{CC} )
#set( CMAKE_CXX_COMPILER $ENV{CXX} )
string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR $ENV{SDKTARGETSYSROOT})
string(REGEX REPLACE "sysroots/" "" CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE )
set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) #same flags for C sources
set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE ) #same flags for C sources
set( CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib )
set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
set( CMAKE_INSTALL_PREFIX $ENV{OECORE_TARGET_SYSROOT}/usr CACHE STRING "" FORCE)
set( ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4 )
set( ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib )
# for java
set( JAVA_AWT_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
set( JAVA_AWT_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjawt.so CACHE FILEPATH "" FORCE)
set( JAVA_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
set( JAVA_INCLUDE_PATH2 $ENV{JAVA_HOME}/include/linux CACHE PATH "" FORCE)
set( JAVA_JVM_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjvm.so CACHE FILEPATH "" FORCE)

View File

@ -5,12 +5,10 @@ UPM uses cmake in order to make compilation relatively painless. Cmake runs
build out of tree so the recommended way is to clone from git and make a build/ build out of tree so the recommended way is to clone from git and make a build/
directory. directory.
This project depends on libmraa, so that needs to be installed first. Use the This project depends on libmraa, so that needs to be installed first. Append
following environment variables to configure the paths: the install location of mraa pkgconfig to the following environment variable:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:.../mraa/build/lib/pkgconfig PKG_CONFIG_PATH=$PKG_CONFIG_PATH:.../mraa/build/lib/pkgconfig
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:.../mraa/build/include
LIBRARY_PATH=$LIBRARY_PATH:.../mraa/build/lib
UPM will attempt to build all directories inside src/ and they must contain UPM will attempt to build all directories inside src/ and they must contain
individual CMakeLists.txt files. individual CMakeLists.txt files.

View File

@ -4,6 +4,60 @@ Changelog {#changelog}
Here's a list summarizing some of the key undergoing changes to our library Here's a list summarizing some of the key undergoing changes to our library
from earlier versions: from earlier versions:
### v0.5.1
* Updated the API and added new functionality for the MY9221 class and derived
sensors: grovecircularled and groveledbar, along with new code samples that
show these changes
* Provided a fix for one JAVA example that uses interrupts and updated library
install paths
* Several documentation improvements and pictures were added for new sensors
* A few other sensors received minor patches
### v0.5.0
* First implementations for industrial grade Modbus sensors, along with first
sensor examples that use the new iio system driver in MRAA
* Significant improvements to the stepmotor driver that will now allow precise
control using any GPIO pin and extended the API with new functionality
* Further improved JAVA bindings and sensor ISRs have been modified to
implement Runnable objects
* Improved Python typemaps and error checking, documentation now includes
detailed function descriptions
* Simplified the build process by eliminating the need to define redundant
MRAA related environment variables
* New sensors: nlgpio16, ads1x15, t3311, hdxxvxta, hwxpxx, rhusb, ili9341,
apds9930, kxcjk1013
### v0.4.1
* Over 150 supported sensor drivers including some industrial grade devices
* Improved the JAVA bindings, added a large number of examples for sensors,
enabled JAVA builds in Travis CI, and introduced automatic loading for the
JAVA shared libraries
* Continued to improve existing sensor drivers and to enhance them with the
new C++ coding style and exception types
* Several cmake improvements to allow building on various Linux distributions
and with a newer version of Node.JS
* Simplified adding and building of C++ sensor examples via cmake
* New sensors: micsv89, xbee, urm37, adxrs610, bma220, dfrph, mcp9808, sx1276,
groveultrasonic, ozw
### v0.4.0
* Fully functional and documented JAVA language bindings for sensors with
several examples also available
* Added standardized exception handling support across all language bindings
and updated sensors to use this feature
* Sensor drivers are now available and can be installed individually using NPM
for Node.js users
* Continuous Integration with Travis CI ensures new contributions are built
automatically once they are received
* API rewrite and improvements for hcsr04, sm130, eboled, loudness
* Documentation improvements and code style changes from C to C++
* New sensors: hyld9767, mg811, wheelencoder, grovegprs, mpu9250, ssd1306,
es9257, lm35, mq4, mq6, mq7, mq8
### v0.3.2 ### v0.3.2
* Introduced RPM package generation feature from cmake via cpack * Introduced RPM package generation feature from cmake via cpack
@ -11,7 +65,7 @@ from earlier versions:
includes last remaining images and grouping sensors by kits includes last remaining images and grouping sensors by kits
* Added support for Sparkfun Sensor Blocks (OLED & IMU) * Added support for Sparkfun Sensor Blocks (OLED & IMU)
* Fully reworked API for at42qt1070, mpu9150 and lcd classes, while * Fully reworked API for at42qt1070, mpu9150 and lcd classes, while
maintaining backwards compatibility for existing lcd displays. maintaining backwards compatibility for existing lcd displays
* Extended doxygen tags for better integration with automated documentation * Extended doxygen tags for better integration with automated documentation
generators generators
* New sensors: rgbringcoder, hp20x, pn532, sainsmartks, lsm9ds0, eboled * New sensors: rgbringcoder, hp20x, pn532, sainsmartks, lsm9ds0, eboled

View File

@ -0,0 +1,353 @@
Creating Java Bindings Guide
==============
* [Overview](#overview)
* [Tools of trade](#tools-of-trade)
* [Recommendations for the native API](#recommendations-for-the-native-api)
* [Pointers](#pointers)
* [Throwing Exceptions in Java](#throwing-exceptions-in-java)
* [Caveats & Challenges](#caveats--challenges)
* [Wrapping C arrays with Java arrays](#wrapping-c-arrays-with-java-arrays)
* [Wrapping unbound C arrays with Java arrays if array is output](#wrapping-unbound-c-arrays-with-java-arrays-if-array-is-output)
* [Wrapping unbound C arrays with Java arrays if array is input](#wrapping-unbound-c-arrays-with-java-arrays-if-array-is-input)
* [Implementing callbacks in Java](#implementing-callbacks-in-java)
##Overview
The "Creating Java Bindings Guide" serves as a basic tutorial for using the SWIG software development tool to create 'glue code' required for Java to call into C/C++ code. It contains: guides for dealing with type conversions, exception handling, callbacks; recommendations on how to write/modify the native API to avoid issues on the Java side, and also workarounds for those issues that can't be avoided.
This guide was created with the [upm](https://github.com/intel-iot-devkit/upm/) and [mraa](https://github.com/intel-iot-devkit/mraa) libraries in mind, and uses examples taken from these sources, but its usage can be extended to any project of creating Java bindings for C/C++ libraries.
##Tools of trade
[SWIG General Documentation](http://www.swig.org/Doc3.0/SWIGDocumentation.html)
[SWIG Java-specific Documentation](http://www.swig.org/Doc3.0/Java.html)
##Recommendations for the native API
###Pointers
As much as possible, avoid passing values/returning values through pointers given as as arguments to methods. As the Java language does not have pointers, SWIG provides a [workaround](http://www.swig.org/Doc3.0/Java.html#Java_tips_techniques) in the typemaps.i library.
####Alternatives:
1. Functions that read data from a driver, return it through a pointer given as argument, and return a bool value, should be __replaced by__ functions that return the value directly and throw a std::runtime_error if a read error occurs. E.g.:
```c++
/*
* Function reads from sensor, places read value in variable bar and
* returns true if succesful. Function returns false if read failed.
*/
bool func(int *bar);
```
__Replaced by:__
```c++
/*
* Function reads from sensor and returns read value.
* Or throws std::runtime_error if a read error occurs
*/
int func();
```
2. Functions that return multiple values through pointers, that make sense to be grouped together into an array<sup>1</sup> (e.g. speed values, acceleration values), should be __replaced by__ functions that return a pointer to an array in which the elements are the returned values. Afterwards, [wrap the C array with a Java array](#wrapping-unbound-c-arrays-with-java-arrays-if-array-is-output). E.g.:
```c++
/*
* Function returns the acceleration on the three
* axis in the given variables.
*/
void getAccel(int *accelX, int *accelY, int *accelZ);
```
__Replaced by:__
```c++
/*
* Function returns the acceleration on the three
* axis as elements of a 3-element array.
*/
int *getAccel();
```
3. Functions that return N values through pointers, that do not make sense to grouped together (e.g. a general purpose function that returns both the light intensity and air pollution), should be __replaced by__ N functions (one for each value) that read only one specific value. E.g.:
```c++
/*
* Function returns the light intensity and air pollution
*/
void getData(int *light, int *air);
```
__Replaced by:__
```c++
int getLight();
int getAir();
```
4. Functions that return N values through pointers; values that do not make sense to be grouped together, but are time dependent, and make sense to be read at the same time. For example, a sensor that reads air humidity and temperature. A user may want to know the temperature value _temp_ read at the exact moment the humidity value _humid_ was read. These should be __replaced by__ N+1 functions: a _getData()_ function that reads all values at the same time and stores them in global variables; and N getter functions, one for each value. E.g.
```c++
/*
* Function returns the light intensity and air pollution
*/
void getData(int *temp, int *humid);
```
__Replaced by:__
```c++
void getData();
int getTemp();
int getHumid();
```
<sup>1</sup>this depends on the interpretation of the returned data. For example, arguments that return the temperature and light intensity, don't make sense to be grouped into an array of size 2. But acceleration on the three axis can be grouped together in an array of size 3. where accelX is accel[0], accelY is accel[1], accelZ is accel[2].
__Notice:__
Sometimes, you may be required to write JNI code. Be aware of the difference between the C JNI calling syntax and the C++ JNI calling syntax.The C++ calling syntax will not compile as C and also vice versa. It is however possible to write JNI calls which will compile under both C and C++ and is covered in the [Typemaps for both C and C++ compilation](http://www.swig.org/Doc3.0/Java.html#Java_typemaps_for_c_and_cpp) section of the SWIG Documentation.
###Throwing Exceptions in Java
####Language independent:
The %exception directive allows you to define a general purpose exception handler. For example, you can specify the following:
```c++
%exception [method_name] {
try {
$action
}
catch (std::invalid_argument& e) {
... handle error ...
}
}
```
If [method_name] is not specified then the directive is applied to all methods in its scope.
The usual thing you'd want to do is catch the C++ exception and throw an equivalent exception in your language.
The exception.i library file provides support for creating language independent exceptions in your interfaces. To use it, simply put an "%include exception.i" in your interface file. This provides a function SWIG_exception() that can be used to raise common language exceptions in a portable manner. For example :
```c++
// Language independent exception handler
%include exception.i
%exception {
try {
$action
} catch(OutOfMemory) {
SWIG_exception(SWIG_MemoryError, "Out of memory");
} catch(...) {
SWIG_exception(SWIG_RuntimeError,"Unknown exception");
}
}
```
In the upm library, the upm_exception.i interface file provides the functionality to catch common exceptions and propagate them through SWIG. It uses the exception.i library file and is language independent.
The upm_exception.i interface file is included in the upm.i file, therefor SWIG wraps all generated methods' body in a try-catch statement for the following exceptions:
* std::invalid_argument
* std::domain_error
* std::overflow_error
* std::out_of_range
* std::length_error
* std::logic_error
* std::bad_alloc
* std::runtime_error
* std::exception
####Java specific:
To throw a specific Java exception:
```c++
%exception {
try {
$action
} catch (std::out_of_range &e) {
jclass clazz = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(clazz, "Range error");
return $null;
}
}
```
Where FindClass and ThrowNew are [JNI functions](http://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html).
Java defines two tipes of exceptions: checked exception and unchecked exceptions (errors and runtime exceptions). Checked exceptions are subject to the [Catch or Specify Requirement](https://docs.oracle.com/javase/tutorial/essential/exceptions/catchOrDeclare.html).
The C++ compiler does not force the code to catch any exception.
The %exception directive does not specify if a method throws a checked exception (does not add classes to the throws clause). For this, the %javaexception(classes) directive is used; where classes is a string containing one or more comma separated Java classes.
```c++
%javaexception("java.lang.Exception") {
try {
$action
} catch (std::out_of_range &e) {
jclass clazz = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(clazz, "Range error");
return $null;
}
}
```
In the upm library, the java_exceptions.i library file provides the functionality to catch exceptions and propagate them through SWIG as Java checked exceptions. The file provides SWIG wrappers, in the form of macros, that can be applied to methods.E.g. use the __READDATA_EXCEPTION(function)__ macro for functions that read data from a sensor and throw a std::runtime_error in case of a read failure. This will result in:
```java
void function throws IOException ();
```
##Caveats & Challenges
###Wrapping C arrays with Java arrays
SWIG can wrap arrays in a more natural Java manner than the default by using the arrays_java.i library file. Just include this file into your SWIG interface file.
###Wrapping unbound C arrays with Java arrays if array is output
Functions that return arrays, return a pointer to that array. E.g.:
```c++
/*
* Function returns the acceleration on the three
* axis as elements of a 3-element array.
*/
int *getAccel();
```
__SWIG:__
```c++
%typemap(jni) int* "jintArray"
%typemap(jstype) int* "int[]"
%typemap(jtype) int* "int[]"
%typemap(javaout) int* {
return $jnicall;
}
%typemap(out) int *getAccel {
$result = JCALL1(NewIntArray, jenv, 3);
JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const signed int*)$1);
}
```
###Wrapping unbound C arrays with Java arrays if array is input
In C, arrays are tipically passed as pointers, with an integer value representig the length of the array. In Java, the length of an array is always known, so the length argument is redundant. This example shows how to wrap the C array and also get rid the length argument. E.g.:
```c++
void func(uint8_t *buffer, int length);
```
__SWIG:__
```c++
%typemap(jtype) (uint8_t *buffer, int length) "byte[]"
%typemap(jstype) (uint8_t *buffer, int length) "byte[]"
%typemap(jni) (uint8_t *buffer, int length) "jbyteArray"
%typemap(javain) (uint8_t *buffer, int length) "$javainput"
%typemap(in,numinputs=1) (uint8_t *buffer, int length) {
$1 = JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
```
!!!! There is a difference between TYPE *name and TYPE * name in typemaps!!!!!
###Implementing callbacks in Java
Callbacks in the UPM Java library (as well as the MRAA Java library) make use of the _void mraa\_java\_isr\_callback(void\* data\)_ method from MRAA.
__Callbacks in the UPM Java library are implemented as follows (we use the a110x Hall Effect sensors as example):__
We extend the sensor class with another method, _installISR\(jobject runnable\)_, which is a wrapper over the original _installISR\(void \(\*isr\)\(void \*\), void \*arg\)_ method. This will install the _mraa\_java\_isr\_callback\(\)_ method as the interrupt service routine \(ISR\) to be called, with _jobject runnable_ as argument.
SWIGJAVA is a symbol that is always defined by SWIG when using Java. We enclose the _installISR\(jobject runnable\)_ method in a _\#if defined(SWIGJAVA)_ check, to ensure the code only exists when creating a wrapper for Java.
```c++
#if defined(SWIGJAVA)
void A110X::installISR(jobject runnable)
{
installISR(mraa_java_isr_callback, runnable);
}
#endif
```
We hide the underlying method, _installISR\(void \(\*isr\)\(void \*\), void \*arg\)_ , and expose only the _installISR\(jobject runnable\)_ to SWIG, through the use of the SWIGJAVA symbol. When SWIGJAVA is defined, we change the access modifier of the underlying method to private.
```c++
public:
#if defined(SWIGJAVA)
void installISR(jobject runnable);
#else
void installISR(void (*isr)(void *), void *arg);
#endif
private:
#if defined(SWIGJAVA)
void installISR(void (*isr)(void *), void *arg);
#endif
```
To use callback in java, we create a ISR class, which implements the Java Runnable interface, and we override the _run\(\)_ method with the code to be executed when the interrupt is received. An example for the a110x Hall sensor that increments a counter each time an interrupt is received:
```java
public class A110X_intrSample {
public static int counter=0;
public static void main(String[] args) throws InterruptedException {
upm_a110x.A110X hall = new upm_a110x.A110X(2);
A110XISR callback = new A110XISR();
hall.installISR(callback);
while(true){
System.out.println("Counter: " + counter);
Thread.sleep(1000);
}
}
}
class A110XISR implements Runnable {
public A110XISR(){
super();
}
public void run(){
A110X_intrSample.counter++;
}
}
```
####Issues with java callbacks and workarounds
__SWIGJAVA not defined at compile time__
Consider the following files:
* example.h - Header file for our source file
* example.cxx - Source file containing the class Example, for which we build java bindings
* example.i - The SWIG interface, that includes the example.h header file
The build process of a java module using SWIG is split into two steps:
1. Generating the intermediate files, from the SWIG interface file. This will produce the java class file (Example.java), the JNI file (exampleJNI.java) and wrapper file (example_wrap.cxx). The source file (example.cxx) is not needed in the first step.
```
swig -c++ -java example.i
```
2. Generating the shared library from the C++ sources and wrapper file
```
g++ -fPIC -c example.cxx example_wrap.cxx -I/usr/lib/jvm/java-1.8.0/include -I/usr/lib/jvm/java-1.8.0/include/linux
g++ -shared example_wrap.o sensor.o -o libexample.so
```
SWIGJAVA is always defined when SWIG parses the interface file, meaning it will be defined when it parses the header file (example.h) that is included in the interface file (example.i).
SWIG also adds the "#define SWIGJAVA" directive in the wrapper file (example_wrap.cxx).
However, in generating the shared library the SWIGJAVA symbol is only defined in the example_wrap.cxx file, because of the added "#define SWIGJAVA" directive. But we have also used the "#if defined(SWIGJAVA)" check in the source file (example.cxx), and thus need to define SWIGJAVA for it too. If we define the SWIGJAVA symbol as a compile flag, when compiling the source code to object code, the SWIGJAVA compile flag and #define SWIGJAVA" directive will clash and give a double definition warning (only a warning).
In this example it is simple to compile the two source codes separately, one with the compile flag, the other without, and then create the shared library (libexample.so).
But in a big automatic build like the java upm libraries, this may prove too hard or too complicated to do. A workaround to this would be to define a custom symbol (e.q. JAVACALLBACK in the upm library) and also test for it. In short, replace:
```c++
#if defined(SWIGJAVA)
```
by
```c++
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
```

View File

@ -50,10 +50,12 @@ Here's an example (disregard the "@verbatim" tags in your actual code):
library's "@defgroup", otherwise this is a new library name, generally the library's "@defgroup", otherwise this is a new library name, generally the
same as chip id. *Mandatory* same as chip id. *Mandatory*
- `<chip-id>` Usually the chip number used by the sensor. When this is not - `<chip-id>` Usually the chip number used by the sensor. When this is not
available or relevant, use a unique descriptor that makes sense. *Mandatory* available or relevant, use a unique descriptor that makes sense. Must match
- `<component-name>` A short name for your sensor, can include manufacturer class name. *Mandatory*
name. *Mandatory* - `<component-name>` A short name for your sensor, try to avoid including the
- `<alt-name>` Alternative names that your sensor driver might have. *Optional* manufacturer's name here. *Mandatory*
- `<alt-name>` Alternative names that your sensor driver might have. This may
include manufacturer's name. *Optional*
- `<alt-id>` Alternative chip-ids that your sensor driver supports. *Optional* - `<alt-id>` Alternative chip-ids that your sensor driver supports. *Optional*
- `<component-category>` Mention one or more categories the sensor fits in. Can - `<component-category>` Mention one or more categories the sensor fits in. Can
be 'other'. *Mandatory* be 'other'. *Mandatory*

BIN
docs/icons/allides.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
docs/icons/eclipse.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
docs/icons/java.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
docs/icons/wyliodrin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
docs/icons/xdk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
docs/images/ads1015.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
docs/images/ads1115.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
docs/images/adxrs610.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
docs/images/bma220.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
docs/images/dfrph.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
docs/images/eboled.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
docs/images/ili9341.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

BIN
docs/images/keypadlcd.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
docs/images/lm35.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

BIN
docs/images/lsm9ds0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
docs/images/mcp9808.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
docs/images/mg811.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
docs/images/micsv89.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
docs/images/mpu60x0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
docs/images/mpu9250.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
docs/images/pn532.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
docs/images/ssd1306.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 198 KiB

BIN
docs/images/urm37.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
docs/images/xbee.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

View File

@ -7,16 +7,21 @@ such sensors and known workarounds if they exist.
#### Grove Sensors #### Grove Sensors
* **Grove I2C Touch Sensor** v1.3 is incompatible with the Intel Edison using * **Grove LCD RGB Backlit** (JHD1313M1) requires 5V and should be used with an
the Arduino board, but will work with the Mini-breakout if supplied with at external power supply connected to the board to function properly. Although
least 4V. Revision v1.2 works well on all Intel boards. some high powered USB ports might be enough, in most cases you will encounter
dropped characters, washed out text and/or failed I2C writes while using USB
power alone.
* **Grove I2C Touch Sensor** (MPR121) v1.3 is incompatible with the Intel
Edison using the Arduino board, but will work with the Mini-breakout if
supplied with at least 4V. Revision v1.2 works well on all Intel boards.
* **Grove Nunchuck** only works with the Intel Galileo boards and is unusable * **Grove Nunchuck** only works with the Intel Galileo boards and is unusable
on the Intel Edison boards. on the Intel Edison boards.
* **Grove 3-Axis Digital Gyroscope** (ITG-3200) is not compatible with the * **Grove 3-Axis Digital Gyroscope** (ITG-3200) is not compatible with the
Intel Edison Arduino board but will work with the Mini-breakout. Intel Edison Arduino board but will work with the Mini-breakout.
* **Grove 3-Axis Digital Accelerometer** (ADXL345) only works with the Intel * **Grove 3-Axis Digital Accelerometer +/-16g** (ADXL345) only works with the
Edison Arduino board when powered from the 3.3V line. Intel Edison Arduino board when powered from the 3.3V line.
* **Grove 3-Axis Digital Compass (HMC5883L) reports inaccurate values at 5V * **Grove 3-Axis Digital Compass** (HMC5883L) reports inaccurate values at 5V
on the Intel Edison Arduino board and newer revisions might not work at all. on the Intel Edison Arduino board and newer revisions might not work at all.
Use 3.3V or the Mini-breakout. Use 3.3V or the Mini-breakout.
* **Grove 96x96 OLED Display** will not work on the Intel Edison with Arduino * **Grove 96x96 OLED Display** will not work on the Intel Edison with Arduino
@ -32,9 +37,18 @@ such sensors and known workarounds if they exist.
Edison with the Arduino board. Edison with the Arduino board.
* **Grove I2C Motor Driver** is not compatible with the Intel Galileo due to * **Grove I2C Motor Driver** is not compatible with the Intel Galileo due to
the inability to change the I2C bus speed to 100 KHz. the inability to change the I2C bus speed to 100 KHz.
* **Grove Digital Light Sensor** (TSL2561) may have an unstable connection on
the Intel Edison using the Arduino breakout that results in missed I2C reads.
This is usually applicable when the I2C lines are pulled-up to 5V. Works as
expected with the Mini-breakout.
* **Grove CO2 Sensor** will return zeroed data and is unusable on the Intel * **Grove CO2 Sensor** will return zeroed data and is unusable on the Intel
Galileo. Galileo.
* **Grove BLE** (HM-11) does not return data on the Intel Galileo board. * **Grove BLE** (HM-11) does not return data on the Intel Galileo board due to
known UART limitation.
* **Grove Hall Sensor** (A11X) if the base shield is set to 3V on Intel Edison,
it will trigger continous callbacks when the sensor is not reading anything.
* **Grove RTC** (DS1307) is not compatible with the Intel Edison Arduino board
but will work with the Mini-breakout.
#### Adafruit Sensors #### Adafruit Sensors
@ -43,15 +57,27 @@ such sensors and known workarounds if they exist.
#### Other Sensors #### Other Sensors
* **SM130** driver might not be fully functional. * **NRF24L01** corrupted data packets are sent to the device due to the Intel
* **NRF24L01** might not handle data packets as expected. Edison SPI bus limitation. Sensor works as expected with the Intel Galileo
* **NRF8001** based devices do not initialize properly with provided examples. boards.
* **NRF8001** based devices do not initialize properly with provided examples
on Intel Edison boards also due to SPI bus limitation and data corruption.
Works on Intel Galileo.
#### General #### General
Some I2C sensors add too much capacitance to the SDA line of the Intel Edison Some *I2C* sensors add too much capacitance to the SDA line of the Intel Edison
Arduino breakout board, thus the signal sticks to a logic 1. When this happens, Arduino breakout board, thus the signal sticks to a logic 1. When this happens,
other sensors connected to the I2C bus are unusable. While there is no generic other sensors connected to the I2C bus are unusable. While there is no generic
solution for this limitation, in most cases the sensor works on the Intel solution for this limitation, in most cases the sensor works on the Intel
Edison Mini-breakout. When this board is not an option, the sensor can be Edison Mini-breakout. When this board is not an option, the sensor can be
sometimes replaced with the same model from a different vendor. sometimes replaced with the same model from a different vendor.
The Intel Edison *SPI* bus can corrupt data being sent across when certain
sensors are connected to it. Based on the sensor, this can affect functionality
slightly or make the sensor entirely unusable. Unlike the I2C bus limitation,
different boards are not likely to resolve this. A kernel update on the other
hand might help alleviate this.
On the Intel Galileo boards, the *UART* bus might drop data if several bytes
are read at once.

View File

@ -26,8 +26,5 @@ sensor can inherit your class if they only have minor changes.
### Doubt ### Doubt
If ever, give either of us a ping via email: If ever, give either of us a ping via email:
mihai.tudor.panu@intel.com mihai.tudor.panu@intel.com or brendan.le.foll@intel.com
john.r.van.drasek@intel.com
brendan.le.foll@intel.com
and we'll try suggest decent names for your module. and we'll try suggest decent names for your module.

View File

@ -767,7 +767,7 @@ WARN_LOGFILE =
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/src/upm.h \ INPUT = @CMAKE_CURRENT_SOURCE_DIR@/src/upm.h \
@CMAKE_CURRENT_SOURCE_DIR@/src \ @CMAKE_CURRENT_SOURCE_DIR@/src \
@CMAKE_CURRENT_SOURCE_DIR@/docs \ @CMAKE_CURRENT_SOURCE_DIR@/docs \
@CMAKE_CURRENT_SOURCE_DIR@/README.md @CMAKE_CURRENT_SOURCE_DIR@/doxy/README.cpp.md
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@ -946,7 +946,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub # (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output. # and want to reuse the introduction page also for the doxygen output.
USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_SOURCE_DIR@/README.md USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_SOURCE_DIR@/doxy/README.cpp.md
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration options related to source browsing # Configuration options related to source browsing

2332
doxy/Doxyfile.java.in Normal file

File diff suppressed because it is too large Load Diff

82
doxy/README.cpp.md Normal file
View File

@ -0,0 +1,82 @@
UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
==============
UPM is a high level repository for sensors that use MRAA. Each sensor links
to MRAA and are not meant to be interlinked although some groups of sensors
may be. Each sensor contains a header which allows to interface with it.
Typically a sensor is represented as a class and instantiated.
The constructor is expected to initialise the sensor and parameters may be used
to provide identification/pin location on the board.
Typically an update() function will be called in order to get new data from the
sensor in order to reduce load when doing multiple reads to sensor data.
### Example
A sensor/actuator is expected to work as such (here is the servo ES08A API):
@snippet es08a.cxx Interesting
However implementation and API design is completely up to the developer, some
enumerable sensors for example may provide much clever instantiation. Displays
may also create more complex structures in order to interface with them.
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples/c%2B%2B).
Multi-sensor samples for the starter and specialized kits can be found in the
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
### Supported Sensors
Supported [sensor list](http://iotdk.intel.com/docs/master/upm/modules.html) from API documentation.
You can also refer to the [Intel IoT Developer Zone](https://software.intel.com/iot/sensors).
### IDE Compatibility
If you would like to create Eclipse IDE projects using the UPM C++ samples,
please follow the instructions provided on the Intel Developer Zone IDE page.
@htmlonly
<a href="https://software.intel.com/iot/software/ide"><img src="docs/icons/eclipse.png"/></a>
@endhtmlonly
### Building UPM
See @ref building here.
### Making your own UPM module
@ref porting link has more information on making new UPM modules.
There is also an example available for @ref max31855 sensor.
### Naming conventions and rules for new UPM contributions
Before you begin development, take a look at our @ref naming conventions.
Also, please read the guidelines for @ref contributions to UPM.
Don't forget to check the @ref documentation section.
Make sure you add yourself as an author on every new code file submitted.
If you are providing a fix with significant changes, feel free to add yourself
as a contributor. Signing-off your commits is mandatory.
API Documentation
==============
@htmlonly
<a href="http://iotdk.intel.com/docs/master/upm"><img src="docs/icons/c++.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="docs/icons/java.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
@endhtmlonly
### Changelog
Version @ref changelog here.
### Known Limitations
List of @ref knownlimitations here.

81
doxy/README.java.md Normal file
View File

@ -0,0 +1,81 @@
UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
UPM is a high level repository for sensors that use MRAA. Each sensor links
to MRAA and are not meant to be interlinked although some groups of sensors
may be. Each sensor contains a header which allows to interface with it.
Typically a sensor is represented as a class and instantiated.
The constructor is expected to initialise the sensor and parameters may be used
to provide identification/pin location on the board.
Typically an update() function will be called in order to get new data from the
sensor in order to reduce load when doing multiple reads to sensor data.
### Example
A sensor/actuator is expected to work as such (here is the servo ES08A API):
@snippet ES08ASample.java Interesting
However implementation and API design is completely up to the developer, some
enumerable sensors for example may provide much clever instantiation. Displays
may also create more complex structures in order to interface with them.
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples/java).
Multi-sensor samples for the starter and specialized kits can be found in the
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
### Supported Sensors
Supported [sensor list](http://iotdk.intel.com/docs/master/upm/java/modules.html) from API documentation.
You can also refer to the [Intel® IoT Developer Zone](https://software.intel.com/iot/sensors).
### IDE Compatibility
If you would like to create Eclipse IDE projects using the UPM Java samples,
please follow the instructions provided on the Intel Developer Zone IDE page.
@htmlonly
<a href="https://software.intel.com/iot/software/ide"><img src="../docs/icons/eclipse.png"/></a>
@endhtmlonly
### Building UPM
See @ref building here.
### Making your own UPM module
@ref porting link has more information on making new UPM modules.
There is also an example available for @ref max31855 sensor.
### Naming conventions and rules for new UPM contributions
Before you begin development, take a look at our @ref naming conventions.
Also, please read the guidelines for @ref contributions to UPM.
Don't forget to check the @ref documentation section.
Make sure you add yourself as an author on every new code file submitted.
If you are providing a fix with significant changes, feel free to add yourself
as a contributor. Signing-off your commits is mandatory.
API Documentation
==============
@htmlonly
<a href="http://iotdk.intel.com/docs/master/upm"><img src="../docs/icons/c++.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="../docs/icons/java.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/icons/python.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/icons/node.png"/></a>
@endhtmlonly
### Changelog
Version @ref changelog here.
### Known Limitations
List of @ref knownlimitations here.

View File

@ -21,7 +21,16 @@ For building UPM, please follow this `link <https://github.com/intel-iot-devkit/
Multi-sensor samples for the starter and specialized kits can be found in the `iot-devkit-samples <https://github.com/intel-iot-devkit/iot-devkit-samples>`_ Multi-sensor samples for the starter and specialized kits can be found in the `iot-devkit-samples <https://github.com/intel-iot-devkit/iot-devkit-samples>`_
repository. repository.
Individual sensor usage examples for python are available `here <https://github.com/intel-iot-devkit/upm/tree/master/examples/python>`_. Individual sensor usage examples for Python are available `here <https://github.com/intel-iot-devkit/upm/tree/master/examples/python>`_.
``IDE Compatibility``
################
While there is no official IDE provided with our Python libraries, we do recommend the web-based IDE Wyliodrin. It can be used with multiple programming
languages, including Python. More information can be found on the Intel Developer Zone IDE page.
.. image:: ../docs/icons/wyliodrin.png
:target: https://software.intel.com/iot/software/ide
``Making your own UPM Module`` ``Making your own UPM Module``
############################## ##############################
@ -48,8 +57,10 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
``List of Available Sensors Drivers`` ``List of Available Sensors Drivers``
###################################### ######################################
Click on the library prefix below to expand the full list of sensors:
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 1
modules modules
@ -57,7 +68,9 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
########################### ###########################
.. image:: ../docs/icons/c++.png .. image:: ../docs/icons/c++.png
:target: http://iotdk.intel.com/docs/master/upm/modules.html :target: http://iotdk.intel.com/docs/master/upm
.. image:: ../docs/icons/java.png
:target: http://iotdk.intel.com/docs/master/upm/java
.. image:: ../docs/icons/python.png .. image:: ../docs/icons/python.png
:target: http://iotdk.intel.com/docs/master/upm/python :target: http://iotdk.intel.com/docs/master/upm/python
.. image:: ../docs/icons/node.png .. image:: ../docs/icons/node.png

View File

@ -7,8 +7,8 @@
<p>Browse to a module or class using the sidebar to view its API <p>Browse to a module or class using the sidebar to view its API
documentation.</p> documentation.</p>
<p>UPM is a high level repository for sensors that use libmraa. Each <p>UPM is a high level repository for sensors that use MRAA. Each
sensor links to libmraa and are not meant to be interlinked although sensor links to MRAA and are not meant to be interlinked although
some groups of sensors may be. Each sensor contains a header which some groups of sensors may be. Each sensor contains a header which
allows to interface with it. Typically a sensor is represented as a allows to interface with it. Typically a sensor is represented as a
class and instantiated.</p> class and instantiated.</p>
@ -36,6 +36,19 @@
href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.</p> href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.</p>
</div> </div>
<div class="section" id="ide">
<h3><tt class="docutils literal"><span class="pre">IDE Compatibility</span>
<span class="pre">UPM</span></tt><a class="headerlink"
href="#ide"
title="Permalink to this headline">*</a></h3>
<p>Intel&reg; XDK IoT Edition is the recommended IDE for Node.js development.
Visit the Intel&reg; Developer Zone IDE page for more information on how to get
started.<br>
<a href="https://software.intel.com/iot/software/ide"><img src="../docs/icons/xdk.png"/></a>
</p>
</div>
<div class="section" id="building-upm"> <div class="section" id="building-upm">
<h3><tt class="docutils literal"><span class="pre">Building</span> <h3><tt class="docutils literal"><span class="pre">Building</span>
<span class="pre">UPM</span></tt><a class="headerlink" <span class="pre">UPM</span></tt><a class="headerlink"
@ -109,7 +122,8 @@
title="Permalink to this headline"></a></h1> title="Permalink to this headline"></a></h1>
<p><a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="../docs/icons/c++.png" /></a> <p><a href="http://iotdk.intel.com/docs/master/upm"><img src="../docs/icons/c++.png" /></a>
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="../docs/icons/java.png" /></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/icons/python.png" /></a> <a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/icons/python.png" /></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/icons/node.png" /></a> <a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/icons/node.png" /></a>
</p> </p>

73
doxy/samples.mapping.txt Normal file
View File

@ -0,0 +1,73 @@
# Mapping C++ sample files to Java sample files
a110x-intr.cxx A110X_intrSample.java
a110x.cxx A110XSample.java
adc121c021.cxx ADC121C021Sample.java
adxl345.cxx Adxl345Sample.java
biss0001.cxx BISS0001Sample.java
bmpx8x.cxx BMPX8XSample.java
buzzer-sound.cxx Buzzer_soundSample.java
cjq4435.cxx CJQ4435Sample.java
ds1307.cxx DS1307Sample.java
enc03r.cxx ENC03RSample.java
es08a.cxx ES08ASample.java
grovebutton.cxx GroveButtonSample.java
groveehr.cxx GroveEHRSample.java
groveled.cxx GroveLEDSample.java
grovelinefinder.cxx GroveLineFinderSample.java
grovelight.cxx GroveLightSample.java
grovemoisture.cxx GroveMoistureSample.java
groverelay.cxx GroveRelaySample.java
groverotary.cxx GroveRotarySample.java
grovescam.cxx GROVESCAMSample.java
groveslide.cxx GroveSlideSample.java
grovespeaker.cxx GroveSpeakerSample.java
grovevdiv.cxx GroveVDivSample.java
grovewater.cxx GroveWaterSample.java
grovewfs.cxx GroveWFSSample.java
guvas12d.cxx GUVAS12DSample.java
h3lis331dl.cxx H3LIS331DLSample.java
hcsr04.cxx HCSR04Sample.java
hm11.cxx HM11Sample.java
hmc5883l.cxx Hmc5883lSample.java
htu21d.cxx HTU21DSample.java
itg3200.cxx Itg3200Sample.java
jhd1313m1-lcd.cxx Jhd1313m1_lcdSample.java
joystick12.cxx Joystick12Sample.java
lcm1602-i2c.cxx Lcm1602_i2cSample.java
ldt0028.cxx LDT0028Sample.java
lol.cxx LoLSample.java
lsm303.cxx LSM303Sample.java
m24lr64e.cxx M24LR64ESample.java
max44000.cxx MAX44000Sample.java
mic.cxx MicrophoneSample.java
mma7455.cxx MMA7455Sample.java
mma7660.cxx MMA7660Sample.java
mpl3115a2.cxx MPL3115A2Sample.java
mpr121.cxx MPR121Sample.java
mpu9150.cxx MPU9150Sample.java
mq2.cxx MQ2Sample.java
mq303a.cxx MQ303ASample.java
mq5.cxx MQ5Sample.java
my9221-ledbar.cxx MY9221_ledbarSample.java
nrf24l01-receiver.cxx NRF24L01_receiverSample.java
nrf24l01-transmitter.cxx NRF24L01_transmitterSample.java
nunchuck.cxx NUNCHUCKSample.java
otp538u.cxx OTP538USample.java
ppd42ns.cxx PPD42NSSample.java
pulsensor.cxx PulsensorSample.java
rfr359f.cxx RFR359FSample.java
rotaryencoder.cxx RotaryEncoderSample.java
rpr220-intr.cxx RPR220_intrSample.java
rpr220.cxx RPR220Sample.java
ssd1308-oled.cxx SSD1308_oledSample.java
ssd1327-oled.cxx SSD1327_oledSample.java
st7735.cxx ST7735Sample.java
stepmotor.cxx StepMotorSample.java
tm1637.cxx TM1637Sample.java
tp401.cxx TP401Sample.java
tsl2561.cxx TSL2561Sample.java
ttp223.cxx TTP223Sample.java
ublox6.cxx Ublox6Sample.java
uln200xa.cxx ULN200XASample.java
wt5001.cxx WT5001Sample.java
yg1006.cxx YG1006Sample.java

View File

@ -1,375 +1,259 @@
# Extract module name from non-standard example name
macro(get_module_name example_name module_name)
string(LENGTH ${example_name} length)
string(FIND ${example_name} "-" index)
if (${index} GREATER 1)
string(SUBSTRING ${example_name} 0 ${index} substr)
set(${module_name} ${substr})
elseif (${example_name} MATCHES "^grove")
set (${module_name} "grove")
elseif ((${example_name} MATCHES "^mq" AND ${length} EQUAL 3) OR ${example_name} STREQUAL "tp401")
set (${module_name} "gas")
else()
set(${module_name} ${example_name})
endif()
endmacro()
# Set source file, include and linker settings for an example
# If example cannot be built, example_bin is cleared
macro(add_custom_example example_bin example_src example_module_list)
set(found_all_modules TRUE)
foreach (module ${example_module_list})
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/${module}")
set(found_all_modules FALSE)
endif()
if (MODULE_LIST)
list(FIND MODULE_LIST ${module} index)
if (${index} EQUAL -1)
set(found_all_modules FALSE)
endif()
endif()
endforeach()
if (found_all_modules)
add_executable (${example_bin} ${example_src})
target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT})
foreach (module ${example_module_list})
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module}")
include_directories (${module_dir})
if (${module} STREQUAL "lcd")
set(module "i2clcd")
endif()
target_link_libraries (${example_bin} ${module})
endforeach()
else()
MESSAGE(INFO " Ignored ${example_bin}")
set (example_bin "")
endif()
endmacro()
# Add specified example by name
# Note special case for grove based examples
macro(add_example example_name)
set(example_src "${example_name}.cxx")
set(example_bin "${example_name}-example")
get_module_name(${example_name} module_name)
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}")
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_src}"
AND EXISTS ${module_dir}
AND IS_DIRECTORY ${module_dir})
add_custom_example(${example_bin} ${example_src} ${module_name})
if ((NOT ${example_bin} STREQUAL "") AND (${module_name} STREQUAL "grove"))
set(grove_module_path "${PROJECT_SOURCE_DIR}/src/${example_name}")
if (EXISTS ${grove_module_path})
include_directories(${grove_module_path})
target_link_libraries (${example_bin} ${example_name})
endif()
endif()
else()
MESSAGE(INFO " Ignored ${example_bin}")
endif()
endmacro()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
add_executable (hmc5883l-example hmc5883l.cxx) # Set the mraa include and link directories prior to adding examples
add_executable (groveled-example groveled.cxx) include_directories (${MRAA_INCLUDE_DIRS})
add_executable (groveled-multi-example groveled-multi.cxx) link_directories (${MRAA_LIBDIR})
add_executable (groverelay-example groverelay.cxx)
add_executable (grovelight-example grovelight.cxx)
add_executable (grovetemp-example grovetemp.cxx)
add_executable (grovebutton-example grovebutton.cxx)
add_executable (groverotary-example groverotary.cxx)
add_executable (groveslide-example groveslide.cxx)
add_executable (lcm1602-lcd-example lcm1602-lcd.cxx)
add_executable (jhd1313m1-lcd-example jhd1313m1-lcd.cxx)
add_executable (buzzer-sound-example buzzer-sound.cxx)
add_executable (my9221-ledbar-example my9221-ledbar.cxx)
add_executable (my9221-updown-example my9221-updown.cxx)
add_executable (nrf24l01-transmitter-example nrf24l01-transmitter.cxx)
add_executable (nrf24l01-receiver-example nrf24l01-receiver.cxx)
add_executable (nrf24l01-broadcast-example nrf24l01-broadcast.cxx)
add_executable (es08a-example es08a.cxx)
add_executable (son-hcsr04-example hcsr04.cxx)
add_executable (ssd1308-oled-example ssd1308-oled.cxx)
add_executable (ssd1327-oled-example ssd1327-oled.cxx)
add_executable (max44000-example max44000.cxx)
add_executable (mma7455-example mma7455.cxx)
add_executable (st7735-example st7735.cxx)
add_executable (max31855-example max31855.cxx)
add_executable (bmpx8x-example bmpx8x.cxx)
add_executable (stepmotor-example stepmotor.cxx)
add_executable (pulsensor-example pulsensor.cxx)
add_executable (mic-example mic.cxx)
add_executable (mpu9150-example mpu9150.cxx)
add_executable (maxds3231m-example maxds3231m.cxx)
add_executable (max31723-example max31723.cxx)
add_executable (max5487-example max5487.cxx)
add_executable (nrf8001-broadcast-example nrf8001-broadcast.cxx)
add_executable (nrf8001-helloworld-example nrf8001-helloworld.cxx)
add_executable (lpd8806-example lpd8806.cxx)
add_executable (mlx90614-example mlx90614.cxx)
add_executable (ecs1030-example ecs1030.cxx)
add_executable (mq2-example mq2.cxx)
add_executable (mq3-example mq3.cxx)
add_executable (mq5-example mq5.cxx)
add_executable (mq9-example mq9.cxx)
add_executable (tp401-example tp401.cxx)
add_executable (tcs3414cs-example tcs3414cs.cxx)
add_executable (th02-example th02.cxx)
add_executable (ttp223-example ttp223.cxx)
add_executable (lsm303-example lsm303.cxx)
add_executable (joystick12-example joystick12-example.cxx)
add_executable (lol-example lol-example.cxx)
add_executable (tsl2561-example tsl2561.cxx)
add_executable (htu21d-example htu21d.cxx)
add_executable (mpl3115a2-example mpl3115a2.cxx)
add_executable (ldt0028-example ldt0028.cxx)
add_executable (am2315-example am2315.cxx)
add_executable (itg3200-example itg3200.cxx)
add_executable (enc03r-example enc03r.cxx)
add_executable (adc121c021-example adc121c021.cxx)
add_executable (ds1307-example ds1307.cxx)
add_executable (a110x-example a110x.cxx)
add_executable (gp2y0a-example gp2y0a.cxx)
add_executable (grovemoisture-example grovemoisture.cxx)
add_executable (groveehr-example groveehr.cxx)
add_executable (ta12200-example ta12200.cxx)
add_executable (grovelinefinder-example grovelinefinder.cxx)
add_executable (grovevdiv-example grovevdiv.cxx)
add_executable (grovewater-example grovewater.cxx)
add_executable (guvas12d-example guvas12d.cxx)
add_executable (groveloudness-example groveloudness.cxx)
add_executable (mpr121-example mpr121.cxx)
add_executable (ublox6-example ublox6.cxx)
add_executable (yg1006-example yg1006.cxx)
add_executable (wt5001-example wt5001.cxx)
add_executable (ppd42ns-example ppd42ns.cxx)
add_executable (mq303a-example mq303a.cxx)
add_executable (grovespeaker-example grovespeaker.cxx)
add_executable (rfr359f-example rfr359f.cxx)
add_executable (biss0001-example biss0001.cxx)
add_executable (rotaryencoder-example rotaryencoder.cxx)
add_executable (adxl345-example adxl345.cxx)
add_executable (rpr220-example rpr220.cxx)
add_executable (rpr220-intr-example rpr220-intr.cxx)
add_executable (mma7660-example mma7660.cxx)
add_executable (cjq4435-example cjq4435.cxx)
add_executable (adxl335-example adxl335.cxx)
add_executable (hmtrp-example hmtrp.cxx)
add_executable (nunchuck-example nunchuck.cxx)
add_executable (otp538u-example otp538u.cxx)
add_executable (grovecollision-example grovecollision.cxx)
add_executable (groveelectromagnet-example groveelectromagnet.cxx)
add_executable (groveemg-example groveemg.cxx)
add_executable (groveo2-example groveo2.cxx)
add_executable (grovegsr-example grovegsr.cxx)
add_executable (ina132-example ina132.cxx)
add_executable (l298-example l298.cxx)
add_executable (l298-stepper-example l298-stepper.cxx)
add_executable (at42qt1070-example at42qt1070.cxx)
add_executable (grovemd-example grovemd.cxx)
add_executable (pca9685-example pca9685.cxx)
add_executable (groveeldriver-example groveeldriver.cxx)
add_executable (adafruitss-example adafruitss.cxx)
add_executable (adafruitms1438-example adafruitms1438.cxx)
add_executable (adafruitms1438-stepper-example adafruitms1438-stepper.cxx)
add_executable (hx711-example hx711.cxx)
add_executable (flex-example flex.cxx)
add_executable (a110x-intr-example a110x-intr.cxx)
add_executable (mhz16-example mhz16.cxx)
add_executable (apds9002-example apds9002.cxx)
add_executable (waterlevel-example waterlevel.cxx)
add_executable (tm1637-example tm1637.cxx)
add_executable (zfm20-example zfm20.cxx)
add_executable (zfm20-register-example zfm20-register.cxx)
add_executable (uln200xa-example uln200xa.cxx)
add_executable (grovewfs-example grovewfs.cxx)
add_executable (isd1820-example isd1820.cxx)
add_executable (sx6119-example sx6119.cxx)
add_executable (si114x-example si114x.cxx)
add_executable (maxsonarez-example maxsonarez.cxx)
add_executable (hm11-example hm11.cxx)
add_executable (ht9170-example ht9170.cxx)
add_executable (h3lis331dl-example h3lis331dl.cxx)
add_executable (ad8232-example ad8232.cxx)
add_executable (grovescam-example grovescam.cxx)
add_executable (m24lr64e-example m24lr64e.cxx)
add_executable (grovecircularled-example grovecircularled.cxx)
add_executable (rgbringcoder-example rgbringcoder.cxx)
add_executable (hp20x-example hp20x.cxx)
add_executable (pn532-example pn532.cxx)
add_executable (pn532-writeurl-example pn532-writeurl.cxx)
add_executable (sainsmartks-example sainsmartks.cxx)
add_executable (mpu60x0-example mpu60x0.cxx)
add_executable (ak8975-example ak8975.cxx)
add_executable (lsm9ds0-example lsm9ds0.cxx)
add_executable (eboled-example eboled.cxx)
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l) # If your sample source file matches the name of the module it tests, add it here
include_directories (${PROJECT_SOURCE_DIR}/src/grove) # Exceptions are as follows:
include_directories (${PROJECT_SOURCE_DIR}/src/lcd) # string after first '-' is ignored (e.g. nrf24l01-transmitter maps to nrf24l01)
include_directories (${PROJECT_SOURCE_DIR}/src/buzzer) # mq? will use module gas
include_directories (${PROJECT_SOURCE_DIR}/src/my9221) # grove* will use module grove
include_directories (${PROJECT_SOURCE_DIR}/src/nrf24l01) add_example (hmc5883l)
include_directories (${PROJECT_SOURCE_DIR}/src/servo) add_example (groveled)
include_directories (${PROJECT_SOURCE_DIR}/src/hcsr04) add_example (groverelay)
include_directories (${PROJECT_SOURCE_DIR}/src/max44000) add_example (grovelight)
include_directories (${PROJECT_SOURCE_DIR}/src/mma7455) add_example (grovetemp)
include_directories (${PROJECT_SOURCE_DIR}/src/st7735) add_example (grovebutton)
include_directories (${PROJECT_SOURCE_DIR}/src/max31855) add_example (groverotary)
include_directories (${PROJECT_SOURCE_DIR}/src/bmpx8x) add_example (groveslide)
include_directories (${PROJECT_SOURCE_DIR}/src/stepmotor) add_example (buzzer-sound)
include_directories (${PROJECT_SOURCE_DIR}/src/pulsensor) add_example (nrf24l01-transmitter)
include_directories (${PROJECT_SOURCE_DIR}/src/mic) add_example (nrf24l01-receiver)
include_directories (${PROJECT_SOURCE_DIR}/src/mpu9150) add_example (nrf24l01-broadcast)
include_directories (${PROJECT_SOURCE_DIR}/src/maxds3231m) add_example (hcsr04)
include_directories (${PROJECT_SOURCE_DIR}/src/max31723) add_example (max44000)
include_directories (${PROJECT_SOURCE_DIR}/src/max5487) add_example (mma7455)
include_directories (${PROJECT_SOURCE_DIR}/src/nrf8001) add_example (st7735)
include_directories (${PROJECT_SOURCE_DIR}/src/lpd8806) add_example (max31855)
include_directories (${PROJECT_SOURCE_DIR}/src/mlx90614) add_example (bmpx8x)
include_directories (${PROJECT_SOURCE_DIR}/src/ecs1030) add_example (stepmotor)
include_directories (${PROJECT_SOURCE_DIR}/src/gas) add_example (pulsensor)
include_directories (${PROJECT_SOURCE_DIR}/src/tcs3414cs) add_example (mic)
include_directories (${PROJECT_SOURCE_DIR}/src/th02) add_example (mpu9150)
include_directories (${PROJECT_SOURCE_DIR}/src/ttp223) add_example (maxds3231m)
include_directories (${PROJECT_SOURCE_DIR}/src/lsm303) add_example (max31723)
include_directories (${PROJECT_SOURCE_DIR}/src/joystick12) add_example (max5487)
include_directories (${PROJECT_SOURCE_DIR}/src/lol) add_example (nrf8001-broadcast)
include_directories (${PROJECT_SOURCE_DIR}/src/tsl2561) add_example (nrf8001-helloworld)
include_directories (${PROJECT_SOURCE_DIR}/src/htu21d) add_example (lpd8806)
include_directories (${PROJECT_SOURCE_DIR}/src/mpl3115a2) add_example (mlx90614)
include_directories (${PROJECT_SOURCE_DIR}/src/ldt0028) add_example (ecs1030)
include_directories (${PROJECT_SOURCE_DIR}/src/am2315) add_example (mq2)
include_directories (${PROJECT_SOURCE_DIR}/src/itg3200) add_example (mq3)
include_directories (${PROJECT_SOURCE_DIR}/src/enc03r) add_example (mq4)
include_directories (${PROJECT_SOURCE_DIR}/src/adc121c021) add_example (mq5)
include_directories (${PROJECT_SOURCE_DIR}/src/ds1307) add_example (mq6)
include_directories (${PROJECT_SOURCE_DIR}/src/a110x) add_example (mq7)
include_directories (${PROJECT_SOURCE_DIR}/src/gp2y0a) add_example (mq8)
include_directories (${PROJECT_SOURCE_DIR}/src/grovemoisture) add_example (mq9)
include_directories (${PROJECT_SOURCE_DIR}/src/groveehr) add_example (tp401)
include_directories (${PROJECT_SOURCE_DIR}/src/ta12200) add_example (tcs3414cs)
include_directories (${PROJECT_SOURCE_DIR}/src/grovelinefinder) add_example (th02)
include_directories (${PROJECT_SOURCE_DIR}/src/grovevdiv) add_example (ttp223)
include_directories (${PROJECT_SOURCE_DIR}/src/grovewater) add_example (lsm303)
include_directories (${PROJECT_SOURCE_DIR}/src/guvas12d) add_example (joystick12)
include_directories (${PROJECT_SOURCE_DIR}/src/groveloudness) add_example (lol)
include_directories (${PROJECT_SOURCE_DIR}/src/mpr121) add_example (tsl2561)
include_directories (${PROJECT_SOURCE_DIR}/src/ublox6) add_example (htu21d)
include_directories (${PROJECT_SOURCE_DIR}/src/yg1006) add_example (mpl3115a2)
include_directories (${PROJECT_SOURCE_DIR}/src/wt5001) add_example (ldt0028)
include_directories (${PROJECT_SOURCE_DIR}/src/ppd42ns) add_example (am2315)
include_directories (${PROJECT_SOURCE_DIR}/src/mq303a) add_example (itg3200)
include_directories (${PROJECT_SOURCE_DIR}/src/grovespeaker) add_example (enc03r)
include_directories (${PROJECT_SOURCE_DIR}/src/rfr359f) add_example (adc121c021)
include_directories (${PROJECT_SOURCE_DIR}/src/biss0001) add_example (ds1307)
include_directories (${PROJECT_SOURCE_DIR}/src/rotaryencoder) add_example (a110x)
include_directories (${PROJECT_SOURCE_DIR}/src/adxl345) add_example (gp2y0a)
include_directories (${PROJECT_SOURCE_DIR}/src/rpr220) add_example (grovemoisture)
include_directories (${PROJECT_SOURCE_DIR}/src/mma7660) add_example (groveehr)
include_directories (${PROJECT_SOURCE_DIR}/src/cjq4435) add_example (ta12200)
include_directories (${PROJECT_SOURCE_DIR}/src/adxl335) add_example (grovelinefinder)
include_directories (${PROJECT_SOURCE_DIR}/src/hmtrp) add_example (grovevdiv)
include_directories (${PROJECT_SOURCE_DIR}/src/nunchuck) add_example (grovewater)
include_directories (${PROJECT_SOURCE_DIR}/src/otp538u) add_example (guvas12d)
include_directories (${PROJECT_SOURCE_DIR}/src/grovecollision) add_example (mpr121)
include_directories (${PROJECT_SOURCE_DIR}/src/groveelectromagnet) add_example (ublox6)
include_directories (${PROJECT_SOURCE_DIR}/src/groveemg) add_example (yg1006)
include_directories (${PROJECT_SOURCE_DIR}/src/groveo2) add_example (wt5001)
include_directories (${PROJECT_SOURCE_DIR}/src/grovegsr) add_example (ppd42ns)
include_directories (${PROJECT_SOURCE_DIR}/src/ina132) add_example (mq303a)
include_directories (${PROJECT_SOURCE_DIR}/src/l298) add_example (grovespeaker)
include_directories (${PROJECT_SOURCE_DIR}/src/at42qt1070) add_example (rfr359f)
include_directories (${PROJECT_SOURCE_DIR}/src/grovemd) add_example (biss0001)
include_directories (${PROJECT_SOURCE_DIR}/src/pca9685) add_example (rotaryencoder)
include_directories (${PROJECT_SOURCE_DIR}/src/groveeldriver) add_example (adxl345)
include_directories (${PROJECT_SOURCE_DIR}/src/adafruitss) add_example (rpr220)
include_directories (${PROJECT_SOURCE_DIR}/src/adafruitms1438) add_example (rpr220-intr)
include_directories (${PROJECT_SOURCE_DIR}/src/hx711) add_example (mma7660)
include_directories (${PROJECT_SOURCE_DIR}/src/flex) add_example (cjq4435)
include_directories (${PROJECT_SOURCE_DIR}/src/mhz16) add_example (adxl335)
include_directories (${PROJECT_SOURCE_DIR}/src/apds9002) add_example (hmtrp)
include_directories (${PROJECT_SOURCE_DIR}/src/waterlevel) add_example (nunchuck)
include_directories (${PROJECT_SOURCE_DIR}/src/tm1637) add_example (otp538u)
include_directories (${PROJECT_SOURCE_DIR}/src/zfm20) add_example (grovecollision)
include_directories (${PROJECT_SOURCE_DIR}/src/uln200xa) add_example (groveelectromagnet)
include_directories (${PROJECT_SOURCE_DIR}/src/grovewfs) add_example (groveemg)
include_directories (${PROJECT_SOURCE_DIR}/src/isd1820) add_example (groveo2)
include_directories (${PROJECT_SOURCE_DIR}/src/sx6119) add_example (grovegsr)
include_directories (${PROJECT_SOURCE_DIR}/src/si114x) add_example (ina132)
include_directories (${PROJECT_SOURCE_DIR}/src/maxsonarez) add_example (l298)
include_directories (${PROJECT_SOURCE_DIR}/src/hm11) add_example (l298-stepper)
include_directories (${PROJECT_SOURCE_DIR}/src/ht9170) add_example (at42qt1070)
include_directories (${PROJECT_SOURCE_DIR}/src/h3lis331dl) add_example (grovemd)
include_directories (${PROJECT_SOURCE_DIR}/src/ad8232) add_example (grovemd-stepper)
include_directories (${PROJECT_SOURCE_DIR}/src/grovescam) add_example (pca9685)
include_directories (${PROJECT_SOURCE_DIR}/src/m24lr64e) add_example (groveeldriver)
include_directories (${PROJECT_SOURCE_DIR}/src/grovecircularled) add_example (adafruitss)
include_directories (${PROJECT_SOURCE_DIR}/src/rgbringcoder) add_example (adafruitms1438)
include_directories (${PROJECT_SOURCE_DIR}/src/hp20x) add_example (adafruitms1438-stepper)
include_directories (${PROJECT_SOURCE_DIR}/src/pn532) add_example (hx711)
include_directories (${PROJECT_SOURCE_DIR}/src/lsm9ds0) add_example (flex)
add_example (a110x-intr)
add_example (mhz16)
add_example (apds9002)
add_example (waterlevel)
add_example (tm1637)
add_example (zfm20)
add_example (zfm20-register)
add_example (uln200xa)
add_example (grovewfs)
add_example (isd1820)
add_example (sx6119)
add_example (si114x)
add_example (maxsonarez)
add_example (hm11)
add_example (ht9170)
add_example (h3lis331dl)
add_example (ad8232)
add_example (grovescam)
add_example (m24lr64e)
add_example (rgbringcoder)
add_example (hp20x)
add_example (pn532)
add_example (pn532-writeurl)
add_example (lsm9ds0)
add_example (loudness)
add_example (mg811)
add_example (wheelencoder)
add_example (sm130)
add_example (grovegprs)
add_example (lm35)
add_example (micsv89)
add_example (xbee)
add_example (urm37)
add_example (urm37-uart)
add_example (adxrs610)
add_example (bma220)
add_example (dfrph)
add_example (mcp9808)
add_example (groveultrasonic)
add_example (sx1276-lora)
add_example (sx1276-fsk)
add_example (ili9341)
if (OPENZWAVE_FOUND)
include_directories(${OPENZWAVE_INCLUDE_DIRS})
add_example (ozw)
endif()
add_example (nlgpio16)
add_example (ads1x15)
if (MODBUS_FOUND)
include_directories(${MODBUS_INCLUDE_DIRS})
add_example (t3311)
add_example (hwxpxx)
endif()
add_example (hdxxvxta)
add_example (rhusb)
add_example (apds9930)
add_example (kxcjk1013)
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT}) # These are special cases where you specify example binary, source file and module(s)
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT}) include_directories (${PROJECT_SOURCE_DIR}/src)
target_link_libraries (groveled-multi-example grove ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (groveled-multi-example groveled-multi.cxx grove)
target_link_libraries (groverelay-example grove ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (lcm1602-i2c-example lcm1602-i2c.cxx lcd)
target_link_libraries (grovelight-example grove ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (lcm1602-parallel-example lcm1602-parallel.cxx lcd)
target_link_libraries (grovetemp-example grove ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (jhd1313m1-lcd-example jhd1313m1-lcd.cxx lcd)
target_link_libraries (grovebutton-example grove ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (es08a-example es08a.cxx servo)
target_link_libraries (groverotary-example grove ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (ssd1306-oled-example ssd1306-oled.cxx lcd)
target_link_libraries (groveslide-example grove ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (ssd1308-oled-example ssd1308-oled.cxx lcd)
target_link_libraries (lcm1602-lcd-example i2clcd ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (ssd1327-oled-example ssd1327-oled.cxx lcd)
target_link_libraries (jhd1313m1-lcd-example i2clcd ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (sainsmartks-example sainsmartks.cxx lcd)
target_link_libraries (buzzer-sound-example buzzer ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (eboled-example eboled.cxx lcd)
target_link_libraries (my9221-ledbar-example my9221 ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (mpu60x0-example mpu60x0.cxx mpu9150)
target_link_libraries (my9221-updown-example my9221 ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (ak8975-example ak8975.cxx mpu9150)
target_link_libraries (nrf24l01-transmitter-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (mpu9250-example mpu9250.cxx mpu9150)
target_link_libraries (nrf24l01-receiver-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (groveledbar-example groveledbar.cxx my9221)
target_link_libraries (nrf24l01-broadcast-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT}) add_custom_example (grovecircularled-example grovecircularled.cxx my9221)
target_link_libraries (es08a-example servo ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (son-hcsr04-example hcsr04 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ssd1308-oled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ssd1327-oled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (max44000-example max44000 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mma7455-example mma7455 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (st7735-example st7735 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (max31855-example max31855 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (bmpx8x-example bmpx8x ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (stepmotor-example stepmotor ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pulsensor-example pulsensor ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mic-example mic ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mpu9150-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (maxds3231m-example maxds3231m ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (max31723-example max31723 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (max5487-example max5487 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (nrf8001-broadcast-example nrf8001 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (nrf8001-helloworld-example nrf8001 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (lpd8806-example lpd8806 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mlx90614-example mlx90614 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ecs1030-example ecs1030 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mq2-example gas ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mq3-example gas ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mq5-example gas ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mq9-example gas ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (tp401-example gas ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (tcs3414cs-example tcs3414cs ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (th02-example th02 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ttp223-example ttp223 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (lsm303-example lsm303 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (joystick12-example joystick12 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (lol-example lol ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (tsl2561-example tsl2561 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (htu21d-example htu21d ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mpl3115a2-example mpl3115a2 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ldt0028-example ldt0028 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (am2315-example am2315 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (itg3200-example itg3200 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (enc03r-example enc03r ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (adc121c021-example adc121c021 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ds1307-example ds1307 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (a110x-example a110x ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (gp2y0a-example gp2y0a ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovemoisture-example grovemoisture ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveehr-example groveehr ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ta12200-example ta12200 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovelinefinder-example grovelinefinder ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovevdiv-example grovevdiv ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovewater-example grovewater ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (guvas12d-example guvas12d ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveloudness-example groveloudness ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mpr121-example mpr121 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ublox6-example ublox6 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (yg1006-example yg1006 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (wt5001-example wt5001 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ppd42ns-example ppd42ns ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mq303a-example mq303a ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovespeaker-example grovespeaker ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (rfr359f-example rfr359f ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (biss0001-example biss0001 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (rotaryencoder-example rotaryencoder ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (adxl345-example adxl345 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (rpr220-example rpr220 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (rpr220-intr-example rpr220 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mma7660-example mma7660 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (cjq4435-example cjq4435 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (adxl335-example adxl335 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (hmtrp-example hmtrp ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (nunchuck-example nunchuck ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (otp538u-example otp538u ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovecollision-example grovecollision ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveelectromagnet-example groveelectromagnet ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveemg-example groveemg ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveo2-example groveo2 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovegsr-example grovegsr ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ina132-example ina132 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (l298-example l298 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (l298-stepper-example l298 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (at42qt1070-example at42qt1070 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovemd-example grovemd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pca9685-example pca9685 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveeldriver-example groveeldriver ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (adafruitss-example adafruitss ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (adafruitms1438-example adafruitms1438 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (adafruitms1438-stepper-example adafruitms1438 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (hx711-example hx711 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (flex-example flex ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (a110x-intr-example a110x ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mhz16-example mhz16 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (apds9002-example apds9002 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (waterlevel-example waterlevel ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (tm1637-example tm1637 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (zfm20-example zfm20 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (zfm20-register-example zfm20 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (uln200xa-example uln200xa ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovewfs-example grovewfs ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (isd1820-example isd1820 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (sx6119-example sx6119 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (si114x-example si114x ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (maxsonarez-example maxsonarez ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (hm11-example hm11 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ht9170-example ht9170 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (h3lis331dl-example h3lis331dl ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ad8232-example ad8232 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovescam-example grovescam ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (m24lr64e-example m24lr64e ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovecircularled-example grovecircularled ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (rgbringcoder-example rgbringcoder ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (hp20x-example hp20x ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pn532-example pn532 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pn532-writeurl-example pn532 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (sainsmartks-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mpu60x0-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ak8975-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (lsm9ds0-example lsm9ds0 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (eboled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})

320
examples/c++/ads1x15.cxx Normal file
View File

@ -0,0 +1,320 @@
/*
* Author: Marc Graham <marc@m2ag.net>
* 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 "mraa.hpp"
#include <iostream>
#include <unistd.h>
#include "ads1015.h"
#include "ads1115.h"
int main()
{
using namespace std;
using namespace upm;
int command;
//Select the device you are testing here and adjust case 6 for the correct sample rates.
//upm::ADS1015 *ads = new upm::ADS1015(1);
upm::ADS1115 *ads = new upm::ADS1115(1, 0x49);
float inputVoltage;
int ans;
do
{
cout << endl;
cout << "1 - get Conversion \t" ;
cout << "2 - get last conversion" << endl;
cout << "3 - get Gain \t\t";
cout << "4 - set Gain" << endl;;
cout << "5 - get Data Rate \t";
cout << "6 - set Data Rate" << endl;
cout << "7 - Set Upper Threshold \t" ;
cout << "8 - Set Lower Threshold \t";
cout << "9 - Display Thresholds \t";
cout << "10 - Set Default Thresholds \t";
cout << "11 - Set conversion ready" << endl;
cout << "12 - get Comp Que \t" ;
cout << "13 - set Comp Que" << endl;
cout << "14 - get Comp Pol \t";
cout << "15 - set Comp Pol" << endl;
cout << "16 - get Comp mode \t";
cout << "17 - set Comp mode " << endl;
cout << "18 - get Comp Latch\t";
cout << "19 - set Comp Latch " << endl;
cout << "20 - get Continuous \t";
cout << "21 - set Continuous \t" << endl;
cout << "-1 - exit" << endl;
cout << "Enter a command: ";
cin >> command;
switch(command)
{
case 2:
cout << ads->getLastSample() << endl;
break;
case 3:
cout << std::hex << ads->getGain() << endl;
break;
case 5:
cout << std::hex << ads->getSPS() << endl;
break;
case 4:
int gain;
ADS1015::ADSGAIN set_gain;
cout << "select one of the following:" << endl;
cout << "1 -> gain 2/3 \t 2 -> gain1 \t 3 -> gain 2" << endl;
cout << "4 -> gain 4 \t 5 -> gain 8 \t 6 -> gain 15" << endl;
cin >> gain;
switch(gain){
case 1:
set_gain = ADS1X15::GAIN_TWOTHIRDS;
break;
case 2:
set_gain = ADS1X15::GAIN_ONE;
break;
case 3:
set_gain = ADS1X15::GAIN_TWO;
break;
case 4:
set_gain = ADS1X15::GAIN_FOUR;
break;
case 5:
set_gain = ADS1X15::GAIN_EIGHT;
break;
case 6:
set_gain = ADS1X15::GAIN_SIXTEEN;
break;
default:
set_gain = ADS1X15::GAIN_ONE;
}
ads->setGain(set_gain);
break;
case 6:
int rate;
/*ADS1015::ADSDATARATE set_rate;
cout << "select one of the following:" << endl;
cout << "1 -> SPS_120 \t 2 -> SPS_250 \t 3 -> SPS_490 \t 4 -> SPS_920" << endl;
cout << "5 -> SPS_1600 \t 6 -> SPS_2400 \t 7 -> SPS_3300" << endl;
cin >> rate;
switch(rate){
case 1:
set_rate = ADS1015::SPS_128;
break;
case 2:
set_rate = ADS1015::SPS_250;
break;
case 3:
set_rate = ADS1015::SPS_490;
break;
case 4:
set_rate = ADS1015::SPS_920;
break;
case 5:
set_rate = ADS1015::SPS_1600;
break;
case 6:
set_rate = ADS1015::SPS_2400;
break;
case 7:
set_rate = ADS1015::SPS_3300;
break;
default:
set_rate = ADS1015::SPS_1600;
} */
ADS1115::ADSDATARATE set_rate;
cout << "select one of the following:" << endl;
cout << "1 -> SPS_8 \t 2 -> SPS_16 \t 3 -> SPS_32 \t 4 -> SPS_64" << endl;
cout << "5 -> SPS_128 \t 6 -> SPS_250 \t 7 -> SPS_475 \t 8-> SPS_860" << endl;
cin >> rate;
switch(rate){
case 1:
set_rate = ADS1115::SPS_8;
break;
case 2:
set_rate = ADS1115::SPS_16;
break;
case 3:
set_rate = ADS1115::SPS_32;
break;
case 4:
set_rate = ADS1115::SPS_64;
break;
case 5:
set_rate = ADS1115::SPS_128;
break;
case 6:
set_rate = ADS1115::SPS_250;
break;
case 7:
set_rate = ADS1115::SPS_475;
break;
case 8:
set_rate = ADS1115::SPS_860;
break;
default:
set_rate = ADS1115::SPS_128;
}
ads->setSPS(set_rate);
break;
case 1:
int mode;
ADS1X15::ADSMUXMODE set_mode;
cout << "select one of the following:" << endl;
cout << "1 -> MUX_0_1 \t 2 -> MUX_0_3 \t 3 -> MUX_1_3 \t 4 -> MUX_2_3" << endl;
cout << "5 -> SINGLE_0 \t 6 -> SINGLE_1 \t 7 -> SINGLE_2 \t 8 -> SINGLE_3" << endl;
cin >> mode;
switch(mode){
case 1:
set_mode = ADS1X15::DIFF_0_1;
break;
case 2:
set_mode = ADS1X15::DIFF_0_3;
break;
case 3:
set_mode = ADS1X15::DIFF_1_3;
break;
case 4:
set_mode = ADS1X15::DIFF_2_3;
break;
case 5:
set_mode = ADS1X15::SINGLE_0;
break;
case 6:
set_mode = ADS1X15::SINGLE_1;
break;
case 7:
set_mode = ADS1X15::SINGLE_2;
break;
case 8:
set_mode = ADS1X15::SINGLE_3;
break;
default:
set_mode = ADS1X15::DIFF_0_1;
break;
}
cout << ads->getSample(set_mode) << endl;
break;
case 7:
cout << " enter a float value: " ;
cin >> inputVoltage;
ads->setThresh(ADS1115::THRESH_HIGH, inputVoltage);
break;
case 8:
cout << " enter a float value: " ;
cin >> inputVoltage;
ads->setThresh(ADS1115::THRESH_LOW, inputVoltage);
break;
case 9:
cout << "Upper " << ads->getThresh(ADS1X15::THRESH_HIGH) << endl;
cout << "Lower " << ads->getThresh(ADS1X15::THRESH_LOW) << endl;
break;
case 10:
ads->setThresh(ADS1115::THRESH_DEFAULT);
break;
case 11:
ads->setThresh(ADS1015::CONVERSION_RDY);
break;
case 12:
cout << ads->getCompQue() << endl;
break;
case 13:
int que;
cout << "select one of the following:" << endl;
cout << "1 -> CQUE_1CONV \t 2 -> CQUE_2CONV \t 3 -> CQUE_3CONV \t 4 -> CQUE_NONE" << endl;
cin >> que;
switch(que){
case 1:
ads->setCompQue(ADS1X15::CQUE_1CONV);
break;
case 2:
ads->setCompQue(ADS1X15::CQUE_2CONV);
break;
case 3:
ads->setCompQue(ADS1X15::CQUE_4CONV);
break;
case 4:
default:
ads->setCompQue(ADS1X15::CQUE_NONE);
break;
}
break;
case 14:
cout << ads->getCompPol() << endl;
break;
case 15:
cout << "select one of the following:" << endl;
cout << "1 -> active high \t 2 -> active low" << endl;
cin >> ans;
if(ans == 1) ads->setCompPol(true);
else ads->setCompPol(false);
break;
case 16:
cout << ads->getCompMode() << endl;
break;
case 17:
cout << "select one of the following:" << endl;
cout << "1 -> Window \t 2 -> Traditional (default)" << endl;
cin >> ans;
if(ans == 1) ads->setCompMode(true);
else ads->setCompMode();
break;
case 18:
cout << ads->getCompLatch() << cout;
break;
case 19:
cout << "select one of the following:" << endl;
cout << "1 -> Latching \t 2 -> Non-latching (default)" << endl;
cin >> ans;
if(ans == 1) ads->setCompLatch(true);
else ads->setCompLatch();
break;
case 20:
cout << ads->getContinuous() << cout;
break;
case 21:
cout << "select one of the following:" << endl;
cout << "1 -> Power Down (default) \t 2 -> Continuous" << endl;
cin >> ans;
if(ans == 1) ads->setContinuous(true);
else ads->setContinuous();
break;
case -1:
break;
default:
break;
}
}while (command != -1 );
delete ads;
return MRAA_SUCCESS;
}

71
examples/c++/adxrs610.cxx Normal file
View File

@ -0,0 +1,71 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "adxrs610.h"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a ADXRS610 sensor on analog pin A0 (dataout), and
// analog A1 (temp out) with an analog reference voltage of
// 5.0
upm::ADXRS610 *sensor = new upm::ADXRS610(0, 1, 5.0);
// set a deadband region around the zero point to report 0.0 (optional)
sensor->setDeadband(0.015);
// Every tenth of a second, sample the ADXRS610 and output it's
// corresponding temperature and angular velocity
while (shouldRun)
{
cout << "Vel (deg/s): " << sensor->getAngularVelocity() << endl;
cout << "Temp (C): " << sensor->getTemperature() << endl;
usleep(100000);
}
//! [Interesting]
cout << "Exiting" << endl;
delete sensor;
return 0;
}

63
examples/c++/apds9930.cxx Normal file
View File

@ -0,0 +1,63 @@
/*
* Author: Lay, Kuan Loon <kuan.loon.lay@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 <signal.h>
#include "apds9930.h"
using namespace std;
int shouldRun = true;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int
main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a Digital Proximity and Ambient Light sensor on iio device 4
upm::APDS9930* light_proximity = new upm::APDS9930(4);
while (shouldRun) {
float lux = light_proximity->getAmbient();
cout << "Luminance value is " << lux << endl;
float proximity = light_proximity->getProximity();
cout << "Proximity value is " << proximity << endl;
sleep(1);
}
//! [Interesting]
cout << "Exiting" << endl;
delete light_proximity;
return 0;
}

70
examples/c++/bma220.cxx Normal file
View File

@ -0,0 +1,70 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "bma220.h"
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 BMA220 using default parameters (bus 0, addr 0x0a)
upm::BMA220 *sensor = new upm::BMA220();
// Output data every half second until interrupted
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer: ";
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

76
examples/c++/dfrph.cxx Normal file
View File

@ -0,0 +1,76 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "dfrph.h"
using namespace std;
bool shouldRun = true;
#define DFRPH_AREF 5.0
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a DFRPH sensor on analog pin A0, with an analog
// reference voltage of DFRPH_AREF
upm::DFRPH *sensor = new upm::DFRPH(0, DFRPH_AREF);
// After calibration, set the offset (based on calibration with a pH
// 7.0 buffer solution). See the UPM sensor documentation for
// calibrations instructions.
sensor->setOffset(0.065);
// Every second, sample the pH and output it's corresponding
// analog voltage.
while (shouldRun)
{
cout << "Detected volts: " << sensor->volts() << endl;
cout << "pH value: " << sensor->pH() << endl;
cout << endl;
sleep(1);
}
//! [Interesting]
cout << "Exiting" << endl;
delete sensor;
return 0;
}

View File

@ -34,10 +34,11 @@ int main(int argc, char **argv)
upm::EBOLED *lcd = new upm::EBOLED(); upm::EBOLED *lcd = new upm::EBOLED();
lcd->clear(); lcd->clear();
lcd->setCursor(2, 0); lcd->setCursor(10, 15);
lcd->write("Hello"); lcd->write("Hello");
lcd->setCursor(3, 5); lcd->setCursor(30, 15);
lcd->write("World!"); lcd->write("World!");
lcd->refresh();
cout << "Sleeping for 5 seconds..." << endl; cout << "Sleeping for 5 seconds..." << endl;
sleep(5); sleep(5);

View File

@ -43,9 +43,9 @@ int main()
//! [Interesting] //! [Interesting]
// Instantiate a Grove Circular LED on gpio pins 5 and 4 // Instantiate a Grove Circular LED on D9 for data, D8 for clock
upm::GroveCircularLED *circle = new upm::GroveCircularLED(5, 4); upm::GroveCircularLED *circle = new upm::GroveCircularLED(9, 8);
int level = 0; int level = 0;
while (shouldRun) while (shouldRun)
@ -54,6 +54,7 @@ int main()
level = (level + 1) % 24; level = (level + 1) % 24;
usleep(100000); usleep(100000);
} }
//! [Interesting] //! [Interesting]
cout << "Exiting" << endl; cout << "Exiting" << endl;

111
examples/c++/grovegprs.cxx Normal file
View File

@ -0,0 +1,111 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include <stdio.h>
#include "grovegprs.h"
using namespace std;
using namespace upm;
void printUsage(char *progname)
{
cout << "Usage: " << progname << " [AT command]" << endl;
cout << endl;
cout << "If an argument is supplied on the command line, that argument is"
<< endl;
cout << "sent to the module and the response is printed out." << endl;
cout << endl;
cout << "If no argument is used, then the manufacturer and the current"
<< endl;
cout << "saved profiles are queried and the results printed out." << endl;
cout << endl;
cout << endl;
}
// simple helper function to send a command and wait for a response
void sendCommand(upm::GroveGPRS* sensor, string cmd)
{
// commands need to be terminated with a carriage return
cmd += "\r";
sensor->writeDataStr(cmd);
// wait up to 1 second
if (sensor->dataAvailable(1000))
{
cout << "Returned: " << sensor->readDataStr(1024) << endl;
}
else
{
cerr << "Timed out waiting for response" << endl;
}
}
int main(int argc, char **argv)
{
//! [Interesting]
// Instantiate a GroveGPRS Module on UART 0
upm::GroveGPRS* sensor = new upm::GroveGPRS(0);
// Set the baud rate, 19200 baud is the default.
if (sensor->setBaudRate(19200) != mraa::SUCCESS)
{
cerr << "Failed to set tty baud rate" << endl;
return 1;
}
printUsage(argv[0]);
if (argc > 1)
{
cout << "Sending command line argument (" << argv[1] << ")..." << endl;
sendCommand(sensor, argv[1]);
}
else
{
// query the module manufacturer
cout << "Querying module manufacturer (AT+CGMI)..." << endl;
sendCommand(sensor, "AT+CGMI");
sleep(1);
// query the saved profiles
cout << "Querying the saved profiles (AT&V)..." << endl;
sendCommand(sensor, "AT&V");
// A comprehensive list is available from the datasheet at:
// http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
}
//! [Interesting]
delete sensor;
return 0;
}

View File

@ -25,7 +25,7 @@
#include <unistd.h> #include <unistd.h>
#include <iostream> #include <iostream>
#include <signal.h> #include <signal.h>
#include "my9221.h" #include "groveledbar.h"
using namespace std; using namespace std;
@ -42,28 +42,27 @@ int main ()
{ {
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]
// Instantiate a MY9221, we use D2 for the data, and D3 for the // Instantiate a GroveLEDBar, we use D8 for the data, and D9 for the
// data clock. This was tested with a Grove LED bar. // clock. This was tested with a Grove LED bar.
upm::GroveLEDBar* bar = new upm::GroveLEDBar(8, 9);
upm::MY9221* bar = new upm::MY9221(2, 3);
while (shouldRun) while (shouldRun)
{ {
// count up from green to red // count up from green to red
for (int i=1; i<=10; i++) for (int i=0; i<=10; i++)
{ {
bar->setBarLevel(i, true); bar->setBarLevel(i, true);
usleep(50000); usleep(100000);
} }
sleep(1); sleep(1);
// count down from red to green // count down from red to green
for (int i=1; i<=10; i++) for (int i=0; i<=10; i++)
{ {
bar->setBarLevel(i, false); bar->setBarLevel(i, false);
usleep(50000); usleep(100000);
} }
sleep(1); sleep(1);
} }
@ -71,7 +70,7 @@ int main ()
cout << "Exiting..." << endl; cout << "Exiting..." << endl;
// turn off the LED's // turn off the LED's
bar->setBarLevel(0, true); bar->setBarLevel(0);
delete bar; delete bar;
return 0; return 0;

View File

@ -0,0 +1,66 @@
/*
* 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.
*/
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include "grovemd.h"
using namespace std;
int main(int argc, char **argv)
{
//! [Interesting]
// Instantiate an I2C Grove Motor Driver on I2C bus 0
upm::GroveMD *motors = new upm::GroveMD(GROVEMD_I2C_BUS,
GROVEMD_DEFAULT_I2C_ADDR);
// This example demonstrates using the GroveMD to drive a stepper motor
// configure it, for this example, we'll assume 200 steps per rev
motors->configStepper(200);
// set for half a rotation
motors->setStepperSteps(100);
// let it go - clockwise rotation, 10 RPM speed
motors->enableStepper(upm::GroveMD::STEP_DIR_CW, 10);
sleep(3);
// Now do it backwards...
motors->setStepperSteps(100);
motors->enableStepper(upm::GroveMD::STEP_DIR_CCW, 10);
// now disable
motors->disableStepper();
//! [Interesting]
cout << "Exiting..." << endl;
delete motors;
return 0;
}

View File

@ -1,6 +1,8 @@
/* /*
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> * Author: Jun Kato <i@junkato.jp>
* Copyright (c) 2014 Intel Corporation. * Copyright (c) 2015 Jun Kato.
*
* Thanks to Seeed Studio for a working arduino sketch
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -24,40 +26,37 @@
#include <unistd.h> #include <unistd.h>
#include <iostream> #include <iostream>
#include "my9221.h" #include "groveultrasonic.h"
#include <signal.h> #include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
int running = 0; upm::GroveUltraSonic *sonar = NULL;
bool running = true;
void void
sig_handler(int signo) sig_handler(int signo)
{ {
printf("got signal\n");
if (signo == SIGINT) { if (signo == SIGINT) {
printf("exiting application\n"); running = false;
running = 1;
} }
} }
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
//! [Interesting] signal(SIGINT, sig_handler);
upm::MY9221 *bar = new upm::MY9221(8, 9); //! [Interesting]
// upm::GroveUltraSonic *sonar = NULL;
signal(SIGINT, sig_handler); sonar = new upm::GroveUltraSonic(2);
while(running) {
while (!running) { int width = sonar->getDistance();
for (int idx = 1; idx < 11; idx++) { printf("Echo width = %d\n", width);
bar->setBarLevel (idx); printf("Distance inches = %f.2\n\n", width/148.0);
usleep(1000); sleep(3);
} }
} //! [Interesting]
//! [Interesting] printf("exiting application\n");
delete sonar;
std::cout << "exiting application" << std::endl; return 0;
delete bar;
return 0;
} }

View File

@ -42,19 +42,20 @@ sig_handler(int signo)
} }
//! [Interesting] //! [Interesting]
void
interrupt (void * args) {
sonar->ackEdgeDetected ();
}
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
sonar = new upm::HCSR04(5, 7, &interrupt); sonar = new upm::HCSR04(5, 6);
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
printf ("width = %d\n", sonar->getDistance()); sleep(1);
std::cout << "exiting application" << std::endl;
for(;;){
std::cout << "get distance" << std::endl;
double distance = sonar->getDistance(CM);
std::cout << "distance " << distance << std::endl;
sleep(5);
}
delete sonar; delete sonar;

79
examples/c++/hdxxvxta.cxx Normal file
View File

@ -0,0 +1,79 @@
/*
* 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 "hdxxvxta.h"
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 HDXXVXTA instance, using A1 for humidity and A0
// for temperature
upm::HDXXVXTA *sensor = new upm::HDXXVXTA(1, 0);
// 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 << endl;
sleep(1);
}
cout << "Exiting..." << endl;
delete sensor;
//! [Interesting]
return 0;
}

102
examples/c++/hwxpxx.cxx Normal file
View File

@ -0,0 +1,102 @@
/*
* 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 "hwxpxx.h"
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 HWXPXX instance, using MODBUS slave address 3, and
// default comm parameters (19200, 8, N, 2)
upm::HWXPXX *sensor = new upm::HWXPXX(defaultDev, 3);
// output the Slave ID (manufacturer, model, serno)
cout << "Slave ID: " << sensor->getSlaveID() << endl;
// stored temperature and humidity offsets
cout << "Temperature Offset: " << sensor->getTemperatureOffset()
<< endl;
cout << "Humidity Offset: " << sensor->getHumidityOffset()
<< endl;
cout << endl;
// 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 << "Slider: " << sensor->getSlider() << " %" << endl;
cout << "Override Switch Status: " << sensor->getOverrideSwitchStatus()
<< endl;
cout << endl;
sleep(1);
}
cout << "Exiting..." << endl;
delete sensor;
//! [Interesting]
return 0;
}

84
examples/c++/ili9341.cxx Normal file
View File

@ -0,0 +1,84 @@
/**
* Author: Shawn Hymel
* Copyright (c) 2016 SparkFun Electronics
*
* 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 "ili9341.h"
int main(int argc, char **argv) {
//! [Interesting]
// Pins (Edison)
// CS_LCD GP44 (MRAA 31)
// CS_SD GP43 (MRAA 38) unused
// DC GP12 (MRAA 20)
// RESEST GP13 (MRAA 14)
upm::ILI9341 * lcd = new upm::ILI9341(31, 38, 20, 14);
// Fill the screen with a solid color
lcd->fillScreen(lcd->color565(0, 40, 16));
// Draw some shapes
lcd->drawFastVLine(10, 10, 100, ILI9341_RED);
lcd->drawFastHLine(20, 10, 50, ILI9341_CYAN);
lcd->drawLine(160, 30, 200, 60, ILI9341_GREEN);
lcd->fillRect(20, 30, 75, 60, ILI9341_ORANGE);
lcd->drawCircle(70, 50, 20, ILI9341_PURPLE);
lcd->fillCircle(120, 50, 20, ILI9341_PURPLE);
lcd->drawTriangle(50, 100, 10, 140, 90, 140, ILI9341_YELLOW);
lcd->fillTriangle(150, 100, 110, 140, 190, 140, ILI9341_YELLOW);
lcd->drawRoundRect(20, 150, 50, 30, 10, ILI9341_RED);
lcd->drawRoundRect(130, 150, 50, 30, 10, ILI9341_RED);
lcd->fillRoundRect(75, 150, 50, 30, 10, ILI9341_RED);
// Write some text
lcd->setCursor(0, 200);
lcd->setTextColor(ILI9341_LIGHTGREY);
lcd->setTextWrap(true);
lcd->setTextSize(1);
lcd->print("Text 1\n");
lcd->setTextSize(2);
lcd->print("Text 2\n");
lcd->setTextSize(3);
lcd->print("Text 3\n");
lcd->setTextSize(4);
lcd->print("Text 4\n");
// Test screen rotation
for(int r = 0; r < 4; r++) {
lcd->setRotation(r);
lcd->fillRect(0, 0, 5, 5, ILI9341_WHITE);
sleep(1);
}
// Invert colors, wait, then revert back
lcd->invertDisplay(true);
sleep(2);
lcd->invertDisplay(false);
// Don't forget to free up that memory!
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -0,0 +1,75 @@
/*
* Author: Lay, Kuan Loon <kuan.loon.lay@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 <signal.h>
#include "kxcjk1013.h"
using namespace std;
int shouldRun = true;
upm::KXCJK1013* accelerometer;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
void
data_callback(char* data)
{
float x, y, z;
accelerometer->extract3Axis(data, &x, &y, &z);
printf("%.1f %.1f %.1f\n", x, y, z);
// usleep(100);
}
int
main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a KXCJK1013 Accelerometer Sensor on iio device 0
accelerometer = new upm::KXCJK1013(0);
accelerometer->setScale(0.019163);
accelerometer->setSamplingFrequency(25.0);
accelerometer->enable3AxisChannel();
accelerometer->installISR(data_callback, NULL);
accelerometer->enableBuffer(16);
while (shouldRun) {
sleep(1);
}
accelerometer->disableBuffer();
//! [Interesting]
cout << "Exiting" << endl;
delete accelerometer;
return 0;
}

View File

@ -32,12 +32,16 @@ main(int argc, char **argv)
lcd->setCursor(0,0); lcd->setCursor(0,0);
lcd->write("Hello World"); lcd->write("Hello World");
//! [Interesting] //! [Interesting]
sleep(3);
lcd->setCursor(1,2); lcd->setCursor(1,2);
lcd->write("Hello World"); lcd->write("Hello World");
sleep(3);
lcd->setCursor(2,4); lcd->setCursor(2,4);
lcd->write("Hello World"); lcd->write("Hello World");
sleep(3);
lcd->setCursor(3,6); lcd->setCursor(3,6);
lcd->write("Hello World"); lcd->write("Hello World");
sleep(3);
delete lcd; delete lcd;
return 0; return 0;

View File

@ -0,0 +1,54 @@
/*
* Author: Sergey Kiselev <sergey.kiselev@intel.com>
* Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 - 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 <lcm1602.h>
int
main(int argc, char **argv)
{
//! [Interesting]
// LCD connection:
// LCD RS pin to digital pin 8
// LCD Enable pin to digital pin 13
// LCD D4 pin to digital pin 2
// LCD D5 pin to digital pin 3
// LCD D6 pin to digital pin 4
// LCD D7 pin to digital pin 5
// LCD R/W pin to ground
// 10K trimmer potentiometer:
// ends to +5V and ground
// wiper to LCD VO pin (pin 3)
upm::Lcm1602 *lcd = new upm::Lcm1602(8, 13, 2, 3, 4, 5, 20, 2);
lcd->setCursor(0,0);
lcd->write("Hello World");
lcd->setCursor(1,2);
lcd->write("Hello World");
printf("Sleeping for 5 seconds\n");
sleep(5);
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -1,6 +1,6 @@
/* /*
* Author: Jon Trulson <jtrulson@ics.com> * Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation. * Copyright (c) 2015 Intel Corporation.
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -25,11 +25,11 @@
#include <unistd.h> #include <unistd.h>
#include <iostream> #include <iostream>
#include <signal.h> #include <signal.h>
#include "groveloudness.h" #include "lm35.h"
using namespace std; using namespace std;
int shouldRun = true; bool shouldRun = true;
void sig_handler(int signo) void sig_handler(int signo)
{ {
@ -37,27 +37,29 @@ void sig_handler(int signo)
shouldRun = false; shouldRun = false;
} }
int main()
int main ()
{ {
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]
// Instantiate a Grove Loudness sensor on analog pin A0
upm::GroveLoudness* loudness = new upm::GroveLoudness(0);
// Print the loudness value every 0.1 seconds // Instantiate a LM35 on analog pin A0, with a default analog
// reference voltage of 5.0
upm::LM35 *sensor = new upm::LM35(0);
// Every half second, sample the sensor and output the temperature
while (shouldRun) while (shouldRun)
{ {
int val = loudness->value(); cout << "Temperature: " << sensor->getTemperature() << " C" << endl;
cout << "Loudness value (higher is louder): " << val << endl;
usleep(500000);
usleep(100000);
} }
//! [Interesting] //! [Interesting]
cout << "Exiting" << endl; cout << "Exiting" << endl;
delete loudness; delete sensor;
return 0; return 0;
} }

68
examples/c++/loudness.cxx Normal file
View File

@ -0,0 +1,68 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "loudness.h"
using namespace std;
bool shouldRun = true;
#define LOUDNESS_AREF 5.0
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a Loudness sensor on analog pin A0, with an analog
// reference voltage of LOUDNESS_AREF
upm::Loudness *loud = new upm::Loudness(0, LOUDNESS_AREF);
// Every tenth of a second, sample the loudness and output it's
// corresponding analog voltage.
while (shouldRun)
{
cout << "Detected loudness (volts): " << loud->loudness() << endl;
usleep(100000);
}
//! [Interesting]
cout << "Exiting" << endl;
delete loud;
return 0;
}

163
examples/c++/mcp9808.cxx Normal file
View File

@ -0,0 +1,163 @@
#include <iostream>
#include <unistd.h>
#include "mcp9808.h"
#include "mraa.hpp"
int main()
{
using namespace std;
//! [Interesting]
int command;
upm::MCP9808 *temp = new upm::MCP9808(6);
do
{
cout << endl;
cout << "1 - read temp \t" ;
cout << "2 - sleep mode \t";
cout << "3 - wake up" << endl;
cout << "4 - set mode to " << (temp->isCelsius() == true ? "Fahrenheit" : "Celcius") << endl;
cout << "5 - show status bits" << endl;
cout << "6 - Set Tcrit \t" ;
cout << "7 - Set Tupper \t" ;
cout << "8 - Set Tlower " << endl;
cout << "9 - Display monitor temps " << endl;
cout << "10 - Enable alert default\t";
cout << "11 - Enable alert interrupt" << endl;
cout << "12 - Clear interrupt \t" ;
cout << "13 - Clear alert mode" << endl;
cout << "14 - Get Hysteresis\t";
cout << "15 - Set Hysteresis" << endl;
cout << "16 - Get Resolution\t";
cout << "17 - Set Resolution" << endl;
cout << "18 - Get Manufacturer ID"<< endl;
cout << "19 - Get Device ID" << endl;
cout << "-1 - exit" << endl;
cout << "Enter a command: ";
cin >> command;
switch(command)
{
float t;
case 1:
std::cout << "Temp: " << temp->getTemp() << "° " << (temp->isCelsius()? "Celsius" : "Fahrenheit")<< std::endl;
break;
case 2:
cout << "shutdown sensor (sleep mode)" << endl;
temp->shutDown();
break;
case 3:
cout << "wake up sensor" << endl;
temp->shutDown(false);
break;
case 4:
cout << "set mode to " << (temp->isCelsius() ? "Fahrenheit" : "Celcius") << endl;
temp->setMode(!temp->isCelsius());
break;
case 5:
cout << "Tcrit = " << temp->isTcrit();
cout << " Tupper = " << temp->isTupper();
cout << " Tlower = " << temp->isTlower();
break;
case 6:
cout << "enter a value";
cin >> t;
temp->setMonitorReg(temp->CRIT_TEMP, t);
break;
case 7:
cout << "enter a value";
cin >> t;
temp->setMonitorReg(temp->UPPER_TEMP, t);
break;
case 8:
cout << "enter a value";
cin >> t;
temp->setMonitorReg(temp->LOWER_TEMP, t);
break;
case 9:
cout << "tcrit = " << temp->getMonitorReg(temp->CRIT_TEMP) << endl;
cout << "tupper = " << temp->getMonitorReg(temp->UPPER_TEMP) << endl;
cout << "tlower = " << temp->getMonitorReg(temp->LOWER_TEMP) << endl;
break;
case 10:
cout << "set alert mode default" ;
temp->setAlertMode(temp->ALERTCTRL);
break;
case 11:
cout << "set alert mode interrupt";
temp->setAlertMode(temp->ALERTMODE | temp->ALERTCTRL );
break;
case 12:
temp->clearInterrupt();
break;
case 13:
cout << "Clear alerts" << endl;
temp->clearAlertMode();
break;
case 14:
cout << "Hysteresis: " << temp->getHysteresis() << endl;
break;
case 15:
int u;
cout << "enter 1 to 4";
cin >> u ;
switch(u)
{
case 1:
temp->setHysteresis(temp->HYST_0);
break;
case 2:
temp->setHysteresis(temp->HYST_1_5);
break;
case 3:
temp->setHysteresis(temp->HYST_3_0);
break;
case 4:
default:
temp->setHysteresis(temp->HYST_6_0);
break;
}
break;
case 16:
cout << "Resolution: " << temp->getResolution() << endl;
break;
case 17:
int v;
cout << "enter 1 to 4";
cin >> v ;
switch(v)
{
case 1:
temp->setResolution(temp->RES_LOW);
break;
case 2:
temp->setResolution(temp->RES_MEDIUM);
break;
case 3:
temp->setResolution(temp->RES_HIGH);
break;
case 4:
default:
temp->setResolution(temp->RES_PRECISION);
break;
}
break;
case 18:
cout << "Manufacturer ID: " << std::hex << temp->getManufacturer() << endl;
break;
case 19:
cout << "Get device ID: " << std::hex << temp->getDevicedId() << endl;
break;
case -1:
break;
default:
cout << endl << "That option is not available. Try again" << endl;
break;
}
}while (command != -1 );
//! [Interesting]
return MRAA_SUCCESS;
}

68
examples/c++/mg811.cxx Normal file
View File

@ -0,0 +1,68 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "mg811.h"
using namespace std;
bool shouldRun = true;
#define MG811_AREF 5.0
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an MG811 on analog pin A0, and digital pin D2 with an
// analog reference voltage of MG811_AREF (5.0)
upm::MG811 *sensor = new upm::MG811(0, 2, MG811_AREF);
// Every tenth of a second, sample the sensor and output it's
// detected CO2 concentration in parts per million (ppm)
while (shouldRun)
{
cout << "CO2 concentration in PPM: " << sensor->ppm() << endl;
usleep(100000);
}
//! [Interesting]
cout << "Exiting" << endl;
delete sensor;
return 0;
}

View File

@ -62,14 +62,15 @@ int main (int argc, char **argv)
sleep(1); sleep(1);
int gas;
int temp;
while (shouldRun) while (shouldRun)
{ {
co2->getData(&gas, &temp); if(!co2->getData()){
cout << "CO2 concentration: " << gas << " PPM, " cerr << "Failed to retrieve data" << endl;
<< "Temperature (in C): " << temp <<endl; continue;
}
cout << "CO2 concentration: " << co2->getGas() << " PPM, "
<< "Temperature (in C): " << co2->getTemperature() <<endl;
sleep(2); sleep(2);
} }

78
examples/c++/micsv89.cxx Normal file
View File

@ -0,0 +1,78 @@
/*
* Author: Marc Graham <marc@m2ag.net>
* 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 <iostream>
#include <unistd.h>
#include <signal.h>
#include "micsv89.h"
/*
* An example for using the MICSV89 sensor library.
* The MICSV89 comes in 4 variants, PWM and I2c
* in 3.3 volts and 5 volts. This library only implements
* the I2c version of the device.
*
* Device output is not valid until a warm up of 15 minutes
* of operation.
*
* Additional linker flags: -lupm-micsv89
*/
using namespace std;
volatile int running = 1;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
cout << "Exiting program." << endl;
running = 0;
}
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
upm::MICSV89 *sensor = new upm::MICSV89(6);
while(running)
{
sensor->update();
while(!sensor->valid());
cout << "co2: " << sensor->co2equ() << endl;
cout << "short: " << sensor->vocshort() << endl;
cout << "tvoc: " << sensor->tvoc() << endl;
cout << "resistor: " << sensor->resistor() << endl;
cout << "****************************" << endl;
sleep(5);
}
delete sensor;
//! [Interesting]
return MRAA_SUCCESS;
}

81
examples/c++/mpu9250.cxx Normal file
View File

@ -0,0 +1,81 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "mpu9250.h"
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]
upm::MPU9250 *sensor = new upm::MPU9250();
sensor->init();
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer: ";
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
sensor->getGyroscope(&x, &y, &z);
cout << "Gryoscope: ";
cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl;
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer: ";
cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl;
cout << "Temperature: " << sensor->getTemperature() << endl;
cout << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

81
examples/c++/mq4.cxx Normal file
View File

@ -0,0 +1,81 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include "mq4.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
bool shouldRun = true;
using namespace std;
void
sig_handler(int signo)
{
if (signo == SIGINT)
{
shouldRun = false;
}
}
//! [Interesting]
int main(int argc, char **argv)
{
// Attach gas sensor to Analog A0
upm::MQ4 *sensor = new upm::MQ4(0);
signal(SIGINT, sig_handler);
uint16_t buffer [128];
thresholdContext ctx;
ctx.averageReading = 0;
ctx.runningAverage = 0;
ctx.averagedOver = 2;
// Infinite loop, ends when script is cancelled
// Repeatedly, take a sample every 2 microseconds;
// find the average of 128 samples; and
// print a running graph of asteriskss as averages
while (shouldRun)
{
int len = sensor->getSampledWindow (2, 128, buffer);
if (len) {
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
sensor->printGraph(&ctx, 5);
if (thresh) {
// do something ....
}
}
}
cout << "Exiting" << endl;
delete sensor;
return 0;
}
//! [Interesting]

81
examples/c++/mq6.cxx Normal file
View File

@ -0,0 +1,81 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include "mq6.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
bool shouldRun = true;
using namespace std;
void
sig_handler(int signo)
{
if (signo == SIGINT)
{
shouldRun = false;
}
}
//! [Interesting]
int main(int argc, char **argv)
{
// Attach gas sensor to Analog A0
upm::MQ6 *sensor = new upm::MQ6(0);
signal(SIGINT, sig_handler);
uint16_t buffer [128];
thresholdContext ctx;
ctx.averageReading = 0;
ctx.runningAverage = 0;
ctx.averagedOver = 2;
// Infinite loop, ends when script is cancelled
// Repeatedly, take a sample every 2 microseconds;
// find the average of 128 samples; and
// print a running graph of asteriskss as averages
while (shouldRun)
{
int len = sensor->getSampledWindow (2, 128, buffer);
if (len) {
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
sensor->printGraph(&ctx, 5);
if (thresh) {
// do something ....
}
}
}
cout << "Exiting" << endl;
delete sensor;
return 0;
}
//! [Interesting]

81
examples/c++/mq7.cxx Normal file
View File

@ -0,0 +1,81 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include "mq7.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
bool shouldRun = true;
using namespace std;
void
sig_handler(int signo)
{
if (signo == SIGINT)
{
shouldRun = false;
}
}
//! [Interesting]
int main(int argc, char **argv)
{
// Attach gas sensor to Analog A0
upm::MQ7 *sensor = new upm::MQ7(0);
signal(SIGINT, sig_handler);
uint16_t buffer [128];
thresholdContext ctx;
ctx.averageReading = 0;
ctx.runningAverage = 0;
ctx.averagedOver = 2;
// Infinite loop, ends when script is cancelled
// Repeatedly, take a sample every 2 microseconds;
// find the average of 128 samples; and
// print a running graph of asteriskss as averages
while (shouldRun)
{
int len = sensor->getSampledWindow (2, 128, buffer);
if (len) {
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
sensor->printGraph(&ctx, 5);
if (thresh) {
// do something ....
}
}
}
cout << "Exiting" << endl;
delete sensor;
return 0;
}
//! [Interesting]

81
examples/c++/mq8.cxx Normal file
View File

@ -0,0 +1,81 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include "mq8.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
bool shouldRun = true;
using namespace std;
void
sig_handler(int signo)
{
if (signo == SIGINT)
{
shouldRun = false;
}
}
//! [Interesting]
int main(int argc, char **argv)
{
// Attach gas sensor to Analog A0
upm::MQ8 *sensor = new upm::MQ8(0);
signal(SIGINT, sig_handler);
uint16_t buffer [128];
thresholdContext ctx;
ctx.averageReading = 0;
ctx.runningAverage = 0;
ctx.averagedOver = 2;
// Infinite loop, ends when script is cancelled
// Repeatedly, take a sample every 2 microseconds;
// find the average of 128 samples; and
// print a running graph of asteriskss as averages
while (shouldRun)
{
int len = sensor->getSampledWindow (2, 128, buffer);
if (len) {
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
sensor->printGraph(&ctx, 5);
if (thresh) {
// do something ....
}
}
}
cout << "Exiting" << endl;
delete sensor;
return 0;
}
//! [Interesting]

52
examples/c++/nlgpio16.cxx Normal file
View File

@ -0,0 +1,52 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include <stdio.h>
#include "nlgpio16.h"
using namespace std;
using namespace upm;
int main(int argc, char **argv)
{
// Instantiate a NLGPIO16 Module on the default UART (/dev/ttyACM0)
upm::NLGPIO16* sensor = new upm::NLGPIO16();
// get the Version
cout << "Device Version: " << sensor->getVersion() << endl;
// read the gpio at pin 3
cout << "GPIO 3 Value: " << sensor->gpioRead(3) << endl;
// read the analog voltage at pin 5
cout << "Analog 5 Voltage: " << sensor->analogReadVolts(5) << endl;
// set the gpio at pin 14 to HIGH
sensor->gpioSet(14);
delete sensor;
return 0;
}
//! [Interesting]

View File

@ -60,7 +60,7 @@ main(int argc, char **argv)
comm->configure (); comm->configure ();
comm->setSpeedRate (upm::NRF_250KBPS); comm->setSpeedRate (upm::NRF_250KBPS);
comm->setChannel (99); comm->setChannel (99);
comm->dataRecievedHandler = nrf_handler; comm->setDataReceivedHandler (nrf_handler);
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);

View File

@ -58,7 +58,7 @@ main(int argc, char **argv)
comm->setPayload (MAX_BUFFER); comm->setPayload (MAX_BUFFER);
comm->setChannel (99); comm->setChannel (99);
comm->configure (); comm->configure ();
comm->dataRecievedHandler = nrf_handler; comm->setDataReceivedHandler (nrf_handler);
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);

View File

@ -49,7 +49,7 @@ int main()
// Instantiate a OTP538U on analog pins A0 and A1 // Instantiate a OTP538U on analog pins A0 and A1
// A0 is used for the Ambient Temperature and A1 is used for the // A0 is used for the Ambient Temperature and A1 is used for the
// Object tempewrature. // Object temperature.
upm::OTP538U *temps = new upm::OTP538U(0, 1, OTP538U_AREF); upm::OTP538U *temps = new upm::OTP538U(0, 1, OTP538U_AREF);
// Output ambient and object temperatures // Output ambient and object temperatures

141
examples/c++/ozw.cxx Normal file
View File

@ -0,0 +1,141 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include "ozw.h"
using namespace std;
int main(int argc, char **argv)
{
//! [Interesting]
string defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (argc > 1)
defaultDev = string(argv[1]);
// Instantiate an OZW instance
upm::OZW *sensor = new upm::OZW();
// The first thing to do is create options, then lock them when done.
sensor->optionsCreate();
sensor->optionsLock();
// Next, initialize it.
cout << "Initializing, this may take awhile depending on your ZWave network"
<< endl;
if (!sensor->init(defaultDev))
{
cerr << "Init failed." << endl;
return 0;
}
cout << "Initialization complete" << endl;
cout << "Dumping nodes..." << endl;
sensor->dumpNodes();
// The following is example output of dumpNodes:
//
// Dumping nodes...
// Node 1: Z-Stick Gen5
// Node 2: Smart Switch 6
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 2, Type: float, Label: Energy, Value: 1.190 kWh
// Index: 3, Type: float, Label: Previous Reading, Value: 1.190 kWh
// Index: 4, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 5, Type: float, Label: Power, Value: 0.000 W
// Index: 6, Type: float, Label: Voltage, Value: 121.256 V
// Index: 7, Type: float, Label: Current, Value: 0.000 A
// Index: 8, Type: bool, Label: Exporting, Value: False
// Index: 45, Type: list, Label: Day, Value: Friday
// Index: 46, Type: byte, Label: Hour, Value: 5
// Index: 47, Type: byte, Label: Minute, Value: 53
// Node 3: Multi Sensor
// Index: 0, Type: bool, Label: Sensor, Value: True
// Index: 1, Type: float, Label: Temperature, Value: 72.8 F
// Index: 2, Type: float, Label: Luminance, Value: 4 lux
// Index: 3, Type: float, Label: Relative Humidity, Value: 22 %
// Index: 17, Type: byte, Label: Battery Level, Value: 98 %
// Node 5: Minimote
// Node 6: Smart Energy Switch
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 2, Type: float, Label: Power, Value: 0.000 W
// Index: 3, Type: float, Label: Energy, Value: 1.609 kWh
// Index: 4, Type: float, Label: Previous Reading, Value: 1.609 kWh
// Index: 5, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 6, Type: float, Label: Power, Value: 0.000 W
// Index: 7, Type: float, Label: Previous Reading, Value: 1.609 W
// Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 9, Type: bool, Label: Exporting, Value: False
// Node 7: Smart Energy Switch
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 2, Type: float, Label: Power, Value: 0.000 W
// Index: 3, Type: float, Label: Energy, Value: 0.000 kWh
// Index: 4, Type: float, Label: Previous Reading, Value: 0.000 kWh
// Index: 5, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 6, Type: float, Label: Power, Value: 0.000 W
// Index: 7, Type: float, Label: Previous Reading, Value: 0.000 W
// Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 9, Type: bool, Label: Exporting, Value: False
//
// So, with the above in mind:
//
// 1. Query the temperature on node 3 and print it out (as a
// string), along with the units of measure:
//
// cout << "Temperature: " << sensor->getValueAsString(3, 1)
// << " " << sensor->getValueUnits(3, 1) << endl;
//
// 2. query the same temperature as a float:
//
// float temperature = sensor->getValueAsFloat(3, 1);
//
// 3. Turn on the light plugged into the switch on Node 7, wait 5
// seconds, then turn it back off again:
//
// cout << "Turning ON node 7" << endl;
// sensor->setValueAsBool(7, 0, true);
//
// cout << "Sleeping for 5 seconds" << endl;
// sleep(5);
//
// cout << "Turning OFF node 7" << endl;
// sensor->setValueAsBool(7, 0, false);
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -27,8 +27,9 @@
#include "pulsensor.h" #include "pulsensor.h"
#include <signal.h> #include <signal.h>
using namespace upm;
int doWork = 0; int doWork = 0;
pulsensor_context sensor_ctx;
void void
sig_handler(int signo) sig_handler(int signo)
@ -49,13 +50,13 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
//! [Interesting] //! [Interesting]
init_pulsensor (&sensor_ctx, handler); Pulsensor *sensor = new Pulsensor(handler);
start_sampler (&sensor_ctx); sensor->start_sampler();
while (!doWork) { while (!doWork) {
usleep (5); usleep (5);
} }
stop_sampler (&sensor_ctx); sensor->stop_sampler();
//! [Interesting] //! [Interesting]
return 0; return 0;
} }

88
examples/c++/rhusb.cxx Normal file
View File

@ -0,0 +1,88 @@
/*
* 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 "rhusb.h"
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 RHUSB instance on defaultDev
upm::RHUSB sensor(defaultDev);
// output the firmware ID
cout << "Firmware ID: " << sensor.getFirmwareID() << endl;
cout << endl;
// 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 << endl;
sleep(1);
}
cout << "Exiting..." << endl;
//! [Interesting]
return 0;
}

74
examples/c++/sm130.cxx Normal file
View File

@ -0,0 +1,74 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <string>
#include <signal.h>
#include <stdio.h>
#include "sm130.h"
using namespace std;
using namespace upm;
int main (int argc, char **argv)
{
//! [Interesting]
// Instantiate a UART based SM130 RFID Module using defaults
upm::SM130* sensor = new upm::SM130();
// set the baud rate. 19200 baud is the default.
if (sensor->setBaudRate(19200))
{
cerr << "Failed to set baud rate" << endl;
return 1;
}
cout << "Resetting..." << endl;
sensor->reset();
cout << "Firmware revision: " << sensor->getFirmwareVersion() << endl;
cout << "Waiting up to 5 seconds for a tag..." << endl;
if (sensor->waitForTag(5000))
{
cout << "Found tag, UID: "
<< sensor->string2HexString(sensor->getUID()) << endl;
cout << "Tag Type: " << sensor->tag2String(sensor->getTagType())
<< endl;
}
else
{
// error
cout << "waitForTag failed: " << sensor->getLastErrorString() << endl;
}
//! [Interesting]
cout << "Exiting" << endl;
delete sensor;
return 0;
}

View File

@ -0,0 +1,149 @@
/*
* Author Marc Graham <marc@m2ag.net>
* Copyright (c) 2015 Intel Corporation.
*
* Adapted from ssd1308 library.
* Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 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 "ssd1306.h"
#define DEVICE_ADDRESS 0x3C
#define BUS_NUMBER 0x6
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,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 192, 192, 192, 224,
224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, 60,
62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31,
30, 62, 62, 62, 62, 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240,
224, 224, 224, 192, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128,
128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195,
195, 7, 15, 15, 63, 127, 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0,
0, 0, 0, 0, 0, 128, 192, 192, 240, 248, 124, 124, 60, 0, 0, 0, 0, 159, 159,
159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0,
0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128,
128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128,
128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255,
0, 0, 0, 0, 3, 7, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255,
255, 255, 0, 0, 224, 248, 252, 252, 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0,
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255,
255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, 255, 255,
255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15,
15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143,
135, 135, 143, 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255,
255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,
224, 248, 248, 255, 255, 255, 255, 255, 127, 15, 255, 255, 255, 255, 255,
255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255,
255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255,
255, 255, 255, 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231,
231, 231, 199, 135, 0, 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0,
0, 0, 224, 240, 248, 248, 252, 254, 255, 255, 255, 127, 63, 63, 31, 15, 7,
7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, 240, 192, 192, 128, 0, 0, 0,
0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7,
0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 7,
7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7,
7, 7, 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7,
7, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15,
31, 127, 127, 127, 255, 255, 252, 252, 252, 248, 240, 240, 240, 224, 224,
224, 192, 192, 192, 192, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192,
224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, 252,
254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
3, 3, 3, 7, 7, 7, 15, 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127,
127, 127, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254,
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, 3, 3,
3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0
};
int
main(int argc, char **argv)
{
//! [Interesting]
upm::SSD1306 *lcd = new upm::SSD1306(BUS_NUMBER, DEVICE_ADDRESS);
lcd->clear();
lcd->stopscroll();
lcd->draw(intel_logo, 1024);
sleep(3);
lcd->clear();
lcd->setCursor(2, 0);
lcd->write("Hello");
lcd->setCursor(3,0);
lcd->write("World");
sleep(3);
lcd->invert(true);
sleep(3);
lcd->dim(true);
sleep(3);
lcd->dim(false);
sleep(3);
lcd->invert(false);
lcd->startscrollright(0x00, 0x0F);
sleep(5);
lcd->stopscroll();
lcd->startscrollleft(0x00, 0x0F);
sleep(5);
lcd->stopscroll();
lcd->startscrolldiagleft(0x00,0x0F);
sleep(5);
lcd->stopscroll();
lcd->startscrolldiagright(0x00,0x0F);
sleep(5);
lcd->stopscroll();
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -1,5 +1,6 @@
/* /*
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> * Authors: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Copyright (c) 2014 Intel Corporation. * Copyright (c) 2014 Intel Corporation.
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
@ -22,13 +23,14 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <iostream> #include <iostream>
#include "stepmotor.h"
#include <signal.h> #include <signal.h>
#include "stepmotor.h"
int doWork = 0; using namespace std;
int doWork = 1;
upm::StepMotor *sensor = NULL; upm::StepMotor *sensor = NULL;
void void
@ -37,7 +39,7 @@ sig_handler(int signo)
printf("got signal\n"); printf("got signal\n");
if (signo == SIGINT) { if (signo == SIGINT) {
printf("exiting application\n"); printf("exiting application\n");
doWork = 1; doWork = 0;
} }
} }
@ -45,26 +47,29 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
//! [Interesting] //! [Interesting]
sensor = new upm::StepMotor(4, 6); sensor = new upm::StepMotor(2, 3);
while (!doWork) { while (doWork) {
sensor->setSpeed (500); cout << "1 Revolution forward and back at 60 rpm" << endl;
sensor->stepForward (500); sensor->setSpeed(60);
usleep (10000); sensor->stepForward(200);
sensor->stepBackwards (500); usleep(1000000);
usleep (10000); sensor->stepBackward(200);
usleep(1000000);
sensor->setSpeed (750); cout << "1 Revolution forward and back at 150 rpm" << endl;
sensor->stepForward (500); sensor->setSpeed(150);
usleep (10000); sensor->stepForward(200);
sensor->stepBackwards (500); usleep(1000000);
usleep (10000); sensor->stepBackward(200);
usleep(1000000);
sensor->setSpeed (1000); cout << "1 Revolution forward and back at 300 rpm" << endl;
sensor->stepForward (500); sensor->setSpeed(300);
usleep (10000); sensor->stepForward(200);
sensor->stepBackwards (500); usleep (1000000);
usleep (10000); sensor->stepBackward(200);
usleep (1000000);
} }
delete sensor; delete sensor;

121
examples/c++/sx1276-fsk.cxx Normal file
View File

@ -0,0 +1,121 @@
/*
* 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.
*/
#include <unistd.h>
#include <stdlib.h>
#include <iostream>
#include <signal.h>
#include "sx1276.h"
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]
cout << "Specify an argument to go into receive mode. Default is transmit"
<< endl;
bool rx = false;
if (argc > 1)
rx = true;
// Instantiate an SX1276 using default parameters
upm::SX1276 *sensor = new upm::SX1276();
// 915Mhz
sensor->setChannel(915000000);
// FSK configuration (rx and tx must be configured the same):
// Tx output power = 14 dBm
// FSK freq deviation = 25000 Hz
// FSK bandwidth = 50000 bps
// FSK AFC bandwidth = 83333 Hz
// FSK datarate = 50000 bps
// FSK preamble len = 5
// FSK fixed length payload = false
// FSK CRC check = true
// FSK (rx) continuous Rx mode = false
sensor->setTxConfig(sensor->MODEM_FSK, 14, 25000, 0,
50000, 0, 5, false, true, false, 0, false);
sensor->setRxConfig(sensor->MODEM_FSK, 50000, 50000,
0, 83333, 5, 0, false, 0, true,
false, 0, false, true);
int count = 0;
int buflen = 64;
char buffer[buflen];
while (shouldRun)
{
if (!rx)
{
snprintf(buffer, buflen, "Ping %d", count++);
cout << "Sending..." << std::string(buffer) << endl;
sensor->sendStr(string(buffer), 3000);
sensor->setSleep();
sleep(1);
}
else
{
// receiving
cout << "Attempting to receive..." << endl;
int rv;
if (rv = sensor->setRx(3000))
{
cout << "setRx returned " << rv << endl;
}
else
{
cout << "Received Buffer: " << sensor->getRxBufferStr() << endl;
}
// go back to sleep when done
sensor->setSleep();
usleep(250000);
}
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -0,0 +1,119 @@
/*
* 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.
*/
#include <unistd.h>
#include <stdlib.h>
#include <iostream>
#include <signal.h>
#include "sx1276.h"
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]
cout << "Specify an argument to go into receive mode. Default is transmit"
<< endl;
bool rx = false;
if (argc > 1)
rx = true;
// Instantiate an SX1276 using default parameters
upm::SX1276 *sensor = new upm::SX1276();
// 915Mhz
sensor->setChannel(915000000);
// LORA configuration (rx and tx must be configured the same):
// Tx output power = 14 dBm
// LORA bandwidth = 125000 (can also be 250K and 500K)
// LORA spreading factor = 7
// LORA coding rate = 1 (4/5)
// LORA preamble len = 8
// LORA symbol timeout = 5
// LORA fixed payload = false
// LORA IQ inversion = false
// LORA (rx) continuous Rx mode = true
sensor->setTxConfig(sensor->MODEM_LORA, 14, 0, 125000,
7, 1, 8, false, true, false, 0, false);
sensor->setRxConfig(sensor->MODEM_LORA, 125000, 7,
1, 0, 8, 5, false, 0, true, false, 0, false, true);
int count = 0;
int buflen = 64;
char buffer[buflen];
while (shouldRun)
{
if (!rx)
{
snprintf(buffer, buflen, "Ping %d", count++);
cout << "Sending..." << std::string(buffer) << endl;
sensor->sendStr(string(buffer), 3000);
sensor->setSleep();
sleep(1);
}
else
{
// receiving
cout << "Attempting to receive..." << endl;
int rv;
if (rv = sensor->setRx(3000))
{
cout << "setRx returned " << rv << endl;
}
else
{
cout << "Received Buffer: " << sensor->getRxBufferStr() << endl;
}
// go back to sleep when done
sensor->setSleep();
usleep(5000);
}
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

115
examples/c++/t3311.cxx Normal file
View File

@ -0,0 +1,115 @@
/*
* 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 "t3311.h"
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 << "Initializing..." << endl;
// Instantiate an T3311 instance, using MODBUS slave address 1, and
// default comm parameters (9600, 8, N, 2)
upm::T3311 *sensor = new upm::T3311(defaultDev, 1);
// output the serial number and firmware revision
cout << "Serial Number: " << sensor->getSerialNumber() << endl;
cout << "Firmware Revision: " << sensor->getFirmwareMajor()
<< "." << sensor->getFirmwareMinor() << endl;
cout << endl;
// 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;
// this value depends on the sensor configuration -- by default
// it is the dew point temperature
cout << "Computed Value: " << sensor->getComputedValue() << endl;
// with FW revisions > 2.44, extended computed data is available
if (sensor->extendedDataAvailable())
{
cout << "Dew Point Temperature: " << sensor->getDewPointTemperature()
<< " C / " << sensor->getDewPointTemperature(true) << " F"
<< endl;
cout << "Absolute Humidity: " << sensor->getAbsoluteHumidity()
<< " g/m3" << endl;
cout << "Specific Humidity: " << sensor->getSpecificHumidity()
<< " g/kg" << endl;
cout << "Mixing Ratio: " << sensor->getMixingRatio()
<< " g/kg" << endl;
cout << "Specific Enthalpy: " << sensor->getSpecificEnthalpy()
<< " kJ/kg" << endl;
}
cout << endl;
sleep(1);
}
cout << "Exiting..." << endl;
delete sensor;
//! [Interesting]
return 0;
}

View File

@ -56,7 +56,7 @@ int main (int argc, char **argv)
// Collect and output NMEA data. There are various libraries out on // Collect and output NMEA data. There are various libraries out on
// the Internet, such as tinyGPS or tinyGPS++ that can handle // the Internet, such as tinyGPS or tinyGPS++ that can handle
// decoding NMEA data and presenting it in a more easily accessable // decoding NMEA data and presenting it in a more easily accessible
// format. This example will just check for, and read raw NMEA data // format. This example will just check for, and read raw NMEA data
// from the device and output it on stdout. // from the device and output it on stdout.

View File

@ -0,0 +1,66 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "urm37.h"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a URM37 sensor on UART 0, with the reset pin on D2
upm::URM37 *sensor = new upm::URM37(0, 2);
// Every half a second, sample the URM37 and output the measured
// distance in cm, and temperature in degrees C
while (shouldRun)
{
cout << "Detected distance (cm): " << sensor->getDistance() << endl;
cout << "Temperature (C): " << sensor->getTemperature() << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting" << endl;
delete sensor;
return 0;
}

65
examples/c++/urm37.cxx Normal file
View File

@ -0,0 +1,65 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "urm37.h"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a URM37 sensor on analog pin A0, reset pin on D2,
// trigger pin on D3 with an analog reference voltage of 5.0
upm::URM37 *sensor = new upm::URM37(0, 2, 3, 5.0);
// Every half a second, sample the URM37 and output the measured
// distance in cm.
while (shouldRun)
{
cout << "Detected distance (cm): " << sensor->getDistance() << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting" << endl;
delete sensor;
return 0;
}

View File

@ -0,0 +1,69 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "wheelencoder.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a DFRobot Wheel Encoder on digital pin D2
upm::WheelEncoder* sensor = new upm::WheelEncoder(2);
// set the counter to 0 and start counting
sensor->clearCounter();
sensor->startCounter();
while (shouldRun)
{
// output milliseconds passed and current sensor count
cout << "Millis: " << sensor->getMillis() << " Count: "
<< sensor->counter() << endl;
sleep(1);
}
sensor->stopCounter();
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

145
examples/c++/xbee.cxx Normal file
View File

@ -0,0 +1,145 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include <stdio.h>
#include "xbee.h"
using namespace std;
using namespace upm;
void printUsage(char *progname)
{
cout << "Usage: " << progname << " [AT command]" << endl;
cout << endl;
cout << "If an argument is supplied on the command line, that argument is"
<< endl;
cout << "sent to the module and the response is printed out." << endl;
cout << endl;
cout << "If no argument is used, then the firmware revision, serial number"
<< endl;
cout << "and the current IP address (if set) are queried." << endl;
cout << endl;
cout << endl;
}
//! [Interesting]
// simple helper function to send a command and wait for a response
void sendCommand(upm::XBee* sensor, string cmd)
{
// commands need to be terminated with a carriage return
cmd += "\r";
sensor->writeDataStr(cmd);
string resp;
while (sensor->dataAvailable(2000))
{
resp += sensor->readDataStr(1024);
}
if (resp.empty())
{
cerr << "Timed out waiting for response" << endl;
return;
}
resp = sensor->stringCR2LF(resp);
cout << "Returned (" << resp.size() << " bytes): " << endl;
cout << resp << endl;
}
int main(int argc, char **argv)
{
// Instantiate a XBee Module on UART 0
upm::XBee* sensor = new upm::XBee(0);
// Set the baud rate, 9600 baud is the default.
if (sensor->setBaudRate(9600))
{
cerr << "Failed to set tty baud rate" << endl;
return 1;
}
printUsage(argv[0]);
if (argc > 1)
{
// enable command mode
sensor->commandMode();
cout << "Sending command line argument (" << argv[1] << ")..." << endl;
sendCommand(sensor, argv[1]);
}
else
{
// enable command mode
sensor->commandMode();
// query the verbose firmware revision
cout << "Querying verbose firmware revision (ATVL)..." << endl;
sendCommand(sensor, "ATVL");
// query the number
cout << "Querying Serial Number High (ATSH)..." << endl;
sendCommand(sensor, "ATSH");
cout << "Querying Serial Number Low (ATSL)..." << endl;
sendCommand(sensor, "ATSL");
cout << "Querying address, if set (ATMY)..." << endl;
sendCommand(sensor, "ATMY");
// For the XBee WiFi S6B
// A comprehensive list of commands and command modes is
// available from the datasheet at:
// ftp1.digi.com/support/documentation/90002180_L.pdf
// For the XBee S1
// A comprehensive list of commands and command modes is
// available from the datasheet at:
// http://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf
// For the XBee WiFi module:
// An example using AT commands to connect to an AP, with a
// private Key using WPA2:
// Connect to AP with SSID 'mySSID':
// ATIDmySSID
// Provide the private key 'secret':
// ATPKsecret
// Use WPA2 encryption
// ATEE2
}
delete sensor;
return 0;
}
//! [Interesting]

View File

@ -0,0 +1,43 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
public class A110XSample {
public static void main(String[] args) throws InterruptedException {
//! [Interesting]
// Instantiate an A110X sensor on digital pin D2
upm_a110x.A110X hall = new upm_a110x.A110X(2);
// check every second for the presence of a magnetic field (south polarity)
while(true){
if(hall.magnetDetected())
System.out.println("Magnet (south polarity) detected.");
else
System.out.println("No magnet detected.");
Thread.sleep(1000);
}
//! [Interesting]
}
}

View File

@ -0,0 +1,57 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
public class A110X_intrSample {
public static int counter=0;
public static void main(String[] args) throws InterruptedException {
//! [Interesting]
// Instantiate an A110X sensor on digital pin D2
upm_a110x.A110X hall = new upm_a110x.A110X(2);
// This example uses a user-supplied interrupt handler to count
// pulses that occur when a magnetic field of the correct polarity
// is detected. This could be used to measure the rotations per
// minute (RPM) of a rotor for example.
A110XISR callback = new A110XISR();
hall.installISR(callback);
while(true){
System.out.println("Counter: " + counter);
Thread.sleep(1000);
}
//! [Interesting]
}
}
class A110XISR implements Runnable {
public A110XISR(){
super();
}
public void run(){
A110X_intrSample.counter++;
}
}

View File

@ -0,0 +1,46 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//NOT TESTED!!!
public class ADC121C021Sample {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate an ADC121C021 on I2C bus 0
upm_adc121c021.ADC121C021 adc = new upm_adc121c021.ADC121C021(0);
// An analog sensor, such as a Grove light sensor,
// must be attached to the adc·
// Prints the value and corresponding voltage every 50 milliseconds
while (true) {
int val = adc.value();
System.out.println("ADC value: " + val + "Volts = " + adc.valueToVolts(val));
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -0,0 +1,51 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//NOT TESTED!!!
public class Adxl345Sample {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
short[] val;
float[] accel;
// Note: Sensor only works at 3.3V on the Intel Edison with Arduino
// breakout
upm_adxl345.Adxl345 sensor = new upm_adxl345.Adxl345(0);
while (true) {
sensor.update();
val = sensor.getRawValues();
accel = sensor.getAcceleration();
System.out.println("Current scale: " + sensor.getScale());
System.out.println("Raw Values: X: " + val[0] + " Y: " + val[1] + " Z: " + val[2]);
System.out.println("Acceleration: X: " + accel[0] + "g Y: " + accel[1] + "g Z: "
+ accel[2] + "g");
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -0,0 +1,47 @@
/*
* Author: Abhishek Malik <abhishek.malik@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import upm_apds9002.APDS9002;
public class Apds9002 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//! [Interesting]
// Instantiate the APDS9002 (Grove luminance sensor) on the Analog pin A0
APDS9002 lum = new APDS9002(0);
while(true){
System.out.println("The Luminance value is : "+lum.value());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
System.out.println("The following exception occured: "+e.getMessage());
}
}
//! [Interesting]
}
}

View File

@ -0,0 +1,45 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
public class BISS0001Sample{
public static void main(String[] args) throws InterruptedException {
//! [Interesting]
// Instantiate a Grove Motion sensor on GPIO pin D7
upm_biss0001.BISS0001 motion = new upm_biss0001.BISS0001(7);
while (true) {
boolean value = motion.value();
if(value)
System.out.println("Detecting moving object");
else
System.out.println("No moving objects detected");
Thread.sleep(1000);
}
//! [Interesting]
}
}

Some files were not shown because too many files have changed in this diff Show More