Compare commits
99 Commits
Author | SHA1 | Date | |
---|---|---|---|
58c800e246 | |||
48a8d3e0cc | |||
1fe9b9eb1d | |||
04edb9be04 | |||
55e8076988 | |||
9db2d57de3 | |||
de49bb0e42 | |||
93595bcd35 | |||
7260c78c33 | |||
197b56003c | |||
f133b6eb4c | |||
cb62f06197 | |||
a2e4fb5d7a | |||
36b0e1dce0 | |||
03e72e02f8 | |||
6613dea552 | |||
ef173ebeaf | |||
5a6fb122ec | |||
8462e8ce52 | |||
1647f572ff | |||
56f7e97536 | |||
3aaafdcecf | |||
99651d2239 | |||
c586cd5177 | |||
fc3a884024 | |||
a91f1e5095 | |||
2314bc2f59 | |||
af2281057a | |||
e85c98062b | |||
c1cde01424 | |||
54cda32a94 | |||
2e36b8dc21 | |||
f4a5c9a391 | |||
08ff50067a | |||
cff584d8b9 | |||
abb9c91320 | |||
a03d0c7e95 | |||
231a1f1b43 | |||
c313e3ae69 | |||
f2503c6167 | |||
7a7b8324b4 | |||
057fa03723 | |||
f64c710c12 | |||
32921ff2b1 | |||
6c7928fc92 | |||
fd29a7409e | |||
61c95088af | |||
24bda4741c | |||
172124f20a | |||
17dbadfe9f | |||
e71ae67b4e | |||
e00ee9b777 | |||
0f015354ef | |||
3ed6e09f20 | |||
0dbfa06359 | |||
2fda38f7b1 | |||
ec1828f2bc | |||
3e6ec5087b | |||
a3b4d466d7 | |||
1ddd325e18 | |||
3d453811fb | |||
67b0b9b219 | |||
502b928aff | |||
a9cb0718fe | |||
a1dac4228a | |||
6e2587576d | |||
f8179328cf | |||
dae5c67c02 | |||
eb2ff59fe5 | |||
b36eb487eb | |||
bc61e9f86b | |||
61175740f6 | |||
a41f59984f | |||
0bab36a95a | |||
ff88313462 | |||
3f5c357971 | |||
d2e11d6f11 | |||
3e82dd8d0a | |||
4f5030ecf7 | |||
784e8a3eb8 | |||
7fbe71102a | |||
6f34162ac5 | |||
46ab65a344 | |||
d8cf4c82a5 | |||
ab14f4f82e | |||
56cbeb6183 | |||
6efe6916ba | |||
ea544e8391 | |||
0c46dd28be | |||
d493c015fd | |||
1e3797ec48 | |||
6effb25bd6 | |||
796f188cb3 | |||
e0bc9573d4 | |||
5733918a2f | |||
6740932c47 | |||
9fb0ca3466 | |||
d6ce082274 | |||
3587162611 |
@ -15,7 +15,7 @@ find_package (PkgConfig REQUIRED)
|
||||
|
||||
# force a libmraa search and minimum required version every time a config is generated
|
||||
unset(MRAA_FOUND CACHE)
|
||||
pkg_check_modules (MRAA REQUIRED mraa>=0.6.0)
|
||||
pkg_check_modules (MRAA REQUIRED mraa>=0.6.2)
|
||||
message (INFO " found libmraa version: ${MRAA_VERSION}")
|
||||
|
||||
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
|
||||
@ -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.0-dirty")
|
||||
message (WARNING " - Install git to compile a production UPM!")
|
||||
set (VERSION "v0.3.2-dirty")
|
||||
endif ()
|
||||
|
||||
message (INFO " - UPM Version ${VERSION}")
|
||||
@ -53,18 +53,28 @@ 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/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()
|
||||
add_custom_target (doc
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
@ -90,7 +100,7 @@ if (BUILDDOC)
|
||||
# todo: use a separate cmake FILE module for string replacement instead
|
||||
COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python
|
||||
COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html
|
||||
COMMAND sed -i.bak s|[[:space:]]module</a>|</a>|g html/python/index.html html/python/modules.html
|
||||
COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html
|
||||
DEPENDS doc
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Sphinx" VERBATIM
|
||||
@ -106,7 +116,7 @@ if (BUILDDOC)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxy/node/${JSDOC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${JSDOC_FILE} COPYONLY)
|
||||
endforeach()
|
||||
add_custom_target(jsdoc ALL
|
||||
COMMAND ${NODE_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../../../docs/images/
|
||||
COMMAND ${NODE_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
|
||||
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers generators/yuidoc/helper.js --themedir generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
|
||||
COMMAND ${NODE_EXECUTABLE} tolower -i html/node
|
||||
DEPENDS doc
|
||||
@ -117,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})
|
||||
@ -143,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)
|
||||
|
2
LICENSE
@ -1,4 +1,4 @@
|
||||
Copyright © 2014 Intel Corporation
|
||||
Copyright © 2014-2015 Intel Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
13
README.md
@ -23,6 +23,9 @@ may also create more complex structures in order to interface with them.
|
||||
|
||||
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples).
|
||||
|
||||
Multi-sensor samples for the starter and specialized kits can be found in the
|
||||
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
|
||||
|
||||
### Supported Sensors
|
||||
|
||||
Supported [sensor list](http://iotdk.intel.com/docs/master/upm/modules.html) from API documentation.
|
||||
@ -57,10 +60,16 @@ Make sure you add yourself as an author on every new code file submitted.
|
||||
If you are providing a fix with significant changes, feel free to add yourself
|
||||
as a contributor. Signing-off your commits is mandatory.
|
||||
|
||||
C/C++ API Documentation
|
||||
API Documentation
|
||||
==============
|
||||
|
||||
The C/C++ documentation is available [here](http://iotdk.intel.com/docs/master/upm/).
|
||||
@htmlonly
|
||||
|
||||
<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
|
||||
|
||||
Version @ref changelog [here](docs/changelog.md).
|
||||
|
||||
|
@ -38,6 +38,7 @@ if (NODE_EXECUTABLE)
|
||||
set (V8_VERSION_STRING ${_V8_VERSION})
|
||||
string (REPLACE "." ";" _V8_VERSION_LIST "${_V8_VERSION}")
|
||||
string (REPLACE "." "" V8_DEFINE_STRING "${_V8_VERSION}")
|
||||
string (STRIP ${V8_DEFINE_STRING} V8_DEFINE_STRING)
|
||||
list (GET _V8_VERSION_LIST 0 V8_VERSION_MAJOR)
|
||||
list (GET _V8_VERSION_LIST 1 V8_VERSION_MINOR)
|
||||
list (GET _V8_VERSION_LIST 2 V8_VERSION_PATCH)
|
||||
@ -49,8 +50,8 @@ if (NODE_EXECUTABLE)
|
||||
set (NODE_VERSION_MINOR "10")
|
||||
set (NODE_VERSION_PATCH "30")
|
||||
set (V8_VERSION_MAJOR "3")
|
||||
set (V8_VERSION_MAJOR "14")
|
||||
set (V8_VERSION_MAJOR "5")
|
||||
set (V8_VERSION_MINOR "28")
|
||||
set (V8_VERSION_PATCH "72")
|
||||
set (V8_VERSION_STRING "3.28.72")
|
||||
message ("defaulted to node 0.10.30")
|
||||
endif ()
|
||||
|
@ -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++,
|
||||
|
@ -4,15 +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
|
||||
* 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
|
||||
|
||||
@ -23,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
|
||||
|
||||
@ -31,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
|
||||
|
||||
|
@ -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*
|
||||
|
BIN
docs/icons/c++.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
docs/icons/node.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
docs/icons/python.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
361
docs/images/LICENSE_CC_3_0.txt
Normal 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/ad8232.jpg
Executable file
After Width: | Height: | Size: 222 KiB |
BIN
docs/images/adxl335.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
docs/images/apds9002.jpg
Executable file
After Width: | Height: | Size: 22 KiB |
BIN
docs/images/at42qt1070.jpg
Executable file
After Width: | Height: | Size: 178 KiB |
BIN
docs/images/ecs1030.jpg
Executable file
After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 12 KiB |
BIN
docs/images/grovebutton.jpg
Executable file
After Width: | Height: | Size: 164 KiB |
BIN
docs/images/grovecircularled.jpg
Executable file
After Width: | Height: | Size: 52 KiB |
BIN
docs/images/groveled.jpg
Executable file
After Width: | Height: | Size: 138 KiB |
BIN
docs/images/grovelight.jpg
Executable file
After Width: | Height: | Size: 22 KiB |
BIN
docs/images/groverelay.jpg
Executable file
After Width: | Height: | Size: 18 KiB |
BIN
docs/images/grovescam.jpg
Executable file
After Width: | Height: | Size: 135 KiB |
BIN
docs/images/grovetemp.jpg
Executable file
After Width: | Height: | Size: 21 KiB |
BIN
docs/images/guvas12d.jpg
Executable file
After Width: | Height: | Size: 100 KiB |
BIN
docs/images/hp20x.jpg
Executable file
After Width: | Height: | Size: 929 KiB |
BIN
docs/images/ht9170.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
docs/images/l298.jpg
Executable file
After Width: | Height: | Size: 169 KiB |
BIN
docs/images/lolshield.jpg
Normal file
After Width: | Height: | Size: 140 KiB |
BIN
docs/images/m24lr64e.jpg
Executable file
After Width: | Height: | Size: 24 KiB |
BIN
docs/images/maxsonarez.jpg
Executable file
After Width: | Height: | Size: 60 KiB |
BIN
docs/images/rgbringcoder.jpg
Executable file
After Width: | Height: | Size: 87 KiB |
BIN
docs/images/sm130.jpg
Executable file
After Width: | Height: | Size: 114 KiB |
@ -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
|
||||
|
||||
|
@ -80,7 +80,7 @@ useful to us and converting it to a double.
|
||||
|
||||
Our final example, very easy to use API!
|
||||
|
||||
@snippet examples/max31855.cxx Interesting
|
||||
@snippet examples/c++/max31855.cxx Interesting
|
||||
|
||||
### Building
|
||||
|
||||
|
@ -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:** " \
|
||||
|
@ -3,7 +3,7 @@
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
**Welcome to UPM Python documentation!**
|
||||
**Welcome to UPM Python Documentation!**
|
||||
=========================================
|
||||
|
||||
.. include:: ../../README.md
|
||||
@ -14,7 +14,15 @@
|
||||
################
|
||||
|
||||
For building UPM, please follow this `link <https://github.com/intel-iot-devkit/upm/blob/master/docs/building.md>`_.
|
||||
|
||||
|
||||
``Examples``
|
||||
############
|
||||
|
||||
Multi-sensor samples for the starter and specialized kits can be found in the `iot-devkit-samples <https://github.com/intel-iot-devkit/iot-devkit-samples>`_
|
||||
repository.
|
||||
|
||||
Individual sensor usage examples for python are available `here <https://github.com/intel-iot-devkit/upm/tree/master/examples/python>`_.
|
||||
|
||||
``Making your own UPM Module``
|
||||
##############################
|
||||
|
||||
@ -22,7 +30,7 @@ This `link <https://github.com/intel-iot-devkit/upm/blob/master/docs/porting.md
|
||||
|
||||
There is also an example available for max31855 `sensor <https://github.com/intel-iot-devkit/upm/blob/master/docs/max31855.md>`_.
|
||||
|
||||
``Naming Conventions and rules for new UPM Contributions``
|
||||
``Naming Conventions and Rules for New UPM Contributions``
|
||||
##########################################################
|
||||
|
||||
Before you begin development, please take a look at our naming `conventions <https://github.com/intel-iot-devkit/upm/blob/master/docs/naming.md>`_.
|
||||
@ -33,11 +41,11 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
|
||||
|
||||
.. note::
|
||||
|
||||
* Make sure you add yourself as an author on every new code file submitted.
|
||||
* If you are providing a fix with significant changes, feel free to add yourself as a contributor.
|
||||
* Make sure you add yourself as an author on every new code file submitted.
|
||||
* If you are providing a fix with significant changes, feel free to add yourself as a contributor.
|
||||
* Signing-off your commits is mandatory.
|
||||
|
||||
``List of available sensors drivers``
|
||||
``List of Available Sensors Drivers``
|
||||
######################################
|
||||
|
||||
.. toctree::
|
||||
@ -45,20 +53,25 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
|
||||
|
||||
modules
|
||||
|
||||
``C/C++ API Documentation``
|
||||
``Other API Documentation``
|
||||
###########################
|
||||
|
||||
The C/C++ API documentation is available `here <http://iotdk.intel.com/docs/master/upm/>`_.
|
||||
.. image:: ../docs/icons/c++.png
|
||||
:target: http://iotdk.intel.com/docs/master/upm/modules.html
|
||||
.. image:: ../docs/icons/python.png
|
||||
:target: http://iotdk.intel.com/docs/master/upm/python
|
||||
.. image:: ../docs/icons/node.png
|
||||
:target: http://iotdk.intel.com/docs/master/upm/node
|
||||
|
||||
``Version``
|
||||
###########
|
||||
``Version Changelog``
|
||||
#####################
|
||||
|
||||
For Version Changelog, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/changelog.md>`_.
|
||||
For our Version Changelog, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/changelog.md>`_.
|
||||
|
||||
``Limitations and List of Changes``
|
||||
``Known Limitations``
|
||||
###################################
|
||||
|
||||
For List of Known Limitations, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/knownlimitations.md>`_.
|
||||
For the List of Known Limitations, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/knownlimitations.md>`_.
|
||||
|
||||
``Indices and tables``
|
||||
######################
|
||||
|
@ -43,20 +43,17 @@ opts
|
||||
|
||||
// use promise-style programming rather than spaghetti callbacks
|
||||
Promise.promisifyAll(fs);
|
||||
|
||||
|
||||
// TODO: create directory structure if doesn't exist
|
||||
var formats = opts.formats.split(',');
|
||||
formats.forEach(function(format){
|
||||
mkdirp('jsdoc/' + format + '/' + opts.module);
|
||||
});
|
||||
Promise.promisifyAll(mkdirp);
|
||||
|
||||
|
||||
// main
|
||||
xml2js.parse().then(function(specjs) {
|
||||
var formats = opts.formats.split(',');
|
||||
Promise.all(_.map(formats, function(format) {
|
||||
var generateDocs = require(__dirname + '/generators/' + format + '/generator');
|
||||
var outFile = opts.outdir + '/' + format + '/' + specjs.MODULE + '/doc.js';
|
||||
return fs.writeFileAsync(outFile, generateDocs(specjs));
|
||||
var dir = opts.outdir + '/' + format + '/' + specjs.MODULE;
|
||||
return mkdirp.mkdirpAsync(dir).then(function() {
|
||||
return fs.writeFileAsync(dir + '/doc.js', generateDocs(specjs));
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
@ -58,6 +58,7 @@ function GENERATE_MODULE(module) {
|
||||
|
||||
// generate method spec with parent module/class
|
||||
function GENERATE_METHOD(name, spec, parent) {
|
||||
name = name.replace(/!+$/, '');
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@method ' + name + '\n'
|
||||
+ '@instance\n'
|
||||
|
@ -28,44 +28,66 @@ var _ = require('lodash');
|
||||
|
||||
// generate json for ternjs input
|
||||
function generateDocs(specjs) {
|
||||
var docs = GENERATE_MODULE(specjs.MODULE);
|
||||
GENERATE_TYPE = (function(enums) {
|
||||
return function(type) {
|
||||
return (_.contains(enums, type) ? ('Enum ' + type) : type);
|
||||
}
|
||||
})(_.keys(specjs.ENUMS_BY_GROUP));
|
||||
var docs = { '!name': specjs.MODULE + 'library' };
|
||||
_.extend(docs, GENERATE_MODULE(specjs.MODULE));
|
||||
_.each(specjs.ENUMS, function(enumSpec, enumName) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_ENUM(enumName, enumSpec));
|
||||
});
|
||||
_.each(specjs.METHODS, function(methodSpec, methodName) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(specjs.CLASSES, function(classSpec, parentClass) {
|
||||
var constructor = classSpec.methods[parentClass];
|
||||
_.extend(docs[specjs.MODULE], GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
|
||||
_.each(classSpec.enums, function(enumSpec, enumName) {
|
||||
_.extend(docs[specjs.MODULE][parentClass], GENERATE_ENUM(enumName, enumSpec));
|
||||
|
||||
if (_.isEmpty(specjs.CLASSGROUPS)) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(specjs.CLASSES));
|
||||
} else {
|
||||
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
|
||||
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped)));
|
||||
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
|
||||
_.extend(docs, GENERATE_MODULE(groupName));
|
||||
_.extend(docs[groupName], GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName));
|
||||
});
|
||||
docs[specjs.MODULE][parentClass].prototype = {};
|
||||
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
|
||||
_.extend(docs[specjs.MODULE][parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(classSpec.variables, function(variableSpec, variableName) {
|
||||
_.extend(docs[specjs.MODULE][parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
|
||||
});
|
||||
});
|
||||
}
|
||||
return JSON.stringify(docs, null, 2);
|
||||
}
|
||||
|
||||
|
||||
// generate module spec
|
||||
function GENERATE_MODULE(module) {
|
||||
var docs = { '!name': module + 'library' };
|
||||
var docs = {};
|
||||
docs[module] = {};
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// generate the spec for the given list of classes
|
||||
function GENERATE_CLASSES(classes) {
|
||||
var docs = {};
|
||||
_.each(classes, function(classSpec, parentClass) {
|
||||
var constructor = classSpec.methods[parentClass];
|
||||
_.extend(docs, GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
|
||||
if (_.has(docs, parentClass)) {
|
||||
_.each(classSpec.enums, function(enumSpec, enumName) {
|
||||
_.extend(docs[parentClass], GENERATE_ENUM(enumName, enumSpec));
|
||||
});
|
||||
docs[parentClass].prototype = {};
|
||||
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
|
||||
_.extend(docs[parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(classSpec.variables, function(variableSpec, variableName) {
|
||||
_.extend(docs[parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
|
||||
});
|
||||
}
|
||||
});
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// generate method spec
|
||||
function GENERATE_METHOD(name, spec) {
|
||||
var doc = {};
|
||||
|
14
doxy/node/generators/yuidoc/generator.js
vendored
@ -46,7 +46,7 @@ function generateDocs(specjs) {
|
||||
docs += GENERATE_MODULE('common', '');
|
||||
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
|
||||
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName);
|
||||
});
|
||||
@ -76,7 +76,7 @@ function GENERATE_MODULE(name, description) {
|
||||
function GENERATE_CLASSES(classes, parent) {
|
||||
return _.reduce(classes, function(memo, classSpec, className) {
|
||||
return memo
|
||||
+ GENERATE_CLASS(className, classSpec.description, parent)
|
||||
+ GENERATE_CLASS(className, classSpec.description, parent, classSpec.parent)
|
||||
+ _.reduce(classSpec.methods, function(memo, methodSpec, methodName) {
|
||||
return memo += GENERATE_METHOD(methodName, methodSpec, className);
|
||||
}, '')
|
||||
@ -91,15 +91,21 @@ function GENERATE_CLASSES(classes, parent) {
|
||||
|
||||
|
||||
// generate class spec
|
||||
function GENERATE_CLASS(name, description, parent) {
|
||||
function GENERATE_CLASS(name, description, namespace, parent) {
|
||||
return GENERATE_DOC(description + '\n'
|
||||
+ '@class ' + name + '\n'
|
||||
+ (parent ? ('@module ' + parent + '\n') : ''));
|
||||
+ (namespace ? ('@module ' + namespace + '\n') : '')
|
||||
/*
|
||||
TODO: leave out until figure out what swig does with inheritance
|
||||
+ (parent ? ('@extends ' + parent + '\n') : '')
|
||||
*/
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// generate method spec with parent module/class
|
||||
function GENERATE_METHOD(name, spec, parent) {
|
||||
name = name.replace(/!+$/, '');
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@method ' + name + '\n'
|
||||
+ (parent ? ('@for ' + parent + '\n') : '@for common\n')
|
||||
|
10
doxy/node/generators/yuidoc/helper.js
vendored
@ -77,17 +77,15 @@ function listByGroup(modules, classes, field, projectRoot) {
|
||||
var groups = Object.keys(modulesByGroup).sort();
|
||||
var html = '';
|
||||
var pfx = projectRoot + 'modules/';
|
||||
var first = true;
|
||||
for (i = 0; i < groups.length; i++) {
|
||||
var group = groups[i];
|
||||
html += (first ? '' : '</span>');
|
||||
html += '<div class="upmGroup"><div class="right-arrow"></div>' + group + '</div><span class="upmModules" style="display:none">';
|
||||
var moduleNames = modulesByGroup[group];
|
||||
for (j = 0; j < moduleNames.length; j++) {
|
||||
var moduleName = moduleNames[j];
|
||||
html += '<a href="' + pfx + moduleName + '.html">' + moduleName + '</a>';
|
||||
}
|
||||
first = false;
|
||||
html += '</span>';
|
||||
}
|
||||
return html;
|
||||
}
|
||||
@ -117,7 +115,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
|
||||
font-size: 0; \
|
||||
margin-right: 5px; \
|
||||
vertical-align: 5px; \
|
||||
display: inline; \
|
||||
float: left; \
|
||||
} \
|
||||
div.down-arrow { \
|
||||
width: 0; \
|
||||
@ -127,7 +125,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
|
||||
border-top: 5px solid #356de4; \
|
||||
font-size: 0; \
|
||||
margin-right: 5px; \
|
||||
display: inline; \
|
||||
float: left; \
|
||||
} \
|
||||
div.upmGroup { \
|
||||
font-weight: bold; \
|
||||
@ -137,7 +135,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
|
||||
|
||||
var scripts = "YUI().use('node', 'event', function (Y) {"
|
||||
+ onClickHandler
|
||||
+ insertStyles
|
||||
// + insertStyles
|
||||
+ "});";
|
||||
|
||||
|
||||
|
@ -311,13 +311,13 @@ abbr {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.prettyprint li.L0,
|
||||
.prettyprint li.L1,
|
||||
.prettyprint li.L2,
|
||||
.prettyprint li.L3,
|
||||
.prettyprint li.L5,
|
||||
.prettyprint li.L6,
|
||||
.prettyprint li.L7,
|
||||
.prettyprint li.L0,
|
||||
.prettyprint li.L1,
|
||||
.prettyprint li.L2,
|
||||
.prettyprint li.L3,
|
||||
.prettyprint li.L5,
|
||||
.prettyprint li.L6,
|
||||
.prettyprint li.L7,
|
||||
.prettyprint li.L8 {
|
||||
list-style: decimal;
|
||||
}
|
||||
@ -357,7 +357,7 @@ ul li p {
|
||||
#hd img {
|
||||
margin-right: 10px;
|
||||
vertical-align: middle;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -787,3 +787,28 @@ kbd .cmd { font-family: Monaco, Helvetica; }
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.right-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-bottom: 5px solid transparent;
|
||||
border-top: 5px solid transparent;
|
||||
border-left: 5px solid #356de4;
|
||||
font-size: 0;
|
||||
margin-right: 5px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
div.down-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-top: 5px solid #356de4;
|
||||
font-size: 0;
|
||||
margin-right: 5px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
div.upmGroup {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
<h1>UPM</h1>
|
||||
<p>
|
||||
The UPM API is a high level sensor library for IoT devices using MRAA. See examples <a href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.
|
||||
Back to <a href="http://iotdk.intel.com/docs/master/upm/node/"> index </a> page.
|
||||
<br><em>SparkFun sensor images provided under <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>CC BY-NC-SA-3.0</a>.</em>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
166
doxy/node/generators/yuidoc/tmpl/partials/index.handlebars
Normal file
@ -0,0 +1,166 @@
|
||||
<div class="apidocs">
|
||||
<div class="content" id="docs-main">
|
||||
<h1><strong>Welcome to UPM Node.JS Documentation!</strong><a class="headerlink"
|
||||
href="#welcome-to-upm-python-documentation"></a></h1>
|
||||
|
||||
|
||||
<p>Browse to a module or class using the sidebar to view its API
|
||||
documentation.</p>
|
||||
|
||||
<p>UPM is a high level repository for sensors that use libmraa. Each
|
||||
sensor links to libmraa and are not meant to be interlinked although
|
||||
some groups of sensors may be. Each sensor contains a header which
|
||||
allows to interface with it. Typically a sensor is represented as a
|
||||
class and instantiated.</p>
|
||||
|
||||
<p>The constructor is expected to initialise the sensor and parameters
|
||||
may be used to provide identification/pin location on the board.</p>
|
||||
|
||||
<p>Typically an update() function will be called in order to get new
|
||||
data from the sensor in order to reduce load when doing multiple reads
|
||||
to sensor data.</p>
|
||||
<div class="section" id="examples">
|
||||
<h3><code class="docutils literal"><span class="pre">Examples</span></code><a class="headerlink"
|
||||
href="#examples"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>Multi-sensor samples for the starter and specialized kits can be
|
||||
found in the
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/iot-devkit-samples">iot-devkit-samples</a>
|
||||
repository.</p>
|
||||
|
||||
<p>Individual sensor usage examples for node.js are available
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="building-upm">
|
||||
<h3><tt class="docutils literal"><span class="pre">Building</span>
|
||||
<span class="pre">UPM</span></tt><a class="headerlink"
|
||||
href="#building-upm"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>For building UPM, please follow this
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/building.md">link</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="making-your-own-upm-module">
|
||||
<h3><tt class="docutils literal"><span class="pre">Making</span>
|
||||
<span class="pre">your</span> <span class="pre">own</span>
|
||||
<span class="pre">UPM</span> <span class="pre">Module</span></tt><a class="headerlink"
|
||||
href="#making-your-own-upm-module"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>This
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/porting.md">link</a>
|
||||
has more information on making a new UPM module.</p>
|
||||
|
||||
<p>There is also an example available for max31855
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/max31855.md">sensor</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section"
|
||||
id="naming-conventions-and-rules-for-new-upm-contributions">
|
||||
<h3><tt class="docutils literal"><span class="pre">Naming</span>
|
||||
<span class="pre">Conventions</span> <span class="pre">and</span>
|
||||
<span class="pre">Rules</span> <span class="pre">for</span>
|
||||
<span class="pre">New</span> <span class="pre">UPM</span>
|
||||
<span class="pre">Contributions</span></tt><a class="headerlink"
|
||||
href="#naming-conventions-and-rules-for-new-upm-contributions"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>Before you begin development, please take a look at our naming
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/naming.md">conventions</a>.</p>
|
||||
|
||||
|
||||
<p>Also, please read the guidelines for contributions to
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/contributions.md">UPM</a>.</p>
|
||||
|
||||
|
||||
<p>Don’t forget to check the documentation
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/documentation.md">section</a>.</p>
|
||||
|
||||
<div class="admonition note">
|
||||
|
||||
<p class="first admonition-title">Note</p>
|
||||
<ul class="last simple">
|
||||
<li>Make sure you add yourself as an author on every new code
|
||||
file submitted.</li>
|
||||
<li>If you are providing a fix with significant changes, feel
|
||||
free to add yourself as a contributor.</li>
|
||||
<li>Signing-off your commits is mandatory.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="api-documentation">
|
||||
<h1><strong>Other API Documentation</strong><a class="headerlink"
|
||||
href="#api-documentation"
|
||||
title="Permalink to this headline"></a></h1>
|
||||
|
||||
|
||||
<p><a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="../docs/icons/c++.png" /></a>
|
||||
<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">
|
||||
<h3><tt class="docutils literal"><span class="pre">Version</span>
|
||||
<span class="pre">Changelog</span></tt><a class="headerlink"
|
||||
href="#version-changelog"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>For our Version Changelog, please see
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/changelog.md">here</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="known-limitations">
|
||||
<h3><tt class="docutils literal"><span class="pre">Known</span>
|
||||
<span class="pre">Limitations</span></tt><a class="headerlink"
|
||||
href="#known-limitations"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>For the List of Known Limitations, please see
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/knownlimitations.md">here</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="keyboard-shortcuts">
|
||||
<h3><tt class="docutils literal"><span class="pre">Keyboard</span>
|
||||
<span class="pre">Shortcuts</span></tt><a class="headerlink"
|
||||
href="#keyboard-shortcuts"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
<p>Press <kbd>s</kbd> to focus the API search box.</p> </li>
|
||||
<li>
|
||||
|
||||
<p>Use <kbd>Up</kbd> and <kbd>Down</kbd> to select classes,
|
||||
modules, and search results.</p> </li>
|
||||
<li class="mac-only">
|
||||
|
||||
<p>With the API search box or sidebar focused, use <kbd><span class="cmd">⌘</span>-Left</kbd>
|
||||
or <kbd><span class="cmd">⌘</span>-Right</kbd> to switch
|
||||
sidebar tabs.</p> </li>
|
||||
<li class="pc-only">
|
||||
|
||||
<p>With the API search box or sidebar focused, use <kbd>Ctrl+Left</kbd>
|
||||
and <kbd>Ctrl+Right</kbd> to switch sidebar tabs.</p> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
@ -69,6 +69,8 @@ var xml2js = {
|
||||
// CLASSES: {
|
||||
// <class name>: {
|
||||
// description: <class description>,
|
||||
// parent: <parent class name>,
|
||||
// group: <group name>,
|
||||
// methods: { ... },
|
||||
// variables: {
|
||||
// <variable name>: {
|
||||
@ -83,7 +85,9 @@ var xml2js = {
|
||||
// CLASSGROUPS: {
|
||||
// <group name>: {
|
||||
// description: <group description>,
|
||||
// classes: [ <class name>, ... ]
|
||||
// classes: [ <class name>, ... ],
|
||||
// enums: { ... },
|
||||
// enums_by_group: { ... }
|
||||
// }, ...
|
||||
// }
|
||||
MODULE: '',
|
||||
@ -98,7 +102,8 @@ var xml2js = {
|
||||
TYPEMAPS: {
|
||||
'^(const)?\\s*(unsigned|signed)?\\s*(int|short|long|float|double|size_t|u?int\\d{1,2}_t)?$': 'Number',
|
||||
'^bool$': 'Boolean',
|
||||
'^(const)?\\s*(unsigned|signed)?\\s*(char|char\\s*\\*|std::string)$': 'String' // TODO: verify that swig does this mapping
|
||||
'^(const)?\\s*(unsigned|signed)?\\s*(char|char\\s*\\*|std::string)$': 'String', // TODO: verify that swig does this mapping
|
||||
'^void\\s*\\(\\s*\\*\\s*\\)\\s*\\(\\s*void\\s*\\*\\)\\s*$': 'Function'
|
||||
},
|
||||
|
||||
|
||||
@ -157,13 +162,14 @@ var xml2js = {
|
||||
try {
|
||||
var spec_c = xmlparser.parse(xml)[0];
|
||||
var className = getName(spec_c);
|
||||
xml2js.CLASSES[className] = {
|
||||
_.extend(xml2js.CLASSES[className], {
|
||||
description: getDescription(spec_c),
|
||||
parent: getParent(spec_c, className),
|
||||
enums: getEnums(spec_c, false, className),
|
||||
enums_by_group: getEnums(spec_c, true, className),
|
||||
variables: getVariables(spec_c, className),
|
||||
methods: getMethods(spec_c, className)
|
||||
};
|
||||
});
|
||||
} catch(e) {
|
||||
console.log(e.toString() + ': class ' + className + ' was not parsed correctly.');
|
||||
}
|
||||
@ -177,15 +183,48 @@ var xml2js = {
|
||||
return fs.readFileAsync(xml2js.opts.inputdir + '/' + fn, 'utf8').then(function(xml) {
|
||||
var spec_c = xmlparser.parse(xml)[0];
|
||||
if (_.isEmpty(getSubmodules(spec_c))) {
|
||||
xml2js.CLASSGROUPS[getName(spec_c)] = {
|
||||
var group = getName(spec_c);
|
||||
var classes = getSubclassNames(spec_c);
|
||||
xml2js.CLASSGROUPS[group] = {
|
||||
description: getDescription(spec_c),
|
||||
classes: getSubclassNames(spec_c)
|
||||
}
|
||||
classes: classes
|
||||
};
|
||||
_.each(classes, function(c) {
|
||||
if (_.has(xml2js.CLASSES, c)) {
|
||||
xml2js.CLASSES[c].group = group;
|
||||
} else {
|
||||
console.log('Warning: Group ' + group + ' has unknown class ' + c);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}));
|
||||
});
|
||||
return Promise.all(parseClasses.concat(parseGroups));
|
||||
}).then(function() {
|
||||
if (!_.isEmpty(xml2js.CLASSGROUPS)) {
|
||||
// try to categorize ungrouped classes, if any
|
||||
var grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
|
||||
_.each(ungrouped, function(c) {
|
||||
_.each(findUsage(c), function(group) {
|
||||
xml2js.CLASSGROUPS[group].classes.push(c);
|
||||
});
|
||||
});
|
||||
grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
|
||||
ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
|
||||
// try to categorize ungrouped enums, if any
|
||||
_.each(xml2js.ENUMS_BY_GROUP, function(enumGroupSpec, enumGroupName) {
|
||||
_.each(findUsage(enumGroupName, true), function(c) {
|
||||
xml2js.CLASSES[c].enums_by_group[enumGroupName] = enumGroupSpec;
|
||||
_.each(enumGroupSpec.members, function(enumName) {
|
||||
xml2js.CLASSES[c].enums[enumName] = xml2js.ENUMS[enumName];
|
||||
delete xml2js.ENUMS[enumName];
|
||||
});
|
||||
delete xml2js.ENUMS_BY_GROUP[enumGroupName];
|
||||
});
|
||||
});
|
||||
}
|
||||
}).then(function() {
|
||||
if (xml2js.opts.custom && fs.existsSync(xml2js.opts.custom)) {
|
||||
return fs.readFileAsync(xml2js.opts.custom, 'utf8').then(function(custom) {
|
||||
@ -199,9 +238,9 @@ var xml2js = {
|
||||
console.log(xml2js.opts.custom ? ('Error: No such customization file exists: ' + xml2js.opts.custom) : 'No customizations given.');
|
||||
}
|
||||
}).then(function() {
|
||||
generateCustomPointerClasses();
|
||||
validateMethods();
|
||||
validateVars();
|
||||
generateCustomPointerClasses();
|
||||
return _.pick(xml2js, 'MODULE', 'ENUMS', 'ENUMS_BY_GROUP', 'METHODS', 'CLASSES', 'CLASSGROUPS');
|
||||
});
|
||||
}
|
||||
@ -391,7 +430,30 @@ function generateCustomPointerClasses() {
|
||||
}
|
||||
|
||||
|
||||
// override autogenerated methods with custom configuration
|
||||
// search for usage of a type
|
||||
function findUsage(type, classOnly) {
|
||||
var filterClasses = function(fn) { return _.without(_.map(xml2js.CLASSES, fn), undefined); };
|
||||
var usesType = function(classSpec, className) {
|
||||
var methodsOfType = (_.find(classSpec.methods, function(methodSpec, methodName) {
|
||||
return ((!_.isEmpty(methodSpec.return) && methodSpec.return.type == type) ||
|
||||
(_.contains(_.pluck(methodSpec.params, 'type'), type)));
|
||||
}) != undefined);
|
||||
var variablesOfType = _.contains(_.pluck(classSpec.variable, 'type'), type);
|
||||
return ((methodsOfType || variablesOfType) ? className : undefined);
|
||||
};
|
||||
var extendsType = function(classSpec, className) {
|
||||
return ((classSpec.parent == type) ? className : undefined);
|
||||
};
|
||||
var classes = _.union(filterClasses(usesType), filterClasses(extendsType));
|
||||
if (classOnly) {
|
||||
return classes;
|
||||
} else {
|
||||
return _.without(_.uniq(_.pluck(_.pick(xml2js.CLASSES, classes), 'group')), undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// override autogenerated methods with custom configuration
|
||||
function customizeMethods(custom) {
|
||||
_.each(custom, function(classMethods, className) {
|
||||
_.extend(xml2js.CLASSES[className].methods, _.pick(classMethods, function(methodSpec, methodName) {
|
||||
@ -527,6 +589,19 @@ function getSubmodules(spec_c) {
|
||||
}
|
||||
|
||||
|
||||
// get parent class, if any
|
||||
function getParent(spec_c, className) {
|
||||
var parent = getChild(spec_c, 'basecompoundref');
|
||||
if (parent) {
|
||||
parent = getText(parent);
|
||||
if (!_.has(xml2js.CLASSES, parent)) {
|
||||
console.log('WARNING: Class ' + className + ' has unknown parent class ' + parent);
|
||||
}
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
function hasParams(paramsSpec) {
|
||||
return !(_.isEmpty(paramsSpec) ||
|
||||
((_.size(paramsSpec) == 1) && getText(getChild(paramsSpec[0], 'type')) == 'void'));
|
||||
@ -559,6 +634,7 @@ function getMethods(spec_c, parent) {
|
||||
if (!_.isEmpty(returnSpec)) {
|
||||
retval = getReturn(returnSpec, getReturnDetails(description), methodName, parent);
|
||||
}
|
||||
methodName = getUniqueMethodName(methodName, spec_js, parent);
|
||||
spec_js[methodName] = {
|
||||
description: methodDescription,
|
||||
params: params,
|
||||
@ -575,6 +651,17 @@ function getMethods(spec_c, parent) {
|
||||
}
|
||||
|
||||
|
||||
// get a unique string to represent the name of an overloaded method
|
||||
function getUniqueMethodName(methodName, module, parent) {
|
||||
if (methodName in module) {
|
||||
do {
|
||||
methodName += '!';
|
||||
} while (methodName in module);
|
||||
}
|
||||
return methodName;
|
||||
}
|
||||
|
||||
|
||||
// get variable specifications for a class
|
||||
function getVariables(spec_c, parent) {
|
||||
var spec_js = {};
|
||||
|
@ -122,6 +122,17 @@ add_executable (ht9170-example ht9170.cxx)
|
||||
add_executable (h3lis331dl-example h3lis331dl.cxx)
|
||||
add_executable (ad8232-example ad8232.cxx)
|
||||
add_executable (grovescam-example grovescam.cxx)
|
||||
add_executable (m24lr64e-example m24lr64e.cxx)
|
||||
add_executable (grovecircularled-example grovecircularled.cxx)
|
||||
add_executable (rgbringcoder-example rgbringcoder.cxx)
|
||||
add_executable (hp20x-example hp20x.cxx)
|
||||
add_executable (pn532-example pn532.cxx)
|
||||
add_executable (pn532-writeurl-example pn532-writeurl.cxx)
|
||||
add_executable (sainsmartks-example sainsmartks.cxx)
|
||||
add_executable (mpu60x0-example mpu60x0.cxx)
|
||||
add_executable (ak8975-example ak8975.cxx)
|
||||
add_executable (lsm9ds0-example lsm9ds0.cxx)
|
||||
add_executable (eboled-example eboled.cxx)
|
||||
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
|
||||
@ -222,6 +233,12 @@ include_directories (${PROJECT_SOURCE_DIR}/src/ht9170)
|
||||
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})
|
||||
@ -345,3 +362,14 @@ target_link_libraries (ht9170-example ht9170 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (h3lis331dl-example h3lis331dl ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ad8232-example ad8232 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovescam-example grovescam ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (m24lr64e-example m24lr64e ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovecircularled-example grovecircularled ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (rgbringcoder-example rgbringcoder ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (hp20x-example hp20x ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (pn532-example pn532 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (pn532-writeurl-example pn532 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (sainsmartks-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mpu60x0-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ak8975-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (lsm9ds0-example lsm9ds0 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (eboled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
72
examples/c++/ak8975.cxx
Normal 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
@ -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;
|
||||
}
|
63
examples/c++/grovecircularled.cxx
Normal 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;
|
||||
}
|
@ -58,7 +58,7 @@ void sendCommand(upm::HM11* ble, char *cmd)
|
||||
{
|
||||
memset(buffer, 0, BUFSIZ);
|
||||
|
||||
ble->readData(buffer, BUFSIZ);
|
||||
ble->readData(buffer, BUFSIZ - 1);
|
||||
cout << "Returned: " << buffer << endl;
|
||||
}
|
||||
else
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "hmtrp.h"
|
||||
@ -128,7 +129,8 @@ int main (int argc, char **argv)
|
||||
// check to see if data is available first.
|
||||
if (radio->dataAvailable())
|
||||
{
|
||||
int rv = radio->readData(radioBuffer, bufferLength);
|
||||
memset(radioBuffer, 0, bufferLength);
|
||||
int rv = radio->readData(radioBuffer, bufferLength - 1);
|
||||
|
||||
if (rv > 0)
|
||||
cout << "Received: " << radioBuffer << endl;
|
||||
|
70
examples/c++/hp20x.cxx
Normal 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;
|
||||
}
|
@ -34,6 +34,10 @@ 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;
|
||||
}
|
||||
|
@ -39,4 +39,6 @@ main(int argc, char **argv)
|
||||
lcd->setCursor(3,6);
|
||||
lcd->write("Hello World");
|
||||
delete lcd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
83
examples/c++/lsm9ds0.cxx
Normal 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;
|
||||
}
|
65
examples/c++/m24lr64e.cxx
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "m24lr64e.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate an M24LR64E on I2C bus 0
|
||||
|
||||
upm::M24LR64E *nfcTag = new upm::M24LR64E(M24LR64E_I2C_BUS);
|
||||
|
||||
// This example accesses the device in the 'user' (default) mode,
|
||||
// reads the last byte of data in the EEPROM, inverts it, writes
|
||||
// it back, and then re-reads it.
|
||||
|
||||
// Read the last byte of the EEPROM area
|
||||
|
||||
int addr = M24LR64E::EEPROM_I2C_LENGTH - 1;
|
||||
printf("Address: %d\n", addr);
|
||||
uint8_t byte = nfcTag->readByte(addr);
|
||||
printf("Read byte: %02x\n", byte);
|
||||
|
||||
// Now change it to it's opposite and write it
|
||||
byte = ~byte;
|
||||
nfcTag->writeByte(addr, byte);
|
||||
printf("Wrote inverted byte: %02x\n", byte);
|
||||
|
||||
// Now read it back.
|
||||
byte = nfcTag->readByte(addr);
|
||||
printf("Read byte: %02x\n", byte);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete nfcTag;
|
||||
return 0;
|
||||
}
|
77
examples/c++/mpu60x0.cxx
Normal 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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
115
examples/c++/pn532-writeurl.cxx
Normal 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
@ -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;
|
||||
}
|
110
examples/c++/rgbringcoder.cxx
Normal 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;
|
||||
}
|
66
examples/c++/sainsmartks.cxx
Normal 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;
|
||||
}
|
@ -95,4 +95,5 @@ main(int argc, char **argv)
|
||||
|
||||
delete lcd;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
@ -123,4 +123,5 @@ main(int argc, char **argv)
|
||||
|
||||
delete lcd;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ main(int argc, char** argv)
|
||||
int timezone = -7; // Your UTC offset
|
||||
time_t rawtime;
|
||||
struct tm * gmt;
|
||||
char myTime[4];
|
||||
char myTime[5];
|
||||
|
||||
fprintf(stdout, "TM1637 Display Example\n");
|
||||
signal(SIGINT, sig_handler);
|
||||
@ -62,8 +62,10 @@ main(int argc, char** argv)
|
||||
time(&rawtime); // Update raw time
|
||||
gmt = gmtime(&rawtime); // Get current time
|
||||
|
||||
int hour = (gmt) ? gmt->tm_hour : 0;
|
||||
int min = (gmt) ? gmt->tm_min : 0;
|
||||
// Format and store the time in 24 hour format
|
||||
sprintf(myTime, "%2d%02d", (gmt->tm_hour + timezone + 24) % 24, gmt->tm_min);
|
||||
snprintf(myTime, 5, "%2d%02d", (hour + timezone + 24) % 24, min);
|
||||
|
||||
myDisplay.write(myTime); // Write to display as string
|
||||
myDisplay.setColon(point ^= true); // Toggle the dots on the display
|
||||
|
64
examples/javascript/ak8975.js
Normal 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);
|
||||
});
|
||||
|
51
examples/javascript/eboled.js
Normal 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);
|
||||
|
||||
|
||||
|
49
examples/javascript/grovecircularled.js
Normal 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);
|
||||
});
|
55
examples/javascript/hp20x.js
Normal 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);
|
||||
});
|
||||
|
77
examples/javascript/lsm9ds0.js
Normal 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);
|
||||
});
|
||||
|
59
examples/javascript/m24lr64e.js
Normal file
@ -0,0 +1,59 @@
|
||||
/*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 nfcTagObj = require('jsupm_m24lr64e');
|
||||
|
||||
// Instantiate a M24LR64E Grove NFC Tag Module on UART 0
|
||||
var nfcTag = new nfcTagObj.M24LR64E(nfcTagObj.M24LR64E_I2C_BUS);
|
||||
|
||||
// This example accesses the device in the 'user' (default) mode,
|
||||
// reads the last byte of data in the EEPROM, inverts it, writes
|
||||
// it back, and then re-reads it.
|
||||
|
||||
// Read the last byte of the EEPROM area
|
||||
var addr = (nfcTagObj.M24LR64E.EEPROM_I2C_LENGTH - 1);
|
||||
console.log("Address: " + addr);
|
||||
var byte = nfcTag.readByte(addr);
|
||||
|
||||
console.log("Read byte: " + byte.toString(16));
|
||||
|
||||
// Now change it to it's opposite and write it
|
||||
byte = (~byte & 0xff);
|
||||
nfcTag.writeByte(addr, byte);
|
||||
console.log("Wrote inverted byte: " + byte.toString(16));
|
||||
|
||||
// Now read it back.
|
||||
byte = nfcTag.readByte(addr);
|
||||
console.log("Read byte: " + byte.toString(16));
|
||||
|
||||
// clean up
|
||||
nfcTag = null;
|
||||
nfcTagObj.cleanUp();
|
||||
nfcTagObj = null;
|
||||
console.log("Exiting...");
|
||||
process.exit(0);
|
71
examples/javascript/mpu60x0.js
Normal 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);
|
||||
});
|
||||
|
76
examples/javascript/mpu9150.js
Normal 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);
|
||||
});
|
||||
|
136
examples/javascript/pn532-writeurl.js
Normal 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);
|
||||
|
102
examples/javascript/pn532.js
Normal 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();
|
||||
});
|
98
examples/javascript/rgbringcoder.js
Normal 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);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
53
examples/javascript/sainsmartks.js
Normal 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
@ -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
@ -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)
|
||||
|
||||
|
||||
|
50
examples/python/grovecircularled.py
Normal 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
@ -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)
|
||||
|
71
examples/python/lsm9ds0.py
Normal 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)
|
49
examples/python/m24lr64e.py
Normal file
@ -0,0 +1,49 @@
|
||||
#!/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 sys
|
||||
import pyupm_m24lr64e as nfcTagObj
|
||||
|
||||
# Instantiate a M24LR64E Grove NFC Tag Module on UART 0
|
||||
nfcTag = nfcTagObj.M24LR64E(nfcTagObj.M24LR64E_I2C_BUS)
|
||||
|
||||
# This example accesses the device in the 'user' (default) mode,
|
||||
# reads the last byte of data in the EEPROM, inverts it, writes
|
||||
# it back, and then re-reads it.
|
||||
|
||||
# Read the last byte of the EEPROM area
|
||||
addr = (nfcTagObj.M24LR64E.EEPROM_I2C_LENGTH - 1)
|
||||
print "Address: ", addr
|
||||
byte = nfcTag.readByte(addr)
|
||||
|
||||
print "Read byte: ", format(byte, '02x')
|
||||
|
||||
# Now change it to it's opposite and write it
|
||||
byte = (~byte & 0xff)
|
||||
nfcTag.writeByte(addr, byte)
|
||||
print "Wrote inverted byte: ", format(byte, '02x')
|
||||
|
||||
# Now read it back.
|
||||
byte = nfcTag.readByte(addr)
|
||||
print "Read byte: ", format(byte, '02x')
|
||||
|
65
examples/python/mpu60x0.py
Normal 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)
|
70
examples/python/mpu9150.py
Normal 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)
|
105
examples/python/pn532-writeurl.py
Normal 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
@ -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"
|
90
examples/python/rgbringcoder.py
Normal 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)
|
54
examples/python/sainsmartks.py
Normal 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)
|
||||
|
@ -55,18 +55,21 @@ 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)
|
||||
if (BUILDSWIG)
|
||||
add_dependencies (_pyupm_${libname} ${libname}doc_i)
|
||||
add_dependencies (pydoc _pyupm_${libname})
|
||||
add_dependencies (pydoc _pyupm_${libname})
|
||||
else ()
|
||||
add_dependencies (${libname} doc)
|
||||
endif ()
|
||||
|
@ -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();
|
||||
|
@ -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,41 +50,46 @@ 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:
|
||||
*
|
||||
* @image html ad8232.jpg
|
||||
* <br><em>AD8232 Heart Rate Monitor image provided by SparkFun under
|
||||
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
|
||||
* CC BY-NC-SA-3.0</a>.</em>
|
||||
*
|
||||
* This example just dumps the raw data.
|
||||
* @snippet ad8232.cxx Interesting
|
||||
*/
|
||||
|
||||
|
||||
class AD8232 {
|
||||
public:
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
* @defgroup adis16448 libupm-adis16488
|
||||
* @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;
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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:
|
||||
|