mirror of
https://github.com/eclipse/upm.git
synced 2025-07-06 11:51:10 +03:00
Compare commits
81 Commits
Author | SHA1 | Date | |
---|---|---|---|
74691914fb | |||
9bf184129e | |||
1667569560 | |||
01119436a9 | |||
344a52ae97 | |||
1accafa145 | |||
e54f5e21c3 | |||
01700b0d49 | |||
a96a2ff44c | |||
cc7930caf3 | |||
ac21c9336b | |||
fd509c7d79 | |||
287250b32d | |||
758b49f51d | |||
2a1af1399a | |||
4de9734f0a | |||
9bfda4219d | |||
dddba3e8a4 | |||
500e14663b | |||
fcb36276b7 | |||
7f7fdb8441 | |||
f8a105adbf | |||
ba43986f82 | |||
6e2355ce9a | |||
4a90e2c4be | |||
1adea8ecf1 | |||
011013e800 | |||
b4d4a215a2 | |||
2eb6ebd3bd | |||
dc97adf578 | |||
181b5f17ea | |||
90bf469245 | |||
85b5c8a64e | |||
422592f993 | |||
fa1c1f3aa4 | |||
b11ad2d170 | |||
d62d9f22cd | |||
dec976e971 | |||
fcf2278553 | |||
b3300d5724 | |||
003ca2169f | |||
0586775ffc | |||
053cf15495 | |||
3d8b732158 | |||
db3b0c39bf | |||
d2c4747251 | |||
8b5cdae4ca | |||
2384fbb218 | |||
212c67fdd0 | |||
ca15860cc3 | |||
cce8ab43e6 | |||
255d6cbe86 | |||
db721845db | |||
53bc249b75 | |||
639f99691b | |||
6e095826d3 | |||
0d2541270e | |||
e34863f223 | |||
27f34face1 | |||
563c72be2c | |||
9bd5e78472 | |||
81c5962220 | |||
bf856c5fca | |||
1040b4e51f | |||
1713d44a4b | |||
5ff625eaf4 | |||
9d63545d44 | |||
06b9e7b6f2 | |||
45773fac80 | |||
ee4efb3d6a | |||
abced2fdbb | |||
537f7e111d | |||
8b49943025 | |||
a6f517d2c1 | |||
d26bde1825 | |||
ef30ab6fb2 | |||
9206480b9c | |||
d81639d715 | |||
08451d98cd | |||
ad81ea55e1 | |||
bd8e22f125 |
10
.travis.yml
10
.travis.yml
@ -8,10 +8,14 @@ install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y -qq swig3.0 python git cmake
|
||||
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
|
||||
- sudo update-java-alternatives -s java-8-oracle
|
||||
before_script:
|
||||
- if [ "$CC" = "gcc" ]; then export BUILDJAVA=ON; else export BUILDJAVA=OFF; fi
|
||||
- export JAVA_HOME=/usr/lib/jvm/java-8-oracle
|
||||
script:
|
||||
- git clone --branch=master https://github.com/intel-iot-devkit/mraa.git
|
||||
- cd mraa && mkdir build && cd build && cmake -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=. -DNODE_ROOT_DIR:PATH=/home/travis/.nvm/v0.10.36/include .. && make && make install
|
||||
- export PKG_CONFIG_PATH=$PWD/lib/pkgconfig
|
||||
- cd mraa && mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=. -DNODE_ROOT_DIR:PATH=/home/travis/.nvm/v0.10.36/include .. && make && make install
|
||||
- export PKG_CONFIG_PATH=$PWD/lib/pkgconfig:$PWD/lib/x86_64-linux-gnu/pkgconfig
|
||||
- export CPLUS_INCLUDE_PATH=$PWD/include
|
||||
- export LIBRARY_PATH=$PWD/lib:$PWD/lib/x86_64-linux-gnu
|
||||
- cd ../.. && mkdir build && cd build && cmake -DNODE_ROOT_DIR:PATH=/home/travis/.nvm/v0.10.36/include -DBUILDEXAMPLES=ON .. && make
|
||||
- cd ../.. && mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DNODE_ROOT_DIR:PATH=/home/travis/.nvm/v0.10.36/include -DBUILDEXAMPLES=ON .. && make
|
||||
|
@ -5,22 +5,17 @@ if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||
message("WARNING: building into sources dir can be risky, prefer other directory")
|
||||
endif ()
|
||||
|
||||
find_package (SWIG)
|
||||
if (SWIG_FOUND)
|
||||
include (${SWIG_USE_FILE})
|
||||
endif ()
|
||||
|
||||
find_package (Threads REQUIRED)
|
||||
find_package (PkgConfig REQUIRED)
|
||||
|
||||
# force a libmraa search and minimum required version every time a config is generated
|
||||
# Force a libmraa search and minimum required version every time a config is generated
|
||||
unset(MRAA_FOUND CACHE)
|
||||
pkg_check_modules (MRAA REQUIRED mraa>=0.8.0)
|
||||
message (INFO " found mraa version: ${MRAA_VERSION}")
|
||||
|
||||
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
||||
set (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries")
|
||||
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
|
||||
|
||||
# Set CMAKE_LIB_INSTALL_DIR if not defined
|
||||
include(GNUInstallDirs)
|
||||
@ -28,14 +23,14 @@ include(GNUInstallDirs)
|
||||
# Make a version file containing the current version from git.
|
||||
include (GetGitRevisionDescription)
|
||||
git_describe (VERSION "--tags")
|
||||
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
|
||||
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
|
||||
message (WARNING " - Install git to compile a production UPM!")
|
||||
set (VERSION "v0.4.0-dirty")
|
||||
set (VERSION "v0.4.1-dirty")
|
||||
endif ()
|
||||
|
||||
message (INFO " - UPM Version ${VERSION}")
|
||||
|
||||
#parse the version information into pieces.
|
||||
# Parse the version information into pieces.
|
||||
string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
|
||||
string (REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
|
||||
string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
|
||||
@ -62,13 +57,25 @@ option (BUILDSWIGJAVA "Build swig java modules" OFF)
|
||||
option (IPK "Generate IPK using CPack" OFF)
|
||||
option (RPM "Generate RPM using CPack" OFF)
|
||||
|
||||
# detect arch
|
||||
# Find swig
|
||||
if (BUILDSWIG)
|
||||
if (BUILDSWIGNODE)
|
||||
find_package (SWIG 3.0.5 REQUIRED)
|
||||
else ()
|
||||
find_package (SWIG REQUIRED)
|
||||
endif ()
|
||||
if (SWIG_FOUND)
|
||||
include (${SWIG_USE_FILE})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Detect arch
|
||||
include (TargetArch)
|
||||
target_architecture (DETECTED_ARCH)
|
||||
message( INFO " - Target arch is ${DETECTED_ARCH}")
|
||||
|
||||
if (BUILDDOC)
|
||||
# add a target to generate API documentation with Doxygen
|
||||
# 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)
|
||||
@ -86,10 +93,10 @@ if (BUILDDOC)
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||
)
|
||||
endif (DOXYGEN_FOUND)
|
||||
# check if Sphinx is installed and add target to generate API documentation
|
||||
# Check if Sphinx is installed and add target to generate API documentation
|
||||
find_package (Sphinx)
|
||||
if(SPHINX_FOUND AND BUILDSWIG AND BUILDSWIGPYTHON)
|
||||
# python required for Sphinx build
|
||||
# Python required for Sphinx build
|
||||
find_package (PythonLibs)
|
||||
string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
|
||||
list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
|
||||
@ -102,7 +109,7 @@ if (BUILDDOC)
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -name "_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -name "pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
|
||||
COMMAND ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/pyupm
|
||||
# todo: use a separate cmake FILE module for string replacement instead
|
||||
# TODO: use a separate cmake FILE module for string replacement instead
|
||||
COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python
|
||||
COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html
|
||||
COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html
|
||||
@ -111,10 +118,10 @@ if (BUILDDOC)
|
||||
COMMENT "Generating API documentation with Sphinx" VERBATIM
|
||||
)
|
||||
endif ()
|
||||
# check if Yuidoc is installed and add target for API documentation
|
||||
# Check if Yuidoc is installed and add target for API documentation
|
||||
find_package(Yuidoc)
|
||||
if(YUIDOC_FOUND AND BUILDSWIGNODE)
|
||||
# node required for Yuidoc documentation
|
||||
# Node required for Yuidoc documentation
|
||||
find_package(Node)
|
||||
file(GLOB_RECURSE JSDOC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/doxy/node doxy/node/*)
|
||||
foreach(JSDOC_FILE ${JSDOC_FILES})
|
||||
@ -138,7 +145,7 @@ if (IPK)
|
||||
GET_FILENAME_COMPONENT (DETECTED_SYSROOT $ENV{OECORE_TARGET_SYSROOT} NAME)
|
||||
string (REGEX REPLACE "-poky-linux" "" TARGET_ARCH "${DETECTED_SYSROOT}")
|
||||
else ()
|
||||
# debian uses amd64 to denote x86_64
|
||||
# Debian uses amd64 to denote x86_64
|
||||
if (DETECTED_ARCH STREQUAL "x86_64")
|
||||
set (TARGET_ARCH "amd64")
|
||||
else ()
|
||||
|
19
README.md
19
README.md
@ -1,8 +1,8 @@
|
||||
UPM (Useful Packages & Modules) Sensor/Actuator repository for libmraa
|
||||
UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
|
||||
==============
|
||||
|
||||
UPM is a high level repository for sensors that use libmraa. Each sensor links
|
||||
to libmraa and are not meant to be interlinked although some groups of sensors
|
||||
UPM is a high level repository for sensors that use MRAA. Each sensor links
|
||||
to MRAA and are not meant to be interlinked although some groups of sensors
|
||||
may be. Each sensor contains a header which allows to interface with it.
|
||||
Typically a sensor is represented as a class and instantiated.
|
||||
|
||||
@ -68,9 +68,10 @@ You can also refer to the [Intel® IoT Developer Zone](https://software.intel.co
|
||||
|
||||
### IDE Integration
|
||||
|
||||
If you would like to create Eclipse IDE projects using the UPM C++ samples,
|
||||
please follow the instructions posted [here](https://software.intel.com/en-us/node/551014).
|
||||
This will show you how to import the code and configure your project.
|
||||
If you would like to create projects and run the UPM samples using an Intel recommended IDE,
|
||||
please refer to the Intel Developer Zone IDE page.
|
||||
|
||||
<a href="https://software.intel.com/iot/software/ide"><img src="docs/icons/allides.png"/></a>
|
||||
|
||||
### Building UPM
|
||||
|
||||
@ -97,13 +98,13 @@ as a contributor. Signing-off your commits is mandatory.
|
||||
API Documentation
|
||||
==============
|
||||
|
||||
<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"><img src="docs/icons/c++.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="docs/icons/java.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
|
||||
|
||||
##### Changelog
|
||||
### Changelog
|
||||
Version changelog [here](docs/changelog.md).
|
||||
|
||||
##### Known Limitations
|
||||
### Known Limitations
|
||||
List of known limitations [here](docs/knownlimitations.md).
|
||||
|
@ -4,6 +4,20 @@ Changelog {#changelog}
|
||||
Here's a list summarizing some of the key undergoing changes to our library
|
||||
from earlier versions:
|
||||
|
||||
### v0.4.1
|
||||
|
||||
* Over 150 supported sensor drivers including some industrial grade devices
|
||||
* Improved the JAVA bindings, added a large number of examples for sensors,
|
||||
enabled JAVA builds in Travis CI, and introduced automatic loading for the
|
||||
JAVA shared libraries
|
||||
* Continued to improve existing sensor drivers and to enhance them with the
|
||||
new C++ coding style and exception types
|
||||
* Several cmake improvements to allow building on various Linux distributions
|
||||
and with a newer version of Node.JS
|
||||
* Simplified adding and building of C++ sensor examples via cmake
|
||||
* New sensors: micsv89, xbee, urm37, adxrs610, bma220, dfrph, mcp9808, sx1276,
|
||||
groveultrasonic, ozw
|
||||
|
||||
### v0.4.0
|
||||
|
||||
* Fully functional and documented JAVA language bindings for sensors with
|
||||
|
BIN
docs/icons/allides.png
Normal file
BIN
docs/icons/allides.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
BIN
docs/icons/eclipse.png
Normal file
BIN
docs/icons/eclipse.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
docs/icons/wyliodrin.png
Normal file
BIN
docs/icons/wyliodrin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
docs/icons/xdk.png
Normal file
BIN
docs/icons/xdk.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
docs/images/mcp9808.jpg
Normal file
BIN
docs/images/mcp9808.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
BIN
docs/images/micsv89.jpg
Normal file
BIN
docs/images/micsv89.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
@ -39,6 +39,8 @@ such sensors and known workarounds if they exist.
|
||||
Galileo.
|
||||
* **Grove BLE** (HM-11) does not return data on the Intel Galileo board due to
|
||||
known UART limitation.
|
||||
* **Grove Hall Sensor** (A11X), if the base shield is set to 3V on Intel Edison,
|
||||
it will trigger continous callbacks when the sensor is not reading anything.
|
||||
|
||||
#### Adafruit Sensors
|
||||
|
||||
|
@ -26,8 +26,5 @@ sensor can inherit your class if they only have minor changes.
|
||||
### Doubt
|
||||
|
||||
If ever, give either of us a ping via email:
|
||||
mihai.tudor.panu@intel.com
|
||||
john.r.van.drasek@intel.com
|
||||
brendan.le.foll@intel.com
|
||||
mihai.tudor.panu@intel.com or brendan.le.foll@intel.com
|
||||
and we'll try suggest decent names for your module.
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
UPM (Useful Packages & Modules) Sensor/Actuator repository for libmraa
|
||||
UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
|
||||
==============
|
||||
|
||||
UPM is a high level repository for sensors that use libmraa. Each sensor links
|
||||
to libmraa and are not meant to be interlinked although some groups of sensors
|
||||
UPM is a high level repository for sensors that use MRAA. Each sensor links
|
||||
to MRAA and are not meant to be interlinked although some groups of sensors
|
||||
may be. Each sensor contains a header which allows to interface with it.
|
||||
Typically a sensor is represented as a class and instantiated.
|
||||
|
||||
@ -21,7 +21,7 @@ However implementation and API design is completely up to the developer, some
|
||||
enumerable sensors for example may provide much clever instantiation. Displays
|
||||
may also create more complex structures in order to interface with them.
|
||||
|
||||
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples).
|
||||
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples/c%2B%2B).
|
||||
|
||||
Multi-sensor samples for the starter and specialized kits can be found in the
|
||||
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
|
||||
@ -32,29 +32,32 @@ Supported [sensor list](http://iotdk.intel.com/docs/master/upm/modules.html) fro
|
||||
|
||||
You can also refer to the [Intel® IoT Developer Zone](https://software.intel.com/iot/sensors).
|
||||
|
||||
### IDE Integration
|
||||
### IDE Compatibility
|
||||
|
||||
If you would like to create Eclipse IDE projects using the UPM C++ samples,
|
||||
please follow the instructions posted [here](https://software.intel.com/en-us/node/551014).
|
||||
This will show you how to import the code and configure your project.
|
||||
please follow the instructions provided on the Intel Developer Zone IDE page.
|
||||
|
||||
@htmlonly
|
||||
<a href="https://software.intel.com/iot/software/ide"><img src="docs/icons/eclipse.png"/></a>
|
||||
@endhtmlonly
|
||||
|
||||
### Building UPM
|
||||
|
||||
See @ref building [here](docs/building.md).
|
||||
See @ref building here.
|
||||
|
||||
### Making your own UPM module
|
||||
|
||||
@ref porting [link](docs/porting.md) has more information on making new UPM modules.
|
||||
@ref porting link has more information on making new UPM modules.
|
||||
|
||||
There is also an example available for @ref max31855 [sensor](docs/max31855.md).
|
||||
There is also an example available for @ref max31855 sensor.
|
||||
|
||||
### Naming conventions and rules for new UPM contributions
|
||||
|
||||
Before you begin development, take a look at our @ref naming [conventions](docs/naming.md).
|
||||
Before you begin development, take a look at our @ref naming conventions.
|
||||
|
||||
Also, please read the guidelines for @ref contributions [to UPM](docs/contributions.md).
|
||||
Also, please read the guidelines for @ref contributions to UPM.
|
||||
|
||||
Don't forget to check the @ref documentation [section](docs/documentation.md).
|
||||
Don't forget to check the @ref documentation section.
|
||||
|
||||
Make sure you add yourself as an author on every new code file submitted.
|
||||
If you are providing a fix with significant changes, feel free to add yourself
|
||||
@ -65,15 +68,15 @@ API Documentation
|
||||
|
||||
@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"><img src="docs/icons/c++.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="docs/icons/java.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
|
||||
|
||||
@endhtmlonly
|
||||
|
||||
##### Changelog
|
||||
Version @ref changelog [here](docs/changelog.md).
|
||||
### Changelog
|
||||
Version @ref changelog here.
|
||||
|
||||
##### Known Limitations
|
||||
List of @ref knownlimitations [here](docs/knownlimitations.md).
|
||||
### Known Limitations
|
||||
List of @ref knownlimitations here.
|
||||
|
@ -1,8 +1,7 @@
|
||||
UPM (Useful Packages & Modules) Sensor/Actuator repository for libmraa
|
||||
==============
|
||||
UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
|
||||
|
||||
UPM is a high level repository for sensors that use libmraa. Each sensor links
|
||||
to libmraa and are not meant to be interlinked although some groups of sensors
|
||||
UPM is a high level repository for sensors that use MRAA. Each sensor links
|
||||
to MRAA and are not meant to be interlinked although some groups of sensors
|
||||
may be. Each sensor contains a header which allows to interface with it.
|
||||
Typically a sensor is represented as a class and instantiated.
|
||||
|
||||
@ -21,7 +20,7 @@ However implementation and API design is completely up to the developer, some
|
||||
enumerable sensors for example may provide much clever instantiation. Displays
|
||||
may also create more complex structures in order to interface with them.
|
||||
|
||||
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples).
|
||||
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples/java).
|
||||
|
||||
Multi-sensor samples for the starter and specialized kits can be found in the
|
||||
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
|
||||
@ -32,29 +31,32 @@ Supported [sensor list](http://iotdk.intel.com/docs/master/upm/java/modules.html
|
||||
|
||||
You can also refer to the [Intel® IoT Developer Zone](https://software.intel.com/iot/sensors).
|
||||
|
||||
### IDE Integration
|
||||
### IDE Compatibility
|
||||
|
||||
If you would like to create Eclipse IDE projects using the UPM C++ samples,
|
||||
please follow the instructions posted [here](https://software.intel.com/en-us/node/551014).
|
||||
This will show you how to import the code and configure your project.
|
||||
If you would like to create Eclipse IDE projects using the UPM Java samples,
|
||||
please follow the instructions provided on the Intel Developer Zone IDE page.
|
||||
|
||||
@htmlonly
|
||||
<a href="https://software.intel.com/iot/software/ide"><img src="../docs/icons/eclipse.png"/></a>
|
||||
@endhtmlonly
|
||||
|
||||
### Building UPM
|
||||
|
||||
See @ref building [here](docs/building.md).
|
||||
See @ref building here.
|
||||
|
||||
### Making your own UPM module
|
||||
|
||||
@ref porting [link](docs/porting.md) has more information on making new UPM modules.
|
||||
@ref porting link has more information on making new UPM modules.
|
||||
|
||||
There is also an example available for @ref max31855 [sensor](docs/max31855.md).
|
||||
There is also an example available for @ref max31855 sensor.
|
||||
|
||||
### Naming conventions and rules for new UPM contributions
|
||||
|
||||
Before you begin development, take a look at our @ref naming [conventions](docs/naming.md).
|
||||
Before you begin development, take a look at our @ref naming conventions.
|
||||
|
||||
Also, please read the guidelines for @ref contributions [to UPM](docs/contributions.md).
|
||||
Also, please read the guidelines for @ref contributions to UPM.
|
||||
|
||||
Don't forget to check the @ref documentation [section](docs/documentation.md).
|
||||
Don't forget to check the @ref documentation section.
|
||||
|
||||
Make sure you add yourself as an author on every new code file submitted.
|
||||
If you are providing a fix with significant changes, feel free to add yourself
|
||||
@ -65,13 +67,15 @@ API Documentation
|
||||
|
||||
@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"><img src="../docs/icons/c++.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="../docs/icons/java.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/icons/python.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/icons/node.png"/></a>
|
||||
|
||||
@endhtmlonly
|
||||
|
||||
Version @ref changelog [here](docs/changelog.md).
|
||||
### Changelog
|
||||
Version @ref changelog here.
|
||||
|
||||
List of @ref knownlimitations [here](docs/knownlimitations.md).
|
||||
### Known Limitations
|
||||
List of @ref knownlimitations here.
|
||||
|
@ -21,7 +21,16 @@ For building UPM, please follow this `link <https://github.com/intel-iot-devkit/
|
||||
Multi-sensor samples for the starter and specialized kits can be found in the `iot-devkit-samples <https://github.com/intel-iot-devkit/iot-devkit-samples>`_
|
||||
repository.
|
||||
|
||||
Individual sensor usage examples for python are available `here <https://github.com/intel-iot-devkit/upm/tree/master/examples/python>`_.
|
||||
Individual sensor usage examples for Python are available `here <https://github.com/intel-iot-devkit/upm/tree/master/examples/python>`_.
|
||||
|
||||
``IDE Compatibility``
|
||||
################
|
||||
|
||||
While there is no official IDE provided with our Python libraries, we do recommend the web-based IDE Wyliodrin. It can be used with multiple programming
|
||||
languages, including Python. More information can be found on the Intel Developer Zone IDE page.
|
||||
|
||||
.. image:: ../docs/icons/wyliodrin.png
|
||||
:target: https://software.intel.com/iot/software/ide
|
||||
|
||||
``Making your own UPM Module``
|
||||
##############################
|
||||
@ -48,8 +57,10 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
|
||||
``List of Available Sensors Drivers``
|
||||
######################################
|
||||
|
||||
Click on the library prefix below to expand the full list of sensors:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:maxdepth: 1
|
||||
|
||||
modules
|
||||
|
||||
@ -57,7 +68,7 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
|
||||
###########################
|
||||
|
||||
.. image:: ../docs/icons/c++.png
|
||||
:target: http://iotdk.intel.com/docs/master/upm/modules.html
|
||||
:target: http://iotdk.intel.com/docs/master/upm
|
||||
.. image:: ../docs/icons/java.png
|
||||
:target: http://iotdk.intel.com/docs/master/upm/java
|
||||
.. image:: ../docs/icons/python.png
|
||||
|
@ -7,8 +7,8 @@
|
||||
<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
|
||||
<p>UPM is a high level repository for sensors that use MRAA. Each
|
||||
sensor links to MRAA and are not meant to be interlinked although
|
||||
some groups of sensors may be. Each sensor contains a header which
|
||||
allows to interface with it. Typically a sensor is represented as a
|
||||
class and instantiated.</p>
|
||||
@ -36,6 +36,19 @@
|
||||
href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="ide">
|
||||
<h3><tt class="docutils literal"><span class="pre">IDE Compatibility</span>
|
||||
<span class="pre">UPM</span></tt><a class="headerlink"
|
||||
href="#ide"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>Intel® XDK IoT Edition is the recommended IDE for Node.js development.
|
||||
Visit the Intel® Developer Zone IDE page for more information on how to get
|
||||
started.<br>
|
||||
<a href="https://software.intel.com/iot/software/ide"><img src="../docs/icons/xdk.png"/></a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section" id="building-upm">
|
||||
<h3><tt class="docutils literal"><span class="pre">Building</span>
|
||||
<span class="pre">UPM</span></tt><a class="headerlink"
|
||||
@ -109,7 +122,7 @@
|
||||
title="Permalink to this headline"></a></h1>
|
||||
|
||||
|
||||
<p><a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="../docs/icons/c++.png" /></a>
|
||||
<p><a href="http://iotdk.intel.com/docs/master/upm"><img src="../docs/icons/c++.png" /></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="../docs/icons/java.png" /></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/icons/python.png" /></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/icons/node.png" /></a>
|
||||
|
@ -1,404 +1,245 @@
|
||||
# Extract module name from non-standard example name
|
||||
macro(get_module_name example_name module_name)
|
||||
string(LENGTH ${example_name} length)
|
||||
string(FIND ${example_name} "-" index)
|
||||
if (${index} GREATER 1)
|
||||
string(SUBSTRING ${example_name} 0 ${index} substr)
|
||||
set(${module_name} ${substr})
|
||||
elseif (${example_name} MATCHES "^grove")
|
||||
set (${module_name} "grove")
|
||||
elseif ((${example_name} MATCHES "^mq" AND ${length} EQUAL 3) OR ${example_name} STREQUAL "tp401")
|
||||
set (${module_name} "gas")
|
||||
else()
|
||||
set(${module_name} ${example_name})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
# Set source file, include and linker settings for an example
|
||||
# If example cannot be built, example_bin is cleared
|
||||
macro(add_custom_example example_bin example_src example_module_list)
|
||||
set(found_all_modules TRUE)
|
||||
foreach (module ${example_module_list})
|
||||
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/${module}")
|
||||
set(found_all_modules FALSE)
|
||||
endif()
|
||||
if (MODULE_LIST)
|
||||
list(FIND MODULE_LIST ${module} index)
|
||||
if (${index} EQUAL -1)
|
||||
set(found_all_modules FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
if (found_all_modules)
|
||||
add_executable (${example_bin} ${example_src})
|
||||
target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT})
|
||||
foreach (module ${example_module_list})
|
||||
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module}")
|
||||
include_directories (${module_dir})
|
||||
if (${module} STREQUAL "lcd")
|
||||
set(module "i2clcd")
|
||||
endif()
|
||||
target_link_libraries (${example_bin} ${module})
|
||||
endforeach()
|
||||
else()
|
||||
MESSAGE(INFO " Ignored ${example_bin}")
|
||||
set (example_bin "")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
# Add specified example by name
|
||||
# Note special case for grove based examples
|
||||
macro(add_example example_name)
|
||||
set(example_src "${example_name}.cxx")
|
||||
set(example_bin "${example_name}-example")
|
||||
get_module_name(${example_name} module_name)
|
||||
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}")
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_src}"
|
||||
AND EXISTS ${module_dir}
|
||||
AND IS_DIRECTORY ${module_dir})
|
||||
add_custom_example(${example_bin} ${example_src} ${module_name})
|
||||
if ((NOT ${example_bin} STREQUAL "") AND (${module_name} STREQUAL "grove"))
|
||||
set(grove_module_path "${PROJECT_SOURCE_DIR}/src/${example_name}")
|
||||
if (EXISTS ${grove_module_path})
|
||||
include_directories(${grove_module_path})
|
||||
target_link_libraries (${example_bin} ${example_name})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
MESSAGE(INFO " Ignored ${example_bin}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
|
||||
|
||||
add_executable (hmc5883l-example hmc5883l.cxx)
|
||||
add_executable (groveled-example groveled.cxx)
|
||||
add_executable (groveled-multi-example groveled-multi.cxx)
|
||||
add_executable (groverelay-example groverelay.cxx)
|
||||
add_executable (grovelight-example grovelight.cxx)
|
||||
add_executable (grovetemp-example grovetemp.cxx)
|
||||
add_executable (grovebutton-example grovebutton.cxx)
|
||||
add_executable (groverotary-example groverotary.cxx)
|
||||
add_executable (groveslide-example groveslide.cxx)
|
||||
add_executable (lcm1602-lcd-example lcm1602-lcd.cxx)
|
||||
add_executable (jhd1313m1-lcd-example jhd1313m1-lcd.cxx)
|
||||
add_executable (buzzer-sound-example buzzer-sound.cxx)
|
||||
add_executable (my9221-ledbar-example my9221-ledbar.cxx)
|
||||
add_executable (my9221-updown-example my9221-updown.cxx)
|
||||
add_executable (nrf24l01-transmitter-example nrf24l01-transmitter.cxx)
|
||||
add_executable (nrf24l01-receiver-example nrf24l01-receiver.cxx)
|
||||
add_executable (nrf24l01-broadcast-example nrf24l01-broadcast.cxx)
|
||||
add_executable (es08a-example es08a.cxx)
|
||||
add_executable (hcsr04-example hcsr04.cxx)
|
||||
add_executable (ssd1306-oled-example ssd1306-oled.cxx)
|
||||
add_executable (ssd1308-oled-example ssd1308-oled.cxx)
|
||||
add_executable (ssd1327-oled-example ssd1327-oled.cxx)
|
||||
add_executable (max44000-example max44000.cxx)
|
||||
add_executable (mma7455-example mma7455.cxx)
|
||||
add_executable (st7735-example st7735.cxx)
|
||||
add_executable (max31855-example max31855.cxx)
|
||||
add_executable (bmpx8x-example bmpx8x.cxx)
|
||||
add_executable (stepmotor-example stepmotor.cxx)
|
||||
add_executable (pulsensor-example pulsensor.cxx)
|
||||
add_executable (mic-example mic.cxx)
|
||||
add_executable (mpu9150-example mpu9150.cxx)
|
||||
add_executable (maxds3231m-example maxds3231m.cxx)
|
||||
add_executable (max31723-example max31723.cxx)
|
||||
add_executable (max5487-example max5487.cxx)
|
||||
add_executable (nrf8001-broadcast-example nrf8001-broadcast.cxx)
|
||||
add_executable (nrf8001-helloworld-example nrf8001-helloworld.cxx)
|
||||
add_executable (lpd8806-example lpd8806.cxx)
|
||||
add_executable (mlx90614-example mlx90614.cxx)
|
||||
add_executable (ecs1030-example ecs1030.cxx)
|
||||
add_executable (mq2-example mq2.cxx)
|
||||
add_executable (mq3-example mq3.cxx)
|
||||
add_executable (mq4-example mq4.cxx)
|
||||
add_executable (mq5-example mq5.cxx)
|
||||
add_executable (mq6-example mq6.cxx)
|
||||
add_executable (mq7-example mq7.cxx)
|
||||
add_executable (mq8-example mq8.cxx)
|
||||
add_executable (mq9-example mq9.cxx)
|
||||
add_executable (tp401-example tp401.cxx)
|
||||
add_executable (tcs3414cs-example tcs3414cs.cxx)
|
||||
add_executable (th02-example th02.cxx)
|
||||
add_executable (ttp223-example ttp223.cxx)
|
||||
add_executable (lsm303-example lsm303.cxx)
|
||||
add_executable (joystick12-example joystick12-example.cxx)
|
||||
add_executable (lol-example lol-example.cxx)
|
||||
add_executable (tsl2561-example tsl2561.cxx)
|
||||
add_executable (htu21d-example htu21d.cxx)
|
||||
add_executable (mpl3115a2-example mpl3115a2.cxx)
|
||||
add_executable (ldt0028-example ldt0028.cxx)
|
||||
add_executable (am2315-example am2315.cxx)
|
||||
add_executable (itg3200-example itg3200.cxx)
|
||||
add_executable (enc03r-example enc03r.cxx)
|
||||
add_executable (adc121c021-example adc121c021.cxx)
|
||||
add_executable (ds1307-example ds1307.cxx)
|
||||
add_executable (a110x-example a110x.cxx)
|
||||
add_executable (gp2y0a-example gp2y0a.cxx)
|
||||
add_executable (grovemoisture-example grovemoisture.cxx)
|
||||
add_executable (groveehr-example groveehr.cxx)
|
||||
add_executable (ta12200-example ta12200.cxx)
|
||||
add_executable (grovelinefinder-example grovelinefinder.cxx)
|
||||
add_executable (grovevdiv-example grovevdiv.cxx)
|
||||
add_executable (grovewater-example grovewater.cxx)
|
||||
add_executable (guvas12d-example guvas12d.cxx)
|
||||
add_executable (mpr121-example mpr121.cxx)
|
||||
add_executable (ublox6-example ublox6.cxx)
|
||||
add_executable (yg1006-example yg1006.cxx)
|
||||
add_executable (wt5001-example wt5001.cxx)
|
||||
add_executable (ppd42ns-example ppd42ns.cxx)
|
||||
add_executable (mq303a-example mq303a.cxx)
|
||||
add_executable (grovespeaker-example grovespeaker.cxx)
|
||||
add_executable (rfr359f-example rfr359f.cxx)
|
||||
add_executable (biss0001-example biss0001.cxx)
|
||||
add_executable (rotaryencoder-example rotaryencoder.cxx)
|
||||
add_executable (adxl345-example adxl345.cxx)
|
||||
add_executable (rpr220-example rpr220.cxx)
|
||||
add_executable (rpr220-intr-example rpr220-intr.cxx)
|
||||
add_executable (mma7660-example mma7660.cxx)
|
||||
add_executable (cjq4435-example cjq4435.cxx)
|
||||
add_executable (adxl335-example adxl335.cxx)
|
||||
add_executable (hmtrp-example hmtrp.cxx)
|
||||
add_executable (nunchuck-example nunchuck.cxx)
|
||||
add_executable (otp538u-example otp538u.cxx)
|
||||
add_executable (grovecollision-example grovecollision.cxx)
|
||||
add_executable (groveelectromagnet-example groveelectromagnet.cxx)
|
||||
add_executable (groveemg-example groveemg.cxx)
|
||||
add_executable (groveo2-example groveo2.cxx)
|
||||
add_executable (grovegsr-example grovegsr.cxx)
|
||||
add_executable (ina132-example ina132.cxx)
|
||||
add_executable (l298-example l298.cxx)
|
||||
add_executable (l298-stepper-example l298-stepper.cxx)
|
||||
add_executable (at42qt1070-example at42qt1070.cxx)
|
||||
add_executable (grovemd-example grovemd.cxx)
|
||||
add_executable (grovemd-stepper-example grovemd-stepper.cxx)
|
||||
add_executable (pca9685-example pca9685.cxx)
|
||||
add_executable (groveeldriver-example groveeldriver.cxx)
|
||||
add_executable (adafruitss-example adafruitss.cxx)
|
||||
add_executable (adafruitms1438-example adafruitms1438.cxx)
|
||||
add_executable (adafruitms1438-stepper-example adafruitms1438-stepper.cxx)
|
||||
add_executable (hx711-example hx711.cxx)
|
||||
add_executable (flex-example flex.cxx)
|
||||
add_executable (a110x-intr-example a110x-intr.cxx)
|
||||
add_executable (mhz16-example mhz16.cxx)
|
||||
add_executable (apds9002-example apds9002.cxx)
|
||||
add_executable (waterlevel-example waterlevel.cxx)
|
||||
add_executable (tm1637-example tm1637.cxx)
|
||||
add_executable (zfm20-example zfm20.cxx)
|
||||
add_executable (zfm20-register-example zfm20-register.cxx)
|
||||
add_executable (uln200xa-example uln200xa.cxx)
|
||||
add_executable (grovewfs-example grovewfs.cxx)
|
||||
add_executable (isd1820-example isd1820.cxx)
|
||||
add_executable (sx6119-example sx6119.cxx)
|
||||
add_executable (si114x-example si114x.cxx)
|
||||
add_executable (maxsonarez-example maxsonarez.cxx)
|
||||
add_executable (hm11-example hm11.cxx)
|
||||
add_executable (ht9170-example ht9170.cxx)
|
||||
add_executable (h3lis331dl-example h3lis331dl.cxx)
|
||||
add_executable (ad8232-example ad8232.cxx)
|
||||
add_executable (grovescam-example grovescam.cxx)
|
||||
add_executable (m24lr64e-example m24lr64e.cxx)
|
||||
add_executable (grovecircularled-example grovecircularled.cxx)
|
||||
add_executable (rgbringcoder-example rgbringcoder.cxx)
|
||||
add_executable (hp20x-example hp20x.cxx)
|
||||
add_executable (pn532-example pn532.cxx)
|
||||
add_executable (pn532-writeurl-example pn532-writeurl.cxx)
|
||||
add_executable (sainsmartks-example sainsmartks.cxx)
|
||||
add_executable (mpu60x0-example mpu60x0.cxx)
|
||||
add_executable (ak8975-example ak8975.cxx)
|
||||
add_executable (lsm9ds0-example lsm9ds0.cxx)
|
||||
add_executable (eboled-example eboled.cxx)
|
||||
add_executable (mpu9250-example mpu9250.cxx)
|
||||
add_executable (loudness-example loudness.cxx)
|
||||
add_executable (mg811-example mg811.cxx)
|
||||
add_executable (wheelencoder-example wheelencoder.cxx)
|
||||
add_executable (sm130-example sm130.cxx)
|
||||
add_executable (grovegprs-example grovegprs.cxx)
|
||||
add_executable (lm35-example lm35.cxx)
|
||||
# If your sample source file matches the name of the module it tests, add it here
|
||||
# Exceptions are as follows:
|
||||
# string after first '-' is ignored (e.g. nrf24l01-transmitter maps to nrf24l01)
|
||||
# mq? will use module gas
|
||||
# grove* will use module grove
|
||||
add_example (hmc5883l)
|
||||
add_example (groveled)
|
||||
add_example (groverelay)
|
||||
add_example (grovelight)
|
||||
add_example (grovetemp)
|
||||
add_example (grovebutton)
|
||||
add_example (groverotary)
|
||||
add_example (groveslide)
|
||||
add_example (buzzer-sound)
|
||||
add_example (my9221-ledbar)
|
||||
add_example (my9221-updown)
|
||||
add_example (nrf24l01-transmitter)
|
||||
add_example (nrf24l01-receiver)
|
||||
add_example (nrf24l01-broadcast)
|
||||
add_example (hcsr04)
|
||||
add_example (max44000)
|
||||
add_example (mma7455)
|
||||
add_example (st7735)
|
||||
add_example (max31855)
|
||||
add_example (bmpx8x)
|
||||
add_example (stepmotor)
|
||||
add_example (pulsensor)
|
||||
add_example (mic)
|
||||
add_example (mpu9150)
|
||||
add_example (maxds3231m)
|
||||
add_example (max31723)
|
||||
add_example (max5487)
|
||||
add_example (nrf8001-broadcast)
|
||||
add_example (nrf8001-helloworld)
|
||||
add_example (lpd8806)
|
||||
add_example (mlx90614)
|
||||
add_example (ecs1030)
|
||||
add_example (mq2)
|
||||
add_example (mq3)
|
||||
add_example (mq4)
|
||||
add_example (mq5)
|
||||
add_example (mq6)
|
||||
add_example (mq7)
|
||||
add_example (mq8)
|
||||
add_example (mq9)
|
||||
add_example (tp401)
|
||||
add_example (tcs3414cs)
|
||||
add_example (th02)
|
||||
add_example (ttp223)
|
||||
add_example (lsm303)
|
||||
add_example (joystick12)
|
||||
add_example (lol)
|
||||
add_example (tsl2561)
|
||||
add_example (htu21d)
|
||||
add_example (mpl3115a2)
|
||||
add_example (ldt0028)
|
||||
add_example (am2315)
|
||||
add_example (itg3200)
|
||||
add_example (enc03r)
|
||||
add_example (adc121c021)
|
||||
add_example (ds1307)
|
||||
add_example (a110x)
|
||||
add_example (gp2y0a)
|
||||
add_example (grovemoisture)
|
||||
add_example (groveehr)
|
||||
add_example (ta12200)
|
||||
add_example (grovelinefinder)
|
||||
add_example (grovevdiv)
|
||||
add_example (grovewater)
|
||||
add_example (guvas12d)
|
||||
add_example (mpr121)
|
||||
add_example (ublox6)
|
||||
add_example (yg1006)
|
||||
add_example (wt5001)
|
||||
add_example (ppd42ns)
|
||||
add_example (mq303a)
|
||||
add_example (grovespeaker)
|
||||
add_example (rfr359f)
|
||||
add_example (biss0001)
|
||||
add_example (rotaryencoder)
|
||||
add_example (adxl345)
|
||||
add_example (rpr220)
|
||||
add_example (rpr220-intr)
|
||||
add_example (mma7660)
|
||||
add_example (cjq4435)
|
||||
add_example (adxl335)
|
||||
add_example (hmtrp)
|
||||
add_example (nunchuck)
|
||||
add_example (otp538u)
|
||||
add_example (grovecollision)
|
||||
add_example (groveelectromagnet)
|
||||
add_example (groveemg)
|
||||
add_example (groveo2)
|
||||
add_example (grovegsr)
|
||||
add_example (ina132)
|
||||
add_example (l298)
|
||||
add_example (l298-stepper)
|
||||
add_example (at42qt1070)
|
||||
add_example (grovemd)
|
||||
add_example (grovemd-stepper)
|
||||
add_example (pca9685)
|
||||
add_example (groveeldriver)
|
||||
add_example (adafruitss)
|
||||
add_example (adafruitms1438)
|
||||
add_example (adafruitms1438-stepper)
|
||||
add_example (hx711)
|
||||
add_example (flex)
|
||||
add_example (a110x-intr)
|
||||
add_example (mhz16)
|
||||
add_example (apds9002)
|
||||
add_example (waterlevel)
|
||||
add_example (tm1637)
|
||||
add_example (zfm20)
|
||||
add_example (zfm20-register)
|
||||
add_example (uln200xa)
|
||||
add_example (grovewfs)
|
||||
add_example (isd1820)
|
||||
add_example (sx6119)
|
||||
add_example (si114x)
|
||||
add_example (maxsonarez)
|
||||
add_example (hm11)
|
||||
add_example (ht9170)
|
||||
add_example (h3lis331dl)
|
||||
add_example (ad8232)
|
||||
add_example (grovescam)
|
||||
add_example (m24lr64e)
|
||||
add_example (grovecircularled)
|
||||
add_example (rgbringcoder)
|
||||
add_example (hp20x)
|
||||
add_example (pn532)
|
||||
add_example (pn532-writeurl)
|
||||
add_example (lsm9ds0)
|
||||
add_example (loudness)
|
||||
add_example (mg811)
|
||||
add_example (wheelencoder)
|
||||
add_example (sm130)
|
||||
add_example (grovegprs)
|
||||
add_example (lm35)
|
||||
add_example (micsv89)
|
||||
add_example (xbee)
|
||||
add_example (urm37)
|
||||
add_example (urm37-uart)
|
||||
add_example (adxrs610)
|
||||
add_example (bma220)
|
||||
add_example (dfrph)
|
||||
add_example (mcp9808)
|
||||
add_example (groveultrasonic)
|
||||
add_example (sx1276-lora)
|
||||
add_example (sx1276-fsk)
|
||||
if (OPENZWAVE_FOUND)
|
||||
include_directories(${OPENZWAVE_INCLUDE_DIRS})
|
||||
add_example (ozw)
|
||||
endif()
|
||||
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/lcd)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/buzzer)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/my9221)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/nrf24l01)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/servo)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/hcsr04)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/max44000)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mma7455)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/st7735)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/max31855)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/bmpx8x)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/stepmotor)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/pulsensor)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mic)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mpu9150)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/maxds3231m)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/max31723)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/max5487)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/nrf8001)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/lpd8806)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mlx90614)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ecs1030)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/gas)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/tcs3414cs)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/th02)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ttp223)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/lsm303)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/joystick12)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/lol)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/tsl2561)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/htu21d)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mpl3115a2)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ldt0028)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/am2315)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/itg3200)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/enc03r)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/adc121c021)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ds1307)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/a110x)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/gp2y0a)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovemoisture)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/groveehr)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ta12200)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovelinefinder)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovevdiv)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovewater)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/guvas12d)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mpr121)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ublox6)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/yg1006)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/wt5001)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ppd42ns)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mq303a)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovespeaker)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/rfr359f)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/biss0001)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/rotaryencoder)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/adxl345)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/rpr220)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mma7660)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/cjq4435)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/adxl335)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/hmtrp)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/nunchuck)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/otp538u)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovecollision)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/groveelectromagnet)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/groveemg)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/groveo2)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovegsr)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ina132)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/l298)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/at42qt1070)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovemd)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/pca9685)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/groveeldriver)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/adafruitss)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/adafruitms1438)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/hx711)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/flex)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mhz16)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/apds9002)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/waterlevel)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/tm1637)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/zfm20)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/uln200xa)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovewfs)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/isd1820)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/sx6119)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/si114x)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/maxsonarez)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/hm11)
|
||||
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)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/loudness)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mg811)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/wheelencoder)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/sm130)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovegprs)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/lm35)
|
||||
|
||||
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveled-multi-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groverelay-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovelight-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovetemp-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovebutton-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groverotary-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveslide-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (lcm1602-lcd-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (jhd1313m1-lcd-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (buzzer-sound-example buzzer ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (my9221-ledbar-example my9221 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (my9221-updown-example my9221 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (nrf24l01-transmitter-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (nrf24l01-receiver-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (nrf24l01-broadcast-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (es08a-example servo ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (hcsr04-example hcsr04 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ssd1306-oled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ssd1308-oled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ssd1327-oled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (max44000-example max44000 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mma7455-example mma7455 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (st7735-example st7735 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (max31855-example max31855 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (bmpx8x-example bmpx8x ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (stepmotor-example stepmotor ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (pulsensor-example pulsensor ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mic-example mic ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mpu9150-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (maxds3231m-example maxds3231m ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (max31723-example max31723 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (max5487-example max5487 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (nrf8001-broadcast-example nrf8001 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (nrf8001-helloworld-example nrf8001 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (lpd8806-example lpd8806 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mlx90614-example mlx90614 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ecs1030-example ecs1030 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq2-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq3-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq4-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq5-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq6-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq7-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq8-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq9-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (tp401-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (tcs3414cs-example tcs3414cs ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (th02-example th02 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ttp223-example ttp223 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (lsm303-example lsm303 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (joystick12-example joystick12 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (lol-example lol ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (tsl2561-example tsl2561 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (htu21d-example htu21d ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mpl3115a2-example mpl3115a2 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ldt0028-example ldt0028 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (am2315-example am2315 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (itg3200-example itg3200 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (enc03r-example enc03r ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (adc121c021-example adc121c021 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ds1307-example ds1307 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (a110x-example a110x ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (gp2y0a-example gp2y0a ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovemoisture-example grovemoisture ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveehr-example groveehr ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ta12200-example ta12200 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovelinefinder-example grovelinefinder ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovevdiv-example grovevdiv ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovewater-example grovewater ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (guvas12d-example guvas12d ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mpr121-example mpr121 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ublox6-example ublox6 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (yg1006-example yg1006 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (wt5001-example wt5001 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ppd42ns-example ppd42ns ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq303a-example mq303a ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovespeaker-example grovespeaker ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (rfr359f-example rfr359f ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (biss0001-example biss0001 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (rotaryencoder-example rotaryencoder ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (adxl345-example adxl345 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (rpr220-example rpr220 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (rpr220-intr-example rpr220 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mma7660-example mma7660 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (cjq4435-example cjq4435 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (adxl335-example adxl335 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (hmtrp-example hmtrp ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (nunchuck-example nunchuck ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (otp538u-example otp538u ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovecollision-example grovecollision ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveelectromagnet-example groveelectromagnet ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveemg-example groveemg ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveo2-example groveo2 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovegsr-example grovegsr ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ina132-example ina132 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (l298-example l298 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (l298-stepper-example l298 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (at42qt1070-example at42qt1070 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovemd-example grovemd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovemd-stepper-example grovemd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (pca9685-example pca9685 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveeldriver-example groveeldriver ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (adafruitss-example adafruitss ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (adafruitms1438-example adafruitms1438 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (adafruitms1438-stepper-example adafruitms1438 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (hx711-example hx711 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (flex-example flex ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (a110x-intr-example a110x ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mhz16-example mhz16 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (apds9002-example apds9002 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (waterlevel-example waterlevel ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (tm1637-example tm1637 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (zfm20-example zfm20 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (zfm20-register-example zfm20 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (uln200xa-example uln200xa ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovewfs-example grovewfs ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (isd1820-example isd1820 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (sx6119-example sx6119 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (si114x-example si114x ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (maxsonarez-example maxsonarez ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (hm11-example hm11 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ht9170-example ht9170 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (h3lis331dl-example h3lis331dl ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ad8232-example ad8232 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovescam-example grovescam ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (m24lr64e-example m24lr64e ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovecircularled-example grovecircularled ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (rgbringcoder-example rgbringcoder ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (hp20x-example hp20x ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (pn532-example pn532 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (pn532-writeurl-example pn532 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (sainsmartks-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mpu60x0-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ak8975-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (lsm9ds0-example lsm9ds0 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (eboled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mpu9250-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (loudness-example loudness ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mg811-example mg811 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (wheelencoder-example wheelencoder ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (sm130-example sm130 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovegprs-example grovegprs ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (lm35-example lm35 ${CMAKE_THREAD_LIBS_INIT})
|
||||
# These are special cases where you specify example binary, source file and module(s)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src)
|
||||
add_custom_example (groveled-multi-example groveled-multi.cxx grove)
|
||||
add_custom_example (lcm1602-i2c-example lcm1602-i2c.cxx lcd)
|
||||
add_custom_example (lcm1602-parallel-example lcm1602-parallel.cxx lcd)
|
||||
add_custom_example (jhd1313m1-lcd-example jhd1313m1-lcd.cxx lcd)
|
||||
add_custom_example (es08a-example es08a.cxx servo)
|
||||
add_custom_example (ssd1306-oled-example ssd1306-oled.cxx lcd)
|
||||
add_custom_example (ssd1308-oled-example ssd1308-oled.cxx lcd)
|
||||
add_custom_example (ssd1327-oled-example ssd1327-oled.cxx lcd)
|
||||
add_custom_example (sainsmartks-example sainsmartks.cxx lcd)
|
||||
add_custom_example (eboled-example eboled.cxx lcd)
|
||||
add_custom_example (mpu60x0-example mpu60x0.cxx mpu9150)
|
||||
add_custom_example (ak8975-example ak8975.cxx mpu9150)
|
||||
add_custom_example (mpu9250-example mpu9250.cxx mpu9150)
|
||||
|
71
examples/c++/adxrs610.cxx
Normal file
71
examples/c++/adxrs610.cxx
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "adxrs610.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a ADXRS610 sensor on analog pin A0 (dataout), and
|
||||
// analog A1 (temp out) with an analog reference voltage of
|
||||
// 5.0
|
||||
upm::ADXRS610 *sensor = new upm::ADXRS610(0, 1, 5.0);
|
||||
|
||||
// set a deadband region around the zero point to report 0.0 (optional)
|
||||
sensor->setDeadband(0.015);
|
||||
|
||||
// Every tenth of a second, sample the ADXRS610 and output it's
|
||||
// corresponding temperature and angular velocity
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << "Vel (deg/s): " << sensor->getAngularVelocity() << endl;
|
||||
cout << "Temp (C): " << sensor->getTemperature() << endl;
|
||||
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
delete sensor;
|
||||
return 0;
|
||||
}
|
70
examples/c++/bma220.cxx
Normal file
70
examples/c++/bma220.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 <iostream>
|
||||
#include <signal.h>
|
||||
#include "bma220.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate an BMA220 using default parameters (bus 0, addr 0x0a)
|
||||
upm::BMA220 *sensor = new upm::BMA220();
|
||||
|
||||
// Output data every half second until interrupted
|
||||
while (shouldRun)
|
||||
{
|
||||
sensor->update();
|
||||
|
||||
float x, y, z;
|
||||
|
||||
sensor->getAccelerometer(&x, &y, &z);
|
||||
cout << "Accelerometer: ";
|
||||
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
|
||||
|
||||
usleep(500000);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
76
examples/c++/dfrph.cxx
Normal file
76
examples/c++/dfrph.cxx
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "dfrph.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
#define DFRPH_AREF 5.0
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a DFRPH sensor on analog pin A0, with an analog
|
||||
// reference voltage of DFRPH_AREF
|
||||
upm::DFRPH *sensor = new upm::DFRPH(0, DFRPH_AREF);
|
||||
|
||||
|
||||
// After calibration, set the offset (based on calibration with a pH
|
||||
// 7.0 buffer solution). See the UPM sensor documentation for
|
||||
// calibrations instructions.
|
||||
sensor->setOffset(0.065);
|
||||
|
||||
// Every second, sample the pH and output it's corresponding
|
||||
// analog voltage.
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << "Detected volts: " << sensor->volts() << endl;
|
||||
cout << "pH value: " << sensor->pH() << endl;
|
||||
cout << endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
delete sensor;
|
||||
return 0;
|
||||
}
|
@ -34,10 +34,11 @@ int main(int argc, char **argv)
|
||||
upm::EBOLED *lcd = new upm::EBOLED();
|
||||
|
||||
lcd->clear();
|
||||
lcd->setCursor(2, 0);
|
||||
lcd->setCursor(10, 15);
|
||||
lcd->write("Hello");
|
||||
lcd->setCursor(3, 5);
|
||||
lcd->setCursor(30, 15);
|
||||
lcd->write("World!");
|
||||
lcd->refresh();
|
||||
|
||||
cout << "Sleeping for 5 seconds..." << endl;
|
||||
sleep(5);
|
||||
|
62
examples/c++/groveultrasonic.cxx
Normal file
62
examples/c++/groveultrasonic.cxx
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Author: Jun Kato <i@junkato.jp>
|
||||
* Copyright (c) 2015 Jun Kato.
|
||||
*
|
||||
* Thanks to Seeed Studio for a working arduino sketch
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* 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 "groveultrasonic.h"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
upm::GroveUltraSonic *sonar = NULL;
|
||||
bool running = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
// upm::GroveUltraSonic *sonar = NULL;
|
||||
sonar = new upm::GroveUltraSonic(2);
|
||||
while(running) {
|
||||
int width = sonar->getDistance();
|
||||
printf("Echo width = %d\n", width);
|
||||
printf("Distance inches = %f.2\n\n", width/148.0);
|
||||
sleep(3);
|
||||
}
|
||||
//! [Interesting]
|
||||
printf("exiting application\n");
|
||||
delete sonar;
|
||||
return 0;
|
||||
}
|
@ -42,15 +42,10 @@ sig_handler(int signo)
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
void
|
||||
interrupt (void * args) {
|
||||
sonar->ackEdgeDetected ();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
sonar = new upm::HCSR04(5, 6, &interrupt);
|
||||
sonar = new upm::HCSR04(5, 6);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
sleep(1);
|
||||
|
@ -32,12 +32,16 @@ main(int argc, char **argv)
|
||||
lcd->setCursor(0,0);
|
||||
lcd->write("Hello World");
|
||||
//! [Interesting]
|
||||
sleep(3);
|
||||
lcd->setCursor(1,2);
|
||||
lcd->write("Hello World");
|
||||
sleep(3);
|
||||
lcd->setCursor(2,4);
|
||||
lcd->write("Hello World");
|
||||
sleep(3);
|
||||
lcd->setCursor(3,6);
|
||||
lcd->write("Hello World");
|
||||
sleep(3);
|
||||
delete lcd;
|
||||
|
||||
return 0;
|
54
examples/c++/lcm1602-parallel.cxx
Normal file
54
examples/c++/lcm1602-parallel.cxx
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Author: Sergey Kiselev <sergey.kiselev@intel.com>
|
||||
* Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 - 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <lcm1602.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// LCD connection:
|
||||
// LCD RS pin to digital pin 8
|
||||
// LCD Enable pin to digital pin 13
|
||||
// LCD D4 pin to digital pin 2
|
||||
// LCD D5 pin to digital pin 3
|
||||
// LCD D6 pin to digital pin 4
|
||||
// LCD D7 pin to digital pin 5
|
||||
// LCD R/W pin to ground
|
||||
// 10K trimmer potentiometer:
|
||||
// ends to +5V and ground
|
||||
// wiper to LCD VO pin (pin 3)
|
||||
upm::Lcm1602 *lcd = new upm::Lcm1602(8, 13, 2, 3, 4, 5, 20, 2);
|
||||
lcd->setCursor(0,0);
|
||||
lcd->write("Hello World");
|
||||
lcd->setCursor(1,2);
|
||||
lcd->write("Hello World");
|
||||
|
||||
printf("Sleeping for 5 seconds\n");
|
||||
sleep(5);
|
||||
delete lcd;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
163
examples/c++/mcp9808.cxx
Normal file
163
examples/c++/mcp9808.cxx
Normal file
@ -0,0 +1,163 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include "mcp9808.h"
|
||||
|
||||
#include "mraa.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
//! [Interesting]
|
||||
int command;
|
||||
upm::MCP9808 *temp = new upm::MCP9808(6);
|
||||
|
||||
do
|
||||
{
|
||||
cout << endl;
|
||||
cout << "1 - read temp \t" ;
|
||||
cout << "2 - sleep mode \t";
|
||||
cout << "3 - wake up" << endl;
|
||||
cout << "4 - set mode to " << (temp->isCelsius() == true ? "Fahrenheit" : "Celcius") << endl;
|
||||
cout << "5 - show status bits" << endl;
|
||||
cout << "6 - Set Tcrit \t" ;
|
||||
cout << "7 - Set Tupper \t" ;
|
||||
cout << "8 - Set Tlower " << endl;
|
||||
cout << "9 - Display monitor temps " << endl;
|
||||
cout << "10 - Enable alert default\t";
|
||||
cout << "11 - Enable alert interrupt" << endl;
|
||||
cout << "12 - Clear interrupt \t" ;
|
||||
cout << "13 - Clear alert mode" << endl;
|
||||
cout << "14 - Get Hysteresis\t";
|
||||
cout << "15 - Set Hysteresis" << endl;
|
||||
cout << "16 - Get Resolution\t";
|
||||
cout << "17 - Set Resolution" << endl;
|
||||
cout << "18 - Get Manufacturer ID"<< endl;
|
||||
cout << "19 - Get Device ID" << endl;
|
||||
cout << "-1 - exit" << endl;
|
||||
cout << "Enter a command: ";
|
||||
cin >> command;
|
||||
|
||||
switch(command)
|
||||
{
|
||||
float t;
|
||||
case 1:
|
||||
std::cout << "Temp: " << temp->getTemp() << "° " << (temp->isCelsius()? "Celsius" : "Fahrenheit")<< std::endl;
|
||||
break;
|
||||
case 2:
|
||||
cout << "shutdown sensor (sleep mode)" << endl;
|
||||
temp->shutDown();
|
||||
break;
|
||||
case 3:
|
||||
cout << "wake up sensor" << endl;
|
||||
temp->shutDown(false);
|
||||
break;
|
||||
case 4:
|
||||
cout << "set mode to " << (temp->isCelsius() ? "Fahrenheit" : "Celcius") << endl;
|
||||
temp->setMode(!temp->isCelsius());
|
||||
break;
|
||||
case 5:
|
||||
cout << "Tcrit = " << temp->isTcrit();
|
||||
cout << " Tupper = " << temp->isTupper();
|
||||
cout << " Tlower = " << temp->isTlower();
|
||||
break;
|
||||
case 6:
|
||||
cout << "enter a value";
|
||||
cin >> t;
|
||||
temp->setMonitorReg(temp->CRIT_TEMP, t);
|
||||
break;
|
||||
case 7:
|
||||
cout << "enter a value";
|
||||
cin >> t;
|
||||
temp->setMonitorReg(temp->UPPER_TEMP, t);
|
||||
break;
|
||||
case 8:
|
||||
cout << "enter a value";
|
||||
cin >> t;
|
||||
temp->setMonitorReg(temp->LOWER_TEMP, t);
|
||||
break;
|
||||
case 9:
|
||||
cout << "tcrit = " << temp->getMonitorReg(temp->CRIT_TEMP) << endl;
|
||||
cout << "tupper = " << temp->getMonitorReg(temp->UPPER_TEMP) << endl;
|
||||
cout << "tlower = " << temp->getMonitorReg(temp->LOWER_TEMP) << endl;
|
||||
break;
|
||||
case 10:
|
||||
cout << "set alert mode default" ;
|
||||
temp->setAlertMode(temp->ALERTCTRL);
|
||||
break;
|
||||
case 11:
|
||||
cout << "set alert mode interrupt";
|
||||
temp->setAlertMode(temp->ALERTMODE | temp->ALERTCTRL );
|
||||
break;
|
||||
case 12:
|
||||
temp->clearInterrupt();
|
||||
break;
|
||||
case 13:
|
||||
cout << "Clear alerts" << endl;
|
||||
temp->clearAlertMode();
|
||||
break;
|
||||
case 14:
|
||||
cout << "Hysteresis: " << temp->getHysteresis() << endl;
|
||||
break;
|
||||
case 15:
|
||||
int u;
|
||||
cout << "enter 1 to 4";
|
||||
cin >> u ;
|
||||
switch(u)
|
||||
{
|
||||
case 1:
|
||||
temp->setHysteresis(temp->HYST_0);
|
||||
break;
|
||||
case 2:
|
||||
temp->setHysteresis(temp->HYST_1_5);
|
||||
break;
|
||||
case 3:
|
||||
temp->setHysteresis(temp->HYST_3_0);
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
temp->setHysteresis(temp->HYST_6_0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
cout << "Resolution: " << temp->getResolution() << endl;
|
||||
break;
|
||||
case 17:
|
||||
int v;
|
||||
cout << "enter 1 to 4";
|
||||
cin >> v ;
|
||||
switch(v)
|
||||
{
|
||||
case 1:
|
||||
temp->setResolution(temp->RES_LOW);
|
||||
break;
|
||||
case 2:
|
||||
temp->setResolution(temp->RES_MEDIUM);
|
||||
break;
|
||||
case 3:
|
||||
temp->setResolution(temp->RES_HIGH);
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
temp->setResolution(temp->RES_PRECISION);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
cout << "Manufacturer ID: " << std::hex << temp->getManufacturer() << endl;
|
||||
break;
|
||||
case 19:
|
||||
cout << "Get device ID: " << std::hex << temp->getDevicedId() << endl;
|
||||
break;
|
||||
case -1:
|
||||
break;
|
||||
default:
|
||||
cout << endl << "That option is not available. Try again" << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
}while (command != -1 );
|
||||
//! [Interesting]
|
||||
return MRAA_SUCCESS;
|
||||
}
|
@ -62,14 +62,15 @@ int main (int argc, char **argv)
|
||||
|
||||
sleep(1);
|
||||
|
||||
int gas;
|
||||
int temp;
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
co2->getData(&gas, &temp);
|
||||
cout << "CO2 concentration: " << gas << " PPM, "
|
||||
<< "Temperature (in C): " << temp <<endl;
|
||||
if(!co2->getData()){
|
||||
cerr << "Failed to retrieve data" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
cout << "CO2 concentration: " << co2->getGas() << " PPM, "
|
||||
<< "Temperature (in C): " << co2->getTemperature() <<endl;
|
||||
|
||||
sleep(2);
|
||||
}
|
||||
|
78
examples/c++/micsv89.cxx
Normal file
78
examples/c++/micsv89.cxx
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Author: Marc Graham <marc@m2ag.net>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "micsv89.h"
|
||||
|
||||
/*
|
||||
* An example for using the MICSV89 sensor library.
|
||||
* The MICSV89 comes in 4 variants, PWM and I2c
|
||||
* in 3.3 volts and 5 volts. This library only implements
|
||||
* the I2c version of the device.
|
||||
*
|
||||
* Device output is not valid until a warm up of 15 minutes
|
||||
* of operation.
|
||||
*
|
||||
* Additional linker flags: -lupm-micsv89
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
volatile int running = 1;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
cout << "Exiting program." << endl;
|
||||
running = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
upm::MICSV89 *sensor = new upm::MICSV89(6);
|
||||
|
||||
while(running)
|
||||
{
|
||||
sensor->update();
|
||||
while(!sensor->valid());
|
||||
cout << "co2: " << sensor->co2equ() << endl;
|
||||
cout << "short: " << sensor->vocshort() << endl;
|
||||
cout << "tvoc: " << sensor->tvoc() << endl;
|
||||
cout << "resistor: " << sensor->resistor() << endl;
|
||||
cout << "****************************" << endl;
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
delete sensor;
|
||||
//! [Interesting]
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
}
|
141
examples/c++/ozw.cxx
Normal file
141
examples/c++/ozw.cxx
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "ozw.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
|
||||
string defaultDev = "/dev/ttyACM0";
|
||||
|
||||
// if an argument was specified, use it as the device instead
|
||||
if (argc > 1)
|
||||
defaultDev = string(argv[1]);
|
||||
|
||||
// Instantiate an OZW instance
|
||||
upm::OZW *sensor = new upm::OZW();
|
||||
|
||||
// The first thing to do is create options, then lock them when done.
|
||||
sensor->optionsCreate();
|
||||
sensor->optionsLock();
|
||||
|
||||
// Next, initialize it.
|
||||
cout << "Initializing, this may take awhile depending on your ZWave network"
|
||||
<< endl;
|
||||
|
||||
if (!sensor->init(defaultDev))
|
||||
{
|
||||
cerr << "Init failed." << endl;
|
||||
return 0;
|
||||
}
|
||||
cout << "Initialization complete" << endl;
|
||||
|
||||
cout << "Dumping nodes..." << endl;
|
||||
|
||||
sensor->dumpNodes();
|
||||
|
||||
// The following is example output of dumpNodes:
|
||||
//
|
||||
// Dumping nodes...
|
||||
// Node 1: Z-Stick Gen5
|
||||
// Node 2: Smart Switch 6
|
||||
// Index: 0, Type: bool, Label: Switch, Value: False
|
||||
// Index: 2, Type: float, Label: Energy, Value: 1.190 kWh
|
||||
// Index: 3, Type: float, Label: Previous Reading, Value: 1.190 kWh
|
||||
// Index: 4, Type: int32, Label: Interval, Value: 1521 seconds
|
||||
// Index: 5, Type: float, Label: Power, Value: 0.000 W
|
||||
// Index: 6, Type: float, Label: Voltage, Value: 121.256 V
|
||||
// Index: 7, Type: float, Label: Current, Value: 0.000 A
|
||||
// Index: 8, Type: bool, Label: Exporting, Value: False
|
||||
// Index: 45, Type: list, Label: Day, Value: Friday
|
||||
// Index: 46, Type: byte, Label: Hour, Value: 5
|
||||
// Index: 47, Type: byte, Label: Minute, Value: 53
|
||||
// Node 3: Multi Sensor
|
||||
// Index: 0, Type: bool, Label: Sensor, Value: True
|
||||
// Index: 1, Type: float, Label: Temperature, Value: 72.8 F
|
||||
// Index: 2, Type: float, Label: Luminance, Value: 4 lux
|
||||
// Index: 3, Type: float, Label: Relative Humidity, Value: 22 %
|
||||
// Index: 17, Type: byte, Label: Battery Level, Value: 98 %
|
||||
// Node 5: Minimote
|
||||
// Node 6: Smart Energy Switch
|
||||
// Index: 0, Type: bool, Label: Switch, Value: False
|
||||
// Index: 2, Type: float, Label: Power, Value: 0.000 W
|
||||
// Index: 3, Type: float, Label: Energy, Value: 1.609 kWh
|
||||
// Index: 4, Type: float, Label: Previous Reading, Value: 1.609 kWh
|
||||
// Index: 5, Type: int32, Label: Interval, Value: 1521 seconds
|
||||
// Index: 6, Type: float, Label: Power, Value: 0.000 W
|
||||
// Index: 7, Type: float, Label: Previous Reading, Value: 1.609 W
|
||||
// Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
|
||||
// Index: 9, Type: bool, Label: Exporting, Value: False
|
||||
// Node 7: Smart Energy Switch
|
||||
// Index: 0, Type: bool, Label: Switch, Value: False
|
||||
// Index: 2, Type: float, Label: Power, Value: 0.000 W
|
||||
// Index: 3, Type: float, Label: Energy, Value: 0.000 kWh
|
||||
// Index: 4, Type: float, Label: Previous Reading, Value: 0.000 kWh
|
||||
// Index: 5, Type: int32, Label: Interval, Value: 1521 seconds
|
||||
// Index: 6, Type: float, Label: Power, Value: 0.000 W
|
||||
// Index: 7, Type: float, Label: Previous Reading, Value: 0.000 W
|
||||
// Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
|
||||
// Index: 9, Type: bool, Label: Exporting, Value: False
|
||||
//
|
||||
// So, with the above in mind:
|
||||
//
|
||||
// 1. Query the temperature on node 3 and print it out (as a
|
||||
// string), along with the units of measure:
|
||||
//
|
||||
// cout << "Temperature: " << sensor->getValueAsString(3, 1)
|
||||
// << " " << sensor->getValueUnits(3, 1) << endl;
|
||||
//
|
||||
// 2. query the same temperature as a float:
|
||||
//
|
||||
// float temperature = sensor->getValueAsFloat(3, 1);
|
||||
//
|
||||
// 3. Turn on the light plugged into the switch on Node 7, wait 5
|
||||
// seconds, then turn it back off again:
|
||||
//
|
||||
// cout << "Turning ON node 7" << endl;
|
||||
// sensor->setValueAsBool(7, 0, true);
|
||||
//
|
||||
// cout << "Sleeping for 5 seconds" << endl;
|
||||
// sleep(5);
|
||||
//
|
||||
// cout << "Turning OFF node 7" << endl;
|
||||
// sensor->setValueAsBool(7, 0, false);
|
||||
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
121
examples/c++/sx1276-fsk.cxx
Normal file
121
examples/c++/sx1276-fsk.cxx
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "sx1276.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Specify an argument to go into receive mode. Default is transmit"
|
||||
<< endl;
|
||||
|
||||
bool rx = false;
|
||||
if (argc > 1)
|
||||
rx = true;
|
||||
|
||||
// Instantiate an SX1276 using default parameters
|
||||
upm::SX1276 *sensor = new upm::SX1276();
|
||||
|
||||
// 915Mhz
|
||||
sensor->setChannel(915000000);
|
||||
|
||||
// FSK configuration (rx and tx must be configured the same):
|
||||
// Tx output power = 14 dBm
|
||||
// FSK freq deviation = 25000 Hz
|
||||
// FSK bandwidth = 50000 bps
|
||||
// FSK AFC bandwidth = 83333 Hz
|
||||
// FSK datarate = 50000 bps
|
||||
// FSK preamble len = 5
|
||||
// FSK fixed length payload = false
|
||||
// FSK CRC check = true
|
||||
// FSK (rx) continuous Rx mode = false
|
||||
|
||||
sensor->setTxConfig(sensor->MODEM_FSK, 14, 25000, 0,
|
||||
50000, 0, 5, false, true, false, 0, false);
|
||||
|
||||
sensor->setRxConfig(sensor->MODEM_FSK, 50000, 50000,
|
||||
0, 83333, 5, 0, false, 0, true,
|
||||
false, 0, false, true);
|
||||
|
||||
int count = 0;
|
||||
int buflen = 64;
|
||||
char buffer[buflen];
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
if (!rx)
|
||||
{
|
||||
snprintf(buffer, buflen, "Ping %d", count++);
|
||||
cout << "Sending..." << std::string(buffer) << endl;
|
||||
sensor->sendStr(string(buffer), 3000);
|
||||
|
||||
sensor->setSleep();
|
||||
sleep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// receiving
|
||||
cout << "Attempting to receive..." << endl;
|
||||
int rv;
|
||||
if (rv = sensor->setRx(3000))
|
||||
{
|
||||
cout << "setRx returned " << rv << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Received Buffer: " << sensor->getRxBufferStr() << endl;
|
||||
}
|
||||
|
||||
// go back to sleep when done
|
||||
sensor->setSleep();
|
||||
usleep(250000);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
119
examples/c++/sx1276-lora.cxx
Normal file
119
examples/c++/sx1276-lora.cxx
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "sx1276.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
cout << "Specify an argument to go into receive mode. Default is transmit"
|
||||
<< endl;
|
||||
|
||||
bool rx = false;
|
||||
if (argc > 1)
|
||||
rx = true;
|
||||
|
||||
// Instantiate an SX1276 using default parameters
|
||||
upm::SX1276 *sensor = new upm::SX1276();
|
||||
|
||||
// 915Mhz
|
||||
sensor->setChannel(915000000);
|
||||
|
||||
// LORA configuration (rx and tx must be configured the same):
|
||||
// Tx output power = 14 dBm
|
||||
// LORA bandwidth = 125000 (can also be 250K and 500K)
|
||||
// LORA spreading factor = 7
|
||||
// LORA coding rate = 1 (4/5)
|
||||
// LORA preamble len = 8
|
||||
// LORA symbol timeout = 5
|
||||
// LORA fixed payload = false
|
||||
// LORA IQ inversion = false
|
||||
// LORA (rx) continuous Rx mode = true
|
||||
|
||||
sensor->setTxConfig(sensor->MODEM_LORA, 14, 0, 125000,
|
||||
7, 1, 8, false, true, false, 0, false);
|
||||
|
||||
sensor->setRxConfig(sensor->MODEM_LORA, 125000, 7,
|
||||
1, 0, 8, 5, false, 0, true, false, 0, false, true);
|
||||
|
||||
int count = 0;
|
||||
int buflen = 64;
|
||||
char buffer[buflen];
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
if (!rx)
|
||||
{
|
||||
snprintf(buffer, buflen, "Ping %d", count++);
|
||||
cout << "Sending..." << std::string(buffer) << endl;
|
||||
sensor->sendStr(string(buffer), 3000);
|
||||
sensor->setSleep();
|
||||
sleep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// receiving
|
||||
cout << "Attempting to receive..." << endl;
|
||||
int rv;
|
||||
if (rv = sensor->setRx(3000))
|
||||
{
|
||||
cout << "setRx returned " << rv << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Received Buffer: " << sensor->getRxBufferStr() << endl;
|
||||
}
|
||||
|
||||
// go back to sleep when done
|
||||
sensor->setSleep();
|
||||
usleep(5000);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
66
examples/c++/urm37-uart.cxx
Normal file
66
examples/c++/urm37-uart.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 <iostream>
|
||||
#include <signal.h>
|
||||
#include "urm37.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a URM37 sensor on UART 0, with the reset pin on D2
|
||||
upm::URM37 *sensor = new upm::URM37(0, 2);
|
||||
|
||||
// Every half a second, sample the URM37 and output the measured
|
||||
// distance in cm, and temperature in degrees C
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << "Detected distance (cm): " << sensor->getDistance() << endl;
|
||||
cout << "Temperature (C): " << sensor->getTemperature() << endl;
|
||||
|
||||
usleep(500000);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
delete sensor;
|
||||
return 0;
|
||||
}
|
65
examples/c++/urm37.cxx
Normal file
65
examples/c++/urm37.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 <signal.h>
|
||||
#include "urm37.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a URM37 sensor on analog pin A0, reset pin on D2,
|
||||
// trigger pin on D3 with an analog reference voltage of 5.0
|
||||
upm::URM37 *sensor = new upm::URM37(0, 2, 3, 5.0);
|
||||
|
||||
// Every half a second, sample the URM37 and output the measured
|
||||
// distance in cm.
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << "Detected distance (cm): " << sensor->getDistance() << endl;
|
||||
usleep(500000);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
delete sensor;
|
||||
return 0;
|
||||
}
|
145
examples/c++/xbee.cxx
Normal file
145
examples/c++/xbee.cxx
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include "xbee.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
void printUsage(char *progname)
|
||||
{
|
||||
cout << "Usage: " << progname << " [AT command]" << endl;
|
||||
cout << endl;
|
||||
|
||||
cout << "If an argument is supplied on the command line, that argument is"
|
||||
<< endl;
|
||||
cout << "sent to the module and the response is printed out." << endl;
|
||||
cout << endl;
|
||||
cout << "If no argument is used, then the firmware revision, serial number"
|
||||
<< endl;
|
||||
cout << "and the current IP address (if set) are queried." << endl;
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
// simple helper function to send a command and wait for a response
|
||||
void sendCommand(upm::XBee* sensor, string cmd)
|
||||
{
|
||||
// commands need to be terminated with a carriage return
|
||||
cmd += "\r";
|
||||
|
||||
sensor->writeDataStr(cmd);
|
||||
|
||||
string resp;
|
||||
while (sensor->dataAvailable(2000))
|
||||
{
|
||||
resp += sensor->readDataStr(1024);
|
||||
}
|
||||
|
||||
if (resp.empty())
|
||||
{
|
||||
cerr << "Timed out waiting for response" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
resp = sensor->stringCR2LF(resp);
|
||||
cout << "Returned (" << resp.size() << " bytes): " << endl;
|
||||
cout << resp << endl;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
// Instantiate a XBee Module on UART 0
|
||||
upm::XBee* sensor = new upm::XBee(0);
|
||||
|
||||
// Set the baud rate, 9600 baud is the default.
|
||||
if (sensor->setBaudRate(9600))
|
||||
{
|
||||
cerr << "Failed to set tty baud rate" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
printUsage(argv[0]);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
// enable command mode
|
||||
sensor->commandMode();
|
||||
cout << "Sending command line argument (" << argv[1] << ")..." << endl;
|
||||
sendCommand(sensor, argv[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// enable command mode
|
||||
sensor->commandMode();
|
||||
// query the verbose firmware revision
|
||||
cout << "Querying verbose firmware revision (ATVL)..." << endl;
|
||||
sendCommand(sensor, "ATVL");
|
||||
// query the number
|
||||
cout << "Querying Serial Number High (ATSH)..." << endl;
|
||||
sendCommand(sensor, "ATSH");
|
||||
cout << "Querying Serial Number Low (ATSL)..." << endl;
|
||||
sendCommand(sensor, "ATSL");
|
||||
|
||||
cout << "Querying address, if set (ATMY)..." << endl;
|
||||
sendCommand(sensor, "ATMY");
|
||||
|
||||
// For the XBee WiFi S6B
|
||||
// A comprehensive list of commands and command modes is
|
||||
// available from the datasheet at:
|
||||
// ftp1.digi.com/support/documentation/90002180_L.pdf
|
||||
|
||||
// For the XBee S1
|
||||
// A comprehensive list of commands and command modes is
|
||||
// available from the datasheet at:
|
||||
// http://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf
|
||||
|
||||
// For the XBee WiFi module:
|
||||
// An example using AT commands to connect to an AP, with a
|
||||
// private Key using WPA2:
|
||||
|
||||
// Connect to AP with SSID 'mySSID':
|
||||
// ATIDmySSID
|
||||
|
||||
// Provide the private key 'secret':
|
||||
// ATPKsecret
|
||||
|
||||
// Use WPA2 encryption
|
||||
// ATEE2
|
||||
|
||||
}
|
||||
|
||||
|
||||
delete sensor;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
@ -23,29 +23,21 @@
|
||||
*/
|
||||
|
||||
public class A110XSample {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_a110x");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate an A110X sensor on digital pin D2
|
||||
upm_a110x.A110X a110x = new upm_a110x.A110X(2);
|
||||
upm_a110x.A110X hall = new upm_a110x.A110X(2);
|
||||
|
||||
// check every second for the presence of a magnetic field (south polarity)
|
||||
while(true){
|
||||
if(hall.magnetDetected())
|
||||
System.out.println("Magnet (south polarity) detected.");
|
||||
else
|
||||
System.out.println("No magnet detected.");
|
||||
|
||||
while(true) {
|
||||
if(a110x.magnetDetected()) {
|
||||
System.out.println("magnet detected...");
|
||||
}
|
||||
else {
|
||||
System.out.println("magnet not detected...");
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
}
|
||||
}
|
59
examples/java/A110X_intrSample.java
Normal file
59
examples/java/A110X_intrSample.java
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_a110x.IsrCallback;
|
||||
|
||||
public class A110X_intrSample {
|
||||
|
||||
public static int counter=0;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate an A110X sensor on digital pin D2
|
||||
upm_a110x.A110X hall = new upm_a110x.A110X(2);
|
||||
|
||||
// This example uses a user-supplied interrupt handler to count
|
||||
// pulses that occur when a magnetic field of the correct polarity
|
||||
// is detected. This could be used to measure the rotations per
|
||||
// minute (RPM) of a rotor for example.
|
||||
|
||||
IsrCallback callback = new A110XISR();
|
||||
hall.installISR(callback);
|
||||
|
||||
while(true){
|
||||
System.out.println("Counter: " + counter);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
}
|
||||
|
||||
class A110XISR extends IsrCallback {
|
||||
public A110XISR(){
|
||||
super();
|
||||
}
|
||||
public void run(){
|
||||
A110X_intrSample.counter++;
|
||||
}
|
||||
}
|
46
examples/java/ADC121C021Sample.java
Normal file
46
examples/java/ADC121C021Sample.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class ADC121C021Sample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate an ADC121C021 on I2C bus 0
|
||||
upm_adc121c021.ADC121C021 adc = new upm_adc121c021.ADC121C021(0);
|
||||
|
||||
// An analog sensor, such as a Grove light sensor,
|
||||
// must be attached to the adc·
|
||||
// Prints the value and corresponding voltage every 50 milliseconds
|
||||
while (true) {
|
||||
int val = adc.value();
|
||||
|
||||
System.out.println("ADC value: " + val + "Volts = " + adc.valueToVolts(val));
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -22,35 +22,30 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class Adxl345Sample {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_adxl345");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Note: Sensor only works at 3.3V on the Intel Edison with Arduino breakout
|
||||
upm_adxl345.Adxl345 obj = new upm_adxl345.Adxl345(0);
|
||||
int[] raw = new int[3];
|
||||
float[] accel = new float[3];
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
short[] val;
|
||||
float[] accel;
|
||||
|
||||
// Note: Sensor only works at 3.3V on the Intel Edison with Arduino
|
||||
// breakout
|
||||
upm_adxl345.Adxl345 sensor = new upm_adxl345.Adxl345(0);
|
||||
|
||||
while (true) {
|
||||
obj.update();
|
||||
raw = obj.getRawValues();
|
||||
accel = obj.getAcceleration();
|
||||
sensor.update();
|
||||
val = sensor.getRawValues();
|
||||
accel = sensor.getAcceleration();
|
||||
|
||||
System.out.println("raw data: " + raw[0] + " " + raw[1] + " " +
|
||||
raw[2]);
|
||||
System.out.println("accel data: " + accel[0] + " " + accel[1] + " "
|
||||
+ accel[2]);
|
||||
System.out.println("Current scale: " + sensor.getScale());
|
||||
System.out.println("Raw Values: X: " + val[0] + " Y: " + val[1] + " Z: " + val[2]);
|
||||
System.out.println("Acceleration: X: " + accel[0] + "g Y: " + accel[1] + "g Z: "
|
||||
+ accel[2] + "g");
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
47
examples/java/Apds9002.java
Normal file
47
examples/java/Apds9002.java
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_apds9002.APDS9002;
|
||||
|
||||
public class Apds9002 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
//! [Interesting]
|
||||
// Instantiate the APDS9002 (Grove luminance sensor) on the Analog pin A0
|
||||
APDS9002 lum = new APDS9002(0);
|
||||
|
||||
while(true){
|
||||
System.out.println("The Luminance value is : "+lum.value());
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("The following exception occured: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -24,15 +24,6 @@
|
||||
|
||||
public class BISS0001Sample{
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_biss0001");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove Motion sensor on GPIO pin D7
|
||||
|
@ -25,32 +25,24 @@
|
||||
//NOT TESTED!!!
|
||||
public class BMPX8XSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_bmpx8x");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate a BMPX8X sensor on I2C
|
||||
upm_bmpx8x.BMPX8X sensor = new upm_bmpx8x.BMPX8X(0);
|
||||
|
||||
// Print the pressure, altitude, sea level, and
|
||||
// temperature values every second
|
||||
while(true){
|
||||
while (true) {
|
||||
System.out.println("Pressure: " + sensor.getPressure());
|
||||
System.out.println("Altitude: " + sensor.getAltitude());
|
||||
System.out.println("Sealevel pressure: " + sensor.getSealevelPressure());
|
||||
System.out.println("Sealevel pressure: "
|
||||
+ sensor.getSealevelPressure());
|
||||
System.out.println("Temperature: " + sensor.getTemperature());
|
||||
System.out.println();
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
55
examples/java/BuzzerSample.java
Normal file
55
examples/java/BuzzerSample.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class BuzzerSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
int chord[] = {
|
||||
upm_buzzer.javaupm_buzzer.DO,
|
||||
upm_buzzer.javaupm_buzzer.RE,
|
||||
upm_buzzer.javaupm_buzzer.MI,
|
||||
upm_buzzer.javaupm_buzzer.FA,
|
||||
upm_buzzer.javaupm_buzzer.SOL,
|
||||
upm_buzzer.javaupm_buzzer.LA,
|
||||
upm_buzzer.javaupm_buzzer.SI};
|
||||
|
||||
// Instantiate a buzzer on digital pin D5
|
||||
upm_buzzer.Buzzer sound = new upm_buzzer.Buzzer(5);
|
||||
|
||||
// print sensor name
|
||||
System.out.println(sound.name());
|
||||
|
||||
for (int i = 0; i < chord.length; i++) {
|
||||
// play each note for one second
|
||||
int note = sound.playSound(chord[i], 1000000);
|
||||
System.out.println(note);
|
||||
|
||||
Thread.sleep(100);
|
||||
}
|
||||
// ! [Interesting]
|
||||
sound.stopSound();
|
||||
}
|
||||
|
||||
}
|
@ -24,15 +24,6 @@
|
||||
|
||||
public class Buzzer_soundSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_buzzer");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
int chord[] = {
|
||||
|
@ -22,28 +22,18 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class CJQ4435Sample{
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_cjq4435");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
public class CJQ4435Sample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
|
||||
upm_cjq4435.CJQ4435 mosfet = new upm_cjq4435.CJQ4435(3);
|
||||
|
||||
mosfet.setPeriodMS(10);
|
||||
mosfet.enable(true);
|
||||
|
||||
while(true){
|
||||
while (true) {
|
||||
// start with a duty cycle of 0.0 (off) and increment to 1.0 (on)
|
||||
for (float i=0; i <= 1; i+=0.1){
|
||||
for (float i = 0; i <= 1; i += 0.1) {
|
||||
mosfet.setDutyCycle(i);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
@ -51,13 +41,12 @@ public class CJQ4435Sample{
|
||||
|
||||
// Now take it back down
|
||||
// start with a duty cycle of 1.0 (on) and decrement to 0.0 (off)
|
||||
for (float i=1; i >= 0; i-=0.1){
|
||||
for (float i = 1; i >= 0; i -= 0.1) {
|
||||
mosfet.setDutyCycle(i);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
|
||||
}
|
74
examples/java/DS1307Sample.java
Normal file
74
examples/java/DS1307Sample.java
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class DS1307Sample {
|
||||
|
||||
static private void printTime(upm_ds1307.DS1307 rtc) {
|
||||
System.out.print("The time is: " + rtc.getMonth() + "/" + rtc.getDayOfMonth() + "/"
|
||||
+ rtc.getYear() + " " + rtc.getHours() + ":" + rtc.getMinutes() + ":"
|
||||
+ rtc.getSeconds());
|
||||
|
||||
if (rtc.getAmPmMode()) {
|
||||
if (rtc.getAmPmMode())
|
||||
System.out.print(" PM");
|
||||
else
|
||||
System.out.print(" AM");
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
|
||||
if (rtc.getAmPmMode())
|
||||
System.out.println("Clock is in AM/PM mode");
|
||||
else
|
||||
System.out.println("Clock is in 24h mode");
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a DS1037 on I2C bus 0
|
||||
upm_ds1307.DS1307 rtc = new upm_ds1307.DS1307(0);
|
||||
|
||||
// always do this first
|
||||
System.out.println("Loading the current time...");
|
||||
if (!rtc.loadTime()) {
|
||||
System.err.println("rtc->loadTime() failed.");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
printTime(rtc);
|
||||
|
||||
// set the year as an example
|
||||
System.out.println("setting the year to 50");
|
||||
rtc.setYear(50);
|
||||
rtc.setTime();
|
||||
|
||||
// reload the time and print it
|
||||
rtc.loadTime();
|
||||
printTime(rtc);
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -26,17 +26,8 @@
|
||||
public class ENC03RSample {
|
||||
private static final long CALIBRATION_SAMPLES = 1000;
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_enc03r");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
|
||||
// Instantiate a ENC03R on analog pin A0
|
||||
upm_enc03r.ENC03R gyro = new upm_enc03r.ENC03R(0);
|
||||
@ -50,7 +41,7 @@ public class ENC03RSample {
|
||||
|
||||
// Read the input and print both the raw value and the angular velocity,
|
||||
// waiting 1 second between readings
|
||||
while(true){
|
||||
while (true) {
|
||||
long val = gyro.value();
|
||||
double av = gyro.angularVelocity(val);
|
||||
|
||||
@ -58,7 +49,7 @@ public class ENC03RSample {
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -22,43 +22,32 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//import upm_servo.ES08A;
|
||||
|
||||
public class ES08ASample{
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_servo");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public class ES08ASample {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
upm_servo.ES08A servo = new upm_servo.ES08A(6);
|
||||
|
||||
// Sets the shaft to 180, then to 90, then to 0,
|
||||
// then back to 90, and finally back to 180,
|
||||
// pausing for a second in between each angle
|
||||
servo.setAngle (180);
|
||||
servo.setAngle(180);
|
||||
System.out.println("Set angle to 180");
|
||||
Thread.sleep(1000);
|
||||
|
||||
servo.setAngle (90);
|
||||
servo.setAngle(90);
|
||||
System.out.println("Set angle to 90");
|
||||
Thread.sleep(1000);
|
||||
|
||||
servo.setAngle (0);
|
||||
servo.setAngle(0);
|
||||
System.out.println("Set angle to 0");
|
||||
Thread.sleep(1000);
|
||||
|
||||
servo.setAngle (90);
|
||||
servo.setAngle(90);
|
||||
System.out.println("Set angle to 90");
|
||||
Thread.sleep(1000);
|
||||
|
||||
servo.setAngle (180);
|
||||
servo.setAngle(180);
|
||||
System.out.println("Set angle to 180");
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
66
examples/java/GROVESCAMSample.java
Normal file
66
examples/java/GROVESCAMSample.java
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class GROVESCAMSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a Grove Serial Camera on UART 0
|
||||
upm_grovescam.GROVESCAM camera = new upm_grovescam.GROVESCAM(0);
|
||||
|
||||
// make sure port is initialized properly. 115200 baud is the default.
|
||||
if (!camera.setupTty()) {
|
||||
System.err.println("Failed to setup tty port parameters");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
if (camera.init())
|
||||
System.out.println("Initialized...");
|
||||
else
|
||||
System.out.println("Initialization failed");
|
||||
|
||||
if (camera.preCapture())
|
||||
System.out.println("preCapture succeeded...");
|
||||
else
|
||||
System.out.println("preCapture failed.");
|
||||
|
||||
if (camera.doCapture())
|
||||
System.out.println("doCapture succeeded...");
|
||||
else
|
||||
System.out.println("doCapture failed.");
|
||||
|
||||
if (camera.getImageSize() > 0) {
|
||||
System.out.println("Storing image.jpg...");
|
||||
|
||||
if (camera.storeImage("image.jpg"))
|
||||
System.out.println("storeImage succeeded...");
|
||||
else
|
||||
System.out.println("storeImage failed.");
|
||||
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -22,35 +22,25 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//import upm_guvas12d.GUVAS12D;
|
||||
|
||||
public class GUVAS12DSample{
|
||||
public class GUVAS12DSample {
|
||||
// analog voltage, usually 3.3 or 5.0
|
||||
private static final float GUVAS12D_AREF = 5;
|
||||
private static final int SAMPLES_PER_QUERY = 1024;
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_guvas12d");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate a GUVAS12D on analog pin A3
|
||||
upm_guvas12d.GUVAS12D volts = new upm_guvas12d.GUVAS12D(3);
|
||||
|
||||
while (true) {
|
||||
float value = volts.value(GUVAS12D_AREF, SAMPLES_PER_QUERY);
|
||||
|
||||
System.out.println("AREF: " + GUVAS12D_AREF + ", Voltage value (higher means more UV): " + value );
|
||||
System.out.println("AREF: " + GUVAS12D_AREF
|
||||
+ ", Voltage value (higher means more UV): " + value);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -22,28 +22,19 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveButtonSample{
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grove");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
public class GroveButtonSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Create the button object using UART
|
||||
upm_grove.GroveButton button = new upm_grove.GroveButton(0);
|
||||
// ! [Interesting]
|
||||
// Create the button object using GPIO pin 2
|
||||
upm_grove.GroveButton button = new upm_grove.GroveButton(2);
|
||||
|
||||
while (true) {
|
||||
System.out.println(button.name() +" value is " + button.value());
|
||||
System.out.println(button.name() + " value is " + button.value());
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
56
examples/java/GroveButton_intrSample.java
Normal file
56
examples/java/GroveButton_intrSample.java
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_grove.IsrCallback;
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class GroveButton_intrSample {
|
||||
|
||||
public static int counter = 0;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_grove.GroveButton b = new upm_grove.GroveButton(2);
|
||||
|
||||
IsrCallback callback = new ButtonISR();
|
||||
b.installISR(mraa.Edge.EDGE_RISING.swigValue(), callback);
|
||||
|
||||
while (true) {
|
||||
System.out.println("Counter: " + counter);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
||||
|
||||
class ButtonISR extends IsrCallback {
|
||||
public ButtonISR() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
GroveButton_intrSample.counter++;
|
||||
System.out.println("Button pressed!");
|
||||
}
|
||||
}
|
50
examples/java/GroveCollision.java
Normal file
50
examples/java/GroveCollision.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_grovecollision.*;
|
||||
|
||||
public class GroveCollision {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
// Initializing the sensor on D2 on the Base Shield
|
||||
upm_grovecollision.GroveCollision collision = new upm_grovecollision.GroveCollision(2);
|
||||
boolean collisionState = false;
|
||||
|
||||
// ! [Interesting]
|
||||
while(shouldRun){
|
||||
if(collision.isColliding() && !collisionState){
|
||||
System.out.println("Collision!!");
|
||||
collisionState = true;
|
||||
}
|
||||
else if (collisionState){
|
||||
System.out.println("No Collision!");
|
||||
collisionState = false;
|
||||
}
|
||||
}
|
||||
// ! [Interesting]
|
||||
System.out.println("Exiting");
|
||||
}
|
||||
|
||||
}
|
53
examples/java/GroveEHRSample.java
Normal file
53
examples/java/GroveEHRSample.java
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class GroveEHRSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
|
||||
upm_groveehr.GroveEHR heart = new upm_groveehr.GroveEHR(2);
|
||||
|
||||
// set the beat counter to 0, init the clock and start counting beats
|
||||
heart.clearBeatCounter();
|
||||
heart.initClock();
|
||||
heart.startBeatCounter();
|
||||
|
||||
while (true) {
|
||||
long millis = heart.getMillis();
|
||||
long beats = heart.beatCounter();
|
||||
|
||||
// heartRate() requires that at least 5 seconds pass before
|
||||
// returning anything other than 0
|
||||
int hr = heart.heartRate();
|
||||
|
||||
// output milliseconds passed, beat count, and computed heart rate
|
||||
System.out.println("Millis: " + millis + ", Beats: " + beats + ", Heart rate: " + hr);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
47
examples/java/GroveEmg.java
Normal file
47
examples/java/GroveEmg.java
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
import upm_groveemg.GroveEMG;
|
||||
|
||||
public class GroveEmg {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
//! [Interesting]
|
||||
// Instantiating the Grove EMG sensor on Analog pin 0
|
||||
GroveEMG emg = new GroveEMG(0);
|
||||
System.out.println("Calibrating ... ");
|
||||
emg.calibrate();
|
||||
|
||||
while(true){
|
||||
System.out.println("EMG Val: "+emg.value());
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("The following exception occured: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
50
examples/java/GroveGsr.java
Normal file
50
examples/java/GroveGsr.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_grovegsr.GroveGSR;
|
||||
|
||||
public class GroveGsr {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove GSR sensor on analog pin A0
|
||||
GroveGSR gsr = new GroveGSR(0);
|
||||
System.out.println("Calibrating...");
|
||||
gsr.calibrate();
|
||||
|
||||
while(true){
|
||||
System.out.println("Value: "+gsr.value());
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("The following exception occured: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -23,15 +23,6 @@
|
||||
*/
|
||||
|
||||
public class GroveLEDSample {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grove");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main (String args[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
upm_grove.GroveLed led = new upm_grove.GroveLed(2);
|
||||
|
45
examples/java/GroveLed_multiSample.java
Normal file
45
examples/java/GroveLed_multiSample.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class GroveLed_multiSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a grove LED on D2. Here we are controlling a Grove
|
||||
// Multi-color flash LED. We just just need to turn it on - it will
|
||||
// then cycle through various colors (red, green, blue, purple) on it's
|
||||
// own until turned off.
|
||||
upm_grove.GroveLed led = new upm_grove.GroveLed(2);
|
||||
|
||||
// start the light show
|
||||
led.on();
|
||||
|
||||
// just sleep until interrupted
|
||||
while (true) {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -23,17 +23,8 @@
|
||||
*/
|
||||
|
||||
public class GroveLightSample {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grove");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main (String args[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_grove.GroveLight gl = new upm_grove.GroveLight(2);
|
||||
|
||||
while (true) {
|
||||
@ -45,6 +36,6 @@ public class GroveLightSample {
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -22,34 +22,24 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveLineFinderSample{
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grovelinefinder");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
public class GroveLineFinderSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate a Grove Line Finder sensor on digital pin D2
|
||||
upm_grovelinefinder.GroveLineFinder finder = new upm_grovelinefinder.GroveLineFinder(2);
|
||||
// check every second for the presence of white detection
|
||||
while(true){
|
||||
while (true) {
|
||||
boolean val = finder.whiteDetected();
|
||||
if(val){
|
||||
if (val) {
|
||||
System.out.println("White detected");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
System.out.println("Black detected");
|
||||
}
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
53
examples/java/GroveMDSample.java
Normal file
53
examples/java/GroveMDSample.java
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveMDSample {
|
||||
private static final short speed50 = 127;
|
||||
private static final short speed0 = 0;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate an I2C Grove Motor Driver on I2C bus 0
|
||||
upm_grovemd.GroveMD motors = new upm_grovemd.GroveMD();
|
||||
|
||||
// set direction to clockwise (CW) and set speed to 50%
|
||||
System.out.println("Spin M1 and M2 at half speed for 3 seconds");
|
||||
motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW,
|
||||
upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW);
|
||||
motors.setMotorSpeeds(speed50, speed50);
|
||||
Thread.sleep(3000);
|
||||
|
||||
// counter clockwise (CCW)
|
||||
System.out.println("Reversing M1 and M2 for 3 seconds");
|
||||
motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW,
|
||||
upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW);
|
||||
Thread.sleep(3000);
|
||||
|
||||
// stop motors
|
||||
System.out.println("Stopping motors");
|
||||
motors.setMotorSpeeds(speed0, speed0);
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
70
examples/java/GroveMQ3.java
Normal file
70
examples/java/GroveMQ3.java
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_gas.Gas;
|
||||
import upm_gas.MQ2;
|
||||
import upm_gas.MQ3;
|
||||
import upm_gas.MQ4;
|
||||
import upm_gas.MQ5;
|
||||
import upm_gas.MQ6;
|
||||
import upm_gas.MQ7;
|
||||
import upm_gas.MQ8;
|
||||
import upm_gas.MQ9;
|
||||
import upm_gas.TP401;
|
||||
import upm_gas.thresholdContext;
|
||||
|
||||
public class GroveMQ3 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
//! [Interesting]
|
||||
// initialize the sensor on A0
|
||||
MQ3 mq3 = new MQ3(0);
|
||||
|
||||
short[] buffer = new short[128];
|
||||
|
||||
thresholdContext context = new thresholdContext();
|
||||
|
||||
context.setAverageReading(0);
|
||||
context.setRunningAverage(0);
|
||||
context.setAveragedOver(2);
|
||||
|
||||
int len;
|
||||
int thres;
|
||||
while(true){
|
||||
len = mq3.getSampledWindow((long)2, buffer);
|
||||
|
||||
if(len != 0){
|
||||
thres = mq3.findThreshold(context, 30, buffer);
|
||||
mq3.printGraph(context, (short)5);
|
||||
if(thres != 0){
|
||||
// do something
|
||||
System.out.println("threshold is crossed");
|
||||
}
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
|
||||
}
|
70
examples/java/GroveMQ9.java
Normal file
70
examples/java/GroveMQ9.java
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_gas.Gas;
|
||||
import upm_gas.MQ2;
|
||||
import upm_gas.MQ3;
|
||||
import upm_gas.MQ4;
|
||||
import upm_gas.MQ5;
|
||||
import upm_gas.MQ6;
|
||||
import upm_gas.MQ7;
|
||||
import upm_gas.MQ8;
|
||||
import upm_gas.MQ9;
|
||||
import upm_gas.TP401;
|
||||
import upm_gas.thresholdContext;
|
||||
|
||||
public class GroveMQ9 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
//! [Interesting]
|
||||
// initialize the sensor on A0
|
||||
MQ9 mq9 = new MQ9(0);
|
||||
|
||||
short[] buffer = new short[128];
|
||||
|
||||
thresholdContext context = new thresholdContext();
|
||||
|
||||
context.setAverageReading(0);
|
||||
context.setRunningAverage(0);
|
||||
context.setAveragedOver(2);
|
||||
|
||||
int len;
|
||||
int thres;
|
||||
while(true){
|
||||
len = mq9.getSampledWindow((long)2, buffer);
|
||||
|
||||
if(len != 0){
|
||||
thres = mq9.findThreshold(context, 30, buffer);
|
||||
mq9.printGraph(context, (short)5);
|
||||
if(thres != 0){
|
||||
// do something
|
||||
System.out.println("threshold is crossed");
|
||||
}
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -22,18 +22,9 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveMoistureSample{
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grovemoisture");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main (String args[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
public class GroveMoistureSample {
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_grovemoisture.GroveMoisture gm = new upm_grovemoisture.GroveMoisture(1);
|
||||
|
||||
while (true) {
|
||||
@ -47,10 +38,10 @@ public class GroveMoistureSample{
|
||||
else
|
||||
result = "Wet";
|
||||
|
||||
System.out.println("Moisture Value: " + moisture_val + ", " + result );
|
||||
System.out.println("Moisture Value: " + moisture_val + ", " + result);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
46
examples/java/GroveO2Example.java
Normal file
46
examples/java/GroveO2Example.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_groveo2.GroveO2;
|
||||
|
||||
public class GroveO2Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
//! [Interesting]
|
||||
// Initializing the Grove O2 sensor on the A) analog pin
|
||||
GroveO2 o2 = new GroveO2(0);
|
||||
|
||||
while(true){
|
||||
System.out.println("The output voltage is: "+o2.voltageValue());
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("The following exception has occured: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
}
|
69
examples/java/GroveQTouch.java
Normal file
69
examples/java/GroveQTouch.java
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_at42qt1070.AT42QT1070;
|
||||
|
||||
public class GroveQTouch {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
// Instantiating the Q Touch sensor on the I2C bus 0
|
||||
AT42QT1070 touch = new AT42QT1070(0, (short) 0x1b);
|
||||
short pressedButtons;
|
||||
|
||||
// ! [Interesting]
|
||||
while(true){
|
||||
touch.updateState();
|
||||
printButtons(touch.getButtons());
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
/**
|
||||
* This function prints out the button numbers from 0 through 6
|
||||
* @param buttonNumber
|
||||
*/
|
||||
public static void printButtons(int buttonNumber){
|
||||
boolean buttonPressed = false;
|
||||
System.out.print("Button Pressed: ");
|
||||
for(int i=0;i<7;i++){
|
||||
if((buttonNumber & (1<<i)) != 0){
|
||||
System.out.println(i+" ");
|
||||
buttonPressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!buttonPressed){
|
||||
System.out.println("None ");
|
||||
}
|
||||
}
|
||||
}
|
@ -22,32 +22,23 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveRelaySample{
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grove");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public class GroveRelaySample {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Create the button object using UART
|
||||
upm_grove.GroveRelay relay = new upm_grove.GroveRelay(5);
|
||||
|
||||
for( int i = 0 ; i < 3 ; i++ ){
|
||||
for (int i = 0; i < 3; i++) {
|
||||
relay.on();
|
||||
if( relay.isOn() )
|
||||
if (relay.isOn())
|
||||
System.out.println("Relay is on");
|
||||
Thread.sleep(1000);
|
||||
|
||||
relay.off();
|
||||
if( relay.isOff() )
|
||||
if (relay.isOff())
|
||||
System.out.println("Relay is off");
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -22,19 +22,10 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveRotarySample{
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grove");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
public class GroveRotarySample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
upm_grove.GroveRotary knob = new upm_grove.GroveRotary(0);
|
||||
|
||||
while (true) {
|
||||
@ -45,12 +36,14 @@ public class GroveRotarySample{
|
||||
float rel_deg = knob.rel_deg(); // Relative degrees
|
||||
float rel_rad = knob.rel_rad(); // Relative radians
|
||||
|
||||
System.out.println( "Absolute: " + abs_value + " raw, " + abs_deg + " deg, " + abs_rad + " rad" );
|
||||
System.out.println( "Relative: " + rel_value + " raw, " + rel_deg + " deg, " + rel_rad + " rad" );
|
||||
System.out.println("Absolute: " + abs_value + " raw, " + abs_deg + " deg, " + abs_rad
|
||||
+ " rad");
|
||||
System.out.println("Relative: " + rel_value + " raw, " + rel_deg + " deg, " + rel_rad
|
||||
+ " rad");
|
||||
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -23,15 +23,6 @@
|
||||
*/
|
||||
|
||||
public class GroveSlideSample {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grove");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main (String args[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate new grove slide potentiometer on analog pin A0
|
||||
|
@ -22,19 +22,10 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveSpeakerSample{
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grovespeaker");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
public class GroveSpeakerSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate a Grove Speaker on digital pin D2
|
||||
upm_grovespeaker.GroveSpeaker speaker = new upm_grovespeaker.GroveSpeaker(2);
|
||||
|
||||
@ -43,7 +34,7 @@ public class GroveSpeakerSample{
|
||||
|
||||
// Play a medium C-sharp
|
||||
speaker.playSound('c', true, "med");
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -23,15 +23,6 @@
|
||||
*/
|
||||
|
||||
public class GroveTempSample {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grove");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main (String args[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
upm_grove.GroveTemp temp = new upm_grove.GroveTemp(3);
|
||||
|
@ -27,32 +27,24 @@ public class GroveVDivSample {
|
||||
private static final short gain3 = 3;
|
||||
private static final short gain10 = 10;
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_grovevdiv");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate a Grove Voltage Divider sensor on analog pin A0
|
||||
upm_grovevdiv.GroveVDiv vDiv = new upm_grovevdiv.GroveVDiv(0);
|
||||
|
||||
// collect data and output measured voltage according to the setting
|
||||
// of the scaling switch (3 or 10)
|
||||
while(true){
|
||||
while (true) {
|
||||
long val = vDiv.value(100);
|
||||
float gain3val = vDiv.computedValue(gain3, val);
|
||||
float gain10val = vDiv.computedValue(gain10, val);
|
||||
|
||||
System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: " + gain10val);
|
||||
System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: "
|
||||
+ gain10val);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
44
examples/java/GroveWFSSample.java
Normal file
44
examples/java/GroveWFSSample.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class GroveWFSSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a Grove Water Flow Sensor on digital pin D2
|
||||
upm_grovewfs.GroveWFS flow = new upm_grovewfs.GroveWFS(2);
|
||||
|
||||
flow.clearFlowCounter();
|
||||
flow.startFlowCounter();
|
||||
|
||||
while (true) {
|
||||
System.out.print("Millis: " + flow.getMillis() + " FlowCount: " + flow.flowCounter());
|
||||
System.out.println(" Flow Rate: " + flow.flowRate() + " LPM");
|
||||
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -22,35 +22,24 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveWaterSample{
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_grovewater");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
public class GroveWaterSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate a Grove Water sensor on digital pin D2
|
||||
upm_grovewater.GroveWater water = new upm_grovewater.GroveWater(2);
|
||||
|
||||
while (true) {
|
||||
boolean val = water.isWet();
|
||||
if (val){
|
||||
if (val) {
|
||||
System.out.println("Sensor is wet");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
System.out.println("Sensor is dry");
|
||||
}
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
|
||||
}
|
52
examples/java/H3LIS331DLSample.java
Normal file
52
examples/java/H3LIS331DLSample.java
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class H3LIS331DLSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
int[] val;
|
||||
float[] accel;
|
||||
|
||||
// Instantiate an H3LIS331DL on I2C bus 0
|
||||
upm_h3lis331dl.H3LIS331DL sensor = new upm_h3lis331dl.H3LIS331DL(0);
|
||||
|
||||
// Initialize the device with default values
|
||||
sensor.init();
|
||||
|
||||
while(true){
|
||||
sensor.update();
|
||||
|
||||
val = sensor.getRawXYZ();
|
||||
System.out.println( "Raw: X: " + val[0] + " Y: " + val[1] + " Z: " + val[2] );
|
||||
|
||||
accel = sensor.getAcceleration();
|
||||
System.out.println( "Acceleration: X: " + accel[0] + " Y: " + accel[1] + " Z: " + accel[2] );
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
}
|
43
examples/java/HCSR04Sample.java
Normal file
43
examples/java/HCSR04Sample.java
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class HCSR04Sample {
|
||||
|
||||
// ! [Interesting]
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
upm_hcsr04.HCSR04 sonar = new upm_hcsr04.HCSR04((short) 5, (short) 6);
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
while (true) {
|
||||
System.out.println("Get distance");
|
||||
double distance = sonar.getDistance(upm_hcsr04.javaupm_hcsr04Constants.CM);
|
||||
System.out.println("Distance: " + distance);
|
||||
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
// ! [Interesting]
|
96
examples/java/HM11Sample.java
Normal file
96
examples/java/HM11Sample.java
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class HM11Sample {
|
||||
|
||||
private static final int BUFSIZ = 1024;
|
||||
|
||||
private static void printUsage() {
|
||||
System.out.println("Usage: java HM11Sample [AT command]");
|
||||
|
||||
System.out.println("If an argument is supplied on the command line, that argument is");
|
||||
System.out.println("sent to the module and the response is printed out.");
|
||||
System.out.println("If no argument is used, then the address and PIN of the module");
|
||||
System.out.println("are queried and the results printed out.");
|
||||
|
||||
}
|
||||
|
||||
private static void sendCommand(upm_hm11.HM11 ble, byte[] cmd) {
|
||||
byte[] buffer = new byte[BUFSIZ];
|
||||
ble.writeData(cmd);
|
||||
|
||||
// wait up to 1 second
|
||||
if (ble.dataAvailable(1000)) {
|
||||
ble.readData(buffer);
|
||||
} else {
|
||||
System.err.println("Timed out waiting for response");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a HM11 BLE Module on UART 0
|
||||
upm_hm11.HM11 ble = new upm_hm11.HM11(0);
|
||||
|
||||
// make sure port is initialized properly. 9600 baud is the default.
|
||||
if (!ble.setupTty()) {
|
||||
System.err.println("Failed to setup tty port parameters");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
printUsage();
|
||||
|
||||
if (args.length > 0) {
|
||||
System.out.println("Sending command line argument (" + args[0] + ")...");
|
||||
sendCommand(ble, args[0].getBytes());
|
||||
} else {
|
||||
// query the module address
|
||||
String addr = "AT+ADDR?";
|
||||
System.out.println("Querying module address (" + addr + ")...");
|
||||
sendCommand(ble, addr.getBytes());
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
// query the module address
|
||||
String pin = "AT+PASS?";
|
||||
System.out.println("Querying module pin (" + pin + ")...");
|
||||
sendCommand(ble, pin.getBytes());
|
||||
|
||||
// Other potentially useful commands are:
|
||||
//
|
||||
// AT+VERS? - query module version
|
||||
// AT+ROLE0 - set as slave
|
||||
// AT+ROLE1 - set as master
|
||||
// AT+CLEAR - clear all previous settings
|
||||
// AT+RESET - restart the device
|
||||
//
|
||||
// A comprehensive list is available from the datasheet at:
|
||||
// http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf
|
||||
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
122
examples/java/HMTRPSample.java
Normal file
122
examples/java/HMTRPSample.java
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class HMTRPSample {
|
||||
|
||||
static private final int bufferLength = 255;
|
||||
|
||||
private static void printUsage() {
|
||||
System.out.println("Usage:");
|
||||
System.out.println("Pass a commandline argument (any argument) to this program");
|
||||
System.out.println("to query the radio configuration and output it. NOTE: the");
|
||||
System.out.println("radio must be in CONFIG mode for this to work.");
|
||||
System.out.println("Running this program without arguments will simply transmit");
|
||||
System.out.println("'Hello World!' every second, and output any data received from");
|
||||
System.out.println("another radio.");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a HMTRP radio device on uart 0
|
||||
upm_hmtrp.HMTRP radio = new upm_hmtrp.HMTRP(0);
|
||||
|
||||
// make sure port is initialized properly. 9600 baud is the default.
|
||||
if (!radio.setupTty()) {
|
||||
System.err.println("Failed to setup tty port parameters");
|
||||
System.exit(-1);
|
||||
}
|
||||
printUsage();
|
||||
|
||||
// By default, this radio simply transmits data sent via writeData()
|
||||
// and reads any available data via readData().
|
||||
|
||||
// It can be placed into a configuration mode by grounding the
|
||||
// CONFIG pin on the module. When this is done, the various
|
||||
// configuration query and config methods can be used. In this
|
||||
// example, by default, we just read any data available fom the
|
||||
// device, and periodically transmit "Hello World".
|
||||
|
||||
// If any argument was specified on the command line, do a simple
|
||||
// configuration query and output the results. The radio must be in·
|
||||
// CONFIG mode for this to work.
|
||||
|
||||
if (args.length > 0) {
|
||||
// config mode
|
||||
long[] freq = {0};
|
||||
long[] dataRate = {0};
|
||||
int[] rxBandwidth = {0};
|
||||
short[] modulation = {0};
|
||||
short[] txPower = {0};
|
||||
long[] uartBaud = {0};
|
||||
|
||||
if (radio.getConfig(freq, dataRate, rxBandwidth, modulation, txPower, uartBaud)) {
|
||||
System.out.println("Radio configuration:");
|
||||
System.out.println("freq: " + freq[0] + " dataRate: " + dataRate[0]
|
||||
+ " rxBandwidth: " + rxBandwidth[0] + "Khz");
|
||||
System.out.println("modulation: " + modulation[0] + "Khz txPower: " + txPower[0]
|
||||
+ " uartBaud: " + uartBaud[0]);
|
||||
} else {
|
||||
System.err.println("getConfig() failed. Make sure the radio is in CONFIG mode.");
|
||||
}
|
||||
} else {
|
||||
// normal read/write mode
|
||||
byte[] radioBuffer = new byte[bufferLength];
|
||||
byte[] hello = "Hello World".getBytes();
|
||||
int counter = 0;
|
||||
|
||||
System.out.println("Running in normal read/write mode.");
|
||||
|
||||
while (true) {
|
||||
// we don't want the read to block in this example, so always
|
||||
// check to see if data is available first.
|
||||
if (radio.dataAvailable()) {
|
||||
int rv = radio.readData(radioBuffer);
|
||||
|
||||
if (rv > 0) {
|
||||
System.out.print("Received: ");
|
||||
for (int i = 0; i < radioBuffer.length; i++)
|
||||
System.out.print((char) radioBuffer[i]);
|
||||
System.out.println();
|
||||
} else {
|
||||
System.err.println("Port read error.");
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
counter++;
|
||||
// every second, transmit "Hello World!"
|
||||
if (counter > 10) {
|
||||
System.out.println("Transmitting hello world...");
|
||||
radio.writeData(hello);
|
||||
counter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
50
examples/java/HP20xExample.java
Normal file
50
examples/java/HP20xExample.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_hp20x.HP20X;
|
||||
|
||||
public class HP20xExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate the sensor on the default I2C bus and sensor
|
||||
HP20X hp20x = new HP20X();
|
||||
|
||||
// Initializing the sensor with the default values
|
||||
hp20x.init();
|
||||
|
||||
while(true){
|
||||
System.out.println("Temperature: "+hp20x.getTemperature()+"\tPressure: "+hp20x.getPressure()+"\tAltitude: "+hp20x.getAltitude());
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("The following exception occured: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
}
|
50
examples/java/HTU21DSample.java
Normal file
50
examples/java/HTU21DSample.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class HTU21DSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
float humidity = 0;
|
||||
float temperature = 0;
|
||||
float compRH = 0;
|
||||
|
||||
upm_htu21d.HTU21D sensor = new upm_htu21d.HTU21D(0);
|
||||
sensor.testSensor();
|
||||
|
||||
while (true) {
|
||||
compRH = sensor.getCompRH();
|
||||
humidity = sensor.getHumidity();
|
||||
temperature = sensor.getTemperature();
|
||||
|
||||
System.out.println("Humidity: " + humidity + ", Temperature: " + temperature
|
||||
+ ", compensated RH: " + compRH);
|
||||
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -22,39 +22,29 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class Hmc5883lSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_hmc5883l");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate on I2C
|
||||
upm_hmc5883l.Hmc5883l compas = new upm_hmc5883l.Hmc5883l(0);
|
||||
|
||||
int[] pos;
|
||||
short[] pos;
|
||||
|
||||
// Set your declination from true north in radians
|
||||
compas.set_declination(0.2749f);
|
||||
|
||||
while(true){
|
||||
while (true) {
|
||||
// Update the coordinates
|
||||
compas.update();
|
||||
|
||||
pos = compas.coordinates();
|
||||
System.out.println("Coor: " + pos[0] + " " + pos[1] + " " + pos[2]);
|
||||
System.out.println("Heading: " + compas.heading() + " Direction:" + compas.heading());
|
||||
System.out.println("Heading: " + compas.heading() + " Direction:" + compas.direction());
|
||||
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
51
examples/java/Itg3200Sample.java
Normal file
51
examples/java/Itg3200Sample.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class Itg3200Sample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
short[] rot;
|
||||
float[] ang;
|
||||
|
||||
// Note: Sensor not supported on Intel Edison with Arduino breakout
|
||||
upm_itg3200.Itg3200 gyro = new upm_itg3200.Itg3200(0);
|
||||
|
||||
while (true) {
|
||||
gyro.update();
|
||||
rot = gyro.getRawValues();
|
||||
ang = gyro.getRotation();
|
||||
|
||||
System.out.println("Raw Values: X: " + rot[0] + " Y: " + rot[1] + " Z: " + rot[2]);
|
||||
System.out.println("Angular Velocities: X: " + ang[0] + " Y: " + ang[1] + " Z: "
|
||||
+ ang[2]);
|
||||
|
||||
System.out.println("Temp: " + gyro.getTemperature() + ", Raw: " + gyro.getRawTemp());
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
42
examples/java/Jhd1313m1Sample.java
Normal file
42
examples/java/Jhd1313m1Sample.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class Jhd1313m1Sample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_i2clcd.Jhd1313m1 lcd = new upm_i2clcd.Jhd1313m1(0);
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.write("Hello World");
|
||||
lcd.setCursor(1, 2);
|
||||
lcd.write("Hello World");
|
||||
|
||||
System.out.println("Sleeping for 5 seconds");
|
||||
Thread.sleep(5000);
|
||||
lcd.clear();
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -24,15 +24,6 @@
|
||||
|
||||
public class Jhd1313m1_lcdSample{
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_i2clcd");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
upm_i2clcd.Jhd1313m1 lcd = new upm_i2clcd.Jhd1313m1(1, 0x3E, 0x62);
|
||||
|
@ -22,18 +22,8 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class Joystick12_exampleSample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_joystick12");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate a joystick on analog pins A0 and A1
|
||||
|
42
examples/java/LDT0028Sample.java
Normal file
42
examples/java/LDT0028Sample.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class LDT0028Sample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
|
||||
// Create the LDT0-028 Piezo Vibration Sensor object using AIO pin 0
|
||||
upm_ldt0028.LDT0028 sensor = new upm_ldt0028.LDT0028(0);
|
||||
|
||||
System.out.println("Sensor name: " + sensor.name());
|
||||
|
||||
while (true) {
|
||||
System.out.println("Sample value: " + sensor.getSample());
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -25,41 +25,35 @@
|
||||
//NOT TESTED!!!
|
||||
public class LSM303Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_lsm303");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate LSM303 compass on I2C
|
||||
upm_lsm303.LSM303 sensor = new upm_lsm303.LSM303(0);
|
||||
|
||||
// Get the coordinate data
|
||||
sensor.getCoordinates();
|
||||
int[] coor = sensor.getRawCoorData(); // in XYZ order.·
|
||||
short[] coor = sensor.getRawCoorData(); // in XYZ order.·
|
||||
// The sensor returns XZY, but the driver compensates and makes it XYZ
|
||||
|
||||
// Print out the X, Y, and Z coordinate data using two different methods
|
||||
System.out.println("coor: rX " + coor[0] + " - rY " + coor[1] + " - rZ " + coor[2]);
|
||||
System.out.println("coor: gX " + sensor.getCoorX() + " - gY " + sensor.getCoorY() + " - gZ " + sensor.getCoorZ());
|
||||
System.out.println("coor: gX " + sensor.getCoorX() + " - gY " + sensor.getCoorY()
|
||||
+ " - gZ " + sensor.getCoorZ());
|
||||
|
||||
// Get and print out the heading
|
||||
System.out.println("heading: " + sensor.getHeading());
|
||||
|
||||
// Get the acceleration
|
||||
sensor.getAcceleration();
|
||||
int[] accel = sensor.getRawAccelData();
|
||||
short[] accel = sensor.getRawAccelData();
|
||||
|
||||
// Print out the X, Y, and Z acceleration data using two different methods
|
||||
// Print out the X, Y, and Z acceleration data using two different
|
||||
// methods
|
||||
System.out.println("acc: rX " + accel[0] + " - rY " + accel[1] + " - rZ " + accel[2]);
|
||||
System.out.println("acc: gX " + sensor.getAccelX() + " - gY " + sensor.getAccelY() + " - gZ " + sensor.getAccelZ());
|
||||
System.out.println("acc: gX " + sensor.getAccelX() + " - gY " + sensor.getAccelY()
|
||||
+ " - gZ " + sensor.getAccelZ());
|
||||
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
49
examples/java/Lcm1602_i2cSample.java
Normal file
49
examples/java/Lcm1602_i2cSample.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class Lcm1602_i2cSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_i2clcd.Lcm1602 lcd = new upm_i2clcd.Lcm1602(0, 0x27);
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.write("Hello World");
|
||||
Thread.sleep(3000);
|
||||
|
||||
lcd.setCursor(1, 2);
|
||||
lcd.write("Hello World");
|
||||
Thread.sleep(3000);
|
||||
|
||||
lcd.setCursor(2, 4);
|
||||
lcd.write("Hello World");
|
||||
Thread.sleep(3000);
|
||||
|
||||
lcd.setCursor(3, 6);
|
||||
lcd.write("Hello World");
|
||||
Thread.sleep(3000);
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
52
examples/java/Lcm1602_parallelSample.java
Normal file
52
examples/java/Lcm1602_parallelSample.java
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class Lcm1602_parallelSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// LCD connection:
|
||||
// LCD RS pin to digital pin 8
|
||||
// LCD Enable pin to digital pin 13
|
||||
// LCD D4 pin to digital pin 2
|
||||
// LCD D5 pin to digital pin 3
|
||||
// LCD D6 pin to digital pin 4
|
||||
// LCD D7 pin to digital pin 5
|
||||
// LCD R/W pin to ground
|
||||
// 10K trimmer potentiometer:
|
||||
// ends to +5V and ground
|
||||
// wiper to LCD VO pin (pin 3)
|
||||
upm_i2clcd.Lcm1602 lcd = new upm_i2clcd.Lcm1602(8, 13, 2, 3, 4, 5, 20, 2);
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.write("Hello World");
|
||||
lcd.setCursor(1, 2);
|
||||
lcd.write("Hello World");
|
||||
|
||||
System.out.println("Sleeping for 5 seconds");
|
||||
Thread.sleep(5000);
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
47
examples/java/LoL_exampleSample.java
Normal file
47
examples/java/LoL_exampleSample.java
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class LoL_exampleSample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_lol.LoL sensor = new upm_lol.LoL();
|
||||
|
||||
int x = 0, y = 0;
|
||||
while (true) {
|
||||
// revert pixel
|
||||
sensor.setPixel(x, y, sensor.getPixel(x, y));
|
||||
|
||||
if (++x == 13) {
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
if (y == 9)
|
||||
y = 0;
|
||||
Thread.sleep(10);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
55
examples/java/M24LR64ESample.java
Normal file
55
examples/java/M24LR64ESample.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class M24LR64ESample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate an M24LR64E on I2C bus 0
|
||||
upm_m24lr64e.M24LR64E nfcTag = new upm_m24lr64e.M24LR64E(0);
|
||||
|
||||
// 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 = upm_m24lr64e.M24LR64E.EEPROM_I2C_LENGTH - 1;
|
||||
System.out.println("Address: " + addr);
|
||||
short read = nfcTag.readByte(addr);
|
||||
System.out.println("Read: " + read);
|
||||
|
||||
// Now change it to it's opposite and write it
|
||||
read = (short) (~read & 0xff);
|
||||
nfcTag.writeByte(addr, read);
|
||||
System.out.println("Wrote: " + read);
|
||||
|
||||
// Now read it back
|
||||
read = nfcTag.readByte(addr);
|
||||
System.out.println("Read: " + read);
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
@ -25,23 +25,14 @@
|
||||
//NOT TESTED!!!
|
||||
public class MAX44000Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_max44000");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
upm_max44000.MAX44000 sensor = new upm_max44000.MAX44000(0);
|
||||
|
||||
while(true){
|
||||
while (true) {
|
||||
System.out.println("proximity value = " + sensor.getAmbient());
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
50
examples/java/MHZ16Sample.java
Normal file
50
examples/java/MHZ16Sample.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class MHZ16Sample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate a MHZ16 serial CO2 sensor on uart 0.
|
||||
upm_mhz16.MHZ16 co2 = new upm_mhz16.MHZ16(0);
|
||||
|
||||
System.out.println("Make sure that the sensor has had at least 3 minutes to warm up");
|
||||
System.out.println("or you will not get valid results.");
|
||||
System.out.println("The temperature reported is not the ambient temperature,");
|
||||
System.out.println("but rather the temperature of the sensor elements.");
|
||||
|
||||
while (true) {
|
||||
if (!co2.getData()) {
|
||||
System.out.println("Failed to retrieve data");
|
||||
continue;
|
||||
}
|
||||
System.out.println("CO2 concentration: " + co2.getGas() + "PPM, Temperature (in C): "
|
||||
+ co2.getTemperature());
|
||||
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
42
examples/java/MMA7455Sample.java
Normal file
42
examples/java/MMA7455Sample.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class MMA7455Sample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_mma7455.MMA7455 sensor = new upm_mma7455.MMA7455(0);
|
||||
short[] val;
|
||||
|
||||
while (true) {
|
||||
val = sensor.readData();
|
||||
System.out.println("Accelerometer X: " + val[0] + ", Y: " + val[1] + ", Z: " + val[2]);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
55
examples/java/MMA7660Sample.java
Normal file
55
examples/java/MMA7660Sample.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class MMA7660Sample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Instantiate an MMA7660 on I2C bus 0
|
||||
upm_mma7660.MMA7660 accel = new upm_mma7660.MMA7660(0);
|
||||
|
||||
// place device in standby mode so we can write registers
|
||||
accel.setModeStandby();
|
||||
|
||||
// enable 64 samples per second
|
||||
accel.setSampleRate(upm_mma7660.MMA7660.MMA7660_AUTOSLEEP_T.AUTOSLEEP_64);
|
||||
|
||||
// place device into active mode
|
||||
accel.setModeActive();
|
||||
|
||||
while (true) {
|
||||
int[] rawValues = accel.getRawValues();
|
||||
System.out.println("Raw Values: x = " + rawValues[0] + " y = " + rawValues[1] + " x = "
|
||||
+ rawValues[2]);
|
||||
|
||||
float[] acceleration = accel.getAcceleration();
|
||||
System.out.println("Raw Values: x = " + acceleration[0] + " y = " + acceleration[1]
|
||||
+ " x = " + acceleration[2]);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -25,21 +25,12 @@
|
||||
//NOT TESTED!!!
|
||||
public class MPL3115A2Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_mpl3115a2");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate a MPL3115A2 sensor on I2C
|
||||
upm_mpl3115a2.MPL3115A2 sensor = new upm_mpl3115a2.MPL3115A2(0);
|
||||
|
||||
while(true){
|
||||
while (true) {
|
||||
System.out.println("Pressure: " + sensor.getPressure());
|
||||
System.out.println("Altitude: " + sensor.getAltitude());
|
||||
System.out.println("Sealevel pressure: " + sensor.getSealevelPressure());
|
||||
@ -48,7 +39,7 @@ public class MPL3115A2Sample {
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
34
examples/java/MPR121Sample.java
Normal file
34
examples/java/MPR121Sample.java
Normal file
@ -0,0 +1,34 @@
|
||||
public class MPR121Sample {
|
||||
|
||||
private static void printButtons(upm_mpr121.MPR121 touch) {
|
||||
boolean buttonPresed = false;
|
||||
|
||||
System.out.print("Buttons pressed: ");
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if ((touch.getM_buttonStates() & (1 << i)) != 0) {
|
||||
System.out.print(i + " ");
|
||||
buttonPresed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!buttonPresed)
|
||||
System.out.print("None ");
|
||||
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// Instantiate an MPR121 on I2C bus 0
|
||||
upm_mpr121.MPR121 touch = new upm_mpr121.MPR121(0);
|
||||
|
||||
// init according to AN3944 defaults
|
||||
touch.configAN3944();
|
||||
|
||||
while (true) {
|
||||
touch.readButtons();
|
||||
printButtons(touch);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -25,35 +25,29 @@
|
||||
//NOT TESTED!!!
|
||||
public class MPU9150Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("upm_mpu9150");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
upm_mpu9150.MPU9150 sensor = new upm_mpu9150.MPU9150();
|
||||
|
||||
sensor.init();
|
||||
|
||||
while(true){
|
||||
while (true) {
|
||||
sensor.update();
|
||||
|
||||
float[] accel = sensor.getAccelerometer();
|
||||
System.out.println("Accelerometer: " + "AX: " + accel[0] + " AY: " + accel[1] + " AZ: " + accel[2] );
|
||||
System.out.println("Accelerometer: " + "AX: " + accel[0] + " AY: " + accel[1] + " AZ: "
|
||||
+ accel[2]);
|
||||
|
||||
float[] gyro = sensor.getGyroscope();
|
||||
System.out.println("Gryoscope: " + "GX: " + gyro[0] + " GY: " + gyro[1] + " GZ: " + gyro[2] );
|
||||
System.out.println("Gryoscope: " + "GX: " + gyro[0] + " GY: " + gyro[1] + " GZ: "
|
||||
+ gyro[2]);
|
||||
|
||||
float[] magn = sensor.getMagnetometer();
|
||||
System.out.println("Magnetometer: " + "MX: " + magn[0] + " MY: " + magn[1] + " MZ: " + magn[2] );
|
||||
System.out.println("Magnetometer: " + "MX: " + magn[0] + " MY: " + magn[1] + " MZ: "
|
||||
+ magn[2]);
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
56
examples/java/MQ2Sample.java
Normal file
56
examples/java/MQ2Sample.java
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class MQ2Sample {
|
||||
private static final short resolution = 5;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
short[] buffer = new short[128];
|
||||
|
||||
// Attach gas sensor to A0
|
||||
upm_gas.MQ2 sensor = new upm_gas.MQ2(0);
|
||||
|
||||
upm_gas.thresholdContext ctx = new upm_gas.thresholdContext();
|
||||
ctx.setAverageReading(0);
|
||||
ctx.setRunningAverage(0);
|
||||
ctx.setAveragedOver(2);
|
||||
|
||||
while (true) {
|
||||
int len = sensor.getSampledWindow(2, buffer);
|
||||
|
||||
if (len != 0) {
|
||||
int thresh = sensor.findThreshold(ctx, 30, buffer);
|
||||
sensor.printGraph(ctx, resolution);
|
||||
if (thresh != 0) {
|
||||
System.out.println("---Threshold reached---");
|
||||
}
|
||||
}
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user