Compare commits

..

191 Commits

Author SHA1 Message Date
78eb975435 upm: v1.2.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 20:38:25 -07:00
a0ea3d5f3d es9257: updated min/max pulse values for C driver
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 20:38:25 -07:00
f77863dfb5 tcs3414cs: added I2C bus and address parameters to constructor
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 20:38:18 -07:00
7e5f6e9856 max31723: added bus parameter to constructor
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 18:37:08 -07:00
d004aa68b7 lpd8806: added bus parameter to constructor
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 18:36:05 -07:00
3aef2ea70e docs: updated @param tags, added missing function descriptions, other minor changes
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 16:59:39 -07:00
39df7fd10f examples: Handle additional example dependencies
Dependencies added via 'TARGETS' in add_example are 'in addition to' the
dependency provided by the example filename.

    * Small change to examples/CMakeLists.txt to handle additional
      dependencies
    * Prefix 'interfaces-' onto the interfaces examples

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-06 14:16:55 -07:00
b8738b32ca Removing example not required anymore
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-06 10:20:47 -07:00
cdb697fd7b nrf8001 examples: minor changes to avoid clang build failures
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-05 18:28:36 -06:00
27dc4a5742 Static Analysis fix and Documentation comment changes
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-05 16:24:07 -07:00
e2fe04927f examples: Added ending 'Interesting' tags
A handful of examples were missing the terminating 'Interesting' tag.
Added these.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:43:02 -07:00
a655235c70 snippet: Updated all snippet tags
Ensure all src C++ headers which have corresponding C++ examples have
doxygen tags which point to those examples.  Some were missing, some
were invalid, some needed to be updated to match the new example names.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:16:20 -07:00
96b219d2fb examples: Added 'Interesting' tag to examples
* Added //! [Interesting] tag to all examples which were missing this
* Removed windows CR/LF
* Removed pointers from examples since these are not needed.  Removed
  try/catch which seems to be there only to handle failing pointers and
  return value from main.
* Reformatted examples when the formatting was wonky/inconstant.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:16:20 -07:00
52879b0b04 contributions.md: Updated sensortemplate script
C/C++ CMakeLists.txt lines are no longer needed - removed.
Converted bash script to a function to add some error checking.
Removed redundant author/copyright entry.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:16:20 -07:00
048f1ac08e examples: C/C++ examples use transitive dependencies
Updated the examples to comprehend transitive dependencies.  This means
that each example target will no longer have a giant list of -I includes
(the examples at the end of the list had includes for all previous
examples, upwards of 200 -I's on the command line).

    * Created a CMakeLists.txt in the upm/examples directory, moved
      common functionality to this level.
    * C/C++ examples now look to the filename for their dependency
      target name, ie; gas-mq2.cxx adds a dependency to the 'gas' target
    * Updated a handful of C/C++ example names to reflect this
    * Example CMake flow - glob the list of files, add targets for any
      special case examples, then att targets for all the rest

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:16:20 -07:00
76a12af15f apichanges.md: Add a section on the renames of constants for C ports
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-05 13:16:11 -06:00
e6ed49427a README.md: update MMA7660 snippet to reflect current reality
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-05 13:16:11 -06:00
c57a0d2c30 bmpx8x: rewrite in C; FTI; C++ wraps C
This driver has been rewritten from scratch.

See docs/apichanges.md for a list of API compatibility changes
compared to the original driver.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-05 11:29:08 -06:00
8d43c431f2 ABP: Making driver generic
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-04 14:34:11 -07:00
336251740d readme: update example and notice on API changes to grove and i2clcd
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-04 13:31:25 -07:00
356f0348ed RSC: Fixing static analysis issues
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-03 21:53:36 -07:00
dc7c012c24 RSC: Minor comment changes
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-03 14:16:52 -07:00
96eb834e9b RSC: Initial Commit
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-03 09:56:54 -07:00
b239866e99 bmm150 C example: use correct units in output
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 18:19:25 -06:00
6a4f06d51b mcp2515 C examples: add default config for Arduino 101
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 17:34:31 -06:00
e765dcf57b bma250e,bmc150,bmg160,bmi055,bmm150,bmx055: C++ examples: use instance rather than allocation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
a594036778 bma250e: correct some comments/documentation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
c014ffddcd bmx055: remove bmm150, use new bmm150 library
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
aeaf84ccc6 bmm150: split into new library, C port, FTI, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
7d789ec208 bma250e: fix up some comments and error messages
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
3d0461b40a bmx055: remove bma250e, use new bma250e library
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
5aed632782 bma250e: split into new library, C port, FTI, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
3c5a5b87c8 bmg160: use MRAA::Edge for interrupt edge specification
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
22a6c52795 bmg160: fixup some comments, add GPIO to FTI
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
b8fa948f7d src/CMakeLists.txt: always add upm include dirs to includes
Previously, the upm include dir was only added for C targets.  This
breaks when you have a C++ only target that depends on a C++/C driver.
Suddenly, you can't find header files like upm.h, upm_platform.h, etc.

This patch has the UPM include dirs always added for all targets.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
f61b615704 bmx055: remove bmg160, use new bmg160 library
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
8dcd22794b bmg160: C port, FTI, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
33f3c882b8 bno055: remove duplicate #defines from header
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
5943dad78c rf22: Removed new from examples
Removed new from examples.  Client had new w/o delete.  These
don't need to be pointers.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
2f051a202c ldt0028: Removed new for example array
Not necessary in C++.  This was getting flagged as a memory
leak in the examples.  Not a big deal, but can be done differently.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
a760f2952a memleak: Free alloc'ed memory for device
Added free for device context.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
9549529faf p9813.cxx: Handle buffer overrun
Changed for loop iterator from <= to <.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
65969462d1 memleak: i2c init was getting called twice
Removed duplicate call to mraa_i2c_init which was allocating
space for the i2c device twice.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
13eea53090 memleak: Free alloc'ed memory for device
Added free for device context.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
fa8ab6194d memleak: Handle freeing return from spi call
mraa_spi_write_buf returns an allocated buffer.  Added call to free
the allocated memory.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
8048e8734f doxygen: Relative paths in generated docs - update
Reverted changes to CMakeLists.txt, change is done solely in
Doxygen.in.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-28 12:29:11 -07:00
8262a4203b doxygen: Use relative paths in generated docs
Updated cmake to use strip the full path to the base UPM directory
from generated documentation.  This removes the build server full-
path from UPM documentation.

Old html:

upm: /iotdk/jenkins/workspace/upm-doc-stable/src/moisture/moisture.h File Reference

New html:

upm: src/moisture/moisture.h File Reference

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-28 11:35:11 -07:00
01f9dd2f41 ims/max30100: Fixed small typo
Changed Initilize -> Initialize.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-20 16:23:37 -07:00
ccb9fa2a4f doc: Updated spelling occured -> occurred
Fixed small typo.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-20 14:26:50 -07:00
05435eed4f docs: Small updates to descriptions.
Updated descriptions on four headers.  One header needed a description.
Replaced 'driver' with 'library' on the other three.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-20 10:30:20 -07:00
54a84af1c3 light: modify so C++ wraps C code
This also provides some more functionality.  get_raw() has been
deprecated in favor of using getNormalized().

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 16:24:15 -06:00
27c6ac1d31 java: solved unclean Java bindings for: htu21d, ozw
Signed-off-by: Bogdan Ichim <bogdan.ichim@rinftech.com>
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
2017-03-17 11:44:41 -06:00
8779700d82 md: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
f9b5d7c52c sht1x: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
a10e798682 md: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
8cd91624ee mcp2515: remove carrays from java interface file
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
68e42a22d6 ims: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
fdef953859 bmi160: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
3f334ed1f3 bh1750: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
1a0bdf00cf mmc35240: add mraa dependency to cmakelists
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-17 08:58:48 -07:00
54cd191d43 src/tmp006/tmp006.hpp: fixed encoding error
Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:28:07 -07:00
9fa4dad1ab src/<sensor>/<sensor>.hpp: fixed file_encoding errors
Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:27:35 -07:00
080c121e07 src/<sensor>/CMakeLists.txt: Added mraa dependency in 'upm_module_init'
Like Propanu commented, I changed the dependency of mraa library in each
CMakeLists.txt file of the sensors:
hdc1000 , mag3110 , mma8x5x , tcs37727 , tmp006

Signed-off-by: Norbert Wesp nwesp@phytec.de
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:27:00 -07:00
545e288967 examples/c++/<sensor>.cxx: changed cout / endl to std::cout / std::endl
Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:26:27 -07:00
aecdac255d hdc1000: Added upm support for sensor HDC1000
The HDC1000 is a digital humidity sensor with integrated temperature sensor.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:25:56 -07:00
5c837f22cb mag3110: Added upm support for sensor MAG3110
MAG3110 is a three-axis digital magnetometer.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:25:20 -07:00
12c81adeba mma8x5x: Added upm support for some MMA8X5X sensors
This commit adds support for following sensors:
MMA8652 , MMA8653, MMA8451 , MMA8452 , MMA8453
These sensors are three-axis accelerometer.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:24:41 -07:00
8342b4c079 tmp006: Added upm support for sensor TMP006
TMP006 is a infrared-thermopile sensor.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:24:01 -07:00
e83b8ef114 tcs37727: Added upm support for color sensor TCS37727
TCS37727 is a Color Light-To-Digital Converter.
I also added the manufacturer 'ams' of TCS37727.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:23:16 -07:00
fabf4287d6 upm: enable MMC35240 3-axis magnetic sensor library and example
MMC35240 is 3-axis magnetic sensor from MEMSIC.

This sensor can measure magnetic fields within the full scale range of
+-24 Gauss (G).

The library provided is libupm-mmc35240.so
The example provided is mmc35240-example-cxx where it will print x,y,z axis
when trigger buffer data is ready. It's also print azimuth value.

This sensor requires calibration. Please shake the sensor in figure 8 pattern,
mmc35240-example will print the calibrated level.

As the sensor data is noisy, we have implemented denoise algorithm within the
sensor library.

The azimuth formula is provided by Han, He <he.han@intel.com>.

Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:22:40 -07:00
4ea01180a1 lcdks: renamed from sainsmartks, added backlight support
The sainsmartks driver has been reimplemented in it's own, new C/C++
library: lcdks (LCD Keypad Shield).

In addition, support for an optional backlight GPIO was added.

This was tested with the SainsmartKS and DFRobot LCD Keypad Shields.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-16 12:40:10 -06:00
ab171573f9 lcd/lcm1602/jhd1313m1: remove lcm1602 and jhd1313m1 from lcd library
The lcm1602 and jhd1313m1 drivers had been rewritten in C with a C++
wrapper some time ago, however the original lcm and jhd drivers were
still present in the lcd library.  In addition, to avoid header file
conflicts, the new, separated lcm and jhd header files were renamed
with a .hxx prefix.

This patch:

- renames the new lcm1602/ and jhd1313m1/ header files to have the
  usual .hpp prefix.

- removes the lcm1602, jhd1313m1, and sainsmartks drivers from the
  lcd/ (i2clcd) library.

- fixes the examples to use the "new" libraries (lcm1602 and
  jhd1313m1)

- changes the argument type for the createChar() (C++) to use a byte
  vector (std::vector<uint8_t>) rather than a typedef'd char array.
  The lcm1602_create_char() function (C) uses a standard char *.  The
  use of std::vector is well supported by SWIG.

- SWIG interface files changed to use upm_vectortypes.i, and removes
  the carrays helpers, which should no longer be needed for these
  drivers.

- removes the inclusion of the driver C .h header files into the SWIG
  interface files - this should not be needed for these drivers.

- the sainsmartks driver will be placed into it's own new lcdks (LCD
  Keypad Shield) library.  This library should support the
  SainsmartKS, DFRobot LCD Keypad Shield, and similar products from
  other manufacturers in a future commit.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-16 12:39:52 -06:00
d965b92af1 ABPDRRT005PG2A5: Initial Commit
This commit enables the ABP Honeywell sensor. Java examples is
yet to be tested and has not been provided with the current commit
and will be provided in a future commit.

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-03-13 11:13:10 -07:00
cc0174910b ds18b20: fix delay timing error in ds18b20_update()
Due to the change of using upm_delay_ms() instead of usleep(), but
failing to adjust the delay time accordingly, ds18b20_update() was
waiting for 750000ms (12 minutes) before reading the result of a
measurement, instead of the more appropriate 750ms.

This should fix Issue #530.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-13 12:05:22 -06:00
c4a506f5a3 bmp280/bme280: C port, C++ wraps C
Some private methods (relating to calibration/compensation) are no
longer exposed.  In addition, the driver auto-detects the chip (BMP280
or BME280) and acts accordingly, rather than requiring the
specification of a chip id in the ctor.

The getHumidity() method no longer accepts an arguement representing
pressure at sea level.  A new method is provided to specify this.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-10 17:00:50 -07:00
58cdfadf4e p9813: Chainable LEDS
Initial commit of the p9813 chainable LED controller.
Added C, C++, python, java, and node examples.

Signed-off-by: Sergey Kiselev <sergey.kiselev@intel.com>
Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-08 09:46:43 -08:00
b3a5275183 t6713: Static analysis fixes
Updated t6713 to use class instances vs class pointers.  Creating these
on the stack clears up some memory leaks where items created in the
heap are not deleted for a handful of the throw conditions.  Removed
all news/deletes.

Also reformatted to remove tabs and some spaces.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-07 22:10:16 -08:00
b314f56c00 l298: fix a potential divied-by-zero
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-07 14:24:04 -07:00
d4b536b593 bno055: C port; C++ wraps C
The API has been changed in some cases - see the apichanges.md
document.

In addition, this driver uses a new upm_vectortypes.i SWIG interface
file to provide a mechanism for methods that return a vector of floats
and ints instead of a pointer to an array.

This works much nicer than C array pointers, and results in Python/JS/Java
code that looks much more "natural" to the language in use.

The Python, JS, and Java examples have been changed to use these
methods.  Support for the "old" C-style pointer methods are still
provided for backward compatibility with existing code.

As an example - to retrieve the x, y, and z data for Euler Angles from
the bno055, the original python code would look something like:

       ...
       x = sensorObj.new_floatp()
       y = sensorObj.new_floatp()
       z = sensorObj.new_floatp()
       ...
       sensor.getEulerAngles(x, y, z)
       ...
       print("Euler: Heading:", sensorObj.floatp_value(x), end=' ')
       print(" Roll:", sensorObj.floatp_value(y), end=' ')
       ...

Now the equivalent code is simply:

       floatData = sensor.getEulerAngles()
       print("Euler: Heading:", floatData[0], ...
       print(" Roll:", floatData[1], end=' ')
       ...

Additionally, interrupt handling for Java is now implemented
completely in the C++ header file now rather than the .cxx file, so no
special SWIG processing is required anymore. See Issue #518 .

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-07 13:16:24 -07:00
2bdde21a2f src/upm_vectortypes.i: SWIG interface file for vector types
This interface file can be used to support some standard vector types
in our SWIG interface code.  The current vector types supported are:

%template(intVector)    vector<int>;
%template(int16Vector)  vector<int16_t>;
%template(floatVector)  vector<float>;
%template(doubleVector) vector<double>;
%template(byteVector)   vector<uint8_t>;

Using these makes it much easier and more "natural" for use with the
SWIG languages rather than the currently used mechanism of array
pointers and certain other pointer-based methods.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-07 13:16:14 -07:00
6ceebc9a17 ppd42ns_data.h: replace tabs with spaces
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-07 13:16:08 -07:00
65fc70a31a rf22: Static analysis fixes
A few small fixes for the rf22 to satisfy klocwork.

    * Converted malloc's to new's to be more C++'ish and since
      malloc return were not checked.
    * Initialize data, buf, and _lastInterruptFlags
    * Up'ed RF22_MAX_MESSAGE_LEN to 64.
        Reason:

void RF22::sendNextFragment()
{
    if (_txBufSentIndex < _bufLen)
    {
    // Some left to send?
    uint8_t len = _bufLen - _txBufSentIndex;
    // But dont send too much
    if (len > (RF22_FIFO_SIZE - RF22_TXFFAEM_THRESHOLD - 1))
        len = (RF22_FIFO_SIZE - RF22_TXFFAEM_THRESHOLD - 1);
    spiBurstWrite(RF22_REG_7F_FIFO_ACCESS, _buf + _txBufSentIndex, len);
    _txBufSentIndex += len;
    }
}

        RF22_FIFO_SIZE = 64
        RF22_TXFFAEM_THRESHOLD = 4
        RF22_MAX_MESSAGE_LEN = 50
        _buf[RF22_MAX_MESSAGE_LEN]
        Length of _buf *was* 50, so if the 'But dont send too much' above
        was to happen, the length is set to 63, which overruns
        _buf[RF22_MAX_MESSAGE_LEN]

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-06 12:13:27 -08:00
51a181a14f java_interfaces: Moved ifdefs for swig version
Moved the SWIG version check from each sensor library .i file to
the base SWIG .i file (per interface).  This cleans up the number
of #if SWIG_VERSION's across the code base, and will make cleanup
of these easier at a later date.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-03 10:27:12 -08:00
cfb4105dd8 docs: Added space to swig interface include
Documentation script was failing when parsing swig file.  Added
a space in the ads1x15 java swig file to make the doc parser happy.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-03 10:11:25 -08:00
b7faba556f sensortemplate: Added a template sensor
The purpose of the templatesensor is to get contributors up and running
faster when adding a new sensor.

    * Created library named 'sensortemplate'
    * Added C++ source
    * Added swig interface files for java, javascript, and python
    * Added sensortemplate image file
    * Added examples for c++, java, javascript, and python
    * Updated contributions.md with steps to create a new sensor from
      the sensortemplate library.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-02 23:05:51 -08:00
95801b395d Corrected typo in led.hpp. File includes led.h, not led.hpp
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
2017-03-02 20:19:24 -08:00
1f18369fbe SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example
This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes.

    * Added java swig interface files for all C++ interfaces to simplify swig
    javaupm_iADC.i
    javaupm_iCO2Sensor.i
    javaupm_iHumiditySensor.i
    javaupm_iLightController.i
    javaupm_iLightSensor.i
    javaupm_iModuleStatus.i
    javaupm_interfaces.i
    javaupm_iPressureSensor.i
    javaupm_iTemperatureSensor.i

    <example Usage>
        %include"../interfaces/javaupm_iADC.i"

    * Modified swig interface files for few sensors that implements interfaces
    ads1x15
    bmp280
    bmpx8x
    ds1808lc
    hlg150h
    lp8860
    max44009
    ms5611
    si1132
    si7005
    t6713

    * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden

    * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance
    For example
    class A {};
    class B : public A {};
    class C : public A {};
    class D : public B, public C {};

    This can be solved as
    class A {};
    class B : virtual public A {};
    class C : virtual public A {};
    class D : public B, public C {};

    * Modified java interface files to support multiple swig versions

    * Modified javaupm interface file to support standard auto load library code

    * Fixed autoloadlibrary tests for interfaces

    * Created one interface example separately <BME280_InterfaceExample.java>,
    <example Usage>
        BME280_InterfaceExample.java
    since we cann't define swig versions inside java example file.
    So, instaed added swig versions in Cmake.
    <example Usage>
         if (SWIG_VERSION VERSION_GREATER 3.0.8)
           add_example_with_path(BME280_InterfaceExample bmp280 bmp280)
         endif()

Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-03-02 20:14:03 -08:00
f8663c90f3 ctest: Fix for autoloadlibrary ctest
Update to fix a python indentation error.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-23 11:14:44 -08:00
1d6d660769 max30100: Small typo fix
Changed initializate->initialization...

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-17 16:49:39 -08:00
b57710cd78 groups.md: Removed redundant group maxbotix
Removed redundant group and renamed Maxbotixs to MaxBotix.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-17 16:40:09 -08:00
6d41566e93 doc: Changed <B5> to u for python doc run
The µ character (<B5>) fails the python documentation run.
Replacing with 'u'.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-14 08:31:55 -08:00
7a60cd5abe AQI: Adding ugm3 calculation to ppd42ns and aqi calculation to upm_utilities
Contributions by: Rex Tsai <rex.cc.tsai@gmail.com>

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-02-13 23:04:20 -08:00
b9988469ba upm: v1.1.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-13 16:11:37 -08:00
4fff3a500d apichanges: list i2clcd library and individual display modules being split
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-13 16:09:44 -08:00
a53ab5cb80 docs: updated sections on porting and documentation authoring
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-09 16:50:00 -08:00
bd8104f6ee tests: exclude build dir and update expected number of duplicates
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-09 16:49:27 -08:00
dbac88d225 ads1x15: extend examples for both ads1015 and ads1115 and clarify which one is used where
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-09 15:11:59 -08:00
70bcdfefa4 lcm1602/jhd1313m1: temporarily rename headers to avoid duplicates
This should be reverted when these 2 classes are removed from the i2clcd library. Will also require updating all the examples to load the new modules instead.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-09 15:06:12 -08:00
762c28f000 docs: Changed magnometer to magnetometer
Replaced all occurances.  While there are a few references
to magnometer out there, magnetometer is used much more broadly.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-08 13:56:28 -08:00
283fce619e doc: Scrubbed ALL sensor library descriptions
In an effort to clean-up and standardize UPM library
documentation, this commit updates (and in most cases,
unifies) the CMake description string AND CXX header
@comname string.

Strings were taken from datasheets when possible, spelling
mistakes were addressed, copy/paste errors where fixed,
Title Case was used, etc.

    * Tested/updated/added @web tags
    * Added/updated invalid sensor images
    * Added/updated @man tags, added missing manufacturers

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-08 11:50:00 -08:00
7a5c8a6cb3 swigjava: Added SWIGJAVA define to java module build
SWIGJAVA is defined for the swig interface file processing but is not
defined for the sensor library source build.  There are multiple sensors
that appear to rely solely on SWIGJAVA - these are not building
correctly.  Adding SWIGJAVA define for the java module src build.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-07 15:37:46 -08:00
4342b880b9 st7735: add typemaps to uint8_t arrays for js and python
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-06 21:28:04 -08:00
ddddbd024d tests: temporarily allow duplicate headers until cleanup
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-06 21:28:01 -08:00
67e0ceb48d tests: add test for duplicate headers
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-06 19:30:02 -08:00
2298846fef install.md: added install instructions for different OSes
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-06 19:02:35 -08:00
567476b89a cmake: Explicit dependency for mraa and interfaces
A handful of modules do not require mraa.  Captured this in
    src/CMakeLists.txt - only add mraa dependency for targets which
    use:

        upm_module_init(mraa ... )
            or
        upm_mixed_module_init(... REQUIRES mraa)

    All sensors which use UPM interfaces (src/interfaces) now
    explicitly add the interfaces target:

        upm_module_init(interfaces ... )
            or
        upm_mixed_module_init(... REQUIRES interfaces)

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-06 16:52:27 -08:00
d345006c03 cmake: Dependency refactoring for includes and libs
This commit attempts to use a more cmake-friendly approach when
handling inter-target dependencies.  A combination of macros and
include_directories usage provided overzealous compile -I/blah
entries which equates to large catch-all build commands.  For
example, the last CXX target contains include directories for nearly
all preceeding targets (~190).  Library dependencies were also often
wrong or missing.

    * Removed nearly all used of include_directories (swig cmake
      commands still appear to need these for generating the swig
      command line)
    * Updated usage of target_link_libraries in upm_module_init,
      also changed to using target_include_directories per target.
      This greatly simplifies upm/mixed_module_init usage for libraries
      which depend on other libraries (in this project).

        example (src/tb7300/CMakeLists.txt)
            old:
                 # upm-libbacnetmstp will bring in libbacnet, I hope
                 set (reqlibname "upm-bacnetmstp")
                 include_directories(${BACNET_INCLUDE_DIRS})
                 include_directories("../bacnetmstp")
                 upm_module_init()
                 upm_target_link_libraries(${libname} bacnetmstp)
            new:
                 upm_module_init(bacnetmstp)

      The reason here, is that tb7300 depends on bacnetmstp, which
      depends on BACNET includes/libs, so tb7300 gets the headers and
      libraries transitively via its dependency on bacnetmstp.
    * Updated pkg-config .pc file generation flow to reflect changes
      with dependencies.
    * Create a real target for the interfaces (CXX abstract sensor
      classes).  Renamed the directory from 'upm/src/upm' to
      'upm/src/interfaces'  Also changed the install location of the
      interface headers to include/upm/interfaces.  Updated interface
      header usage to reflect this.
    * Updated a few sensor libs to use fwd declarations for mraa.
      Ideally the UPM libs would do more of this which eases the
      burden on anyone building on top of the sensor libraries since
      they would not need to know about mraa headers.
    * Fixed examples which use symbols not defined in local includes

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-06 10:23:28 -08:00
7f0e03b0e3 cmake: Convert module_init to function
This is a housekeeping commit to move the upm_module_init
macro to a function.  The scope resolution of the function
call adds a bit more protection for the variables used inside
this macro/function.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-05 21:30:20 -08:00
08a46ee8e6 grovecollision,groveeldriver,groveelectromagnet,waterlevel: remove unnecessary librt dependency
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-02-02 14:36:51 -07:00
fb88fda5cb upm_utilities: Add a _POSIX_C_SOURCE define if needed
In certain systems, where -std=c11 is used, certain posix extensions
are disabled unless specifically enabled.  On these systems, this
could cause usleep() and/or nanosleep() to fail with an implicit
declaration warning.  This patch ensures that at least POSIX 200809 is
used, if otherwise undefined.

This should fix Issue #513.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-02-02 13:58:41 -07:00
90d856d128 utilities: use nanosleep() instead of usleep() for upm_delay*() functions
usleep() has been deprecated, and can cause compile problems on never
glibc versions (debian jesse).  We now use nanosleep() on linux
systems to implement delays.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-02-02 12:32:04 -07:00
d2e0327c30 src/CMakLists.txt: re-disable other warnings for SWIG building
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-02-02 12:31:57 -07:00
2e97aa9979 speaker: fix some incorrect comments/documentation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-02-01 17:59:15 -07:00
cdb75e8c13 swig_java: Fix for #518 - java wrapper implementations
This commit fixes #518 by adding source back into the CXX swig-
generated wrapper.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-01 16:15:30 -08:00
dac31a0347 speaker: Add pwm functionality and 5 new examples to demonstrate
These changes add the ability to intialize a speaker instance to use a
PWM pin instead of a standard GPIO pin in order to emit sounds.

The current GPIO functionality is fairly constrained by the
implementation -- it only permits playing cerain hardcoded "notes".

The PWM support allows one to emit specific frequencies (currently
between 50-32Khz) using a PWM pin.  Of course, you may still be
constrained by the limits of your PWM hardware in the end.

There are a few new functions provided to support this PWM mode.  To
use the PWM mode of speaker, use the speaker_init_pwm() initialization
routine instead of speaker_init() (for C). For C++ and the SWIG
languages, pass "true" as the second argument to the constructor to
enable PWM mode.  The default is "false", to match current default
behavior (GPIO).

Functions that are not related to a given mode (GPIO vs. PWM) will do
nothing if not usable in that mode.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-02-01 17:08:05 -07:00
0749f130e1 nunchuck: C port; FTI; C++ wraps C
Some API changes were made as well, see docs/apichanges.md.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-31 13:08:20 -07:00
1bbb9386b7 enc03r: C port; FTI; C++ wraps C
The API for this driver has changed.  See docs/apichanges.md.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-30 12:06:32 -07:00
f914159e21 ims: Small logging change for C init method
Added a bit more description if the library cannot set I2C
standard mode.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-01-27 11:16:24 -08:00
849711c47d wfs: C port; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-26 15:13:01 -07:00
0a91eb0b46 hmc5883l: C port; FTI; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-25 17:42:38 -07:00
806b00c2b7 uartat: add missing uartat_defs.h to SWIG interface files
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-24 17:31:57 -07:00
e8151640a1 uartat, le910: initial implementation.
uartat is the underlying UART driver, specifically for use with
AT-style command driven devices like modems.

The le910 support is provided in the form of examples that make use
of the uartat driver to interact with the device.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-24 14:02:03 -07:00
123e611f45 cjq4435: C port, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-20 12:02:30 -07:00
8d5278b9d4 CMakeLists.txt: Bump minimum MRAA version to 1.4.0
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-19 16:26:48 -07:00
ab96e8f3a3 speaker: C port, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-19 13:54:47 -07:00
d3b864362d ds18b20: rewrite C++ to wrap C, add FTI, update examples
Previously, the C++ and C versions of this driver were separate.  Now
the C++ implementation wraps the C implementation.

In addition, the C++ init() function has been deprecated.  It
currently does nothing, and examples have been modified to remove it's
calls.  This function will be removed in a separate release.

The examples have been further modified to update all detected devices
and print their respective temperatures, instead of only reporting the
on the first device detected.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-18 13:33:44 -07:00
6769d976a0 max30100: ISR recover attempt
Handle failure in ISR routine - attempt to read status and
FIFO registers and continue sampleing (vs exiting and turning
off continuous sampling).

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-01-11 15:52:41 -08:00
bd47b9ed45 max30100: Initial commit - MAX30100 pulse oximeter
* c/c++ source
    * java/js/python/c/c++ examples
    * Doc image (png)
    * Tested on Intel Edison
    * TODO: Tuning for SpO2 reading

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-01-10 11:29:30 -08:00
6ea65a16a4 upm_platform: use __linux__ define to detect linux platforms
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-01-10 10:51:13 -07:00
0849fbc674 ads1x15: added elaborate examples for TI ADS1015 ADC
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-01-05 21:20:58 -08:00
e25be536a1 ims: Small typo fix
Changed ISM to IMS.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-12-20 23:25:26 -08:00
a70629e3b2 mcp2515: fix return from rx_status_filtermatch; Travis CI (clang)
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-12-20 13:01:04 -07:00
fed0478dc9 mcp2515: fix conversion error reported by Travis CI (clang)
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-12-20 12:47:43 -07:00
fcb4d9d36d mcp2515: Initial implementation; C; C++
The mcp2515 is a CAN bus controller.  It was developed using the Seeed
CAN bus shield.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-12-20 12:17:14 -07:00
5eb8af6d70 upm.i: treat upm_result_t like an int in SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-12-20 12:17:09 -07:00
3c93eba4af LICENSE: Update license to be clearer and add 2016 copyright
MIT licenses should start with the following line to identify it as an MIT
license.

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-12-15 17:50:59 -08:00
78953b110f npm: small improvement in logic for handling C sources
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-12-15 16:44:36 -08:00
53124e9704 npm: rename c sources to avoid node-gyp makefile target collision
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-12-13 17:14:21 -08:00
cde747439f upm: v1.0.2
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-12-08 15:47:13 -08:00
dfc7a710d4 firmata: extended data types on pins to allow subplatform usage
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-12-08 15:10:36 -08:00
130cb822e4 rf22: Initial implementation for RFM22B radios, C++ only & bindings
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-12-07 14:38:56 -08:00
c057fa6708 travis.yml: use different swig ppa for Travis CI builds
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-12-06 19:33:00 -08:00
c6ad8cb5ee utilities: use a better method for detecting zephyr kernel version
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-12-05 15:04:34 -07:00
024b43dfa3 utilities: fix new Zephyr k_timer based implementation
- Fixed the Zephyr kernel version checks to check for 0.1.6 rather
  than 1.6.0.
- fixed the k_timer implementation to actually work.  None of these
  were being called correctly.
- due to the fact that the k_timer API only has a 1ms resolution,
  re-implement upm_delay_us() (on 0.1.6 version of zephyr) as a busy
  loop using a upm_clock_t.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-12-05 13:41:19 -07:00
6667646d32 mb704x: Initial implementation; C; FTI; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-12-02 16:44:43 -07:00
e1e9067744 groups.md: Add MaxBotix manufacturer
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-12-02 16:44:43 -07:00
c4656bf8ba utilities: add Zephyr 1.6 k_timer support (pulled from zupm)
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-12-02 16:44:43 -07:00
232089f400 cmake: Check for JAVA in top-level CMakeLists.txt
Moved require for Java/JNI/mraajava to top-level CMakeLists.txt
which will fail early if these are NOT found (vs failing in
the src-level CMakeLists.txt

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-29 15:14:32 -08:00
09144e712b cmake: Consolidated BUILDJAVAEXAMPLES and BUILDEXAMPLES
The java examples will now build if BUILDSWIGJAVA=on and
BUILDEXAMPLES=on.  This is similar to the C/C++ examples.

    * Replaced BUILDJAVAEXAMPLES w/BUILDEXAMPLES
    * Updated docs
    * Updated travis-ci

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-29 12:25:25 -08:00
2d94c2ed90 travis-ci: Turn on FTI source compiling in travis-ci
* Build FTI source w/travis

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-29 11:49:52 -08:00
91652a2da5 button: fix so that button intr C example is built
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-29 12:02:26 -07:00
929244b27a ims: Fixed IMS java example
* Fixed a compile issue for the JAVA example
    * Added C header to swig java/js interface files

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-29 09:56:57 -08:00
9a4f0cae0c ims: Added FTI and java example
* Added compiling FTI for IMS
    * Updated JAVA example, added to CMakeLists.txt

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-29 08:51:45 -08:00
402de082d3 ecezo: make sure to mraa_init() in ecezo_uart_init()
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-28 18:23:18 -07:00
ad275e1d41 ecezo: initial implementation; C, C++; FTI + examples
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-28 17:45:23 -07:00
d4559878df cmake: Removed -dirty from VERSION if git_describe fails
* Removed -dirty
    * Also removed redundant set(PACK_PACKAGE_VERSION ...
      since the first gets overwritten by the second

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-22 15:03:14 -08:00
971cb4ab51 ims: Initial turnin of I2C Moisture Sensor
* Added C library
    * Added CXX library
    * Added C/CXX/java/js/python examples

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-21 14:57:15 -08:00
a2698fd560 upm: v1.0.1
Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-21 12:20:03 -08:00
11e14a891f ms5803: remove utf8 delta-sigma characters from comment block
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-16 10:57:21 -07:00
803f9a9838 ms5803: initial implementation; C, C++; FTI + examples
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-14 17:26:42 -07:00
7bc9ef0150 cmake: disable some other warnings seen with edison gcc 4.9.1
Also, fix possible uninitialized access in ds1808lc C++ example.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-11 10:44:43 -07:00
72e8629d72 cmake: Make sure utilities directory gets added to cmake
If directories are specified with -DMODULE_LIST=blah, it's
possible to skip adding the utilities directory which is needed
by *most* sensor library targets in UPM.  Added a check for this
when using -DMODULE_LIST.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-08 21:58:05 -08:00
cdc33ceb9f bitbake: Fix for pthreads C test w/yocto
Fixed a problem where the C/CXX compile flags were getting
overwritten.  Fixed warnings in a few sensor drivers.

This commit fixes #485

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-08 16:28:54 -08:00
54771e63c1 my9221: C implementation; C example; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-08 17:13:22 -07:00
fde727b601 Button: Adding C sources and C examples
This commit adds C sources and examples for the button sensor.

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2016-11-08 13:38:52 -08:00
68091dcf43 werror: Don't emit -Wmisleading-indentation warnings
GCC-6 added -Wmisleading-indentation to -Wall.  Skip these for now.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-07 16:46:57 -08:00
1630ebfca4 otp538u: C implementation; FTI; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-07 13:53:43 -07:00
1aa748e3d6 docs: Removed 'Grove' from Comments
Signed-off-by: Suyash Lakhotia <suyashlakhotia@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-11-04 13:08:31 -07:00
b3991979ad examples: Changed Node.js module from jsupm_grove
Signed-off-by: Suyash Lakhotia <suyashlakhotia@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-11-04 13:08:31 -07:00
3eb3a0b825 guvas12d: C implementation; FTI; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-04 12:52:33 -06:00
9be920dbcd cxx_warnings: Misc changes to enable Werror
* CMake option to enable -Werror as default
    * Change to make sure all cxx examples have correct target name
    * Added PUBLIC CXX compiler flags to ads1x15 and ozw targets to
      work around compiler warnings
    * Renamed cmake variable for compiler warnings

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-03 16:45:32 -07:00
601d25cebc llvm: Fixed remaining warnings for llvm
This commit addresses warnings emitted from the llvm
compilers which were not encountered with gnu.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-03 14:14:37 -07:00
c900743f8d upm.i: turn off swig warnings relating to nested structs
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-03 13:54:46 -06:00
2b4e43281f Wunused-variable: fix several warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-03 13:23:44 -06:00
630d12d963 mic: fix sign comparison warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-03 13:23:44 -06:00
8da9f28157 gas: fix sign comparison warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-03 13:23:44 -06:00
aab0c5afe2 lcm1602, st7735: Fix up some Worder warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-03 12:51:07 -06:00
0589f445f0 Wreorder: fix a variety of re-ordering warnings
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-03 12:19:21 -06:00
d33e7e532e bacnetmstp: fix -Wreturn-type
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-03 12:14:26 -06:00
c63692b5fd Wreorder: Fixed a subset of reorder errors
This commit addresses warnings emitted from -Wreorder
in the C++ src.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-03 10:19:59 -07:00
2f31aede0e Wno-unknown-pragmas: Fixed all unknown pragmas
This commit addresses all warnings emitted from -Wno-unknown-pragmas
in the C++ src.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-02 22:57:38 -07:00
33471436bf Wunused-but-set-variable: Fixed all unused but set variables
This commit addresses all warnings emitted from
-Wunused-but-set-variable in the C++ src.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-02 22:45:52 -07:00
ee27485218 Wnon-virtual-dtor: Fixed all virtual functions w/o virtual destructor
This commit addresses all warnings emitted from -Wnon-virtual-dtor
in the C++ src.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-02 22:35:53 -07:00
6bc22dcee2 Wunused-variable: Fixed all unused variables in src
Additional unused variables.

This commit addresses all warnings emitted from -Wunused-variable
in the C++ src.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-02 22:29:59 -07:00
ae9b8fb13e Wsign-compare: Fixed all sign compare warnings in src
This commit addresses all warnings emitted from -Wunused-function
in the C++ src.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-02 22:27:17 -07:00
1dd5cbb445 Wunused-function: Fixed all unused functions in src
This commit addresses all warnings emitted from -Wunused-function
in the C++ src.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-02 21:55:19 -07:00
a3a1fdc81b Wunused-variable: Fixed all unused variables in src
This commit addresses all warnings emitted from -Wunused-variable
in the C++ src.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-11-02 21:44:27 -07:00
1f954a8cbf ppd42ns: C implementation; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-02 17:51:05 -06:00
8f6442e9c7 utilities: add new platform checks, implement new clock functions
The new clock functions provide a mechanism for measuring durations in
the ms (millisecond) or us (microsecond) range, in a platform
independant manner.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-02 17:51:05 -06:00
f2ad2c5679 upm_math.h: use new platform defines, include math.h on zephyr platforms
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-02 17:51:05 -06:00
d03de942c5 upm_platform.h: add new include for defining current platform (linux/zephyr, for now)
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-11-02 17:51:05 -06:00
1127 changed files with 55817 additions and 16800 deletions

View File

@ -15,7 +15,7 @@ compiler:
- clang
- gcc
install:
- sudo add-apt-repository --yes ppa:fenics-packages/fenics-dev/swig
- sudo add-apt-repository --yes ppa:rosmo/swig3.0.7
- sudo apt-get update -qq
- sudo apt-get install -y --force-yes -qq swig3.0 git
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
@ -36,7 +36,7 @@ script:
- sudo make install
- sudo ldconfig
# Build/install UPM
- cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA -DBUILDTESTS=ON .. && sudo make install && sudo ldconfig && ctest --output-on-failure -E examplenames_js
- cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDTESTS=ON -DBUILDFTI=ON .. && sudo make install && sudo ldconfig && ctest --output-on-failure -E examplenames_js
addons:
apt:
sources:

View File

@ -8,13 +8,12 @@ option (BUILDFTI "Build Funtion Table Interface (FTI) in C sensor libraries" OFF
option (BUILDSWIGPYTHON "Build swig python modules" ON)
option (BUILDSWIGNODE "Build swig node modules" ON)
option (BUILDSWIGJAVA "Build swig java modules" OFF)
option (BUILDEXAMPLES "Build C/C++ example binaries" OFF)
option (BUILDJAVAEXAMPLES "Build java example jars" OFF)
option (BUILDEXAMPLES "Build C/C++/JAVA examples" OFF)
option (IPK "Generate IPK using CPack" OFF)
option (RPM "Generate RPM using CPack" OFF)
option (NPM "Generate NPM/GYP tarballs" OFF)
option (BUILDTESTS "Generate check-ups for upm" OFF)
option (WERROR "Make all warnings into errors." OFF)
option (WERROR "Make all warnings into errors." ON)
# Warn if building in source root
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
@ -71,6 +70,7 @@ include (CheckCXXCompilerFlag)
# This function checks to see if each flag is supported
# by the compiler before setting the compile option.
function (upm_add_compile_flags compiler)
set (_TMP_COMPILER_FLAGS "")
# Iterate the flags, check if supported
foreach (flag ${ARGN})
# Check if this compile flag is supported
@ -85,15 +85,17 @@ function (upm_add_compile_flags compiler)
endforeach (flag ${ARGN})
# Set the variable in the parent scope
set (CMAKE_${compiler}_FLAGS ${_TMP_COMPILER_FLAGS} PARENT_SCOPE)
set (CMAKE_${compiler}_FLAGS "${CMAKE_${compiler}_FLAGS} ${_TMP_COMPILER_FLAGS}" PARENT_SCOPE)
endfunction ()
# Compiler flags common to both C and CXX
set (C_CXX_WARNING_FLAGS -Wall)
# Enable -Wall
# GCC-6 added -Wmisleading-indentation to -Wall, skip these for now
set (C_CXX_WARNING_FLAGS -Wall -Wno-misleading-indentation -Wno-strict-aliasing)
# Errors as warnings?
# Warnings as errors?
if (WERROR)
list (APPEND C_CXX_WARNING_FLAGS -Werror)
set (C_CXX_WARNING_FLAGS "-Werror ${C_CXX_WARNING_FLAGS}")
message (STATUS "Warnings as errors enabled (-Werror), disable with -DWERROR=off")
endif (WERROR)
@ -116,8 +118,10 @@ find_package (PkgConfig REQUIRED)
# Force a libmraa search and minimum required version every time a config is generated
unset(MRAA_FOUND CACHE)
set(MRAA_MINIMUM 1.1.1)
set(MRAA_MINIMUM 1.6.1)
pkg_check_modules (MRAA REQUIRED mraa>=${MRAA_MINIMUM})
# Also, get full path to the mraa library
find_library(MRAA_LIBRARY NAMES mraa PATHS ${MRAA_LIBDIR} NO_DEFAULT_PATH)
# Check for BACNET
pkg_check_modules (BACNET libbacnet)
@ -136,6 +140,15 @@ if (BUILDSWIGNODE)
find_package (Node REQUIRED)
endif (BUILDSWIGNODE)
# Find JAVA/JNI
if (BUILDSWIGJAVA)
find_package (Java REQUIRED)
find_package (JNI REQUIRED)
pkg_check_modules (MRAAJAVA REQUIRED mraajava>=0.8.0)
# Also, get full path to the mraajava library
find_library(MRAAJAVA_LIBRARY NAMES mraajava PATHS ${MRAA_LIBDIR} NO_DEFAULT_PATH)
endif (BUILDSWIGJAVA)
# Find swig if any wrapper is enabled
if (BUILDSWIGPYTHON OR BUILDSWIGNODE OR BUILDSWIGJAVA)
find_package (SWIG 3.0.5 REQUIRED)
@ -184,7 +197,7 @@ include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
# If git_describe fails, use a dirty version
if (${VERSION} MATCHES -NOTFOUND)
set (VERSION "v1.0.0-dirty")
set (VERSION "v1.2.0")
message (WARNING "Failed to retrieve UPM version with 'git describe' (using "
"${VERSION}). Check that git is installed and this is a valid git repo.")
endif ()
@ -378,7 +391,6 @@ endif()
if (RPM)
message (STATUS "RPM packaging enabled for ${DETECTED_ARCH}")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "upm")
set(upm_PACKAGE_ON_TAG ".")
@ -407,17 +419,11 @@ set (UPM_COMMON_HEADER_DIRS
${CMAKE_HOME_DIRECTORY}/include
${CMAKE_HOME_DIRECTORY}/include/fti)
# UPM source
add_subdirectory (src)
if(BUILDEXAMPLES)
add_subdirectory (examples/c)
if(BUILDCPP)
add_subdirectory (examples/c++)
endif(BUILDCPP)
endif()
if(BUILDJAVAEXAMPLES)
add_subdirectory (examples/java)
endif()
# UPM examples
add_subdirectory (examples)
# Python interp is previously found if BUILDTESTS=ON
if (BUILDTESTS)

View File

@ -1,4 +1,5 @@
Copyright © 2014-2015 Intel Corporation
The MIT License (MIT)
Copyright © 2014-2016 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@ -30,36 +30,28 @@ sensors and actuators and provide feedback on interface design.
A sensor/actuator is expected to work as such (here is the MMA7660 accelerometer API):
```C++
// Instantiate an MMA7660 on I2C bus 0
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_I2C_BUS,
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_DEFAULT_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);
accel->setSampleRate(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
cout << "Acceleration: x = " << ax
<< "g y = " << ay
<< "g z = " << az
<< "g" << endl;
usleep(500000);
}
```
@ -82,6 +74,10 @@ please refer to the Intel Developer Zone IDE page.
<a href="https://software.intel.com/iot/software/ide"><img src="docs/icons/allides.png"/></a>
### Installing UPM
Find notes on how to install UPM on various OS'es on this [page](docs/installing.md).
### Building UPM
See building documentation [here](docs/building.md).
@ -90,24 +86,34 @@ See building documentation [here](docs/building.md).
### Making your own UPM module
Porting [link](docs/porting.md) has more information on making new UPM modules.
A quick way to add a new sensor driver is to port existing code from another
platform (e.g. Arduino) and swap the IO calls to the MRAA API. This of course
assumes either ownership of the original code or licensing that allows
unrestricted redistribution.
There is also an example available gfor max31855 [sensor](docs/max31855.md).
The [porting](docs/porting.md) section has more information on this process,
and there is an example available based on the max31855 [sensor](docs/max31855.md).
Guide on creating Java [bindings](docs/creating_java_bindings.md).
Read more on creating Java [bindings](docs/creating_java_bindings.md) for your
new driver.
### Naming conventions and rules for new UPM contributions
### Guidelines and rules for new UPM contributions
Before you begin development, take a look at our naming [conventions](docs/naming.md).
The name you pick for a newly added sensor needs to be unique in the UPM library.
Also, please read the guidelines for contributions [to UPM](docs/contributions.md).
Don't forget to check the documentation [section](docs/documentation.md).
Then, please go over this short set of rules for new [contributions](docs/contributions.md).
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.
Documenting your code is also a big part of the task. We have a strict set of
tags used to classify our sensors and their capabilities. You can find out more
about this in our [section](docs/documentation.md) on documenting a sensor API.
Finally, if you really want to ensure consistency with the rest of the library,
and the intel-iot-devkit repositories in general, take a look at our extensive
[author guide](docs/guidelines.md).
API Documentation
==============
@ -122,7 +128,8 @@ our API in a way that will break backwards compatibility. If you find yourself
unable to compile code that was working fine before a library update, make sure
you check the [API changes](docs/apichanges.md) section first.
**NOTE** - Our **C++ header files** changed extension from *.h* to *.hpp*!
**NOTE** - Several important API changes are currently underway for some of our
widely used libraries including `libupm-grove` and `libupm-i2clcd`!
### Changelog
Version changelog [here](docs/changelog.md).

View File

@ -4,6 +4,191 @@ API Changes {#apichanges}
Here's a list of other API changes made to the library that break source/binary
compatibility between releases:
# v1.2.0
* **Note for all drivers ported to C** As a general note concerning
all of the drivers that have been ported to C: **external constants
have likely been renamed**. Previously in C++, most these constants
were defined as enums in the *upm::classname* namespace.
For drivers written in C, all of these constants are no longer in
a class (or UPM) namespace, and instead have the driver name
prefixed to the original value.
The driver name is prefixed to these constants to avoid name
collisions when using multiple drivers in a given application, and
to make it clear which constants belong to which driver.
For drivers that used *#define* for constants, only the prefix has
been added if not already present. In some cases, names that were
not very descriptive were changed, for example *ADDR* renamed to
*BMPX8X_DEFAULT_I2C_ADDR*.
So for example, a constant that might once have been referred to
in a C++ example as *upm::MMA7660::AUTOSLEEP_64*, would now be
referenced as *MMA7660_AUTOSLEEP_64*.
This holds true for most, if not all drivers that have been ported
to C. Not all of these changes are listed in this file due to the
sheer number of them.
If you run into problems with constants that were working
previously, and now cannot be found, this is likely the reason.
Check the driver documentation and the source code to see what the
new name is.
In C, constants are now usually implemented in a separate header
file named *drivername_defs.h* or *drivername_regs.h*, for easier
integration into the SWIG languages, and shared use between C++ and
C implementations.
* **bmpx8x** This driver has been rewritten from scratch in C, with a
C++ wrapper.
All exported symbols have been renamed for consistency and to
avoid symbol collisions by having a *BMPX8X_* prefix. As an example,
*ADDR* has been renamed to *BMPX8X_DEFAULT_I2C_ADDR*. Most C
ported drivers follow this rule.
The *getPressureRaw()* and *getTemperatureRaw()* functions have
been removed. This functionality was only needed internally to
the driver.
The constructor no longer accepts a mode argument. Only the I2C
bus and I2C address are accepted. By default, the device will be
configured for it's maximum resolution *BMPX8X_OSS_ULTRAHIGHRES*,
the previous default. You can use the new method
*setOversampling()* to change the mode to something else if
desired.
The methods related to calibration, like *computeB5()* are no
longer exposed.
New methods, *init()* and *reset()* have been added. *reset()*
resets the device to a freshly powered up state. *init()* can be
used to re-initialize the device after a reset (reload calibration
data) and set a default oversampling mode.
A new method, *update()* has been added. This method will update
all internal state from the device, and **must** be called before
querying the pressure, temperature, sea level and altitude values.
The *getSeaLevelPressure()* method has been split into two
overloaded methods. One which **requires** an argument in meters
(previously, a default was provided), and another which does not
accept arguments at all and computes the sea level pressure based
on current altitude.
The *i2cReadReg_16()*, *i2CWriteReg()* and *i2cReadReg_8()* have
been replaced with *readReg()*, *readRegs()*, and *writeReg()*, in
line with other I2C/SPI drivers of this type. They are marked
protected (in C++) now as well. Please see the updated
documentation and examples for this driver.
* **mma7660** This driver has been rewritten in C. Some exported
symbols have been changed, for example, *MMA7660_I2C_BUS* was renamed
to *MMA7660_DEFAULT_I2C_BUS*.
See updated documentation and examples for other changes.
* **bmx055, bmi055, bmc150, bma250e, bmg160, bmm150** This driver has
been split up. The *bma250e*, *bmg160*, *bmm150* drivers have been
rewritten in C (with C++ wrappers) and now reside in their own
libraries. The versions of these drivers that used to be present in
*bmx055* have been removed, and *bmx055* now uses the new libraries
for it's functionality. The other two composite devices, *bmi055*,
and *bmc150* are still contained within the *bmx055* library, and
also use the new libraries for their functionality.
In addition, for all of these drivers some private methods are no
longer exposed (such as the compensation routines).
The C++ driver methods that once returned pointers to a floating
point array now return *std::vectors* of the appropriate type.
The SWIG language examples for these drivers have been modified to
use these methods instead of the C pointer based SWIG methods
previously used.
* **sainsmartks** This driver has been renamed to *lcdks* (LCD Keypad
Shield) and moved into it's own library. It uses the *lcm1602*
library to do most of it's work. In addition, an additional argument
was added to the constructor to optionally allow specifying a GPIO
pin to be used to control the backlight. This driver supports the
SainsmartKS and DFRobot LCD Keypad Shields. Similar devices from
other manufacturers should also work with this driver.
* **lcm1602/jhd1313m1** These drivers had been rewritten in C, with
C++ wrappers and placed into their own libraries in the previous
version of UPM, however, the original C++ implementation was kept in
the lcd/i2clcd library for compatibility reasons with existing code.
To avoid collisions with the header files, the new *lcm1602* and
*jhd1313m1* drivers had their C++ headers renamed to use a **.hxx**
suffix.
In this version of UPM, the *lcm1602* and *jhd1313m1* drivers have
been removed from the lcd/i2clcd library. In addition, the header
files for the new implementation have been renamed from their
**.hxx** suffix to the normal **.hpp** suffix.
A change was also made to the new *lcm1602* and *jhd1313m1* C++
drivers. The *createChar()* function now accepts a byte vector
*std::vector<uint8_t>* rather than the *char ** pointer that was
used previously. This should make it easier to use with the SWIG
language bindings (Python, JavaScript, and especially Java).
* **bmp280/bme280** Some private methods are no longer exposed (such
as the calibration and compensation routines). In addition,
the *getHumidity()* method no longer accepts an argument representing
pressure at sea level. A separate method is provided to set this now.
* **bno055** This module no longer uses std::strings to pass around
binary data (*read/writeCalibrationData()*). Rather, now *std::vectors* of
the appropriate type are used. In addition, methods that previously
returned certain data in the form of an array, like *getEulerAngles()*,
now return a *std::vector* instead. This simplifies the Python,
JavaScript, and Java bindings considerably, and leads to more
"natural" looking Python/JavaScript/Java code. For JavaScript, Java,
and Python, the examples have been modified to use these methods
rather than the methods that return data in argument pointers or
arrays.
* **lpd8806** The constructor for this driver was updated to allow specifying
a SPI bus number. This is now the first parameter, the number of LEDs on the
strip is now the last (3rd) parameter instead.
* **max31723** The constructor for this driver was updated to allow specifying
a SPI bus number. This is now the first parameter, CS pin second.
* **tcs3414cs** The constructor for this can now accept an I2C bus and
address.
# v1.1.0 and prior
* **i2clcd/jhd1313m1/lcm1602** LCD devices supported by the i2clcd module are
being separated into individual libraries. The APIs will be preserved, but
we recommend changing your code to use the new libraries as they become
available. Once this transition is complete, the i2clcd module will be
deprecated. So far, the following libraries have been made available
separately: jhd1313m1, lcm1602.
* **nunchuck** This driver no longer supports the init() function.
All initialization is now done in the C nunchuck_init() function,
or the C++ constructor. In addition, the *NUNCHUCK_I2C_ADDR*
define is no longer exposed, as it is not possible to use any other
I2C address than *0x52*. The readBytes() and writeByte() functions
are also no longer exposed, since aside from what the driver does
to initialize and read data, there are no other options available.
* **enc03r** This driver no longer supports the value() function. In
addition, an update() function has been added. This function must be
called prior to calling angularVelocity(). angularVelocity() no
longer accepts an argument. Additional functions have been added,
however they do not affect compatibility with previous versions.
* **ds18b20** The C++ interface init() function has been deprecated.
It is still present, but currently does nothing. It will be removed
in a future release.
* **grove<name>** Starting with UPM 1.0 the Grove libraries have been renamed
from *upm-grove<name>* to simply *upm-<name>*. Class names also match this new
format, with old classes marked as deprecated throughout the documentation.
@ -11,27 +196,35 @@ compatibility between releases:
groveelectromagnet, groveemg, grovegprs, grovegsr, grovelinefinder, grovemd,
grovemoisture, groveo2, grovescam, grovespeaker, groveultrasonic, grovevdiv,
grovewater, grovewfs.
* **grove** As of UPM 1.0 the Grove classes for sensors in the starter kit are
being separated into individual libraries. The old classes will be deprecated
over time and eventually removed. Corresponding libraries have the grove
prefix removed. Affected classes are GroveButton, GroveLed, GroveLight,
GroveRelay, GroveRotary, GroveSlide and GroveTemp.
* The **ublox6** driver has been replaced with a generic implementation called
nmea_gps as of UPM 1.0. This driver should handle all generic serial GPS
devices that output NMEA data going forward. This new driver has been tested
with ublox6, DFRobot VK2828U7 (ublox7) and ublox LEA-6H GPS devices.
* **grove** Binary compatibility was broken for the GroveTemp class as of UPM
v0.7.3. C++ code using this class has to be recompiled.
* There were frequent misspellings of the word *Celsius* in the UPM
code. In some cases, these were in method names, which will cause
some API compatibility issues. These have all been corrected for UPM
versions after v.0.7.2.
* Our **C++ header files** changed their extension from *.h* to *.hpp* in
version 0.7.0, Intel provided examples and code samples also reflect this
change but you will need to modify your `#include` directives in existing
code.
* **my9221**, **groveledbar** and **grovecircularled** are now all part of the
same library (my9221) and new functionality was added going to v.0.5.1.
* **stepmotor** driver API was changed significantly from v.0.4.1 to v.0.5.0.
* **eboled** library was greatly improved in version 0.4.0 and the `draw()`
function was removed in favor of a more complete GFX library implementation.

View File

@ -80,14 +80,10 @@ Building documentation
~~~~~~~~~~~~~
-DBUILDDOC=ON
~~~~~~~~~~~~~
Build C++ example binaries
Build C/C++/JAVA examples
~~~~~~~~~~~~~
-DBUILDEXAMPLES=ON
~~~~~~~~~~~~~
Build Java examples
~~~~~~~~~~~~~
-DBUILDJAVAEXAMPLES=ON
~~~~~~~~~~~~~
If you intend to turn on all the options and build everything at once
(C++, Java, Node, Python and Documentation) you will have to edit the

View File

@ -4,6 +4,47 @@ Changelog {#changelog}
Here's a list summarizing some of the key undergoing changes to our library
from earlier versions:
### v1.2.0
* Improved JAVA binding compiler compatibility and added JAVA interfaces that
match existing C++ interfaces
* Ported Bosch drivers to C thus now they can be used on supported MCUs
* Completely redesigned C/C++ example handling by cmake to avoid maintaining
a list by hand
* Fixed several existing drivers, mostly based on static code analysis reports
* Added a sensor driver template plus bash script that can be easily used by
developers to start writing their own sensor driver
* Numerous documentation improvements
* New sensors: p9813, abp, rsc, mmc35240, tcs37727, tmp006, mma8x6x, mag3110,
hdc1000
### v1.1.0
* Reworked cmake handling of internal and external dependencies
* Documentation improvements for sensor names, sensor descriptions, external
contributor guides and added new section on installing UPM on a supported OS
* Fixed issues with C11 builds on some WRLinux gateways and Debian systems
* New examples and functionality for speaker and ads1x15 modules
* Modified JAVA builds to ensure the SWIG generated wrappers include all
functionality and typemaps
* New sensors: mcp2515, max30100, uartat, le910
### v1.0.2
* Minor cmake changes for Java builds and Java examples are now toggled with
the same BUILDEXAMPLES cmake switch
* Made some improvements in the utilities class for our C drivers
* Fixed issue with some drivers not being usable on subplatforms due to pin
numbers using uint8 type
* New sensors: ims, ecezo, mb704x, rf22
### v1.0.1
* Warnings as errors enabled for C/CXX (fixed warnings from -Wall and others)
* Fix for C/CXX compile flag append issue #485
* C sensor libraries for: my9221, otp538u, guvas12d, ppd42ns
* New sensor: ms5803
### v1.0.0
* Added approximately 50 C sources for UPM drivers that can be used on both

View File

@ -94,3 +94,55 @@ then you just add a line to each of your commits with `--signoff` saying
using your real name (sorry, no pseudonyms or anonymous contributions.)
Unsigned commits will not be accepted.
Creating a new sensor library using the sensortemplate
=======================================
A stubbed-out sensor library is available which can be leveraged to get
up-and-running quickly when writing a new sensor library. Use the shell
commands below to generate collateral files for your new sensor library.
```shell
#!/bin/bash
function make_new_sensor {
SensorName=$1
# Make sure this is run from the root UPM directory
if ! grep -q 'UPM ' README.md; then echo "Please run from the root UPM directory"; return -1; fi
# Copy/paste the below commands into a bash shell...
# Get a lowercase version of the string
sensorname=${SensorName,,}
# Copy sensortemplate files to ${sensorname}
find docs/ examples/ src/ -name '*sensortemplate*' -exec bash -c 'cp -r $0 ${0/sensortemplate/${sensorname}}' {} \;
# Copy SensorTemplate files to ${SensorName}
find examples/ src/ -name '*SensorTemplate*' -exec bash -c 'cp -r $0 ${0/SensorTemplate/${SensorName}}' {} \;
# Rename sernsortemplate src files
rename "s/sensortemplate/${sensorname}/" src/${sensorname}/*
# Search/replace the new files, replacing all instances of sensortemplate
perl -p -i -e "s/SensorTemplate/${SensorName}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
perl -p -i -e "s/sensortemplate/${sensorname}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
# Add mynewmodule example target for java
perl -p -i -e "s/^((.*)SensorTemplateSample sensortemplate(.*))/\1\n\2${SensorName}Sample ${sensorname}\3/g" examples/java/CMakeLists.txt
# Add mynewmodule example mappings for doxygen
perl -p -i -e "s/^(.*SensorTemplateSample.*)$/\1\n${sensorname}.cxx\t${SensorName}Sample.java\t${sensorname}.js\t${sensorname}.py/g" doxy/samples.mapping.txt
# Display TODO's
printf "Generation complete for sensor library: ${SensorName}\n"
printf "TODO's:\n"
printf "\t1. Update src/hdr files: src/${sensorname}/${sensorname}.hpp src/${sensorname}/${sensorname}.cxx\n"
printf "\t\tChange the Author\n"
printf "\t\tChange the Copyright\n"
printf "\t\tUpdate all doxygen tags (follow directions for @tags)\n"
printf "\t2. Update examples: examples/*/${sensorname}.* examples/java/*${SensorName}*.java\n"
printf "\t3. Overwrite docs/images/${sensorname}.png with a valid image of your sensor\n"
}
# Call make_new_sensor with your new sensor name, example: 'MyNewSensor1234'
make_new_sensor MyNewSensor1234
```
Once all files have been created, they can be used as a starting-point for your
new library. They will need additional customization (your name/email address,
documentation, sensor images, etc).

View File

@ -4,7 +4,7 @@ Writing sensor documentation {#documentation}
It is highly encouraged to provide at least some basic documentation for the
sensors that you want to add to UPM:
- If you don't add documentation, the code review will take very long and
- If you don't add documentation, the code review will take very long and
your contribution could be rejected.
- Try to have no warnings in doxygen, this is generally fairly easy.
- Have the specific sensor manufacturer/model & version that you used, if you
@ -15,7 +15,7 @@ sensors that you want to add to UPM:
####The sensor block
This is added just before the class declaration in your header(.h) file and has
This is added just before the class declaration in your header(.h) file and has
mandatory fields. For single sensor libraries, this block will actually
follow immediately after the library block. If you have multiple physical
sensors, add this to every one.
@ -36,7 +36,7 @@ Here's an example (disregard the "@verbatim" tags in your actual code):
* @kit <component-kit>
*
* @brief Short class/sensor description
*
*
* Then add a longer
* description here.
*
@ -52,8 +52,9 @@ Here's an example (disregard the "@verbatim" tags in your actual code):
- `<chip-id>` Usually the chip number used by the sensor. When this is not
available or relevant, use a unique descriptor that makes sense. Must match
class name. *Mandatory*
- `<component-name>` A short name for your sensor, try to avoid including the
manufacturer's name here. *Mandatory*
- `<component-name>` Title Case descriptive name for your sensor, try to avoid
including the manufacturer's name here. Examples: Digital Pressure Sensor,
Serial MP3 Module, etc... *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*

348
docs/guidelines.md Normal file
View File

@ -0,0 +1,348 @@
# Code Commenting And Documentation Authoring Guidelines
#### [Part I. Code Commenting](#code-commenting)
[Grammar](#grammar)
- [Active vs passive voice](#voice)
- [Capitalization](#capitalization)
- [No possessive case](#possessive-case)
- [Present tense](#present-tense)
- [Second person vs the user / reader / programmer / engineer](#second-person)
- [Third person vs infinitive](#third-person)
[Punctuation](#punctuation)
- [Comma in enumerations](#comma)
- [No period at the end of description](#period)
[Specific word usage](#word-usage)
- [Abbreviations and acronyms](#abbr-acr)
- [Adjectives containing numbers](#adj-num)
- [App vs application](#app)
- [Function vs method](#func-meth)
- [Onboard vs on-board](#onboard)
- [Sensor name vs sensor model](#name-model)
- [Setup vs set up](#setup)
- [Wi-Fi vs WiFi / Wifi / Wi-fi / wifi / wi-fi](#setup)
[Trademarks](#trademarks)
- [Intel products](#intel-prod)
- [Third-party technology](#third-party)
- [Trademark + noun](#tm-noun)
#### [Part II. Documentation Authoring](#doc-authoring)
[Grammar](#da-grammar)
- [Capitalization](#da-capitalization)
[Styling](#da-styling)
- [Bolding](#da-bolding)
- [Backticks](#da-backticks)
- [Links](#da-links)
- [Numbered list vs bullet points](#da-lists)
[Specific word usage](#da-word-usage)
- [Login vs log in](#da-login)
- [Click](#da-click)
- [SSH](#da-ssh)
# <a name="code-commenting"></a>Code Commenting Guidelines
## <a name="grammar"></a>Grammar
### <a name="voice"></a>Active vs passive voice
Where possible, prefer active voice over passive.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It can be put into the configuration mode by grounding the CONFIG pin on the transceiver. | - You can put it into the configuration mode by grounding the CONFIG pin on the transceiver.<br>- To put it into the configuration mode, ground the CONFIG pin on the transceiver.<br>- Put it into the configuration mode by grounding the CONFIG pin on the transceiver. |
### <a name="capitalization"></a>Capitalization
- Capitalize the first word in the description of an entity.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| checks to see if there is data available for reading | Checks to see if there is data available for reading |
| @param len length of the buffer | @param len Length of the buffer |
- Be consistent with the capitalization of boolean values.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Returns True on success, false otherwise | - Returns true on success, false otherwise<br>- Returns True on success, False otherwise |
### <a name="possessive-case"></a>No possessive case
Do not use possessive case to avoid unnecessary personalization.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| method's output | - method output<br>- output of the method |
### <a name="present-tense"></a>Present tense
Use the present simple tense instead of future, past, or present perfect.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| When specified, this value will be used in computing the voltage. | When specified, this value is used in computing the voltage. |
| Once the data has been read… | Once the data is read… |
### <a name="second-person"></a>Second person vs the user / reader / programmer / engineer
Use second person when addressing the target reader of your comment.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| The user can easily override this method. | You can easily override this method. |
### <a name="third-person"></a>Third person vs infinitive
Use third-person verb forms in short descriptions of classes, methods, functions, etc., not infinitive.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Get the proximity value from the sensor | Gets the proximity value from the sensor |
## <a name="punctuation"></a>Punctuation
### <a name="comma"></a>Comma in enumerations
Add an extra comma before the last item in a list joined by **and** / **or**.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Returns raw values for the X, Y and Z axes. | Returns raw values for the X, Y, and Z axes. |
### <a name="period"></a>No period at the end of description
Do not put a period if the description of an entity is one sentence long.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Returns the name of the sensor. | Returns the name of the sensor |
| Sets the frequency modulation<br>Valid values are between 10 and 160 (in kHz) | Sets the frequency modulation. Valid values are between 10 and 160 (in kHz). |
| @param millis Maximum time in milliseconds to wait for the input<br>-1 means waiting forever (default) | @param millis Maximum time in milliseconds to wait for the input. -1 means waiting forever (default). |
<font color="purple">**Exception:**</font> if the description contains more than one sentence, put periods after each sentence.
## <a name="word-usage"></a>Specific word usage
### <a name="abbr-acr"></a>Abbreviations and acronyms
- Spell out the first occurrence or the first prominent use of an abbreviation or acronym, followed by a shortened form.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| @brief API for the GP2Y0A family of IR Proximity Sensors | @brief API for the GP2Y0A family of infrared (IR) Proximity Sensors |
- Do not use Latin abbreviations.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Works best with halved values; e.g., 1.0, 0.5, 0.25, etc. | Works best with halved values; for example, 1.0, 0.5, 0.25, and so on. |
- Know exactly what the abbreviation or acronym means to avoid unnecessary duplication.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| - LCD display<br>- ISR routine | - LCD / liquid-crystal display<br>- ISR / interrupt service routine |
### <a name="adj-num"></a>Adjectives containing numbers
Adjectives of the form **number + noun / participle** should be hyphenated. It does not matter if a number is represented by one or more digits or spelled out.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| - 4 wire stepper motor<br>- 3 axis gyroscope<br>- zero based indexing<br>- one byte register | - 4-wire stepper motor<br>- 3-axis gyroscope<br>- zero-based indexing<br>- one-byte register |
### <a name="app"></a>App vs application
Use **app** when referring to a program running on a device, and **application** when referring to a program running on a desktop / laptop computer.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| The wiki page for this device includes a link to an Android\* application that can be used to read the device via NFC. | The wiki page for this device includes a link to an Android\* app that can be used to read the device via NFC. |
### <a name="func-meth"></a>Function vs method
If a function is associated with a class, use **method** instead.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| class WheelEncoder {<br>...<br>/**<br>* Starts the counter. This function also clears<br>* the current count and resets the clock.<br>*/<br>void startCounter(); | class WheelEncoder {<br>...<br>/**<br>* Starts the counter. This method also clears<br>* the current count and resets the clock.<br>*/<br>void startCounter(); |
### <a name="onboard"></a>Onboard vs on-board
Use **onboard**.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| This ADC features an on-board reference and oscillator. | This ADC features an onboard reference and oscillator. |
### <a name="name-model"></a>Sensor name vs sensor model
Use a sensor name alone or a sensor model followed by a sensor name, not a sensor model alone.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| ADXL345 is compatible with… | - The ADXL345 3-axis digital accelerometer is compatible with…<br>- The accelerometer is compatible with… |
<font color="purple">**Exception:**</font> you can use a sensor model alone when introducing a
sensor for the first time:
ADXL345 is a 3-axis digital accelerometer…
### <a name="setup"></a>Setup vs set up
**Setup** is a noun, **set up** is a verb.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It does not require any additional set up. | It does not require any additional setup. |
| For instructions on how to setup…, refer to... | For instructions on how to set up…, refer to... |
### <a name="wi-fi"></a>Wi-Fi vs WiFi / Wifi / Wi-fi / wifi / wi-fi
Use **Wi-Fi**.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It was tested with the XBee\* S6B WiFi module. | It is tested with the XBee\* S6B Wi-Fi\* module. |
## <a name="trademarks"></a>Trademarks
### <a name="intel-prod"></a>Intel products
Use the correct official names of Intel products. When in doubt, check the TM names database.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It is a 64x48 pixel OLED display that connects directly to an edison via its 80-pin connector. | It is a 64x48 pixel OLED display that connects directly to an Intel(R) Edison board via its 80-pin connector. |
**Note:** if an Intel product has a legally approved short name, you may use it in subsequent instances, after spelling it out the first time.
### <a name="third-party"></a>Third-party technology
Add an asterisk (\*) after a name to indicate a third-party trademark or registered intellectual property. If you are not sure whether an asterisk is necessary after a particular name, the rule of thumb is to put one, to be on the safe side.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| The Grove MQ2 Gas Sensor module is useful for gas leakage detection. | The Grove\* MQ2 Gas Sensor module is useful for gas leakage detection. |
### <a name="tm-noun"></a>Trademark + noun
Always follow trademarks by an appropriate noun. For a list of approved nouns for a particular trademark, check the TM names database.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It is a 64x48 pixel OLED display that connects directly to an Intel(R) Edison via its 80-pin connector. | It is a 64x48 pixel OLED display that connects directly to an Intel(R) Edison board via its 80-pin connector. |
# <a name="doc-authoring"></a>Documentation Authoring Guidelines
## <a name="da-grammar"></a>Grammar
### <a name="da-capitalization"></a>Capitalization
For titles, use sentence capitalization.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Add a New Device | Add a new device |
## <a name="da-styling"></a>Styling
### <a name="da-bolding"></a>Bolding
For GUI elements and file names, use bolding instead of quotes.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| In the “Environment Variables” window, click “OK”. | In the **Environment Variables** window, click **OK**. |
| Copy the “example.zip” archive into the installation directory. | Copy the **example.zip** archive into the installation directory. |
### <a name="da-backticks"></a>Backticks
Enclose program commands, code blocks, and file paths in backticks (\`).
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| To create a new device, use the **create-thing** command. | To create a new device, use the \`create-thing\` (rendered as `create-thing`) command. |
| Go to **C:\Users\me\Documents\GitHub\intel-iot-examples-mqtt\support\aws**. | Go to \`C:\Users\me\Documents\GitHub\intel-iot-examples-mqtt\support\aws\` (rendered as `C:\Users\me\Documents\GitHub\intel-iot-examples-mqtt\support\aws`). |
### <a name="da-links"></a>Links
Do not use embedded links to third-party websites.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Create an account on [Microsoft Azure](https://azure.microsoft.com/en-us), if you do not yet have one. | Create an account on [https://azure.microsoft.com/en-us](https://azure.microsoft.com/en-us), if you do not yet have one. |
### <a name="da-lists"></a>Numbered list vs bullet points
- For a logical sequence of steps, use a numbered list.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| When running your C++ code on the Edison, you need to set the MQTT parameters in Eclipse. Go to "Run configurations", and change the "Commands to execute before application" to the following:<br><br>Click on the "Apply" button to save these settings.<br>Click on the "Run" button to run the code on the Edison. | When running your C++ code on the Intel® Edison board, you need to set the MQTT\* client parameters in Eclipse\*. To do that:<br>1. Go to **Run configurations** and, in the **Commands to execute before application** field, type the following:<br><br>2. Click the **Apply** button to save these settings.<br>3. Click the **Run** button to run the code on your board. |
- For a list of equally important options, use a bulleted list.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| From this exercise, developers will learn how to:<br>1. Connect the Intel® Edison board...<br>2. Run these code samples in the Intel® System Studio IoT Edition...<br>3. Set up a web application server... | From this exercise, developers will learn how to:<br>- Connect the Intel® Edison board…<br>- Run these code samples in the Intel® System Studio IoT Edition…<br>- Set up a web application server… |
## <a name="da-word-usage"></a>Specific word usage
### <a name="da-login"></a>Login vs log in
**Login** is a noun, **log in** is a verb.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Provide your log in and password. | Provide your login and password. |
| Login to your account. | Log in( )to your account. |
### <a name="da-click"></a>Click
Omit **on** after **click**.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Click on **Advanced system settings**. | Click **Advanced system settings**. |
### <a name="da-ssh"></a>SSH
Do not use SSH as a verb. It is considered slang and is to be avoided.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| SSH into your Intel® Edison board. | Establish an SSH connection to your Intel® Edison board. |

BIN
docs/images/es9257.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
docs/images/ims.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

BIN
docs/images/max30100.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
docs/images/p9813.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
docs/images/rf22.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

77
docs/installing.md Normal file
View File

@ -0,0 +1,77 @@
Installing UPM {#installing}
============
UPM packages are provided for some of the major supported distributions, making
it very easy to install UPM and its dependencies without having to go through a
full build.
### Poky Linux
Yocto Project based Poky Linux builds are provided for Intel Galileo, Intel
Edison and Minnowboard. These are the official images released with the Intel
IoT Developer Kit and can found [here](https://iotdk.intel.com/images/3.5/).
To update to the latest stable UPM version:
```bash
echo "src intel-iotdk https://iotdk.intel.com/repos/3.5/intelgalactic/opkg/i586/" > /etc/opkg/intel-iotdk.conf
opkg update
opkg upgrade mraa upm
```
If you would like to try the development version use `intelgalactic-dev`
instead.
### WindRiver Pulsar Linux
WR Pulsar uses SmartPM for software updates. Updating to the latest UPM version
requires:
```bash
smart channel -y --add upm_mraa_channel type=rpm-md name="MRAA/UPM" baseurl=http://iotdk.intel.com/repos/pulsar/8/x64
smart update
smart install -y mraa upm
```
For Pulsar 7 use the following baseurl instead: `baseurl=http://iotdk.intel.com/repos/pulsar/7/x64`
Wind River Linux 7 uses 01.org repositories and will have a default update
channel that includes MRAA & UPM. Thus you only have to update and install.
### Ubuntu Desktop/Server
MRAA and UPM are available through a Personal Package Archive (PPA) on Ubuntu
that can be found [here](https://launchpad.net/~mraa/+archive/ubuntu/mraa).
To install:
```bash
sudo add-apt-repository ppa:mraa/mraa
sudo apt-get update
sudo apt-get install libupm-dev python-upm python3-upm upm-examples
```
Note that the Ubuntu PPA only provides the C/C++ and Python packages. Node.js
developers will have to install MRAA and UPM using NPM instead.
### Node.js bindings only (NPM)
This option allows compiling MRAA/UPM on any system with npm and node-gyp.
The UPM modules have a hard dependency on MRAA, thus you will have to install
it first. Also, make sure Node can find MRAA by updating the `NODE_PATH`
variable if necessary. A global installation is preferred:
`npm install mraa -g`
After this, to install a UPM module using npm simply type:
`npm install jsupm_<module-name> -g`
In order to initialize the platform, require MRAA *before* you load a UPM
module in your code:
```js
require('mraa');
var lib = require('jsupm_<module-name>');
```

View File

@ -156,7 +156,7 @@ FULL_PATH_NAMES = YES
# will be relative from the directory where doxygen is started.
# This tag requires that the tag FULL_PATH_NAMES is set to YES.
STRIP_FROM_PATH =
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
# path mentioned in the documentation of a class, which tells the reader which

View File

@ -5,15 +5,16 @@ adc121c021.cxx ADC121C021Sample.java adc121c021.js adc121c021.py
adxl345.cxx Adxl345Sample.java adxl345.js adxl345.py
biss0001.cxx BISS0001Sample.java biss0001.js biss0001.py
bmpx8x.cxx BMPX8XSample.java bmpx8x.js bmpx8x.py
bno055.cxx BNO055_Example.java bno055.js bno055.py
button.cxx ButtonSample.java button.js button.py
buzzer.cxx BuzzerSample.java buzzer.js buzzer.py
cjq4435.cxx CJQ4435Sample.java cjq4435.js cjq4435.py
ds1307.cxx DS1307Sample.java ds1307.js ds1307.py
enc03r.cxx ENC03RSample.java enc03r.js enc03r.py
es08a.cxx ES08ASample.java es08a.js es08a.py
servo-es08a.cxx ES08ASample.java es08a.js es08a.py
groveehr.cxx GroveEHRSample.java groveehr.js groveehr.py
groveledbar.cxx GroveLEDBar.java groveledbar.js groveledbar.py
groveled.cxx GroveLEDSample.java groveled.js groveled.py
my9221-groveledbar.cxx GroveLEDBar.java groveledbar.js groveledbar.py
grove-groveled.cxx GroveLEDSample.java groveled.js groveled.py
grovelinefinder.cxx GroveLineFinderSample.java grovelinefinder.js grovelinefinder.py
grovemoisture.cxx GroveMoistureSample.java grovemoisture.js grovemoisture.py
grovescam.cxx GROVESCAMSample.java grovescam.js grovescam.py
@ -24,6 +25,7 @@ hcsr04.cxx HCSR04Sample.java hcsr04.js hcsr04.py
hm11.cxx HM11Sample.java hm11.js hm11.py
hmc5883l.cxx Hmc5883lSample.java hmc5883l.js hmc5883l.py
htu21d.cxx HTU21DSample.java htu21d.js htu21d.py
ims.cxx IMS_Example.java ims.js ims.py
itg3200.cxx Itg3200Sample.java itg3200.js itg3200.py
jhd1313m1-lcd.cxx Jhd1313m1_lcdSample.java jhd1313m1-lcd.js jhd1313m1-lcd.py
joystick12.cxx Joystick12Sample.java joystick12.js joystick12.py
@ -40,9 +42,9 @@ mma7660.cxx MMA7660Sample.java mma7660.js mma7660.py
mpl3115a2.cxx MPL3115A2Sample.java mpl3115a2.js mpl3115a2.py
mpr121.cxx MPR121Sample.java mpr121.js mpr121.py
mpu9150.cxx MPU9150Sample.java mpu9150.js mpu9150.py
mq2.cxx MQ2Sample.java mq2.js mq2.py
gas-mq2.cxx MQ2Sample.java mq2.js mq2.py
mq303a.cxx MQ303ASample.java mq303a.js mq303a.py
mq5.cxx MQ5Sample.java mq5.js mq5.py
gas-mq5.cxx MQ5Sample.java mq5.js mq5.py
nrf24l01-receiver.cxx NRF24L01_receiverSample.java nrf24l01-receiver.js nrf24l01-receiver.py
nrf24l01-transmitter.cxx NRF24L01_transmitterSample.java nrf24l01-transmitter.js nrf24l01-transmitter.py
nunchuck.cxx NUNCHUCKSample.java nunchuck.js nunchuck.py
@ -57,12 +59,12 @@ rpr220.cxx RPR220Sample.java rpr220.js rpr220.py
rpr220-intr.cxx RPR220_intrSample.java rpr220-intr.js rpr220-intr.py
slide.cxx SlideSample.java slide.js slide.py
speaker.cxx SpeakerSample.java speaker.js speaker.py
ssd1308-oled.cxx SSD1308_oledSample.java ssd1308-oled.js ssd1308-oled.py
ssd1327-oled.cxx SSD1327_oledSample.java ssd1327-oled.js ssd1327-oled.py
i2clcd-ssd1308-oled.cxx SSD1308_oledSample.java ssd1308-oled.js ssd1308-oled.py
i2clcd-ssd1327-oled.cxx SSD1327_oledSample.java ssd1327-oled.js ssd1327-oled.py
st7735.cxx ST7735Sample.java st7735.js st7735.py
stepmotor.cxx StepMotorSample.java stepmotor.js stepmotor.py
tm1637.cxx TM1637Sample.java tm1637.js tm1637.py
tp401.cxx TP401Sample.java tp401.js tp401.py
gas-tp401.cxx TP401Sample.java tp401.js tp401.py
tsl2561.cxx TSL2561Sample.java tsl2561.js tsl2561.py
ttp223.cxx TTP223Sample.java ttp223.js ttp223.py
uln200xa.cxx ULN200XASample.java uln200xa.js uln200xa.py
@ -70,3 +72,10 @@ vdiv.cxx VDivSample.java vdiv.js vdiv.py
water.cxx WaterSample.java water.js water.py
wt5001.cxx WT5001Sample.java wt5001.js wt5001.py
yg1006.cxx YG1006Sample.java yg1006.js yg1006.py
sensortemplate.cxx SensorTemplateSample.java sensortemplate.js sensortemplate.py
p9813.cxx P9813Sample.java p9813.js p9813.py
tcs37727.cxx tcs37727.py
tmp006.cxx tmp006.py
mma8x5x.cxx mma8x5x.py
mag3110.cxx mag3110.py
hdc1000.cxx hdc1000.py

119
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,119 @@
# Add an example executable target for the provided source file which depends
# on a UPM library target. Strings after the first '-' are ignored.
#
# Usage:
# add_example(source_file TARGETS <target0> <target1> <targetn> SUFFIX <target_suffix>)
#
# Parameters:
# source_file - C/C++ source file. Filename must follow a specific format:
# <library>-[additional].c(xx)
# library: Name of UPM library required by example
# -additional: Any other string used to identify the example
# TARGETS - Additional dependency target/s required to BUILD/RUN this example. If TARGETS is
# set, these are in addition to the dependency library provided by the example filename.
# SUFFIX - Provide a means to differentiate between C/C++ dependency targets and
# example names. Leave empty for CXX examples. Use '-c' for c targets.
# SUFFIX Example file Dependency target Example binary
# ------ ------------ ----------------- --------------
# "-c" foo.c foo-c foo-example-c
# foo.cxx foo foo-example-cxx
#
# Parent scope variable:
# example_src_list - Any example target which is successfully created by
# add_example will be removed from the parent scope variable
# example_src_list (if it exists). This provides a means to handle
# special case examples BEFORE handling all files in example_src_list.
#
# Examples:
# # Creates sensorfoo-example-cxx, depends on target: sensorfoo
# add_example(sensorfoo.cxx)
#
# # Creates sensorfoo-example-c, depends on target: sensorfoo-c
# add_example(sensorfoo.c SUFFIX "-c")
#
# # Creates sensorfoo-bar-example-c, depends on target: sensorfoo-c
# add_example(sensorfoo-bar.c SUFFIX "-c")
#
# # Creates testfoobar-cxx, depends on targets: blib, blah
# add_example(testfoobar.c TARGETS blib blah)
#
# Examples:
# a110x.c Requires libupmc-a110x
# lcm1602-i2c.c Requires libupmc-lcm1602
# bmp280-bme280.c Requires libupmc-bmp280
# i2clcd-eboled.cxx Requires libupm-i2clcd
#
#
function (add_example example_src)
set (oneValueArgs SUFFIX)
set (multiValueArgs TARGETS)
# Parse function parameters
cmake_parse_arguments(add_example "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Get the base filename from the full filename
# For file /some/path/to/sensorfoo-bar.c, example_name = sensorfoo-bar
get_filename_component(example_name ${example_src} NAME_WE)
# Parse out <library>
# Example: sensorfoo-bar.c, library = sensorfoo
string (REPLACE "-" ";" split_name ${example_name})
list (GET split_name 0 library_name)
# Parse dependency target name from example_src filename (add on suffix)
# For sensorfoo, lib_target_names = sensorfoo-c
set (lib_target_names "${library_name}${add_example_SUFFIX}")
# If TARGETS is provided, add additional dependency targets
if (add_example_TARGETS)
list (APPEND lib_target_names "${add_example_TARGETS}")
endif ()
# Unfortunately, c++ and c library targets are not named the same. If
# no suffix is provided, assume C++ and add a suffix of -cxx to the
# example target name
# library example target
# c: sensorfoo-c sensorfoo-bar-example-c
# cxx: sensorfoo sensorfoo-bar-example-cxx
if (NOT add_example_SUFFIX)
set(add_example_SUFFIX "-cxx")
endif ()
# Create the target name for this example: mylibrary-bar-example-c
set (this_target_name "${example_name}-example${add_example_SUFFIX}")
# If a dependency target does NOT exist, print a warning and skip
foreach(_dep_target ${lib_target_names})
if (NOT TARGET ${_dep_target})
message(STATUS "Missing CMake target (${_dep_target}), skipping example ${example_src}")
return()
endif ()
endforeach ()
# Create an executable target for this example
add_executable (${this_target_name} ${example_src})
# Add each dependency to the library target
foreach(_dep_target ${lib_target_names})
target_link_libraries(${this_target_name} ${_dep_target} ${CMAKE_THREAD_LIBS_INIT})
endforeach ()
# Special case...
list (REMOVE_ITEM example_src_list ${example_src})
set (example_src_list ${example_src_list} PARENT_SCOPE)
endfunction (add_example example_src)
# Add subdirectories if BUILDEXAMPLES=on
if(BUILDEXAMPLES)
# Add C examples
add_subdirectory (c)
# Add C++ examples?
if (BUILDCPP)
add_subdirectory (c++)
endif ()
# Add java examples?
if(BUILDSWIGJAVA)
add_subdirectory (java)
endif()
endif()

View File

@ -1,357 +1,20 @@
# 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()
# Create an list of all C++ source files in this directory
file (GLOB example_src_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cxx")
# 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 (WARNING "Ignored ${example_bin}")
set (example_bin "")
endif()
endmacro()
# - Handle special cases here --------------------------------------------------
# Test humidity interface for 2 sensor libraries
add_example(interfaces-humiditysensor.cxx TARGETS si7005 bmp280)
# Test pressure interface for 2 sensor libraries
add_example(interfaces-pressuresensor.cxx TARGETS bmp280 bmpx8x)
# Test temperature interface for 3 sensor libraries
add_example(interfaces-temperaturesensor.cxx TARGETS bmp280 bmpx8x si7005)
# Test light interface for 2 sensor libraries
add_example(interfaces-lightsensor.cxx TARGETS si1132 max44009)
# Test light controller interface for 3 sensor libraries
add_example(interfaces-lightcontroller.cxx TARGETS lp8860 ds1808lc hlg150h)
# 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-cxx")
get_module_name(${example_name} module_name)
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}")
# nrf examples can flag a warning, make sure this isn't an error, currently
# this is done for all examples
set_source_files_properties(${example_src}
PROPERTIES COMPILE_FLAGS -Wno-tautological-compare)
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 (WARNING "Ignored ${example_bin}")
endif()
endmacro()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
# UPM c include directories
include_directories (${PROJECT_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src/utilities)
# Set the mraa include and link directories prior to adding examples
include_directories (${MRAA_INCLUDE_DIRS})
link_directories (${MRAA_LIBDIR})
# If your sample source file matches the name of the module it tests, add it here
# Exceptions are as follows:
# string after first '-' is ignored (e.g. nrf24l01-transmitter maps to nrf24l01)
# mq? will use module gas
# grove* will use module grove
add_example (hmc5883l)
add_example (led)
add_example (groveled)
add_example (relay)
add_example (groverelay)
add_example (light)
add_example (grovelight)
add_example (temperature)
add_example (grovetemp)
add_example (button)
add_example (grovebutton)
add_example (rotary)
add_example (groverotary)
add_example (slide)
add_example (groveslide)
add_example (buzzer)
add_example (nrf24l01-transmitter)
add_example (nrf24l01-receiver)
add_example (nrf24l01-broadcast)
add_example (hcsr04)
add_example (max44000)
add_example (mma7455)
add_example (st7735)
add_example (max31855)
add_example (bmpx8x)
add_example (stepmotor)
add_example (pulsensor)
add_example (mic)
add_example (mpu9150)
add_example (maxds3231m)
add_example (max31723)
add_example (max5487)
add_example (nrf8001-broadcast)
add_example (nrf8001-helloworld)
add_example (lpd8806)
add_example (mlx90614)
add_example (ecs1030)
add_example (mq2)
add_example (mq3)
add_example (mq4)
add_example (mq5)
add_example (mq6)
add_example (mq7)
add_example (mq8)
add_example (mq9)
add_example (tp401)
add_example (tcs3414cs)
add_example (th02)
add_example (ttp223)
add_example (lsm303)
add_example (joystick12)
add_example (lol)
add_example (tsl2561)
add_example (htu21d)
add_example (mpl3115a2)
add_example (ldt0028)
add_example (am2315)
add_example (itg3200)
add_example (enc03r)
add_example (adc121c021)
add_example (ds1307)
add_example (a110x)
add_example (gp2y0a)
add_example (moisture)
add_example (grovemoisture)
add_example (ehr)
add_example (groveehr)
add_example (ta12200)
add_example (grovelinefinder)
add_example (linefinder)
add_example (vdiv)
add_example (grovevdiv)
add_example (water)
add_example (grovewater)
add_example (guvas12d)
add_example (mpr121)
add_example (yg1006)
add_example (wt5001)
add_example (ppd42ns)
add_example (mq303a)
add_example (speaker)
add_example (grovespeaker)
add_example (rfr359f)
add_example (biss0001)
add_example (rotaryencoder)
add_example (adxl345)
add_example (rpr220)
add_example (rpr220-intr)
add_example (mma7660)
add_example (cjq4435)
add_example (adxl335)
add_example (hmtrp)
add_example (nunchuck)
add_example (otp538u)
add_example (collision)
add_example (grovecollision)
add_example (electromagnet)
add_example (groveelectromagnet)
add_example (emg)
add_example (groveemg)
add_example (o2)
add_example (groveo2)
add_example (gsr)
add_example (grovegsr)
add_example (ina132)
add_example (l298)
add_example (l298-stepper)
add_example (at42qt1070)
add_example (grovemd)
add_example (md)
add_example (grovemd-stepper)
add_example (md-stepper)
add_example (pca9685)
add_example (eldriver)
add_example (groveeldriver)
add_example (adafruitss)
add_example (adafruitms1438)
add_example (adafruitms1438-stepper)
add_example (hx711)
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 (wfs)
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 (scam)
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 (gprs)
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 (ultrasonic)
add_example (sx1276-lora)
add_example (sx1276-fsk)
add_example (ili9341)
add_example (nlgpio16)
add_example (ads1x15)
if (MODBUS_FOUND)
include_directories(${MODBUS_INCLUDE_DIRS})
add_example (t3311)
add_example (hwxpxx)
add_example (h803x)
endif()
add_example (hdxxvxta)
add_example (rhusb)
add_example (apds9930)
add_example (kxcjk1013)
add_example (ssd1351)
add_example (ds1808lc)
add_example (hlg150h)
add_example (lp8860)
add_example (max44009)
add_example (si1132)
add_example (si7005)
add_example (t6713)
add_example (cwlsxxa)
add_example (teams)
add_example (apa102)
add_example (tex00)
add_example (bmi160)
add_example (smartdrive)
if (HAVE_FIRMATA)
add_example (curieimu)
endif ()
if (BACNET_FOUND)
include_directories(${BACNET_INCLUDE_DIRS})
# we need access to bacnetmstp headers too
include_directories(${PROJECT_SOURCE_DIR}/src/bacnetmstp)
add_example (e50hx)
add_example (t8100)
add_example (tb7300)
endif()
if (JPEG_FOUND)
add_example (vcap)
endif (JPEG_FOUND)
add_example (ds2413)
add_example (ds18b20)
add_example (bmp280)
add_example (bno055)
add_example (l3gd20)
add_example (l3gd20-i2c)
add_example (bmx055)
add_example (ms5611)
add_example (nmea_gps)
add_example (mma7361)
add_example (bh1750)
add_example (hka5)
add_example (dfrorp)
add_example (dfrec)
add_example (sht1x)
# These are special cases where you specify example binary, source file and module(s)
include_directories (${PROJECT_SOURCE_DIR}/src)
add_custom_example (groveled-multi-example groveled-multi.cxx grove)
add_custom_example (lcm1602-i2c-example lcm1602-i2c.cxx lcd)
add_custom_example (lcm1602-parallel-example lcm1602-parallel.cxx lcd)
add_custom_example (jhd1313m1-lcd-example jhd1313m1-lcd.cxx lcd)
add_custom_example (es08a-example es08a.cxx servo)
add_custom_example (ssd1306-oled-example ssd1306-oled.cxx lcd)
add_custom_example (ssd1308-oled-example ssd1308-oled.cxx lcd)
add_custom_example (ssd1327-oled-example ssd1327-oled.cxx lcd)
add_custom_example (sainsmartks-example sainsmartks.cxx lcd)
add_custom_example (eboled-example eboled.cxx lcd)
add_custom_example (mpu60x0-example mpu60x0.cxx mpu9150)
add_custom_example (ak8975-example ak8975.cxx mpu9150)
add_custom_example (mpu9250-example mpu9250.cxx mpu9150)
add_custom_example (groveledbar-example groveledbar.cxx my9221)
add_custom_example (grovecircularled-example grovecircularled.cxx my9221)
add_custom_example (temperature-sensor-example temperature-sensor.cxx "si7005;bmpx8x;bmp280")
add_custom_example (humidity-sensor-example humidity-sensor.cxx "si7005;bmp280")
add_custom_example (pressure-sensor-example pressure-sensor.cxx "bmpx8x;bmp280")
add_custom_example (co2-sensor-example co2-sensor.cxx "t6713")
add_custom_example (adc-example adc-sensor.cxx "ads1x15")
add_custom_example (light-sensor-example light-sensor.cxx "si1132;max44009")
add_custom_example (light-controller-example light-controller.cxx "lp8860;ds1808lc;hlg150h")
add_custom_example (bme280-example bme280.cxx bmp280)
add_custom_example (bma250e-example bma250e.cxx bmx055)
add_custom_example (bmg160-example bmg160.cxx bmx055)
add_custom_example (bmm150-example bmm150.cxx bmx055)
add_custom_example (bmc150-example bmc150.cxx bmx055)
add_custom_example (bmi055-example bmi055.cxx bmx055)
if (OPENZWAVE_FOUND)
include_directories(${OPENZWAVE_INCLUDE_DIRS})
add_custom_example (ozwdump-example ozwdump.cxx ozw)
add_custom_example (aeotecss6-example aeotecss6.cxx ozw)
add_custom_example (aeotecsdg2-example aeotecsdg2.cxx ozw)
add_custom_example (aeotecdw2e-example aeotecdw2e.cxx ozw)
add_custom_example (aeotecdsb09104-example aeotecdsb09104.cxx ozw)
add_custom_example (tzemt400-example tzemt400.cxx ozw)
endif()
add_custom_example (nmea_gps_i2c_example-cxx nmea_gps_i2c.cxx nmea_gps)
# - Create an executable for all other src files in this directory -------------
foreach (_example_src ${example_src_list})
add_example(${_example_src})
endforeach ()

61
examples/c++/abp.cxx Normal file
View File

@ -0,0 +1,61 @@
/*
* Author: Abhishek Malik <abhishek.malik@intel.com>
* Copyright (c) 2017 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 "abp.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main ()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an ABP sensor on i2c bus 0
upm::ABP* abp = new upm::ABP(0, ABP_DEFAULT_ADDRESS);
while (shouldRun) {
abp->update();
cout << "Retrieved pressure: " << abp->getPressure() << endl;
cout << "Retrieved Temperature: " << abp->getTemperature() << endl;
sleep(1);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete abp;
return 0;
}

View File

@ -40,7 +40,7 @@
#include <iostream>
#include <signal.h>
#include "adis16448.h"
#include "adis16448.hpp"
int
main(int argc, char **argv)

View File

@ -0,0 +1,104 @@
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* This example demonstrates how to use one the ADS1015 ADC on the Grove Joule
* Shield or the Sparkfun ADC Block for Edison with devices that output a small
* differential voltage (e.g. geophones, piezoelectric bands or pads,
* thermocouples).
*/
#include <fstream>
#include <string>
#include <thread>
#include <unistd.h>
#include "ads1015.hpp"
using namespace std;
using namespace upm;
bool running = true; // Controls main read/write loop
// Thread function
void stop()
{
sleep(10);
running = false;
}
int main()
{
//! [Interesting]
long id = 0; // Sample number
string fileName = "./ads1015.data"; // Output filename
ofstream f;
// Initialize and configure the ADS1015
ADS1015 *ads1015 = new upm::ADS1015(0, 0x48);
// Put the ADC into differential mode for pins A0 and A1
ads1015->getSample(ADS1X15::DIFF_0_1);
// Set the gain based on expected VIN range to -/+ 2.048 V
// Can be adjusted based on application to as low as -/+ 0.256 V, see API
// documentation for details
ads1015->setGain(ADS1X15::GAIN_TWO);
// Set the sample rate to 3300 samples per second (max) and turn on continuous
// sampling
ads1015->setSPS(ADS1015::SPS_3300);
ads1015->setContinuous(true);
// Enable exceptions from the output stream
f.exceptions(ofstream::failbit | ofstream::badbit);
// Open the file
try{
f.open(fileName);
// Output formatting
f.setf(ios_base::fixed);
f.precision(7);
// Start the thread that will stop logging after 10 seconds
thread timer (stop);
// Read sensor data and write it to the output file every ms
while(running){
f << id++ << " " << ads1015->getLastSample() << endl;
usleep(1000);
}
// Clean-up and exit
timer.join();
f.close();
delete ads1015;
} catch (ios_base::failure &e) {
cout << "Failed to write to file: " << e.what() << endl;
return 1;
}
cout << "Wrote " << id << " samples to file: " << fileName << endl;
//! [Interesting]
return 0;
}

View File

@ -0,0 +1,107 @@
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* This example demonstrates how to use one of the ADS1115 ADCs on the
* DFRobot Joule Shield with devices that output a small differential
* voltage (e.g. geophones, piezoelectric bands or pads, thermocouples).
*/
#include <fstream>
#include <string>
#include <thread>
#include <unistd.h>
#include "ads1115.hpp"
using namespace std;
using namespace upm;
bool running = true; // Controls main read/write loop
// Thread function
void stop()
{
sleep(10);
running = false;
}
int main()
{
//! [Interesting]
long id = 0; // Sample number
string fileName = "./ads1115.data"; // Output filename
ofstream f;
// Initialize and configure the ADS1115 for the SM-24 Geophone
// There are two ADS1115 chips on the DFRobot Joule Shield on the same I2C bus
// - 0x48 gives access to pins A0 - A3
// - 0x49 gives access to pins A4 - A7
ADS1115 *ads1115 = new upm::ADS1115(0, 0x48);
// Put the ADC into differential mode for pins A0 and A1,
// the SM-24 Geophone is connected to these pins
ads1115->getSample(ADS1X15::DIFF_0_1);
// Set the gain based on expected VIN range to -/+ 2.048 V
// Can be adjusted based on application to as low as -/+ 0.256 V, see API
// documentation for details
ads1115->setGain(ADS1X15::GAIN_TWO);
// Set the sample rate to 860 samples per second (max) and turn on continuous
// sampling
ads1115->setSPS(ADS1115::SPS_860);
ads1115->setContinuous(true);
// Enable exceptions from the output stream
f.exceptions(ofstream::failbit | ofstream::badbit);
// Open the file
try{
f.open(fileName);
// Output formatting
f.setf(ios_base::fixed);
f.precision(7);
// Start the thread that will stop logging after 10 seconds
thread timer (stop);
// Read sensor data and write it to the output file every ms
while(running){
f << id++ << " " << ads1115->getLastSample() << endl;
usleep(1000);
}
// Clean-up and exit
timer.join();
f.close();
delete ads1115;
} catch (ios_base::failure &e) {
cout << "Failed to write to file: " << e.what() << endl;
return 1;
}
cout << "Wrote " << id << " samples to file: " << fileName << endl;
//! [Interesting]
return 0;
}

View File

@ -37,6 +37,7 @@ int main()
using namespace std;
using namespace upm;
int command;
//! [Interesting]
//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);
@ -315,6 +316,7 @@ int main()
}while (command != -1 );
delete ads;
//! [Interesting]
return MRAA_SUCCESS;
return 0;
}

View File

@ -44,7 +44,7 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMA250E using default I2C parameters
upm::BMA250E *sensor = new upm::BMA250E();
upm::BMA250E sensor;
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: BMA250E(0, -1, 10);
@ -54,9 +54,9 @@ int main(int argc, char **argv)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getAccelerometer(&x, &y, &z);
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
@ -64,8 +64,8 @@ int main(int argc, char **argv)
<< endl;
// we show both C and F for temperature
cout << "Compensation Temperature: " << sensor->getTemperature()
<< " C / " << sensor->getTemperature(true) << " F"
cout << "Compensation Temperature: " << sensor.getTemperature()
<< " C / " << sensor.getTemperature(true) << " F"
<< endl;
cout << endl;
@ -77,7 +77,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -44,7 +44,7 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMG160 using default I2C parameters
upm::BMG160 *sensor = new upm::BMG160();
upm::BMG160 sensor;
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: BMG160(0, -1, 10);
@ -54,9 +54,9 @@ int main(int argc, char **argv)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getGyroscope(&x, &y, &z);
sensor.getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
@ -64,8 +64,8 @@ int main(int argc, char **argv)
<< endl;
// we show both C and F for temperature
cout << "Compensation Temperature: " << sensor->getTemperature()
<< " C / " << sensor->getTemperature(true) << " F"
cout << "Compensation Temperature: " << sensor.getTemperature()
<< " C / " << sensor.getTemperature(true) << " F"
<< endl;
cout << endl;
@ -77,7 +77,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -44,7 +44,7 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMM150 using default I2C parameters
upm::BMM150 *sensor = new upm::BMM150();
upm::BMM150 sensor;
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: BMM150(0, -1, 10);
@ -54,9 +54,9 @@ int main(int argc, char **argv)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getMagnetometer(&x, &y, &z);
sensor.getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
@ -72,7 +72,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -31,7 +31,7 @@
using namespace std;
using namespace upm;
int shouldRun = true;
bool shouldRun = true;
void sig_handler(int signo)
{

View File

@ -1,6 +1,8 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
* Copyright (c) 2016-2017 Intel Corporation.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -31,7 +33,7 @@
using namespace std;
using namespace upm;
int shouldRun = true;
bool shouldRun = true;
void sig_handler(int signo)
{

View File

@ -1,6 +1,11 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2017 Intel Corporation.
*
* This driver was rewritten based on the original driver written by:
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -24,57 +29,50 @@
#include <unistd.h>
#include <iostream>
#include "bmpx8x.hpp"
#include <signal.h>
int doWork = 0;
upm::BMPX8X *sensor = NULL;
#include "bmpx8x.hpp"
void
sig_handler(int signo)
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
printf("got signal\n");
if (signo == SIGINT) {
printf("exiting application\n");
doWork = 1;
}
if (signo == SIGINT)
shouldRun = false;
}
int
main(int argc, char **argv)
int main(int argc, char **argv)
{
//! [Interesting]
uint32_t presure = 0;
float temperature = 0;
float altitude = 0;
uint32_t sealevel = 0;
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a BMPX8X sensor on I2C
sensor = new upm::BMPX8X(0, ADDR);
// Instantiate a BMPX8X sensor on I2C using defaults.
upm::BMPX8X sensor;
// Print the pressure, altitude, sea level, and
// temperature values every 0.1 seconds
while (!doWork) {
presure = sensor->getPressure ();
temperature = sensor->getTemperature ();
altitude = sensor->getAltitude ();
sealevel = sensor->getSealevelPressure ();
// temperature values every 0.5 seconds
while (shouldRun)
{
sensor.update();
std::cout << "pressure value = " <<
presure <<
", altitude value = " <<
altitude <<
", sealevel value = " <<
sealevel <<
", temperature = " <<
temperature << std::endl;
usleep (100000);
cout << "Pressure: "
<< sensor.getPressure()
<< " Pa, Temperature: "
<< sensor.getTemperature()
<< " C, Altitude: "
<< sensor.getAltitude()
<< " m, Sea level: "
<< sensor.getSealevelPressure()
<< " Pa"
<< endl;
usleep(500000);
}
//! [Interesting]
std::cout << "exiting application" << std::endl;
delete sensor;
cout << "Exiting..." << endl;
//! [Interesting]
return 0;
}

View File

@ -44,23 +44,23 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMC150 using default I2C parameters
upm::BMC150 *sensor = new upm::BMC150();
upm::BMC150 sensor;
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getAccelerometer(&x, &y, &z);
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor->getMagnetometer(&x, &y, &z);
sensor.getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
@ -76,7 +76,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -44,23 +44,23 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMI055 using default I2C parameters
upm::BMI055 *sensor = new upm::BMI055();
upm::BMI055 sensor;
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getAccelerometer(&x, &y, &z);
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor->getGyroscope(&x, &y, &z);
sensor.getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
@ -76,7 +76,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -44,30 +44,30 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMX055 using default I2C parameters
upm::BMX055 *sensor = new upm::BMX055();
upm::BMX055 sensor;
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getAccelerometer(&x, &y, &z);
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor->getGyroscope(&x, &y, &z);
sensor.getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
<< " degrees/s"
<< endl;
sensor->getMagnetometer(&x, &y, &z);
sensor.getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
@ -83,7 +83,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -33,45 +33,45 @@ int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
if (signo == SIGINT)
shouldRun = false;
}
int main ()
{
signal(SIGINT, sig_handler);
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
upm::CJQ4435* mosfet = new upm::CJQ4435(3);
mosfet->setPeriodMS(10);
mosfet->enable(true);
// Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
upm::CJQ4435* mosfet = new upm::CJQ4435(3);
while (shouldRun)
mosfet->setPeriodMS(10);
mosfet->enable(true);
while (shouldRun)
{
// start with a duty cycle of 0.0 (off) and increment to 1.0 (on)
for (float i=0.0; i <= 1.0; i+=0.1)
// start with a duty cycle of 0.0 (off) and increment to 1.0 (on)
for (float i=0.0; i <= 1.0; i+=0.1)
{
mosfet->setDutyCycle(i);
usleep(100000);
mosfet->setDutyCycle(i);
usleep(100000);
}
sleep(1);
// Now take it back down
// start with a duty cycle of 1.0 (on) and decrement to 0.0 (off)
for (float i=1.0; i >= 0.0; i-=0.1)
sleep(1);
// Now take it back down
// start with a duty cycle of 1.0 (on) and decrement to 0.0 (off)
for (float i=1.0; i >= 0.0; i-=0.1)
{
mosfet->setDutyCycle(i);
usleep(100000);
mosfet->setDutyCycle(i);
usleep(100000);
}
sleep(1);
sleep(1);
}
//! [Interesting]
cout << "Exiting..." << endl;
cout << "Exiting..." << endl;
delete mosfet;
return 0;
delete mosfet;
return 0;
}

View File

@ -76,6 +76,7 @@ main(int argc, char **argv)
printf("motion is: %d, %d, %d, %d, %d, %d\n", m, n, o, p, q, r);
delete sensor;
//! [Interesting]
return 0;
}

View File

@ -1,51 +1,43 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <string>
#include "ds1808lc.hpp"
#define EDISON_I2C_BUS 1 // Edison I2C-1
#define DS1808_GPIO_PWR 15 // Edison GP165
void printState(upm::ILightController *lightController)
{
if (lightController->isPowered())
{
std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
}
int main( int argc, char **argv )
{
int status = 0;
upm::ILightController* lightController;
try {
lightController = new upm::DS1808LC(DS1808_GPIO_PWR, EDISON_I2C_BUS);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0) {
lightController->setPowerOn();
lightController->setBrightness(brightness);
} else
lightController->setPowerOff();
}
std::cout << "Now: ";printState(lightController);
} catch (std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
status = 1;
}
delete lightController;
return status;
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <string>
#include "ds1808lc.hpp"
#define EDISON_I2C_BUS 1 // Edison I2C-1
#define DS1808_GPIO_PWR 15 // Edison GP165
void printState(upm::ILightController &lightController)
{
if (lightController.isPowered())
{
std::cout << "Light is powered, brightness = " << lightController.getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
}
int main( int argc, char **argv )
{
//! [Interesting]
upm::DS1808LC lightController(DS1808_GPIO_PWR, EDISON_I2C_BUS);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0)
{
lightController.setPowerOn();
lightController.setBrightness(brightness);
}
else
lightController.setPowerOff();
}
std::cout << "Now: ";printState(lightController);
//! [Interesting]
return 0;
}

View File

@ -1,6 +1,6 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
* Copyright (c) 2016-2017 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -49,9 +49,6 @@ int main(int argc, char **argv)
// Instantiate an DS18B20 instance using the default values (uart 0)
upm::DS18B20 sensor;
// locate and setup our devices
sensor.init();
cout << "Found " << sensor.devicesFound() << " device(s)" << endl;
cout << endl;
@ -59,18 +56,26 @@ int main(int argc, char **argv)
if (!sensor.devicesFound())
return 1;
// update and print available values every second
// update and print available values every 2 seconds
while (shouldRun)
{
// update our values for the first sensor
sensor.update(0);
// update our values for all of the detected sensors
sensor.update(-1);
// we show both C and F for temperature for the first sensor
cout << "Temperature: " << sensor.getTemperature(0)
<< " C / " << sensor.getTemperature(0, true) << " F"
<< endl;
// we show both C and F for temperature for the sensors
int i;
for (i=0; i<sensor.devicesFound(); i++)
{
cout << "Device "
<< i
<< ": Temperature: "
<< sensor.getTemperature(i)
<< " C / " << sensor.getTemperature(i, true) << " F"
<< endl;
}
cout << endl;
sleep(1);
sleep(2);
}
cout << "Exiting..." << endl;

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

@ -0,0 +1,81 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <signal.h>
#include <upm_utilities.h>
#include <ecezo.hpp>
using namespace std;
using namespace upm;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a ECEZO sensor on uart 0 at 9600 baud.
upm::ECEZO *sensor = new upm::ECEZO(0, 9600, false);
// For I2C, assuming the device is configured for address 0x64 on
// I2C bus 0, you could use something like:
//
// upm::ECEZO *sensor = new upm::ECEZO(0, 0x64, true);
while (shouldRun)
{
// this will take about 1 second to complete
sensor->update();
cout << "EC "
<< sensor->getEC()
<< " uS/cm, TDS "
<< sensor->getTDS()
<< " mg/L, Salinity "
<< sensor->getSalinity()
<< " PSS-78, SG "
<< sensor->getSG()
<< endl;
upm_delay(5);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -1,6 +1,6 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
* Copyright (c) 2014-2017 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -36,44 +36,45 @@ bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a ENC03R on analog pin A0
upm::ENC03R *gyro = new upm::ENC03R(0);
// The first thing we need to do is calibrate the sensor.
cout << "Please place the sensor in a stable location, and do not" << endl;
cout << "move it while calibration takes place." << endl;
cout << "This may take a couple of minutes." << endl;
// Instantiate a ENC03R on analog pin A0
upm::ENC03R *gyro = new upm::ENC03R(0);
gyro->calibrate(CALIBRATION_SAMPLES);
cout << "Calibration complete. Reference value: "
<< gyro->calibrationValue() << endl;
// The first thing we need to do is calibrate the sensor.
cout << "Please place the sensor in a stable location, and do not" << endl;
cout << "move it while calibration takes place." << endl;
cout << "This may take a couple of minutes." << endl;
// Read the input and print both the raw value and the angular velocity,
// waiting 0.1 seconds between readings
while (shouldRun)
gyro->calibrate(CALIBRATION_SAMPLES);
cout << "Calibration complete. Reference value: "
<< gyro->calibrationValue() << endl;
// Read the input and print both the raw value and the angular velocity,
// waiting 0.1 seconds between readings
while (shouldRun)
{
unsigned int val = gyro->value();
double av = gyro->angularVelocity(val);
gyro->update();
cout << "Raw value: " << val << ", "
<< "angular velocity: " << av << " deg/s" << endl;
usleep(100000);
cout << "Angular velocity: "
<< gyro->angularVelocity()
<< " deg/s"
<< endl;
usleep(100000);
}
//! [Interesting]
cout << "Exiting" << endl;
cout << "Exiting" << endl;
delete gyro;
return 0;
delete gyro;
return 0;
}

View File

@ -33,40 +33,40 @@ bool shouldRun = true;
// analog voltage, usually 3.3 or 5.0
#define GUVAS12D_AREF 5.0
#define SAMPLES_PER_QUERY 1024
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
signal(SIGINT, sig_handler);
//! [Interesting]
// The was tested with the Grove UV Sensor module.
// It has a sensing range from between 200-400nm. It's strongest
// response is around 320-360nm.
// This was tested with the Grove UV Sensor module.
// It has a sensing range from between 240-370nm. It's strongest
// response is around 320-360nm.
// Instantiate a GUVAS12D on analog pin A0
upm::GUVAS12D *volts = new upm::GUVAS12D(0);
// The higher the voltage the more intense the UV radiation.
// Instantiate a GUVAS12D on analog pin A0
upm::GUVAS12D *volts = new upm::GUVAS12D(0);
while (shouldRun)
// The higher the voltage the more intense the UV radiation.
while (shouldRun)
{
cout << "AREF: " << GUVAS12D_AREF
<< ", Voltage value (higher means more UV): "
<< volts->value(GUVAS12D_AREF, SAMPLES_PER_QUERY) << endl;
sleep(1);
cout << "Volts: " << volts->volts()
<< ", Intensity: " << volts->intensity()
<< " mW/m^2"
<< endl;
sleep(1);
}
//! [Interesting]
cout << "Exiting" << endl;
cout << "Exiting" << endl;
delete volts;
return 0;
delete volts;
return 0;
}

67
examples/c++/hdc1000.cxx Normal file
View File

@ -0,0 +1,67 @@
/* Author: Norbert Wesp <nwesp@phytec.de>
* Copyright (c) 2017 Phytec Messtechnik GmbH.
*
* 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 "hdc1000.hpp"
using namespace upm;
bool run = true;
void sig_handler(int sig)
{
if (sig == SIGINT)
run = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
std::cout << "Initializing test-application..." << std::endl;
// Instantiate an HDC1000 instance on bus 1
upm::HDC1000 *mySensor = new upm::HDC1000(1);
// update and print available values every second
while (run)
{
std::cout << "Humidity: " << mySensor->getHumidity(true) << std::endl
<< "Temperature: " << mySensor->getTemperature(true) << std::endl;
std::cout << std::endl;
sleep(1);
}
std::cout << "Exiting test-application..." << std::endl;
delete mySensor;
//! [Interesting]
return 0;
}

View File

@ -8,44 +8,37 @@
#define HLG150H_GPIO_RELAY 21
#define HLG150H_GPIO_PWM 22
void printState(upm::ILightController *lightController)
void printState(upm::ILightController &lightController)
{
if (lightController->isPowered())
{
std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
if (lightController.isPowered())
{
std::cout << "Light is powered, brightness = " << lightController.getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
}
int main( int argc, char **argv )
{
int status = 0;
upm::ILightController* lightController;
//! [Interesting]
upm::HLG150H lightController(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0)
{
lightController.setPowerOn();
lightController.setBrightness(brightness);
}
else
lightController.setPowerOff();
}
std::cout << "Now: ";printState(lightController);
//! [Interesting]
try {
lightController = new upm::HLG150H(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0) {
lightController->setPowerOn();
lightController->setBrightness(brightness);
} else
lightController->setPowerOff();
}
std::cout << "Now: ";printState(lightController);
delete lightController;
} catch (std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
status = 1;
}
return status;
return 0;
}

View File

@ -40,7 +40,7 @@ void printUsage(char *progname)
<< endl;
cout << "sent to the module and the response is printed out." << endl;
cout << endl;
cout << "If no argument is used, then the address and PIN of the module"
cout << "If no argument is used, then the address and PIN of the module"
<< endl;
cout << "are queried and the results printed out." << endl;
cout << endl;
@ -52,12 +52,12 @@ void sendCommand(upm::HM11* ble, char *cmd)
{
char buffer[BUFSIZ];
ble->writeData(cmd, strlen(cmd));
// wait up to 1 second
if (ble->dataAvailable(1000))
{
memset(buffer, 0, BUFSIZ);
ble->readData(buffer, BUFSIZ - 1);
cout << "Returned: " << buffer << endl;
}
@ -71,7 +71,6 @@ void sendCommand(upm::HM11* ble, char *cmd)
int main (int argc, char **argv)
{
//! [Interesting]
char buffer[BUFSIZ];
// Instantiate a HM11 BLE Module on UART 0
upm::HM11* ble = new upm::HM11(0);

View File

@ -32,16 +32,17 @@ main(int argc, char **argv)
//! [Interesting]
// Instantiate on I2C
upm::Hmc5883l* compass = new upm::Hmc5883l(0);
int16_t *pos;
compass->set_declination(0.2749); // Set your declination from true north in radians
compass->set_declination(0.2749); // Set your declination from
// true north in radians
// Print out the coordinates, heading, and direction every second
while(true){
compass->update(); // Update the coordinates
pos = compass->coordinates();
const int16_t *pos = compass->coordinates();
fprintf(stdout, "coor: %5d %5d %5d ", pos[0], pos[1], pos[2]);
fprintf(stdout, "heading: %5.2f direction: %3.2f\n", compass->heading(), compass->direction());
fprintf(stdout, "heading: %5.2f direction: %3.2f\n",
compass->heading(), compass->direction());
sleep(1);
}
//! [Interesting]

69
examples/c++/ims.cxx Normal file
View File

@ -0,0 +1,69 @@
/*
* Author: Noel Eck <noel.eck@intel.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "ims.hpp"
using namespace upm;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a IMS instance using i2c bus 0 and default address
upm::IMS sensor(0);
while (shouldRun)
{
std::cout << "Version: "
<< sensor.get_version()
<< " light: "
<< sensor.get_light()
<< " moisture: "
<< sensor.get_moisture()
<< " temp: "
<< sensor.get_temperature()
<< " C"
<< std::endl;
sleep(1);
}
//! [Interesting]
std::cout << "Exiting..." << std::endl;
return 0;
}

View File

@ -95,4 +95,4 @@ int main( int argc, char **argv )
return status;
}
//! [Interesting]

73
examples/c++/lcdks.cxx Normal file
View File

@ -0,0 +1,73 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2017 Intel Corporation.
*
* The MIT License
*
* 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 "lcdks.hpp"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a LCDKS (LCD Keypad Shield) using default pins
// NOTE: The default pins do not include support for a gpio
// controlled backlight. If you need one, you will need to specify
// all neccessary pins to the constructor.
upm::LCDKS* lcd = new upm::LCDKS();
lcd->setCursor(0,0);
lcd->write("LCDKS driver");
lcd->setCursor(1,2);
lcd->write("Hello World");
// output current key value every second.
while (shouldRun)
{
cout << "Button value: " << lcd->getKeyValue() << endl;
sleep(1);
}
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -44,7 +44,7 @@ main(int argc, char **argv)
std::cout << "For the next " << NUMBER_OF_SECONDS << " seconds, "
<< SAMPLES_PER_SECOND << " samples will be taken every second."
<< std::endl << std::endl;
uint16_t* buffer = new uint16_t[NUMBER_OF_SECONDS * SAMPLES_PER_SECOND];
uint16_t buffer[NUMBER_OF_SECONDS * SAMPLES_PER_SECOND];
for (int i=0; i < NUMBER_OF_SECONDS * SAMPLES_PER_SECOND; i++) {
buffer[i] = (uint16_t) sensor->getSample();
usleep(MICROSECONDS_PER_SECOND / SAMPLES_PER_SECOND);

View File

@ -34,10 +34,11 @@ main(int argc, char **argv)
// Create the light sensor object using AIO pin 0
upm::Light* light = new upm::Light(0);
// Read the input and print both the raw value and a rough lux value,
// waiting one second between readings
// Read the input and print both the normalized ADC value and a
// rough lux value, waiting one second between readings
while( 1 ) {
std::cout << light->name() << " raw value is " << light->raw_value() <<
std::cout << light->name() << " normalized value is "
<< light->getNormalized() <<
", which is roughly " << light->value() << " lux" << std::endl;
sleep(1);
}

View File

@ -48,7 +48,6 @@ main(int argc, char **argv)
sensor = new upm::LoL();
signal(SIGINT, sig_handler);
unsigned char *buffer;
//buffer = sensor->getFramebuffer();
int x = 0, y = 0;
while (!is_running) {

View File

@ -9,44 +9,37 @@
#define LP8860_GPIO_PWR 45 // Edison GP45
void printState(upm::ILightController *lightController)
void printState(upm::ILightController &lightController)
{
if (lightController->isPowered())
{
std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
if (lightController.isPowered())
{
std::cout << "Light is powered, brightness = " << lightController.getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
}
int main( int argc, char **argv )
{
int status = 0;
upm::LP8860* lightController;
//! [Interesting]
upm::LP8860 lightController(LP8860_GPIO_PWR, EDISON_I2C_BUS);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0)
{
lightController.setPowerOn();
lightController.setBrightness(brightness);
}
else
lightController.setPowerOff();
}
std::cout << "Now: ";printState(lightController);
//! [Interesting]
try {
lightController = new upm::LP8860(LP8860_GPIO_PWR, EDISON_I2C_BUS);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0) {
lightController->setPowerOn();
lightController->setBrightness(brightness);
} else
lightController->setPowerOff();
}
std::cout << "Now: ";printState(lightController);
delete lightController;
} catch (std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
status = 1;
}
return status;
return 0;
}

View File

@ -46,7 +46,7 @@ int
main(int argc, char **argv)
{
//! [Interesting]
sensor = new upm::LPD8806(10, 7);
sensor = new upm::LPD8806(0, 7, 10);
usleep (1000000);
sensor->show ();

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

@ -0,0 +1,76 @@
/* Author: Norbert Wesp <nwesp@phytec.de>
* Copyright (c) 2017 Phytec Messtechnik GmbH.
*
* 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 "mag3110.hpp"
using namespace upm;
bool run = true;
void sig_handler(int sig)
{
if (sig == SIGINT)
run = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
upm::mag3110_data_t data;
std::cout << "Initializing test-application..." << std::endl;
// Instantiate an MAG3110 instance on bus 1
upm::MAG3110 *mySensor = new upm::MAG3110(1);
// activate periodic measurements
mySensor->setActive();
// update and print available values every second
while (run)
{
mySensor->getData (&data, true);
std::cout << "x: " << data.x << std::endl
<< "y: " << data.y << std::endl
<< "z: " << data.z << std::endl
<< "Status: " << data.status << std::endl
<< "Die temperature: " << data.dtemp << std::endl;
std::cout << std::endl;
sleep(1);
}
std::cout << "Exiting test-application..." << std::endl;
delete mySensor;
//! [Interesting]
return 0;
}

99
examples/c++/max30100.cxx Normal file
View File

@ -0,0 +1,99 @@
/*
* Author: Noel Eck <noel.eck@intel.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "max30100.hpp"
using namespace upm;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
// Example Callback handler
class mycallback : public Callback
{
public:
virtual void run(max30100_value samp)
{
std::cout << "My callback sample IR: "
<< samp.IR << " R: " << samp.R << std::endl;
}
};
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a MAX30100 instance using i2c bus 0
upm::MAX30100 sensor(0);
// Create an instance of the Callback class
mycallback cb;
// Read the temperature and version
std::cout << "Temperature: " << sensor.temperature() << " C" << std::endl;
std::cout << "Version: " << sensor.version() << std::endl;
// Set high-res (50 Hz, 16-bit)
sensor.high_res_enable(true);
// Set to sample SpO2
sensor.mode(MAX30100_MODE_SPO2_EN);
// Read continuously, stepping up the LED current every second,
// us GPIO 0 as the interrupt pin
sensor.sample_continuous(0, false, &cb);
for (int i = MAX30100_LED_CURRENT_0_0_MA;
i <= MAX30100_LED_CURRENT_50_0_MA && shouldRun; i++)
{
// Toggle the LED current
std::cout << "Setting LED current = " << i << std::endl;
sensor.current((MAX30100_LED_CURRENT)i, (MAX30100_LED_CURRENT)i);
upm_delay(1);
}
// Read individual samples
for (int i = 0; i < 10; i++)
{
max30100_value val = sensor.sample();
std::cout << "Single value IR: " << val.IR << " R: " << val.R << std::endl;
}
//! [Interesting]
std::cout << "Exiting..." << std::endl;
return 0;
}

View File

@ -44,7 +44,7 @@ int
main(int argc, char **argv)
{
//! [Interesting]
sensor = new upm::MAX31723(7);
sensor = new upm::MAX31723(0, 7);
usleep (1000000);
while (!doWork) {

View File

@ -30,17 +30,13 @@
int main ()
{
try {
upm::MAX44009* lightSensor = new upm::MAX44009(EDISON_I2C_BUS);
while (true) {
float value = lightSensor->getVisibleLux();
std::cout << "Light level = " << value << " lux" << std::endl;
sleep(1);
}
delete lightSensor;
} catch (std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
//! [Interesting]
upm::MAX44009 lightSensor(EDISON_I2C_BUS);
while (true) {
float value = lightSensor.getVisibleLux();
std::cout << "Light level = " << value << " lux" << std::endl;
sleep(1);
}
//! [Interesting]
return 0;
}

View File

@ -1,6 +1,6 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -24,13 +24,14 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include "sainsmartks.hpp"
#include <upm_utilities.h>
#include <mb704x.hpp>
using namespace std;
using namespace upm;
int shouldRun = true;
bool shouldRun = true;
void sig_handler(int signo)
{
@ -38,29 +39,32 @@ void sig_handler(int signo)
shouldRun = false;
}
int main(int argc, char **argv)
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// use default pins
upm::SAINSMARTKS* lcd = new upm::SAINSMARTKS();
lcd->setCursor(0,0);
lcd->write("Sainsmart KS");
lcd->setCursor(1,2);
lcd->write("Hello World");
// output current key value every second.
while (shouldRun)
{
cout << "Button value: " << lcd->getRawKeyValue() << endl;
sleep(1);
}
signal(SIGINT, sig_handler);
//! [Interesting]
delete lcd;
return 0;
// Instantiate a MB704X sensor using default parameters (bus 0,
// address 112)
upm::MB704X *sensor = new upm::MB704X();
while (shouldRun)
{
cout << "Range: "
<< sensor->getRange()
<< " cm"
<< endl;
upm_delay_ms(500);
}
cout << "Exiting..." << endl;
delete sensor;
//! [Interesting]
return 0;
}

View File

@ -0,0 +1,125 @@
/*
* 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 <stdio.h>
#include <iostream>
#include <signal.h>
#include <upm_utilities.h>
#include "mcp2515.hpp"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
// by default we just receive packets
bool do_tx = false;
// if an argument is given, we will transmit packets
if (argc > 1)
do_tx = true;
//! [Interesting]
// NOTE: This example assumes that only two devices are connected
// to the CAN bus, and that both devices are running this example;
// one in TX (transmit) mode, and one in RX (receive) mode.
// If this is not the case, then in rx mode you may see other
// packets from other devices, or not, depending on whether the
// speed is correct for the network. In tx mode, errors may be
// generated on the bus, especially if the CAN bus speed does not
// match the rest of the network.
// You should start the receiver example first. The transmitter
// example will fail after about 5 seconds (timeout) of not being
// able to transmit a message.
// Instantiate a MCP2515 on SPI bus 0 using a hw CS pin (-1).
upm::MCP2515 *sensor = new upm::MCP2515(0, 9);
// By default, after initialization, the baud rate is set to
// 50Kbps, and the mode is NORMAL, so we don't need to set any of
// that here.
// our TX payload. If transmitting, the first number will be
// incremented (and rollover) on each transmission.
string myPayload = "01234567";
while (shouldRun)
{
if (do_tx)
{
cout << "Loading a packet of 8 numbers (0-7) into a TX buffer..."
<< endl;
sensor->loadTXBuffer(MCP2515_TX_BUFFER0, 0, false, false,
myPayload);
// now lets try to transmit it
cout << "Transmitting packet..." << endl;
sensor->transmitBuffer(MCP2515_TX_BUFFER0, true);
myPayload[0]++;
cout << "Transmit successful" << endl;
cout << endl;
upm_delay_ms(500);
}
else
{
// RX mode
// Look for a packet waiting for us in RXB0
if (sensor->rxStatusMsgs() == MCP2515_RXMSG_RXB0)
{
cout << "Packet received in RXB0, decoding..." << endl;
// now lets retrieve and print it
sensor->getRXMsg(MCP2515_RX_BUFFER0);
sensor->printMsg();
cout << endl;
}
upm_delay_ms(100);
}
}
cout << "Exiting..." << endl;
delete sensor;
//! [Interesting]
return 0;
}

79
examples/c++/mcp2515.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 <stdio.h>
#include <iostream>
#include "mcp2515.hpp"
using namespace std;
int main(int argc, char **argv)
{
//! [Interesting]
// Instantiate a MCP2515 on SPI bus 0 using a hw CS pin (-1).
upm::MCP2515 *sensor = new upm::MCP2515(0, -1);
cout << "Setting loopback mode..." << endl;
// set the mode to loopback mode. In loopback mode, transmitted
// packets are sent directly to an appropriate receive buffer
// without actually going out onto the CAN bus.
sensor->setOpmode(MCP2515_OPMODE_LOOPBACK);
// lets build up a packet and try loading it (8 bytes max).
string myPayload = "01234567";
cout << "Loading a packet of 8 numbers (0-7) into a TX buffer..." << endl;
sensor->loadTXBuffer(MCP2515_TX_BUFFER0, 0, false, false, myPayload);
// now lets try to transmit it
cout << "Transmitting packet..." << endl;
sensor->transmitBuffer(MCP2515_TX_BUFFER0, true);
cout << "Transmit successful" << endl;
// There should now be a packet waiting for us in RXB0
if (sensor->rxStatusMsgs() == MCP2515_RXMSG_RXB0)
{
cout << "Packet received in RXB0, decoding..." << endl;
// now lets retrieve and print it
sensor->getRXMsg(MCP2515_RX_BUFFER0);
sensor->printMsg();
}
else
{
cout << "No packet found, how strange." << endl;
}
cout << "Exiting..." << endl;
delete sensor;
//! [Interesting]
return 0;
}

View File

@ -159,5 +159,5 @@ int main()
}while (command != -1 );
//! [Interesting]
return MRAA_SUCCESS;
return 0;
}

View File

@ -74,5 +74,5 @@ int main()
delete sensor;
//! [Interesting]
return MRAA_SUCCESS;
return 0;
}

91
examples/c++/mma8x5x.cxx Normal file
View File

@ -0,0 +1,91 @@
/* Author: Norbert Wesp <nwesp@phytec.de>
* Copyright (c) 2017 Phytec Messtechnik GmbH.
*
* 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 "mma8x5x.hpp"
using namespace upm;
bool run = true;
void sig_handler(int sig)
{
if (sig == SIGINT)
run = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
upm::mma8x5x_data_t data;
// U can set your own parameters for an MMA8X5X instance with
/*
upm::mma8x5x_params_t params;
params.type = <device-id>; device-id of your sensor
params.rate = <sampling-rate>; between 0<<3 and 7<<3
params.range = <range>; between 0 and 2
params.offsetX = <x-axis offset>; between 0 and 255
params.offsetY = <y-axis offset>; between 0 and 255
params.offsetZ = <z-axis offset>; between 0 and 255
*/
std::cout << "Initializing test-application..." << std::endl;
// Instantiate an MMA8X5X instance on bus 1 with default parameters
// The sensor-type will be detected by reading out the device-id
upm::MMA8X5X *mySensor = new upm::MMA8X5X(1);
// If u have set own parameters use this one
/*
upm::MMA8X5X *mySensor = new upm::MMA8X5X(1, &params);
*/
// activate periodic measurements
mySensor->setActive();
// update and print available values every second
while (run)
{
mySensor->getData (&data, true);
std::cout << "x: " << (int)data.x << std::endl
<< "y: " << (int)data.y << std::endl
<< "z: " << (int)data.z << std::endl;
std::cout << std::endl;
sleep(1);
}
std::cout << "Exiting test-application..." << std::endl;
delete mySensor;
//! [Interesting]
return 0;
}

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

@ -0,0 +1,111 @@
/*
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <unistd.h>
#include <signal.h>
#include <math.h>
#include "mmc35240.hpp"
using namespace std;
int shouldRun = true;
upm::MMC35240* magnetometer;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
void
data_callback(char* data)
{
float x, y, z;
double azimuth;
int level;
magnetometer->extract3Axis(data, &x, &y, &z);
/* calibrated level
* UNRELIABLE = 0
* ACCURACY_LOW = 1
* ACCURACY_MEDIUM = 2
* ACCURACY_HIGH = >=3
*/
level = magnetometer->getCalibratedLevel();
if ((x == 0) && (y == 0)) {
cout << "Point (0, 0) is invalid!\n" << endl;
return;
}
if (x == 0) {
if (y > 0)
azimuth = 0;
else
azimuth = 180;
} else if (y == 0) {
if (x > 0)
azimuth = 90;
else
azimuth = 270;
} else {
if (x > 0)
azimuth = 90 - atan(y / x) * 180 / M_PI;
else
azimuth = 270 - atan(y / x) * 180 / M_PI;
}
cout << "[Calibrated Level:" << level << ']' << "[Azimuth:" << (int) (360 - azimuth) << ']'
<< '\t' << (int) x << '\t' << (int) y << '\t' << (int) z << "[uT]" << endl;
}
int
main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a MMC35240 Magnetic Sensor on iio device 5. This configuration is a reference and
// should be changed per platform/board type.
magnetometer = new upm::MMC35240(5);
// Kernel driver does not allow changing the value of scale at run-time, default scale is
// 0.001000
magnetometer->setScale(0.001000);
// Available sampling frequency are 1.5, 13, 25, 50
magnetometer->setSamplingFrequency(25.000000);
magnetometer->enable3AxisChannel();
magnetometer->installISR(data_callback, NULL);
magnetometer->enableBuffer(16);
while (shouldRun) {
sleep(1);
}
magnetometer->disableBuffer();
//! [Interesting]
cout << "Exiting" << endl;
delete magnetometer;
return 0;
}

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

@ -0,0 +1,78 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "ms5803.hpp"
using namespace std;
using namespace upm;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a MS5803 instance using i2c bus 0 and default address
upm::MS5803 *sensor = new upm::MS5803(0);
// For SPI, bus 0, you would pass -1 as the address, and a valid
// pin for CS (or -1 if you are using a hw pin you have no control
// over, like edison):
// MS5803(0, -1, 9);
while (shouldRun)
{
// update our values from the sensor
sensor->update();
cout << "Temperature: "
<< sensor->getTemperature()
<< " C, "
<< "Pressure: "
<< sensor->getPressure()
<< " mbar"
<< endl;
sleep(1);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -31,6 +31,7 @@
using namespace std;
using namespace upm;
//! [Interesting]
int main(int argc, char **argv)
{
// Instantiate a NLGPIO16 Module on the default UART (/dev/ttyACM0)

View File

@ -29,6 +29,7 @@
#include <lib_aci.h>
#include <aci_setup.h>
#include <signal.h>
#include <assert.h>
#ifdef SERVICES_PIPE_TYPE_MAPPING_CONTENT
static services_pipe_type_mapping_t
@ -77,11 +78,11 @@ init_aci_setup () {
/**
* Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001
*/
if (NULL != services_pipe_type_mapping) {
aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
} else {
aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
}
// abort if this is NULL
assert(services_pipe_type_mapping != NULL);
aci_state.aci_setup_info.services_pipe_type_mapping =
&services_pipe_type_mapping[0];
aci_state.aci_setup_info.number_of_pipes = NUMBER_OF_PIPES;
aci_state.aci_setup_info.setup_msgs = setup_msgs;

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