mirror of
https://github.com/eclipse/upm.git
synced 2025-07-07 12:21:11 +03:00
Compare commits
250 Commits
Author | SHA1 | Date | |
---|---|---|---|
04dc6df429 | |||
453a6eae0e | |||
d325ae1fda | |||
98ea1c615a | |||
511d796fc2 | |||
58888fc49b | |||
19bf570561 | |||
922c8f628c | |||
3b6812ff36 | |||
e3dde0e390 | |||
68f54d1c59 | |||
5f4e8b18e5 | |||
5d356917cc | |||
1ceb784252 | |||
e9679e0982 | |||
c6386269ef | |||
f03f967a38 | |||
5fda514544 | |||
9fe9d4aec2 | |||
cd7815aa07 | |||
1563c71c5f | |||
3b7eb9afc2 | |||
d7bc084565 | |||
3d702a6e64 | |||
cd30c7d71f | |||
ed71aa029d | |||
7ffe895374 | |||
a427d6ebe5 | |||
83e62aabba | |||
d94a6d00fb | |||
14a3924fb2 | |||
7935ef1622 | |||
a0af1c01bd | |||
7ce8dc3434 | |||
33c123420a | |||
21eb2de086 | |||
5e72c4febd | |||
428bac360b | |||
a0518976c6 | |||
bdacb6c640 | |||
ce6a095079 | |||
701a25261f | |||
6719168a20 | |||
2002904faa | |||
7d0dccf9ed | |||
bfe548ac45 | |||
3c36aa1624 | |||
64777bd0ef | |||
1fefdcbdf1 | |||
8765416016 | |||
26317cbd2a | |||
f358b2e16d | |||
619da95553 | |||
3585761ecf | |||
ca04996524 | |||
6b19482ceb | |||
d3bfebeca0 | |||
60a3f6cd7e | |||
5e9d9f4e66 | |||
a56485f288 | |||
d0b5a98952 | |||
36cbca05bb | |||
f6ab1fb451 | |||
9c4a4d0ff0 | |||
5cc8c90251 | |||
a24f8209bc | |||
e8823dd74e | |||
b8ee0cf22d | |||
14fc909400 | |||
0db47c7528 | |||
aeb120c284 | |||
ab20e34c59 | |||
d0d89b579d | |||
6db7dfd3d9 | |||
36237ae596 | |||
9e20268bb8 | |||
77abd94682 | |||
7323b58b61 | |||
cb6427b22e | |||
fe133d7454 | |||
52274d8b10 | |||
0af62a6992 | |||
6a6eaa1b71 | |||
3fc672a19f | |||
69bd77dd30 | |||
9421cdaf30 | |||
fb779ecd6a | |||
3cd61b56f8 | |||
56ddb441d4 | |||
8d38bd0bcc | |||
1f1c303937 | |||
f567f282ae | |||
5ab01e5a65 | |||
b56095a3ff | |||
b20a5f1d68 | |||
c3297bcc55 | |||
4513a8ad09 | |||
ae60a92963 | |||
eba82a1c73 | |||
b7dda9021f | |||
d7b8fac41b | |||
1079baf2fd | |||
b925f13bac | |||
78d940aaf5 | |||
3d837284fd | |||
b8af35a797 | |||
1eb9e7b9dc | |||
1617b03d3d | |||
da49741527 | |||
f86e812f13 | |||
f84973b0e4 | |||
b0ac4b5da2 | |||
0566b4f995 | |||
a1db1b423b | |||
f29141087e | |||
fbbc0de6fb | |||
427dd6e851 | |||
4f5b4d5886 | |||
8345687ab9 | |||
bea94a70b2 | |||
a4db81c15f | |||
c7aa1b1f8a | |||
8e54381216 | |||
9081c35f53 | |||
88c11fb1cf | |||
9e3c72a547 | |||
2f2b502813 | |||
6b4a3e1fd0 | |||
c50dd16d82 | |||
7866e54e8d | |||
b00e81dfce | |||
cc6ba3be6d | |||
a564258fb0 | |||
03cb2ec362 | |||
f4e5a5109f | |||
dc49f36e83 | |||
5516faca38 | |||
74cbc25f21 | |||
1ea36c6f89 | |||
38351cbe6e | |||
d4d29307a2 | |||
b4e4e9ae89 | |||
a2855c5e72 | |||
667a8fdb49 | |||
04e91db166 | |||
6c8f82901c | |||
5f27c5515f | |||
48e6d4bcfa | |||
4e70ed4973 | |||
3159005aa3 | |||
5a62602a11 | |||
0bc1930cf5 | |||
ef74a7b137 | |||
f991bcf915 | |||
6cbddff31a | |||
ff42bd390f | |||
b4d2a2e1f2 | |||
b44995da74 | |||
3af7cccb93 | |||
021c003ca8 | |||
2e5fbd0d54 | |||
2cab79b4c2 | |||
ab730038fd | |||
b8835958e2 | |||
ea1df1b178 | |||
85c602d524 | |||
8147a89cb7 | |||
20d5c50725 | |||
138c5af5f8 | |||
6793c892ed | |||
76f7abb112 | |||
1e5b755b99 | |||
a79d8abfcd | |||
4b8b75b19b | |||
2bae3931b9 | |||
5fd2d9c439 | |||
c45e493b1b | |||
4985cf4b00 | |||
7afd1f3fc1 | |||
83cb6dc2fd | |||
dc7e33558e | |||
0406258466 | |||
2ceb6a9d8d | |||
fbf68d1dd8 | |||
a5a66e9e17 | |||
07f6ffb0a4 | |||
ebdb4f10d1 | |||
3d74ea9820 | |||
f6c56be5e4 | |||
cfe63bf7b6 | |||
1f82757c64 | |||
be2e8d7c76 | |||
3aad8e367f | |||
45b83502a1 | |||
9cfd1a9679 | |||
fb6627083b | |||
42c59e98ab | |||
ea669ddfc6 | |||
4f30959a43 | |||
2455938691 | |||
5e3263e2e2 | |||
58846ba68a | |||
a21db7ca78 | |||
40fb6f5d75 | |||
2595c0b623 | |||
c7185739dc | |||
945a6d4828 | |||
19bcbc7c42 | |||
323905a215 | |||
3e59323abb | |||
59c6b28cdd | |||
b17a3b34b7 | |||
8b9267c253 | |||
78a159594b | |||
8eed56fda0 | |||
647d9b44a9 | |||
749952f7e3 | |||
d3e0ae5771 | |||
a81b1836a3 | |||
c7389d0cb6 | |||
fb86dc5cec | |||
98f400e326 | |||
b0625e11f1 | |||
60cfe88e37 | |||
ad1cc81c0d | |||
4a6492af0a | |||
488ea234d5 | |||
fba8139416 | |||
45738d0b93 | |||
52810cef77 | |||
f02fa1fdf1 | |||
f8766cccdc | |||
4bea93163d | |||
8b0d1b2b3d | |||
7e2ae96c1f | |||
181823cb20 | |||
11f9154ce0 | |||
018e09e5b2 | |||
984391eb64 | |||
9bf954071b | |||
448ee39c7f | |||
8dac9f7356 | |||
fcca8ada45 | |||
2e0efd6690 | |||
c878283c44 | |||
b81be93411 | |||
3ad25f65c8 | |||
97e7f74a8f | |||
66d688bc90 | |||
84f795e453 |
17
.travis.yml
Normal file
17
.travis.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
language: cpp
|
||||||
|
compiler:
|
||||||
|
- gcc
|
||||||
|
- clang
|
||||||
|
install:
|
||||||
|
- sudo add-apt-repository --yes ppa:kalakris/cmake
|
||||||
|
- sudo add-apt-repository --yes ppa:fenics-packages/fenics-exp/swig
|
||||||
|
- sudo apt-get update -qq
|
||||||
|
- sudo apt-get install -y -qq swig3.0 python git cmake
|
||||||
|
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
|
||||||
|
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
|
||||||
|
- 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
|
@ -15,8 +15,8 @@ find_package (PkgConfig REQUIRED)
|
|||||||
|
|
||||||
# force a libmraa search and minimum required version every time a config is generated
|
# force a libmraa search and minimum required version every time a config is generated
|
||||||
unset(MRAA_FOUND CACHE)
|
unset(MRAA_FOUND CACHE)
|
||||||
pkg_check_modules (MRAA REQUIRED mraa>=0.6.2)
|
pkg_check_modules (MRAA REQUIRED mraa>=0.8.0)
|
||||||
message (INFO " found libmraa version: ${MRAA_VERSION}")
|
message (INFO " found mraa version: ${MRAA_VERSION}")
|
||||||
|
|
||||||
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
|
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
|
||||||
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
||||||
@ -30,7 +30,7 @@ include (GetGitRevisionDescription)
|
|||||||
git_describe (VERSION "--tags")
|
git_describe (VERSION "--tags")
|
||||||
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
|
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
|
||||||
message (WARNING " - Install git to compile a production UPM!")
|
message (WARNING " - Install git to compile a production UPM!")
|
||||||
set (VERSION "v0.3.2-dirty")
|
set (VERSION "v0.4.0-dirty")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
message (INFO " - UPM Version ${VERSION}")
|
message (INFO " - UPM Version ${VERSION}")
|
||||||
@ -58,6 +58,7 @@ option (BUILDSWIG "Build swig modules." ON)
|
|||||||
option (BUILDSWIGPYTHON "Build swig python modules." ON)
|
option (BUILDSWIGPYTHON "Build swig python modules." ON)
|
||||||
option (BUILDSWIGNODE "Build swig node modules." ON)
|
option (BUILDSWIGNODE "Build swig node modules." ON)
|
||||||
option (BUILDEXAMPLES "Build C++ example binaries" OFF)
|
option (BUILDEXAMPLES "Build C++ example binaries" OFF)
|
||||||
|
option (BUILDSWIGJAVA "Build swig java modules" OFF)
|
||||||
option (IPK "Generate IPK using CPack" OFF)
|
option (IPK "Generate IPK using CPack" OFF)
|
||||||
option (RPM "Generate RPM using CPack" OFF)
|
option (RPM "Generate RPM using CPack" OFF)
|
||||||
|
|
||||||
@ -71,12 +72,16 @@ if (BUILDDOC)
|
|||||||
find_package (Doxygen)
|
find_package (Doxygen)
|
||||||
if (DOXYGEN_FOUND)
|
if (DOXYGEN_FOUND)
|
||||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||||
|
if (BUILDSWIGJAVA)
|
||||||
|
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.java.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-java @ONLY)
|
||||||
|
endif()
|
||||||
file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/icons/*.png)
|
file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/icons/*.png)
|
||||||
foreach(PNG_FILE ${PNG_FILES})
|
foreach(PNG_FILE ${PNG_FILES})
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY)
|
||||||
endforeach()
|
endforeach()
|
||||||
add_custom_target (doc
|
add_custom_target (doc
|
||||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||||
|
COMMAND tar -czf html/xml.tar.gz -C xml .
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||||
)
|
)
|
||||||
@ -127,9 +132,23 @@ if (BUILDDOC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (IPK)
|
if (IPK)
|
||||||
message (INFO " - IPK packaging enabled for ${DETECTED_ARCH}")
|
|
||||||
|
# Get target package arch from Yocto ADT sysroot if set or host OS, mapping to Ubuntu name if necessary
|
||||||
|
if (DEFINED ENV{OECORE_TARGET_SYSROOT})
|
||||||
|
GET_FILENAME_COMPONENT (DETECTED_SYSROOT $ENV{OECORE_TARGET_SYSROOT} NAME)
|
||||||
|
string (REGEX REPLACE "-poky-linux" "" TARGET_ARCH "${DETECTED_SYSROOT}")
|
||||||
|
else ()
|
||||||
|
# debian uses amd64 to denote x86_64
|
||||||
|
if (DETECTED_ARCH STREQUAL "x86_64")
|
||||||
|
set (TARGET_ARCH "amd64")
|
||||||
|
else ()
|
||||||
|
set (TARGET_ARCH ${DETECTED_ARCH})
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
message (INFO " - Package arch is ${TARGET_ARCH}")
|
||||||
|
|
||||||
set(CPACK_GENERATOR "DEB" "TGZ")
|
set(CPACK_GENERATOR "DEB" "TGZ")
|
||||||
set(OPKG_ARCH ${DETECTED_ARCH})
|
set(OPKG_ARCH ${TARGET_ARCH})
|
||||||
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
|
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
|
||||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
|
||||||
set(upm_PACKAGE_ON_TAG ".")
|
set(upm_PACKAGE_ON_TAG ".")
|
||||||
@ -140,9 +159,9 @@ if (IPK)
|
|||||||
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
|
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
|
||||||
set(CPACK_PACKAGE_NAME "upm")
|
set(CPACK_PACKAGE_NAME "upm")
|
||||||
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
|
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
|
||||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH})
|
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${TARGET_ARCH})
|
||||||
set(CPACK_SYSTEM_NAME ${DETECTED_ARCH})
|
set(CPACK_SYSTEM_NAME ${TARGET_ARCH})
|
||||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libmraa0 (>= ${MRAA_VERSION})")
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "mraa (>= ${MRAA_VERSION})")
|
||||||
set(CPACK_DEBIAN_PACKAGE_PROVIDES "upm-dev, upm-dbg, upm-doc")
|
set(CPACK_DEBIAN_PACKAGE_PROVIDES "upm-dev, upm-dbg, upm-doc")
|
||||||
set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
|
set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
|
||||||
set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
|
set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
|
||||||
@ -160,7 +179,7 @@ if (RPM)
|
|||||||
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}-${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
|
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}-${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
|
||||||
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
|
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
|
||||||
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
|
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
|
||||||
set(CPACK_RPM_PACKAGE_REQUIRES "libmraa0 >= ${MRAA_VERSION}")
|
set(CPACK_RPM_PACKAGE_REQUIRES "mraa >= ${MRAA_VERSION}")
|
||||||
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
|
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
|
||||||
EXECUTE_PROCESS(COMMAND rpm --showrc
|
EXECUTE_PROCESS(COMMAND rpm --showrc
|
||||||
COMMAND grep -E "dist[[:space:]]*\\."
|
COMMAND grep -E "dist[[:space:]]*\\."
|
||||||
|
63
README.md
63
README.md
@ -1,4 +1,4 @@
|
|||||||
UPM - Sensor/Actuator repository for libmraa
|
UPM (Useful Packages & Modules) Sensor/Actuator repository for libmraa
|
||||||
==============
|
==============
|
||||||
|
|
||||||
UPM is a high level repository for sensors that use libmraa. Each sensor links
|
UPM is a high level repository for sensors that use libmraa. Each sensor links
|
||||||
@ -14,8 +14,42 @@ sensor in order to reduce load when doing multiple reads to sensor data.
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
A sensor/actuator is expected to work as such (here is the servo ES08A API):
|
A sensor/actuator is expected to work as such (here is the MMA7660 accelerometer API):
|
||||||
@snippet es08a.cxx Interesting
|
```C++
|
||||||
|
// Instantiate an MMA7660 on I2C bus 0
|
||||||
|
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_I2C_BUS,
|
||||||
|
MMA7660_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
|
// place device in standby mode so we can write registers
|
||||||
|
accel->setModeStandby();
|
||||||
|
|
||||||
|
// enable 64 samples per second
|
||||||
|
accel->setSampleRate(upm::MMA7660::AUTOSLEEP_64);
|
||||||
|
|
||||||
|
// place device into active mode
|
||||||
|
accel->setModeActive();
|
||||||
|
|
||||||
|
while (shouldRun)
|
||||||
|
{
|
||||||
|
int x, y, z;
|
||||||
|
|
||||||
|
accel->getRawValues(&x, &y, &z);
|
||||||
|
cout << "Raw values: x = " << x
|
||||||
|
<< " y = " << y
|
||||||
|
<< " z = " << z
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
float ax, ay, az;
|
||||||
|
|
||||||
|
accel->getAcceleration(&ax, &ay, &az);
|
||||||
|
cout << "Acceleration: x = " << ax
|
||||||
|
<< "g y = " << ay
|
||||||
|
<< "g z = " << az
|
||||||
|
<< "g" << endl;
|
||||||
|
|
||||||
|
usleep(500000);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
However implementation and API design is completely up to the developer, some
|
However implementation and API design is completely up to the developer, some
|
||||||
enumerable sensors for example may provide much clever instantiation. Displays
|
enumerable sensors for example may provide much clever instantiation. Displays
|
||||||
@ -40,21 +74,21 @@ This will show you how to import the code and configure your project.
|
|||||||
|
|
||||||
### Building UPM
|
### Building UPM
|
||||||
|
|
||||||
See @ref building [here](docs/building.md).
|
See building documentation [here](docs/building.md).
|
||||||
|
|
||||||
### Making your own UPM module
|
### Making your own UPM module
|
||||||
|
|
||||||
@ref porting [link](docs/porting.md) has more information on making new UPM modules.
|
Porting [link](docs/porting.md) has more information on making new UPM modules.
|
||||||
|
|
||||||
There is also an example available for @ref max31855 [sensor](docs/max31855.md).
|
There is also an example available for max31855 [sensor](docs/max31855.md).
|
||||||
|
|
||||||
### Naming conventions and rules for new UPM contributions
|
### Naming conventions and rules for new UPM contributions
|
||||||
|
|
||||||
Before you begin development, take a look at our @ref naming [conventions](docs/naming.md).
|
Before you begin development, take a look at our naming [conventions](docs/naming.md).
|
||||||
|
|
||||||
Also, please read the guidelines for @ref contributions [to UPM](docs/contributions.md).
|
Also, please read the guidelines for contributions [to UPM](docs/contributions.md).
|
||||||
|
|
||||||
Don't forget to check the @ref documentation [section](docs/documentation.md).
|
Don't forget to check the documentation [section](docs/documentation.md).
|
||||||
|
|
||||||
Make sure you add yourself as an author on every new code file submitted.
|
Make sure you add yourself as an author on every new code file submitted.
|
||||||
If you are providing a fix with significant changes, feel free to add yourself
|
If you are providing a fix with significant changes, feel free to add yourself
|
||||||
@ -63,14 +97,13 @@ as a contributor. Signing-off your commits is mandatory.
|
|||||||
API Documentation
|
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/modules.html"><img src="docs/icons/c++.png"/></a>
|
||||||
|
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="docs/icons/java.png"/></a>
|
||||||
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
|
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
|
||||||
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
|
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
|
||||||
|
|
||||||
@endhtmlonly
|
##### Changelog
|
||||||
|
Version changelog [here](docs/changelog.md).
|
||||||
|
|
||||||
Version @ref changelog [here](docs/changelog.md).
|
##### Known Limitations
|
||||||
|
List of known limitations [here](docs/knownlimitations.md).
|
||||||
List of @ref knownlimitations [here](docs/knownlimitations.md).
|
|
||||||
|
25
cmake/Toolchains/oe-sdk_cross.cmake
Normal file
25
cmake/Toolchains/oe-sdk_cross.cmake
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# this toolchain file comes from gnuradio project
|
||||||
|
|
||||||
|
set( CMAKE_SYSTEM_NAME Linux )
|
||||||
|
#set( CMAKE_C_COMPILER $ENV{CC} )
|
||||||
|
#set( CMAKE_CXX_COMPILER $ENV{CXX} )
|
||||||
|
string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR $ENV{SDKTARGETSYSROOT})
|
||||||
|
string(REGEX REPLACE "sysroots/" "" CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
|
||||||
|
set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE )
|
||||||
|
set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) #same flags for C sources
|
||||||
|
set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE ) #same flags for C sources
|
||||||
|
set( CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib )
|
||||||
|
set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} )
|
||||||
|
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
|
||||||
|
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
|
||||||
|
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
|
||||||
|
set( CMAKE_INSTALL_PREFIX $ENV{OECORE_TARGET_SYSROOT}/usr CACHE STRING "" FORCE)
|
||||||
|
set( ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4 )
|
||||||
|
set( ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib )
|
||||||
|
|
||||||
|
# for java
|
||||||
|
set( JAVA_AWT_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
|
||||||
|
set( JAVA_AWT_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjawt.so CACHE FILEPATH "" FORCE)
|
||||||
|
set( JAVA_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
|
||||||
|
set( JAVA_INCLUDE_PATH2 $ENV{JAVA_HOME}/include/linux CACHE PATH "" FORCE)
|
||||||
|
set( JAVA_JVM_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjvm.so CACHE FILEPATH "" FORCE)
|
@ -4,6 +4,21 @@ Changelog {#changelog}
|
|||||||
Here's a list summarizing some of the key undergoing changes to our library
|
Here's a list summarizing some of the key undergoing changes to our library
|
||||||
from earlier versions:
|
from earlier versions:
|
||||||
|
|
||||||
|
### v0.4.0
|
||||||
|
|
||||||
|
* Fully functional and documented JAVA language bindings for sensors with
|
||||||
|
several examples also available
|
||||||
|
* Added standardized exception handling support across all language bindings
|
||||||
|
and updated sensors to use this feature
|
||||||
|
* Sensor drivers are now available and can be installed individually using NPM
|
||||||
|
for Node.js users
|
||||||
|
* Continuous Integration with Travis CI ensures new contributions are built
|
||||||
|
automatically once they are received
|
||||||
|
* API rewrite and improvements for hcsr04, sm130, eboled, loudness
|
||||||
|
* Documentation improvements and code style changes from C to C++
|
||||||
|
* New sensors: hyld9767, mg811, wheelencoder, grovegprs, mpu9250, ssd1306,
|
||||||
|
es9257, lm35, mq4, mq6, mq7, mq8
|
||||||
|
|
||||||
### v0.3.2
|
### v0.3.2
|
||||||
|
|
||||||
* Introduced RPM package generation feature from cmake via cpack
|
* Introduced RPM package generation feature from cmake via cpack
|
||||||
|
BIN
docs/icons/java.png
Normal file
BIN
docs/icons/java.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
docs/images/ssd1306.jpeg
Normal file
BIN
docs/images/ssd1306.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
@ -7,16 +7,16 @@ such sensors and known workarounds if they exist.
|
|||||||
|
|
||||||
#### Grove Sensors
|
#### Grove Sensors
|
||||||
|
|
||||||
* **Grove I2C Touch Sensor** v1.3 is incompatible with the Intel Edison using
|
* **Grove I2C Touch Sensor** (MPR121) v1.3 is incompatible with the Intel
|
||||||
the Arduino board, but will work with the Mini-breakout if supplied with at
|
Edison using the Arduino board, but will work with the Mini-breakout if
|
||||||
least 4V. Revision v1.2 works well on all Intel boards.
|
supplied with at least 4V. Revision v1.2 works well on all Intel boards.
|
||||||
* **Grove Nunchuck** only works with the Intel Galileo boards and is unusable
|
* **Grove Nunchuck** only works with the Intel Galileo boards and is unusable
|
||||||
on the Intel Edison boards.
|
on the Intel Edison boards.
|
||||||
* **Grove 3-Axis Digital Gyroscope** (ITG-3200) is not compatible with the
|
* **Grove 3-Axis Digital Gyroscope** (ITG-3200) is not compatible with the
|
||||||
Intel Edison Arduino board but will work with the Mini-breakout.
|
Intel Edison Arduino board but will work with the Mini-breakout.
|
||||||
* **Grove 3-Axis Digital Accelerometer** (ADXL345) only works with the Intel
|
* **Grove 3-Axis Digital Accelerometer** (ADXL345) only works with the Intel
|
||||||
Edison Arduino board when powered from the 3.3V line.
|
Edison Arduino board when powered from the 3.3V line.
|
||||||
* **Grove 3-Axis Digital Compass (HMC5883L) reports inaccurate values at 5V
|
* **Grove 3-Axis Digital Compass** (HMC5883L) reports inaccurate values at 5V
|
||||||
on the Intel Edison Arduino board and newer revisions might not work at all.
|
on the Intel Edison Arduino board and newer revisions might not work at all.
|
||||||
Use 3.3V or the Mini-breakout.
|
Use 3.3V or the Mini-breakout.
|
||||||
* **Grove 96x96 OLED Display** will not work on the Intel Edison with Arduino
|
* **Grove 96x96 OLED Display** will not work on the Intel Edison with Arduino
|
||||||
@ -26,6 +26,9 @@ such sensors and known workarounds if they exist.
|
|||||||
* **Grove Barometer** (BMP085) has an unstable connection on the Intel Edison
|
* **Grove Barometer** (BMP085) has an unstable connection on the Intel Edison
|
||||||
using the Arduino breakout and may drop read data. The Xadow version of this
|
using the Arduino breakout and may drop read data. The Xadow version of this
|
||||||
sensor (BMP180) is also dropping data packets occasionally.
|
sensor (BMP180) is also dropping data packets occasionally.
|
||||||
|
* **Grove Digital Light Sensor** (TSL2561) occasionally drops I2C reads on the
|
||||||
|
Intel Edison with the Arduino breakout. This might cause the sensor not to
|
||||||
|
initialize properly. Works as expected with the Mini-breakout.
|
||||||
* **Grove 6-Axis Accelerometer & Compass** (LSM303) fails to write to the
|
* **Grove 6-Axis Accelerometer & Compass** (LSM303) fails to write to the
|
||||||
configuration register properly and returns invalid data.
|
configuration register properly and returns invalid data.
|
||||||
* **Grove I2C ADC Converter** does not show up on the I2C bus on the Intel
|
* **Grove I2C ADC Converter** does not show up on the I2C bus on the Intel
|
||||||
@ -34,7 +37,8 @@ such sensors and known workarounds if they exist.
|
|||||||
the inability to change the I2C bus speed to 100 KHz.
|
the inability to change the I2C bus speed to 100 KHz.
|
||||||
* **Grove CO2 Sensor** will return zeroed data and is unusable on the Intel
|
* **Grove CO2 Sensor** will return zeroed data and is unusable on the Intel
|
||||||
Galileo.
|
Galileo.
|
||||||
* **Grove BLE** (HM-11) does not return data on the Intel Galileo board.
|
* **Grove BLE** (HM-11) does not return data on the Intel Galileo board due to
|
||||||
|
known UART limitation.
|
||||||
|
|
||||||
#### Adafruit Sensors
|
#### Adafruit Sensors
|
||||||
|
|
||||||
@ -43,15 +47,27 @@ such sensors and known workarounds if they exist.
|
|||||||
|
|
||||||
#### Other Sensors
|
#### Other Sensors
|
||||||
|
|
||||||
* **SM130** driver might not be fully functional.
|
* **NRF24L01** corrupted data packets are sent to the device due to the Intel
|
||||||
* **NRF24L01** might not handle data packets as expected.
|
Edison SPI bus limitation. Sensor works as expected with the Intel Galileo
|
||||||
* **NRF8001** based devices do not initialize properly with provided examples.
|
boards.
|
||||||
|
* **NRF8001** based devices do not initialize properly with provided examples
|
||||||
|
on Intel Edison boards also due to SPI bus limitation and data corruption.
|
||||||
|
Works on Intel Galileo.
|
||||||
|
|
||||||
#### General
|
#### General
|
||||||
|
|
||||||
Some I2C sensors add too much capacitance to the SDA line of the Intel Edison
|
Some *I2C* sensors add too much capacitance to the SDA line of the Intel Edison
|
||||||
Arduino breakout board, thus the signal sticks to a logic 1. When this happens,
|
Arduino breakout board, thus the signal sticks to a logic 1. When this happens,
|
||||||
other sensors connected to the I2C bus are unusable. While there is no generic
|
other sensors connected to the I2C bus are unusable. While there is no generic
|
||||||
solution for this limitation, in most cases the sensor works on the Intel
|
solution for this limitation, in most cases the sensor works on the Intel
|
||||||
Edison Mini-breakout. When this board is not an option, the sensor can be
|
Edison Mini-breakout. When this board is not an option, the sensor can be
|
||||||
sometimes replaced with the same model from a different vendor.
|
sometimes replaced with the same model from a different vendor.
|
||||||
|
|
||||||
|
The Intel Edison *SPI* bus can corrupt data being sent across when certain
|
||||||
|
sensors are connected to it. Based on the sensor, this can affect functionality
|
||||||
|
slightly or make the sensor entirely unusable. Unlike the I2C bus limitation,
|
||||||
|
different boards are not likely to resolve this. A kernel update on the other
|
||||||
|
hand might help alleviate this.
|
||||||
|
|
||||||
|
On the Intel Galileo boards, the *UART* bus might drop data if several bytes
|
||||||
|
are read at once.
|
||||||
|
@ -767,7 +767,7 @@ WARN_LOGFILE =
|
|||||||
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/src/upm.h \
|
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/src/upm.h \
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/src \
|
@CMAKE_CURRENT_SOURCE_DIR@/src \
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/docs \
|
@CMAKE_CURRENT_SOURCE_DIR@/docs \
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/README.md
|
@CMAKE_CURRENT_SOURCE_DIR@/doxy/README.cpp.md
|
||||||
|
|
||||||
# This tag can be used to specify the character encoding of the source files
|
# This tag can be used to specify the character encoding of the source files
|
||||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||||
@ -946,7 +946,7 @@ FILTER_SOURCE_PATTERNS =
|
|||||||
# (index.html). This can be useful if you have a project on for instance GitHub
|
# (index.html). This can be useful if you have a project on for instance GitHub
|
||||||
# and want to reuse the introduction page also for the doxygen output.
|
# and want to reuse the introduction page also for the doxygen output.
|
||||||
|
|
||||||
USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_SOURCE_DIR@/README.md
|
USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_SOURCE_DIR@/doxy/README.cpp.md
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Configuration options related to source browsing
|
# Configuration options related to source browsing
|
||||||
|
2332
doxy/Doxyfile.java.in
Normal file
2332
doxy/Doxyfile.java.in
Normal file
File diff suppressed because it is too large
Load Diff
79
doxy/README.cpp.md
Normal file
79
doxy/README.cpp.md
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
UPM (Useful Packages & Modules) Sensor/Actuator repository for libmraa
|
||||||
|
==============
|
||||||
|
|
||||||
|
UPM is a high level repository for sensors that use libmraa. Each sensor links
|
||||||
|
to libmraa and are not meant to be interlinked although some groups of sensors
|
||||||
|
may be. Each sensor contains a header which allows to interface with it.
|
||||||
|
Typically a sensor is represented as a class and instantiated.
|
||||||
|
|
||||||
|
The constructor is expected to initialise the sensor and parameters may be used
|
||||||
|
to provide identification/pin location on the board.
|
||||||
|
|
||||||
|
Typically an update() function will be called in order to get new data from the
|
||||||
|
sensor in order to reduce load when doing multiple reads to sensor data.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
A sensor/actuator is expected to work as such (here is the servo ES08A API):
|
||||||
|
@snippet es08a.cxx Interesting
|
||||||
|
|
||||||
|
However implementation and API design is completely up to the developer, some
|
||||||
|
enumerable sensors for example may provide much clever instantiation. Displays
|
||||||
|
may also create more complex structures in order to interface with them.
|
||||||
|
|
||||||
|
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples).
|
||||||
|
|
||||||
|
Multi-sensor samples for the starter and specialized kits can be found in the
|
||||||
|
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
|
||||||
|
|
||||||
|
### Supported Sensors
|
||||||
|
|
||||||
|
Supported [sensor list](http://iotdk.intel.com/docs/master/upm/modules.html) from API documentation.
|
||||||
|
|
||||||
|
You can also refer to the [Intel® IoT Developer Zone](https://software.intel.com/iot/sensors).
|
||||||
|
|
||||||
|
### IDE 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.
|
||||||
|
|
||||||
|
### Building UPM
|
||||||
|
|
||||||
|
See @ref building [here](docs/building.md).
|
||||||
|
|
||||||
|
### Making your own UPM module
|
||||||
|
|
||||||
|
@ref porting [link](docs/porting.md) has more information on making new UPM modules.
|
||||||
|
|
||||||
|
There is also an example available for @ref max31855 [sensor](docs/max31855.md).
|
||||||
|
|
||||||
|
### Naming conventions and rules for new UPM contributions
|
||||||
|
|
||||||
|
Before you begin development, take a look at our @ref naming [conventions](docs/naming.md).
|
||||||
|
|
||||||
|
Also, please read the guidelines for @ref contributions [to UPM](docs/contributions.md).
|
||||||
|
|
||||||
|
Don't forget to check the @ref documentation [section](docs/documentation.md).
|
||||||
|
|
||||||
|
Make sure you add yourself as an author on every new code file submitted.
|
||||||
|
If you are providing a fix with significant changes, feel free to add yourself
|
||||||
|
as a contributor. Signing-off your commits is mandatory.
|
||||||
|
|
||||||
|
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/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).
|
||||||
|
|
||||||
|
##### Known Limitations
|
||||||
|
List of @ref knownlimitations [here](docs/knownlimitations.md).
|
77
doxy/README.java.md
Normal file
77
doxy/README.java.md
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
UPM (Useful Packages & Modules) Sensor/Actuator repository for libmraa
|
||||||
|
==============
|
||||||
|
|
||||||
|
UPM is a high level repository for sensors that use libmraa. Each sensor links
|
||||||
|
to libmraa and are not meant to be interlinked although some groups of sensors
|
||||||
|
may be. Each sensor contains a header which allows to interface with it.
|
||||||
|
Typically a sensor is represented as a class and instantiated.
|
||||||
|
|
||||||
|
The constructor is expected to initialise the sensor and parameters may be used
|
||||||
|
to provide identification/pin location on the board.
|
||||||
|
|
||||||
|
Typically an update() function will be called in order to get new data from the
|
||||||
|
sensor in order to reduce load when doing multiple reads to sensor data.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
A sensor/actuator is expected to work as such (here is the servo ES08A API):
|
||||||
|
@snippet ES08ASample.java Interesting
|
||||||
|
|
||||||
|
However implementation and API design is completely up to the developer, some
|
||||||
|
enumerable sensors for example may provide much clever instantiation. Displays
|
||||||
|
may also create more complex structures in order to interface with them.
|
||||||
|
|
||||||
|
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples).
|
||||||
|
|
||||||
|
Multi-sensor samples for the starter and specialized kits can be found in the
|
||||||
|
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
|
||||||
|
|
||||||
|
### Supported Sensors
|
||||||
|
|
||||||
|
Supported [sensor list](http://iotdk.intel.com/docs/master/upm/java/modules.html) from API documentation.
|
||||||
|
|
||||||
|
You can also refer to the [Intel® IoT Developer Zone](https://software.intel.com/iot/sensors).
|
||||||
|
|
||||||
|
### IDE 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.
|
||||||
|
|
||||||
|
### Building UPM
|
||||||
|
|
||||||
|
See @ref building [here](docs/building.md).
|
||||||
|
|
||||||
|
### Making your own UPM module
|
||||||
|
|
||||||
|
@ref porting [link](docs/porting.md) has more information on making new UPM modules.
|
||||||
|
|
||||||
|
There is also an example available for @ref max31855 [sensor](docs/max31855.md).
|
||||||
|
|
||||||
|
### Naming conventions and rules for new UPM contributions
|
||||||
|
|
||||||
|
Before you begin development, take a look at our @ref naming [conventions](docs/naming.md).
|
||||||
|
|
||||||
|
Also, please read the guidelines for @ref contributions [to UPM](docs/contributions.md).
|
||||||
|
|
||||||
|
Don't forget to check the @ref documentation [section](docs/documentation.md).
|
||||||
|
|
||||||
|
Make sure you add yourself as an author on every new code file submitted.
|
||||||
|
If you are providing a fix with significant changes, feel free to add yourself
|
||||||
|
as a contributor. Signing-off your commits is mandatory.
|
||||||
|
|
||||||
|
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/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).
|
||||||
|
|
||||||
|
List of @ref knownlimitations [here](docs/knownlimitations.md).
|
@ -58,6 +58,8 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
|
|||||||
|
|
||||||
.. image:: ../docs/icons/c++.png
|
.. image:: ../docs/icons/c++.png
|
||||||
:target: http://iotdk.intel.com/docs/master/upm/modules.html
|
:target: http://iotdk.intel.com/docs/master/upm/modules.html
|
||||||
|
.. image:: ../docs/icons/java.png
|
||||||
|
:target: http://iotdk.intel.com/docs/master/upm/java
|
||||||
.. image:: ../docs/icons/python.png
|
.. image:: ../docs/icons/python.png
|
||||||
:target: http://iotdk.intel.com/docs/master/upm/python
|
:target: http://iotdk.intel.com/docs/master/upm/python
|
||||||
.. image:: ../docs/icons/node.png
|
.. image:: ../docs/icons/node.png
|
||||||
|
@ -110,6 +110,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<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/modules.html"><img src="../docs/icons/c++.png" /></a>
|
||||||
|
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="../docs/icons/java.png" /></a>
|
||||||
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/icons/python.png" /></a>
|
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/icons/python.png" /></a>
|
||||||
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/icons/node.png" /></a>
|
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/icons/node.png" /></a>
|
||||||
</p>
|
</p>
|
||||||
|
122
doxy/samples.mapping.txt
Normal file
122
doxy/samples.mapping.txt
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
# Mapping C++ sample files to Java sample files
|
||||||
|
a110x-intr.cxx A110X_intrSample.java
|
||||||
|
a110x.cxx A110XSample.java
|
||||||
|
ad8232.cxx AD8232Sample.java
|
||||||
|
adc121c021.cxx ADC121C021Sample.java
|
||||||
|
adis16448.cxx ADIS16448Sample.java
|
||||||
|
adxl335.cxx ADXL335Sample.java
|
||||||
|
adxl345.cxx Adxl345Sample.java
|
||||||
|
ak8975.cxx AK8975Sample.java
|
||||||
|
am2315.cxx AM2315Sample.java
|
||||||
|
apds9002.cxx APDS9002Sample.java
|
||||||
|
biss0001.cxx BISS0001Sample.java
|
||||||
|
bmpx8x.cxx BMPX8XSample.java
|
||||||
|
buzzer-sound.cxx Buzzer_soundSample.java
|
||||||
|
cjq4435.cxx CJQ4435Sample.java
|
||||||
|
ds1307.cxx DS1307Sample.java
|
||||||
|
eboled.cxx EBOLEDSample.java
|
||||||
|
ecs1030.cxx ECS1030Sample.java
|
||||||
|
enc03r.cxx ENC03RSample.java
|
||||||
|
es08a.cxx ES08ASample.java
|
||||||
|
flex.cxx FlexSample.java
|
||||||
|
gp2y0a.cxx GP2Y0ASample.java
|
||||||
|
grovebutton.cxx GroveButtonSample.java
|
||||||
|
grovecircularled.cxx GroveCircularLEDSample.java
|
||||||
|
grovecollision.cxx GroveCollisionSample.java
|
||||||
|
groveehr.cxx GroveEHRSample.java
|
||||||
|
groveeldriver.cxx GroveElDriverSample.java
|
||||||
|
groveelectromagnet.cxx GroveElectromagnetSample.java
|
||||||
|
groveemg.cxx GroveEMGSample.java
|
||||||
|
grovegprs.cxx GroveGPRSSample.java
|
||||||
|
grovegsr.cxx GroveGSRSample.java
|
||||||
|
groveled.cxx GroveLEDSample.java
|
||||||
|
grovelinefinder.cxx GroveLineFinderSample.java
|
||||||
|
grovelight.cxx GroveLightSample.java
|
||||||
|
groveloudness.cxx GroveLoudnessSample.java
|
||||||
|
grovemoisture.cxx GroveMoistureSample.java
|
||||||
|
groveo2.cxx GroveO2Sample.java
|
||||||
|
groverelay.cxx GroveRelaySample.java
|
||||||
|
groverotary.cxx GroveRotarySample.java
|
||||||
|
grovescam.cxx GROVESCAMSample.java
|
||||||
|
groveslide.cxx GroveSlideSample.java
|
||||||
|
grovespeaker.cxx GroveSpeakerSample.java
|
||||||
|
grovevdiv.cxx GroveVDivSample.java
|
||||||
|
grovewater.cxx GroveWaterSample.java
|
||||||
|
grovewfs.cxx GroveWFSSample.java
|
||||||
|
guvas12d.cxx GUVAS12DSample.java
|
||||||
|
h3lis331dl.cxx H3LIS331DLSample.java
|
||||||
|
hcsr04.cxx HCSR04Sample.java
|
||||||
|
hm11.cxx HM11Sample.java
|
||||||
|
hmc5883l.cxx Hmc5883lSample.java
|
||||||
|
hp20x.cxx HP20XSample.java
|
||||||
|
ht9170.cxx HT9170Sample.java
|
||||||
|
htu21d.cxx HTU21DSample.java
|
||||||
|
hx711.cxx HX711Sample.java
|
||||||
|
hyld9767.cxx HYLD9767Sample.java
|
||||||
|
ina132.cxx INA132Sample.java
|
||||||
|
itg3200.cxx Itg3200Sample.java
|
||||||
|
jhd1313m1-lcd.cxx Jhd1313m1_lcdSample.java
|
||||||
|
joystick12-example.cxx Joystick12_exampleSample.java
|
||||||
|
l298-stepper.cxx L298_stepperSample.java
|
||||||
|
l298.cxx L298Sample.java
|
||||||
|
lcm1602-lcd.cxx Lcm1602_lcdSample.java
|
||||||
|
ldt0028.cxx LDT0028Sample.java
|
||||||
|
lol-example.cxx LoL_exampleSample.java
|
||||||
|
lpd8806.cxx LPD8806Sample.java
|
||||||
|
lsm303.cxx LSM303Sample.java
|
||||||
|
lsm9ds0.cxx LSM9DS0Sample.java
|
||||||
|
m24lr64e.cxx M24LR64ESample.java
|
||||||
|
max31723.cxx MAX31723Sample.java
|
||||||
|
max31855.cxx MAX31855Sample.java
|
||||||
|
max44000.cxx MAX44000Sample.java
|
||||||
|
max5487.cxx MAX5487Sample.java
|
||||||
|
maxds3231m.cxx MAXDS3231MSample.java
|
||||||
|
mg811.cxx MG811Sample.java
|
||||||
|
mic.cxx MicrophoneSample.java
|
||||||
|
mlx90614.cxx MLX90614Sample.java
|
||||||
|
mma7455.cxx MMA7455Sample.java
|
||||||
|
mma7660.cxx MMA7660Sample.java
|
||||||
|
mpl3115a2.cxx MPL3115A2Sample.java
|
||||||
|
mpr121.cxx MPR121Sample.java
|
||||||
|
mpu60x0.cxx MPU60X0Sample.java
|
||||||
|
mpu9150.cxx MPU9150Sample.java
|
||||||
|
mpu9250.cxx MPU9250Sample.java
|
||||||
|
mq2.cxx MQ2Sample.java
|
||||||
|
mq3.cxx MQ3Sample.java
|
||||||
|
mq303a.cxx MQ303ASample.java
|
||||||
|
mq5.cxx MQ5Sample.java
|
||||||
|
mq9.cxx MQ9Sample.java
|
||||||
|
my9221-ledbar.cxx MY9221_ledbarSample.java
|
||||||
|
my9221-updown.cxx MY9221_updownSample.java
|
||||||
|
nrf24l01-broadcast.cxx NRF24L01_broadcastSample.java
|
||||||
|
nrf24l01-receiver.cxx NRF24L01_receiverSample.java
|
||||||
|
nrf24l01-transmitter.cxx NRF24L01_transmitterSample.java
|
||||||
|
nunchuck.cxx NUNCHUCKSample.java
|
||||||
|
otp538u.cxx OTP538USample.java
|
||||||
|
pca9685.cxx PCA9685Sample.java
|
||||||
|
pn532-writeurl.cxx PN532_writeurlSample.java
|
||||||
|
pn532.cxx PN532Sample.java
|
||||||
|
ppd42ns.cxx PPD42NSSample.java
|
||||||
|
pulsensor.cxx PulsensorSample.java
|
||||||
|
rfr359f.cxx RFR359FSample.java
|
||||||
|
rgbringcoder.cxx RGBRingCoderSample.java
|
||||||
|
rotaryencoder.cxx RotaryEncoderSample.java
|
||||||
|
rpr220-intr.cxx RPR220_intrSample.java
|
||||||
|
rpr220.cxx RPR220Sample.java
|
||||||
|
sainsmartks.cxx SAINSMARTKSSample.java
|
||||||
|
sm130.cxx SM130Sample.java
|
||||||
|
ssd1306-oled.cxx SSD1306_oledSample.java
|
||||||
|
ssd1308-oled.cxx SSD1308_oledSample.java
|
||||||
|
ssd1327-oled.cxx SSD1327_oledSample.java
|
||||||
|
st7735.cxx ST7735Sample.java
|
||||||
|
stepmotor.cxx StepMotorSample.java
|
||||||
|
ta12200.cxx TA12200Sample.java
|
||||||
|
tm1637.cxx TM1637Sample.java
|
||||||
|
tp401.cxx TP401Sample.java
|
||||||
|
tsl2561.cxx TSL2561Sample.java
|
||||||
|
ttp223.cxx TTP223Sample.java
|
||||||
|
ublox6.cxx Ublox6Sample.java
|
||||||
|
uln200xa.cxx ULN200XASample.java
|
||||||
|
waterlevel.cxx WaterLevelSample.java
|
||||||
|
wt5001.cxx WT5001Sample.java
|
||||||
|
yg1006.cxx YG1006Sample.java
|
@ -18,7 +18,8 @@ add_executable (nrf24l01-transmitter-example nrf24l01-transmitter.cxx)
|
|||||||
add_executable (nrf24l01-receiver-example nrf24l01-receiver.cxx)
|
add_executable (nrf24l01-receiver-example nrf24l01-receiver.cxx)
|
||||||
add_executable (nrf24l01-broadcast-example nrf24l01-broadcast.cxx)
|
add_executable (nrf24l01-broadcast-example nrf24l01-broadcast.cxx)
|
||||||
add_executable (es08a-example es08a.cxx)
|
add_executable (es08a-example es08a.cxx)
|
||||||
add_executable (son-hcsr04-example hcsr04.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 (ssd1308-oled-example ssd1308-oled.cxx)
|
||||||
add_executable (ssd1327-oled-example ssd1327-oled.cxx)
|
add_executable (ssd1327-oled-example ssd1327-oled.cxx)
|
||||||
add_executable (max44000-example max44000.cxx)
|
add_executable (max44000-example max44000.cxx)
|
||||||
@ -40,7 +41,11 @@ add_executable (mlx90614-example mlx90614.cxx)
|
|||||||
add_executable (ecs1030-example ecs1030.cxx)
|
add_executable (ecs1030-example ecs1030.cxx)
|
||||||
add_executable (mq2-example mq2.cxx)
|
add_executable (mq2-example mq2.cxx)
|
||||||
add_executable (mq3-example mq3.cxx)
|
add_executable (mq3-example mq3.cxx)
|
||||||
|
add_executable (mq4-example mq4.cxx)
|
||||||
add_executable (mq5-example mq5.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 (mq9-example mq9.cxx)
|
||||||
add_executable (tp401-example tp401.cxx)
|
add_executable (tp401-example tp401.cxx)
|
||||||
add_executable (tcs3414cs-example tcs3414cs.cxx)
|
add_executable (tcs3414cs-example tcs3414cs.cxx)
|
||||||
@ -67,7 +72,6 @@ add_executable (grovelinefinder-example grovelinefinder.cxx)
|
|||||||
add_executable (grovevdiv-example grovevdiv.cxx)
|
add_executable (grovevdiv-example grovevdiv.cxx)
|
||||||
add_executable (grovewater-example grovewater.cxx)
|
add_executable (grovewater-example grovewater.cxx)
|
||||||
add_executable (guvas12d-example guvas12d.cxx)
|
add_executable (guvas12d-example guvas12d.cxx)
|
||||||
add_executable (groveloudness-example groveloudness.cxx)
|
|
||||||
add_executable (mpr121-example mpr121.cxx)
|
add_executable (mpr121-example mpr121.cxx)
|
||||||
add_executable (ublox6-example ublox6.cxx)
|
add_executable (ublox6-example ublox6.cxx)
|
||||||
add_executable (yg1006-example yg1006.cxx)
|
add_executable (yg1006-example yg1006.cxx)
|
||||||
@ -97,6 +101,7 @@ add_executable (l298-example l298.cxx)
|
|||||||
add_executable (l298-stepper-example l298-stepper.cxx)
|
add_executable (l298-stepper-example l298-stepper.cxx)
|
||||||
add_executable (at42qt1070-example at42qt1070.cxx)
|
add_executable (at42qt1070-example at42qt1070.cxx)
|
||||||
add_executable (grovemd-example grovemd.cxx)
|
add_executable (grovemd-example grovemd.cxx)
|
||||||
|
add_executable (grovemd-stepper-example grovemd-stepper.cxx)
|
||||||
add_executable (pca9685-example pca9685.cxx)
|
add_executable (pca9685-example pca9685.cxx)
|
||||||
add_executable (groveeldriver-example groveeldriver.cxx)
|
add_executable (groveeldriver-example groveeldriver.cxx)
|
||||||
add_executable (adafruitss-example adafruitss.cxx)
|
add_executable (adafruitss-example adafruitss.cxx)
|
||||||
@ -133,6 +138,13 @@ add_executable (mpu60x0-example mpu60x0.cxx)
|
|||||||
add_executable (ak8975-example ak8975.cxx)
|
add_executable (ak8975-example ak8975.cxx)
|
||||||
add_executable (lsm9ds0-example lsm9ds0.cxx)
|
add_executable (lsm9ds0-example lsm9ds0.cxx)
|
||||||
add_executable (eboled-example eboled.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)
|
||||||
|
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
|
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
|
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
|
||||||
@ -183,7 +195,6 @@ include_directories (${PROJECT_SOURCE_DIR}/src/grovelinefinder)
|
|||||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovevdiv)
|
include_directories (${PROJECT_SOURCE_DIR}/src/grovevdiv)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovewater)
|
include_directories (${PROJECT_SOURCE_DIR}/src/grovewater)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/guvas12d)
|
include_directories (${PROJECT_SOURCE_DIR}/src/guvas12d)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/groveloudness)
|
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/mpr121)
|
include_directories (${PROJECT_SOURCE_DIR}/src/mpr121)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/ublox6)
|
include_directories (${PROJECT_SOURCE_DIR}/src/ublox6)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/yg1006)
|
include_directories (${PROJECT_SOURCE_DIR}/src/yg1006)
|
||||||
@ -239,6 +250,12 @@ include_directories (${PROJECT_SOURCE_DIR}/src/rgbringcoder)
|
|||||||
include_directories (${PROJECT_SOURCE_DIR}/src/hp20x)
|
include_directories (${PROJECT_SOURCE_DIR}/src/hp20x)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/pn532)
|
include_directories (${PROJECT_SOURCE_DIR}/src/pn532)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/lsm9ds0)
|
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 (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||||
@ -258,7 +275,8 @@ target_link_libraries (nrf24l01-transmitter-example nrf24l01 ${CMAKE_THREAD_LIBS
|
|||||||
target_link_libraries (nrf24l01-receiver-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 (nrf24l01-broadcast-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (es08a-example servo ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (es08a-example servo ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (son-hcsr04-example hcsr04 ${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 (ssd1308-oled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (ssd1327-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 (max44000-example max44000 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
@ -280,7 +298,11 @@ target_link_libraries (mlx90614-example mlx90614 ${CMAKE_THREAD_LIBS_INIT})
|
|||||||
target_link_libraries (ecs1030-example ecs1030 ${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 (mq2-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (mq3-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 (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 (mq9-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (tp401-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 (tcs3414cs-example tcs3414cs ${CMAKE_THREAD_LIBS_INIT})
|
||||||
@ -307,7 +329,6 @@ target_link_libraries (grovelinefinder-example grovelinefinder ${CMAKE_THREAD_LI
|
|||||||
target_link_libraries (grovevdiv-example grovevdiv ${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 (grovewater-example grovewater ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (guvas12d-example guvas12d ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (guvas12d-example guvas12d ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (groveloudness-example groveloudness ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
target_link_libraries (mpr121-example mpr121 ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (mpr121-example mpr121 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (ublox6-example ublox6 ${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 (yg1006-example yg1006 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
@ -337,6 +358,7 @@ target_link_libraries (l298-example l298 ${CMAKE_THREAD_LIBS_INIT})
|
|||||||
target_link_libraries (l298-stepper-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 (at42qt1070-example at42qt1070 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (grovemd-example grovemd ${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 (pca9685-example pca9685 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (groveeldriver-example groveeldriver ${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 (adafruitss-example adafruitss ${CMAKE_THREAD_LIBS_INIT})
|
||||||
@ -373,3 +395,10 @@ target_link_libraries (mpu60x0-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
|
|||||||
target_link_libraries (ak8975-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 (lsm9ds0-example lsm9ds0 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (eboled-example i2clcd ${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})
|
||||||
|
111
examples/c++/grovegprs.cxx
Normal file
111
examples/c++/grovegprs.cxx
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "grovegprs.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace upm;
|
||||||
|
|
||||||
|
void printUsage(char *progname)
|
||||||
|
{
|
||||||
|
cout << "Usage: " << progname << " [AT command]" << endl;
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
cout << "If an argument is supplied on the command line, that argument is"
|
||||||
|
<< endl;
|
||||||
|
cout << "sent to the module and the response is printed out." << endl;
|
||||||
|
cout << endl;
|
||||||
|
cout << "If no argument is used, then the manufacturer and the current"
|
||||||
|
<< endl;
|
||||||
|
cout << "saved profiles are queried and the results printed out." << endl;
|
||||||
|
cout << endl;
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// simple helper function to send a command and wait for a response
|
||||||
|
void sendCommand(upm::GroveGPRS* sensor, string cmd)
|
||||||
|
{
|
||||||
|
// commands need to be terminated with a carriage return
|
||||||
|
cmd += "\r";
|
||||||
|
|
||||||
|
sensor->writeDataStr(cmd);
|
||||||
|
|
||||||
|
// wait up to 1 second
|
||||||
|
if (sensor->dataAvailable(1000))
|
||||||
|
{
|
||||||
|
cout << "Returned: " << sensor->readDataStr(1024) << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cerr << "Timed out waiting for response" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
// Instantiate a GroveGPRS Module on UART 0
|
||||||
|
upm::GroveGPRS* sensor = new upm::GroveGPRS(0);
|
||||||
|
|
||||||
|
// Set the baud rate, 19200 baud is the default.
|
||||||
|
if (sensor->setBaudRate(19200) != mraa::SUCCESS)
|
||||||
|
{
|
||||||
|
cerr << "Failed to set tty baud rate" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printUsage(argv[0]);
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
cout << "Sending command line argument (" << argv[1] << ")..." << endl;
|
||||||
|
sendCommand(sensor, argv[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// query the module manufacturer
|
||||||
|
cout << "Querying module manufacturer (AT+CGMI)..." << endl;
|
||||||
|
sendCommand(sensor, "AT+CGMI");
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
// query the saved profiles
|
||||||
|
cout << "Querying the saved profiles (AT&V)..." << endl;
|
||||||
|
sendCommand(sensor, "AT&V");
|
||||||
|
|
||||||
|
// A comprehensive list is available from the datasheet at:
|
||||||
|
// http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
delete sensor;
|
||||||
|
return 0;
|
||||||
|
}
|
66
examples/c++/grovemd-stepper.cxx
Normal file
66
examples/c++/grovemd-stepper.cxx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include "grovemd.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
//! [Interesting]
|
||||||
|
// Instantiate an I2C Grove Motor Driver on I2C bus 0
|
||||||
|
|
||||||
|
upm::GroveMD *motors = new upm::GroveMD(GROVEMD_I2C_BUS,
|
||||||
|
GROVEMD_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
|
// This example demonstrates using the GroveMD to drive a stepper motor
|
||||||
|
|
||||||
|
// configure it, for this example, we'll assume 200 steps per rev
|
||||||
|
motors->configStepper(200);
|
||||||
|
|
||||||
|
// set for half a rotation
|
||||||
|
motors->setStepperSteps(100);
|
||||||
|
|
||||||
|
// let it go - clockwise rotation, 10 RPM speed
|
||||||
|
motors->enableStepper(upm::GroveMD::STEP_DIR_CW, 10);
|
||||||
|
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
// Now do it backwards...
|
||||||
|
motors->setStepperSteps(100);
|
||||||
|
motors->enableStepper(upm::GroveMD::STEP_DIR_CCW, 10);
|
||||||
|
|
||||||
|
// now disable
|
||||||
|
motors->disableStepper();
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
cout << "Exiting..." << endl;
|
||||||
|
|
||||||
|
delete motors;
|
||||||
|
return 0;
|
||||||
|
}
|
@ -50,11 +50,17 @@ interrupt (void * args) {
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
sonar = new upm::HCSR04(5, 7, &interrupt);
|
sonar = new upm::HCSR04(5, 6, &interrupt);
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
printf ("width = %d\n", sonar->getDistance());
|
sleep(1);
|
||||||
std::cout << "exiting application" << std::endl;
|
|
||||||
|
for(;;){
|
||||||
|
std::cout << "get distance" << std::endl;
|
||||||
|
double distance = sonar->getDistance(CM);
|
||||||
|
std::cout << "distance " << distance << std::endl;
|
||||||
|
sleep(5);
|
||||||
|
}
|
||||||
|
|
||||||
delete sonar;
|
delete sonar;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
* Copyright (c) 2014 Intel Corporation.
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@ -25,11 +25,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "groveloudness.h"
|
#include "lm35.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
void sig_handler(int signo)
|
void sig_handler(int signo)
|
||||||
{
|
{
|
||||||
@ -37,27 +37,29 @@ void sig_handler(int signo)
|
|||||||
shouldRun = false;
|
shouldRun = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
int main ()
|
|
||||||
{
|
{
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
// Instantiate a Grove Loudness sensor on analog pin A0
|
|
||||||
upm::GroveLoudness* loudness = new upm::GroveLoudness(0);
|
|
||||||
|
|
||||||
// Print the loudness value every 0.1 seconds
|
// Instantiate a LM35 on analog pin A0, with a default analog
|
||||||
|
// reference voltage of 5.0
|
||||||
|
upm::LM35 *sensor = new upm::LM35(0);
|
||||||
|
|
||||||
|
// Every half second, sample the sensor and output the temperature
|
||||||
|
|
||||||
while (shouldRun)
|
while (shouldRun)
|
||||||
{
|
{
|
||||||
int val = loudness->value();
|
cout << "Temperature: " << sensor->getTemperature() << " C" << endl;
|
||||||
cout << "Loudness value (higher is louder): " << val << endl;
|
|
||||||
|
|
||||||
usleep(100000);
|
usleep(500000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
|
||||||
cout << "Exiting" << endl;
|
cout << "Exiting" << endl;
|
||||||
|
|
||||||
delete loudness;
|
delete sensor;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
68
examples/c++/loudness.cxx
Normal file
68
examples/c++/loudness.cxx
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <signal.h>
|
||||||
|
#include "loudness.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
bool shouldRun = true;
|
||||||
|
|
||||||
|
#define LOUDNESS_AREF 5.0
|
||||||
|
|
||||||
|
void sig_handler(int signo)
|
||||||
|
{
|
||||||
|
if (signo == SIGINT)
|
||||||
|
shouldRun = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
// Instantiate a Loudness sensor on analog pin A0, with an analog
|
||||||
|
// reference voltage of LOUDNESS_AREF
|
||||||
|
upm::Loudness *loud = new upm::Loudness(0, LOUDNESS_AREF);
|
||||||
|
|
||||||
|
// Every tenth of a second, sample the loudness and output it's
|
||||||
|
// corresponding analog voltage.
|
||||||
|
|
||||||
|
while (shouldRun)
|
||||||
|
{
|
||||||
|
cout << "Detected loudness (volts): " << loud->loudness() << endl;
|
||||||
|
|
||||||
|
usleep(100000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
cout << "Exiting" << endl;
|
||||||
|
|
||||||
|
delete loud;
|
||||||
|
return 0;
|
||||||
|
}
|
68
examples/c++/mg811.cxx
Normal file
68
examples/c++/mg811.cxx
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <signal.h>
|
||||||
|
#include "mg811.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
bool shouldRun = true;
|
||||||
|
|
||||||
|
#define MG811_AREF 5.0
|
||||||
|
|
||||||
|
void sig_handler(int signo)
|
||||||
|
{
|
||||||
|
if (signo == SIGINT)
|
||||||
|
shouldRun = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
// Instantiate an MG811 on analog pin A0, and digital pin D2 with an
|
||||||
|
// analog reference voltage of MG811_AREF (5.0)
|
||||||
|
upm::MG811 *sensor = new upm::MG811(0, 2, MG811_AREF);
|
||||||
|
|
||||||
|
// Every tenth of a second, sample the sensor and output it's
|
||||||
|
// detected CO2 concentration in parts per million (ppm)
|
||||||
|
|
||||||
|
while (shouldRun)
|
||||||
|
{
|
||||||
|
cout << "CO2 concentration in PPM: " << sensor->ppm() << endl;
|
||||||
|
|
||||||
|
usleep(100000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
cout << "Exiting" << endl;
|
||||||
|
|
||||||
|
delete sensor;
|
||||||
|
return 0;
|
||||||
|
}
|
81
examples/c++/mpu9250.cxx
Normal file
81
examples/c++/mpu9250.cxx
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <signal.h>
|
||||||
|
#include "mpu9250.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int shouldRun = true;
|
||||||
|
|
||||||
|
void sig_handler(int signo)
|
||||||
|
{
|
||||||
|
if (signo == SIGINT)
|
||||||
|
shouldRun = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
signal(SIGINT, sig_handler);
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
upm::MPU9250 *sensor = new upm::MPU9250();
|
||||||
|
|
||||||
|
sensor->init();
|
||||||
|
|
||||||
|
while (shouldRun)
|
||||||
|
{
|
||||||
|
sensor->update();
|
||||||
|
|
||||||
|
float x, y, z;
|
||||||
|
|
||||||
|
sensor->getAccelerometer(&x, &y, &z);
|
||||||
|
cout << "Accelerometer: ";
|
||||||
|
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
|
||||||
|
|
||||||
|
sensor->getGyroscope(&x, &y, &z);
|
||||||
|
cout << "Gryoscope: ";
|
||||||
|
cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl;
|
||||||
|
|
||||||
|
sensor->getMagnetometer(&x, &y, &z);
|
||||||
|
cout << "Magnetometer: ";
|
||||||
|
cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl;
|
||||||
|
|
||||||
|
cout << "Temperature: " << sensor->getTemperature() << endl;
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
usleep(500000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
cout << "Exiting..." << endl;
|
||||||
|
|
||||||
|
delete sensor;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
81
examples/c++/mq4.cxx
Normal file
81
examples/c++/mq4.cxx
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include "mq4.h"
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
bool shouldRun = true;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void
|
||||||
|
sig_handler(int signo)
|
||||||
|
{
|
||||||
|
if (signo == SIGINT)
|
||||||
|
{
|
||||||
|
shouldRun = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
// Attach gas sensor to Analog A0
|
||||||
|
upm::MQ4 *sensor = new upm::MQ4(0);
|
||||||
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
|
uint16_t buffer [128];
|
||||||
|
|
||||||
|
thresholdContext ctx;
|
||||||
|
ctx.averageReading = 0;
|
||||||
|
ctx.runningAverage = 0;
|
||||||
|
ctx.averagedOver = 2;
|
||||||
|
|
||||||
|
// Infinite loop, ends when script is cancelled
|
||||||
|
// Repeatedly, take a sample every 2 microseconds;
|
||||||
|
// find the average of 128 samples; and
|
||||||
|
// print a running graph of asteriskss as averages
|
||||||
|
while (shouldRun)
|
||||||
|
{
|
||||||
|
int len = sensor->getSampledWindow (2, 128, buffer);
|
||||||
|
if (len) {
|
||||||
|
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
|
||||||
|
sensor->printGraph(&ctx, 5);
|
||||||
|
if (thresh) {
|
||||||
|
// do something ....
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "Exiting" << endl;
|
||||||
|
|
||||||
|
delete sensor;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
81
examples/c++/mq6.cxx
Normal file
81
examples/c++/mq6.cxx
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include "mq6.h"
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
bool shouldRun = true;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void
|
||||||
|
sig_handler(int signo)
|
||||||
|
{
|
||||||
|
if (signo == SIGINT)
|
||||||
|
{
|
||||||
|
shouldRun = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
// Attach gas sensor to Analog A0
|
||||||
|
upm::MQ6 *sensor = new upm::MQ6(0);
|
||||||
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
|
uint16_t buffer [128];
|
||||||
|
|
||||||
|
thresholdContext ctx;
|
||||||
|
ctx.averageReading = 0;
|
||||||
|
ctx.runningAverage = 0;
|
||||||
|
ctx.averagedOver = 2;
|
||||||
|
|
||||||
|
// Infinite loop, ends when script is cancelled
|
||||||
|
// Repeatedly, take a sample every 2 microseconds;
|
||||||
|
// find the average of 128 samples; and
|
||||||
|
// print a running graph of asteriskss as averages
|
||||||
|
while (shouldRun)
|
||||||
|
{
|
||||||
|
int len = sensor->getSampledWindow (2, 128, buffer);
|
||||||
|
if (len) {
|
||||||
|
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
|
||||||
|
sensor->printGraph(&ctx, 5);
|
||||||
|
if (thresh) {
|
||||||
|
// do something ....
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "Exiting" << endl;
|
||||||
|
|
||||||
|
delete sensor;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
81
examples/c++/mq7.cxx
Normal file
81
examples/c++/mq7.cxx
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include "mq7.h"
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
bool shouldRun = true;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void
|
||||||
|
sig_handler(int signo)
|
||||||
|
{
|
||||||
|
if (signo == SIGINT)
|
||||||
|
{
|
||||||
|
shouldRun = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
// Attach gas sensor to Analog A0
|
||||||
|
upm::MQ7 *sensor = new upm::MQ7(0);
|
||||||
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
|
uint16_t buffer [128];
|
||||||
|
|
||||||
|
thresholdContext ctx;
|
||||||
|
ctx.averageReading = 0;
|
||||||
|
ctx.runningAverage = 0;
|
||||||
|
ctx.averagedOver = 2;
|
||||||
|
|
||||||
|
// Infinite loop, ends when script is cancelled
|
||||||
|
// Repeatedly, take a sample every 2 microseconds;
|
||||||
|
// find the average of 128 samples; and
|
||||||
|
// print a running graph of asteriskss as averages
|
||||||
|
while (shouldRun)
|
||||||
|
{
|
||||||
|
int len = sensor->getSampledWindow (2, 128, buffer);
|
||||||
|
if (len) {
|
||||||
|
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
|
||||||
|
sensor->printGraph(&ctx, 5);
|
||||||
|
if (thresh) {
|
||||||
|
// do something ....
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "Exiting" << endl;
|
||||||
|
|
||||||
|
delete sensor;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
81
examples/c++/mq8.cxx
Normal file
81
examples/c++/mq8.cxx
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include "mq8.h"
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
bool shouldRun = true;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void
|
||||||
|
sig_handler(int signo)
|
||||||
|
{
|
||||||
|
if (signo == SIGINT)
|
||||||
|
{
|
||||||
|
shouldRun = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
// Attach gas sensor to Analog A0
|
||||||
|
upm::MQ8 *sensor = new upm::MQ8(0);
|
||||||
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
|
uint16_t buffer [128];
|
||||||
|
|
||||||
|
thresholdContext ctx;
|
||||||
|
ctx.averageReading = 0;
|
||||||
|
ctx.runningAverage = 0;
|
||||||
|
ctx.averagedOver = 2;
|
||||||
|
|
||||||
|
// Infinite loop, ends when script is cancelled
|
||||||
|
// Repeatedly, take a sample every 2 microseconds;
|
||||||
|
// find the average of 128 samples; and
|
||||||
|
// print a running graph of asteriskss as averages
|
||||||
|
while (shouldRun)
|
||||||
|
{
|
||||||
|
int len = sensor->getSampledWindow (2, 128, buffer);
|
||||||
|
if (len) {
|
||||||
|
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
|
||||||
|
sensor->printGraph(&ctx, 5);
|
||||||
|
if (thresh) {
|
||||||
|
// do something ....
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "Exiting" << endl;
|
||||||
|
|
||||||
|
delete sensor;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
@ -60,7 +60,7 @@ main(int argc, char **argv)
|
|||||||
comm->configure ();
|
comm->configure ();
|
||||||
comm->setSpeedRate (upm::NRF_250KBPS);
|
comm->setSpeedRate (upm::NRF_250KBPS);
|
||||||
comm->setChannel (99);
|
comm->setChannel (99);
|
||||||
comm->dataRecievedHandler = nrf_handler;
|
comm->setDataReceivedHandler (nrf_handler);
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ main(int argc, char **argv)
|
|||||||
comm->setPayload (MAX_BUFFER);
|
comm->setPayload (MAX_BUFFER);
|
||||||
comm->setChannel (99);
|
comm->setChannel (99);
|
||||||
comm->configure ();
|
comm->configure ();
|
||||||
comm->dataRecievedHandler = nrf_handler;
|
comm->setDataReceivedHandler (nrf_handler);
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ int main()
|
|||||||
|
|
||||||
// Instantiate a OTP538U on analog pins A0 and A1
|
// Instantiate a OTP538U on analog pins A0 and A1
|
||||||
// A0 is used for the Ambient Temperature and A1 is used for the
|
// A0 is used for the Ambient Temperature and A1 is used for the
|
||||||
// Object tempewrature.
|
// Object temperature.
|
||||||
upm::OTP538U *temps = new upm::OTP538U(0, 1, OTP538U_AREF);
|
upm::OTP538U *temps = new upm::OTP538U(0, 1, OTP538U_AREF);
|
||||||
|
|
||||||
// Output ambient and object temperatures
|
// Output ambient and object temperatures
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
int doWork = 0;
|
int doWork = 0;
|
||||||
pulsensor_context sensor_ctx;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sig_handler(int signo)
|
sig_handler(int signo)
|
||||||
@ -49,13 +48,13 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
init_pulsensor (&sensor_ctx, handler);
|
Pulsensor *sensor = new Pulsensor(handler);
|
||||||
|
|
||||||
start_sampler (&sensor_ctx);
|
sensor->start_sampler();
|
||||||
while (!doWork) {
|
while (!doWork) {
|
||||||
usleep (5);
|
usleep (5);
|
||||||
}
|
}
|
||||||
stop_sampler (&sensor_ctx);
|
sensor->stop_sampler();
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
74
examples/c++/sm130.cxx
Normal file
74
examples/c++/sm130.cxx
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "sm130.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace upm;
|
||||||
|
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
// Instantiate a UART based SM130 RFID Module using defaults
|
||||||
|
upm::SM130* sensor = new upm::SM130();
|
||||||
|
|
||||||
|
// set the baud rate. 19200 baud is the default.
|
||||||
|
if (sensor->setBaudRate(19200))
|
||||||
|
{
|
||||||
|
cerr << "Failed to set baud rate" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "Resetting..." << endl;
|
||||||
|
sensor->reset();
|
||||||
|
|
||||||
|
cout << "Firmware revision: " << sensor->getFirmwareVersion() << endl;
|
||||||
|
|
||||||
|
cout << "Waiting up to 5 seconds for a tag..." << endl;
|
||||||
|
|
||||||
|
if (sensor->waitForTag(5000))
|
||||||
|
{
|
||||||
|
cout << "Found tag, UID: "
|
||||||
|
<< sensor->string2HexString(sensor->getUID()) << endl;
|
||||||
|
cout << "Tag Type: " << sensor->tag2String(sensor->getTagType())
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// error
|
||||||
|
cout << "waitForTag failed: " << sensor->getLastErrorString() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
cout << "Exiting" << endl;
|
||||||
|
delete sensor;
|
||||||
|
return 0;
|
||||||
|
}
|
149
examples/c++/ssd1306-oled.cxx
Normal file
149
examples/c++/ssd1306-oled.cxx
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* Author Marc Graham <marc@m2ag.net>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Adapted from ssd1308 library.
|
||||||
|
* Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com>
|
||||||
|
* Copyright (c) 2014 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ssd1306.h"
|
||||||
|
|
||||||
|
#define DEVICE_ADDRESS 0x3C
|
||||||
|
#define BUS_NUMBER 0x6
|
||||||
|
|
||||||
|
static uint8_t intel_logo[] = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 192, 192, 192, 224,
|
||||||
|
224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, 60,
|
||||||
|
62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||||
|
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31,
|
||||||
|
30, 62, 62, 62, 62, 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240,
|
||||||
|
224, 224, 224, 192, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, 1, 1, 1, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195,
|
||||||
|
195, 7, 15, 15, 63, 127, 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 128, 192, 192, 240, 248, 124, 124, 60, 0, 0, 0, 0, 159, 159,
|
||||||
|
159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0,
|
||||||
|
0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128,
|
||||||
|
128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128,
|
||||||
|
128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
0, 0, 0, 0, 3, 7, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 0, 0, 224, 248, 252, 252, 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15,
|
||||||
|
15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143,
|
||||||
|
135, 135, 143, 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,
|
||||||
|
224, 248, 248, 255, 255, 255, 255, 255, 127, 15, 255, 255, 255, 255, 255,
|
||||||
|
255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255,
|
||||||
|
255, 255, 255, 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231,
|
||||||
|
231, 231, 199, 135, 0, 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0,
|
||||||
|
0, 0, 224, 240, 248, 248, 252, 254, 255, 255, 255, 127, 63, 63, 31, 15, 7,
|
||||||
|
7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, 240, 192, 192, 128, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7,
|
||||||
|
7, 7, 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7,
|
||||||
|
7, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15,
|
||||||
|
31, 127, 127, 127, 255, 255, 252, 252, 252, 248, 240, 240, 240, 224, 224,
|
||||||
|
224, 192, 192, 192, 192, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192,
|
||||||
|
224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, 252,
|
||||||
|
254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
3, 3, 3, 7, 7, 7, 15, 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127,
|
||||||
|
127, 127, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||||
|
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 127, 127, 127, 127,
|
||||||
|
63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, 3, 3,
|
||||||
|
3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
//! [Interesting]
|
||||||
|
upm::SSD1306 *lcd = new upm::SSD1306(BUS_NUMBER, DEVICE_ADDRESS);
|
||||||
|
|
||||||
|
lcd->clear();
|
||||||
|
lcd->stopscroll();
|
||||||
|
lcd->draw(intel_logo, 1024);
|
||||||
|
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
lcd->clear();
|
||||||
|
lcd->setCursor(2, 0);
|
||||||
|
lcd->write("Hello");
|
||||||
|
lcd->setCursor(3,0);
|
||||||
|
lcd->write("World");
|
||||||
|
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
lcd->invert(true);
|
||||||
|
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
lcd->dim(true);
|
||||||
|
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
lcd->dim(false);
|
||||||
|
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
lcd->invert(false);
|
||||||
|
lcd->startscrollright(0x00, 0x0F);
|
||||||
|
|
||||||
|
sleep(5);
|
||||||
|
|
||||||
|
lcd->stopscroll();
|
||||||
|
lcd->startscrollleft(0x00, 0x0F);
|
||||||
|
|
||||||
|
sleep(5);
|
||||||
|
|
||||||
|
lcd->stopscroll();
|
||||||
|
lcd->startscrolldiagleft(0x00,0x0F);
|
||||||
|
|
||||||
|
sleep(5);
|
||||||
|
|
||||||
|
lcd->stopscroll();
|
||||||
|
lcd->startscrolldiagright(0x00,0x0F);
|
||||||
|
|
||||||
|
sleep(5);
|
||||||
|
|
||||||
|
lcd->stopscroll();
|
||||||
|
|
||||||
|
delete lcd;
|
||||||
|
//! [Interesting]
|
||||||
|
return 0;
|
||||||
|
}
|
@ -56,7 +56,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
// Collect and output NMEA data. There are various libraries out on
|
// Collect and output NMEA data. There are various libraries out on
|
||||||
// the Internet, such as tinyGPS or tinyGPS++ that can handle
|
// the Internet, such as tinyGPS or tinyGPS++ that can handle
|
||||||
// decoding NMEA data and presenting it in a more easily accessable
|
// decoding NMEA data and presenting it in a more easily accessible
|
||||||
// format. This example will just check for, and read raw NMEA data
|
// format. This example will just check for, and read raw NMEA data
|
||||||
// from the device and output it on stdout.
|
// from the device and output it on stdout.
|
||||||
|
|
||||||
|
69
examples/c++/wheelencoder.cxx
Normal file
69
examples/c++/wheelencoder.cxx
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <signal.h>
|
||||||
|
#include "wheelencoder.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int shouldRun = true;
|
||||||
|
|
||||||
|
void sig_handler(int signo)
|
||||||
|
{
|
||||||
|
if (signo == SIGINT)
|
||||||
|
shouldRun = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
// Instantiate a DFRobot Wheel Encoder on digital pin D2
|
||||||
|
upm::WheelEncoder* sensor = new upm::WheelEncoder(2);
|
||||||
|
|
||||||
|
// set the counter to 0 and start counting
|
||||||
|
sensor->clearCounter();
|
||||||
|
sensor->startCounter();
|
||||||
|
|
||||||
|
while (shouldRun)
|
||||||
|
{
|
||||||
|
// output milliseconds passed and current sensor count
|
||||||
|
cout << "Millis: " << sensor->getMillis() << " Count: "
|
||||||
|
<< sensor->counter() << endl;
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sensor->stopCounter();
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
cout << "Exiting..." << endl;
|
||||||
|
|
||||||
|
delete sensor;
|
||||||
|
return 0;
|
||||||
|
}
|
51
examples/java/A110XSample.java
Normal file
51
examples/java/A110XSample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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]
|
||||||
|
// Instantiate an A110X sensor on digital pin D2
|
||||||
|
upm_a110x.A110X a110x = new upm_a110x.A110X(2);
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
if(a110x.magnetDetected()) {
|
||||||
|
System.out.println("magnet detected...");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("magnet not detected...");
|
||||||
|
}
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
56
examples/java/Adxl345Sample.java
Normal file
56
examples/java/Adxl345Sample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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];
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
obj.update();
|
||||||
|
raw = obj.getRawValues();
|
||||||
|
accel = obj.getAcceleration();
|
||||||
|
|
||||||
|
System.out.println("raw data: " + raw[0] + " " + raw[1] + " " +
|
||||||
|
raw[2]);
|
||||||
|
System.out.println("accel data: " + accel[0] + " " + accel[1] + " "
|
||||||
|
+ accel[2]);
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
54
examples/java/BISS0001Sample.java
Normal file
54
examples/java/BISS0001Sample.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class BISS0001Sample{
|
||||||
|
|
||||||
|
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
|
||||||
|
upm_biss0001.BISS0001 motion = new upm_biss0001.BISS0001(7);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
boolean value = motion.value();
|
||||||
|
|
||||||
|
if(value)
|
||||||
|
System.out.println("Detecting moving object");
|
||||||
|
else
|
||||||
|
System.out.println("No moving objects detected");
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
56
examples/java/BMPX8XSample.java
Normal file
56
examples/java/BMPX8XSample.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 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]
|
||||||
|
// 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){
|
||||||
|
System.out.println("Pressure: " + sensor.getPressure());
|
||||||
|
System.out.println("Altitude: " + sensor.getAltitude());
|
||||||
|
System.out.println("Sealevel pressure: " + sensor.getSealevelPressure());
|
||||||
|
System.out.println("Temperature: " + sensor.getTemperature());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
66
examples/java/Buzzer_soundSample.java
Normal file
66
examples/java/Buzzer_soundSample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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[] = {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
63
examples/java/CJQ4435Sample.java
Normal file
63
examples/java/CJQ4435Sample.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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 CJQ4435Sample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_cjq4435");
|
||||||
|
}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 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){
|
||||||
|
// start with a duty cycle of 0.0 (off) and increment to 1.0 (on)
|
||||||
|
for (float i=0; i <= 1; i+=0.1){
|
||||||
|
mosfet.setDutyCycle(i);
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
// 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){
|
||||||
|
mosfet.setDutyCycle(i);
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
64
examples/java/ENC03RSample.java
Normal file
64
examples/java/ENC03RSample.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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 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]
|
||||||
|
|
||||||
|
// Instantiate a ENC03R on analog pin A0
|
||||||
|
upm_enc03r.ENC03R gyro = new upm_enc03r.ENC03R(0);
|
||||||
|
|
||||||
|
System.out.println("Please place the sensor in a stable location, and do not");
|
||||||
|
System.out.println("move it while calibration takes place");
|
||||||
|
System.out.println("This may take a couple of minutes.");
|
||||||
|
|
||||||
|
gyro.calibrate(CALIBRATION_SAMPLES);
|
||||||
|
System.out.println("Calibration complete. Reference value: " + gyro.calibrationValue());
|
||||||
|
|
||||||
|
// Read the input and print both the raw value and the angular velocity,
|
||||||
|
// waiting 1 second between readings
|
||||||
|
while(true){
|
||||||
|
long val = gyro.value();
|
||||||
|
double av = gyro.angularVelocity(val);
|
||||||
|
|
||||||
|
System.out.println("Raw value: " + val + ", angular velocity: " + av + " deg/s");
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
64
examples/java/ES08ASample.java
Normal file
64
examples/java/ES08ASample.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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_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 static void main(String[] args) throws InterruptedException {
|
||||||
|
//! [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);
|
||||||
|
System.out.println("Set angle to 180");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
servo.setAngle (90);
|
||||||
|
System.out.println("Set angle to 90");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
servo.setAngle (0);
|
||||||
|
System.out.println("Set angle to 0");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
servo.setAngle (90);
|
||||||
|
System.out.println("Set angle to 90");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
servo.setAngle (180);
|
||||||
|
System.out.println("Set angle to 180");
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
56
examples/java/GUVAS12DSample.java
Normal file
56
examples/java/GUVAS12DSample.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_guvas12d.GUVAS12D;
|
||||||
|
|
||||||
|
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]
|
||||||
|
// 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 );
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
examples/java/GroveButtonSample.java
Normal file
49
examples/java/GroveButtonSample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GroveButtonSample{
|
||||||
|
|
||||||
|
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]
|
||||||
|
// Create the button object using UART
|
||||||
|
upm_grove.GroveButton button = new upm_grove.GroveButton(0);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
System.out.println(button.name() +" value is " + button.value());
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
48
examples/java/GroveLEDSample.java
Normal file
48
examples/java/GroveLEDSample.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Author: Andrei Vasiliu <andrei.vasiliu@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 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);
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
led.on();
|
||||||
|
Thread.sleep(1000);
|
||||||
|
led.off();
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
led.delete();
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
50
examples/java/GroveLightSample.java
Normal file
50
examples/java/GroveLightSample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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]
|
||||||
|
upm_grove.GroveLight gl = new upm_grove.GroveLight(2);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
float raw_value = gl.raw_value();
|
||||||
|
float value = gl.value();
|
||||||
|
|
||||||
|
System.out.println("raw value: " + raw_value);
|
||||||
|
System.out.println("value: " + value);
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
55
examples/java/GroveLineFinderSample.java
Normal file
55
examples/java/GroveLineFinderSample.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 GroveLineFinderSample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_grovelinefinder");
|
||||||
|
}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 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){
|
||||||
|
boolean val = finder.whiteDetected();
|
||||||
|
if(val){
|
||||||
|
System.out.println("White detected");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("Black detected");
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
56
examples/java/GroveMoistureSample.java
Normal file
56
examples/java/GroveMoistureSample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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]
|
||||||
|
upm_grovemoisture.GroveMoisture gm = new upm_grovemoisture.GroveMoisture(1);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
int moisture_val = gm.value();
|
||||||
|
String result;
|
||||||
|
|
||||||
|
if (moisture_val >= 0 && moisture_val < 300)
|
||||||
|
result = "Dry";
|
||||||
|
else if ((moisture_val >= 0 && moisture_val < 300))
|
||||||
|
result = "Moist";
|
||||||
|
else
|
||||||
|
result = "Wet";
|
||||||
|
|
||||||
|
System.out.println("Moisture Value: " + moisture_val + ", " + result );
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
53
examples/java/GroveRelaySample.java
Normal file
53
examples/java/GroveRelaySample.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 GroveRelaySample{
|
||||||
|
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]
|
||||||
|
// Create the button object using UART
|
||||||
|
upm_grove.GroveRelay relay = new upm_grove.GroveRelay(5);
|
||||||
|
|
||||||
|
for( int i = 0 ; i < 3 ; i++ ){
|
||||||
|
relay.on();
|
||||||
|
if( relay.isOn() )
|
||||||
|
System.out.println("Relay is on");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
relay.off();
|
||||||
|
if( relay.isOff() )
|
||||||
|
System.out.println("Relay is off");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
56
examples/java/GroveRotarySample.java
Normal file
56
examples/java/GroveRotarySample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GroveRotarySample{
|
||||||
|
|
||||||
|
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.GroveRotary knob = new upm_grove.GroveRotary(0);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
float abs_value = knob.abs_value(); // Absolute raw value
|
||||||
|
float abs_deg = knob.abs_deg(); // Absolute degrees
|
||||||
|
float abs_rad = knob.abs_rad(); // Absolute radians
|
||||||
|
float rel_value = knob.rel_value(); // Relative raw value
|
||||||
|
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" );
|
||||||
|
|
||||||
|
Thread.sleep(3000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
51
examples/java/GroveSlideSample.java
Normal file
51
examples/java/GroveSlideSample.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Author: Andrei Vasiliu <andrei.vasiliu@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 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
|
||||||
|
upm_grove.GroveSlide slide = new upm_grove.GroveSlide(0);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
float raw_value = slide.raw_value();
|
||||||
|
float value = slide.voltage_value();
|
||||||
|
|
||||||
|
System.out.println("raw value: " + raw_value);
|
||||||
|
System.out.println("value: " + value);
|
||||||
|
|
||||||
|
Thread.sleep(2500);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
49
examples/java/GroveSpeakerSample.java
Normal file
49
examples/java/GroveSpeakerSample.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Author: Andrei Vasiliu <andrei.vasiliu@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 GroveSpeakerSample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_grovespeaker");
|
||||||
|
}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 Speaker on digital pin D2
|
||||||
|
upm_grovespeaker.GroveSpeaker speaker = new upm_grovespeaker.GroveSpeaker(2);
|
||||||
|
|
||||||
|
// Play all 7 of the lowest notes
|
||||||
|
speaker.playAll();
|
||||||
|
|
||||||
|
// Play a medium C-sharp
|
||||||
|
speaker.playSound('c', true, "med");
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
52
examples/java/GroveTempSample.java
Normal file
52
examples/java/GroveTempSample.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Author: Andrei Vasiliu <andrei.vasiliu@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 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);
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
|
||||||
|
int celsius = temp.value();
|
||||||
|
int fahrneheit = celsius * 2 + 32;
|
||||||
|
|
||||||
|
System.out.println("Celsius: " + celsius);
|
||||||
|
System.out.println("Fahrneheit: " + fahrneheit);
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
temp.delete();
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
58
examples/java/GroveVDivSample.java
Normal file
58
examples/java/GroveVDivSample.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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 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]
|
||||||
|
// 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){
|
||||||
|
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);
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
56
examples/java/GroveWaterSample.java
Normal file
56
examples/java/GroveWaterSample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GroveWaterSample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_grovewater");
|
||||||
|
}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 Water sensor on digital pin D2
|
||||||
|
upm_grovewater.GroveWater water = new upm_grovewater.GroveWater(2);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
boolean val = water.isWet();
|
||||||
|
if (val){
|
||||||
|
System.out.println("Sensor is wet");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("Sensor is dry");
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
60
examples/java/Hmc5883lSample.java
Normal file
60
examples/java/Hmc5883lSample.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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 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]
|
||||||
|
// Instantiate on I2C
|
||||||
|
upm_hmc5883l.Hmc5883l compas = new upm_hmc5883l.Hmc5883l(0);
|
||||||
|
|
||||||
|
int[] pos;
|
||||||
|
|
||||||
|
// Set your declination from true north in radians
|
||||||
|
compas.set_declination(0.2749f);
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
51
examples/java/Jhd1313m1_lcdSample.java
Normal file
51
examples/java/Jhd1313m1_lcdSample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
54
examples/java/Joystick12_exampleSample.java
Normal file
54
examples/java/Joystick12_exampleSample.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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 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
|
||||||
|
upm_joystick12.Joystick12 joystick = new upm_joystick12.Joystick12(0,1);
|
||||||
|
|
||||||
|
// Print the X and Y input values every second
|
||||||
|
while(true){
|
||||||
|
float x = joystick.getXInput();
|
||||||
|
float y = joystick.getYInput();
|
||||||
|
|
||||||
|
System.out.println("Driving X: " + x + " , and Y: " + y );
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
65
examples/java/LSM303Sample.java
Normal file
65
examples/java/LSM303Sample.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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 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]
|
||||||
|
// 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.·
|
||||||
|
// 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());
|
||||||
|
|
||||||
|
// Get and print out the heading
|
||||||
|
System.out.println("heading: " + sensor.getHeading());
|
||||||
|
|
||||||
|
// Get the acceleration
|
||||||
|
sensor.getAcceleration();
|
||||||
|
int[] accel = sensor.getRawAccelData();
|
||||||
|
|
||||||
|
// 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());
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
47
examples/java/MAX44000Sample.java
Normal file
47
examples/java/MAX44000Sample.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 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]
|
||||||
|
upm_max44000.MAX44000 sensor = new upm_max44000.MAX44000(0);
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
System.out.println("proximity value = " + sensor.getAmbient());
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
54
examples/java/MPL3115A2Sample.java
Normal file
54
examples/java/MPL3115A2Sample.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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 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]
|
||||||
|
// Instantiate a MPL3115A2 sensor on I2C
|
||||||
|
upm_mpl3115a2.MPL3115A2 sensor = new upm_mpl3115a2.MPL3115A2(0);
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
System.out.println("Pressure: " + sensor.getPressure());
|
||||||
|
System.out.println("Altitude: " + sensor.getAltitude());
|
||||||
|
System.out.println("Sealevel pressure: " + sensor.getSealevelPressure());
|
||||||
|
System.out.println("Temperature: " + sensor.getTemperature());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
59
examples/java/MPU9150Sample.java
Normal file
59
examples/java/MPU9150Sample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//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]
|
||||||
|
upm_mpu9150.MPU9150 sensor = new upm_mpu9150.MPU9150();
|
||||||
|
|
||||||
|
sensor.init();
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
sensor.update();
|
||||||
|
|
||||||
|
float[] accel = sensor.getAccelerometer();
|
||||||
|
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] );
|
||||||
|
|
||||||
|
float[] magn = sensor.getMagnetometer();
|
||||||
|
System.out.println("Magnetometer: " + "MX: " + magn[0] + " MY: " + magn[1] + " MZ: " + magn[2] );
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
64
examples/java/MQ303ASample.java
Normal file
64
examples/java/MQ303ASample.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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 MQ303ASample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_mq303a");
|
||||||
|
}catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("error in loading native library");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InterruptedException {
|
||||||
|
//! [Interesting]
|
||||||
|
// Instantiate an mq303a sensor on analog pin A0
|
||||||
|
|
||||||
|
// This device uses a heater powered from an analog I/O pin.·
|
||||||
|
// If using A0 as the data pin, then you need to use A1, as the heater
|
||||||
|
// pin (if using a grove mq303a). For A1, we can use the D15 gpio,·
|
||||||
|
// setup as an output, and drive it low to power the heater.
|
||||||
|
upm_mq303a.MQ303A mq303a = new upm_mq303a.MQ303A(1,15);
|
||||||
|
|
||||||
|
System.out.println("Enabling heater and waiting 2 minutes for warmup.");
|
||||||
|
mq303a.heaterEnable(true);
|
||||||
|
Thread.sleep(120000);
|
||||||
|
|
||||||
|
System.out.println("This sensor may need to warm until the value drops below about 450.");
|
||||||
|
|
||||||
|
for(int i = 1 ; i < 10 ; i++){
|
||||||
|
int val = mq303a.value();
|
||||||
|
System.out.println("Alcohol detected (higher means stronger alcohol): " + val);
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
mq303a.heaterEnable(false);
|
||||||
|
System.out.println("Exiting");
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
50
examples/java/MY9221_ledbarSample.java
Normal file
50
examples/java/MY9221_ledbarSample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MY9221_ledbarSample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_my9221");
|
||||||
|
}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 LED Bar, with Data pin D8 and Clock pin D9
|
||||||
|
upm_my9221.MY9221 bar = new upm_my9221.MY9221((short) 8, (short) 9);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
for (short idx = 1; idx < 11; idx++) {
|
||||||
|
bar.setBarLevel(idx);
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
69
examples/java/NUNCHUCKSample.java
Normal file
69
examples/java/NUNCHUCKSample.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* 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 NUNCHUCKSample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_nunchuck");
|
||||||
|
}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 nunchuck controller bus 0
|
||||||
|
upm_nunchuck.NUNCHUCK nunchuck = new upm_nunchuck.NUNCHUCK(0);
|
||||||
|
|
||||||
|
// always do this first
|
||||||
|
System.out.println("Initializing... ");
|
||||||
|
if (!nunchuck.init()) {
|
||||||
|
System.err.println("nunchuck->init() failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
nunchuck.update();
|
||||||
|
System.out.println( "stickX: " + nunchuck.getStickX() + ", stickY: " + nunchuck.getStickY() );
|
||||||
|
System.out.println( "accelX: " + nunchuck.getAccelX() + ", accelY: " + nunchuck.getAccelY()
|
||||||
|
+", accelZ: " + nunchuck.getAccelZ());
|
||||||
|
|
||||||
|
if(nunchuck.getButtonC())
|
||||||
|
System.out.println("Button C pressed");
|
||||||
|
else
|
||||||
|
System.out.println("Button C not pressed");
|
||||||
|
|
||||||
|
if(nunchuck.getButtonZ())
|
||||||
|
System.out.println("Button Z pressed");
|
||||||
|
else
|
||||||
|
System.out.println("Button Z not pressed");
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
51
examples/java/OTP538USample.java
Normal file
51
examples/java/OTP538USample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class OTP538USample{
|
||||||
|
private static final float OTP538U_AREF = 5;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_otp538u");
|
||||||
|
}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 OTP538U on analog pins A0 and A1
|
||||||
|
// A0 is used for the Ambient Temperature and A1 is used for the Object temperature.
|
||||||
|
upm_otp538u.OTP538U temps = new upm_otp538u.OTP538U(0, 1, OTP538U_AREF);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
System.out.println( "Ambient temp: " + temps.ambientTemperature() + " C" );
|
||||||
|
System.out.println( "Object temp: " + temps.objectTemperature() + " C" );
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
}
|
55
examples/java/PPD42NSSample.java
Normal file
55
examples/java/PPD42NSSample.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 PPD42NSSample {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_ppd42ns");
|
||||||
|
}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 dust sensor on GPIO pin D8
|
||||||
|
upm_ppd42ns.PPD42NS dust = new upm_ppd42ns.PPD42NS(8);
|
||||||
|
upm_ppd42ns.dustData data;
|
||||||
|
|
||||||
|
System.out.println("This program will give readings every 30 seconds until you stop it");
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
data = dust.getData();
|
||||||
|
|
||||||
|
System.out.println("Low pulse occupancy: " + data.getLowPulseOccupancy());
|
||||||
|
System.out.println("Ratio: " + data.getRatio());
|
||||||
|
System.out.println("Concentration: " + data.getConcentration());
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
54
examples/java/RFR359FSample.java
Normal file
54
examples/java/RFR359FSample.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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 RFR359FSample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_rfr359f");
|
||||||
|
}catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("error in loading native library");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InterruptedException {
|
||||||
|
//! [Interesting]
|
||||||
|
// Instantiate an RFR359F digital pin D2
|
||||||
|
upm_rfr359f.RFR359F dInterruptor = new upm_rfr359f.RFR359F(2);
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
if (dInterruptor.objectDetected()) {
|
||||||
|
System.out.println("Object detected");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("Area is clear!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
examples/java/RotaryEncoderSample.java
Normal file
49
examples/java/RotaryEncoderSample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class RotaryEncoderSample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_rotaryencoder");
|
||||||
|
}catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("error in loading native library");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InterruptedException {
|
||||||
|
//! [Interesting]
|
||||||
|
// Create the button object using UART
|
||||||
|
upm_rotaryencoder.RotaryEncoder rotaryencoder = new upm_rotaryencoder.RotaryEncoder(2, 3);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
System.out.println("Position: " + rotaryencoder.position());
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
71
examples/java/TP401Sample.java
Normal file
71
examples/java/TP401Sample.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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 TP401Sample{
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_gas");
|
||||||
|
}catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("error in loading native library");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String airQuality(int value){
|
||||||
|
if(value < 50) return "Fresh Air";
|
||||||
|
if(value < 200) return "Normal Indoor Air";
|
||||||
|
if(value < 400) return "Low Pollution";
|
||||||
|
if(value < 600) return "High Pollution - Action Recommended";
|
||||||
|
return "Very High Pollution - Take Action Immediately";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InterruptedException {
|
||||||
|
//! [Interesting]
|
||||||
|
// Instantiate new grove air quality sensor on analog pin A0
|
||||||
|
upm_gas.TP401 airSensor = new upm_gas.TP401(0);
|
||||||
|
|
||||||
|
System.out.println(airSensor.name());
|
||||||
|
|
||||||
|
System.out.println("Heating sensor for 3 minutes...");
|
||||||
|
// wait 3 minutes for sensor to warm up
|
||||||
|
for(int i = 0; i < 3; i++) {
|
||||||
|
if(i != 0)
|
||||||
|
System.out.println("Please wait, " + i + " minute(s) passed..");
|
||||||
|
Thread.sleep(60000);
|
||||||
|
}
|
||||||
|
System.out.println( "Sensor ready!");
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
int value = airSensor.getSample(); // Read raw value
|
||||||
|
float ppm = airSensor.getPPM(); // Read CO ppm (can vary slightly from previous read)
|
||||||
|
|
||||||
|
System.out.println("raw: " + value + " ppm: " + ppm + " " + airQuality(value) );
|
||||||
|
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
51
examples/java/TTP223Sample.java
Normal file
51
examples/java/TTP223Sample.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TTP223Sample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_ttp223");
|
||||||
|
}catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("error in loading native library");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InterruptedException {
|
||||||
|
//! [Interesting]
|
||||||
|
upm_ttp223.TTP223 touch = new upm_ttp223.TTP223(7);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if(touch.isPressed())
|
||||||
|
System.out.println( touch.name() + " is pressed" );
|
||||||
|
else
|
||||||
|
System.out.println( touch.name() + " is not pressed" );
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
63
examples/java/ULN200XASample.java
Normal file
63
examples/java/ULN200XASample.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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 ULN200XASample {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_uln200xa");
|
||||||
|
}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 Stepper motor on a ULN200XA Dual H-Bridge.
|
||||||
|
// Wire the pins so that I1 is pin D8, I2 is pin D9, I3 is pin D10 and
|
||||||
|
// I4 is pin D11
|
||||||
|
upm_uln200xa.ULN200XA uln200xa = new upm_uln200xa.ULN200XA(4096, 8, 9, 10, 11);
|
||||||
|
|
||||||
|
uln200xa.setSpeed(5);
|
||||||
|
System.out.println("Rotating 1 revolution clockwise.");
|
||||||
|
uln200xa.setDirection(upm_uln200xa.ULN200XA.ULN200XA_DIRECTION_T.DIR_CW);
|
||||||
|
uln200xa.stepperSteps(4096);
|
||||||
|
|
||||||
|
System.out.println("Sleeping for 2 seconds...");
|
||||||
|
Thread.sleep(2000);
|
||||||
|
|
||||||
|
System.out.println("Rotating 1/2 revolution counter clockwise.");
|
||||||
|
uln200xa.setDirection(upm_uln200xa.ULN200XA.ULN200XA_DIRECTION_T.DIR_CCW);
|
||||||
|
uln200xa.stepperSteps(2048);
|
||||||
|
|
||||||
|
// turn off the power
|
||||||
|
uln200xa.release();
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
System.out.println("Exiting...");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
83
examples/java/Ublox6Sample.java
Normal file
83
examples/java/Ublox6Sample.java
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* 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 Ublox6Sample {
|
||||||
|
private static final int BUFFERLENGTH = 256;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_ublox6");
|
||||||
|
}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 Ublox6 GPS device on uart 0
|
||||||
|
upm_ublox6.Ublox6 nmea = new upm_ublox6.Ublox6(0);
|
||||||
|
|
||||||
|
// make sure port is initialized properly. 9600 baud is the default.
|
||||||
|
if(!nmea.setupTty()){
|
||||||
|
throw new RuntimeException("Failed to setup tty port parameters");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect and output NMEA data. There are various libraries out on
|
||||||
|
// the Internet, such as tinyGPS or tinyGPS++ that can handle
|
||||||
|
// decoding NMEA data and presenting it in a more easily accessible
|
||||||
|
// format. This example will just check for, and read raw NMEA data
|
||||||
|
// from the device and output it on standard output.
|
||||||
|
|
||||||
|
// This device also supports numerous configuration options, which
|
||||||
|
// you can set with writeData(). Please refer to the Ublox-6 data
|
||||||
|
// sheet for further information on the formats of the data sent and
|
||||||
|
// received, and the various operating modes available.
|
||||||
|
|
||||||
|
byte[] nmeaBuffer = new byte[BUFFERLENGTH];
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
// we don't want the read to block in this example, so always
|
||||||
|
// check to see if data is available first.
|
||||||
|
if (nmea.dataAvailable()){
|
||||||
|
int rv = nmea.readData(nmeaBuffer);
|
||||||
|
|
||||||
|
if(rv > 0)
|
||||||
|
for (int i = 0; i < nmeaBuffer.length; i++)
|
||||||
|
System.out.print(nmeaBuffer[i]);
|
||||||
|
|
||||||
|
if (rv < 0){ // some sort of read error occured
|
||||||
|
System.err.println("Port read error.") ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
55
examples/java/YG1006Sample.java
Normal file
55
examples/java/YG1006Sample.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 YG1006Sample{
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("javaupm_yg1006");
|
||||||
|
}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 yg1006 flame sensor on digital pin D2
|
||||||
|
upm_yg1006.YG1006 flame = new upm_yg1006.YG1006(2);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
boolean val = flame.flameDetected();
|
||||||
|
if (val){
|
||||||
|
System.out.println("Flame detected");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("No flame detected");
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
//! [Interesting]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,9 @@
|
|||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
* Copyright (c) 2015 Intel Corporation.
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
*
|
*
|
||||||
|
* Author: Tyler Gibson <tgibson@microsoft.com>
|
||||||
|
* Copyright (c) 2015 Microsoft Corporation.
|
||||||
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* "Software"), to deal in the Software without restriction, including
|
||||||
@ -25,27 +28,123 @@
|
|||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var lcdObj = require('jsupm_i2clcd');
|
||||||
|
var oled = new lcdObj.EBOLED();
|
||||||
|
|
||||||
|
var sample = 0;
|
||||||
|
var samples = 13;
|
||||||
|
|
||||||
function exit()
|
function exit()
|
||||||
{
|
{
|
||||||
lcd = null;
|
oled = null;
|
||||||
lcdObj.cleanUp();
|
lcdObj.cleanUp();
|
||||||
lcdObj = null;
|
lcdObj = null;
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load i2clcd module
|
setInterval( function()
|
||||||
var lcdObj = require('jsupm_i2clcd');
|
{
|
||||||
|
if(sample>samples)
|
||||||
var lcd = new lcdObj.EBOLED();
|
{
|
||||||
|
exit();
|
||||||
lcd.clear();
|
}
|
||||||
lcd.setCursor(2, 0);
|
oled.clearScreenBuffer();
|
||||||
lcd.write("Hello");
|
runSample(sample++);
|
||||||
lcd.setCursor(3, 5);
|
oled.refresh();
|
||||||
lcd.write("World!");
|
}, 1500);
|
||||||
|
|
||||||
console.log("Sleeping for 5 seconds...");
|
|
||||||
setTimeout(exit, 5000);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function runSample(sample)
|
||||||
|
{
|
||||||
|
switch(sample) {
|
||||||
|
case 0:
|
||||||
|
// x/y coords are 0 based, using 1 here for padding.
|
||||||
|
oled.setCursor(1,1);
|
||||||
|
// nowrap = 0, wrapping = 1
|
||||||
|
oled.setTextWrap(1);
|
||||||
|
oled.write("HELLO WORLD! Mixed with #123 and y's, g's and q's.");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
oled.setCursor(12, 1);
|
||||||
|
//multiply text size, only integers
|
||||||
|
oled.setTextSize(3);
|
||||||
|
oled.write("BOO!");
|
||||||
|
oled.setTextSize(1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
oled.drawRectangleFilled(0,0,48,9);
|
||||||
|
oled.setCursor(1,1);
|
||||||
|
// 0=Black, 1=White, 2=Xor (Toggle)
|
||||||
|
oled.setTextColor(2);
|
||||||
|
oled.write("Cutout");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
var total = Math.random()*100;
|
||||||
|
for(var stars=0; stars<total; stars++ )
|
||||||
|
oled.drawPixel(Math.floor(Math.random()*63), Math.floor(Math.random()*47), 1);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
for(var burst=0; burst<12; burst++)
|
||||||
|
oled.drawLine(31, 24, Math.floor(Math.random()*63), Math.floor(Math.random()*47), 1);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
var lastPeak = 24;
|
||||||
|
for(var peak=0; peak < 64; peak++)
|
||||||
|
{
|
||||||
|
var thisPeak = Math.abs(lastPeak + Math.floor(Math.random()*(-6) + Math.random()*6));
|
||||||
|
oled.drawLine(peak, thisPeak, peak, 47, 1);
|
||||||
|
lastPeak = thisPeak;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
for(var y=0; y<47; y++)
|
||||||
|
{
|
||||||
|
oled.drawLineHorizontal(0,y+1,63,2);
|
||||||
|
oled.refresh();
|
||||||
|
oled.drawLineHorizontal(0,y,63,2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
var eqbarHeights = [ Math.floor(Math.random()*32),
|
||||||
|
Math.floor(Math.random()*32),
|
||||||
|
Math.floor(Math.random()*32),
|
||||||
|
Math.floor(Math.random()*32),
|
||||||
|
Math.floor(Math.random()*32),
|
||||||
|
Math.floor(Math.random()*32),
|
||||||
|
Math.floor(Math.random()*32) ];
|
||||||
|
var begin = Date.now();
|
||||||
|
while(Date.now()-begin < 2000)
|
||||||
|
{
|
||||||
|
oled.clearScreenBuffer();
|
||||||
|
for(var eqbar=0; eqbar<7; eqbar++)
|
||||||
|
{
|
||||||
|
oled.drawRectangleFilled(eqbar*9, 49 - eqbarHeights[eqbar], 8, eqbarHeights[eqbar], 1);
|
||||||
|
eqbarHeights[eqbar] = eqbarHeights[eqbar] + Math.random()*(-2) + Math.random()*2;
|
||||||
|
if(eqbarHeights[eqbar]<0)
|
||||||
|
eqbarHeights[eqbar] = 1;
|
||||||
|
}
|
||||||
|
oled.refresh();
|
||||||
|
}
|
||||||
|
oled.clear();
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
oled.drawRoundedRectangle(8, 8, 48, 16, 4, 1);
|
||||||
|
oled.setCursor(12, 16);
|
||||||
|
oled.write("Cancel");
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
oled.drawTriangle(2, 2, 52, 7, 17, 37, 1);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
oled.drawTriangleFilled(2, 2, 52, 7, 17, 37, 1);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
oled.drawCircle(32, 24, 14, 1);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
oled.drawCircleFilled(32, 24, 14, 1);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
oled.fillScreen(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
114
examples/javascript/grovegprs.js
Normal file
114
examples/javascript/grovegprs.js
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var sensorObj = require('jsupm_grovegprs');
|
||||||
|
|
||||||
|
|
||||||
|
/************** Functions **************/
|
||||||
|
function printUsage(progname)
|
||||||
|
{
|
||||||
|
var outputStr = "Usage: " + progname + " [AT command]\n\n" +
|
||||||
|
"If an argument is supplied on the command line, that argument is\n" +
|
||||||
|
"sent to the module and the response is printed out.\n\n" +
|
||||||
|
"If no argument is used, then the manufacturer and the current\n" +
|
||||||
|
"saved profiles are queried and the results printed out.\n\n"
|
||||||
|
console.log(outputStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// simple helper function to send a command and wait for a response
|
||||||
|
function sendCommand(sensor, cmd, callback)
|
||||||
|
{
|
||||||
|
// commands need to be terminated with a carriage return
|
||||||
|
cmd += "\r";
|
||||||
|
sensor.writeDataStr(cmd);
|
||||||
|
|
||||||
|
// wait up to 1 second
|
||||||
|
if (sensor.dataAvailable(1000))
|
||||||
|
{
|
||||||
|
console.log("Returned: " + sensor.readDataStr(1024));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
console.log("Timed out waiting for response");
|
||||||
|
|
||||||
|
if (callback)
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
/************** Main code **************/
|
||||||
|
// Instantiate a GROVEGPRS Module on UART 0
|
||||||
|
var sensor = new sensorObj.GroveGPRS(0);
|
||||||
|
|
||||||
|
// Set the baud rate, 19200 baud is the default.
|
||||||
|
if (sensor.setBaudRate(19200))
|
||||||
|
{
|
||||||
|
console.log("Failed to set baud rate");
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
printUsage(process.argv[1]);
|
||||||
|
|
||||||
|
// Note: in nodeJS, command-line argument 0 is "node".
|
||||||
|
// Command-line argument 1 is "grovegprs.js"
|
||||||
|
// If you have a third argument, then it's a command
|
||||||
|
if (process.argv.length > 2)
|
||||||
|
{
|
||||||
|
console.log("Sending command line argument (" + process.argv[2] + ")...");
|
||||||
|
sendCommand(sensor, process.argv[2]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// sending this command as a synchronous callback ensures better timing
|
||||||
|
var callbackFunc = function()
|
||||||
|
{
|
||||||
|
setTimeout(function()
|
||||||
|
{
|
||||||
|
// query the saved profiles
|
||||||
|
console.log("Querying the saved profiles (AT&V)...");
|
||||||
|
sendCommand(sensor, "AT&V");
|
||||||
|
|
||||||
|
// A comprehensive list is available from the
|
||||||
|
// datasheet at:
|
||||||
|
// http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
|
||||||
|
}, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
// query the module manufacturer
|
||||||
|
console.log("Querying module manufacturer (AT+CGMI)...");
|
||||||
|
sendCommand(sensor, "AT+CGMI", callbackFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************** Exit code **************/
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
sensor = null;
|
||||||
|
sensorObj.cleanUp();
|
||||||
|
sensorObj = null;
|
||||||
|
console.log("Exiting...");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
@ -1,43 +0,0 @@
|
|||||||
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
|
||||||
/*jshint unused:true */
|
|
||||||
/*global */
|
|
||||||
/*
|
|
||||||
* Author: Zion Orent <zorent@ics.com>
|
|
||||||
* Copyright (c) 2014 Intel Corporation.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var loudnessSensor = require('jsupm_groveloudness');
|
|
||||||
// Instantiate a Grove Loudness sensor on analog pin A0
|
|
||||||
var myLoudnessSensor = new loudnessSensor.GroveLoudness(0);
|
|
||||||
|
|
||||||
// Print the loudness value every 0.1 seconds
|
|
||||||
setInterval(function()
|
|
||||||
{
|
|
||||||
console.log("Loudness value (higher is louder): " + myLoudnessSensor.value());
|
|
||||||
}, 100);
|
|
||||||
|
|
||||||
// Print message when exiting
|
|
||||||
process.on('SIGINT', function()
|
|
||||||
{
|
|
||||||
console.log("Exiting...");
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
95
examples/javascript/grovemd-stepper.js
Normal file
95
examples/javascript/grovemd-stepper.js
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var grovemdObj = require('jsupm_grovemd');
|
||||||
|
|
||||||
|
// This example demonstrates using the GroveMD to drive a stepper motor
|
||||||
|
|
||||||
|
function start()
|
||||||
|
{
|
||||||
|
if (motor)
|
||||||
|
{
|
||||||
|
// configure it, for this example, we'll assume 200 steps per rev
|
||||||
|
motor.configStepper(200);
|
||||||
|
motor.setStepperSteps(100);
|
||||||
|
// start it going at 10 RPM
|
||||||
|
motor.enableStepper(grovemdObj.GroveMD.STEP_DIR_CW, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function reverse()
|
||||||
|
{
|
||||||
|
if (motor)
|
||||||
|
{
|
||||||
|
// now reverse
|
||||||
|
motor.setStepperSteps(100);
|
||||||
|
// start it going at 10 RPM
|
||||||
|
motor.enableStepper(grovemdObj.GroveMD.STEP_DIR_CCW, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function end()
|
||||||
|
{
|
||||||
|
if (motor)
|
||||||
|
{
|
||||||
|
motor.disableStepper();
|
||||||
|
}
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// When exiting: clear memory and print exit message
|
||||||
|
function exit()
|
||||||
|
{
|
||||||
|
if (motor)
|
||||||
|
{
|
||||||
|
motor = null;
|
||||||
|
grovemdObj.cleanUp();
|
||||||
|
}
|
||||||
|
grovemdObj = null;
|
||||||
|
console.log("Exiting");
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Instantiate an I2C Grove Motor Driver on I2C bus 0
|
||||||
|
var motor = new grovemdObj.GroveMD(
|
||||||
|
grovemdObj.GROVEMD_I2C_BUS,
|
||||||
|
grovemdObj.GROVEMD_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
|
start();
|
||||||
|
|
||||||
|
setTimeout(function()
|
||||||
|
{
|
||||||
|
reverse();
|
||||||
|
setTimeout(end, 3000);
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
exit();
|
||||||
|
});
|
51
examples/javascript/lm35.js
Normal file
51
examples/javascript/lm35.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var sensorObj = require('jsupm_lm35');
|
||||||
|
|
||||||
|
// Instantiate a LM35 on analog pin A0, with a default analog
|
||||||
|
// reference voltage of 5.0
|
||||||
|
var sensor = new sensorObj.LM35(0);
|
||||||
|
|
||||||
|
// Every half second, sample the sensor and output the temperature
|
||||||
|
|
||||||
|
setInterval(function()
|
||||||
|
{
|
||||||
|
console.log("Temperature: " + sensor.getTemperature() + " C");
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
// exit on ^C
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
sensor = null;
|
||||||
|
sensorObj.cleanUp();
|
||||||
|
sensorObj = null;
|
||||||
|
console.log("Exiting.");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
52
examples/javascript/loudness.js
Normal file
52
examples/javascript/loudness.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var sensorObj = require('jsupm_loudness');
|
||||||
|
|
||||||
|
// Instantiate a Loudness sensor on analog pin A0, with an analog
|
||||||
|
// reference voltage of 5.0
|
||||||
|
var sensor = new sensorObj.Loudness(0, 5.0);
|
||||||
|
|
||||||
|
// Every tenth of a second, sample the loudness and output it's
|
||||||
|
// corresponding analog voltage.
|
||||||
|
|
||||||
|
setInterval(function()
|
||||||
|
{
|
||||||
|
console.log("Detected loudness (volts): " + sensor.loudness());
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
// exit on ^C
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
sensor = null;
|
||||||
|
sensorObj.cleanUp();
|
||||||
|
sensorObj = null;
|
||||||
|
console.log("Exiting.");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
53
examples/javascript/mg811.js
Normal file
53
examples/javascript/mg811.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var sensorObj = require('jsupm_mg811');
|
||||||
|
|
||||||
|
// Instantiate an MG811 on analog pin A0, and digital pin D2 with an
|
||||||
|
// analog reference voltage of MG811_AREF (5.0)
|
||||||
|
|
||||||
|
var sensor = new sensorObj.MG811(0, 2, 5.0);
|
||||||
|
|
||||||
|
// Every tenth of a second, sample the sensor and output it's
|
||||||
|
// detected CO2 concentration in parts per million (ppm)
|
||||||
|
|
||||||
|
setInterval(function()
|
||||||
|
{
|
||||||
|
console.log("CO2 concentration in PPM: " + sensor.ppm());
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
// exit on ^C
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
sensor = null;
|
||||||
|
sensorObj.cleanUp();
|
||||||
|
sensorObj = null;
|
||||||
|
console.log("Exiting.");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
76
examples/javascript/mpu9250.js
Normal file
76
examples/javascript/mpu9250.js
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var sensorObj = require('jsupm_mpu9150');
|
||||||
|
|
||||||
|
// Instantiate an MPU9105 on default I2C bus and address
|
||||||
|
var sensor = new sensorObj.MPU9250();
|
||||||
|
|
||||||
|
// Initialize the device with default values
|
||||||
|
sensor.init();
|
||||||
|
|
||||||
|
var x = new sensorObj.new_floatp();
|
||||||
|
var y = new sensorObj.new_floatp();
|
||||||
|
var z = new sensorObj.new_floatp();
|
||||||
|
|
||||||
|
// Output data every half second until interrupted
|
||||||
|
setInterval(function()
|
||||||
|
{
|
||||||
|
sensor.update();
|
||||||
|
|
||||||
|
sensor.getAccelerometer(x, y, z);
|
||||||
|
console.log("Accelerometer: AX: " + sensorObj.floatp_value(x) +
|
||||||
|
" AY: " + sensorObj.floatp_value(y) +
|
||||||
|
" AZ: " + sensorObj.floatp_value(z));
|
||||||
|
|
||||||
|
sensor.getGyroscope(x, y, z);
|
||||||
|
console.log("Gyroscope: GX: " + sensorObj.floatp_value(x) +
|
||||||
|
" AY: " + sensorObj.floatp_value(y) +
|
||||||
|
" AZ: " + sensorObj.floatp_value(z));
|
||||||
|
|
||||||
|
sensor.getMagnetometer(x, y, z);
|
||||||
|
console.log("Magnetometer: MX: " + sensorObj.floatp_value(x) +
|
||||||
|
" MY: " + sensorObj.floatp_value(y) +
|
||||||
|
" MZ: " + sensorObj.floatp_value(z));
|
||||||
|
|
||||||
|
console.log("Temperature: " + sensor.getTemperature());
|
||||||
|
|
||||||
|
console.log();
|
||||||
|
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
// exit on ^C
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
sensor = null;
|
||||||
|
sensorObj.cleanUp();
|
||||||
|
sensorObj = null;
|
||||||
|
console.log("Exiting.");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
60
examples/javascript/mq4.js
Normal file
60
examples/javascript/mq4.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var upmGAS = require("jsupm_gas");
|
||||||
|
|
||||||
|
// Attach gas sensor to Analog A0
|
||||||
|
var sensor = new upmGAS.MQ4(0);
|
||||||
|
|
||||||
|
var threshContext = new upmGAS.thresholdContext;
|
||||||
|
threshContext.averageReading = 0;
|
||||||
|
threshContext.runningAverage = 0;
|
||||||
|
threshContext.averagedOver = 2;
|
||||||
|
|
||||||
|
// Infinite loop, ends when script is cancelled
|
||||||
|
// Repeatedly, take a sample every 2 microseconds;
|
||||||
|
// find the average of 128 samples; and
|
||||||
|
// print a running graph of asteriskss as averages
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
var buffer = new upmGAS.uint16Array(128);
|
||||||
|
var len = sensor.getSampledWindow(2, 128, buffer);
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
var thresh = sensor.findThreshold(threshContext, 30, buffer, len);
|
||||||
|
sensor.printGraph(threshContext, 5);
|
||||||
|
//if (thresh)
|
||||||
|
// console.log("Threshold is " + thresh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print message when exiting
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
console.log("Exiting...");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
60
examples/javascript/mq6.js
Normal file
60
examples/javascript/mq6.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var upmGAS = require("jsupm_gas");
|
||||||
|
|
||||||
|
// Attach gas sensor to Analog A0
|
||||||
|
var sensor = new upmGAS.MQ6(0);
|
||||||
|
|
||||||
|
var threshContext = new upmGAS.thresholdContext;
|
||||||
|
threshContext.averageReading = 0;
|
||||||
|
threshContext.runningAverage = 0;
|
||||||
|
threshContext.averagedOver = 2;
|
||||||
|
|
||||||
|
// Infinite loop, ends when script is cancelled
|
||||||
|
// Repeatedly, take a sample every 2 microseconds;
|
||||||
|
// find the average of 128 samples; and
|
||||||
|
// print a running graph of asteriskss as averages
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
var buffer = new upmGAS.uint16Array(128);
|
||||||
|
var len = sensor.getSampledWindow(2, 128, buffer);
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
var thresh = sensor.findThreshold(threshContext, 30, buffer, len);
|
||||||
|
sensor.printGraph(threshContext, 5);
|
||||||
|
//if (thresh)
|
||||||
|
// console.log("Threshold is " + thresh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print message when exiting
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
console.log("Exiting...");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
60
examples/javascript/mq7.js
Normal file
60
examples/javascript/mq7.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var upmGAS = require("jsupm_gas");
|
||||||
|
|
||||||
|
// Attach gas sensor to Analog A0
|
||||||
|
var sensor = new upmGAS.MQ7(0);
|
||||||
|
|
||||||
|
var threshContext = new upmGAS.thresholdContext;
|
||||||
|
threshContext.averageReading = 0;
|
||||||
|
threshContext.runningAverage = 0;
|
||||||
|
threshContext.averagedOver = 2;
|
||||||
|
|
||||||
|
// Infinite loop, ends when script is cancelled
|
||||||
|
// Repeatedly, take a sample every 2 microseconds;
|
||||||
|
// find the average of 128 samples; and
|
||||||
|
// print a running graph of asteriskss as averages
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
var buffer = new upmGAS.uint16Array(128);
|
||||||
|
var len = sensor.getSampledWindow(2, 128, buffer);
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
var thresh = sensor.findThreshold(threshContext, 30, buffer, len);
|
||||||
|
sensor.printGraph(threshContext, 5);
|
||||||
|
//if (thresh)
|
||||||
|
// console.log("Threshold is " + thresh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print message when exiting
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
console.log("Exiting...");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
60
examples/javascript/mq8.js
Normal file
60
examples/javascript/mq8.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var upmGAS = require("jsupm_gas");
|
||||||
|
|
||||||
|
// Attach gas sensor to Analog A0
|
||||||
|
var sensor = new upmGAS.MQ8(0);
|
||||||
|
|
||||||
|
var threshContext = new upmGAS.thresholdContext;
|
||||||
|
threshContext.averageReading = 0;
|
||||||
|
threshContext.runningAverage = 0;
|
||||||
|
threshContext.averagedOver = 2;
|
||||||
|
|
||||||
|
// Infinite loop, ends when script is cancelled
|
||||||
|
// Repeatedly, take a sample every 2 microseconds;
|
||||||
|
// find the average of 128 samples; and
|
||||||
|
// print a running graph of asteriskss as averages
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
var buffer = new upmGAS.uint16Array(128);
|
||||||
|
var len = sensor.getSampledWindow(2, 128, buffer);
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
var thresh = sensor.findThreshold(threshContext, 30, buffer, len);
|
||||||
|
sensor.printGraph(threshContext, 5);
|
||||||
|
//if (thresh)
|
||||||
|
// console.log("Threshold is " + thresh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print message when exiting
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
console.log("Exiting...");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
151
examples/javascript/oled_ssd1306.js
Normal file
151
examples/javascript/oled_ssd1306.js
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var intel_logo = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 192, 192, 192, 224,
|
||||||
|
224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, 60,
|
||||||
|
62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||||
|
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31,
|
||||||
|
30, 62, 62, 62, 62, 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240,
|
||||||
|
224, 224, 224, 192, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, 1, 1, 1, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195,
|
||||||
|
195, 7, 15, 15, 63, 127, 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 128, 192, 192, 240, 248, 124, 124, 60, 0, 0, 0, 0, 159, 159,
|
||||||
|
159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0,
|
||||||
|
0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128,
|
||||||
|
128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128,
|
||||||
|
128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
0, 0, 0, 0, 3, 7, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 0, 0, 224, 248, 252, 252, 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15,
|
||||||
|
15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143,
|
||||||
|
135, 135, 143, 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,
|
||||||
|
224, 248, 248, 255, 255, 255, 255, 255, 127, 15, 255, 255, 255, 255, 255,
|
||||||
|
255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255,
|
||||||
|
255, 255, 255, 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231,
|
||||||
|
231, 231, 199, 135, 0, 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0,
|
||||||
|
0, 0, 224, 240, 248, 248, 252, 254, 255, 255, 255, 127, 63, 63, 31, 15, 7,
|
||||||
|
7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, 240, 192, 192, 128, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7,
|
||||||
|
7, 7, 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7,
|
||||||
|
7, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15,
|
||||||
|
31, 127, 127, 127, 255, 255, 252, 252, 252, 248, 240, 240, 240, 224, 224,
|
||||||
|
224, 192, 192, 192, 192, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192,
|
||||||
|
224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, 252,
|
||||||
|
254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
3, 3, 3, 7, 7, 7, 15, 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127,
|
||||||
|
127, 127, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||||
|
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 127, 127, 127, 127,
|
||||||
|
63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, 3, 3,
|
||||||
|
3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0];
|
||||||
|
|
||||||
|
function exit()
|
||||||
|
{
|
||||||
|
lcd = null;
|
||||||
|
lcdObj.cleanUp();
|
||||||
|
lcdObj = null;
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load i2clcd module
|
||||||
|
var lcdObj = require('jsupm_i2clcd');
|
||||||
|
var lcd = new lcdObj.SSD1306(6, 0x3c);
|
||||||
|
var next = 0;
|
||||||
|
|
||||||
|
lcd.clear();
|
||||||
|
lcd.setCursor(2, 0);
|
||||||
|
lcd.write("Hello");
|
||||||
|
lcd.setCursor(3, 0);
|
||||||
|
lcd.write("World!");
|
||||||
|
|
||||||
|
setInterval(function(){
|
||||||
|
loop();
|
||||||
|
},
|
||||||
|
3000 );
|
||||||
|
|
||||||
|
function loop(){
|
||||||
|
switch(next)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
lcd.invert(true)
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
lcd.dim(true);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
lcd.invert(false);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
lcd.startscrollright(0x00, 0x0F);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
lcd.startscrollleft(0x00, 0x0F);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
lcd.startscrolldiagleft(0x00, 0x0F)
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
lcd.startscrolldiagright(0x00, 0x0F)
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
var logo = new lcdObj.uint8Array(intel_logo.length);
|
||||||
|
for(var x = 0 ; x < intel_logo.length ; x++){
|
||||||
|
logo.setitem(x, intel_logo[x]);
|
||||||
|
}
|
||||||
|
lcd.stopscroll();
|
||||||
|
lcd.clear();
|
||||||
|
lcd.draw(logo, 1024);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
default:
|
||||||
|
lcd.stopscroll();
|
||||||
|
lcd.clear();
|
||||||
|
lcd.setCursor(2, 0);
|
||||||
|
lcd.write("All");
|
||||||
|
lcd.setCursor(3, 0);
|
||||||
|
lcd.write("Done!");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
next++;
|
||||||
|
}
|
70
examples/javascript/sm130.js
Normal file
70
examples/javascript/sm130.js
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var sensorObj = require('jsupm_sm130');
|
||||||
|
|
||||||
|
// Instantiate a UART based SM130 RFID Module using defaults
|
||||||
|
var sensor = new sensorObj.SM130();
|
||||||
|
|
||||||
|
// Set the baud rate, 19200 baud is the default.
|
||||||
|
if (sensor.setBaudRate(19200))
|
||||||
|
{
|
||||||
|
console.log("Failed to set baud rate");
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Resetting...");
|
||||||
|
sensor.reset();
|
||||||
|
|
||||||
|
console.log("Firmware revision: " + sensor.getFirmwareVersion());
|
||||||
|
|
||||||
|
console.log("Waiting up to 5 seconds for a tag...");
|
||||||
|
|
||||||
|
if (sensor.waitForTag(5000))
|
||||||
|
{
|
||||||
|
console.log("Found tag, UID: " +
|
||||||
|
sensor.string2HexString(sensor.getUID()));
|
||||||
|
console.log("Tag Type: " +
|
||||||
|
sensor.tag2String(sensor.getTagType()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// error
|
||||||
|
console.log("waitForTag failed: " +
|
||||||
|
sensor.getLastErrorString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/************** Exit code **************/
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
sensor = null;
|
||||||
|
sensorObj.cleanUp();
|
||||||
|
sensorObj = null;
|
||||||
|
console.log("Exiting...");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
54
examples/javascript/wheelencoder.js
Normal file
54
examples/javascript/wheelencoder.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||||
|
/*jshint unused:true */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
* Copyright (c) 2015 Intel Corporation.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var sensorObj = require('jsupm_wheelencoder');
|
||||||
|
|
||||||
|
// Instantiate a DFRobot Wheel Encoder on digital pin D2
|
||||||
|
var sensor = new sensorObj.WheelEncoder(2);
|
||||||
|
|
||||||
|
// set the counter to 0 and start counting
|
||||||
|
sensor.clearCounter();
|
||||||
|
sensor.startCounter();
|
||||||
|
|
||||||
|
setInterval(function()
|
||||||
|
{
|
||||||
|
// output milliseconds passed and current sensor count
|
||||||
|
console.log("Millis: " + sensor.getMillis() + " Count: " +
|
||||||
|
sensor.counter());
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
// exit on ^C
|
||||||
|
process.on('SIGINT', function()
|
||||||
|
{
|
||||||
|
sensor = null;
|
||||||
|
sensorObj.cleanUp();
|
||||||
|
sensorObj = null;
|
||||||
|
console.log("Exiting.");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
86
examples/python/grovegprs.py
Normal file
86
examples/python/grovegprs.py
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import time, sys, signal, atexit
|
||||||
|
import pyupm_grovegprs as sensorObj
|
||||||
|
|
||||||
|
# Instantiate a GroveGPRS Module on UART 0
|
||||||
|
sensor = sensorObj.GroveGPRS(0)
|
||||||
|
|
||||||
|
## Exit handlers ##
|
||||||
|
# This stops python from printing a stacktrace when you hit control-C
|
||||||
|
def SIGINTHandler(signum, frame):
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
# This function lets you run code on exit
|
||||||
|
def exitHandler():
|
||||||
|
print "Exiting"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Register exit handlers
|
||||||
|
atexit.register(exitHandler)
|
||||||
|
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||||
|
|
||||||
|
# Set the baud rate, 19200 baud is the default.
|
||||||
|
if (sensor.setBaudRate(19200)):
|
||||||
|
print "Failed to set baud rate"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
usageStr = ("Usage:\n"
|
||||||
|
"If an argument is supplied on the command line, that argument is\n"
|
||||||
|
"sent to the module and the response is printed out.\n\n"
|
||||||
|
"If no argument is used, then the manufacturer and the current\n"
|
||||||
|
"saved profiles are queried and the results printed out.\n\n")
|
||||||
|
print usageStr
|
||||||
|
|
||||||
|
# simple helper function to send a command and wait for a response
|
||||||
|
def sendCommand(sensor, cmd):
|
||||||
|
# commands need to be terminated with a carriage return
|
||||||
|
cmd += "\r";
|
||||||
|
sensor.writeDataStr(cmd)
|
||||||
|
|
||||||
|
# wait up to 1 second
|
||||||
|
if (sensor.dataAvailable(1000)):
|
||||||
|
print "Returned: ",
|
||||||
|
print sensor.readDataStr(1024)
|
||||||
|
else:
|
||||||
|
print "Timed out waiting for response"
|
||||||
|
|
||||||
|
|
||||||
|
if (len(sys.argv) > 1):
|
||||||
|
print "Sending command line argument (" + sys.argv[1] + ")..."
|
||||||
|
sendCommand(sensor, sys.argv[1])
|
||||||
|
else:
|
||||||
|
# query the module manufacturer
|
||||||
|
print "Querying module manufacturer (AT+CGMI)..."
|
||||||
|
sendCommand(sensor, "AT+CGMI");
|
||||||
|
|
||||||
|
time.sleep(1);
|
||||||
|
|
||||||
|
# query the saved profiles
|
||||||
|
print "Querying the saved profiles (AT&V)..."
|
||||||
|
sendCommand(sensor, "AT&V");
|
||||||
|
|
||||||
|
# A comprehensive list is available from the datasheet at:
|
||||||
|
# http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
|
52
examples/python/grovemd-stepper.py
Normal file
52
examples/python/grovemd-stepper.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import time
|
||||||
|
import pyupm_grovemd as upmGrovemd
|
||||||
|
|
||||||
|
I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
|
||||||
|
I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR
|
||||||
|
|
||||||
|
# Instantiate an I2C Grove Motor Driver on I2C bus 0
|
||||||
|
myMotorDriver = upmGrovemd.GroveMD(I2C_BUS, I2C_ADDR)
|
||||||
|
|
||||||
|
# This example demonstrates using the GroveMD to drive a stepper motor
|
||||||
|
|
||||||
|
# configure it, for this example, we'll assume 200 steps per rev
|
||||||
|
myMotorDriver.configStepper(200)
|
||||||
|
|
||||||
|
# set for half a rotation
|
||||||
|
myMotorDriver.setStepperSteps(100)
|
||||||
|
|
||||||
|
# let it go - clockwise rotation, 10 RPM speed
|
||||||
|
myMotorDriver.enableStepper(upmGrovemd.GroveMD.STEP_DIR_CW, 10)
|
||||||
|
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
# Now do it backwards...
|
||||||
|
myMotorDriver.setStepperSteps(100)
|
||||||
|
myMotorDriver.enableStepper(upmGrovemd.GroveMD.STEP_DIR_CCW, 10)
|
||||||
|
|
||||||
|
# now disable
|
||||||
|
myMotorDriver.disableStepper()
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# Author: Zion Orent <zorent@ics.com>
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
# Copyright (c) 2015 Intel Corporation.
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -22,18 +22,18 @@
|
|||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
import time, sys, signal, atexit
|
import time, sys, signal, atexit
|
||||||
import pyupm_groveloudness as upmGroveloudness
|
import pyupm_lm35 as sensorObj
|
||||||
|
|
||||||
# Instantiate a Grove Loudness sensor on analog pin A0
|
|
||||||
myLoudness = upmGroveloudness.GroveLoudness(0)
|
|
||||||
|
|
||||||
|
# Instantiate a LM35 on analog pin A0, with a default analog
|
||||||
|
# reference voltage of 5.0
|
||||||
|
sensor = sensorObj.LM35(0)
|
||||||
|
|
||||||
## Exit handlers ##
|
## Exit handlers ##
|
||||||
# This stops python from printing a stacktrace when you hit control-C
|
# This function stops python from printing a stacktrace when you hit control-C
|
||||||
def SIGINTHandler(signum, frame):
|
def SIGINTHandler(signum, frame):
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# This lets you run code on exit, including functions from myLoudness
|
# This function lets you run code on exit
|
||||||
def exitHandler():
|
def exitHandler():
|
||||||
print "Exiting"
|
print "Exiting"
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -42,7 +42,8 @@ def exitHandler():
|
|||||||
atexit.register(exitHandler)
|
atexit.register(exitHandler)
|
||||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||||
|
|
||||||
|
# Every half second, sample the sensor and output the temperature
|
||||||
|
|
||||||
while (1):
|
while (1):
|
||||||
print "Loudness value (higher is louder):", myLoudness.value()
|
print "Temperature:", sensor.getTemperature(), "C"
|
||||||
time.sleep(.1)
|
time.sleep(.5)
|
50
examples/python/loudness.py
Normal file
50
examples/python/loudness.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import time, sys, signal, atexit
|
||||||
|
import pyupm_loudness as sensorObj
|
||||||
|
|
||||||
|
# Instantiate a Loudness sensor on analog pin A0, with an analog
|
||||||
|
# reference voltage of 5.0
|
||||||
|
sensor = sensorObj.Loudness(0, 5.0)
|
||||||
|
|
||||||
|
## Exit handlers ##
|
||||||
|
# This function stops python from printing a stacktrace when you hit control-C
|
||||||
|
def SIGINTHandler(signum, frame):
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
# This function lets you run code on exit
|
||||||
|
def exitHandler():
|
||||||
|
print "Exiting"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Register exit handlers
|
||||||
|
atexit.register(exitHandler)
|
||||||
|
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||||
|
|
||||||
|
# Every tenth of a second, sample the loudness and output it's
|
||||||
|
# corresponding analog voltage.
|
||||||
|
|
||||||
|
while (1):
|
||||||
|
print "Detected loudness (volts): ", sensor.loudness()
|
||||||
|
time.sleep(.1)
|
51
examples/python/mg811.py
Normal file
51
examples/python/mg811.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import time, sys, signal, atexit
|
||||||
|
import pyupm_mg811 as sensorObj
|
||||||
|
|
||||||
|
# Instantiate an MG811 on analog pin A0, and digital pin D2 with an
|
||||||
|
# analog reference voltage of MG811_AREF (5.0)
|
||||||
|
|
||||||
|
sensor = sensorObj.MG811(0, 2, 5.0)
|
||||||
|
|
||||||
|
## Exit handlers ##
|
||||||
|
# This function stops python from printing a stacktrace when you hit control-C
|
||||||
|
def SIGINTHandler(signum, frame):
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
# This function lets you run code on exit
|
||||||
|
def exitHandler():
|
||||||
|
print "Exiting"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Register exit handlers
|
||||||
|
atexit.register(exitHandler)
|
||||||
|
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||||
|
|
||||||
|
# Every tenth of a second, sample the sensor and output it's
|
||||||
|
# detected CO2 concentration in parts per million (ppm)
|
||||||
|
|
||||||
|
while (1):
|
||||||
|
print "CO2 concentration in PPM: ", sensor.ppm()
|
||||||
|
time.sleep(.1)
|
70
examples/python/mpu9250.py
Normal file
70
examples/python/mpu9250.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import time, sys, signal, atexit
|
||||||
|
import pyupm_mpu9150 as sensorObj
|
||||||
|
|
||||||
|
# Instantiate an MPU9250 on I2C bus 0
|
||||||
|
sensor = sensorObj.MPU9250()
|
||||||
|
|
||||||
|
## Exit handlers ##
|
||||||
|
# This function stops python from printing a stacktrace when you hit control-C
|
||||||
|
def SIGINTHandler(signum, frame):
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
# This function lets you run code on exit
|
||||||
|
def exitHandler():
|
||||||
|
print "Exiting"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Register exit handlers
|
||||||
|
atexit.register(exitHandler)
|
||||||
|
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||||
|
|
||||||
|
sensor.init()
|
||||||
|
|
||||||
|
x = sensorObj.new_floatp()
|
||||||
|
y = sensorObj.new_floatp()
|
||||||
|
z = sensorObj.new_floatp()
|
||||||
|
|
||||||
|
while (1):
|
||||||
|
sensor.update()
|
||||||
|
sensor.getAccelerometer(x, y, z)
|
||||||
|
print "Accelerometer: AX: ", sensorObj.floatp_value(x),
|
||||||
|
print " AY: ", sensorObj.floatp_value(y),
|
||||||
|
print " AZ: ", sensorObj.floatp_value(z)
|
||||||
|
|
||||||
|
sensor.getGyroscope(x, y, z)
|
||||||
|
print "Gyroscope: GX: ", sensorObj.floatp_value(x),
|
||||||
|
print " GY: ", sensorObj.floatp_value(y),
|
||||||
|
print " GZ: ", sensorObj.floatp_value(z)
|
||||||
|
|
||||||
|
sensor.getMagnetometer(x, y, z)
|
||||||
|
print "Magnetometer: MX: ", sensorObj.floatp_value(x),
|
||||||
|
print " MY: ", sensorObj.floatp_value(y),
|
||||||
|
print " MZ: ", sensorObj.floatp_value(z)
|
||||||
|
|
||||||
|
print "Temperature: ", sensor.getTemperature()
|
||||||
|
print
|
||||||
|
|
||||||
|
time.sleep(.5)
|
62
examples/python/mq4.py
Normal file
62
examples/python/mq4.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import time, sys, signal, atexit
|
||||||
|
import pyupm_gas as upmGAS
|
||||||
|
|
||||||
|
# Attach gas sensor to Analog A0
|
||||||
|
sensor = upmGAS.MQ4(0)
|
||||||
|
|
||||||
|
|
||||||
|
## Exit handlers ##
|
||||||
|
# This function stops python from printing a stacktrace when you hit control-C
|
||||||
|
def SIGINTHandler(signum, frame):
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
# This function lets you run code on exit, including functions from sensor
|
||||||
|
def exitHandler():
|
||||||
|
print "Exiting"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Register exit handlers
|
||||||
|
atexit.register(exitHandler)
|
||||||
|
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||||
|
|
||||||
|
|
||||||
|
threshContext = upmGAS.thresholdContext()
|
||||||
|
threshContext.averageReading = 0
|
||||||
|
threshContext.runningAverage = 0
|
||||||
|
threshContext.averagedOver = 2
|
||||||
|
|
||||||
|
# Infinite loop, ends when script is cancelled
|
||||||
|
# Repeatedly, take a sample every 2 microseconds;
|
||||||
|
# find the average of 128 samples; and
|
||||||
|
# print a running graph of asteriskss as averages
|
||||||
|
mybuffer = upmGAS.uint16Array(128)
|
||||||
|
while(1):
|
||||||
|
samplelen = sensor.getSampledWindow(2, 128, mybuffer)
|
||||||
|
if samplelen:
|
||||||
|
thresh = sensor.findThreshold(threshContext, 30, mybuffer, samplelen)
|
||||||
|
sensor.printGraph(threshContext, 5)
|
||||||
|
# if(thresh):
|
||||||
|
# print "Threshold is ", thresh
|
62
examples/python/mq6.py
Normal file
62
examples/python/mq6.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import time, sys, signal, atexit
|
||||||
|
import pyupm_gas as upmGAS
|
||||||
|
|
||||||
|
# Attach gas sensor to Analog A0
|
||||||
|
sensor = upmGAS.MQ6(0)
|
||||||
|
|
||||||
|
|
||||||
|
## Exit handlers ##
|
||||||
|
# This function stops python from printing a stacktrace when you hit control-C
|
||||||
|
def SIGINTHandler(signum, frame):
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
# This function lets you run code on exit, including functions from sensor
|
||||||
|
def exitHandler():
|
||||||
|
print "Exiting"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Register exit handlers
|
||||||
|
atexit.register(exitHandler)
|
||||||
|
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||||
|
|
||||||
|
|
||||||
|
threshContext = upmGAS.thresholdContext()
|
||||||
|
threshContext.averageReading = 0
|
||||||
|
threshContext.runningAverage = 0
|
||||||
|
threshContext.averagedOver = 2
|
||||||
|
|
||||||
|
# Infinite loop, ends when script is cancelled
|
||||||
|
# Repeatedly, take a sample every 2 microseconds;
|
||||||
|
# find the average of 128 samples; and
|
||||||
|
# print a running graph of asteriskss as averages
|
||||||
|
mybuffer = upmGAS.uint16Array(128)
|
||||||
|
while(1):
|
||||||
|
samplelen = sensor.getSampledWindow(2, 128, mybuffer)
|
||||||
|
if samplelen:
|
||||||
|
thresh = sensor.findThreshold(threshContext, 30, mybuffer, samplelen)
|
||||||
|
sensor.printGraph(threshContext, 5)
|
||||||
|
# if(thresh):
|
||||||
|
# print "Threshold is ", thresh
|
62
examples/python/mq7.py
Normal file
62
examples/python/mq7.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import time, sys, signal, atexit
|
||||||
|
import pyupm_gas as upmGAS
|
||||||
|
|
||||||
|
# Attach gas sensor to Analog A0
|
||||||
|
sensor = upmGAS.MQ7(0)
|
||||||
|
|
||||||
|
|
||||||
|
## Exit handlers ##
|
||||||
|
# This function stops python from printing a stacktrace when you hit control-C
|
||||||
|
def SIGINTHandler(signum, frame):
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
# This function lets you run code on exit, including functions from sensor
|
||||||
|
def exitHandler():
|
||||||
|
print "Exiting"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Register exit handlers
|
||||||
|
atexit.register(exitHandler)
|
||||||
|
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||||
|
|
||||||
|
|
||||||
|
threshContext = upmGAS.thresholdContext()
|
||||||
|
threshContext.averageReading = 0
|
||||||
|
threshContext.runningAverage = 0
|
||||||
|
threshContext.averagedOver = 2
|
||||||
|
|
||||||
|
# Infinite loop, ends when script is cancelled
|
||||||
|
# Repeatedly, take a sample every 2 microseconds;
|
||||||
|
# find the average of 128 samples; and
|
||||||
|
# print a running graph of asteriskss as averages
|
||||||
|
mybuffer = upmGAS.uint16Array(128)
|
||||||
|
while(1):
|
||||||
|
samplelen = sensor.getSampledWindow(2, 128, mybuffer)
|
||||||
|
if samplelen:
|
||||||
|
thresh = sensor.findThreshold(threshContext, 30, mybuffer, samplelen)
|
||||||
|
sensor.printGraph(threshContext, 5)
|
||||||
|
# if(thresh):
|
||||||
|
# print "Threshold is ", thresh
|
62
examples/python/mq8.py
Normal file
62
examples/python/mq8.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Author: Jon Trulson <jtrulson@ics.com>
|
||||||
|
# Copyright (c) 2015 Intel Corporation.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import time, sys, signal, atexit
|
||||||
|
import pyupm_gas as upmGAS
|
||||||
|
|
||||||
|
# Attach gas sensor to Analog A0
|
||||||
|
sensor = upmGAS.MQ8(0)
|
||||||
|
|
||||||
|
|
||||||
|
## Exit handlers ##
|
||||||
|
# This function stops python from printing a stacktrace when you hit control-C
|
||||||
|
def SIGINTHandler(signum, frame):
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
# This function lets you run code on exit, including functions from sensor
|
||||||
|
def exitHandler():
|
||||||
|
print "Exiting"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Register exit handlers
|
||||||
|
atexit.register(exitHandler)
|
||||||
|
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||||
|
|
||||||
|
|
||||||
|
threshContext = upmGAS.thresholdContext()
|
||||||
|
threshContext.averageReading = 0
|
||||||
|
threshContext.runningAverage = 0
|
||||||
|
threshContext.averagedOver = 2
|
||||||
|
|
||||||
|
# Infinite loop, ends when script is cancelled
|
||||||
|
# Repeatedly, take a sample every 2 microseconds;
|
||||||
|
# find the average of 128 samples; and
|
||||||
|
# print a running graph of asteriskss as averages
|
||||||
|
mybuffer = upmGAS.uint16Array(128)
|
||||||
|
while(1):
|
||||||
|
samplelen = sensor.getSampledWindow(2, 128, mybuffer)
|
||||||
|
if samplelen:
|
||||||
|
thresh = sensor.findThreshold(threshContext, 30, mybuffer, samplelen)
|
||||||
|
sensor.printGraph(threshContext, 5)
|
||||||
|
# if(thresh):
|
||||||
|
# print "Threshold is ", thresh
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user