Compare commits

..

60 Commits

Author SHA1 Message Date
58c800e246 upm: version 0.3.2
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 17:03:58 -07:00
48a8d3e0cc cmake: fixed IPK version tag
Broken when RPM support was added and incompatible with current IPK naming strings

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 14:07:46 -07:00
1fe9b9eb1d docs: final batch of header files reviewed
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 14:03:08 -07:00
04edb9be04 docs: more header files edited
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 12:21:16 -07:00
55e8076988 eboled: Initial implementation
This driver supports the Sparkfun 64x48 pixel OLED Edison block:

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

It is based on an ssd1306, but with some modifications (custom COM pin
mapping and a custom column offset).  It uses SPI to communicate, and
since it is an Edison Block, you don't really have any options for
different bus and pin assignments.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 11:20:14 -07:00
9db2d57de3 docs: header files for sensors starting with [a] reviewed.
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-07 13:57:52 -07:00
de49bb0e42 docs: removed mpu9150 from list of known limitations and added bmp180
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-06 17:27:09 -07:00
93595bcd35 adafruitss: removed ambiguous servo() overload
Overload is unnecessary and SWIG can't handle overloads with the same number of arguments
thus it would break the js and py bindings

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:55:47 -07:00
7260c78c33 adafruitss: fix the period setting in setPWMFreq()
Tweak the fudge factor so it is more accurate for 50Hz and 60Hz periods. (Tested on Logic 4 and it is spot on now)
Get rid of compiler warnings when -Wall is set
Allow for float angle to be passed into the servo() method for more accurate positioning

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:16:06 -07:00
197b56003c lcd: jhd1313m1 example: sleep a bit so we can see the display
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:13:31 -07:00
f133b6eb4c lcd: jhd1313m1: rewrite to use Lcm1602 as a base class
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:13:23 -07:00
cb62f06197 lcd: lcm1602: modifications for eventual use as a base class for jhd1313m1
We add a new bool isExpander to the the I2C constructor.  This allows
us (in the case we are not dealing with an expander) to just
initialize the i2c context only and bail in the constructor.  The
default is true to preserve backward compatibility.

Additionally, add two new virtual protected methods, data() and
command() for sending data or commands to the controller.  The default
implementation in lcm1602 will work for 4bit GPIO and expander use.

In the case of jhd1313m1, they will need to be redefined in that class
as the sematics for sending data and commands are different.

All of the underlying functionality will use command() or data() as
appropriate.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:13:15 -07:00
a2e4fb5d7a lcd: add missing functionality to lcm1602
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:13:00 -07:00
36b0e1dce0 lsm9ds0: Initial implementation
This module implements support for the LSM9DS0 accelerometer,
magnetometer, and gyroscope.

It was developed on the Sparkfun 9DOF sensor block for Intel Edison.

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

Commonly used capabilities are supported, and methods/register
definitions exist to easily implement any desired functionality that
is missing.  Interrupt support has also been added.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-04 15:56:25 -07:00
03e72e02f8 mpu9150: rewrite from scratch
This driver has been rewritten from scratch.  It is implemented as 3
seperate drivers now (but all included as part of the mpu9150 UPM
library):

AK8975 (Magnetometer)
MPU60X0 (Accelerometer, Gyroscope, and Temperature sensor)
MPU9150 (composed of AK8975 and MPU60X0)

Each driver can be used independently and includes examples in
C++/JS/Python.

Commonly used capabilities are supported, and methods/register
definitions exist to easily implement any desired functionality that
is missing.  Interrupt support has also been added.

Scaling support has also been properly implemented for both the
Accelerometer and Gyroscope.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-29 13:25:05 -07:00
6613dea552 cmake: adds option to use different lib&class names with python docs
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-22 11:48:17 -07:00
ef173ebeaf sainsmartks: Initial Implementation
This driver was developed with a Sainsmart LCD Keypad Shield.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:38:52 -07:00
5a6fb122ec lcm1602: add 4-bit gpio support with RS and Enable pins
In addition, move the command/data sending methods into the protected
block so that derived classes can use them if need be.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:38:01 -07:00
8462e8ce52 jhd1313m1: add createChar() method, as it should be supported by this device
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:37:06 -07:00
1647f572ff lcd: remove i2c context from LCD base class
This commit removes the I2C context from the LCD base class and moves
it into each of the drivers.

In addition, the createChar() virtual function was removed from the
base class, as it directly used the now non-existant i2c context, and
it would not work on anything other than hd44780 based controllers and
displays anyway. Also, it is likely the capability itself, as well as
the data required to implement it, is going to be different from
device to device.

createChar() has been added to the Lcm1602 driver which can support it.

While doing this work, the LCD base class m_name is now set appropriately
in the driver constructors.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:36:09 -07:00
56f7e97536 lcd: move the hd44780 controller bit definitions into a separate header
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:35:09 -07:00
3aaafdcecf lcd: rename I2CLcd class to LCD
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:34:13 -07:00
99651d2239 lcd: rename i2clcd.{h,cxx} to lcd.{h,cxx}
We keep the same upm module library name (i2clcd), and the header
documentation still specifies @library i2clcd.

These will need to be changed when the actual library is renamed.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:33:15 -07:00
c586cd5177 pn532: initial implementation
This driver was written using an Adafruit PN532 board:

http://www.adafruit.com/products/364

It is based heavily on their arduino code, with significant
modifications.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 16:29:58 -07:00
fc3a884024 cmake: tweaked RPM generation and made arch detection global
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-20 11:59:55 -07:00
a91f1e5095 cmake: enabled RPM packaging
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-17 16:46:23 -07:00
2314bc2f59 grovecircularled: updated description
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 17:10:14 -07:00
af2281057a ht9170: added image for DTMF shield
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 17:02:25 -07:00
e85c98062b adxl335: added image for adxl335
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 17:00:18 -07:00
c1cde01424 lol: added image for lol shield
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 16:57:43 -07:00
54cda32a94 waterlevel: updated description and few changes to header
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 16:53:00 -07:00
2e36b8dc21 images: Added few images and modified few header files
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-07-08 11:46:30 -07:00
f4a5c9a391 hp20x: Initial implementation
This module implements support for the hp20x family of high accuracy
barometers.  It was developed on the Grove Barometer (High Accuracy)
based on the HP206C.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-06 15:19:18 -07:00
08ff50067a hcsr04: Fixed compilation error after MRAA enum renaming
Closes #214.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2015-07-06 18:45:27 +02:00
cff584d8b9 docs: implement broken link fix in cmake configuration file instead
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 14:15:04 -07:00
abb9c91320 revert: "docs: fix for broken index image links after move"
This reverts commit a03d0c7e95.
Fix can be implemented easier in cmake configuration instead.
2015-06-29 14:00:57 -07:00
a03d0c7e95 docs: fix for broken index image links after move
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 13:31:31 -07:00
231a1f1b43 rgbringcoder: Initial implementation.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 10:28:13 -07:00
c313e3ae69 grovecircularled: Initial import/implementation
This code is based off ofthe my9221 driver.  This modification was
done by Jun Kato, but abandoned.

This driver will not work correctly on Galileo.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 10:02:53 -07:00
f2503c6167 cmake: Change error message when git not found to say UPM
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 09:41:05 -07:00
7a7b8324b4 at42qt1070: fix invalid assignment
Signed-off-by: Wouter van Verre <wouter.van.verre@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 09:36:23 -07:00
057fa03723 at42qt1070: Add additional functionality
Add functionality to read and set the low-power mode settings
Add functions to read and set the averaging factor per key
Add functions to read and set the adjecent key suppression (AKS) groups
Add a function to read the ID register
Add a sanity check to the constructor

Signed-off-by: Wouter van Verre <wouter.van.verre@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 09:36:01 -07:00
f64c710c12 at42qt1070: code style changes
Run .clang-format on the header and source files
Add missing braces

Signed-off-by: Wouter van Verre <wouter.van.verre@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 09:35:41 -07:00
32921ff2b1 upm: updated headers of sensors in home automation kit
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-24 13:39:09 -07:00
6c7928fc92 upm: updated headers of sensors in environmental kit
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-24 13:25:29 -07:00
fd29a7409e upm: added kit tags to @ingroup too
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-24 13:16:52 -07:00
61c95088af upm: updated headers of sensors in transportation kit
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 16:47:11 -07:00
24bda4741c upm: updated headers of sensors in robotics kit
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 16:35:50 -07:00
172124f20a mhz16: fixed connection type in @ingroup
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 12:03:07 -07:00
17dbadfe9f grovescam: fixed tag names in header
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 11:18:03 -07:00
e71ae67b4e hm11: updated header tag names and new @altid tag
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 11:13:02 -07:00
e00ee9b777 a110x: updated header with new @altid tag
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 10:52:56 -07:00
0f015354ef doxygen: new @altid tag for sensors supporting multiple chip variants
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 10:50:26 -07:00
3ed6e09f20 changelog: added sensors to the list for the latest versions
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-19 11:59:53 -07:00
0dbfa06359 jhd1313m1: modified destructor to clear and turn off lcd on delete
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-16 17:02:21 -07:00
2fda38f7b1 i2clcd: added virtual destructor to base lcd class
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-16 16:48:27 -07:00
ec1828f2bc changelog: rephrased an item from the list
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-16 12:15:45 -07:00
3e6ec5087b docs: made a few modifications in known limitations, changelog and building instructions
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-16 11:58:00 -07:00
a3b4d466d7 docs: moved API images used on links to their own subfolder
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-12 13:46:24 -07:00
1ddd325e18 images: added CC BY-NC-SA 3.0 license file for Sparkfun images
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-12 11:36:36 -07:00
229 changed files with 14873 additions and 3485 deletions

View File

@ -29,8 +29,8 @@ include(GNUInstallDirs)
include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
message (WARNING " - Install git to compile a production libmraa!")
set (VERSION "v0.3.1-dirty")
message (WARNING " - Install git to compile a production UPM!")
set (VERSION "v0.3.2-dirty")
endif ()
message (INFO " - UPM Version ${VERSION}")
@ -53,19 +53,25 @@ set (upm_VERSION_STRING ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_
set (CMAKE_SWIG_FLAGS "")
option (IPK "Generate IPK using CPack" OFF)
option (BUILDDOC "Build all doc." OFF)
option (BUILDSWIG "Build swig modules." ON)
option (BUILDSWIGPYTHON "Build swig python modules." ON)
option (BUILDSWIGNODE "Build swig node modules." ON)
option (BUILDEXAMPLES "Build C++ example binaries" OFF)
option (IPK "Generate IPK using CPack" OFF)
option (RPM "Generate RPM using CPack" OFF)
# detect arch
include (TargetArch)
target_architecture (DETECTED_ARCH)
message( INFO " - Target arch is ${DETECTED_ARCH}")
if (BUILDDOC)
# add a target to generate API documentation with Doxygen
find_package (Doxygen)
if (DOXYGEN_FOUND)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/*.png)
file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/icons/*.png)
foreach(PNG_FILE ${PNG_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY)
endforeach()
@ -121,10 +127,7 @@ if (BUILDDOC)
endif()
if (IPK)
include (TargetArch)
target_architecture (DETECTED_ARCH)
message( INFO " - Target arch is ${DETECTED_ARCH}")
message (INFO " - IPK packaging enabled for ${DETECTED_ARCH}")
set(CPACK_GENERATOR "DEB" "TGZ")
set(OPKG_ARCH ${DETECTED_ARCH})
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
@ -147,6 +150,28 @@ if (IPK)
include (CPack)
endif()
if (RPM)
message (INFO " - RPM packaging enabled for ${DETECTED_ARCH}")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "libupm${upm_VERSION_MAJOR}")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_VERSION
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}-${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
set(CPACK_RPM_PACKAGE_REQUIRES "libmraa0 >= ${MRAA_VERSION}")
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
EXECUTE_PROCESS(COMMAND rpm --showrc
COMMAND grep -E "dist[[:space:]]*\\."
COMMAND sed -e "s/^.*dist\\s*\\.//"
COMMAND tr \\n \\t
COMMAND sed -e s/\\t//
OUTPUT_VARIABLE DIST_TAG)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${DIST_TAG}.${DETECTED_ARCH}")
include(CPack)
endif()
add_subdirectory (src)
if(BUILDEXAMPLES)

View File

@ -65,9 +65,9 @@ API Documentation
@htmlonly
<a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="docs/c++.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/python.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/node.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="docs/icons/c++.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
@endhtmlonly

View File

@ -3,8 +3,7 @@ Building UPM {#building}
UPM uses cmake in order to make compilation relatively painless. Cmake runs
build out of tree so the recommended way is to clone from git and make a build/
directory. Failure to do an out-of-source build may cause issues when
rebuilding later on.
directory.
This project depends on libmraa, so that needs to be installed first. Use the
following environment variables to configure the paths:
@ -25,7 +24,8 @@ make install
~~~~~~~~~~~~~
The last command will create the include/ and lib/ directories with a copy of
the headers and library objects respectively in your build location.
the headers and library objects respectively in your build location. Note that
doing an out-of-source build may cause issues when rebuilding later on.
Our cmake configure has a number of options, *cmake-gui* or *ccmake* can show
you all the options. The interesting ones are detailed below:
@ -61,7 +61,11 @@ Setting the python library to use:
~~~~~~~~~~~~~
Building doxygen doc
~~~~~~~~~~~~~
-BUILDDOC=ON
-DBUILDDOC=ON
~~~~~~~~~~~~~
Build C++ example binaries
~~~~~~~~~~~~~
-DBUILDEXAMPLES=ON
~~~~~~~~~~~~~
If you intend to turn on all the options and build everything at once (C++,

View File

@ -4,24 +4,38 @@ Changelog {#changelog}
Here's a list summarizing some of the key undergoing changes to our library
from earlier versions:
### v0.3.2
* Introduced RPM package generation feature from cmake via cpack
* Performed a thorough documentation review and merged resulting changes,
includes last remaining images and grouping sensors by kits
* Added support for Sparkfun Sensor Blocks (OLED & IMU)
* Fully reworked API for at42qt1070, mpu9150 and lcd classes, while
maintaining backwards compatibility for existing lcd displays.
* Extended doxygen tags for better integration with automated documentation
generators
* New sensors: rgbringcoder, hp20x, pn532, sainsmartks, lsm9ds0, eboled
### v0.3.1
* Updated index pages for API documentation and cross-linked them
* More images were added for Grove, Adafruit and Sparkfun sensors along with
licensing information
* Addressed several issues reported by static code analysis tools
* Applied a set of patches to improve code robustness
* Added support for Grove NFC Tag sensor
* Fixed several typos in library and sensor names
* New sensor: m24lr64e
### v0.3.0
* New CMake targets to build python and node documentation with Sphinx and
Yuidoc
* Provided automated, updated and comprehensive sensor API documentation for
C++, Python and JavaScript
* Edited sensor names, library descriptions and doxygen tags for consistency
* Added support for several new sensors
* Fixed the TH02 sensor driver and made major improvements to i2clcd driver
* Updated and added new images for a lot of the existing sensors
* Added this changelog
* Added new and updated images for numerous new and existing sensors
* Started this changelog
* New sensors: sx6119, si114x, maxsonarez, hm11, ht9170, h3lis331dl, ad8232,
grovescam
### v0.2.0
@ -32,6 +46,10 @@ from earlier versions:
* Fixed the buzzer and servo drivers for the Intel Edison
* Renamed bmp and gp2y sensor classes to be more generic
* Completely revamped implementation for tm1637
* New sensors: mma7660, cjq4435, adxl335, hmtrp, nunchuck, otp538u, l298,
groveelectromagnet, grovecollision, adis16448, at42qt1070, grovemd, ina132,
grovegsr, groveo2, groveemg, pca9685, pca9685ss, adafruitms1438, hx711, flex,
groveeldriver, mhz16, apds9002, waterlevel, zfm20, uln200xa, grovewfs, isd1820
### v0.1.9
@ -40,6 +58,12 @@ from earlier versions:
* Several examples and documentation updates submitted
* Wrote new proper SWIG typemaps for arrays
* Fixed the i2clcd write function, improved several other sensors
* New sensors: rpr220, rotaryencoder, biss0001, rfr359f, grovespeaker, mq303a,
ppd42ns, wt5001, yg1006, ublox6, mpr121, groveloudness, guvas12d, grovewater,
grovevdiv, grovelinefinder, ta12200, groveehr, grovemoisture, gp2y0a, a110x,
ds1307, adc121c021, enc03r, ttp223, itg3200, am2315, tp401, ldt0028, htu21d,
mpl3115a2, lsm303, joystick12, tsl2561, groverotary, groveslider, adxl345,
grovebutton, lol, groverelay
### v0.1.8

View File

@ -28,6 +28,7 @@ Here's an example (disregard the "@verbatim" tags in your actual code):
* @sensor <chip-id>
* @comname <component-name>
* @altname <alt-name>
* @altid <alt-id>
* @type <component-category>
* @man <component-manufacturer>
* @web <component-weblinks>
@ -52,8 +53,8 @@ Here's an example (disregard the "@verbatim" tags in your actual code):
available or relevant, use a unique descriptor that makes sense. *Mandatory*
- `<component-name>` A short name for your sensor, can include manufacturer
name. *Mandatory*
- `<alt-name>` Alternative names or chip-ids that your sensor driver might
have or support respectively. *Optional*
- `<alt-name>` Alternative names that your sensor driver might have. *Optional*
- `<alt-id>` Alternative chip-ids that your sensor driver supports. *Optional*
- `<component-category>` Mention one or more categories the sensor fits in. Can
be 'other'. *Mandatory*
- `<component-manufacturer>` Sensor manufacturer. Can be 'generic'. *Mandatory*

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,361 @@
Creative Commons Legal Code
Attribution-NonCommercial-ShareAlike 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and
other pre-existing works, such as a translation, adaptation,
derivative work, arrangement of music or other alterations of a
literary or artistic work, or phonogram or performance and includes
cinematographic adaptations or any other form in which the Work may be
recast, transformed, or adapted including in any form recognizably
derived from the original, except that a work that constitutes a
Collection will not be considered an Adaptation for the purpose of
this License. For the avoidance of doubt, where the Work is a musical
work, performance or phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be considered an
Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as
encyclopedias and anthologies, or performances, phonograms or
broadcasts, or other works or subject matter other than works listed
in Section 1(g) below, which, by reason of the selection and
arrangement of their contents, constitute intellectual creations, in
which the Work is included in its entirety in unmodified form along
with one or more other contributions, each constituting separate and
independent works in themselves, which together are assembled into a
collective whole. A work that constitutes a Collection will not be
considered an Adaptation (as defined above) for the purposes of this
License.
c. "Distribute" means to make available to the public the original and
copies of the Work or Adaptation, as appropriate, through sale or
other transfer of ownership.
d. "License Elements" means the following high-level license attributes
as selected by Licensor and indicated in the title of this License:
Attribution, Noncommercial, ShareAlike.
e. "Licensor" means the individual, individuals, entity or entities that
offer(s) the Work under the terms of this License.
f. "Original Author" means, in the case of a literary or artistic work,
the individual, individuals, entity or entities who created the Work
or if no individual or entity can be identified, the publisher; and in
addition (i) in the case of a performance the actors, singers,
musicians, dancers, and other persons who act, sing, deliver, declaim,
play in, interpret or otherwise perform literary or artistic works or
expressions of folklore; (ii) in the case of a phonogram the producer
being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
g. "Work" means the literary and/or artistic work offered under the terms
of this License including without limitation any production in the
literary, scientific and artistic domain, whatever may be the mode or
form of its expression including digital form, such as a book,
pamphlet and other writing; a lecture, address, sermon or other work
of the same nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a musical
composition with or without words; a cinematographic work to which are
assimilated works expressed by a process analogous to cinematography;
a work of drawing, painting, architecture, sculpture, engraving or
lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied
art; an illustration, map, plan, sketch or three-dimensional work
relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the
extent it is protected as a copyrightable work; or a work performed by
a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
h. "You" means an individual or entity exercising rights under this
License who has not previously violated the terms of this License with
respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous
violation.
i. "Publicly Perform" means to perform public recitations of the Work and
to communicate to the public those public recitations, by any means or
process, including by wire or wireless means or public digital
performances; to make available to the public Works in such a way that
members of the public may access these Works from a place and at a
place individually chosen by them; to perform the Work to the public
by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to
broadcast and rebroadcast the Work by any means including signs,
sounds or images.
j. "Reproduce" means to make copies of the Work by any means including
without limitation by sound or visual recordings and the right of
fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic
medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
limit, or restrict any uses free from copyright or rights arising from
limitations or exceptions that are provided for in connection with the
copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License,
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
perpetual (for the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more
Collections, and to Reproduce the Work as incorporated in the
Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation,
including any translation in any medium, takes reasonable steps to
clearly label, demarcate or otherwise identify that changes were made
to the original Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or a
modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated
in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
The above rights may be exercised in all media and formats whether now
known or hereafter devised. The above rights include the right to make
such modifications as are technically necessary to exercise the rights in
other media and formats. Subject to Section 8(f), all rights not expressly
granted by Licensor are hereby reserved, including but not limited to the
rights described in Section 4(e).
4. Restrictions. The license granted in Section 3 above is expressly made
subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms
of this License. You must include a copy of, or the Uniform Resource
Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that
recipient under the terms of the License. You may not sublicense the
Work. You must keep intact all notices that refer to this License and
to the disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Work, You may not impose any effective technological
measures on the Work that restrict the ability of a recipient of the
Work from You to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to the Work as
incorporated in a Collection, but this does not require the Collection
apart from the Work itself to be made subject to the terms of this
License. If You create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the Collection any credit
as required by Section 4(d), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent
practicable, remove from the Adaptation any credit as required by
Section 4(d), as requested.
b. You may Distribute or Publicly Perform an Adaptation only under: (i)
the terms of this License; (ii) a later version of this License with
the same License Elements as this License; (iii) a Creative Commons
jurisdiction license (either this or a later license version) that
contains the same License Elements as this License (e.g.,
Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable License").
You must include a copy of, or the URI, for Applicable License with
every copy of each Adaptation You Distribute or Publicly Perform. You
may not offer or impose any terms on the Adaptation that restrict the
terms of the Applicable License or the ability of the recipient of the
Adaptation to exercise the rights granted to that recipient under the
terms of the Applicable License. You must keep intact all notices that
refer to the Applicable License and to the disclaimer of warranties
with every copy of the Work as included in the Adaptation You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Adaptation, You may not impose any effective technological
measures on the Adaptation that restrict the ability of a recipient of
the Adaptation from You to exercise the rights granted to that
recipient under the terms of the Applicable License. This Section 4(b)
applies to the Adaptation as incorporated in a Collection, but this
does not require the Collection apart from the Adaptation itself to be
made subject to the terms of the Applicable License.
c. You may not exercise any of the rights granted to You in Section 3
above in any manner that is primarily intended for or directed toward
commercial advantage or private monetary compensation. The exchange of
the Work for other copyrighted works by means of digital file-sharing
or otherwise shall not be considered to be intended for or directed
toward commercial advantage or private monetary compensation, provided
there is no payment of any monetary compensation in con-nection with
the exchange of copyrighted works.
d. If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and, (iv) consistent with Section 3(b), in the case of an Adaptation,
a credit identifying the use of the Work in the Adaptation (e.g.,
"French translation of the Work by Original Author," or "Screenplay
based on original Work by Original Author"). The credit required by
this Section 4(d) may be implemented in any reasonable manner;
provided, however, that in the case of a Adaptation or Collection, at
a minimum such credit will appear, if a credit for all contributing
authors of the Adaptation or Collection appears, then as part of these
credits and in a manner at least as prominent as the credits for the
other contributing authors. For the avoidance of doubt, You may only
use the credit required by this Section for the purpose of attribution
in the manner set out above and, by exercising Your rights under this
License, You may not implicitly or explicitly assert or imply any
connection with, sponsorship or endorsement by the Original Author,
Licensor and/or Attribution Parties, as appropriate, of You or Your
use of the Work, without the separate, express prior written
permission of the Original Author, Licensor and/or Attribution
Parties.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any
exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the Licensor reserves
the exclusive right to collect such royalties for any exercise by
You of the rights granted under this License if Your exercise of
such rights is for a purpose or use which is otherwise than
noncommercial as permitted under Section 4(c) and otherwise waives
the right to collect royalties through any statutory or compulsory
licensing scheme; and,
iii. Voluntary License Schemes. The Licensor reserves the right to
collect royalties, whether individually or, in the event that the
Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise
by You of the rights granted under this License that is for a
purpose or use which is otherwise than noncommercial as permitted
under Section 4(c).
f. Except as otherwise agreed in writing by the Licensor or as may be
otherwise permitted by applicable law, if You Reproduce, Distribute or
Publicly Perform the Work either by itself or as part of any
Adaptations or Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation. Licensor
agrees that in those jurisdictions (e.g. Japan), in which any exercise
of the right granted in Section 3(b) of this License (the right to
make Adaptations) would be deemed to be a distortion, mutilation,
modification or other derogatory action prejudicial to the Original
Author's honor and reputation, the Licensor will waive or not assert,
as appropriate, this Section, to the fullest extent permitted by the
applicable national law, to enable You to reasonably exercise Your
right under Section 3(b) of this License (right to make Adaptations)
but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING AND TO THE
FULLEST EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR OFFERS THE WORK AS-IS
AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE
WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT
LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT
DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
WARRANTIES, SO THIS EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate
automatically upon any breach by You of the terms of this License.
Individuals or entities who have received Adaptations or Collections
from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work).
Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at
any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is
required to be, granted under the terms of this License), and this
License will continue in full force and effect unless terminated as
stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection,
the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this License, and without further action
by the parties to this agreement, such provision shall be reformed to
the minimum extent necessary to make such provision valid and
enforceable.
d. No term or provision of this License shall be deemed waived and no
breach consented to unless such waiver or consent shall be in writing
and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings,
agreements or representations with respect to the Work not specified
here. Licensor shall not be bound by any additional provisions that
may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this
License were drafted utilizing the terminology of the Berne Convention
for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant
jurisdiction in which the License terms are sought to be enforced
according to the corresponding provisions of the implementation of
those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law
includes additional rights not granted under this License, such
additional rights are deemed to be included in the License; this
License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty
whatsoever in connection with the Work. Creative Commons will not be
liable to You or any party on any legal theory for any damages
whatsoever, including without limitation any general, special,
incidental or consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences, if Creative
Commons has expressly identified itself as the Licensor hereunder, it
shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the
Work is licensed under the CCPL, Creative Commons does not authorize
the use by either party of the trademark "Creative Commons" or any
related trademark or logo of Creative Commons without the prior
written consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark usage
guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt,
this trademark restriction does not form part of this License.
Creative Commons may be contacted at https://creativecommons.org/.

BIN
docs/images/adxl335.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
docs/images/grovecircularled.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
docs/images/hp20x.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 KiB

BIN
docs/images/ht9170.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
docs/images/lolshield.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

BIN
docs/images/rgbringcoder.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

View File

@ -16,12 +16,16 @@ such sensors and known workarounds if they exist.
Intel Edison Arduino board but will work with the Mini-breakout.
* **Grove 3-Axis Digital Accelerometer** (ADXL345) only works with the Intel
Edison Arduino board when powered from the 3.3V line.
* **Grove 3-Axis Digital Compass (HMC5883L) reports inaccurate values at 5V
on the Intel Edison Arduino board and newer revisions might not work at all.
Use 3.3V or the Mini-breakout.
* **Grove 96x96 OLED Display** will not work on the Intel Edison with Arduino
breakout.
* **Grove 128x64 OLED Display** will not work on the Intel Edison with Arduino
breakout.
* **Grove Barometer** (BMP085) has an unstable connection on the Intel Edison
using the Arduino breakout and does not run properly.
using the Arduino breakout and may drop read data. The Xadow version of this
sensor (BMP180) is also dropping data packets occasionally.
* **Grove 6-Axis Accelerometer & Compass** (LSM303) fails to write to the
configuration register properly and returns invalid data.
* **Grove I2C ADC Converter** does not show up on the I2C bus on the Intel
@ -39,7 +43,9 @@ such sensors and known workarounds if they exist.
#### Other Sensors
* **MPU9150** might return inaccurate data.
* **SM130** driver might not be fully functional.
* **NRF24L01** might not handle data packets as expected.
* **NRF8001** based devices do not initialize properly with provided examples.
#### General

View File

@ -236,6 +236,7 @@ ALIASES = library="@ingroup " \
sensor="@li **ID:** " \
comname="@li **Name:** " \
altname="@li **Other Names:** " \
altid="@li **Other Chips:** " \
type="@li **Category:** " \
man="@li **Manufacturer:** " \
web="@li **Link:** " \

View File

@ -56,11 +56,11 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
``Other API Documentation``
###########################
.. image:: ../docs/c++.png
.. image:: ../docs/icons/c++.png
:target: http://iotdk.intel.com/docs/master/upm/modules.html
.. image:: ../docs/python.png
.. image:: ../docs/icons/python.png
:target: http://iotdk.intel.com/docs/master/upm/python
.. image:: ../docs/node.png
.. image:: ../docs/icons/node.png
:target: http://iotdk.intel.com/docs/master/upm/node
``Version Changelog``

View File

@ -109,9 +109,9 @@
title="Permalink to this headline"></a></h1>
<p><a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="../docs/c++.png" /></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/python.png" /></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/node.png" /></a>
<p><a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="../docs/icons/c++.png" /></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/icons/python.png" /></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/icons/node.png" /></a>
</p>
</div>
<div class="section" id="version-changelog">

View File

@ -123,6 +123,16 @@ add_executable (h3lis331dl-example h3lis331dl.cxx)
add_executable (ad8232-example ad8232.cxx)
add_executable (grovescam-example grovescam.cxx)
add_executable (m24lr64e-example m24lr64e.cxx)
add_executable (grovecircularled-example grovecircularled.cxx)
add_executable (rgbringcoder-example rgbringcoder.cxx)
add_executable (hp20x-example hp20x.cxx)
add_executable (pn532-example pn532.cxx)
add_executable (pn532-writeurl-example pn532-writeurl.cxx)
add_executable (sainsmartks-example sainsmartks.cxx)
add_executable (mpu60x0-example mpu60x0.cxx)
add_executable (ak8975-example ak8975.cxx)
add_executable (lsm9ds0-example lsm9ds0.cxx)
add_executable (eboled-example eboled.cxx)
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
@ -224,6 +234,11 @@ include_directories (${PROJECT_SOURCE_DIR}/src/h3lis331dl)
include_directories (${PROJECT_SOURCE_DIR}/src/ad8232)
include_directories (${PROJECT_SOURCE_DIR}/src/grovescam)
include_directories (${PROJECT_SOURCE_DIR}/src/m24lr64e)
include_directories (${PROJECT_SOURCE_DIR}/src/grovecircularled)
include_directories (${PROJECT_SOURCE_DIR}/src/rgbringcoder)
include_directories (${PROJECT_SOURCE_DIR}/src/hp20x)
include_directories (${PROJECT_SOURCE_DIR}/src/pn532)
include_directories (${PROJECT_SOURCE_DIR}/src/lsm9ds0)
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
@ -348,3 +363,13 @@ target_link_libraries (h3lis331dl-example h3lis331dl ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ad8232-example ad8232 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovescam-example grovescam ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (m24lr64e-example m24lr64e ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovecircularled-example grovecircularled ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (rgbringcoder-example rgbringcoder ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (hp20x-example hp20x ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pn532-example pn532 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pn532-writeurl-example pn532 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (sainsmartks-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mpu60x0-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ak8975-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (lsm9ds0-example lsm9ds0 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (eboled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})

72
examples/c++/ak8975.cxx Normal file
View File

@ -0,0 +1,72 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "mpu9150.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
upm::AK8975 *sensor = new upm::AK8975();
sensor->init();
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer: ";
cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl;
cout << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

48
examples/c++/eboled.cxx Normal file
View File

@ -0,0 +1,48 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include "eboled.h"
using namespace std;
int main(int argc, char **argv)
{
//! [Interesting]
// Instantiate an Edison Block OLED using default values
upm::EBOLED *lcd = new upm::EBOLED();
lcd->clear();
lcd->setCursor(2, 0);
lcd->write("Hello");
lcd->setCursor(3, 5);
lcd->write("World!");
cout << "Sleeping for 5 seconds..." << endl;
sleep(5);
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -0,0 +1,63 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "grovecircularled.h"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a Grove Circular LED on gpio pins 5 and 4
upm::GroveCircularLED *circle = new upm::GroveCircularLED(5, 4);
int level = 0;
while (shouldRun)
{
circle->setSpinner(level);
level = (level + 1) % 24;
usleep(100000);
}
//! [Interesting]
cout << "Exiting" << endl;
delete circle;
return 0;
}

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

@ -0,0 +1,70 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include "hp20x.h"
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 an HP20X on default I2C bus and address
upm::HP20X *bar = new upm::HP20X();
// Initialize the device with default values
bar->init();
// Output data every second until interrupted
while (shouldRun)
{
printf("Temperature: %f Celcius\n", bar->getTemperature());
printf("Pressure: %f Millibars\n", bar->getPressure());
printf("Altitude: %f Meters\n", bar->getAltitude());
printf("\n");
sleep(1);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete bar;
return 0;
}

View File

@ -34,6 +34,9 @@ main(int argc, char **argv)
lcd->write("Hello World");
lcd->setCursor(1,2);
lcd->write("Hello World");
printf("Sleeping for 5 seconds\n");
sleep(5);
delete lcd;
//! [Interesting]
return 0;

83
examples/c++/lsm9ds0.cxx Normal file
View File

@ -0,0 +1,83 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "lsm9ds0.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b,
// xm addr 1d)
upm::LSM9DS0 *sensor = new upm::LSM9DS0();
sensor->init();
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer: ";
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
sensor->getGyroscope(&x, &y, &z);
cout << "Gryoscope: ";
cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl;
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer: ";
cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl;
cout << "Temperature: " << sensor->getTemperature() << endl;
cout << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

77
examples/c++/mpu60x0.cxx Normal file
View File

@ -0,0 +1,77 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "mpu9150.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
upm::MPU60X0 *sensor = new upm::MPU60X0();
sensor->init();
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer: ";
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
sensor->getGyroscope(&x, &y, &z);
cout << "Gryoscope: ";
cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl;
cout << "Temperature: " << sensor->getTemperature() << endl;
cout << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -1,6 +1,6 @@
/*
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 Intel Corporation.
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -24,36 +24,58 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "mpu9150.h"
int
main(int argc, char **argv)
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
//! [Interesting]
upm::Vector3D data;
upm::MPU9150 *sensor = new upm::MPU9150(0, ADDR);
sensor->getData ();
sensor->getAcceleromter (&data);
std::cout << "*************************************************" << std::endl;
std::cout << "DEVICE ID (" << (int) sensor->getDeviceID () << ")" << std::endl;
std::cout << "*************************************************" << std::endl;
std::cout << "ACCELEROMETER :: X (" << data.axisX << ")" << " Y (" << data.axisY << ")"
<< " Z (" << data.axisZ << ")" << std::endl;
sensor->getGyro (&data);
std::cout << "GYRO :: X (" << data.axisX << ")" << " Y (" << data.axisY << ")"
<< " Z (" << data.axisZ << ")" << std::endl;
sensor->getMagnometer (&data);
std::cout << "MAGNOMETER :: X (" << data.axisX << ")" << " Y (" << data.axisY << ")"
<< " Z (" << data.axisZ << ")" << std::endl;
std::cout << "TEMPERATURE (" << sensor->getTemperature () << ")" << std::endl;
std::cout << "*************************************************" << std::endl;
//! [Interesting]
std::cout << "exiting application" << std::endl;
delete sensor;
return 0;
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
upm::MPU9150 *sensor = new upm::MPU9150();
sensor->init();
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer: ";
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
sensor->getGyroscope(&x, &y, &z);
cout << "Gryoscope: ";
cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl;
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer: ";
cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl;
cout << "Temperature: " << sensor->getTemperature() << endl;
cout << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -0,0 +1,115 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include "pn532.h"
using namespace std;
// the URL we want to add as an NDEF record
// NOTE: this cannot exceed 34 characters.
static char url[] = "iotdk.intel.com";
int main(int argc, char **argv)
{
//! [Interesting]
// Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
// IRQ, and gpio 2 for the reset pin.
upm::PN532 *nfc = new upm::PN532(3, 2);
if (!nfc->init())
cerr << "init() failed" << endl;
uint32_t vers = nfc->getFirmwareVersion();
if (vers)
printf("Got firmware version: 0x%08x\n", vers);
else
{
printf("Could not identify PN532\n");
return 1;
}
// Now scan and identify any cards that come in range (1 for now)
// Retry forever
nfc->setPassiveActivationRetries(0xff);
nfc->SAMConfig();
uint8_t uidSize;
uint8_t uid[7];
bool foundCard = false;
while (!foundCard)
{
memset(uid, 0, 7);
if (nfc->readPassiveTargetID(nfc->BAUD_MIFARE_ISO14443A,
uid, &uidSize, 2000))
{
// found a card
printf("Found a card: UID len %d\n", uidSize);
printf("UID: ");
for (int i = 0; i < uidSize; i++)
printf("%02x ", uid[i]);
printf("\n");
printf("SAK: 0x%02x\n", nfc->getSAK());
printf("ATQA: 0x%04x\n\n", nfc->getATQA());
foundCard = true;
}
else
{
printf("Waiting for a card...\n");
}
}
if (uidSize != 7)
{
printf("This example will only write an NDEF URI to preformatted\n");
printf("Mifare Ultralight or NTAG2XX tags\n");
return 1;
}
// 48 bytes is maximum data area on ultralight cards, so we use that
// as the maximum datasize here. Obviously if you have a bigger
// card, you can write more data.
if (!nfc->ntag2xx_WriteNDEFURI(nfc->NDEF_URIPREFIX_HTTP, url, 48))
{
// failure
printf("Failed to write NDEF record tag.\n");
return 1;
}
printf("Success, URL record written to tag.\n");
//! [Interesting]
delete nfc;
return 0;
}

101
examples/c++/pn532.cxx Normal file
View File

@ -0,0 +1,101 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include "pn532.h"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
// IRQ, and gpio 2 for the reset pin.
upm::PN532 *nfc = new upm::PN532(3, 2);
if (!nfc->init())
cerr << "init() failed" << endl;
uint32_t vers = nfc->getFirmwareVersion();
if (vers)
printf("Got firmware version: 0x%08x\n", vers);
else
{
printf("Could not identify PN532\n");
return 1;
}
// Now scan and identify any cards that come in range (1 for now)
// Retry forever
nfc->setPassiveActivationRetries(0xff);
nfc->SAMConfig();
uint8_t uidSize;
uint8_t uid[7];
while (shouldRun)
{
memset(uid, 0, 7);
if (nfc->readPassiveTargetID(nfc->BAUD_MIFARE_ISO14443A,
uid, &uidSize, 2000))
{
// found a card
printf("Found a card: UID len %d\n", uidSize);
printf("UID: ");
for (int i = 0; i < uidSize; i++)
printf("%02x ", uid[i]);
printf("\n");
printf("SAK: 0x%02x\n", nfc->getSAK());
printf("ATQA: 0x%04x\n\n", nfc->getATQA());
sleep(1);
}
else
{
printf("Waiting for a card...\n");
}
}
//! [Interesting]
delete nfc;
return 0;
}

View File

@ -0,0 +1,110 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include "rgbringcoder.h"
#include <signal.h>
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// There are a lot of pins to hook up. These pins are valid for the
// Edison board, but may need to be adjusted for other platforms.
// In order:
// enable - 4
// latch - 10
// clear - 11
// clock - 2
// data - 9
// switch - 7
// red pwm - 3
// green pwm - 5
// blue pwm - 6
// encA - 12
// encB - 13
upm::RGBRingCoder *ringCoder =
new upm::RGBRingCoder(4, 10, 11, 2, 9, 7, 12, 13, 3, 5, 6);
uint16_t spin = 0x0001;
bool oldState = false;
int oldPos = 0;
// Lets go green
ringCoder->setRGBLED(0.99, 0.01, 0.99);
while (shouldRun)
{
// you spin me round...
if (spin == 0)
spin = 0x0001;
ringCoder->setRingLEDS(spin);
spin <<= 1;
// check button state
bool bstate = ringCoder->getButtonState();
if (bstate != oldState)
{
cout << "Button state changed from " << oldState << " to "
<< bstate << endl;
oldState = bstate;
}
// check encoder position
int epos = ringCoder->getEncoderPosition();
if (epos != oldPos)
{
cout << "Encoder position changed from " << oldPos << " to "
<< epos << endl;
oldPos = epos;
}
usleep(100000);
}
//! [Interesting]
delete ringCoder;
return 0;
}

View File

@ -0,0 +1,66 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include "sainsmartks.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// 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);
}
//! [Interesting]
delete lcd;
return 0;
}

View File

@ -0,0 +1,64 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var sensorObj = require('jsupm_mpu9150');
// Instantiate an AK8975 on default I2C bus and address
var sensor = new sensorObj.AK8975();
// Initialize the device with default values
sensor.init();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// Output data every half second until interrupted
setInterval(function()
{
sensor.update();
sensor.getMagnetometer(x, y, z);
console.log("Magnetometer: MX: " + sensorObj.floatp_value(x) +
" MY: " + sensorObj.floatp_value(y) +
" MZ: " + sensorObj.floatp_value(z));
console.log();
}, 500);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,51 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
function exit()
{
lcd = null;
lcdObj.cleanUp();
lcdObj = null;
process.exit(0);
}
// Load i2clcd module
var lcdObj = require('jsupm_i2clcd');
var lcd = new lcdObj.EBOLED();
lcd.clear();
lcd.setCursor(2, 0);
lcd.write("Hello");
lcd.setCursor(3, 5);
lcd.write("World!");
console.log("Sleeping for 5 seconds...");
setTimeout(exit, 5000);

View File

@ -0,0 +1,49 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jun Kato
* Contributions: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Instantiate a Grove Circular LED on gpio pins 5 and 4
var GCL = require("jsupm_grovecircularled");
var circle = new GCL.GroveCircularLED(5, 4);
var level = 0;
// Show a spinner.
var myInterval = setInterval(function()
{
circle.setSpinner(level);
level = (level + 1) % 24;
}, 100);
// When exiting, clear interval and print message.
process.on('SIGINT', function()
{
clearInterval(myInterval);
circle.setLevel(0);
circle = null;
GCL.cleanUp();
console.log("Exiting...");
process.exit(0);
});

View File

@ -0,0 +1,55 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var barometerObj = require('jsupm_hp20x');
// Instantiate an HP20X on default I2C bus and address
var bar = new barometerObj.HP20X();
// Initialize the device with default values
bar.init();
// Output data every second until interrupted
setInterval(function()
{
console.log("Temperature: " + bar.getTemperature() + " Celcius");
console.log("Pressure: " + bar.getPressure() + " Millibars");
console.log("Altitude: " + bar.getAltitude() + " Meters");
console.log("");
}, 1000);
// exit on ^C
process.on('SIGINT', function()
{
bar = null;
barometerObj.cleanUp();
barometerObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,77 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var sensorObj = require('jsupm_lsm9ds0');
// Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b,
// xm addr 1d)
var sensor = new sensorObj.LSM9DS0();
// Initialize the device with default values
sensor.init();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// Output data every half second until interrupted
setInterval(function()
{
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer: AX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getGyroscope(x, y, z);
console.log("Gyroscope: GX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getMagnetometer(x, y, z);
console.log("Magnetometer: MX: " + sensorObj.floatp_value(x) +
" MY: " + sensorObj.floatp_value(y) +
" MZ: " + sensorObj.floatp_value(z));
console.log("Temperature: " + sensor.getTemperature());
console.log();
}, 500);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,71 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var sensorObj = require('jsupm_mpu9150');
// Instantiate an MPU60X0 on default I2C bus and address
var sensor = new sensorObj.MPU60X0();
// Initialize the device with default values
sensor.init();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// Output data every half second until interrupted
setInterval(function()
{
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer: AX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getGyroscope(x, y, z);
console.log("Gyroscope: GX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
console.log("Temperature: " + sensor.getTemperature());
console.log();
}, 500);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,76 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var sensorObj = require('jsupm_mpu9150');
// Instantiate an MPU9105 on default I2C bus and address
var sensor = new sensorObj.MPU9150();
// Initialize the device with default values
sensor.init();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// Output data every half second until interrupted
setInterval(function()
{
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer: AX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getGyroscope(x, y, z);
console.log("Gyroscope: GX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getMagnetometer(x, y, z);
console.log("Magnetometer: MX: " + sensorObj.floatp_value(x) +
" MY: " + sensorObj.floatp_value(y) +
" MZ: " + sensorObj.floatp_value(z));
console.log("Temperature: " + sensor.getTemperature());
console.log();
}, 500);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,136 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Load PN532 module
var pn532 = require('jsupm_pn532');
// Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
// IRQ, and gpio 2 for the reset pin.
var myNFCObj = new pn532.PN532(3, 2);
function writeUrl()
{
if (uidSize.getitem(0) != 7)
{
console.log("This example will only write an NDEF URI to preformatted");
console.log("Mifare Ultralight or NTAG2XX tags");
exit();
}
// 48 bytes is maximum data area on ultralight cards, so we use that
// as the maximum datasize here. Obviously if you have a bigger
// card, you can write more data.
if (!myNFCObj.ntag2xx_WriteNDEFURI(pn532.PN532.NDEF_URIPREFIX_HTTP,
url, 48))
{
// failure
console.log("Failed to write NDEF record tag.");
exit(1);
}
console.log("Success, URL record written to tag.");
}
function toHex(d, pad)
{
// pad should be between 1 and 8
return ("00000000"+(Number(d).toString(16))).slice(-pad)
}
function exit()
{
clearInterval(myInterval);
myNFCObj = null;
pn532.cleanUp();
pn532 = null;
console.log("Exiting");
process.exit(0);
}
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
exit();
});
// "main"
if (!myNFCObj.init())
console.log("init() failed");
var vers = myNFCObj.getFirmwareVersion();
if (vers)
console.log("Got firmware version: " + toHex(vers, 8));
else
{
console.log("Could not identify PN532");
exit();
}
// Now scan and identify any cards that come in range (1 for now)
// Retry forever
myNFCObj.setPassiveActivationRetries(0xff);
myNFCObj.SAMConfig();
var uidSize = new pn532.uint8Array(0);
var uid = new pn532.uint8Array(7);
// the URL we want to add as an NDEF record
// NOTE: this cannot exceed 34 characters.
url = "iotdk.intel.com";
var myInterval = setInterval(function()
{
for (var x = 0; x < 7; x++)
uid.setitem(x, 0);
if (myNFCObj.readPassiveTargetID(pn532.PN532.BAUD_MIFARE_ISO14443A,
uid, uidSize, 2000))
{
// found a card
console.log("Found a card: UID len " + uidSize.getitem(0));
process.stdout.write("UID: ");
for (var i = 0; i < uidSize.getitem(0); i++)
{
var byteVal = uid.getitem(i);
process.stdout.write(toHex(byteVal, 2) + " ");
}
process.stdout.write("\n");
console.log("SAK: " + toHex(myNFCObj.getSAK(), 2));
console.log("ATQA: " + toHex(myNFCObj.getATQA(), 4));
console.log(" ");
// write the URL
writeUrl();
clearInterval(myInterval);
return;
}
else
console.log("Waiting for a card...");
}, 1000);

View File

@ -0,0 +1,102 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Load PN532 module
var pn532 = require('jsupm_pn532');
// Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
// IRQ, and gpio 2 for the reset pin.
var myNFCObj = new pn532.PN532(3, 2);
if (!myNFCObj.init())
console.log("init() failed");
var vers = myNFCObj.getFirmwareVersion();
if (vers)
console.log("Got firmware version: " + toHex(vers, 8));
else
{
console.log("Could not identify PN532");
exit();
}
// Now scan and identify any cards that come in range (1 for now)
// Retry forever
myNFCObj.setPassiveActivationRetries(0xff);
myNFCObj.SAMConfig();
var uidSize = new pn532.uint8Array(0);
var uid = new pn532.uint8Array(7);
var myInterval = setInterval(function()
{
for (var x = 0; x < 7; x++)
uid.setitem(x, 0);
if (myNFCObj.readPassiveTargetID(pn532.PN532.BAUD_MIFARE_ISO14443A,
uid, uidSize, 2000))
{
// found a card
console.log("Found a card: UID len " + uidSize.getitem(0));
process.stdout.write("UID: ");
for (var i = 0; i < uidSize.getitem(0); i++)
{
var byteVal = uid.getitem(i);
process.stdout.write(toHex(byteVal, 2) + " ");
}
process.stdout.write("\n");
console.log("SAK: " + toHex(myNFCObj.getSAK(), 2));
console.log("ATQA: " + toHex(myNFCObj.getATQA(), 4));
console.log(" ");
}
else
console.log("Waiting for a card...");
}, 1000);
function toHex(d, pad)
{
// pad should be between 1 and 8
return ("00000000"+(Number(d).toString(16))).slice(-pad)
}
function exit()
{
clearInterval(myInterval);
myNFCObj = null;
pn532.cleanUp();
pn532 = null;
console.log("Exiting");
process.exit(0);
}
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
exit();
});

View File

@ -0,0 +1,98 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var ringcoderObj = require('jsupm_rgbringcoder');
// There are a lot of pins to hook up. These pins are valid for the
// Edison board, but may need to be adjusted for other platforms.
// In order:
// enable - 4
// latch - 10
// clear - 11
// clock - 2
// data - 9
// switch - 7
// red pwm - 3
// green pwm - 5
// blue pwm - 6
// encA - 12
// encB - 13
var ringCoder = new ringcoderObj.RGBRingCoder(4, 10, 11, 2, 9, 7, 12, 13, 3,
5, 6);
var spin = 0x0001;
var oldState = false;
var oldPos = 0;
// Lets go green
ringCoder.setRGBLED(0.99, 0.01, 0.99);
setInterval(function()
{
// you spin me round...
if ((spin & 0xffff) == 0)
spin = 0x0001;
ringCoder.setRingLEDS(spin);
spin <<= 1;
// check button state
var bstate = ringCoder.getButtonState();
if (bstate != oldState)
{
console.log("Button state changed from " + oldState + " to "
+ bstate);
oldState = bstate;
}
// check encoder position
var epos = ringCoder.getEncoderPosition();
if (epos != oldPos)
{
console.log("Encoder position changed from " + oldPos + " to "
+ epos);
oldPos = epos;
}
}, 100);
// exit on ^C
process.on('SIGINT', function()
{
ringCoder = null;
ringcoderObj.cleanUp();
ringcoderObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,53 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var sainsmartObj = require('jsupm_i2clcd');
// Instantiate a Sainsmart LCD Keypad Shield using default pins
var lcd = new sainsmartObj.SAINSMARTKS();
lcd.setCursor(0,0);
lcd.write("Sainsmart KS");
lcd.setCursor(1,2);
lcd.write("Hello World");
// output current key value every second.
setInterval(function()
{
console.log("Button value: " + lcd.getRawKeyValue());
}, 1000);
// exit on ^C
process.on('SIGINT', function()
{
lcd = null;
sainsmartObj.cleanUp();
sainsmartObj = null;
console.log("Exiting.");
process.exit(0);
});

59
examples/python/ak8975.py Normal file
View File

@ -0,0 +1,59 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_mpu9150 as sensorObj
# Instantiate an AK8975 on I2C bus 0
sensor = sensorObj.AK8975()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
sensor.init()
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
while (1):
sensor.update()
sensor.getMagnetometer(x, y, z)
print "Magnetometer: MX: ", sensorObj.floatp_value(x),
print " MY: ", sensorObj.floatp_value(y),
print " MZ: ", sensorObj.floatp_value(z)
print
time.sleep(.5)

40
examples/python/eboled.py Normal file
View File

@ -0,0 +1,40 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys
import pyupm_i2clcd as lcdObj
# setup with default values
lcd = lcdObj.EBOLED();
lcd.clear();
lcd.setCursor(2, 0);
lcd.write("Hello");
lcd.setCursor(3, 5);
lcd.write("World!");
print "Sleeping for 5 seconds..."
time.sleep(5)

View File

@ -0,0 +1,50 @@
#!/usr/bin/python
#
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_grovecircularled as upmGroveCircularLED
# Exit handlers
def SIGINTHandler(signum, frame):
raise SystemExit
def exitHandler():
circle.setLevel(0, True)
print "Exiting"
sys.exit(0)
# This function lets you run code on exit
atexit.register(exitHandler)
# This function stops python from printing a stacktrace when you hit control-C
signal.signal(signal.SIGINT, SIGINTHandler)
# Instantiate a Grove Circular LED on gpio pins 5 and 4
circle = upmGroveCircularLED.GroveCircularLED(5, 4)
level = 0
while(1):
circle.setSpinner(level)
level = (level + 1) % 24
time.sleep(.1)

54
examples/python/hp20x.py Normal file
View File

@ -0,0 +1,54 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_hp20x as barometerObj
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit,
# including functions from ringCoder
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
# Instantiate an HP20X on default I2C bus and address
bar = barometerObj.HP20X()
# Initialize the device with default values
bar.init()
while(1):
print "Temperature:", bar.getTemperature(), "Celcius"
print "Pressure: ", bar.getPressure(), "Millibars"
print "Altitude: ", bar.getAltitude(), "Meters"
print
time.sleep(1)

View File

@ -0,0 +1,71 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_lsm9ds0 as sensorObj
# Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b,
# xm addr 1d)
sensor = sensorObj.LSM9DS0()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
sensor.init()
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer: AX: ", sensorObj.floatp_value(x),
print " AY: ", sensorObj.floatp_value(y),
print " AZ: ", sensorObj.floatp_value(z)
sensor.getGyroscope(x, y, z)
print "Gyroscope: GX: ", sensorObj.floatp_value(x),
print " GY: ", sensorObj.floatp_value(y),
print " GZ: ", sensorObj.floatp_value(z)
sensor.getMagnetometer(x, y, z)
print "Magnetometer: MX: ", sensorObj.floatp_value(x),
print " MY: ", sensorObj.floatp_value(y),
print " MZ: ", sensorObj.floatp_value(z)
print "Temperature: ", sensor.getTemperature()
print
time.sleep(.5)

View File

@ -0,0 +1,65 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_mpu9150 as sensorObj
# Instantiate an MPU60X0 on I2C bus 0
sensor = sensorObj.MPU60X0()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
sensor.init()
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer: AX: ", sensorObj.floatp_value(x),
print " AY: ", sensorObj.floatp_value(y),
print " AZ: ", sensorObj.floatp_value(z)
sensor.getGyroscope(x, y, z)
print "Gyroscope: GX: ", sensorObj.floatp_value(x),
print " GY: ", sensorObj.floatp_value(y),
print " GZ: ", sensorObj.floatp_value(z)
print "Temperature: ", sensor.getTemperature()
print
time.sleep(.5)

View File

@ -0,0 +1,70 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_mpu9150 as sensorObj
# Instantiate an MPU9150 on I2C bus 0
sensor = sensorObj.MPU9150()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
sensor.init()
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer: AX: ", sensorObj.floatp_value(x),
print " AY: ", sensorObj.floatp_value(y),
print " AZ: ", sensorObj.floatp_value(z)
sensor.getGyroscope(x, y, z)
print "Gyroscope: GX: ", sensorObj.floatp_value(x),
print " GY: ", sensorObj.floatp_value(y),
print " GZ: ", sensorObj.floatp_value(z)
sensor.getMagnetometer(x, y, z)
print "Magnetometer: MX: ", sensorObj.floatp_value(x),
print " MY: ", sensorObj.floatp_value(y),
print " MZ: ", sensorObj.floatp_value(z)
print "Temperature: ", sensor.getTemperature()
print
time.sleep(.5)

View File

@ -0,0 +1,105 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_pn532 as upmPn532
# Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
# IRQ, and gpio 2 for the reset pin.
myNFC = upmPn532.PN532(3, 2)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
if (not myNFC.init()):
print "init() failed"
sys.exit(0)
vers = myNFC.getFirmwareVersion()
if (vers):
print "Got firmware version: %08x" % vers
else:
print "Could not identify PN532"
sys.exit(0)
# Now scan and identify any cards that come in range (1 for now)
# Retry forever
myNFC.setPassiveActivationRetries(0xff)
myNFC.SAMConfig()
uidSize = upmPn532.uint8Array(0)
uid = upmPn532.uint8Array(7)
# the URL we want to add as an NDEF record
# NOTE: this cannot exceed 34 characters.
url = "iotdk.intel.com"
foundCard = False
while (not foundCard):
for i in range(7):
uid.__setitem__(i, 0)
if (myNFC.readPassiveTargetID(upmPn532.PN532.BAUD_MIFARE_ISO14443A,
uid, uidSize, 2000)):
# found a card
print "Found a card: UID len", uidSize.__getitem__(0)
print "UID: ",
for i in range(uidSize.__getitem__(0)):
print "%02x" % uid.__getitem__(i),
print
print "SAK: %02x" % myNFC.getSAK()
print "ATQA: %04x" % myNFC.getATQA()
print
foundCard = True
else:
print "Waiting for a card...\n"
if (uidSize.__getitem__(0) != 7):
print "This example will only write an NDEF URI to preformatted"
print "Mifare Ultralight or NTAG2XX tags"
sys.exit(1)
# 48 bytes is maximum data area on ultralight cards, so we use that
# as the maximum datasize here. Obviously if you have a bigger
# card, you can write more data.
if (not myNFC.ntag2xx_WriteNDEFURI(upmPn532.PN532.NDEF_URIPREFIX_HTTP, url, 48)):
# failure
print "Failed to write NDEF record tag."
sys.exit(1)
print "Success, URL record written to tag."

85
examples/python/pn532.py Normal file
View File

@ -0,0 +1,85 @@
#!/usr/bin/python
# Author: Zion Orent <zorent@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_pn532 as upmPn532
# Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
# IRQ, and gpio 2 for the reset pin.
myNFC = upmPn532.PN532(3, 2)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
if (not myNFC.init()):
print "init() failed"
sys.exit(0)
vers = myNFC.getFirmwareVersion()
if (vers):
print "Got firmware version: %08x" % vers
else:
print "Could not identify PN532"
sys.exit(0)
# Now scan and identify any cards that come in range (1 for now)
# Retry forever
myNFC.setPassiveActivationRetries(0xff)
myNFC.SAMConfig()
uidSize = upmPn532.uint8Array(0)
uid = upmPn532.uint8Array(7)
while (1):
for i in range(7):
uid.__setitem__(i, 0)
if (myNFC.readPassiveTargetID(upmPn532.PN532.BAUD_MIFARE_ISO14443A,
uid, uidSize, 2000)):
# found a card
print "Found a card: UID len", uidSize.__getitem__(0)
print "UID: ",
for i in range(uidSize.__getitem__(0)):
print "%02x" % uid.__getitem__(i),
print
print "SAK: %02x" % myNFC.getSAK()
print "ATQA: %04x" % myNFC.getATQA()
print
time.sleep(1)
else:
print "Waiting for a card...\n"

View File

@ -0,0 +1,90 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_rgbringcoder as upmRGBRingCoder
# There are a lot of pins to hook up. These pins are valid for the
# Edison board, but may need to be adjusted for other platforms.
# In order:
# enable - 4
# latch - 10
# clear - 11
# clock - 2
# data - 9
# switch - 7
# red pwm - 3
# green pwm - 5
# blue pwm - 6
# encA - 12
# encB - 13
ringCoder = upmRGBRingCoder.RGBRingCoder(4, 10, 11, 2, 9, 7, 12, 13, 3,
5, 6)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit,
# including functions from ringCoder
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
spin = 0x0001;
oldState = False;
oldPos = 0;
# Lets go green
ringCoder.setRGBLED(0.99, 0.01, 0.99);
while(1):
# you spin me round...
if ((spin & 0xffff) == 0):
spin = 0x0001
ringCoder.setRingLEDS(spin)
spin <<= 1
# check button state
bstate = ringCoder.getButtonState()
if (bstate != oldState):
print "Button state changed from", oldState, " to ", bstate
oldState = bstate
# check encoder position
epos = ringCoder.getEncoderPosition()
if (epos != oldPos):
print "Encoder position changed from", oldPos, "to", epos
oldPos = epos
time.sleep(0.1)

View File

@ -0,0 +1,54 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_i2clcd as sainsmartObj
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit,
# including functions from ringCoder
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
# Instantiate a Sainsmart LCD Keypad Shield using default pins
lcd = sainsmartObj.SAINSMARTKS()
lcd.setCursor(0,0)
lcd.write("Sainsmart KS")
lcd.setCursor(1,2)
lcd.write("Hello World")
# output current key value every second.
while(1):
print "Button value: ", lcd.getRawKeyValue()
time.sleep(1)

View File

@ -55,12 +55,15 @@ endmacro()
macro(upm_doxygen)
if (DOXYGEN_FOUND)
if(NOT DEFINED classname)
set (classname ${libname})
endif()
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../doxy2swig.py -n
${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
${CMAKE_BINARY_DIR}/xml/${classname}_8h.xml
${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
DEPENDS ${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
DEPENDS ${CMAKE_BINARY_DIR}/xml/${classname}_8h.xml
)
add_custom_target (${libname}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i)
add_dependencies (${libname}doc_i doc)

View File

@ -30,19 +30,20 @@ namespace upm {
/**
* @brief A110X Hall Effect library
* @defgroup a110x libupm-a110x
* @ingroup seeed gpio electric
* @ingroup seeed gpio electric robok
*/
/**
* @library a110x
* @sensor a110x
* @comname A110X Hall Effect Sensor
* @altname A1101, A1102, A1103, A1004, A1106
* @altname Grove Hall Sensor
* @altid A1101, A1102, A1103, A1004, A1106
* @type electric
* @man seeed
* @web http://www.allegromicro.com/en/Products/Magnetic-Digital-Position-Sensor-ICs/Hall-Effect-Unipolar-Switches/A1101-2-3-4-6.aspx
* @con gpio
* @kit robok
*
* @brief API for the A110X Hall Effect sensors
*
@ -62,32 +63,32 @@ namespace upm {
/**
* A110x digital sensor constructor
*
* @param pin digital pin to use
* @param pin Digital pin to use
*/
A110X(int pin);
/**
* A110X Destructor
* A110X destructor
*/
~A110X();
/**
* Determine whether a magnetic field of south polarity has been detected
* Determines whether a magnetic field of south polarity has been detected
*
* @return True if magnetic field detected
*/
bool magnetDetected();
/**
* Install an Interrupt Service Routine (ISR) to be called when
* the appropriate magnetic field is detected.
* Installs an interrupt service routine (ISR) to be called when
* the appropriate magnetic field is detected
*
* @param fptr function pointer to function to be called on interrupt
* @param arg pointer to an object that will be supplied as an
* arguement to the ISR.
* @param fptr Pointer to a function to be called on interrupt
* @param arg Pointer to an object to be supplied as an
* argument to the ISR.
*/
void installISR(void (*isr)(void *), void *arg);
/**
* Uninstall the previously installed Interrupt Service Routine (ISR)
* Uninstalls the previously installed ISR
*
*/
void uninstallISR();

View File

@ -34,7 +34,7 @@
namespace upm {
/**
* @brief AD8232 heart rate monitor library
* @brief AD8232 Heart Rate Monitor library
* @defgroup ad8232 libupm-ad8232
* @ingroup sparkfun gpio medical
*/
@ -50,17 +50,17 @@ namespace upm {
*
* @brief UPM module for the AD8232 Heart Rate Monitor
*
* Note, this sensor must be driven at 3.3v only.
* Note: this sensor must be driven at 3.3V only.
*
* This module will simply spit out the ADC values reported by the
* sensor, with the intent being to send that data somewhere (via
* serial or network port) to another piece of software running on a
* computer that will plot the data for you, like an EKG.
* This module simply spits out the ADC values reported by the sensor, with
* the intent to send that data, via serial or network port, somewhere to
* another piece of software running on a computer that plots the data for
* you, like an EKG.
*
* Processing (https://www.processing.org/), is a piece of software
* that should work, using information from the Sparkfun website.
* Processing (https://www.processing.org/) is software
* that should work, using information from the SparkFun* website.
*
* This example just dumps the raw data.
* This example just dumps the raw data:
*
* @image html ad8232.jpg
* <br><em>AD8232 Heart Rate Monitor image provided by SparkFun under
@ -76,20 +76,20 @@ namespace upm {
/**
* AD8232 constructor
*
* @param loPlus digital pin to use for LO+
* @param loMinus digital pin to use LO-
* @param output analog pin to use for reading the data
* @param loPlus Digital pin to use for LO+
* @param loMinus Digital pin to use for LO-
* @param output Analog pin to read the data
*/
AD8232(int loPlus, int loMinus, int output, float aref=AD8232_DEFAULT_AREF);
/**
* AD8232 Destructor
* AD8232 destructor
*/
~AD8232();
/**
* return the current ADC value for the device output pin. If an
* LO (Leads Off) event is detected, 0 will be returned.
* Returns the current ADC value for the device output pin. If an
* LO (leads off) event is detected, 0 is returned.
*
* @return ADC value
*/

View File

@ -52,16 +52,16 @@ namespace upm {
* @web http://www.adafruit.com/products/1438
* @con i2c
*
* @brief API for the ADAFRUITMS1438 motor shield
* @brief API for the AdafruitMS1438 Motor Shield
*
* This class implements support for the stepper and DC motors that
* can be connected to this Motor Shield.
* NOTE: The two servo connections are not actually controlled by
* the pca9685 controller (or this class), rather they are connected
* directly to digital PWM pins 9 and 10 on the arduino breakout.
* Note: the two servo connections are not controlled by the PCA9685
* controller (or this class). They are connected directly to digital
* PWM pins 9 and 10 on the Arduino* breakout board.
*
* @image html adafruitms1438.jpg
* An example using a DC motor conected to M3
* An example using a DC motor connected to M3
* @snippet adafruitms1438.cxx Interesting
* An example using a stepper motor connected to M1 & M2
* @snippet adafruitms1438-stepper.cxx Interesting
@ -89,7 +89,7 @@ namespace upm {
} DCMOTORS_T;
/**
* Enum to specify a Stepper motor
* Enum to specify a stepper motor
*/
typedef enum {
STEPMOTOR_M12 = 0,
@ -99,62 +99,62 @@ namespace upm {
/**
* AdafruitMS1438 constructor
*
* @param bus i2c bus to use
* @param address the address for this sensor
* @param bus I2C bus to use
* @param address Address for this sensor
*/
AdafruitMS1438(int bus, uint8_t address = ADAFRUITMS1438_DEFAULT_I2C_ADDR);
/**
* AdafruitMS1438 Destructor
* AdafruitMS1438 destructor
*/
~AdafruitMS1438();
/**
* Return the number of milliseconds elapsed since initClock(...)
* Returns the number of milliseconds elapsed since initClock(...)
* was last called.
*
* @return elapsed milliseconds
* @return Elapsed milliseconds
*/
uint32_t getMillis(STEPMOTORS_T motor);
/**
* Reset the Clock
* Resets the clock
*
*/
void initClock(STEPMOTORS_T motor);
/**
* Set the PWM period. Note this applies to all PWM channels.
* Sets the PWM period. Note: this applies to all PWM channels.
*
* @param hz set the PWM period
* @param hz Sets the PWM period
*/
void setPWMPeriod(float hz);
/**
* enable PWM output for a motor
* Enables PWM output for a motor
*
* @param motor the DC motor to enable
* @param motor DC motor to enable
*/
void enableMotor(DCMOTORS_T motor);
/**
* disable PWM output for a motor
* Disables PWM output for a motor
*
* @param motor the DC motor to disable
* @param motor DC motor to disable
*/
void disableMotor(DCMOTORS_T motor);
/**
* enable output for a stepper motor
* Enables output for a stepper motor
*
* @param motor the stepper motor to enable
* @param motor Stepper motor to enable
*/
void enableStepper(STEPMOTORS_T motor);
/**
* disable output for a stepper motor
* Disable output for a stepper motor
*
* @param motor the stepper motor to disable
* @param motor Stepper motor to disable
*/
void disableStepper(STEPMOTORS_T motor);
@ -168,57 +168,57 @@ namespace upm {
void setMotorSpeed(DCMOTORS_T motor, int speed);
/**
* set the speed of a stepper in revolution per minute (RPM)
* Sets the speed of a stepper in revolutions per minute (RPM)
*
* @param motor the DC motor to configure
* @param speed speed to set the motor to
* @param motor DC motor to configure
* @param speed Speed to set the motor to
*/
void setStepperSpeed(STEPMOTORS_T motor, int speed);
/**
* set the direction of a DC motor, clockwise or counter clockwise
* Sets the direction of a DC motor, clockwise or counterclockwise
*
* @param motor the DC motor to configure
* @param dir direction to set the motor to
* @param motor DC motor to configure
* @param dir Direction to set the motor in
*/
void setMotorDirection(DCMOTORS_T motor, DIRECTION_T dir);
/**
* set the direction of a stepper motor, clockwise or counter clockwise
* Sets the direction of a stepper motor, clockwise or counterclockwise
*
* @param motor the stepper motor to configure
* @param dir direction to set the motor to
* @param motor Stepper motor to configure
* @param dir Direction to set the motor in
*/
void setStepperDirection(STEPMOTORS_T motor, DIRECTION_T dir);
/**
* set a stepper motor configuration
* Sets a stepper motor configuration
*
* @param motor the stepper motor to configure
* @param stepsPerRev the number of step to complete a full revolution
* @param motor Stepper motor to configure
* @param stepsPerRev Number of steps to complete a full revolution
*/
void stepConfig(STEPMOTORS_T motor, unsigned int stepsPerRev);
/**
* step a stepper motor a specified number of steps
* Steps a stepper motor a specified number of steps
*
* @param motor the stepper motor to step
* @param steps number of steps to move the stepper motor
* @param motor Stepper motor to step
* @param steps Number of steps to move the stepper motor
*/
void stepperSteps(STEPMOTORS_T motor, unsigned int steps);
private:
// SWIG will generate warning for these 'nested structs', however
// those can be ignored as these structs are never exposed.
// SWIG will generate a warning for these 'nested structs'; however,
// it can be ignored as these structs are never exposed.
// struct to hold mappings of the dc motors
// struct to hold mappings of DC motors
typedef struct {
int pwm;
int in1;
int in2;
} DC_PINMAP_T;
// struct to hold mappings of the stepper motors
// struct to hold mappings of stepper motors
typedef struct {
int pwmA;
int in1A;
@ -228,7 +228,7 @@ namespace upm {
int in2B;
} STEPPER_PINMAP_T;
// struct to hold some information about each stepper
// struct to hold information about each stepper
typedef struct {
int stepsPerRev; // steps per revolution
int currentStep; // current step number

View File

@ -30,75 +30,69 @@ using namespace upm;
adafruitss::adafruitss(int bus,int i2c_address)
{
int n;
int result;
mraa_init();
m_i2c = mraa_i2c_init(bus);
pca9685_addr = i2c_address;
result=mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_address(m_i2c, pca9685_addr);
m_rx_tx_buf[0]=PCA9685_MODE1;
m_rx_tx_buf[1]=0;
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
adafruitss::setPWMFreq(60);
adafruitss::update();
}
void adafruitss::setPWMFreq(float freq) {
int result;
freq *= 0.88; // Correct for overshoot in the frequency setting (see issue #11).
float afreq= freq * 0.899683334F; // Correct for overshoot in the frequency setting (see issue #11). (Tested at 60hz with Logic 4 for 50hz and 60hz)
float prescaleval = 25000000;
prescaleval /= 4096;
prescaleval /= freq;
prescaleval /= afreq;
prescaleval -= 1;
_pwm_frequency = 60.18; // FInal achieved frequency measured with Logic 8!
float pwm_frequency = freq; // Use actual requested frequency gives the correct pulse width
_duration_1ms = ((4096*_pwm_frequency)/1000); // This is 1ms duration
_duration_1ms = ((4096*pwm_frequency)/1000); // This is 1ms duration
uint8_t prescale = floor(prescaleval + 0.5);
uint8_t prescale = roundf(prescaleval);
result=mraa_i2c_address(m_i2c, pca9685_addr);
uint8_t oldmode=0;
oldmode = mraa_i2c_read_byte_data(m_i2c,PCA9685_MODE1);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_read_byte_data(m_i2c,PCA9685_MODE1);
m_rx_tx_buf[0]=PCA9685_MODE1;
m_rx_tx_buf[1]=0x10; // sleep
result=mraa_i2c_address(m_i2c, pca9685_addr);
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
m_rx_tx_buf[0]=PCA9685_PRESCALE;
m_rx_tx_buf[1]=prescale;
result=mraa_i2c_address(m_i2c, pca9685_addr);
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
m_rx_tx_buf[0]=PCA9685_MODE1;
m_rx_tx_buf[1]=0x00;
result=mraa_i2c_address(m_i2c, pca9685_addr);
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
// result=mraa_i2c_write_byte_data(m_i2c,0x00,PCA9685_MODE1);
// mraa_i2c_write_byte_data(m_i2c,0x00,PCA9685_MODE1);
usleep(5000);
m_rx_tx_buf[0]=PCA9685_MODE1;
m_rx_tx_buf[1]=0xa1;
result=mraa_i2c_address(m_i2c, pca9685_addr);
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
}
int adafruitss::update(void)
@ -106,21 +100,19 @@ int adafruitss::update(void)
return MRAA_SUCCESS;
}
void adafruitss::servo(uint8_t port, uint8_t servo_type, uint16_t degrees) {
void adafruitss::servo(uint8_t port, uint8_t servo_type, float degrees) {
// Set Servo values
// Degrees is from 0 to 180
// servo_type: 0 = standard 1ms to 2ms
// 1 = extended 0.6ms to 2.4ms
// 2 = extended 0.8ms to 2.2ms
uint16_t duration = 0;
int result;
int r2;
float duration;
if(degrees>180) degrees=180; // Ensure within bounds
if (degrees<0) degrees=0;
switch (servo_type) {
default:
case 0: // Standard Servo 1ms to 2ms
duration = _duration_1ms + ((_duration_1ms*degrees)/180);
break;
@ -135,18 +127,19 @@ void adafruitss::servo(uint8_t port, uint8_t servo_type, uint16_t degrees) {
duration = (_duration_1ms*0.8) + ((_duration_1ms*degrees)/128);
break;
case 3: // Extended Servo 0.9ms to 2.1ms, - GWS Mini STD BB servo
//duration = (_duration_1ms*0.8) + ((_duration_1ms*1.4*degrees)/180); simplified to..
//duration = (_duration_1ms*0.9) + ((_duration_1ms*1.4*degrees)/180); simplified to..
duration = (_duration_1ms*0.9) + ((_duration_1ms*degrees)/120);
break;
}
result=mraa_i2c_address(m_i2c, pca9685_addr);
uint16_t d= roundf(duration);
mraa_i2c_address(m_i2c, pca9685_addr);
m_rx_tx_buf[0]=LED0_REG+4*port;
m_rx_tx_buf[1]=0;
m_rx_tx_buf[2]=0;
m_rx_tx_buf[3]=duration;
m_rx_tx_buf[4]=duration>>8;
m_rx_tx_buf[3]=d;
m_rx_tx_buf[4]=d>>8;
mraa_i2c_write(m_i2c,m_rx_tx_buf,5);
}
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,5);
r2=result;
}

View File

@ -52,15 +52,14 @@
#define PCA9685_PRESCALE_REG 0xFE
#define LED0_REG 0x06
namespace upm {
/**
* @brief Adafruit PCA9685 based servo controller library
* @brief Adafruit PCA9685-based Servo Shield library
* @defgroup adafruitss libupm-adafruitss
* @ingroup adafruit i2c servos
*/
/**
* @library adafruitss
* @sensor adafruitss
@ -70,47 +69,48 @@ namespace upm {
* @web http://www.adafruit.com/product/1411
* @con i2c
*
* @brief API for Adafruit Servo Shield
* @brief API for the Adafruit Servo Shield
*
* UPM library for the PCA9685 based Adafruit 16-channel servo shield. When 3
* or more GWS servos attached results unpredictable. Adafruit do recommend a
* capacitor be installed on the board which should alleviate the issue.
* Sizing depends on servos and count.
* UPM library for the PCA9685-based Adafruit 16-channel servo shield. If 3
* or more GWS servos are attached, results could be unpredictable. Adafruit
* Industries recommend installing a capacitor on the board, which should
* alleviate the issue. Sizing depends on servos and their number.
*
* @image html adafruitss.jpg
* @image html adafruitss.jpg
* @snippet adafruitss.cxx Interesting
*/
class adafruitss {
public:
/**
* Creates a adafruitss object
* Creates an adafruitss object
*
* @param bus number of used i2c bus
* @param i2c_address address of servo controller on i2c bus
* @param bus Number of the used I2C bus
* @param i2c_address Address of the servo shield on the I2C bus
*/
adafruitss(int bus, int i2c_address);
int update(void);
/**
* Sets the frequency for your servos
* Sets the frequency of the servos
*
* @param freq the frequency at which the servos operate
* @param freq Frequency at which the servos operate
*/
void setPWMFreq(float freq);
/**
* Moves the one of the servos to the specified angle
* Moves one of the servos to a specified angle
*
* @param port port of the servo on the controller (servo number)
* @param servo_type can be 0 = standard 1ms to 2ms, 1 = extended 0.6ms to 2.4ms, or 2 = extended 0.8ms to 2.2ms
* @param degrees angle to set the servo to
* @param port Port of the servo on the shield (servo number)
* @param servo_type Can be 0 = standard (1ms to 2ms), 1 = extended
* (0.6ms to 2.4ms), or 2 = extended (0.8ms to 2.2ms)
* @param degrees Angle to set the servo to
*/
void servo(uint8_t port, uint8_t servo_type, uint16_t degrees);
void servo(uint8_t port, uint8_t servo_type, float degrees);
private:
int pca9685_addr;
mraa_i2c_context m_i2c;
uint8_t m_rx_tx_buf[MAX_BUFFER_LENGTH];
float _pwm_frequency;
float _duration_1ms;
};

View File

@ -49,14 +49,14 @@
namespace upm {
/**
* @brief ADC121C021 I2C analog digital converter library
* @brief ADC121C021 I2C Analog-to-Digital Converter library
* @defgroup adc121c021 libupm-adc121c021
* @ingroup seeed i2c electric
*/
/**
* valid cycle times for automatic conversion mode
* Valid cycle times for the automatic conversion mode
*/
typedef enum { ADC121C021_CYCLE_NONE = 0, // disabled
@ -72,18 +72,18 @@ namespace upm {
/**
* @library adc121c021
* @sensor adc121c021
* @comname ADC121C021 Analog Digital Converter
* @comname ADC121C021 Analog-to-Digital Converter
* @altname Grove I2C ADC
* @type electric
* @man seeed
* @web http://www.seeedstudio.com/depot/Grove-I2C-ADC-p-1580.html
* @con i2c
*
* @brief API for the ADC121C021 I2C ADC
* @brief API for the ADC121C021 I2C Analog-to-Digital Converter
*
* UPM module for the ADC121C021 12 bit Analog to Digital (ADC) converter.
* By providing a constant reference voltage, this sensor helps
* to increase the accuracy of a value collected from an analog sensor.
* UPM module for the ADC121C021 12-bit analog-to-digital converter (ADC).
* By constantly providing a reference voltage, this sensor helps
* increase the accuracy of a value collected from an analog sensor.
*
* @image html adc121c021.jpg
* @snippet adc121c021.cxx Interesting
@ -91,208 +91,212 @@ namespace upm {
class ADC121C021 {
public:
/**
* adc121c021 ADC constructor
* ADC121C021 ADC constructor
*
* @param bus i2c bus to use
* @param address the address for this sensor; default is 0x55
* @param vref reference voltage for this sensor; default is 3.0
* @param bus I2C bus to use
* @param address Address for this sensor; default is 0x55
* @param vref Reference voltage for this sensor; default is 3.0v
*/
ADC121C021(int bus, uint8_t address = ADC121C021_DEFAULT_I2C_ADDR,
float vref = ADC121C021_DEFAULT_VREF);
/**
* ADC121C021 Destructor
* ADC121C021 destructor
*/
~ADC121C021();
/**
* Write byte value into register
* Writes a byte value into the register
*
* @param reg register location to write into
* @param byte byte to write
* @param reg Register location to write into
* @param byte Byte to write
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t writeByte(uint8_t reg, uint8_t byte);
/**
* Write word value into register
* Writes a word value into the register
*
* @param reg register location to write into
* @param word word to write
* @param reg Register location to write into
* @param word Word to write
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t writeWord(uint8_t reg, uint16_t word);
/**
* Read byte value from register
* Reads the byte value from the register
*
* @param reg register location to read from
* @return value at specified register
* @param reg Register location to read from
* @return Value in the specified register
*/
uint8_t readByte(uint8_t reg);
/**
* Read word value from register
* Reads the word value from the register
*
* @param reg register location to read from
* @return value at specified register
* @param reg Register location to read from
* @return Value in the specified register
*/
uint16_t readWord(uint8_t reg);
/**
* Read current value of conversion
* Reads the current value of conversion
*
* @return current conversion value
* @return Current value of conversion
*/
uint16_t value();
/**
* Convert a supplied value to voltage based on set VREF
* Converts a supplied value to voltage based on the set vref
*
* @param val value of conversion (from value())
* @return conversion value in volts
* @param val Value of conversion (from value())
* @return Value of conversion in volts
*/
float valueToVolts(uint16_t val);
/**
* Read current status of the alert flag. If the flag is set, the
* lower or upper alert indicators will be set as appropriate, and
* Reads the current status of the alert flag. If the flag is set, the
* low or high alert indicators are set as appropriate, and
* you can access these values with alertLowTriggered() or
* alertHighTriggered().
*
* @return true if the alert flag is set
* @return True if the alert flag is set
*/
bool getAlertStatus();
/**
* Return the current value of m_alertLow. You must call
* Returns the current value of m_alertLow. You must call
* getAlertStatus() to update this value.
*
* @return current alert low status
* @return Current status of the alert low flag
*/
bool alertLowTriggered() { return m_alertLow; };
/**
* Return the current value of m_alertHigh. You must call
* Returns the current value of m_alertHigh. You must call
* getAlertStatus() to update this value.
*
* @return current alert high status
* @return Current status of the alert high flag
*/
bool alertHighTriggered() { return m_alertHigh; };
/**
* Clear the alert low and high flags. This will also clear the
* Clears the alert low and alert high flags. This also clears the
* last stored alert values.
*/
void clearAlertStatus();
/**
* Enable or disable the Alert Flag functionality. If enabled,
* then when the measured value exceeds the low or high limits
* configured, the alert flag will be set. Use getAlertStatus()
* Enables or disables the alert flag functionality. If enabled,
* when the measured value exceeds the low or high limits
* configured, the alert flag is set. Use getAlertStatus()
* to access these values.
*
* @param enable if true, enables Alert Flag; otherwise, disables Alert Flag
* @param enable If true, enables the alert flag; otherwise, disables the
* alert flag
*/
void enableAlertFlag(bool enable);
/**
* Enable or disable the Alert Pin functionality.
* Enables or disables the alert pin functionality.
*
* @param enable if true, enables Alert Pin; otherwise, disables Alert Pin
* @param enable If true, enables the alert pin; otherwise, disables the
* alert pin
*/
void enableAlertPin(bool enable);
/**
* Enable or disable the Alert Hold functionality. When Alert
* Hold is enabled, the alert status remains until manually
* cleared via clearAlertStatus(). Otherwise, the alert will self
* clear when the value moves into the defined limits if alerts
* Enables or disables the alert hold functionality. When the alert
* hold is enabled, the alert status remains until manually
* cleared via clearAlertStatus(). Otherwise, the alert self-clears
* when the value moves into the defined limits if alerts
* are enabled via enableAlertFlag().
*
* @param enable if true, enables Alert Hold; otherwise, disables Alert Hold
* @param enable If true, enables the alert hold; otherwise, disables the
* alert hold
*/
void enableAlertHold(bool enable);
/**
* If the Alert Pin fnctionality is enabled, define the active
* polarity of the pin in an alert condition. Enabling this sets
* the pin to active high in an alert condition, otherwise an
* If the alert pin is enabled, defines the active
* polarity of the pin in an alert condition. Enabling this sets
* the pin to active high in an alert condition; otherwise,
* active low is used.
*
* @param enable if true, Alert Pin is active high, else active low
* @param enable If true, the alert pin is active high; otherwise, active
* low
*/
void enableAlertPinPolarityHigh(bool enable);
/**
* Enable or disable Automatic Conversion mode. When enabled, the
* ADC will sample and update the conversion value independently.
* This is disabled by default, and a conversion is only done by
* Enables or disables the automatic conversion mode. When enabled, the
* ADC samples and updates the conversion value independently.
* It is disabled by default, so conversion is only done by
* calling value().
*
* @param cycleTime set the Cycle Time for automatic conversion
* @param cycleTime Sets the cycle time for automatic conversion
*/
void setAutomaticConversion(ADC121C021_CYCLE_TIME_T cycleTime);
/**
* Set the Alert Low Limit. If Alerts are enabled and the
* measured conversion value is lower than this, an alert will be
* Sets the alert low limit. If alerts are enabled and the
* measured conversion value is lower than the low limit, an alert is
* triggered.
*
* @param limit the Low Alert Limit
* @param limit Alert low limit
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t setAlertLowLimit(uint16_t limit);
/**
* Set the Alert High Limit. If Alerts are enabled and the
* measured conversion value is higher than this, an alert will be
* Sets the alert high limit. If alerts are enabled and the
* measured conversion value is higher than the high limit, an alert is
* triggered.
*
* @param limit the High Alert Limit
* @param limit Alert high limit
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t setAlertHighLimit(uint16_t limit);
/**
* Set the Hysteresis value. If a high or low alert condition is
* Sets the hysteresis value. If a high or low alert condition is
* triggered, the conversion result must move within the high or
* low limit by more than this value to clear the alert condition.
* If the Alert Hold bit is set, then the alert will not self
* clear regardless of this value.
* If the alert hold is set, the alert doesn't self-clear
* regardless of this value.
*
* @param limit Hysteresis Limit
* @param limit Hysteresis limit
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t setHysteresis(uint16_t limit);
/**
* Return the Highest Conversion value sampled so far. This value
* is only updated by the converter when automatic conversion mode
* Returns the highest conversion value recorded so far. This value
* is only updated by the converter when the automatic conversion mode
* is enabled.
*
* @return the highest conversion value recorded
* @return Highest conversion value
*/
uint16_t getHighestConversion();
/**
* Return the Lowest Conversion value sampled so far. This value
* is only updated by the converter when automatic conversion mode
* Returns the lowest conversion value recorded so far. This value
* is only updated by the converter when the automatic conversion mode
* is enabled.
*
* @return the lowest conversion value recorded
* @return Lowest conversion value
*/
uint16_t getLowestConversion();
/**
* Clear the Highest Conversion value sampled so far.
* Clears the highest conversion value recorded so far.
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t clearHighestConversion();
/**
* Clear the Lowest Conversion value sampled so far.
* Clears the lowest conversion value recorded so far.
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/

View File

@ -11,7 +11,7 @@
//
// This library runs on an Intel Edison and uses mraa to acquire data
// from an ADIS16448. This data is then scaled and printed onto the terminal.
//
//
// This software has been tested to connect to an ADIS16448 through a level shifter
// such as the TI TXB0104. The SPI lines (DIN, DOUT, SCLK, /CS) are all wired through
// the level shifter and the ADIS16448 is also being powered by the Intel Edison.
@ -84,11 +84,11 @@
namespace upm {
/**
* @brief ADIS16448 accelerometer library
* @brief ADIS16448 Accelerometer library
* @defgroup adis16448 libupm-adis16448
* @ingroup generic spi accelerometer
*/
/**
* @library adis16448
* @sensor adis16448
@ -98,54 +98,76 @@ namespace upm {
* @web http://www.analog.com/en/products/sensors/isensor-mems-inertial-measurement-units/adis16448.html
* @con spi
*
* @brief API for Analog Devices ADIS16448
* @brief API for the Analog Devices ADIS16448 Accelerometer
*
* This is an industrial grade accelerometer by Analog Devices.
* This is an industrial-grade accelerometer by Analog Devices.
*
* @snippet adis16448.cxx Interesting
*/
class ADIS16448{
class ADIS16448{
public:
public:
// Constructor with configurable HW Reset
ADIS16448(int bus, int rst);
/**
* Constructor with configurable HW Reset
*/
ADIS16448(int bus, int rst);
//Destructor
~ADIS16448();
/**
* Destructor
*/
~ADIS16448();
//Performs hardware reset by sending the specified pin low for 2 seconds
void resetDUT();
/**
* Performs hardware reset by sending the specified pin low for 2 seconds
*/
void resetDUT();
//Sets SPI frequency, mode, and bits/word
void configSPI();
/**
* Sets SPI frequency, mode, and bits/word
*/
void configSPI();
//Read specified register and return data
int16_t regRead(uint8_t regAddr);
/**
* Reads a specified register and returns data
*/
int16_t regRead(uint8_t regAddr);
//Write to specified register
void regWrite(uint8_t regAddr, uint16_t regData);
/**
* Writes to a specified register
*/
void regWrite(uint8_t regAddr, uint16_t regData);
//Scale accelerometer data
float accelScale(int16_t sensorData);
/**
* Scales accelerometer data
*/
float accelScale(int16_t sensorData);
//Scale gyro data
float gyroScale(int16_t sensorData);
/**
* Scales gyro data
*/
float gyroScale(int16_t sensorData);
//Scale temperature data
float tempScale(int16_t sensorData);
/**
* Scales temperature data
*/
float tempScale(int16_t sensorData);
//Scale pressure data
float pressureScale(int16_t sensorData);
/**
* Scales pressure data
*/
float pressureScale(int16_t sensorData);
//Scale magnetometer data
float magnetometerScale(int16_t sensorData);
/**
* Scales magnetometer data
*/
float magnetometerScale(int16_t sensorData);
private:
private:
mraa_spi_context _spi;
mraa_gpio_context _rst;
mraa_spi_context _spi;
mraa_gpio_context _rst;
};
};
}

View File

@ -35,7 +35,7 @@
namespace upm {
/**
* @brief ADXL335 accelerometer library
* @brief ADXL335 Accelerometer library
* @defgroup adxl335 libupm-adxl335
* @ingroup seeed analog accelerometer
*/
@ -49,12 +49,13 @@ namespace upm {
* @man seeed
* @con analog
*
* @brief API for the ADXL335 3-axis Analog Accelerometer
* @brief API for the ADXL335 3-Axis Analog Accelerometer
*
* UPM module for the ADXL335 3-axis analog accelerometer. This
* was tested on a Grove 3-axis Analog Accelerometer. It uses 3
* analog pins, one each for X, Y, and Z axis.
* UPM module for the ADXL335 3-axis analog accelerometer. This
* was tested on a Grove 3-axis Analog Accelerometer. It uses 3
* analog pins, one for each axis: X, Y, and Z.
*
* @image html adxl335.jpg
* @snippet adxl335.cxx Interesting
*/
class ADXL335 {
@ -62,61 +63,60 @@ namespace upm {
/**
* ADXL335 constructor
*
* @param pinX analog pin to use for axis X
* @param pinY analog pin to use for axis Y
* @param pinZ analog pin to use for axis Z
* @param aref analog voltage reference, default 5.0
* @param pinX Analog pin to use for X-axis
* @param pinY Analog pin to use for Y-axis
* @param pinZ Analog pin to use for Z-axis
* @param aref Analog reference voltage; default is 5.0v
*/
ADXL335(int pinX, int pinY, int pinZ, float aref=ADXL335_DEFAULT_AREF);
/**
* ADXL335 Destructor
* ADXL335 destructor
*/
~ADXL335();
/**
* Set the "zero" value of the X axis, determined through calibration
* Sets the "zero" value of the X-axis, determined through calibration
*
* @param zeroX The "zero" value of the X axis
* @param zeroX "Zero" value of the X-axis
*/
void setZeroX(float zeroX) { m_zeroX = zeroX; };
/**
* Set the "zero" value of the Y axis, determined through calibration
* Sets the "zero" value of the Y-axis, determined through calibration
*
* @param zeroX The "zero" value of the Y axis
* @param zeroY "Zero" value of the Y-axis
*/
void setZeroY(float zeroY) { m_zeroY = zeroY; };
/**
* Set the "zero" value of the Z axis, determined through calibration
* Sets the "zero" value of the Z-axis, determined through calibration
*
* @param zeroX The "zero" value of the Z axis
* @param zeroZ "Zero" value of the Z-axis
*/
void setZeroZ(float zeroZ) { m_zeroZ = zeroZ; };
/**
* Get the analog values for the 3 axes
* Gets the analog values for the 3 axes
*
* @param xVal pointer to returned X value
* @param yVal pointer to returned Y value
* @param zVal pointer to returned Z value
* @param xVal Pointer to the returned X-axis value
* @param yVal Pointer to the returned Y-axis value
* @param zVal Pointer to the returned Z-axis value
*/
void values(int *xVal, int *yVal, int *zVal);
/**
* Get the acceleration along all 3 axes
* Gets the acceleration along all 3 axes
*
* @param xAccel pointer to returned X value
* @param yAccel pointer to returned Y value
* @param zAccel pointer to returned Z value
* @param xAccel Pointer to returned X-axis value
* @param yAccel Pointer to returned Y-axis value
* @param zAccel Pointer to returned Z-axis value
*/
void acceleration(float *xAccel, float *yAccel, float *zAccel);
/**
* While the sensor is still, measure the X, Y, and Z values and
* use those values as our zero values.
*
* While the sensor is still, measures the X-axis, Y-axis, and Z-axis
* values and uses those values as the zero values.
*/
void calibrate();

View File

@ -1,4 +1,4 @@
/*
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
@ -30,7 +30,7 @@
namespace upm {
/**
* @brief ADXL345 accelerometer library
* @brief ADXL345 Accelerometer library
* @defgroup adxl345 libupm-adxl345
* @ingroup seeed i2c accelerometer
*/
@ -44,13 +44,14 @@ namespace upm {
* @man seeed
* @con i2c
*
* @brief API for Adxl345 (3-axis digital accelerometer)
* @brief API for the ADXL345 3-Axis Digital Accelerometer
*
* The Adxl345 is a 3-axis digital accelerometer.
* ADXL345 is a 3-axis digital accelerometer.
* (http://www.seeedstudio.com/wiki/images/2/2c/ADXL345_datasheet.pdf)
* The sensor has configurable resolutions for measuring ±2g, ±4g, ±8g or ±16g.
* Note that the sensor it is incompatible and will not be detected on the I2C bus
* by the Intel Edison using the Arduino breakout board at 5V (3V3 will work fine).
* The sensor has configurable resolutions to measure ±2g, ±4g, ±8g, or ±16g.
* Note: The Grove* version of the sensor is incompatible with and not detected
* on the I2C bus by the Intel(R) Edison using an Arduino* breakout board at 5V
* (3V works fine).
*
* @image html adxl345.jpeg
* @snippet adxl345.cxx Interesting
@ -58,14 +59,14 @@ namespace upm {
class Adxl345 {
public:
/**
* Creates an Adxl345 object
* Creates an ADXL345 object
*
* @param bus number of used i2c bus
* @param bus Number of the used I2C bus
*/
Adxl345(int bus);
/**
* Adxl345 object destructor
* ADXL345 object destructor
*/
~Adxl345();
@ -77,23 +78,25 @@ public:
float* getAcceleration();
/**
* Returns a pointer to an int[3] that contains the raw register values for X, Y and Z
* Returns a pointer to an int[3] that contains the raw register values
* for X, Y, and Z
*
* @return int* to an int[3]
*/
int16_t* getRawValues();
/**
* Returns the scale the accelerometer is currently set up to: 2, 4, 8 or 16
* Returns the scale the accelerometer is currently set up to: 2, 4, 8,
* or 16
*
* @return uint with current scale value
* @return uint with the current scale value
*/
uint8_t getScale();
/**
* Updates the acceleration values from i2c bus
* Updates the acceleration values from the I2C bus
*
* @return 0 for success
* @return 0 if successful
*/
mraa_result_t update();
private:

View File

@ -50,7 +50,7 @@
namespace upm {
/**
* @brief AM2315 temperature & humidity sensor library
* @brief AM2315 Temperature & Humidity Sensor library
* @defgroup am2315 libupm-am2315
* @ingroup adafruit i2c temp
*/
@ -64,15 +64,15 @@ namespace upm {
* @web http://www.adafruit.com/products/1293
* @con i2c
*
* @brief API for AM2315 chip (Temperature & Humidity Sensor)
* @brief API for the AM2315 Temperature & Humidity Sensor
*
* Measurement Specialties [AM2315]
* AM2315 by Measurement Specialties
* (http://www.aosong.com/asp_bin/Products/en/AM2315.pdf)
* is a digital humidity sensor with temperature output.
* RH will report between 0 and 100% and temperature range is
* RH reports between 0 and 100%, and the temperature range is
* -40 to +125 degC.
* The sampling period of this sensor is 2 seconds. Reads occurring
* more often than that will return cached data.
* The sampling period of this sensor is 2 seconds. Reads occurring
* more often than that return cached data.
*
* @image html am2315.jpeg
* @snippet am2315.cxx Interesting
@ -80,94 +80,97 @@ namespace upm {
class AM2315 {
public:
/**
* Instanciates a AM2315 object
* Instantiates an AM2315 object
*
* @param bus number of used bus
* @param devAddr address of used i2c device
* @param bus Number of the used bus
* @param devAddr Address of the used I2C device
* @param mode AM2315 oversampling
*/
AM2315 (int bus, int devAddr=AM2315_I2C_ADDRESS);
/**
* AM2315 object destructor, basicaly it close i2c connection.
* AM2315 object destructor; basically, it closes the I2C connection.
*/
~AM2315 ();
/**
* Get the current measured humidity [RH]
* Data is updated every 2 seconds - accesses more often than
* that will return cached data
* Gets the current measured humidity [RH]
*
* Data is updated every 2 seconds - accesses occurring more often than
* that return cached data
*/
float getHumidity(void);
/**
* Get the humidity cell temperature [degC]
* Data is updated every 2 seconds - accesses more often than
* that will return cached data
* Gets the humidity cell temperature [degC]
*
* Data is updated every 2 seconds - accesses occurring more often than
* that return cached data
*/
float getTemperature(void);
/**
* Get the humidity cell temperature [degF]
* Data is updated every 2 seconds - accesses more often than
* that will return cached data
* Gets the humidity cell temperature [degF]
*
* Data is updated every 2 seconds - accesses occurring more often than
* that return cached data
*/
float getTemperatureF(void);
/**
* Function intended to test the device and verify it
* is correctly operating.
* is operating correctly.
*
*/
int testSensor(void);
/**
* Write four byte (32b) register
* Writes a four-byte (32b) register
*
* Note: These access routines are not the normal accesses to an i2c
* device. The AM2315 contains a microcontroller that manages the
* actual readings. These handlers then make requests over i2c using
* a protocol defined by the AM2315.
* Note: these access routines are not the normal accesses to an I2C
* device. AM2315 contains a microcontroller that manages the
* actual readings. These handlers then make requests over I2C using
* a protocol defined by AM2315.
*
* @param reg address of a register
* @param reg Address of the register
* @param ival 32b value
*/
int i2cWriteReg_32(int reg, uint32_t ival);
/**
* Write two byte (16b) register
* Writes a two-byte (16b) register
*
* @param reg address of a register
* @param reg Address of the register
* @param ival 16b value
*/
int i2cWriteReg_16(int reg, uint16_t ival);
/**
* Write one byte (8b) register
* Writes a one-byte (8b) register
*
* @param reg address of a register
* @param reg Address of the register
* @param ival 8b value
*/
int i2cWriteReg_8(int reg, uint8_t ival);
/**
* Read four bytes register
* Reads a four-byte register
*
* @param reg address of a register
* @param reg Address of the register
*/
uint32_t i2cReadReg_32 (int reg);
/**
* Read two bytes register
* Reads a two-byte register
*
* @param reg address of a register
* @param reg Address of the register
*/
uint16_t i2cReadReg_16 (int reg);
/**
* Read one byte register
* Reads a one-byte register
*
* @param reg address of a register
* @param reg Address of the register
*/
uint8_t i2cReadReg_8 (int reg);

View File

@ -28,7 +28,7 @@
namespace upm {
/**
* @brief APDS-9002 luminance sensor library
* @brief APDS-9002 Luminance Sensor library
* @defgroup apds9002 libupm-apds9002
* @ingroup seeed analog light
*/
@ -42,10 +42,10 @@ namespace upm {
* @man seeed
* @con analog
*
* @brief UPM module for the Grove Luminance Sensor
* @brief UPM module for the APDS-9002 Luminance Sensor
*
* This sensor transforms luminous intensity to output analog values.
* It uses the APDS-9002 ambient light sensor.
* It uses an APDS-9002 ambient light sensor.
*
* @image html apds9002.jpg
* @snippet apds9002.cxx Interesting
@ -54,19 +54,19 @@ namespace upm {
class APDS9002 {
public:
/**
* Grove luminance sensor constructor
* APDS-9002 luminance sensor constructor
*
* @param pin analog pin to use
* @param pin Analog pin to use
*/
APDS9002(int pin);
/**
* APDS9002 Destructor
* APDS9002 destructor
*/
~APDS9002();
/**
* Get the luminance value from the sensor
* Gets the luminance value from the sensor
*
* @return the luminance reading
* @return Luminance value
*/
int value();

View File

@ -26,6 +26,7 @@
#include <math.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include "at42qt1070.h"
@ -35,111 +36,216 @@ using namespace std;
AT42QT1070::AT42QT1070(int bus, uint8_t address)
{
m_addr = address;
m_addr = address;
// setup our i2c link
if ( !(m_i2c = mraa_i2c_init(bus)) )
{
cerr << __FUNCTION__ << ": mraa_i2c_init() failed." << endl;
return;
}
mraa_result_t rv;
if ( (rv = mraa_i2c_address(m_i2c, m_addr)) != MRAA_SUCCESS)
{
cerr << __FUNCTION__ << ": Could not initialize i2c bus. " << endl;
mraa_result_print(rv);
return;
// setup our i2c link
if (!(m_i2c = mraa_i2c_init(bus))) {
cerr << __FUNCTION__ << ": mraa_i2c_init() failed." << endl;
return;
}
m_buttonStates = false;
m_calibrating = false;
m_overflow = false;
mraa_result_t rv;
if ((rv = mraa_i2c_address(m_i2c, m_addr)) != MRAA_SUCCESS) {
cerr << __FUNCTION__ << ": Could not initialize i2c bus. " << endl;
mraa_result_print(rv);
return;
}
if (readChipID() != 0x2E) {
throw std::runtime_error("Chip ID does not match the expected value (2Eh)");
}
m_buttonStates = 0;
m_calibrating = false;
m_overflow = false;
}
AT42QT1070::~AT42QT1070()
{
mraa_i2c_stop(m_i2c);
mraa_i2c_stop(m_i2c);
}
bool AT42QT1070::writeByte(uint8_t reg, uint8_t byte)
bool
AT42QT1070::writeByte(uint8_t reg, uint8_t byte)
{
mraa_result_t rv = mraa_i2c_write_byte_data(m_i2c, byte, reg);
mraa_result_t rv = mraa_i2c_write_byte_data(m_i2c, byte, reg);
if (rv != MRAA_SUCCESS)
{
cerr << __FUNCTION__ << ": mraa_i2c_write_byte() failed." << endl;
mraa_result_print(rv);
return false;
if (rv != MRAA_SUCCESS) {
cerr << __FUNCTION__ << ": mraa_i2c_write_byte() failed." << endl;
mraa_result_print(rv);
return false;
}
return true;
return true;
}
bool AT42QT1070::writeWord(uint8_t reg, uint16_t word)
bool
AT42QT1070::writeWord(uint8_t reg, uint16_t word)
{
mraa_result_t rv = mraa_i2c_write_word_data(m_i2c, word, reg);
mraa_result_t rv = mraa_i2c_write_word_data(m_i2c, word, reg);
if (rv != MRAA_SUCCESS)
{
cerr << __FUNCTION__ << ": mraa_i2c_write_word() failed." << endl;
mraa_result_print(rv);
return false;
if (rv != MRAA_SUCCESS) {
cerr << __FUNCTION__ << ": mraa_i2c_write_word() failed." << endl;
mraa_result_print(rv);
return false;
}
return true;
return true;
}
uint8_t AT42QT1070::readByte(uint8_t reg)
uint8_t
AT42QT1070::readByte(uint8_t reg)
{
return mraa_i2c_read_byte_data(m_i2c, reg);
return mraa_i2c_read_byte_data(m_i2c, reg);
}
uint16_t AT42QT1070::readWord(uint8_t reg)
uint16_t
AT42QT1070::readWord(uint8_t reg)
{
return mraa_i2c_read_word_data(m_i2c, reg);
return mraa_i2c_read_word_data(m_i2c, reg);
}
void AT42QT1070::updateState()
uint8_t
AT42QT1070::readChipID(void)
{
uint8_t stat = readByte(REG_DETSTATUS);
return readByte(REG_CHIPID);
}
// if we are calibrating, don't change anything
if (stat & DET_CALIBRATE)
{
m_calibrating = true;
return;
void
AT42QT1070::updateState()
{
uint8_t stat = readByte(REG_DETSTATUS);
// if we are calibrating, don't change anything
if (stat & DET_CALIBRATE) {
m_calibrating = true;
return;
} else {
m_calibrating = false;
}
else
m_calibrating = false;
if (stat & DET_OVERFLOW)
m_overflow = true;
else
m_overflow = false;
if (stat & DET_OVERFLOW)
m_overflow = true;
else
m_overflow = false;
// if a touch is occurring, read the button states
if (stat & DET_TOUCH)
{
uint8_t keys = readByte(REG_KEYSTATUS);
// high bit is reserved, filter it out
m_buttonStates = keys & ~0x80;
// if a touch is occurring, read the button states
if (stat & DET_TOUCH) {
uint8_t keys = readByte(REG_KEYSTATUS);
// high bit is reserved, filter it out
m_buttonStates = keys & ~0x80;
} else {
m_buttonStates = 0;
}
else
m_buttonStates = 0;
}
bool AT42QT1070::reset()
uint8_t
AT42QT1070::getLPMode(void)
{
// write a non-zero value to the reset register
return writeByte(REG_RESET, 0xff);
return readByte(REG_LP);
}
bool AT42QT1070::calibrate()
uint8_t
AT42QT1070::setLPMode(uint8_t mode)
{
// write a non-zero value to the calibrate register
return writeByte(REG_CALIBRATE, 0xff);
writeByte(REG_LP, mode);
return getLPMode();
}
uint8_t
AT42QT1070::getAVE(uint8_t key)
{
uint8_t value, ave;
if (key > 6) {
throw std::invalid_argument("Only keys 0-6 are allowed");
}
value = readByte(REG_AVE0 + key);
ave = (value & 0xFC) >> 2;
return ave;
}
uint8_t
AT42QT1070::setAVE(uint8_t key, uint8_t ave)
{
uint8_t value;
if (key > 6) {
throw std::invalid_argument("Only keys 0-6 are allowed");
}
switch (ave) {
case 1:
case 2:
case 4:
case 8:
case 16:
case 32:
break;
default:
throw std::invalid_argument("Invalid averaging factor");
}
value = readByte(REG_AVE0 + key);
value = value & 0x03;
value = value | (ave << 2);
writeByte(REG_AVE0 + key, value);
return getAVE(key);
}
uint8_t
AT42QT1070::getAKSGroup(uint8_t key)
{
uint8_t value, aks;
if (key > 6) {
throw std::invalid_argument("Only keys 0-6 are allowed");
}
value = readByte(REG_AVE0 + key);
aks = value & 0x03;
return aks;
}
uint8_t
AT42QT1070::setAKSGroup(uint8_t key, uint8_t group)
{
uint8_t value;
if (key > 6) {
throw std::invalid_argument("Only keys 0-6 are allowed");
}
if (group > 3) {
throw std::invalid_argument("Only groups 0-3 are allowed");
}
value = readByte(REG_AVE0 + key);
value = value & 0xFC;
value = value | group;
writeByte(REG_AVE0 + key, value);
return getAKSGroup(key);
}
bool
AT42QT1070::reset()
{
// write a non-zero value to the reset register
return writeByte(REG_RESET, 0xff);
}
bool
AT42QT1070::calibrate()
{
// write a non-zero value to the calibrate register
return writeByte(REG_CALIBRATE, 0xff);
}

View File

@ -32,202 +32,275 @@
#define AT42QT1070_I2C_BUS 0
#define AT42QT1070_DEFAULT_I2C_ADDR 0x1b
namespace upm {
namespace upm
{
/**
* @brief Atmel* AT42QT1070 QTouch* Sensor library
* @defgroup at42qt1070 libupm-at42qt1070
* @ingroup seeed i2c touch
*/
/**
* @brief Atmel AT42QT1070 QTouch sensor library
* @defgroup at42qt1070 libupm-at42qt1070
* @ingroup seeed i2c touch
*/
/**
* @library at42qt1070
* @sensor at42qt1070
* @comname AT42QT1070 QTouch Sensor
* @altname Grove QTouch Sensor
* @type touch
* @man seeed
* @con i2c
*
* @brief API for the Atmel AT42QT1070 QTouch sensor
*
* This class implements support for the Atmel AT42QT1070 QTouch
* sensor, which supports 7 capacitive buttons.
*
* It was developed using the Grove Q Touch Sensor board.
*
* @image html at42qt1070.jpg
* @snippet at42qt1070.cxx Interesting
*/
class AT42QT1070 {
/**
* @library at42qt1070
* @sensor at42qt1070
* @comname AT42QT1070 QTouch Sensor
* @altname Grove QTouch Sensor
* @type touch
* @man seeed
* @con i2c
*
* @brief API for the Atmel AT42QT1070 QTouch Sensor
*
* This class implements support for the Atmel AT42QT1070 QTouch
* sensor, which supports 7 capacitive buttons.
*
* It was developed using a Grove-Q Touch Sensor board.
*
* @image html at42qt1070.jpg
* @snippet at42qt1070.cxx Interesting
*/
class AT42QT1070
{
public:
// registers
typedef enum { REG_CHIPID = 0,
REG_FWVERS = 1,
typedef enum {
REG_CHIPID = 0,
REG_FWVERS = 1,
REG_DETSTATUS = 2, // detection status
REG_KEYSTATUS = 3, // key status
REG_DETSTATUS = 2, // detection status
REG_KEYSTATUS = 3, // key status
REG_KEYSIG0_H = 4, // key signal
REG_KEYSIG0_L = 5,
REG_KEYSIG1_H = 6,
REG_KEYSIG1_L = 7,
REG_KEYSIG2_H = 8,
REG_KEYSIG2_L = 9,
REG_KEYSIG3_H = 10,
REG_KEYSIG3_L = 11,
REG_KEYSIG4_H = 12,
REG_KEYSIG4_L = 13,
REG_KEYSIG5_H = 14,
REG_KEYSIG5_L = 15,
REG_KEYSIG6_H = 16,
REG_KEYSIG6_L = 17,
REG_KEYSIG0_H = 4, // key signal
REG_KEYSIG0_L = 5,
REG_KEYSIG1_H = 6,
REG_KEYSIG1_L = 7,
REG_KEYSIG2_H = 8,
REG_KEYSIG2_L = 9,
REG_KEYSIG3_H = 10,
REG_KEYSIG3_L = 11,
REG_KEYSIG4_H = 12,
REG_KEYSIG4_L = 13,
REG_KEYSIG5_H = 14,
REG_KEYSIG5_L = 15,
REG_KEYSIG6_H = 16,
REG_KEYSIG6_L = 17,
REG_REFDATA0_H = 18, // key reference data
REG_REFDATA0_L = 19,
REG_REFDATA1_H = 20,
REG_REFDATA1_L = 21,
REG_REFDATA2_H = 22,
REG_REFDATA2_L = 23,
REG_REFDATA3_H = 24,
REG_REFDATA3_L = 25,
REG_REFDATA4_H = 26,
REG_REFDATA4_L = 27,
REG_REFDATA5_H = 28,
REG_REFDATA5_L = 29,
REG_REFDATA6_H = 30,
REG_REFDATA6_L = 31,
REG_REFDATA0_H = 18, // key reference data
REG_REFDATA0_L = 19,
REG_REFDATA1_H = 20,
REG_REFDATA1_L = 21,
REG_REFDATA2_H = 22,
REG_REFDATA2_L = 23,
REG_REFDATA3_H = 24,
REG_REFDATA3_L = 25,
REG_REFDATA4_H = 26,
REG_REFDATA4_L = 27,
REG_REFDATA5_H = 28,
REG_REFDATA5_L = 29,
REG_REFDATA6_H = 30,
REG_REFDATA6_L = 31,
REG_NTHR0 = 32, // negative threshold level
REG_NTHR1 = 33,
REG_NTHR2 = 34,
REG_NTHR3 = 35,
REG_NTHR4 = 36,
REG_NTHR5 = 37,
REG_NTHR6 = 38,
REG_NTHR0 = 32, // negative threshold level
REG_NTHR1 = 33,
REG_NTHR2 = 34,
REG_NTHR3 = 35,
REG_NTHR4 = 36,
REG_NTHR5 = 37,
REG_NTHR6 = 38,
REG_AVE0 = 39, // key suppression
REG_AVE1 = 40,
REG_AVE2 = 41,
REG_AVE3 = 42,
REG_AVE4 = 43,
REG_AVE5 = 44,
REG_AVE6 = 45,
REG_AVE0 = 39, // key suppression
REG_AVE1 = 40,
REG_AVE2 = 41,
REG_AVE3 = 42,
REG_AVE4 = 43,
REG_AVE5 = 44,
REG_AVE6 = 45,
REG_DI0 = 46, // detection integrator
REG_DI1 = 47,
REG_DI2 = 48,
REG_DI3 = 49,
REG_DI4 = 50,
REG_DI5 = 51,
REG_DI6 = 52,
REG_DI0 = 46, // detection integrator
REG_DI1 = 47,
REG_DI2 = 48,
REG_DI3 = 49,
REG_DI4 = 50,
REG_DI5 = 51,
REG_DI6 = 52,
REG_GUARD = 53, // FastOutDI/Max Cal/Guard channel
REG_LP = 54, // low power
REG_MAXON = 55, // max on duration
REG_CALIBRATE = 56,
REG_RESET = 57
REG_GUARD = 53, // FastOutDI/Max Cal/Guard channel
REG_LP = 54, // low power
REG_MAXON = 55, // max on duration
REG_CALIBRATE = 56,
REG_RESET = 57
} AT42QT1070_REG_T;
// detection register bits
typedef enum { DET_TOUCH = 0x01,
// 0x02-0x20 reserved
DET_OVERFLOW = 0x40,
DET_CALIBRATE = 0x80
typedef enum {
DET_TOUCH = 0x01,
// 0x02-0x20 reserved
DET_OVERFLOW = 0x40,
DET_CALIBRATE = 0x80
} AT42QT1070_DET_T;
/**
* AT42QT1070 constructor
*
* @param bus i2c bus to use
* @param address the address for this sensor
* @param bus I2C bus to use
* @param address Address for this sensor
*/
AT42QT1070(int bus, uint8_t address = AT42QT1070_DEFAULT_I2C_ADDR);
/**
* AT42QT1070 Destructor
* AT42QT1070 destructor
*/
~AT42QT1070();
/**
* Write byte value into register
* Writes a byte value into the register
*
* @param reg register location to write into
* @param byte byte to write
* @return true if successful
* @param reg Register location to write into
* @param byte Byte to write
* @return True if successful
*/
bool writeByte(uint8_t reg, uint8_t byte);
/**
* Write word value at register. Note, the device must have the
* Writes a word value into the register. Note: the device must have the
* auto-increment bit set in the MODE1 register to work.
*
* @param reg register location to write into
* @param word word to write
* @return true if successful
* @param reg Register location to write into
* @param word Word to write
* @return True if successful
*/
bool writeWord(uint8_t reg, uint16_t word);
/**
* Read byte value from register
* Read a byte value from the register
*
* @param reg register location to read from
* @return value at specified register
* @param reg Register location to read from
* @return Value in the specified register
*/
uint8_t readByte(uint8_t reg);
/**
* Read word value from register. Note, the device must have the
* Read a word value from the register. Note: the device must have the
* auto-increment bit set in the MODE1 register to work.
*
* @param reg register location to read from
* @return value at specified register
* @param reg Register location to read from
* @return Value in the specified register
*/
uint16_t readWord(uint8_t reg);
/**
* Read the current touch status and detection state
* Reads the Chip ID register on the sensor
*
* @return key status bits for all keys (0-6)
* @return Value of the Chip ID register
*/
uint8_t readChipID(void);
/**
* Reads the current touch status and detection state
*
* @return Key status bits for all keys (0-6)
*/
void updateState();
/**
* return the overflow indicator
*
* @return true if overflow indicated
*/
bool isOverflowed() { return m_overflow; };
/**
* return the calibrating indicator
* Reads the current low-power mode setting
*
* @return true if calibration is in progress
* @return Low-power mode setting from the sensor
*/
bool isCalibrating() { return m_calibrating; };
uint8_t getLPMode(void);
/**
* Issue a reset command
* Changes the low-pomer mode setting on the sensor
*
* @return true if reset successful
* @param mode dDsired new mode
* @return New setting on the sensor
*/
uint8_t setLPMode(uint8_t mode);
/**
* Reads the current averaging factor setting for a key
*
* @param key Key being read
* @return Averaging factor
*/
uint8_t getAVE(uint8_t key);
/**
* Changes the averaging factor setting for a key
*
* @param key Key being changed
* @param ave New averaging factor
* @return New averaging factor as read from the device
*/
uint8_t setAVE(uint8_t key, uint8_t ave);
/**
* Reads the AKS group of which a key is part
*
* @param key Key (0-6) being queried
* @return AKS group of which the key is part
*/
uint8_t getAKSGroup(uint8_t key);
/**
* Changes the AKS group of which a key is part
*
* @param key Key (0-6) being changed
* @param group New group for the key
* @return New value on the sensor
*/
uint8_t setAKSGroup(uint8_t key, uint8_t group);
/**
* Returns the overflow indicator
*
* @return True if overflow is indicated
*/
bool
isOverflowed()
{
return m_overflow;
};
/**
* Returns the calibrating indicator
*
* @return True if calibration is in progress
*/
bool
isCalibrating()
{
return m_calibrating;
};
/**
* Issues a reset command
*
* @return True if successful
*/
bool reset();
/**
* Issue a calibrate command
* Issues a calibrate command
*
* @return true if calibrate successful
* @return True if successful
*/
bool calibrate();
/**
* Get the current button states
* Gets the current button states
*
* @returns the button states
* @returns Button states
*/
uint8_t getButtons() { return m_buttonStates; };
uint8_t
getButtons()
{
return m_buttonStates;
};
private:
uint8_t m_buttonStates;
@ -236,7 +309,5 @@ namespace upm {
mraa_i2c_context m_i2c;
uint8_t m_addr;
};
};
}

View File

@ -28,9 +28,9 @@
namespace upm {
/**
* @brief BISS0001 motion sensor library
* @brief BISS0001 Motion Sensor library
* @defgroup biss0001 libupm-biss0001
* @ingroup seeed gpio light
* @ingroup seeed gpio light tsk
*/
/**
@ -42,6 +42,7 @@ namespace upm {
* @man seeed
* @web http://www.seeedstudio.com/depot/Grove-PIR-Motion-Sensor-p-802.html
* @con gpio
* @kit tsk
*
* @brief API for the BISS0001 Motion Sensor
*
@ -55,17 +56,17 @@ namespace upm {
/**
* BISS0001 motion sensor constructor
*
* @param pin digital pin to use
* @param pin Digital pin to use
*/
BISS0001(int pin);
/**
* BISS0001 Destructor
* BISS0001 destructor
*/
~BISS0001();
/**
* Get the motion value from the sensor
* Gets the motion value from the sensor
*
* @return the motion reading
* @return Motion reading
*/
bool value();

View File

@ -62,7 +62,7 @@
namespace upm {
/**
* @brief Bosch BMP & GY65 atmospheric pressure sensor library
* @brief Bosch BMP & GY65 Atmospheric Pressure Sensor library
* @defgroup bmpx8x libupm-bmpx8x
* @ingroup seeed adafruit sparkfun i2c pressure
*/
@ -76,11 +76,11 @@ namespace upm {
* @man seeed adafruit sparkfun
* @con i2c
*
* @brief API for GY65/BMP085 and BMP180 chips (Atmospheric Pressure Sensor)
* @brief API for the GY65/BMP085 and BMP180 Atmospheric Pressure Sensors
*
* The Bosch GY65/BMP085 and BMP180 are high precision, ultra-low
* power consumption pressure sensors. They have a range of between
* 30,000 and 110,000 Pa.
* Bosch GY65/BMP085 and BMP180 are high-precision, ultra-low
* power consumption pressure sensors. They operate in the range of
* 30,000-110,000 Pa.
*
* This module has been tested on the GY65/BMP085 and BMP180 sensors.
*
@ -91,80 +91,80 @@ namespace upm {
class BMPX8X {
public:
/**
* Instanciates a BMPX8X object
* Instantiates a BMPX8X object
*
* @param bus number of used bus
* @param devAddr address of used i2c device
* @param bus Number of the used bus
* @param devAddr Address of the used I2C device
* @param mode BMP085 mode
*/
BMPX8X (int bus, int devAddr=0x77, uint8_t mode=BMP085_ULTRAHIGHRES);
/**
* BMPX8X object destructor, basicaly it close i2c connection.
* BMPX8X object destructor; basically, it closes the I2C connection.
*/
~BMPX8X ();
/**
* Return calculated pressure
* Returns the calculated pressure
*/
int32_t getPressure ();
/**
*
* Get raw pressure data
* Gets raw pressure data
*/
int32_t getPressureRaw ();
/**
* Get raw temperature data from chip
* Gets raw temperature data from the sensor
*/
int16_t getTemperatureRaw ();
/**
* Return calculated temperature
* Returns the calculated temperature
*/
float getTemperature ();
/**
* With given absolute altitude sea level can be calculated
* With a given absolute altitude, sea level can be calculated
*
* @param altitudeMeters altitude
* @param altitudeMeters Altitude
*/
int32_t getSealevelPressure(float altitudeMeters = 0);
/**
* With given sea level altitude in meters can be calculated
* With a given sea level, altitude in meters can be calculated
*
* @param sealevelPressure Sea level
*/
float getAltitude (float sealevelPressure = 101325);
/**
* Calculation of B5 (check spec for more information)
* Calculates B5 (check the spec for more information)
*
* @param UT
*/
int32_t computeB5 (int32_t UT);
/**
* Read two bytes register
* Reads a two-byte register
*
* @param reg address of a register
* @param reg Address of the register
*/
uint16_t i2cReadReg_16 (int reg);
/**
* Write to one byte register
* Writes to a one-byte register
*
* @param reg address of a register
* @param value byte to be written
* @param reg Address of the register
* @param value Byte to be written
*/
mraa_result_t i2cWriteReg (uint8_t reg, uint8_t value);
/**
* Read one byte register
* Reads a one-byte register
*
* @param reg address of a register
* @param reg Address of the register
*/
uint8_t i2cReadReg_8 (int reg);

View File

@ -51,7 +51,7 @@ namespace upm {
* @con pwm
* @kit gsk
*
* @brief API for Buzzer component
* @brief API for the Buzzer component
*
* This file defines the Buzzer interface for libbuzzer.
* This sensor can make different tones when connected to
@ -77,42 +77,42 @@ class Buzzer {
~Buzzer ();
/**
* Play a tone for a certain amount of time or indefinitely. When delay
* Plays a tone for a certain amount of time or indefinitely. When delay
* is not used, the sound can be stopped by calling stopSound().
*
* @param note the note to be played (DO, RE, MI, etc...) or frequency
* @param delay time in microseconds for playing the sound, a value of
* 0 plays the sound indefinitely
* @param note Note to play (C, D, E, etc.) or frequency
* @param delay Time in microseconds for which to play the sound; if the value is
* 0, the sound is played indefinitely
*
* @return the note played
* @return Note played
*/
int playSound (int note, int delay);
/**
* Stops the sound currently playing. Has to be called when playSound()
* does not set a delay value.
* Stops the sound currently playing. Should be called when playSound()
* does not have a delay value.
*/
void stopSound();
/**
* Sets the volume for the buzzer, but may affect the sound timbre.
* Works best with halved values, e.g. 1.0, 0.5, 0.25, ...
* Works best with halved values; e.g., 1.0, 0.5, 0.25, etc.
*
* @param vol the value to set the volume to from 0.0 to 1.0
* @param vol Value to set the volume to, from 0.0 to 1.0
*/
void setVolume(float vol);
/**
* Gets the buzzer volume.
*
* @return the value the volume was set to
* @return Value the volume was set to
*/
float getVolume();
/**
* Return name of the component.
* Returns the name of the sensor.
*
* @return name of the sensor
* @return Name of the sensor
*/
std::string name()
{

View File

@ -29,7 +29,7 @@ namespace upm {
/**
* @brief CJQ4435 MOSFET library
* @defgroup cjq4435 libupm-cjq4435
* @ingroup seeed gpio pwm electric
* @ingroup seeed gpio pwm electric robok
*/
/**
@ -40,14 +40,15 @@ namespace upm {
* @type electric
* @man seeed
* @con gpio pwm
* @kit robok
*
* @brief API for the CJQ4435 MOSFET
*
* UPM module for the CJQ4435 MOSFET. It was developed using the
* UPM module for the CJQ4435 MOSFET. It was developed using the
* Grove MOSFET module. A MOSFET is like a switch, but it can
* switch much faster than a mechanical relay. Here, we implement
* support via MRAA's PWM (Pulse Width Modulation) functions.
* Please note, that the available periods will vary depending on
* support via MRAA pulse width modulation (PWM) functions.
* Note: available periods vary depending on
* the capabilities of your device.
*
* @image html cjq4435.jpg
@ -58,60 +59,60 @@ namespace upm {
/**
* CJQ4435 constructor
*
* @param pin digital pin to use - this pin must be PWM capable
* @param pin Digital pin to use; this pin must be PWM-capable
*/
CJQ4435(int pin);
/**
* CJQ4435 Destructor
* CJQ4435 destructor
*/
~CJQ4435();
/**
* set the period in microseconds
* Sets a period in microseconds
*
* @param us period in microseconds
* @param us Period in microseconds
*/
void setPeriodUS(int us);
/**
* set the period in milliseconds
* Sets a period in milliseconds
*
* @param ms period in milliseconds
* @param ms Period in milliseconds
*/
void setPeriodMS(int ms);
/**
* set the period in seconds
* Sets a period in seconds
*
* @param seconds period in seconds
* @param seconds Period in seconds
*/
void setPeriodSeconds(float seconds);
/**
* enable output
* Enables output
*
* @param enable enable PWM output if true, disable if false
* @param enable Enables PWM output if true, disables otherwise
*/
void enable(bool enable);
/**
* set the duty cycle. The duty cycle is a floating point number
* between 0.0 (always off) to 1.0 (always on). It represents how
* much time as a percentage, per period, that the output will be
* Sets a duty cycle. Duty cycle is a floating-point number
* between 0.0 (always off) and 1.0 (always on). It represents a
* proportion of time, per period, during which the output is
* driven high.
*
* @param dutyCycle the duty cycle to use
* @param dutyCycle Duty cycle to use
*/
void setDutyCycle(float dutyCycle);
/**
* a shortcut for turning the output to continuous on (high)
* Shortcut to turn the output to continuous on (high)
*/
void on();
/**
* a shortcut for turning the output to continuous off (low)
* Shortcut to turn the output to continuous off (low)
*/
void off();

View File

@ -43,7 +43,7 @@
namespace upm {
/**
* @brief DS1307 real-time clock library
* @brief DS1307 Real-Time Clock library
* @defgroup ds1307 libupm-ds1307
* @ingroup seeed i2c time
*/
@ -57,11 +57,11 @@ namespace upm {
* @man seeed
* @con i2c
*
* @brief API for the DS1307 Real Time CLock
* @brief API for the DS1307 Real-Time CLock
*
* UPM module for the DS1307 based RTC. The clock can provide information
* about the seconds, minutes, hours, day of the week, day of the month,
* month, and year. It can operate in either 24-hour or 12-hour format.
* UPM module for the DS1307-based real-time clock. The clock can provide information
* about seconds, minutes, hours, day of the week, day of the month,
* month, and year. It can operate in either a 24-hour or a 12-hour format.
* This device can also output a square wave at 1Khz, 4Khz, 8Khz, and 32Khz.
* However, this capability is not implemented in this module.
*
@ -71,41 +71,41 @@ namespace upm {
class DS1307 {
public:
/**
* ds1307 Real Time Clock constructor
* DS1307 constructor
*
* @param bus i2c bus to use
* @param bus I2C bus to use
*/
DS1307(int bus);
/**
* DS1307 Destructor
* DS1307 destructor
*/
~DS1307();
/**
* Load all of the time values
* Loads all the time values
*
* @return True if time data loaded successfully
*/
bool loadTime();
/**
* Set the time. You should call loadTime() beforehand to
* Sets the time. You should call loadTime() beforehand to
* maintain consistency
*
* @return True if time saved successfully
* @return True if time is set successfully
*/
bool setTime();
/**
* Enable the oscillator on the clock.
* Enables an oscillator on the clock.
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t enableClock();
/**
* Disable the oscillator on the clock. This will prevent the clock
* Disables the oscillator on the clock. This prevents the clock
* from updating any time/date values
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
@ -113,80 +113,80 @@ namespace upm {
mraa_result_t disableClock();
/**
* Write value(s) into registers
* Writes value(s) into registers
*
* @param reg register location to start writing into
* @param buffer buffer for data storage
* @param len number of bytes to write
* @param reg Register location to start writing into
* @param buffer Buffer for data storage
* @param len Number of bytes to write
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len);
/**
* Read value(s) from registers
* Reads value(s) from registers
*
* @param reg register location to start reading from
* @param buffer buffer for data storage
* @param len number of bytes to read
* @return number of bytes read
* @param reg Register location to start reading from
* @param buffer Buffer for data storage
* @param len Number of bytes to read
* @return Number of bytes read
*/
uint8_t readBytes(uint8_t reg, uint8_t *buffer, unsigned int len);
/**
* Convert a BCD value into decimal
* Converts a BCD value into decimal
*
* @param val BCD value to convert
* @return the converted value in decimal
* @return Converted decimal value
*/
unsigned int bcdToDec(uint8_t val);
/**
* Convert a decimal value into BCD
* Converts a decimal value into BCD
*
* @param val decimal value to convert
* @return the converted value in BCD
* @param val Decimal value to convert
* @return Converted BCD value
*/
uint8_t decToBcd(unsigned int val);
// These variables store the time data loaded with loadTime(), and
// will be the source of data when setTime() is called. It is a
// good idea call loadTime() to setup the current values before
// are the source of data when setTime() is called. It is a
// good idea to call loadTime() to set up the current values before
// calling setTime() to ensure RTC data is consistent
/**
* holds the seconds
* Holds seconds
*/
unsigned int seconds;
/**
* holds the minutes
* Holds minutes
*/
unsigned int minutes;
/**
* holds the hours, 1-12 in am/pm mode, 0-23 otherwise
* Holds hours; 1-12 in the am/pm format, 0-23 otherwise
*/
unsigned int hours;
/**
* holds the day of the week, 1-7 where 1 is Sunday
* Holds a day of the week; 1-7, where 1 is Sunday
*/
unsigned int dayOfWeek;
/**
* holds the day of the month, 1-31
* Holds a day of the month, 1-31
*/
unsigned int dayOfMonth;
/**
* holds the month, 1-12
* Holds a month, 1-12
*/
unsigned int month;
/**
* holds the year, 0-99
* Holds a year, 0-99
*/
unsigned int year;
/**
* True if in AM/PM mode, false if 24h format.
* True if the am/pm format is used, false otherwise
*/
bool amPmMode;
/**
* If in AmPmMode (12-hr), then this is true if it's PM, clear if AM
* For the am/pm format, it is true if it's pm, false otherwise
*/
bool pm;

View File

@ -61,12 +61,12 @@ namespace upm {
* This non-invasive current sensor can be clamped around the supply line of
* an electrical load to tell you how much current is passing through it. It
* does this by acting as an inductor and responding to the magnetic field
* around a current-carrying conductor. This particular current sensor will
* measure a load up to 30 Amps which makes it great for building your own
* around a current-carrying conductor. This particular current sensor
* measures a load up to 30 A, which makes it great for building your own
* energy monitors.
*
* @image html ecs1030.jpg
* <br><em>ECS1030 Sensor image provided by Sparkfun under
* <br><em>ECS1030 Sensor image provided by SparkFun* under
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
* CC BY-NC-SA-3.0</a>.</em>
*
@ -79,39 +79,39 @@ class ECS1030 {
static const uint8_t R_LOAD = 2000.0 / CURRENT_RATIO;
/**
* Instanciates a ECS1030 (current sensor) object
* Instantiates an ECS1030 object
*
* @param pinNumber number of the data pin
* @param pinNumber Number of the data pin
*/
ECS1030 (uint8_t pinNumber);
/**
* ECS1030 object destructor, basicaly it close the GPIO.
* ECS1030 object destructor; basically, it closes the GPIO.
*/
~ECS1030 ();
/**
* Return currency data for the sampled period
* Returns electric current data for a sampled period
*/
double getCurrency_A ();
/**
* Return power data for the sampled period
* Returns power data for a sampled period
*/
double getPower_A ();
/**
* Return currency data for the sampled period
* Returns electric current data for a sampled period
*/
double getCurrency_B ();
/**
* Return power data for the sampled period
* Returns power data for a sampled period
*/
double getPower_B ();
/**
* Return name of the component
* Returns the name of the component
*/
std::string name() {
return m_name;

View File

@ -31,7 +31,7 @@ namespace upm {
/**
* @brief ENC03R Single Axis Gyro library
* @defgroup enc03r libupm-enc03r
* @ingroup seeed analog compass
* @ingroup seeed analog compass robok
*/
/**
@ -42,11 +42,12 @@ namespace upm {
* @type compass
* @man seeed
* @con analog
* @kit robok
*
* @brief API for the ENC03R Single Axis Analog Gyro
*
* UPM module for the ENC03R Single Axis Analog Gyro.
* This gyroscope measures the x-axis angular velocity; that is,
* UPM module for the ENC03R single axis analog gyro.
* This gyroscope measures x-axis angular velocity, that is
* how fast the sensor is rotating around the x-axis.
* Calibration of the sensor is necessary for accurate readings.
*
@ -59,45 +60,45 @@ namespace upm {
/**
* ENC03R sensor constructor
*
* @param pin analog pin to use
* @param vref the voltage reference to use, default 5.0
* @param pin Analog pin to use
* @param vref Reference voltage to use; default is 5.0 V
*/
ENC03R(int pin, float vref=5.0);
/**
* ENC03R Destructor
* ENC03R destructor
*/
~ENC03R();
/**
* Calibrate the sensor by determining an analog reading over many
* samples with no movement of the sensor. This must be done
* Calibrates the sensor by determining an analog reading over many
* samples with no movement of the sensor. This must be done
* before attempting to use the sensor.
*
* @param samples the number of samples to use for calibration
* @param samples Number of samples to use for calibration
*/
void calibrate(unsigned int samples);
/**
* Return the raw value of the sensor
* Returns the raw value of the sensor
*
* @return raw value of sensor
* @return Raw value of the sensor
*/
unsigned int value();
/**
* Return the currently stored calibration value
* Returns the currently stored calibration value
*
* @return current calibration value
* @return Current calibration value
*/
float calibrationValue() { return m_calibrationValue; };
/**
* Compute angular velocity based on value and stored calibration
* Computes angular velocity based on the value and stored calibration
* reference.
*
* @param val the value to use to compute the angular velocity
* @return computed angular velocity
* @param val Value to use to compute angular velocity
* @return Computed angular velocity
*/
double angularVelocity(unsigned int val);

View File

@ -29,7 +29,7 @@
namespace upm {
/**
* @brief Spectra Symbol Flex sensor library
* @brief Spectra Symbol Flex Sensor library
* @defgroup flex libupm-flex
* @ingroup sparkfun analog flexfor
*/
@ -43,14 +43,14 @@ namespace upm {
* @web https://www.sparkfun.com/products/8606
* @con analog
*
* @brief API for the Spectra Symbol Flex sensor
* @brief API for the Spectra Symbol Flex Sensor
*
* A simple flex sensor, the resistance across the sensor increases when
* bent. Patented technology by Spectra Symbol, these sensors were used in
* the original Nintendo Power Glove.
* A simple flex sensor. The resistance across the sensor increases when
* flexed. Patented technology by Spectra Symbol, these sensors were used in
* the original Nintendo* Power Glove.
*
* @image html flex.jpg
* <br><em>Flex Sensor image provided by SparkFun under
* <br><em>Flex Sensor image provided by SparkFun* under
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
* CC BY-NC-SA-3.0</a>.</em>
*
@ -61,15 +61,15 @@ namespace upm {
/**
* Flex sensor constructor
*
* @param pin analog pin to use
* @param pin Analog pin to use
*/
Flex(int pin);
/**
* Flex Destructor
* Flex sensor destructor
*/
~Flex();
/**
* @return the analog flex value
* @return Analog flex value
*/
int value();

View File

@ -35,20 +35,20 @@ struct thresholdContext {
namespace upm {
/**
* @brief Gas sensor library
* @brief Gas Sensor library
*
* Sensor Library for air quality and gas detecting sensors. Base class Gas provides buffered
* sampling, threshold checking, a basic printing function and a standard read function.
* Library for air quality and gas detecting sensors. Base class Gas provides buffered
* sampling, threshold checking, basic printing function, and standard read function.
*
* @defgroup gas libupm-gas
* @ingroup seeed analog gaseous
* @ingroup seeed analog gaseous eak hak
*/
class Gas {
public:
/**
* Instantiates a Gas object
*
* @param gasPin pin where gas is connected
* @param gasPin Pin where gas is connected
*/
Gas(int gasPin);
@ -58,45 +58,45 @@ class Gas {
~Gas();
/**
* Get samples from gas sensor according to provided window and
* Gets samples from the gas sensor according to the provided window and
* number of samples
*
* @param freqMS time between each sample (in milliseconds)
* @param numberOfSamples number of sample to sample for this window
* @param buffer buffer with sampled data
* @param freqMS Time between each sample (in milliseconds)
* @param numberOfSamples Number of sample to sample for this window
* @param buffer Buffer with sampled data
*/
virtual int getSampledWindow (unsigned int freqMS, unsigned int numberOfSamples, uint16_t * buffer);
/**
* Given sampled buffer this method will return TRUE/FALSE if threshold
* was reached
* Given the sampled buffer, this method returns TRUE/FALSE if the threshold
* is reached
*
* @param ctx threshold context
* @param threshold sample threshold
* @param buffer buffer with samples
* @param len buffer length
* @param ctx Threshold context
* @param threshold Sample threshold
* @param buffer Buffer with samples
* @param len Buffer length
*/
virtual int findThreshold (thresholdContext* ctx, unsigned int threshold, uint16_t * buffer, unsigned int len);
/**
* Return average data for the sampled window
* Returns average data for the sampled window
*
* @param ctx threshold context
* @param ctx Threshold context
*/
virtual int getSampledData (thresholdContext* ctx);
/**
* Return one sample from the sensor
* Returns one sample from the sensor
*
* @param ctx threshold context
* @param ctx Threshold context
*/
virtual int getSample ();
/**
*
* Print running average of threshold context
* Prints a running average of the threshold context
*
* @param ctx threshold context
* @param ctx Threshold context
*/
virtual void printGraph (thresholdContext* ctx, uint8_t resolution);

View File

@ -35,13 +35,14 @@ namespace upm {
* @type gaseous
* @man seeed
* @con analog
* @kit hak
*
* @brief API for MQ2 Gas Sensor
* @brief API for the Grove MQ2 Gas Sensor
*
* The Grove - Gas Sensor (MQ2) module is useful for gas leakage detecting
* The Grove MQ2 Gas Sensor module is useful for gas leakage detection
* (in home and industry). It can detect LPG, i-butane, methane, alcohol,
* Hydrogen, smoke and other combustible gases. It's a medium sensitivity
* sensor with a detect concentration of 300-10000 ppm.
* hydrogen, smoke, and other combustible gases. It's a medium-sensitivity
* sensor with a detection range of 300-10,000 ppm.
*
* @image html mq2-5.jpeg
* @snippet mq2.cxx Interesting
@ -51,7 +52,7 @@ namespace upm {
/**
* MQ2 constructor
*
* @param gasPin analog pin where sensor is connected
* @param gasPin Analog pin where the sensor is connected
*/
MQ2 (int gasPin);
@ -61,7 +62,7 @@ namespace upm {
~MQ2 ();
/**
* Return name of the component
* Returns the name of the sensor
*/
std::string name()
{

View File

@ -36,12 +36,12 @@ namespace upm {
* @man seeed
* @con analog
*
* @brief API for MQ3 Gas Sensor
* @brief API for the MQ3 Gas Sensor
*
* The Grove MQ3 Gas Sensor module is useful for gas leakage detecting (in
* home and industry). It can detect Alcohol Vapour and Benzine. It's
* The Grove MQ3 Gas Sensor module is useful for gas leakage detection (in
* home and industry). It can detect alcohol vapors and benzine. It's
* highly sensitive but has a long warm-up time of about 1 minute. It's
* detect rate is of 0.04-4 mg/L Alcohol.
* detection range is 0.04-4 mg/L Alcohol.
*
* @image html mq3-9.jpeg
* @snippet mq3.cxx Interesting
@ -51,7 +51,7 @@ namespace upm {
/**
* MQ3 constructor
*
* @param gasPin analog pin where sensor is connected
* @param gasPin Analog pin where the sensor is connected
*/
MQ3 (int gasPin);
@ -61,7 +61,7 @@ namespace upm {
~MQ3 ();
/**
* Return name of the component
* Returns the name of the sensor
*/
std::string name()
{

View File

@ -35,13 +35,14 @@ namespace upm {
* @type gaseous
* @man seeed
* @con analog
* @kit eak
*
* @brief API for MQ5 Gas Sensor
* @brief API for the MQ5 Gas Sensor
*
* The Grove - Gas Sensor (MQ5) module is useful for gas leakage detecting
* (in home and industry). It can detect LPG, natural gas, town gas and so
* on. It is highly sensitive and has a detection concentration of
* 300-10000 ppm.
* The Grove MQ5 Gas Sensor module is useful for gas leakage detection
* (in home and industry). It can detect LPG, natural gas, town gas, and so
* on. It is highly sensitive and has a detection range of
* 300-10,000 ppm.
*
* @image html mq2-5.jpeg
* @snippet mq5.cxx Interesting
@ -51,7 +52,7 @@ namespace upm {
/**
* MQ5 constructor
*
* @param gasPin analog pin where sensor is connected
* @param gasPin Analog pin where the sensor is connected
*/
MQ5 (int gasPin);
@ -61,7 +62,7 @@ namespace upm {
~MQ5 ();
/**
* Return name of the component
* Returns the name of the sensor
*/
std::string name()
{

View File

@ -36,11 +36,11 @@ namespace upm {
* @man seeed
* @con analog
*
* @brief API for MQ9 Gas Sensor
* @brief API for the MQ9 Gas Sensor
*
* The Grove MQ9 Gas Sensor module is useful for gas leakage detecting (in
* home and industry). It can detect Carbon Monoxide, Coal Gas and
* Liquefied Gas. It's sensitivity is 10-1000 ppm CO, 100-10000 ppm Gas.
* The Grove MQ9 Gas Sensor module is useful for gas leakage detection (in
* home and industry). It can detect carbon monoxide, coal gas, and
* liquefied gas. Its sensitivity is 10-1,000 ppm CO, and 100-10,000 ppm Gas.
*
* @image html mq3-9.jpeg
* @snippet mq9.cxx Interesting
@ -48,9 +48,9 @@ namespace upm {
class MQ9 : public Gas {
public:
/**
* Jhd1313m1 constructor
* MQ9 constructor
*
* @param gasPin analog pin where sensor is connected
* @param gasPin Analog pin where the sensor is connected
*/
MQ9 (int gasPin);
@ -60,7 +60,7 @@ namespace upm {
~MQ9 ();
/**
* Return name of the component
* Returns the name of the sensor
*/
std::string name()
{

View File

@ -36,15 +36,16 @@ namespace upm {
* @type gaseous
* @man seeed
* @con analog
* @kit hak
*
* @brief API for Grove TP401 Air Quality Sensor
* @brief API for the Grove TP401 Air Quality Sensor
*
* The Grove TP401 Air Quality Sensor module is useful for monitoring air purity indoors.
* It can detect CO and a wide range of other harmful gases, but due to limited sensing
* range should be used only when qualitative results are needed. Example applications
* It can detect CO and a wide range of other harmful gases, but, due to a limited detection
* range, it should be used only when qualitative results are needed. Example applications
* are air recirculation, ventilation systems, and refreshing sprayers.
* The sensor is linear and should be roughly sensitive to 0 ~ 20 ppm CO from 0 ~ 4V.
* Also note that the sensor requires 2-3 minutes to warm up initially and 48 hours of
* The sensor is linear and should be roughly sensitive to 0-20 ppm CO from 0-4 V.
* Note: the sensor requires 2-3 minutes to warm up initially and 48 hours of
* operation to stabilize completely.
*
* @image html tp401.jpeg
@ -55,7 +56,7 @@ namespace upm {
/**
* TP401 constructor
*
* @param gasPin analog pin where sensor was connected
* @param gasPin Analog pin where the sensor is connected
*/
TP401 (int gasPin);
@ -65,9 +66,9 @@ namespace upm {
~TP401 ();
/**
* Return name of the component
* Returns the name of the sensor
*
* @return a string with the name of the sensor
* @return Name of the sensor
*/
std::string name()
{
@ -76,9 +77,9 @@ namespace upm {
/**
* Returns one sample in parts per million (ppm) of CO in the air based on
* the following sensor calibration: 0 ~ 4V is roughly 0 ~ 20 ppm CO
* the following sensor calibration: 0-4 V is roughly 0-20 ppm CO
*
* @return a new sample converted to ppm CO
* @return New sample converted to ppm CO
*/
float getPPM();

View File

@ -29,7 +29,7 @@
namespace upm {
/**
* @brief GP2Y0A based IR proximity sensor library
* @brief GP2Y0A-based IR Proximity Sensor library
* @defgroup gp2y0a libupm-gp2y0a
* @ingroup seeed analog light
*/
@ -45,8 +45,8 @@ namespace upm {
*
* @brief API for the GP2Y0A family of IR Proximity Sensors
*
* This sensor family returns an analog voltage corresponding to the distance
* of an object from the sensor. The voltage is lower when objects
* Sensors of this family return an analog voltage corresponding to the distance
* of an object from the sensor. The voltage is lower when objects
* are far away; the voltage increases as objects get closer
* to the sensor.
*
@ -59,21 +59,21 @@ namespace upm {
/**
* GP2Y0A sensor constructor
*
* @param pin analog pin to use
* @param pin Analog pin to use
*/
GP2Y0A(int pin);
/**
* GP2Y0A Destructor
* GP2Y0A destructor
*/
~GP2Y0A();
/**
* Get the averaged voltage value from the sensor
* Gets an average voltage value from the sensor
*
* @param aref the reference voltage in use (5.0 or 3.3 usually)
* @param samples number of samples to average over
* @return the averaged voltage reading
* @param aref Reference voltage in use (usually 5.0V or 3.3V)
* @param samples Number of samples to average over
* @return Average voltage reading
*/
float value(float aref, uint8_t samples);

View File

@ -32,9 +32,9 @@
namespace upm {
/**
* @brief generic library for basic grove sensors
* @brief Generic library for basic Grove sensors
* @defgroup grove libupm-grove
* @ingroup seeed gpio pwm ainput button led light relay temp touch gsk
* @ingroup seeed gpio pwm ainput button led light relay temp touch gsk eak hak
*/
class Grove {
public:
@ -48,14 +48,14 @@ class Grove {
};
/**
* @brief API for Grove LED
* @brief API for the Grove LED
*
* UPM module for Grove LED (or other similar light-emitting diode).
* An LED is a small lightbulb that will emit light (turn on) in
* response to a small curent. The longer wire of an LED connects
* UPM module for the Grove LED (or other similar light-emitting diodes).
* An LED is a small lightbulb that emits light in
* response to a small current. The longer wire of an LED connects
* to the positive seat (anode); the shorter wire connects to the
* negative seat (cathode). The flat side of the bulb corresponds
* to the cathode while the rounded side corresponds to the anode.
* negative seat (cathode). The flat side of the bulb corresponds
* to the cathode, while the rounded side corresponds to the anode.
*
* @ingroup grove gpio
* @snippet groveled.cxx Interesting
@ -67,7 +67,7 @@ class GroveLed: public Grove {
/**
* Grove LED constructor
*
* @param gpio pin to use
* @param gpio Pin to use
*/
GroveLed(int pin);
/**
@ -75,27 +75,27 @@ class GroveLed: public Grove {
*/
~GroveLed();
/**
* Turn the LED on or off, depending on the value.
* Turns the LED on or off, depending on the value.
* If the value is positive (greater than or equal
* to 1), the LED is turned on. Otherwise, for 0
* or negative values, the LED is turned off.
*
* @param value tells the LED to turn on (for value >=1)
* or off (for value <1)
* @param value Tells the LED to turn on (for values >=1)
* or off (for values <1)
*
* @return 0 on success; non-zero otherwise
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t write(int value);
/**
* Turn the LED off
* Turns the LED off
*
* @return 0 on success; non-zero otherwise
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t off();
/**
* Turn the LED on
* Turns the LED on
*
* @return 0 on success; non-zero otherwise
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t on();
private:
@ -103,12 +103,12 @@ class GroveLed: public Grove {
};
/**
* @brief API for Grove Relay
* @brief API for the Grove Relay
*
* UPM module for Grove relay switch. The Grove relay is a
* UPM module for the Grove relay switch. Grove relay is a
* digital normally-open switch that uses low voltage or current to
* control a higher voltage and/or higher current. When closed,
* the indicator LED will light up and current is allowed to flow.
* the indicator LED lights up and current is allowed to flow.
*
* @ingroup grove gpio
* @snippet groverelay.cxx Interesting
@ -119,7 +119,7 @@ class GroveRelay: public Grove {
/**
* Grove relay constructor
*
* @param gpio pin to use
* @param gpio Pin to use
*/
GroveRelay(unsigned int pin);
/**
@ -127,29 +127,29 @@ class GroveRelay: public Grove {
*/
~GroveRelay();
/**
* Set the relay switch to on (close). This allows current
* Sets the relay switch to on (closed). This allows current
* to flow and lights up the indicator LED.
*
* @return 0 on success; non-zero otherwise
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t on();
/**
* Set the relay switch to off (open). This stops current
* from flowing and the indicator LED will not be lit.
* Sets the relay switch to off (open). This stops current
* from flowing and the indicator LED is not lit.
*
* @return 0 on success; non-zero otherwise
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t off();
/**
* Returns whether or not the relay switch is closed.
* Defines whether the relay switch is closed.
*
* @return true if the switch is on (closed); false otherwise
* @return True if the switch is on (closed), false otherwise
*/
bool isOn();
/**
* Returns whether or not the relay switch is open.
* Defines whether the relay switch is open.
*
* @return true if the switch is off (open); false otherwise
* @return True if the switch is off (open), false otherwise
*/
bool isOff();
private:
@ -157,9 +157,9 @@ class GroveRelay: public Grove {
};
/**
* @brief API for Grove temperature sensor
* @brief API for the Grove Temperature Sensor
*
* Very basic UPM module for Grove temperature sensor on analog
* Basic UPM module for the Grove temperature sensor on analog
*
* @ingroup grove analog
* @snippet grovetemp.cxx Interesting
@ -170,7 +170,7 @@ class GroveTemp: public Grove {
/**
* Grove analog temperature sensor constructor
*
* @param pin analog pin to use
* @param pin Analog pin to use
*/
GroveTemp(unsigned int pin);
/**
@ -178,15 +178,15 @@ class GroveTemp: public Grove {
*/
~GroveTemp();
/**
* Get raw value from AIO pin
* Gets the raw value from the AIO pin
*
* @return the raw value from the ADC
* @return Raw value from the ADC
*/
float raw_value();
/**
* Get the temperature in Celsius from the sensor
* Gets the temperature in Celsius from the sensor
*
* @return the normalized temperature in Celsius
* @return Normalized temperature in Celsius
*/
int value();
private:
@ -194,12 +194,12 @@ class GroveTemp: public Grove {
};
/**
* @brief API for Grove light sensor
* @brief API for the Grove Light Sensor
*
* The Grove light sensor detects the intensity of the ambient light.
* As the light intensity of the environment increases, the resistance
* of the sensor decreases. This means that the raw value from the
* analog pin will be larger in bright light and smaller in the dark.
* of the sensor decreases. This means the raw value from the
* analog pin is greater in bright light and smaller in the dark.
* An approximate lux value can also be returned.
*
* @ingroup grove analog
@ -211,23 +211,23 @@ class GroveLight: public Grove {
/**
* Grove analog light sensor constructor
*
* @param pin analog pin to use
* @param pin Analog pin to use
*/
GroveLight(unsigned int pin);
/**
* GroveLight Destructor
* GroveLight destructor
*/
~GroveLight();
/**
* Get raw value from AIO pin
* Gets the raw value from the AIO pin
*
* @return the raw value from the ADC
* @return Raw value from the ADC
*/
float raw_value();
/**
* Get the approximate light value, in lux, from the sensor
* Gets an approximate light value, in lux, from the sensor
*
* @return the normalized light reading in lux
* @return Normalized light reading in lux
*/
int value();
private:
@ -235,11 +235,11 @@ class GroveLight: public Grove {
};
/**
* @brief API for Grove Rotary Angle Sensor (Knob)
* @brief API for the Grove Rotary Angle Sensor (Knob)
*
* Very basic UPM module for Grove rotary angle sensor (knob) on analog. Provides
* a set of functions to read the absolute pin value, degrees or radians and another
* to do the same relative to the center of the knob's range.
* Basic UPM module for the Grove rotary angle sensor (knob) on analog. Provides
* a set of functions to read the absolute pin value, degrees or radians, and another set
* to do the same relative to the center of the knob range.
*
* @ingroup grove analog
* @snippet groverotary.cxx Interesting
@ -250,47 +250,47 @@ class GroveRotary: public Grove {
/**
* Grove rotary angle sensor constructor
*
* @param pin number of analog pin to use
* @param pin Number of the analog pin to use
*/
GroveRotary(unsigned int pin);
/**
* GroveRotary Destructor
* GroveRotary destructor
*/
~GroveRotary();
/**
* Get absolute raw value from AIO pin
* Gets the absolute raw value from the AIO pin
*
* @return the unsigned value from the ADC
* @return Unsigned value from the ADC
*/
float abs_value();
/**
* Get absolute raw degrees from AIO pin
* Gets absolute raw degrees from the AIO pin
*
* @return the unsigned degrees from the ADC
* @return Unsigned degrees from the ADC
*/
float abs_deg();
/**
* Get absolute raw radians from AIO pin
* Gets absolute raw radians from the AIO pin
*
* @return the unsigned radians from the ADC
* @return Unsigned radians from the ADC
*/
float abs_rad();
/**
* Get the relative value from the pin
* Gets the relative value from the AIO pin
*
* @return the signed value from the ADC
* @return Signed value from the ADC
*/
float rel_value();
/**
* Get relative degrees from AIO pin
* Gets relative degrees from the AIO pin
*
* @return the signed degrees from the ADC
* @return Signed degrees from the ADC
*/
float rel_deg();
/**
* Get relative radians from AIO pin
* Gets relative radians from the AIO pin
*
* @return the signed radians from the ADC
* @return Signed radians from the ADC
*/
float rel_rad();
private:
@ -299,10 +299,10 @@ class GroveRotary: public Grove {
};
/**
* @brief API for Grove Slide Potentiometer
* @brief API for the Grove Slide Potentiometer
*
* Very basic UPM module for Grove slide potentiometer on analog,
* returns either raw value or scaled voltage value.
* Basic UPM module for the Grove slide potentiometer on analog that
* returns either a raw value or a scaled voltage value.
*
* @ingroup grove analog
* @snippet groveslide.cxx Interesting
@ -313,31 +313,31 @@ class GroveSlide: public Grove {
/**
* Grove analog slide potentiometer constructor
*
* @param pin number of analog pin to use
* @param pin Number of the analog pin to use
*
* @param ref_voltage the reference voltage the board is set to as float, e.g. 3.3 or 5.0 (default)
* @param ref_voltage Reference voltage the board is set to, as a floating-point value; default is 5.0V
*/
GroveSlide(unsigned int pin, float ref_voltage = 5.0);
/**
* GroveSlide Destructor
* GroveSlide destructor
*/
~GroveSlide();
/**
* Get raw value from AIO pin
* Gets the raw value from the AIO pin
*
* @return the raw value from the ADC
* @return Raw value from the ADC
*/
float raw_value();
/**
* Get the voltage value from the pin
* Gets the voltage value from the pin
*
* @return the voltage reading based on the reference voltage
* @return Voltage reading based on the reference voltage
*/
float voltage_value();
/**
* Get the board's reference voltage passed on object initialization
* Gets the board's reference voltage passed on object initialization
*
* @return the reference voltage the class was set for
* @return Reference voltage the class was set for
*/
float ref_voltage();
private:
@ -346,9 +346,9 @@ class GroveSlide: public Grove {
};
/**
* @brief API for Grove button
* @brief API for the Grove Button
*
* Very basic UPM module for Grove button
* Basic UPM module for the Grove button
*
* @ingroup grove gpio
* @snippet grovebutton.cxx Interesting
@ -359,7 +359,7 @@ class GroveButton: public Grove {
/**
* Grove button constructor
*
* @param gpio pin to use
* @param gpio Pin to use
*/
GroveButton(unsigned int pin);
/**
@ -367,15 +367,15 @@ class GroveButton: public Grove {
*/
~GroveButton();
/**
* Get name of sensor
* Gets the name of the sensor
*
* @return the name of this sensor
* @return Name of this sensor
*/
std::string name();
/**
* Get value from GPIO pin
* Gets the value from the GPIO pin
*
* @return the value from the GPIO pin
* @return Value from the GPIO pin
*/
int value();
private:

View File

@ -33,9 +33,10 @@
* @con gpio
* @kit gsk
*
* @brief API for Grove Button
* @brief API for the Grove Button
*
* Basic UPM module for the Grove button
*
* Very basic UPM module for Grove button
* @image html grovebutton.jpg
* @snippet grovebutton.cxx Interesting
*/

View File

@ -32,16 +32,16 @@
* @con gpio
* @kit gsk
*
* @brief API for Grove LED
* @brief API for the Grove LED
*
* UPM module for Grove LED (or other similar light-emitting diode).
* An LED is a small lightbulb that will emit light (turn on) in
* response to a small curent. The longer wire of an LED connects
* UPM module for the Grove LED (or other similar light-emitting diodes).
* An LED is a small lightbulb that emits light in
* response to a small current. The longer wire of an LED connects
* to the positive seat (anode); the shorter wire connects to the
* negative seat (cathode). The flat side of the bulb corresponds
* to the cathode while the rounded side corresponds to the anode.
* negative seat (cathode). The flat side of the bulb corresponds
* to the cathode, while the rounded side corresponds to the anode.
*
* @image html groveled.h
* @image html groveled.jpg
* @snippet groveled.cxx Interesting
* @snippet groveled-multi.cxx Interesting
*/

View File

@ -32,12 +32,12 @@
* @con analog
* @kit gsk
*
* @brief API for Grove Light Sensor
* @brief API for the Grove Light Sensor
*
* The Grove light sensor detects the intensity of the ambient light.
* As the light intensity of the environment increases, the resistance
* of the sensor decreases. This means that the raw value from the
* analog pin will be larger in bright light and smaller in the dark.
* of the sensor decreases. This means the raw value from the
* analog pin is larger in bright light and smaller in the dark.
* An approximate lux value can also be returned.
*
* @image html grovelight.jpg

View File

@ -30,14 +30,14 @@
* @type relay
* @man seeed
* @con gpio
* @kit gsk
* @kit gsk eak hak
*
* @brief API for Grove Relay
* @brief API for the Grove Relay
*
* UPM module for Grove relay switch. The Grove relay is a
* UPM module for the Grove relay switch. The Grove relay is a
* digital normally-open switch that uses low voltage or current to
* control a higher voltage and/or higher current. When closed,
* the indicator LED will light up and current is allowed to flow.
* the indicator LED lights up and current is allowed to flow.
*
* @image html groverelay.jpg
* @snippet groverelay.cxx Interesting

View File

@ -31,11 +31,12 @@
* @type ainput
* @man seeed
* @con analog
* @kit gsk
*
* @brief API for Grove Rotary Angle Sensor (Knob)
* @brief API for the Grove Rotary Angle Sensor (Knob)
*
* Very basic UPM module for Grove rotary angle sensor (knob) on analog. Provides
* a set of functions to read the absolute pin value, degrees or radians and another
* Basic UPM module for the Grove rotary angle sensor (knob) on analog. Provides
* a set of functions to read the absolute pin value, degrees or radians, and another set
* to do the same relative to the center of the knob's range.
*
* @image html groverotary.jpeg

View File

@ -31,10 +31,10 @@
* @man seeed
* @con analog
*
* @brief API for Grove Slide Potentiometer
* @brief API for the Grove Slide Potentiometer
*
* Very basic UPM module for Grove slide potentiometer on analog,
* returns either raw value or scaled voltage value.
* Basic UPM module for the Grove slide potentiometer on analog that
* returns either a raw value or a scaled voltage value.
*
* @image html groveslide.jpeg
* @snippet groveslide.cxx Interesting

View File

@ -32,11 +32,11 @@
* @con analog
* @kit gsk
*
* @brief API for Grove Temperature Sensor
* @brief API for the Grove Temperature Sensor
*
* Very basic UPM module for Grove temperature sensor on analog
* Basic UPM module for the Grove temperature sensor on analog
*
* @image html grovetemp.h
* @image html grovetemp.jpg
* @snippet grovetemp.cxx Interesting
*/

View File

@ -0,0 +1,5 @@
set (libname "grovecircularled")
set (libdescription "upm grove circular led")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -0,0 +1,164 @@
/*
* Author: Jun Kato and Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Contributions: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* This module is based on the my9221 driver
*
* 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 <stdlib.h>
#include "grovecircularled.h"
using namespace upm;
GroveCircularLED::GroveCircularLED (uint8_t di, uint8_t dcki) {
mraa_result_t error = MRAA_SUCCESS;
// init clock context
m_clkPinCtx = mraa_gpio_init(dcki);
if (m_clkPinCtx == NULL) {
fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", dcki);
exit(1);
}
mraa_gpio_use_mmaped(m_clkPinCtx, 1);
// init data context
m_dataPinCtx = mraa_gpio_init(di);
if (m_dataPinCtx == NULL) {
fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", di);
exit(1);
}
mraa_gpio_use_mmaped(m_dataPinCtx, 1);
// set direction (out)
error = mraa_gpio_dir(m_clkPinCtx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
mraa_result_print(error);
}
// set direction (out)
error = mraa_gpio_dir(m_dataPinCtx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
mraa_result_print(error);
}
}
GroveCircularLED::~GroveCircularLED() {
mraa_result_t error = MRAA_SUCCESS;
error = mraa_gpio_close (m_dataPinCtx);
if (error != MRAA_SUCCESS) {
mraa_result_print(error);
}
error = mraa_gpio_close (m_clkPinCtx);
if (error != MRAA_SUCCESS) {
mraa_result_print(error);
}
}
mraa_result_t
GroveCircularLED::setSpinner (uint8_t position) {
if (position < 0 || position >= 24) {
return MRAA_ERROR_INVALID_PARAMETER;
}
for(uint8_t block_idx = 0; block_idx < 24; block_idx++) {
if (block_idx % 12 == 0) {
send16bitBlock (CMDMODE);
}
uint32_t state = (block_idx == position) ? BIT_HIGH : BIT_LOW;
send16bitBlock (state);
}
return lockData ();
}
mraa_result_t
GroveCircularLED::setLevel (uint8_t level, bool direction) {
if (level < 0 || level > 24) {
return MRAA_ERROR_INVALID_PARAMETER;
}
if (direction) {
for(uint8_t block_idx = 24; block_idx > 0; block_idx--) {
if (block_idx % 12 == 0) {
send16bitBlock (CMDMODE);
}
uint32_t state = (block_idx <= level) ? BIT_HIGH : BIT_LOW;
send16bitBlock (state);
}
} else {
for(uint8_t block_idx = 0; block_idx < 24; block_idx++) {
if (block_idx % 12 == 0) {
send16bitBlock (CMDMODE);
}
uint32_t state = (block_idx <= level - 1) ? BIT_HIGH : BIT_LOW;
send16bitBlock (state);
}
}
return lockData ();
}
mraa_result_t
GroveCircularLED::setStatus (bool status[24]) {
for(uint8_t block_idx = 0; block_idx < 24; block_idx++) {
if (block_idx % 12 == 0) {
send16bitBlock (CMDMODE);
}
send16bitBlock (status[block_idx] ? BIT_HIGH : BIT_LOW);
}
return lockData ();
}
mraa_result_t
GroveCircularLED::lockData () {
mraa_result_t error = MRAA_SUCCESS;
error = mraa_gpio_write (m_dataPinCtx, LOW);
usleep(10);
for(int idx = 0; idx < 4; idx++) {
error = mraa_gpio_write (m_dataPinCtx, HIGH);
error = mraa_gpio_write (m_dataPinCtx, LOW);
}
return error;
}
mraa_result_t
GroveCircularLED::send16bitBlock (short data) {
mraa_result_t error = MRAA_SUCCESS;
for (uint8_t bit_idx = 0; bit_idx < MAX_BIT_PER_BLOCK; bit_idx++) {
uint32_t state = (data & 0x8000) ? HIGH : LOW;
error = mraa_gpio_write (m_dataPinCtx, state);
state = mraa_gpio_read (m_clkPinCtx);
if (state) {
state = LOW;
} else {
state = HIGH;
}
error = mraa_gpio_write (m_clkPinCtx, state);
data <<= 1;
}
return error;
}

View File

@ -0,0 +1,119 @@
/*
* Author: Jun Kato and Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Contributions: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* This module is based on the my9221 driver
*
* 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.
*/
#pragma once
#include <string>
#include <mraa/aio.h>
#include <mraa/gpio.h>
#define MAX_BIT_PER_BLOCK 16
#define CMDMODE 0x0000
#define BIT_HIGH 0x00ff
#define BIT_LOW 0x0000
#define HIGH 1
#define LOW 0
namespace upm {
/**
* @brief Grove Circular LED library
* @defgroup grovecircularled libupm-grovecircularled
* @ingroup seeed display gpio
*/
/**
* @library grovecircularled
* @sensor grovecircularled
* @comname Grove Circular LED
* @type display
* @man seeed
* @web http://www.seeedstudio.com/wiki/Grove_-_Circular_LED
* @con gpio
*
* @brief API for the Grove Circular LED module
*
* This is a circular LED ring based on the MY9221 chip. It is often used
* with a rotary encoder and has 24 controllable LEDs.
*
* @image html grovecircularled.jpg
* @snippet grovecircularled.cxx Interesting
*/
class GroveCircularLED {
public:
/**
* Instantiates an MY9221 object
*
* @param di Data pin
* @param dcki Clock pin
*/
GroveCircularLED (uint8_t di, uint8_t dcki);
/**
* MY9221 object destructor
*/
~GroveCircularLED ();
/**
* Sets the lighting status
*
* @param level Selected level for the circular LED (0-24)
* @param direction Up or down; up is true and default
*/
mraa_result_t setLevel (uint8_t level, bool direction=true);
/**
* Sets the spinner (lights up all the other LEDs but one)
*
* @param position Selected position for the spinner (0-23)
*/
mraa_result_t setSpinner (uint8_t position);
/**
* Sets the lighting status
*
* @param status Boolean array (24 elements)
*/
mraa_result_t setStatus (bool status[24]);
/**
* Returns the name of the component
*/
std::string name()
{
return m_name;
}
private:
mraa_result_t lockData ();
mraa_result_t send16bitBlock (short data);
std::string m_name;
mraa_gpio_context m_clkPinCtx;
mraa_gpio_context m_dataPinCtx;
};
}

View File

@ -0,0 +1,8 @@
%module jsupm_grovecircularled
%include "../upm.i"
%{
#include "grovecircularled.h"
%}
%include "grovecircularled.h"

View File

@ -0,0 +1,9 @@
%module pyupm_grovecircularled
%include "../upm.i"
%feature("autodoc", "3");
%include "grovecircularled.h"
%{
#include "grovecircularled.h"
%}

View File

@ -27,7 +27,7 @@
namespace upm {
/**
* @brief Grove Collision sensor library
* @brief Grove Collision Sensor library
* @defgroup grovecollision libupm-grovecollision
* @ingroup seeed gpio accelerometer
*/
@ -44,7 +44,7 @@ namespace upm {
*
* The Grove Collision Sensor can detect whether any
* collision movement or vibration happens.
* It will output a low pulse signal when vibration is detected.
* It outputs a low pulse signal when vibration is detected.
*
* @image html grovecollision.jpg
* @snippet grovecollision.cxx Interesting
@ -52,17 +52,17 @@ namespace upm {
class GroveCollision {
public:
/**
* Grove Collision Constructor
* Grove collision sensor constructor
*
* @param pin digital pin to use
* @param pin Digital pin to use
*/
GroveCollision(int pin);
/**
* Grove Collision Destructor
* GroveCollision destructor
*/
~GroveCollision();
/**
* @return bool returns whether something is colliding with sensor
* @return bool Defines whether something is colliding with sensor
*/
bool isColliding();

View File

@ -30,7 +30,7 @@
namespace upm {
/**
* @brief Grove Ear-clip Heart Rate sensor library
* @brief Grove Ear-clip Heart Rate Sensor library
* @defgroup groveehr libupm-groveehr
* @ingroup seeed gpio medical
*/
@ -43,10 +43,10 @@ namespace upm {
* @man seeed
* @con gpio
*
* @brief API for the Grove Ear-clip Heart Rate sensor
* @brief API for the Grove Ear-clip Heart Rate Sensor
*
* UPM module for the GroveEHR sensor. It is used to measure your
* heartbeat.
* UPM module for the Grove ear-clip heart rate sensor. It is used to measure your
* heart rate.
*
* @image html groveehr.jpg
* @snippet groveehr.cxx Interesting
@ -56,63 +56,63 @@ namespace upm {
/**
* GroveEHR constructor
*
* @param pin digital pin to use
* @param pin Digital pin to use
*/
GroveEHR(int pin);
/**
* GroveEHR Destructor
* GroveEHR destructor
*/
~GroveEHR();
/**
* Return the number of milliseconds elapsed since initClock()
* Returns the time of milliseconds elapsed since initClock()
* was last called.
*
* @return elapsed milliseconds
* @return Elapsed milliseconds
*/
uint32_t getMillis();
/**
* Reset the Clock
* Resets the clock
*
*/
void initClock();
/**
* Reset the beat counter to 0. The beat Counter should be
* Resets the beat counter to 0. The beat counter should be
* stopped via stopBeatCounter() prior to calling this function.
*
*/
void clearBeatCounter();
/**
* Start the beat counter
* Starts the beat counter
*
*/
void startBeatCounter();
/**
* Stop the beat counter
* Stops the beat counter
*
*/
void stopBeatCounter();
/**
* Get the beat Counter
* Gets the beat Counter
*
* @return the beat counter
* @return Beat counter
*/
uint32_t beatCounter();
/**
* Beat Interrupt Service Routine
* Beat interrupt service routine (ISR)
*
*/
static void beatISR(void *ctx);
/**
* Compute the heart rate
* Computes the heart rate
*
* @return the computed heart rate
* @return Computed heart rate
*/
int heartRate();

View File

@ -30,7 +30,7 @@
namespace upm {
/**
* @brief Grove El Driver module library
* @brief Grove EL Driver Module library
* @defgroup groveeldriver libupm-groveeldriver
* @ingroup seeed gpio electric
*/
@ -38,15 +38,15 @@ namespace upm {
/**
* @library groveeldriver
* @sensor groveeldriver
* @comname Grove El Driver
* @comname Grove EL Driver
* @type electric
* @man seeed
* @con gpio
*
* @brief API for the Grove El Driver Module
* @brief API for the Grove EL Driver Module
*
* The Grove EL Driver allows you to easily light up an
* EL Wire with just one single Grove cable.
* EL wire with just one single Grove cable.
*
* @image html groveeldriver.jpg
* @snippet groveeldriver.cxx Interesting
@ -54,21 +54,21 @@ namespace upm {
class GroveElDriver {
public:
/**
* Grove El Driver Constructor
* Grove EL Driver constructor
*
* @param pin digital pin to use
* @param pin Digital pin to use
*/
GroveElDriver(int pin);
/**
* Grove El Driver Destructor
* Grove EL Driver destructor
*/
~GroveElDriver();
/**
* Turn el wire on
* Turns the EL wire on
*/
void on();
/**
* Turn el wire off
* Turns the EL wire off
*/
void off();

View File

@ -45,7 +45,7 @@ namespace upm {
*
* @brief API for the Grove Electromagnet
*
* The Grove Electromagnet can hold up to 1 KG (approximately 2.2 lbs)
* The Grove Electromagnet can hold up to 1 kg (approximately 2.2 lbs)
*
* @image html groveelectromagnet.jpg
* @snippet groveelectromagnet.cxx Interesting
@ -53,21 +53,21 @@ namespace upm {
class GroveElectromagnet {
public:
/**
* Grove Electromagnet Constructor
* Grove Electromagnet constructor
*
* @param pin digital pin to use
* @param pin Digital pin to use
*/
GroveElectromagnet(int pin);
/**
* Grove Electromagnet Destructor
* Grove Electromagnet destructor
*/
~GroveElectromagnet();
/**
* Turn magnet on
* Turns the magnet on
*/
void on();
/**
* Turn magnet off
* Turns the magnet off
*/
void off();

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