mirror of
https://github.com/eclipse/upm.git
synced 2025-07-06 20:01:12 +03:00
Compare commits
126 Commits
Author | SHA1 | Date | |
---|---|---|---|
16e72d2ff7 | |||
94be00a63d | |||
d5cb613ad0 | |||
c0c37028e4 | |||
eb8d64f52b | |||
1ddf969020 | |||
85608a9f61 | |||
4927311a0c | |||
b50b93272d | |||
ed4fe56ef8 | |||
67b77b78aa | |||
bc01f710ea | |||
1af38e060e | |||
62f84dcc47 | |||
6ae7e9125b | |||
07a9af07fe | |||
89e2ec870a | |||
4935a16530 | |||
9ef90ccb81 | |||
5f2557b159 | |||
09208e90d0 | |||
e0105cb601 | |||
c2ce3e8222 | |||
db3c73cbd1 | |||
be46240b8c | |||
ef81a20140 | |||
8a617aa904 | |||
a16d279b6f | |||
3e84b74bdf | |||
186bbfab76 | |||
01cc3a0734 | |||
09e536b4ff | |||
dc45cd7859 | |||
3790c0bbc1 | |||
7a2332fa7d | |||
330c94f1e2 | |||
9a959b578c | |||
cdfb68c381 | |||
6228498147 | |||
8b4e1020f4 | |||
3a077df5f6 | |||
1b5087105b | |||
ec9143e976 | |||
37642f3b01 | |||
17110d41d0 | |||
dd73c4aa45 | |||
8f63914d76 | |||
306872619a | |||
ad15b27cb1 | |||
b55501e327 | |||
e99f1d73fd | |||
fc56e56048 | |||
757683b2ca | |||
b09944f4b8 | |||
f45429e1f0 | |||
54c6d294af | |||
83f541a5db | |||
090ce2040e | |||
76dd42a47d | |||
63c3b4bc69 | |||
7254d5f75e | |||
f907ebcf2e | |||
334f7365f0 | |||
41e80d611e | |||
92b0919f56 | |||
c54d6de054 | |||
86e8471cad | |||
2c17998ac9 | |||
a43bcfe8d2 | |||
1be36ec1df | |||
e4dd6457bb | |||
ad36f83857 | |||
2a17fe094e | |||
8f99289a48 | |||
829da899fc | |||
20aa4962f0 | |||
3d674efb51 | |||
cc7fec9ae0 | |||
4a1eb99d6d | |||
a12baf379f | |||
38817b72dc | |||
fe7bd75c91 | |||
460fdc2eb5 | |||
9d51454290 | |||
6f72c52a44 | |||
7d83e8c569 | |||
96bcfc9128 | |||
6be656d5b0 | |||
3cfea676e2 | |||
f64060b9d2 | |||
36ebd15abc | |||
23a57b8c90 | |||
666452e873 | |||
d49ab2ac95 | |||
d06e632f3b | |||
e192a125f3 | |||
63b2b33df7 | |||
2551596309 | |||
6725559669 | |||
680649ba6f | |||
74b5ec00dc | |||
abefdfc756 | |||
f97a62b055 | |||
7422ec937c | |||
a842898bd5 | |||
76949d9358 | |||
b244fe45d1 | |||
b367a63010 | |||
a5680d9b9a | |||
a6111a83b5 | |||
450f071f7d | |||
82c8acf0fe | |||
a65cd2e59b | |||
c154ec6cb8 | |||
d9d48e939f | |||
b1a49f0d3c | |||
ac89a4a130 | |||
f848deb35b | |||
71b2b9b1fc | |||
18b8ca2633 | |||
a96c607fb5 | |||
bc4f124d54 | |||
35e4fc012e | |||
4037ec517c | |||
40084ea651 | |||
91876d48ed |
22
.travis.yml
22
.travis.yml
@ -7,16 +7,26 @@ services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- sudo rm /usr/local/bin/docker-compose
|
||||
- curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > docker-compose
|
||||
- chmod +x docker-compose
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
- sudo wget -q https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` -O /usr/local/bin/docker-compose
|
||||
|
||||
jobs:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: TARGET=ipk
|
||||
include:
|
||||
- &run-with-clang-minimal
|
||||
stage: Clang 3.8 - minimal with unit tests
|
||||
env:
|
||||
- TARGET=minimal
|
||||
- CMAKE_BUILD_TYPE=Debug
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=clang-3.8 CXX=clang++-3.8
|
||||
- docker-compose run ${TARGET}
|
||||
- <<: *run-with-clang-minimal
|
||||
env:
|
||||
- TARGET=minimal
|
||||
- CMAKE_BUILD_TYPE=Release
|
||||
- &run-with-clang
|
||||
stage: Clang 3.8
|
||||
env: TARGET=python
|
||||
@ -71,6 +81,10 @@ jobs:
|
||||
- docker-compose run ${TARGET}
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=android
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=cordova
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=examples
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=sonar-scan
|
||||
- <<: *run-additional-jobs
|
||||
|
121
CMakeLists.txt
121
CMakeLists.txt
@ -8,6 +8,7 @@ option (BUILDFTI "Build Funtion Table Interface (FTI) in C sensor libraries" OFF
|
||||
option (BUILDSWIGPYTHON "Build swig python modules" ON)
|
||||
option (BUILDSWIGNODE "Build swig node modules" ON)
|
||||
option (BUILDSWIGJAVA "Build swig java modules" OFF)
|
||||
option (BUILDCORDOVA "Build cordova bindings" OFF)
|
||||
option (BUILDEXAMPLES "Build C/C++/JAVA examples" OFF)
|
||||
option (IPK "Generate IPK using CPack" OFF)
|
||||
option (RPM "Generate RPM using CPack" OFF)
|
||||
@ -91,7 +92,11 @@ endfunction ()
|
||||
# Compiler flags common to both C and CXX
|
||||
# Enable -Wall
|
||||
# GCC-6 added -Wmisleading-indentation to -Wall, skip these for now
|
||||
set (C_CXX_WARNING_FLAGS -Wall -Wno-misleading-indentation -Wno-strict-aliasing)
|
||||
set (C_CXX_WARNING_FLAGS -Wall
|
||||
-Wno-misleading-indentation
|
||||
-Wno-strict-aliasing
|
||||
-Wno-deprecated-declarations # Temp fix for MRAA deprecated methods
|
||||
)
|
||||
|
||||
# Warnings as errors?
|
||||
if (WERROR)
|
||||
@ -104,6 +109,7 @@ endif (WERROR)
|
||||
upm_add_compile_flags(C ${C_CXX_WARNING_FLAGS}
|
||||
-Winit-self
|
||||
-Wimplicit
|
||||
-Wsign-compare
|
||||
-Wmissing-parameter-type)
|
||||
|
||||
# Set CXX compiler warning flags at top-level scope and emit a warning about
|
||||
@ -111,6 +117,7 @@ upm_add_compile_flags(C ${C_CXX_WARNING_FLAGS}
|
||||
upm_add_compile_flags(CXX ${C_CXX_WARNING_FLAGS}
|
||||
-Wnon-virtual-dtor
|
||||
-Woverloaded-virtual
|
||||
-Wsign-compare
|
||||
-Wreorder)
|
||||
|
||||
# Allow exception error handling for Android C++
|
||||
@ -123,7 +130,7 @@ find_package (PkgConfig REQUIRED)
|
||||
|
||||
# Force a libmraa search and minimum required version every time a config is generated
|
||||
unset(MRAA_FOUND CACHE)
|
||||
set(MRAA_MINIMUM 1.8.0)
|
||||
set(MRAA_MINIMUM 2.0.0)
|
||||
pkg_check_modules (MRAA REQUIRED mraa>=${MRAA_MINIMUM})
|
||||
# Also, get full path to the mraa library
|
||||
find_library(MRAA_LIBRARY NAMES mraa HINTS ${MRAA_LIBDIR})
|
||||
@ -151,11 +158,6 @@ if (BUILDSWIGNODE)
|
||||
find_package (Node REQUIRED)
|
||||
if (BUILDTESTS)
|
||||
find_package (Npm REQUIRED)
|
||||
if(NPM_EXECUTABLE)
|
||||
message(STATUS "NPM Executable found at: ${NPM_EXECUTABLE}")
|
||||
else()
|
||||
message(FATAL_ERROR "Please install NPM first, you can't run tests without it")
|
||||
endif()
|
||||
endif (BUILDTESTS)
|
||||
endif (BUILDSWIGNODE)
|
||||
|
||||
@ -168,6 +170,17 @@ if (BUILDSWIGJAVA)
|
||||
find_library(MRAAJAVA_LIBRARY NAMES mraajava HINTS ${MRAA_LIBDIR})
|
||||
endif (BUILDSWIGJAVA)
|
||||
|
||||
# Cordova binding
|
||||
if (BUILDCORDOVA)
|
||||
if (NOT BUILDSWIGJAVA)
|
||||
message(FATAL_ERROR "Cordova bindings require JAVA packages, please enable BUILDSWIGJAVA (-DBUILDSWIGJAVA=on).")
|
||||
endif()
|
||||
|
||||
find_package (Node REQUIRED)
|
||||
find_package (Npm REQUIRED)
|
||||
find_package (UpmCordovaGenerator 0.2.1 REQUIRED)
|
||||
endif (BUILDCORDOVA)
|
||||
|
||||
# Find swig if any wrapper is enabled
|
||||
if (BUILDSWIGPYTHON OR BUILDSWIGNODE OR BUILDSWIGJAVA)
|
||||
find_package (SWIG 3.0.5 REQUIRED)
|
||||
@ -216,7 +229,7 @@ include (GetGitRevisionDescription)
|
||||
git_describe (VERSION "--tags")
|
||||
# If git_describe fails, use a dirty version
|
||||
if (${VERSION} MATCHES -NOTFOUND)
|
||||
set (VERSION "v1.5.0")
|
||||
set (VERSION "v1.7.1")
|
||||
message (WARNING "Failed to retrieve UPM version with 'git describe' (using "
|
||||
"${VERSION}). Check that git is installed and this is a valid git repo.")
|
||||
endif ()
|
||||
@ -278,37 +291,36 @@ else()
|
||||
set (C_EXTENSIONS OFF)
|
||||
endif()
|
||||
|
||||
# The doc target depends on each sensor target
|
||||
# The doc target depends on the C/C++ source and all libraries
|
||||
#
|
||||
# doc
|
||||
# ├──> src
|
||||
# ├──> include
|
||||
# ├──> libupm_sensor0
|
||||
# ├──> libupm_sensor1
|
||||
# ├──> libupm_sensor2
|
||||
# ├──> ...
|
||||
# └──> libupm_sensor_n
|
||||
#
|
||||
# The pydoc target builds documentation with sphinx via inspection by loading
|
||||
# each python module. Those modules must include the CXX documentation via
|
||||
# each python2 module. Those modules must include the CXX documentation via
|
||||
# a monolithic swig file generated by doxy2swig
|
||||
#
|
||||
# pydoc
|
||||
# └──> _pyupm_sensor0_python2
|
||||
# ├──────> libupm_sensor0
|
||||
# └──────> doxy2swig
|
||||
# ├──> libupm_sensor0
|
||||
# └──> doxy2swig
|
||||
#
|
||||
# The doxy2swig target is dependent upon the doc target IF BUILDDOC=ON,
|
||||
# otherwise doxy2swig uses an empty file. Doxy2swig also depends on each
|
||||
# sensor target
|
||||
#
|
||||
# doxy2swig
|
||||
# ├──> BUILDDOC=ON───> doc
|
||||
# └──> libupm_sensor0
|
||||
# └──> BUILDDOC=ON───> doc
|
||||
#
|
||||
# The jsdoc target builds js documentation via yuidoc and only requires
|
||||
# the doc target
|
||||
#
|
||||
# jsdoc ─> doc
|
||||
#
|
||||
if (BUILDDOC)
|
||||
function (CreateDocumentationTargets)
|
||||
# Add a target to generate API documentation with Doxygen
|
||||
find_package (Doxygen 1.8 REQUIRED)
|
||||
if (DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_GREATER "1.8")
|
||||
@ -320,12 +332,17 @@ if (BUILDDOC)
|
||||
foreach(PNG_FILE ${PNG_FILES})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY)
|
||||
endforeach()
|
||||
add_custom_target (doc
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
|
||||
# Custom command to run doxygen (note depends on ALL UPM C++ targets)
|
||||
add_custom_command (
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/xml/index.xml
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${UPM_TARGETS_CXX}
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
COMMAND tar -czf html/xml.tar.gz -C xml .
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||
)
|
||||
COMMENT "Generating C/C++ API documentation with Doxygen"
|
||||
VERBATIM)
|
||||
add_custom_target(doc DEPENDS ${CMAKE_BINARY_DIR}/xml/index.xml)
|
||||
else ()
|
||||
message (SEND_ERROR "ERROR - Failed to find a compatible version of Doxygen. API doc will not be generated")
|
||||
endif (DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_GREATER "1.8")
|
||||
@ -333,24 +350,47 @@ if (BUILDDOC)
|
||||
# Check if Sphinx is installed and add target to generate API documentation
|
||||
# Currently, the per-module documentation for python is generated from the
|
||||
# python2 modules.
|
||||
# Since python2 is required for documentation, only copy from python2 paths, this
|
||||
# ensures that sphinx doesn't run across python2 and python3 binaries. When running
|
||||
# the sphinx tools, explicitly run from the python2 interpreter (tested with the sphinx
|
||||
# 1.3.6 python2 and python3 modules).
|
||||
if(BUILDSWIGPYTHON)
|
||||
# Generate python module documentation from doxygen collateral
|
||||
#
|
||||
# doxygen index.xml -> doxy2swig.py -> pyupm_doxy2swig.i
|
||||
add_custom_command (
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/src/pyupm_doxy2swig.i
|
||||
COMMAND ${PYTHON2_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/doxy2swig.py
|
||||
${CMAKE_BINARY_DIR}/xml/index.xml --quiet
|
||||
${CMAKE_BINARY_DIR}/src/pyupm_doxy2swig.i
|
||||
COMMENT "Generating pyupm_doxy2swig.i from Doxygen output for use by SWIG"
|
||||
DEPENDS doc
|
||||
VERBATIM)
|
||||
add_custom_target(pyupm_doxy2swig DEPENDS ${CMAKE_BINARY_DIR}/src/pyupm_doxy2swig.i)
|
||||
foreach (_python2_target ${UPM_TARGETS_PYTHON2})
|
||||
add_dependencies(${_python2_target} pyupm_doxy2swig)
|
||||
endforeach()
|
||||
|
||||
find_package (Sphinx 1.3 REQUIRED)
|
||||
if (SPHINX_FOUND AND SPHINX_VERSION VERSION_GREATER "1.3")
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/pydoc/conf.py @ONLY)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/index.rst ${CMAKE_CURRENT_BINARY_DIR}/pydoc/index.rst COPYONLY)
|
||||
add_custom_target (pydoc ALL
|
||||
add_custom_command (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pydoc.stamp
|
||||
COMMAND rm -r -f ${CMAKE_BINARY_DIR}/pyupm && mkdir -p ${CMAKE_BINARY_DIR}/pyupm
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -name "_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -name "pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
|
||||
COMMAND ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/pyupm
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -path "*python${MIN_VER_PYTHON2}/_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -path "*python${MIN_VER_PYTHON2}/pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
|
||||
COMMAND ${PYTHON2_EXECUTABLE} ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/pyupm
|
||||
# TODO: use a separate cmake FILE module for string replacement instead
|
||||
COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python
|
||||
COMMAND ${PYTHON2_EXECUTABLE} ${SPHINX_EXECUTABLE} -b html pydoc html/python
|
||||
COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html
|
||||
COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html
|
||||
DEPENDS doc
|
||||
COMMAND cmake -E touch ${CMAKE_CURRENT_BINARY_DIR}/pydoc.stamp
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Sphinx" VERBATIM
|
||||
)
|
||||
COMMENT "Generating Python API documentation with Sphinx"
|
||||
DEPENDS doc ${UPM_TARGETS_PYTHON2}
|
||||
VERBATIM)
|
||||
add_custom_target(pydoc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pydoc.stamp)
|
||||
else ()
|
||||
message (SEND_ERROR "ERROR - Failed to find a compatible version of Sphinx. Python API doc will not be generated")
|
||||
endif ()
|
||||
@ -360,19 +400,22 @@ if (BUILDDOC)
|
||||
if(BUILDSWIGNODE)
|
||||
find_package (Yuidoc 0.10 REQUIRED)
|
||||
if (YUIDOC_FOUND AND YUIDOC_VERSION VERSION_GREATER "0.10")
|
||||
add_custom_target (jsdoc ALL
|
||||
add_custom_command (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/jsdoc/jsdoc.stamp
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/doxy/doxygen2jsdoc/docgen.js -m upm -i xml -o jsdoc -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
|
||||
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers ${CMAKE_SOURCE_DIR}/doxy/node/generators/yuidoc/helper.js --themedir ${CMAKE_SOURCE_DIR}/doxy/node/generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/doxy/doxygen2jsdoc/tolower.js -i html/node
|
||||
DEPENDS doc
|
||||
COMMAND cmake -E touch ${CMAKE_CURRENT_BINARY_DIR}/jsdoc/jsdoc.stamp
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Yuidoc" VERBATIM
|
||||
)
|
||||
COMMENT "Generating Javascript API documentation with Yuidoc"
|
||||
DEPENDS doc
|
||||
VERBATIM)
|
||||
add_custom_target(jsdoc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/jsdoc/jsdoc.stamp)
|
||||
else ()
|
||||
message (SEND_ERROR "ERROR - Failed to find a compatible version of Yuidoc. Node.js API doc will not be generated")
|
||||
endif ()
|
||||
endif(BUILDSWIGNODE)
|
||||
endif (BUILDDOC)
|
||||
endfunction()
|
||||
|
||||
if (IPK)
|
||||
# Get target package arch from Yocto ADT sysroot if set or host OS, mapping to Ubuntu name if necessary
|
||||
@ -454,6 +497,12 @@ if (BUILDTESTS)
|
||||
add_subdirectory (tests)
|
||||
endif()
|
||||
|
||||
# Setup documentation AFTER all source targets have been added
|
||||
if (BUILDDOC)
|
||||
CreateDocumentationTargets()
|
||||
endif()
|
||||
|
||||
# Install C headers
|
||||
install(DIRECTORY include/ DESTINATION include/upm
|
||||
FILES_MATCHING PATTERN "*.h")
|
||||
COMPONENT ${CMAKE_PROJECT_NAME}-dev
|
||||
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
|
||||
|
@ -138,7 +138,7 @@ unable to compile code that was working fine before a library update, make sure
|
||||
you check the [API changes](docs/apichanges.md) section first.
|
||||
|
||||
**NOTE** - Several important API changes are currently underway for some of our
|
||||
widely used libraries including `libupm-grove` and `libupm-i2clcd`!
|
||||
widely used libraries including `libupm-grove`
|
||||
|
||||
### Changelog
|
||||
Version changelog [here](docs/changelog.md).
|
||||
|
@ -1,69 +1,66 @@
|
||||
# Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
|
||||
macro(add_include_dir dir)
|
||||
# Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
|
||||
macro(add_include_dir dir)
|
||||
if (IS_DIRECTORY ${dir} AND NOT ${dir} STREQUAL "/usr/include")
|
||||
set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir})
|
||||
set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
find_program (NODEJS_EXECUTABLE NAMES node nodejs
|
||||
HINTS
|
||||
$ENV{NODE_DIR}
|
||||
PATH_SUFFIXES bin
|
||||
DOC "Node.js interpreter"
|
||||
)
|
||||
DOC "Node.js interpreter")
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
# If compat-libuv package exists, it must be at start of include path
|
||||
find_path (UV_ROOT_DIR "uv.h" PATHS /usr/include/compat-libuv010 NO_DEFAULT_PATH)
|
||||
if (UV_ROOT_DIR)
|
||||
# set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR})
|
||||
add_include_dir(${UV_ROOT_DIR})
|
||||
# set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR})
|
||||
add_include_dir(${UV_ROOT_DIR})
|
||||
endif()
|
||||
|
||||
# Now look for node. Flag an error if not found
|
||||
find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h" "src/node.h"
|
||||
PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
|
||||
find_path (NODE_ROOT_DIR
|
||||
NAMES node.h src/node.h
|
||||
PATH_SUFFIXES node node4 node5 node6 node7 node8 nodejs
|
||||
PATHS /usr/include /usr/local/include)
|
||||
|
||||
if (NODE_ROOT_DIR)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/src)
|
||||
add_include_dir(${NODE_ROOT_DIR}/src)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/node)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/uv/include)
|
||||
add_include_dir(${NODE_ROOT_DIR})
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/uv/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/node)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/src)
|
||||
add_include_dir(${NODE_ROOT_DIR}/src)
|
||||
else()
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - node.h not found")
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - node.h not found")
|
||||
endif()
|
||||
|
||||
# Check that v8.h is in NODEJS_INCLUDE_DIRS
|
||||
find_path (V8_ROOT_DIR "v8.h" PATHS ${NODEJS_INCLUDE_DIRS})
|
||||
if (NOT V8_ROOT_DIR)
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - v8.h not found")
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - v8.h not found")
|
||||
endif()
|
||||
|
||||
# Check that uv.h is in NODEJS_INCLUDE_DIRS
|
||||
find_path (UV_ROOT_DIR "uv.h" PATHS ${NODEJS_INCLUDE_DIRS})
|
||||
if (NOT UV_ROOT_DIR)
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - uv.h not found")
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - uv.h not found")
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args (Nodejs DEFAULT_MSG
|
||||
NODEJS_EXECUTABLE
|
||||
NODEJS_INCLUDE_DIRS
|
||||
)
|
||||
|
||||
if (NODEJS_EXECUTABLE)
|
||||
execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE _VERSION
|
||||
RESULT_VARIABLE _NODE_VERSION_RESULT)
|
||||
OUTPUT_VARIABLE _VERSION
|
||||
RESULT_VARIABLE _NODE_VERSION_RESULT)
|
||||
execute_process(COMMAND ${NODEJS_EXECUTABLE} -e "console.log(process.versions.v8)"
|
||||
OUTPUT_VARIABLE _V8_VERSION
|
||||
RESULT_VARIABLE _V8_RESULT)
|
||||
OUTPUT_VARIABLE _V8_VERSION
|
||||
RESULT_VARIABLE _V8_RESULT)
|
||||
if (NOT _NODE_VERSION_RESULT AND NOT _V8_RESULT)
|
||||
string (REPLACE "v" "" NODE_VERSION_STRING "${_VERSION}")
|
||||
string (REPLACE "." ";" _VERSION_LIST "${NODE_VERSION_STRING}")
|
||||
@ -88,13 +85,15 @@ if (NODEJS_EXECUTABLE)
|
||||
set (V8_VERSION_MINOR "28")
|
||||
set (V8_VERSION_PATCH "72")
|
||||
set (V8_VERSION_STRING "3.28.72")
|
||||
message ("defaulted to node 0.10.30")
|
||||
message (STATUS "defaulted to node 0.10.30")
|
||||
endif ()
|
||||
string (REGEX REPLACE "\n" "" NODE_VERSION_STRING ${NODE_VERSION_STRING})
|
||||
string (REGEX REPLACE "\n" "" V8_VERSION_STRING ${V8_VERSION_STRING})
|
||||
message (STATUS "Node version is ${NODE_VERSION_STRING}")
|
||||
message (STATUS "Node using v8 ${V8_VERSION_STRING}")
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
|
||||
find_package_handle_standard_args (Nodejs
|
||||
REQUIRED_VARS NODEJS_EXECUTABLE NODEJS_INCLUDE_DIRS
|
||||
VERSION_VAR NODE_VERSION_STRING)
|
||||
message(STATUS "Found v8: ${V8_ROOT_DIR}/v8.h (found version \"${V8_VERSION_STRING}\")")
|
||||
endif ()
|
||||
|
@ -1,13 +1,71 @@
|
||||
# Finding and pointing a variable to the npm executable if found
|
||||
# Only works on Linux systems as of now
|
||||
# FindNpm
|
||||
# --------
|
||||
#
|
||||
# Find npm
|
||||
#
|
||||
# This module finds an installed npm. It sets the following variables:
|
||||
#
|
||||
# NPM_FOUND - Set to true if npm is found
|
||||
# NPM_DIR - The directory where npm is installed
|
||||
# NPM_GLOBAL_NODE_MODULE_DIR - The global node_modules directory
|
||||
# NPM_EXECUTABLE - The path to the npm executable
|
||||
# NPM_VERSION - The version number of the npm executable
|
||||
|
||||
find_program(NPM_EXECUTABLE NAMES npm
|
||||
HINTS
|
||||
/usr
|
||||
)
|
||||
find_program(NPM_EXECUTABLE NAMES npm HINTS /usr)
|
||||
|
||||
if(NPM_EXECUTABLE)
|
||||
message(STATUS "NPM Executable found at ${NPM_EXECUTABLE}")
|
||||
# If npm was found, fill in the rest
|
||||
if (NPM_EXECUTABLE)
|
||||
# Set the global node_modules location
|
||||
execute_process(COMMAND ${NPM_EXECUTABLE} root -g
|
||||
OUTPUT_VARIABLE NPM_GLOBAL_NODE_MODULE_DIR
|
||||
ERROR_VARIABLE NPM_root_g_error
|
||||
RESULT_VARIABLE NPM_root_g_result_code)
|
||||
# Remove and newlines
|
||||
string (STRIP ${NPM_GLOBAL_NODE_MODULE_DIR} NPM_GLOBAL_NODE_MODULE_DIR)
|
||||
if(NPM_root_g_result_code)
|
||||
if(NPM_FIND_REQUIRED)
|
||||
message(SEND_ERROR "Command \"${NPM_EXECUTABLE} root -g\" failed with output:\n${NPM_root_g_error}")
|
||||
else ()
|
||||
message(STATUS "Command \"${NPM_EXECUTABLE} root -g\" failed with output:\n${NPM_root_g_error}")
|
||||
endif ()
|
||||
endif()
|
||||
unset(NPM_root_g_error)
|
||||
unset(NPM_root_g_result_code)
|
||||
|
||||
# Set the NPM dir
|
||||
if (EXISTS "${NPM_GLOBAL_NODE_MODULE_DIR}/npm")
|
||||
set(NPM_DIR "${NPM_GLOBAL_NODE_MODULE_DIR}/npm")
|
||||
endif()
|
||||
|
||||
# Set the VERSION
|
||||
execute_process(COMMAND ${NPM_EXECUTABLE} -v
|
||||
OUTPUT_VARIABLE NPM_VERSION
|
||||
ERROR_VARIABLE NPM_version_error
|
||||
RESULT_VARIABLE NPM_version_result_code)
|
||||
|
||||
if(NPM_version_result_code)
|
||||
if(NPM_FIND_REQUIRED)
|
||||
message(SEND_ERROR "Command \"${NPM_EXECUTABLE} -v\" failed with output:\n${NPM_version_error}")
|
||||
else()
|
||||
message(STATUS "Command \"${NPM_EXECUTABLE} -v\" failed with output:\n${NPM_version_error}")
|
||||
endif ()
|
||||
endif ()
|
||||
unset(NPM_version_error)
|
||||
unset(NPM_version_result_code)
|
||||
|
||||
# Remove and newlines
|
||||
string (STRIP ${NPM_VERSION} NPM_VERSION)
|
||||
|
||||
set (NPM_FOUND TRUE)
|
||||
else()
|
||||
message(ERROR "Unable to find NPM installation, please install NPM")
|
||||
endif()
|
||||
# Fail on REQUIRED
|
||||
if (Npm_FIND_REQUIRED)
|
||||
message(SEND_ERROR "Failed to find npm executable")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
find_package_handle_standard_args(NPM
|
||||
REQUIRED_VARS NPM_EXECUTABLE NPM_DIR
|
||||
VERSION_VAR NPM_VERSION )
|
||||
|
||||
mark_as_advanced(NPM_DIR NPM_GLOBAL_NODE_MODULE_DIR NPM_EXECUTABLE NPM_VERSION)
|
||||
|
20
cmake/modules/FindUpmCordovaGenerator.cmake
Normal file
20
cmake/modules/FindUpmCordovaGenerator.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
find_program (UPM_CORDOVA_BINDING NAMES upm-cordova-binding
|
||||
DOC "UPM Cordova binding generator")
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
# Get version
|
||||
if (UPM_CORDOVA_BINDING)
|
||||
execute_process(COMMAND ${NPM_EXECUTABLE} info upm-cordova-binding version
|
||||
OUTPUT_VARIABLE UPM_CORDOVA_BINDING_VERSION
|
||||
ERROR_VARIABLE UPM_CORDOVA_BINDING_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(UpmCordovaGenerator
|
||||
REQUIRED_VARS UPM_CORDOVA_BINDING
|
||||
VERSION_VAR UPM_CORDOVA_BINDING_VERSION
|
||||
FAIL_MESSAGE "Unable to find the npm package for generating UPM Cordova bindings. The generator can be installed via: 'npm install -g upm-cordova-binding'")
|
||||
|
||||
mark_as_advanced (UPM_CORDOVA_BINDING UPM_CORDOVA_BINDING_VERSION)
|
@ -3,7 +3,7 @@ version: '2.1'
|
||||
services:
|
||||
|
||||
base:
|
||||
image: dnoliver/upm-base
|
||||
image: inteliotdevkit/upm-base
|
||||
environment:
|
||||
- http_proxy
|
||||
- https_proxy
|
||||
@ -13,8 +13,10 @@ services:
|
||||
- BUILDFTI=${BUILDFTI:-ON}
|
||||
- BUILDSWIGPYTHON=${BUILDSWIGPYTHON:-OFF}
|
||||
- BUILDSWIGJAVA=${BUILDSWIGJAVA:-OFF}
|
||||
- BUILDCORDOVA=${BUILDCORDOVA:-OFF}
|
||||
- BUILDSWIGNODE=${BUILDSWIGNODE:-OFF}
|
||||
- BUILDEXAMPLES=${BUILDEXAMPLES:-ON}
|
||||
- BUILDEXAMPLES=${BUILDEXAMPLES:-OFF}
|
||||
- CMAKE_BUILD_TYPE
|
||||
- IPK=${IPK:-OFF}
|
||||
- RPM=${RPM:-OFF}
|
||||
- NPM=${NPM:-OFF}
|
||||
@ -26,9 +28,18 @@ services:
|
||||
volumes:
|
||||
- .:${UPM_SRC_DIR:-/usr/src/app}
|
||||
|
||||
doc:
|
||||
all:
|
||||
extends: base
|
||||
image: dnoliver/upm-all
|
||||
image: inteliotdevkit/upm-all
|
||||
|
||||
minimal:
|
||||
extends: base
|
||||
environment:
|
||||
- BUILDFTI=OFF
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make && ctest -R unit --output-on-failure"
|
||||
|
||||
doc:
|
||||
extends: all
|
||||
environment:
|
||||
- BUILDSWIGPYTHON=ON
|
||||
- BUILDSWIGJAVA=ON
|
||||
@ -36,35 +47,43 @@ services:
|
||||
- BUILDDOC=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && ./scripts/build-doc.sh"
|
||||
|
||||
examples:
|
||||
extends: all
|
||||
environment:
|
||||
- BUILDSWIGPYTHON=ON
|
||||
- BUILDSWIGJAVA=ON
|
||||
- BUILDSWIGNODE=ON
|
||||
- BUILDEXAMPLES=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8"
|
||||
|
||||
ipk:
|
||||
extends: base
|
||||
extends: all
|
||||
environment:
|
||||
- IPK=ON
|
||||
- BUILDDOC=OFF
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 package"
|
||||
|
||||
rpm:
|
||||
extends: doc
|
||||
extends: all
|
||||
environment:
|
||||
- RPM=ON
|
||||
- BUILDDOC=OFF
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 package"
|
||||
|
||||
npm:
|
||||
extends: doc
|
||||
extends: all
|
||||
environment:
|
||||
- NPM=ON
|
||||
- BUILDDOC=OFF
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 npmpkg"
|
||||
|
||||
sonar-scan:
|
||||
extends: base
|
||||
image: dnoliver/upm-all
|
||||
extends: all
|
||||
environment:
|
||||
- BUILDSWIGPYTHON=ON
|
||||
- BUILDSWIGNODE=ON
|
||||
- BUILDSWIGJAVA=ON
|
||||
- BUILDSWIGEXAMPLES=ON
|
||||
- BUILDEXAMPLES=ON
|
||||
- SONAR_TOKEN
|
||||
- SONAR_ORG
|
||||
- SONAR_PROJ_KEY
|
||||
@ -77,36 +96,43 @@ services:
|
||||
|
||||
python:
|
||||
extends: base
|
||||
image: dnoliver/upm-python
|
||||
image: inteliotdevkit/upm-python
|
||||
environment:
|
||||
- BUILDSWIGPYTHON=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8 && make -j8 install && ldconfig && ctest --output-on-failure"
|
||||
|
||||
java:
|
||||
extends: base
|
||||
image: dnoliver/upm-java
|
||||
image: inteliotdevkit/upm-java
|
||||
environment:
|
||||
- BUILDSWIGJAVA=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8 && make -j8 install && ldconfig && ctest --output-on-failure"
|
||||
|
||||
android:
|
||||
extends: java
|
||||
image: dnoliver/upm-android
|
||||
image: inteliotdevkit/upm-android
|
||||
environment:
|
||||
- BUILDTESTS=OFF
|
||||
command: bash -c "./scripts/build-android.sh"
|
||||
|
||||
cordova:
|
||||
extends: all
|
||||
environment:
|
||||
- BUILDSWIGJAVA=ON
|
||||
- BUILDCORDOVA=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8 && make -j8"
|
||||
|
||||
node4:
|
||||
extends: base
|
||||
image: dnoliver/upm-node4
|
||||
image: inteliotdevkit/upm-node4
|
||||
environment:
|
||||
- BUILDSWIGNODE=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8 && make -j8 install && ldconfig && ctest --output-on-failure -E examplenames_js"
|
||||
|
||||
node5:
|
||||
extends: node4
|
||||
image: dnoliver/upm-node5
|
||||
image: inteliotdevkit/upm-node5
|
||||
|
||||
node6:
|
||||
extends: node4
|
||||
image: dnoliver/upm-node6
|
||||
image: inteliotdevkit/upm-node6
|
||||
|
@ -4,6 +4,29 @@ API Changes {#apichanges}
|
||||
Here's a list of other API changes made to the library that break source/binary
|
||||
compatibility between releases:
|
||||
|
||||
# v1.7.0
|
||||
* The interface of **kx122** has been modified to return values instead
|
||||
of receiving pointers. This applies to member functions: getWhoAmI,
|
||||
getInterruptSource, getBufferStatus, getRawBufferSamples, and
|
||||
getBufferSamples.
|
||||
* The **tm1637** constructor has been updated and the fast GPIO parameter
|
||||
has been removed with the deprecation of supporting MRAA functions. The
|
||||
GPIO lines will initialize by default in fast mode when available.
|
||||
* The generic **nmea_gps** library for GPS devices has been greatly enhanced
|
||||
with new APIs to offer better control over acquisition intervals and simplify
|
||||
parsing of the returned data.
|
||||
|
||||
# v1.6.0
|
||||
|
||||
* Several C libraries had their init function pin type modified from uint8_t
|
||||
to int allowing usage with subplatforms
|
||||
* Our **led** class constructor has been overloaded with a string based
|
||||
variant that uses the new MRAA LED APIs
|
||||
* The **i2clcd** library has finally been renamed to **lcd** and is now
|
||||
mostly considered a bundle for ssd lcd display controllers only
|
||||
* The **zfm20** class constructor has been overloaded with a string variant
|
||||
that allows initialization using any UART device
|
||||
|
||||
# v1.5.0
|
||||
|
||||
* **VEML6070** This sensor class no longer needs an I2C address when
|
||||
@ -138,13 +161,13 @@ compatibility between releases:
|
||||
* **lcm1602/jhd1313m1** These drivers had been rewritten in C, with
|
||||
C++ wrappers and placed into their own libraries in the previous
|
||||
version of UPM, however, the original C++ implementation was kept in
|
||||
the lcd/i2clcd library for compatibility reasons with existing code.
|
||||
the lcd library for compatibility reasons with existing code.
|
||||
To avoid collisions with the header files, the new *lcm1602* and
|
||||
*jhd1313m1* drivers had their C++ headers renamed to use a **.hxx**
|
||||
suffix.
|
||||
|
||||
In this version of UPM, the *lcm1602* and *jhd1313m1* drivers have
|
||||
been removed from the lcd/i2clcd library. In addition, the header
|
||||
been removed from the lcd library. In addition, the header
|
||||
files for the new implementation have been renamed from their
|
||||
**.hxx** suffix to the normal **.hpp** suffix.
|
||||
|
||||
|
@ -96,32 +96,35 @@ You can also generate the include and lib directories containing all the sensor
|
||||
headers and library files respectively with *make install*. Further, you may
|
||||
choose to generate these only for a specific sensor you modified, and this can
|
||||
be achieved by building from the individual makefile of the sensor. Assuming
|
||||
you're in the build directory, to make the lcd module you would:
|
||||
you're in the build directory, to build/install the lcd module you would:
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
cd src/lcd
|
||||
make install
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Note: 'make install' under src/lcd will build all targets (and dependencies)
|
||||
for the lcd but will NOT install dependencies.
|
||||
|
||||
Often developers are only interested in building one module or even just the
|
||||
python/node module to do some quick testing using scripting. In order to do
|
||||
this you need to use the target name for the python or node module you want to
|
||||
rebuild. For example the lcd module target name is i2clcd. Therefore the python
|
||||
module target name will be prefixed by _pyupm_. Just do the following to build
|
||||
only that module. Modules not using the UPM cmake macros may have different
|
||||
naming.
|
||||
rebuild. For example, the lcd module target will have a python2 target prefixed
|
||||
by _pyupm_ (_pyupm_lcd-python2). Modules not using the UPM cmake macros may
|
||||
have different naming. To build the python2 lcd module (and all dependencies),
|
||||
use the following make target:
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
make _pyupm_i2clcd
|
||||
make _pyupm_lcd-python2
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Sometimes you want to build a small C++ example against an installed library.
|
||||
This is fairly easy if installed system-wide. Just link against the correct
|
||||
library (in this case libupm-i2clcd) and then add /usr/include/upm to the
|
||||
library (in this case libupm-lcd) and then add /usr/include/upm to the
|
||||
loader path:
|
||||
|
||||
~~~~~~~~~~~~
|
||||
g++ test.cxx -lupm-i2clcd -I/usr/include/upm
|
||||
g++ test.cxx -lupm-lcd -I/usr/include/upm
|
||||
~~~~~~~~~~~~
|
||||
|
||||
You can also use pkg-config to return the information to you, which is
|
||||
@ -129,9 +132,37 @@ considered the correct way if including UPM in a build system like cmake or
|
||||
autotools on linux.
|
||||
|
||||
~~~~~~~~~~~
|
||||
pkg-config --cflags --libs upm-i2clcd
|
||||
pkg-config --cflags --libs upm-lcd
|
||||
~~~~~~~~~~~
|
||||
|
||||
## Building for Android Things
|
||||
|
||||
Requirements:
|
||||
* [io.mraa.at](https://search.maven.org/#artifactdetails%7Cio.mraa.at%7Cmraa%7C1.8.0%7Caar)
|
||||
* [io.mraa.at.upm](https://search.maven.org/#artifactdetails%7Cio.mraa.at.upm%7Cupm_zfm20%7C1.3.0%7Caar)
|
||||
* [Android NDK](https://developer.android.com/ndk/downloads/index.html) >= 14b
|
||||
|
||||
### Android NDK r14b
|
||||
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
NDK_HOME="/path/to/android-ndk-r14b"
|
||||
MRAA_INSTALL_DIR="/path/to/mraa/install"
|
||||
|
||||
cmake -DBUILDSWIG=ON \
|
||||
-DBUILDSWIGPYTHON=OFF \
|
||||
-DBUILDSWIGNODE=OFF \
|
||||
-DBUILDSWIGJAVA=ON \
|
||||
-DANDROID_COMPILER_FLAGS_CXX='-std=c++11' \
|
||||
-DANDROID_PIE=1 \
|
||||
-DANDROID_PLATFORM=android-24 \
|
||||
-DANDROID_STL_FORCE_FEATURES=ON \
|
||||
-DANDROID_STL=c++_shared \
|
||||
-DANDROID_TOOLCHAIN_NAME=x86-i686 \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
|
||||
-DCMAKE_FIND_ROOT_PATH=$MRAA_INSTALL_DIR \
|
||||
..
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
## Building with Docker
|
||||
|
||||
You can use `docker` and `docker-compose` to generate a complete build environment
|
||||
@ -192,7 +223,7 @@ $ docker run \
|
||||
--env BUILDSWIGPYTHON=ON \
|
||||
--env BUILDSWIGJAVA=OFF \
|
||||
--env BUILDSWIGNODE=OFF \
|
||||
dnoliver/upm-python \
|
||||
inteliotdevkit/upm-python \
|
||||
bash -c "./scripts/run-cmake.sh && make -Cbuild"
|
||||
```
|
||||
|
||||
@ -226,6 +257,6 @@ $ docker run \
|
||||
--env http_proxy=$http_proxy \
|
||||
--env https_proxy=$https_proxy \
|
||||
--env no_proxy=$no_proxy \
|
||||
dnoliver/upm-python \
|
||||
inteliotdevkit/upm-python \
|
||||
bash -c "./scripts/run-cmake.sh && make -Cbuild"
|
||||
```
|
||||
|
@ -4,6 +4,32 @@ Changelog {#changelog}
|
||||
Here's a list summarizing some of the key undergoing changes to our library
|
||||
from earlier versions:
|
||||
|
||||
### v1.7.1
|
||||
|
||||
* Bumped library compatibility to new MRAA 2.0 APIs
|
||||
* Added installation details for Fedora
|
||||
* Minor fixes based on static analysis vulnerability report
|
||||
|
||||
### v1.7.0
|
||||
|
||||
* Added Cordova bindings based on Java packages
|
||||
* Complete rework of the nmea_gps library giving more control over data
|
||||
acquisition and parsing
|
||||
* Added GTest support for unit tests
|
||||
* Removed calls to deprecated MRAA fast GPIO functions
|
||||
* Several bug fixes and improvements around SWIG type maps and gcc8 support
|
||||
* New sensors: kx122, kxtj3, bh1792, bh1749
|
||||
|
||||
### v1.6.0
|
||||
|
||||
* Extended LED library to support the new MRAA gpio-leds APIs
|
||||
* Many CMake changes around SWIG wrapper generation and improved FindNodejs
|
||||
detection module
|
||||
* Several code fixes based on static code analysis
|
||||
* Improved documentation generation and Travis CI builds
|
||||
* Cleaned-up doxygen tags in headers and class names in JSON library files
|
||||
* New sensor: lis3dh
|
||||
|
||||
### v1.5.0
|
||||
|
||||
* Introduced a flexible JSON format for technical sensor specifications, notes
|
||||
|
@ -125,6 +125,8 @@ function make_new_sensor {
|
||||
# Search/replace the new files, replacing all instances of sensortemplate
|
||||
perl -p -i -e "s/SensorTemplate/${SensorName}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
|
||||
perl -p -i -e "s/sensortemplate/${sensorname}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
|
||||
# Remove objects starting with "//" from the new library descriptor .json file
|
||||
perl -p -i -e 'BEGIN{undef $/;} s/\s+"\/\/.*?},//smg' src/${sensorname}/${sensorname}.json
|
||||
# Add mynewmodule example target for java
|
||||
perl -p -i -e "s/^((.*)SensorTemplateSample sensortemplate(.*))/\1\n\2${SensorName}Sample ${sensorname}\3/g" examples/java/CMakeLists.txt
|
||||
# Add mynewmodule example mappings for doxygen
|
||||
|
@ -33,66 +33,66 @@ As much as possible, avoid passing values/returning values through pointers give
|
||||
#### Alternatives:
|
||||
1. Functions that read data from a driver, return it through a pointer given as argument, and return a bool value, should be __replaced by__ functions that return the value directly and throw a std::runtime_error if a read error occurs. E.g.:
|
||||
```c++
|
||||
/*
|
||||
* Function reads from sensor, places read value in variable bar and
|
||||
* returns true if succesful. Function returns false if read failed.
|
||||
*/
|
||||
bool func(int *bar);
|
||||
/*
|
||||
* Function reads from sensor, places read value in variable bar and
|
||||
* returns true if succesful. Function returns false if read failed.
|
||||
*/
|
||||
bool func(int *bar);
|
||||
```
|
||||
__Replaced by:__
|
||||
```c++
|
||||
/*
|
||||
* Function reads from sensor and returns read value.
|
||||
* Or throws std::runtime_error if a read error occurs
|
||||
*/
|
||||
int func();
|
||||
/*
|
||||
* Function reads from sensor and returns read value.
|
||||
* Or throws std::runtime_error if a read error occurs
|
||||
*/
|
||||
int func();
|
||||
```
|
||||
|
||||
2. Functions that return multiple values through pointers, that make sense to be grouped together into an array<sup>1</sup> (e.g. speed values, acceleration values), should be __replaced by__ functions that return a pointer to an array in which the elements are the returned values. Afterwards, [wrap the C array with a Java array](#wrapping-unbound-c-arrays-with-java-arrays-if-array-is-output). E.g.:
|
||||
```c++
|
||||
/*
|
||||
* Function returns the acceleration on the three
|
||||
* axis in the given variables.
|
||||
*/
|
||||
void getAccel(int *accelX, int *accelY, int *accelZ);
|
||||
/*
|
||||
* Function returns the acceleration on the three
|
||||
* axis in the given variables.
|
||||
*/
|
||||
void getAccel(int *accelX, int *accelY, int *accelZ);
|
||||
```
|
||||
|
||||
__Replaced by:__
|
||||
__Replaced by:__
|
||||
```c++
|
||||
/*
|
||||
* Function returns the acceleration on the three
|
||||
* axis as elements of a 3-element array.
|
||||
*/
|
||||
int *getAccel();
|
||||
/*
|
||||
* Function returns the acceleration on the three
|
||||
* axis as elements of a 3-element array.
|
||||
*/
|
||||
int *getAccel();
|
||||
```
|
||||
|
||||
3. Functions that return N values through pointers, that do not make sense to grouped together (e.g. a general purpose function that returns both the light intensity and air pollution), should be __replaced by__ N functions (one for each value) that read only one specific value. E.g.:
|
||||
```c++
|
||||
/*
|
||||
* Function returns the light intensity and air pollution
|
||||
*/
|
||||
void getData(int *light, int *air);
|
||||
/*
|
||||
* Function returns the light intensity and air pollution
|
||||
*/
|
||||
void getData(int *light, int *air);
|
||||
```
|
||||
|
||||
__Replaced by:__
|
||||
__Replaced by:__
|
||||
```c++
|
||||
int getLight();
|
||||
int getAir();
|
||||
int getLight();
|
||||
int getAir();
|
||||
```
|
||||
|
||||
4. Functions that return N values through pointers; values that do not make sense to be grouped together, but are time dependent, and make sense to be read at the same time. For example, a sensor that reads air humidity and temperature. A user may want to know the temperature value _temp_ read at the exact moment the humidity value _humid_ was read. These should be __replaced by__ N+1 functions: a _getData()_ function that reads all values at the same time and stores them in global variables; and N getter functions, one for each value. E.g.
|
||||
```c++
|
||||
/*
|
||||
* Function returns the light intensity and air pollution
|
||||
*/
|
||||
void getData(int *temp, int *humid);
|
||||
/*
|
||||
* Function returns the light intensity and air pollution
|
||||
*/
|
||||
void getData(int *temp, int *humid);
|
||||
```
|
||||
|
||||
__Replaced by:__
|
||||
__Replaced by:__
|
||||
```c++
|
||||
void getData();
|
||||
int getTemp();
|
||||
int getHumid();
|
||||
void getData();
|
||||
int getTemp();
|
||||
int getHumid();
|
||||
```
|
||||
|
||||
<sup>1</sup>this depends on the interpretation of the returned data. For example, arguments that return the temperature and light intensity, don't make sense to be grouped into an array of size 2. But acceleration on the three axis can be grouped together in an array of size 3. where accelX is accel[0], accelY is accel[1], accelZ is accel[2].
|
||||
@ -124,18 +124,18 @@ The exception.i library file provides support for creating language independent
|
||||
|
||||
|
||||
```c++
|
||||
// Language independent exception handler
|
||||
%include exception.i
|
||||
// Language independent exception handler
|
||||
%include exception.i
|
||||
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
} catch(OutOfMemory) {
|
||||
SWIG_exception(SWIG_MemoryError, "Out of memory");
|
||||
} catch(...) {
|
||||
SWIG_exception(SWIG_RuntimeError,"Unknown exception");
|
||||
}
|
||||
}
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
} catch(OutOfMemory) {
|
||||
SWIG_exception(SWIG_MemoryError, "Out of memory");
|
||||
} catch(...) {
|
||||
SWIG_exception(SWIG_RuntimeError,"Unknown exception");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In the upm library, the upm_exception.i interface file provides the functionality to catch common exceptions and propagate them through SWIG. It uses the exception.i library file and is language independent.
|
||||
@ -157,15 +157,15 @@ The upm_exception.i interface file is included in the upm.i file, therefor SWIG
|
||||
To throw a specific Java exception:
|
||||
|
||||
```c++
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
} catch (std::out_of_range &e) {
|
||||
jclass clazz = jenv->FindClass("java/lang/Exception");
|
||||
jenv->ThrowNew(clazz, "Range error");
|
||||
return $null;
|
||||
}
|
||||
}
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
} catch (std::out_of_range &e) {
|
||||
jclass clazz = jenv->FindClass("java/lang/Exception");
|
||||
jenv->ThrowNew(clazz, "Range error");
|
||||
return $null;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Where FindClass and ThrowNew are [JNI functions](http://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html).
|
||||
@ -177,21 +177,21 @@ The C++ compiler does not force the code to catch any exception.
|
||||
The %exception directive does not specify if a method throws a checked exception (does not add classes to the throws clause). For this, the %javaexception(classes) directive is used; where classes is a string containing one or more comma separated Java classes.
|
||||
|
||||
```c++
|
||||
%javaexception("java.lang.Exception") {
|
||||
try {
|
||||
$action
|
||||
} catch (std::out_of_range &e) {
|
||||
jclass clazz = jenv->FindClass("java/lang/Exception");
|
||||
jenv->ThrowNew(clazz, "Range error");
|
||||
return $null;
|
||||
}
|
||||
}
|
||||
%javaexception("java.lang.Exception") {
|
||||
try {
|
||||
$action
|
||||
} catch (std::out_of_range &e) {
|
||||
jclass clazz = jenv->FindClass("java/lang/Exception");
|
||||
jenv->ThrowNew(clazz, "Range error");
|
||||
return $null;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In the upm library, the java_exceptions.i library file provides the functionality to catch exceptions and propagate them through SWIG as Java checked exceptions. The file provides SWIG wrappers, in the form of macros, that can be applied to methods.E.g. use the __READDATA_EXCEPTION(function)__ macro for functions that read data from a sensor and throw a std::runtime_error in case of a read failure. This will result in:
|
||||
|
||||
```java
|
||||
void function throws IOException ();
|
||||
void function throws IOException ();
|
||||
```
|
||||
|
||||
## Caveats & Challenges
|
||||
@ -203,84 +203,73 @@ SWIG can wrap arrays in a more natural Java manner than the default by using the
|
||||
Functions that return arrays, return a pointer to that array. E.g.:
|
||||
|
||||
```c++
|
||||
/*
|
||||
* Function returns the acceleration on the three
|
||||
* axis as elements of a 3-element array.
|
||||
*/
|
||||
/*
|
||||
* Function returns the acceleration on the three
|
||||
* axis as elements of a 3-element array.
|
||||
*/
|
||||
|
||||
int *getAccel();
|
||||
int *getAccel();
|
||||
```
|
||||
|
||||
__SWIG:__
|
||||
__SWIG:__
|
||||
```c++
|
||||
%typemap(jni) int* "jintArray"
|
||||
%typemap(jstype) int* "int[]"
|
||||
%typemap(jtype) int* "int[]"
|
||||
%typemap(jni) int* "jintArray"
|
||||
%typemap(jstype) int* "int[]"
|
||||
%typemap(jtype) int* "int[]"
|
||||
|
||||
%typemap(javaout) int* {
|
||||
return $jnicall;
|
||||
}
|
||||
%typemap(javaout) int* {
|
||||
return $jnicall;
|
||||
}
|
||||
|
||||
%typemap(out) int *getAccel {
|
||||
$result = JCALL1(NewIntArray, jenv, 3);
|
||||
JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const signed int*)$1);
|
||||
}
|
||||
%typemap(out) int *getAccel {
|
||||
$result = JCALL1(NewIntArray, jenv, 3);
|
||||
JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const signed int*)$1);
|
||||
}
|
||||
```
|
||||
|
||||
### Wrapping unbound C arrays with Java arrays if array is input
|
||||
In C, arrays are tipically passed as pointers, with an integer value representig the length of the array. In Java, the length of an array is always known, so the length argument is redundant. This example shows how to wrap the C array and also get rid the length argument. E.g.:
|
||||
|
||||
```c++
|
||||
void func(uint8_t *buffer, int length);
|
||||
void func(uint8_t *buffer, int length);
|
||||
```
|
||||
|
||||
__SWIG:__
|
||||
__SWIG:__
|
||||
```c++
|
||||
%typemap(jtype) (uint8_t *buffer, int length) "byte[]"
|
||||
%typemap(jstype) (uint8_t *buffer, int length) "byte[]"
|
||||
%typemap(jni) (uint8_t *buffer, int length) "jbyteArray"
|
||||
%typemap(javain) (uint8_t *buffer, int length) "$javainput"
|
||||
%typemap(jtype) (uint8_t *buffer, int length) "byte[]"
|
||||
%typemap(jstype) (uint8_t *buffer, int length) "byte[]"
|
||||
%typemap(jni) (uint8_t *buffer, int length) "jbyteArray"
|
||||
%typemap(javain) (uint8_t *buffer, int length) "$javainput"
|
||||
|
||||
%typemap(in,numinputs=1) (uint8_t *buffer, int length) {
|
||||
$1 = JCALL2(GetByteArrayElements, jenv, $input, NULL);
|
||||
$2 = JCALL1(GetArrayLength, jenv, $input);
|
||||
}
|
||||
%typemap(in,numinputs=1) (uint8_t *buffer, int length) {
|
||||
$1 = JCALL2(GetByteArrayElements, jenv, $input, NULL);
|
||||
$2 = JCALL1(GetArrayLength, jenv, $input);
|
||||
}
|
||||
```
|
||||
|
||||
!!!! There is a difference between TYPE *name and TYPE * name in typemaps!!!!!
|
||||
|
||||
|
||||
### Implementing callbacks in Java
|
||||
Callbacks in the UPM Java library (as well as the MRAA Java library) make use of the _void mraa\_java\_isr\_callback(void\* data\)_ method from MRAA.
|
||||
Callbacks in the UPM Java library (as well as the MRAA Java library) make use of the _void mraa\_java\_isr\_callback(void\* data\)_ method from MRAA.
|
||||
|
||||
__Callbacks in the UPM Java library are implemented as follows (we use the a110x Hall Effect sensors as example):__
|
||||
|
||||
We extend the sensor class with another method, _installISR\(jobject runnable\)_, which is a wrapper over the original _installISR\(void \(\*isr\)\(void \*\), void \*arg\)_ method. This will install the _mraa\_java\_isr\_callback\(\)_ method as the interrupt service routine \(ISR\) to be called, with _jobject runnable_ as argument.
|
||||
|
||||
SWIGJAVA is a symbol that is always defined by SWIG when using Java. We enclose the _installISR\(jobject runnable\)_ method in a _\#if defined(SWIGJAVA)_ check, to ensure the code only exists when creating a wrapper for Java.
|
||||
Java callbacks are added at the SWIG interface level. For ease-of-use, a collection of macros are available in src/_upm.i.
|
||||
|
||||
src/a110x/a110x.i:
|
||||
```c++
|
||||
#if defined(SWIGJAVA)
|
||||
void A110X::installISR(jobject runnable)
|
||||
{
|
||||
installISR(mraa_java_isr_callback, runnable);
|
||||
}
|
||||
#endif
|
||||
JAVA_ADD_INSTALLISR(upm::A110X)
|
||||
```
|
||||
|
||||
We hide the underlying method, _installISR\(void \(\*isr\)\(void \*\), void \*arg\)_ , and expose only the _installISR\(jobject runnable\)_ to SWIG, through the use of the SWIGJAVA symbol. When SWIGJAVA is defined, we change the access modifier of the underlying method to private.
|
||||
Will expand to the following SWIG wrapper code:
|
||||
|
||||
```c++
|
||||
public:
|
||||
#if defined(SWIGJAVA)
|
||||
void installISR(jobject runnable);
|
||||
#else
|
||||
void installISR(void (*isr)(void *), void *arg);
|
||||
#endif
|
||||
private:
|
||||
#if defined(SWIGJAVA)
|
||||
void installISR(void (*isr)(void *), void *arg);
|
||||
#endif
|
||||
SWIGINTERN void upm_A110X_installISR__SWIG_1(upm::A110X *self,jobject runnable){
|
||||
self->installISR(mraa_java_isr_callback, runnable);
|
||||
}
|
||||
```
|
||||
|
||||
To use callback in java, we create a ISR class, which implements the Java Runnable interface, and we override the _run\(\)_ method with the code to be executed when the interrupt is received. An example for the a110x Hall sensor that increments a counter each time an interrupt is received:
|
||||
@ -288,13 +277,13 @@ To use callback in java, we create a ISR class, which implements the Java Runnab
|
||||
```java
|
||||
public class A110X_intrSample {
|
||||
public static int counter=0;
|
||||
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
upm_a110x.A110X hall = new upm_a110x.A110X(2);
|
||||
|
||||
A110XISR callback = new A110XISR();
|
||||
hall.installISR(callback);
|
||||
|
||||
|
||||
while(true){
|
||||
System.out.println("Counter: " + counter);
|
||||
Thread.sleep(1000);
|
||||
@ -311,39 +300,3 @@ class A110XISR implements Runnable {
|
||||
}
|
||||
}
|
||||
```
|
||||
#### Issues with java callbacks and workarounds
|
||||
|
||||
__SWIGJAVA not defined at compile time__
|
||||
|
||||
Consider the following files:
|
||||
* example.h - Header file for our source file
|
||||
* example.cxx - Source file containing the class Example, for which we build java bindings
|
||||
* example.i - The SWIG interface, that includes the example.h header file
|
||||
|
||||
The build process of a java module using SWIG is split into two steps:
|
||||
|
||||
1. Generating the intermediate files, from the SWIG interface file. This will produce the java class file (Example.java), the JNI file (exampleJNI.java) and wrapper file (example_wrap.cxx). The source file (example.cxx) is not needed in the first step.
|
||||
```
|
||||
swig -c++ -java example.i
|
||||
```
|
||||
|
||||
2. Generating the shared library from the C++ sources and wrapper file
|
||||
```
|
||||
g++ -fPIC -c example.cxx example_wrap.cxx -I/usr/lib/jvm/java-1.8.0/include -I/usr/lib/jvm/java-1.8.0/include/linux
|
||||
g++ -shared example_wrap.o sensor.o -o libexample.so
|
||||
```
|
||||
|
||||
SWIGJAVA is always defined when SWIG parses the interface file, meaning it will be defined when it parses the header file (example.h) that is included in the interface file (example.i).
|
||||
SWIG also adds the "#define SWIGJAVA" directive in the wrapper file (example_wrap.cxx).
|
||||
However, in generating the shared library the SWIGJAVA symbol is only defined in the example_wrap.cxx file, because of the added "#define SWIGJAVA" directive. But we have also used the "#if defined(SWIGJAVA)" check in the source file (example.cxx), and thus need to define SWIGJAVA for it too. If we define the SWIGJAVA symbol as a compile flag, when compiling the source code to object code, the SWIGJAVA compile flag and #define SWIGJAVA" directive will clash and give a double definition warning (only a warning).
|
||||
|
||||
In this example it is simple to compile the two source codes separately, one with the compile flag, the other without, and then create the shared library (libexample.so).
|
||||
But in a big automatic build like the java upm libraries, this may prove too hard or too complicated to do. A workaround to this would be to define a custom symbol (e.q. JAVACALLBACK in the upm library) and also test for it. In short, replace:
|
||||
```c++
|
||||
#if defined(SWIGJAVA)
|
||||
```
|
||||
by
|
||||
```c++
|
||||
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
|
||||
```
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
Before Width: | Height: | Size: 23 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB |
@ -1,361 +0,0 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
Attribution-NonCommercial-ShareAlike 3.0 Unported
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
|
||||
DAMAGES RESULTING FROM ITS USE.
|
||||
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
||||
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
||||
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
||||
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
||||
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
||||
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
||||
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
||||
CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
||||
other pre-existing works, such as a translation, adaptation,
|
||||
derivative work, arrangement of music or other alterations of a
|
||||
literary or artistic work, or phonogram or performance and includes
|
||||
cinematographic adaptations or any other form in which the Work may be
|
||||
recast, transformed, or adapted including in any form recognizably
|
||||
derived from the original, except that a work that constitutes a
|
||||
Collection will not be considered an Adaptation for the purpose of
|
||||
this License. For the avoidance of doubt, where the Work is a musical
|
||||
work, performance or phonogram, the synchronization of the Work in
|
||||
timed-relation with a moving image ("synching") will be considered an
|
||||
Adaptation for the purpose of this License.
|
||||
b. "Collection" means a collection of literary or artistic works, such as
|
||||
encyclopedias and anthologies, or performances, phonograms or
|
||||
broadcasts, or other works or subject matter other than works listed
|
||||
in Section 1(g) below, which, by reason of the selection and
|
||||
arrangement of their contents, constitute intellectual creations, in
|
||||
which the Work is included in its entirety in unmodified form along
|
||||
with one or more other contributions, each constituting separate and
|
||||
independent works in themselves, which together are assembled into a
|
||||
collective whole. A work that constitutes a Collection will not be
|
||||
considered an Adaptation (as defined above) for the purposes of this
|
||||
License.
|
||||
c. "Distribute" means to make available to the public the original and
|
||||
copies of the Work or Adaptation, as appropriate, through sale or
|
||||
other transfer of ownership.
|
||||
d. "License Elements" means the following high-level license attributes
|
||||
as selected by Licensor and indicated in the title of this License:
|
||||
Attribution, Noncommercial, ShareAlike.
|
||||
e. "Licensor" means the individual, individuals, entity or entities that
|
||||
offer(s) the Work under the terms of this License.
|
||||
f. "Original Author" means, in the case of a literary or artistic work,
|
||||
the individual, individuals, entity or entities who created the Work
|
||||
or if no individual or entity can be identified, the publisher; and in
|
||||
addition (i) in the case of a performance the actors, singers,
|
||||
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
||||
play in, interpret or otherwise perform literary or artistic works or
|
||||
expressions of folklore; (ii) in the case of a phonogram the producer
|
||||
being the person or legal entity who first fixes the sounds of a
|
||||
performance or other sounds; and, (iii) in the case of broadcasts, the
|
||||
organization that transmits the broadcast.
|
||||
g. "Work" means the literary and/or artistic work offered under the terms
|
||||
of this License including without limitation any production in the
|
||||
literary, scientific and artistic domain, whatever may be the mode or
|
||||
form of its expression including digital form, such as a book,
|
||||
pamphlet and other writing; a lecture, address, sermon or other work
|
||||
of the same nature; a dramatic or dramatico-musical work; a
|
||||
choreographic work or entertainment in dumb show; a musical
|
||||
composition with or without words; a cinematographic work to which are
|
||||
assimilated works expressed by a process analogous to cinematography;
|
||||
a work of drawing, painting, architecture, sculpture, engraving or
|
||||
lithography; a photographic work to which are assimilated works
|
||||
expressed by a process analogous to photography; a work of applied
|
||||
art; an illustration, map, plan, sketch or three-dimensional work
|
||||
relative to geography, topography, architecture or science; a
|
||||
performance; a broadcast; a phonogram; a compilation of data to the
|
||||
extent it is protected as a copyrightable work; or a work performed by
|
||||
a variety or circus performer to the extent it is not otherwise
|
||||
considered a literary or artistic work.
|
||||
h. "You" means an individual or entity exercising rights under this
|
||||
License who has not previously violated the terms of this License with
|
||||
respect to the Work, or who has received express permission from the
|
||||
Licensor to exercise rights under this License despite a previous
|
||||
violation.
|
||||
i. "Publicly Perform" means to perform public recitations of the Work and
|
||||
to communicate to the public those public recitations, by any means or
|
||||
process, including by wire or wireless means or public digital
|
||||
performances; to make available to the public Works in such a way that
|
||||
members of the public may access these Works from a place and at a
|
||||
place individually chosen by them; to perform the Work to the public
|
||||
by any means or process and the communication to the public of the
|
||||
performances of the Work, including by public digital performance; to
|
||||
broadcast and rebroadcast the Work by any means including signs,
|
||||
sounds or images.
|
||||
j. "Reproduce" means to make copies of the Work by any means including
|
||||
without limitation by sound or visual recordings and the right of
|
||||
fixation and reproducing fixations of the Work, including storage of a
|
||||
protected performance or phonogram in digital form or other electronic
|
||||
medium.
|
||||
|
||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
||||
limit, or restrict any uses free from copyright or rights arising from
|
||||
limitations or exceptions that are provided for in connection with the
|
||||
copyright protection under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License,
|
||||
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
||||
perpetual (for the duration of the applicable copyright) license to
|
||||
exercise the rights in the Work as stated below:
|
||||
|
||||
a. to Reproduce the Work, to incorporate the Work into one or more
|
||||
Collections, and to Reproduce the Work as incorporated in the
|
||||
Collections;
|
||||
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
||||
including any translation in any medium, takes reasonable steps to
|
||||
clearly label, demarcate or otherwise identify that changes were made
|
||||
to the original Work. For example, a translation could be marked "The
|
||||
original work was translated from English to Spanish," or a
|
||||
modification could indicate "The original work has been modified.";
|
||||
c. to Distribute and Publicly Perform the Work including as incorporated
|
||||
in Collections; and,
|
||||
d. to Distribute and Publicly Perform Adaptations.
|
||||
|
||||
The above rights may be exercised in all media and formats whether now
|
||||
known or hereafter devised. The above rights include the right to make
|
||||
such modifications as are technically necessary to exercise the rights in
|
||||
other media and formats. Subject to Section 8(f), all rights not expressly
|
||||
granted by Licensor are hereby reserved, including but not limited to the
|
||||
rights described in Section 4(e).
|
||||
|
||||
4. Restrictions. The license granted in Section 3 above is expressly made
|
||||
subject to and limited by the following restrictions:
|
||||
|
||||
a. You may Distribute or Publicly Perform the Work only under the terms
|
||||
of this License. You must include a copy of, or the Uniform Resource
|
||||
Identifier (URI) for, this License with every copy of the Work You
|
||||
Distribute or Publicly Perform. You may not offer or impose any terms
|
||||
on the Work that restrict the terms of this License or the ability of
|
||||
the recipient of the Work to exercise the rights granted to that
|
||||
recipient under the terms of the License. You may not sublicense the
|
||||
Work. You must keep intact all notices that refer to this License and
|
||||
to the disclaimer of warranties with every copy of the Work You
|
||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||
Perform the Work, You may not impose any effective technological
|
||||
measures on the Work that restrict the ability of a recipient of the
|
||||
Work from You to exercise the rights granted to that recipient under
|
||||
the terms of the License. This Section 4(a) applies to the Work as
|
||||
incorporated in a Collection, but this does not require the Collection
|
||||
apart from the Work itself to be made subject to the terms of this
|
||||
License. If You create a Collection, upon notice from any Licensor You
|
||||
must, to the extent practicable, remove from the Collection any credit
|
||||
as required by Section 4(d), as requested. If You create an
|
||||
Adaptation, upon notice from any Licensor You must, to the extent
|
||||
practicable, remove from the Adaptation any credit as required by
|
||||
Section 4(d), as requested.
|
||||
b. You may Distribute or Publicly Perform an Adaptation only under: (i)
|
||||
the terms of this License; (ii) a later version of this License with
|
||||
the same License Elements as this License; (iii) a Creative Commons
|
||||
jurisdiction license (either this or a later license version) that
|
||||
contains the same License Elements as this License (e.g.,
|
||||
Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable License").
|
||||
You must include a copy of, or the URI, for Applicable License with
|
||||
every copy of each Adaptation You Distribute or Publicly Perform. You
|
||||
may not offer or impose any terms on the Adaptation that restrict the
|
||||
terms of the Applicable License or the ability of the recipient of the
|
||||
Adaptation to exercise the rights granted to that recipient under the
|
||||
terms of the Applicable License. You must keep intact all notices that
|
||||
refer to the Applicable License and to the disclaimer of warranties
|
||||
with every copy of the Work as included in the Adaptation You
|
||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||
Perform the Adaptation, You may not impose any effective technological
|
||||
measures on the Adaptation that restrict the ability of a recipient of
|
||||
the Adaptation from You to exercise the rights granted to that
|
||||
recipient under the terms of the Applicable License. This Section 4(b)
|
||||
applies to the Adaptation as incorporated in a Collection, but this
|
||||
does not require the Collection apart from the Adaptation itself to be
|
||||
made subject to the terms of the Applicable License.
|
||||
c. You may not exercise any of the rights granted to You in Section 3
|
||||
above in any manner that is primarily intended for or directed toward
|
||||
commercial advantage or private monetary compensation. The exchange of
|
||||
the Work for other copyrighted works by means of digital file-sharing
|
||||
or otherwise shall not be considered to be intended for or directed
|
||||
toward commercial advantage or private monetary compensation, provided
|
||||
there is no payment of any monetary compensation in con-nection with
|
||||
the exchange of copyrighted works.
|
||||
d. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
||||
Collections, You must, unless a request has been made pursuant to
|
||||
Section 4(a), keep intact all copyright notices for the Work and
|
||||
provide, reasonable to the medium or means You are utilizing: (i) the
|
||||
name of the Original Author (or pseudonym, if applicable) if supplied,
|
||||
and/or if the Original Author and/or Licensor designate another party
|
||||
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
||||
attribution ("Attribution Parties") in Licensor's copyright notice,
|
||||
terms of service or by other reasonable means, the name of such party
|
||||
or parties; (ii) the title of the Work if supplied; (iii) to the
|
||||
extent reasonably practicable, the URI, if any, that Licensor
|
||||
specifies to be associated with the Work, unless such URI does not
|
||||
refer to the copyright notice or licensing information for the Work;
|
||||
and, (iv) consistent with Section 3(b), in the case of an Adaptation,
|
||||
a credit identifying the use of the Work in the Adaptation (e.g.,
|
||||
"French translation of the Work by Original Author," or "Screenplay
|
||||
based on original Work by Original Author"). The credit required by
|
||||
this Section 4(d) may be implemented in any reasonable manner;
|
||||
provided, however, that in the case of a Adaptation or Collection, at
|
||||
a minimum such credit will appear, if a credit for all contributing
|
||||
authors of the Adaptation or Collection appears, then as part of these
|
||||
credits and in a manner at least as prominent as the credits for the
|
||||
other contributing authors. For the avoidance of doubt, You may only
|
||||
use the credit required by this Section for the purpose of attribution
|
||||
in the manner set out above and, by exercising Your rights under this
|
||||
License, You may not implicitly or explicitly assert or imply any
|
||||
connection with, sponsorship or endorsement by the Original Author,
|
||||
Licensor and/or Attribution Parties, as appropriate, of You or Your
|
||||
use of the Work, without the separate, express prior written
|
||||
permission of the Original Author, Licensor and/or Attribution
|
||||
Parties.
|
||||
e. For the avoidance of doubt:
|
||||
|
||||
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme cannot be waived, the Licensor
|
||||
reserves the exclusive right to collect such royalties for any
|
||||
exercise by You of the rights granted under this License;
|
||||
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme can be waived, the Licensor reserves
|
||||
the exclusive right to collect such royalties for any exercise by
|
||||
You of the rights granted under this License if Your exercise of
|
||||
such rights is for a purpose or use which is otherwise than
|
||||
noncommercial as permitted under Section 4(c) and otherwise waives
|
||||
the right to collect royalties through any statutory or compulsory
|
||||
licensing scheme; and,
|
||||
iii. Voluntary License Schemes. The Licensor reserves the right to
|
||||
collect royalties, whether individually or, in the event that the
|
||||
Licensor is a member of a collecting society that administers
|
||||
voluntary licensing schemes, via that society, from any exercise
|
||||
by You of the rights granted under this License that is for a
|
||||
purpose or use which is otherwise than noncommercial as permitted
|
||||
under Section 4(c).
|
||||
f. Except as otherwise agreed in writing by the Licensor or as may be
|
||||
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
||||
Publicly Perform the Work either by itself or as part of any
|
||||
Adaptations or Collections, You must not distort, mutilate, modify or
|
||||
take other derogatory action in relation to the Work which would be
|
||||
prejudicial to the Original Author's honor or reputation. Licensor
|
||||
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
||||
of the right granted in Section 3(b) of this License (the right to
|
||||
make Adaptations) would be deemed to be a distortion, mutilation,
|
||||
modification or other derogatory action prejudicial to the Original
|
||||
Author's honor and reputation, the Licensor will waive or not assert,
|
||||
as appropriate, this Section, to the fullest extent permitted by the
|
||||
applicable national law, to enable You to reasonably exercise Your
|
||||
right under Section 3(b) of this License (right to make Adaptations)
|
||||
but not otherwise.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING AND TO THE
|
||||
FULLEST EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR OFFERS THE WORK AS-IS
|
||||
AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE
|
||||
WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT
|
||||
LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
|
||||
WARRANTIES, SO THIS EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
||||
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
||||
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
||||
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
a. This License and the rights granted hereunder will terminate
|
||||
automatically upon any breach by You of the terms of this License.
|
||||
Individuals or entities who have received Adaptations or Collections
|
||||
from You under this License, however, will not have their licenses
|
||||
terminated provided such individuals or entities remain in full
|
||||
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
||||
survive any termination of this License.
|
||||
b. Subject to the above terms and conditions, the license granted here is
|
||||
perpetual (for the duration of the applicable copyright in the Work).
|
||||
Notwithstanding the above, Licensor reserves the right to release the
|
||||
Work under different license terms or to stop distributing the Work at
|
||||
any time; provided, however that any such election will not serve to
|
||||
withdraw this License (or any other license that has been, or is
|
||||
required to be, granted under the terms of this License), and this
|
||||
License will continue in full force and effect unless terminated as
|
||||
stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
||||
the Licensor offers to the recipient a license to the Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
||||
offers to the recipient a license to the original Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
c. If any provision of this License is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this License, and without further action
|
||||
by the parties to this agreement, such provision shall be reformed to
|
||||
the minimum extent necessary to make such provision valid and
|
||||
enforceable.
|
||||
d. No term or provision of this License shall be deemed waived and no
|
||||
breach consented to unless such waiver or consent shall be in writing
|
||||
and signed by the party to be charged with such waiver or consent.
|
||||
e. This License constitutes the entire agreement between the parties with
|
||||
respect to the Work licensed here. There are no understandings,
|
||||
agreements or representations with respect to the Work not specified
|
||||
here. Licensor shall not be bound by any additional provisions that
|
||||
may appear in any communication from You. This License may not be
|
||||
modified without the mutual written agreement of the Licensor and You.
|
||||
f. The rights granted under, and the subject matter referenced, in this
|
||||
License were drafted utilizing the terminology of the Berne Convention
|
||||
for the Protection of Literary and Artistic Works (as amended on
|
||||
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
||||
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
||||
and the Universal Copyright Convention (as revised on July 24, 1971).
|
||||
These rights and subject matter take effect in the relevant
|
||||
jurisdiction in which the License terms are sought to be enforced
|
||||
according to the corresponding provisions of the implementation of
|
||||
those treaty provisions in the applicable national law. If the
|
||||
standard suite of rights granted under applicable copyright law
|
||||
includes additional rights not granted under this License, such
|
||||
additional rights are deemed to be included in the License; this
|
||||
License is not intended to restrict the license of any rights under
|
||||
applicable law.
|
||||
|
||||
|
||||
Creative Commons Notice
|
||||
|
||||
Creative Commons is not a party to this License, and makes no warranty
|
||||
whatsoever in connection with the Work. Creative Commons will not be
|
||||
liable to You or any party on any legal theory for any damages
|
||||
whatsoever, including without limitation any general, special,
|
||||
incidental or consequential damages arising in connection to this
|
||||
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
||||
Commons has expressly identified itself as the Licensor hereunder, it
|
||||
shall have all rights and obligations of Licensor.
|
||||
|
||||
Except for the limited purpose of indicating to the public that the
|
||||
Work is licensed under the CCPL, Creative Commons does not authorize
|
||||
the use by either party of the trademark "Creative Commons" or any
|
||||
related trademark or logo of Creative Commons without the prior
|
||||
written consent of Creative Commons. Any permitted use will be in
|
||||
compliance with Creative Commons' then-current trademark usage
|
||||
guidelines, as may be published on its website or otherwise made
|
||||
available upon request from time to time. For the avoidance of doubt,
|
||||
this trademark restriction does not form part of this License.
|
||||
|
||||
Creative Commons may be contacted at https://creativecommons.org/.
|
||||
|
BIN
docs/images/kxtj3.png
Executable file
BIN
docs/images/kxtj3.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
@ -54,6 +54,18 @@ sudo apt-get install libupm-dev libupm-java python-upm python3-upm node-upm upm-
|
||||
Running UPM applications on Ubuntu systems requires elevated permissions
|
||||
(e.g. run with `sudo`).
|
||||
|
||||
### Fedora Linux
|
||||
|
||||
MRAA and UPM are available through the default package repositories on Fedora and can be
|
||||
installed in the standard method using dnf.
|
||||
|
||||
To install:
|
||||
|
||||
```bash
|
||||
sudo dnf install upm
|
||||
sudo dnf install paython3-upm nodejs-upm upm-examples
|
||||
```
|
||||
|
||||
### Node.js bindings only (NPM)
|
||||
|
||||
This option allows compiling MRAA/UPM on any system with npm and node-gyp.
|
||||
|
@ -14,8 +14,7 @@ First thing to do is to create a tree structure like this in upm/src/max31855:
|
||||
|
||||
* max31855.cxx
|
||||
* max31855.hpp
|
||||
* jsupm_max31855.i
|
||||
* pyupm_max31855.i
|
||||
* max31855.i
|
||||
* CMakeLists.txt
|
||||
|
||||
And then an example file to use & test our lib with in upm/examples/max31855.cxx.
|
||||
|
@ -702,7 +702,7 @@ CITE_BIB_FILES =
|
||||
# messages are off.
|
||||
# The default value is: NO.
|
||||
|
||||
QUIET = NO
|
||||
QUIET = YES
|
||||
|
||||
# The WARNINGS tag can be used to turn on/off the warning messages that are
|
||||
# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
|
||||
|
@ -702,7 +702,7 @@ CITE_BIB_FILES =
|
||||
# messages are off.
|
||||
# The default value is: NO.
|
||||
|
||||
QUIET = NO
|
||||
QUIET = YES
|
||||
|
||||
# The WARNINGS tag can be used to turn on/off the warning messages that are
|
||||
# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
|
||||
|
@ -34,13 +34,6 @@ var lib = require('jsupm_<module-name>');
|
||||
### Supported Sensors
|
||||
The full list is available on [Intel® IoT Developer Zone](https://software.intel.com/en-us/iot/hardware/sensors).
|
||||
|
||||
### IDE Integration
|
||||
Intel® XDK IoT Edition is the recommended IDE for Node.js development. Visit
|
||||
the Intel® Developer Zone [IDE page](https://software.intel.com/iot/software/ide)
|
||||
for more information on how to get started.
|
||||
|
||||

|
||||
|
||||
### Building UPM
|
||||
See building documentation [here](https://github.com/intel-iot-devkit/upm/blob/master/docs/building.md).
|
||||
|
||||
|
@ -23,15 +23,6 @@ repository.
|
||||
|
||||
Individual sensor usage examples for Python are available `here <https://github.com/intel-iot-devkit/upm/tree/master/examples/python>`_.
|
||||
|
||||
``IDE Compatibility``
|
||||
################
|
||||
|
||||
While there is no official IDE provided with our Python libraries, we do recommend the web-based IDE Wyliodrin. It can be used with multiple programming
|
||||
languages, including Python. More information can be found on the Intel Developer Zone IDE page.
|
||||
|
||||
.. image:: ../docs/icons/wyliodrin.png
|
||||
:target: https://software.intel.com/iot/software/ide
|
||||
|
||||
``Making your own UPM Module``
|
||||
##############################
|
||||
|
||||
|
@ -36,19 +36,6 @@
|
||||
href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="ide">
|
||||
<h3><tt class="docutils literal"><span class="pre">IDE Compatibility</span>
|
||||
<span class="pre">UPM</span></tt><a class="headerlink"
|
||||
href="#ide"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>Intel® XDK IoT Edition is the recommended IDE for Node.js development.
|
||||
Visit the Intel® Developer Zone IDE page for more information on how to get
|
||||
started.<br>
|
||||
<a href="https://software.intel.com/iot/software/ide"><img src="../docs/icons/xdk.png"/></a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section" id="building-upm">
|
||||
<h3><tt class="docutils literal"><span class="pre">Building</span>
|
||||
<span class="pre">UPM</span></tt><a class="headerlink"
|
||||
|
@ -1,79 +1,82 @@
|
||||
# Mapping examples across provided languages
|
||||
a110x.cxx A110XSample.java a110x.js a110x.py
|
||||
a110x-intr.cxx A110X_intrSample.java a110x-intr.js a110x-intr.py
|
||||
adc121c021.cxx ADC121C021Sample.java adc121c021.js adc121c021.py
|
||||
adxl345.cxx Adxl345Sample.java adxl345.js adxl345.py
|
||||
biss0001.cxx BISS0001Sample.java biss0001.js biss0001.py
|
||||
bmpx8x.cxx BMPX8XSample.java bmpx8x.js bmpx8x.py
|
||||
bno055.cxx BNO055_Example.java bno055.js bno055.py
|
||||
button.cxx ButtonSample.java button.js button.py
|
||||
buzzer.cxx BuzzerSample.java buzzer.js buzzer.py
|
||||
cjq4435.cxx CJQ4435Sample.java cjq4435.js cjq4435.py
|
||||
ds1307.cxx DS1307Sample.java ds1307.js ds1307.py
|
||||
enc03r.cxx ENC03RSample.java enc03r.js enc03r.py
|
||||
servo-es08a.cxx ES08ASample.java es08a.js es08a.py
|
||||
groveehr.cxx GroveEHRSample.java groveehr.js groveehr.py
|
||||
my9221-groveledbar.cxx GroveLEDBar.java groveledbar.js groveledbar.py
|
||||
grove-groveled.cxx GroveLEDSample.java groveled.js groveled.py
|
||||
grovelinefinder.cxx GroveLineFinderSample.java grovelinefinder.js grovelinefinder.py
|
||||
grovemoisture.cxx GroveMoistureSample.java grovemoisture.js grovemoisture.py
|
||||
grovescam.cxx GROVESCAMSample.java grovescam.js grovescam.py
|
||||
grovewfs.cxx GroveWFSSample.java grovewfs.js grovewfs.py
|
||||
guvas12d.cxx GUVAS12DSample.java guvas12d.js guvas12d.py
|
||||
h3lis331dl.cxx H3LIS331DLSample.java h3lis331dl.js h3lis331dl.py
|
||||
hcsr04.cxx HCSR04Sample.java hcsr04.js hcsr04.py
|
||||
hm11.cxx HM11Sample.java hm11.js hm11.py
|
||||
hmc5883l.cxx Hmc5883lSample.java hmc5883l.js hmc5883l.py
|
||||
htu21d.cxx HTU21DSample.java htu21d.js htu21d.py
|
||||
ims.cxx IMS_Example.java ims.js ims.py
|
||||
itg3200.cxx Itg3200Sample.java itg3200.js itg3200.py
|
||||
jhd1313m1-lcd.cxx Jhd1313m1_lcdSample.java jhd1313m1-lcd.js jhd1313m1-lcd.py
|
||||
joystick12.cxx Joystick12Sample.java joystick12.js joystick12.py
|
||||
lcm1602-i2c.cxx Lcm1602_i2cSample.java lcm1602-i2c.js lcm1602-i2c.py
|
||||
ldt0028.cxx LDT0028Sample.java ldt0028.js ldt0028.py
|
||||
light.cxx LightSample.java light.js light.py
|
||||
lol.cxx LoLSample.java lol.js lol.py
|
||||
lsm303dlh.cxx LSM303DLHSample.java lsm303dlh.js lsm303dlh.py
|
||||
m24lr64e.cxx M24LR64ESample.java m24lr64e.js m24lr64e.py
|
||||
max44000.cxx MAX44000Sample.java max44000.js max44000.py
|
||||
mic.cxx MicrophoneSample.java mic.js mic.py
|
||||
mma7455.cxx MMA7455Sample.java mma7455.js mma7455.py
|
||||
mma7660.cxx MMA7660Sample.java mma7660.js mma7660.py
|
||||
mpl3115a2.cxx MPL3115A2Sample.java mpl3115a2.js mpl3115a2.py
|
||||
mpr121.cxx MPR121Sample.java mpr121.js mpr121.py
|
||||
mpu9150.cxx MPU9150Sample.java mpu9150.js mpu9150.py
|
||||
gas-mq2.cxx MQ2Sample.java mq2.js mq2.py
|
||||
mq303a.cxx MQ303ASample.java mq303a.js mq303a.py
|
||||
gas-mq5.cxx MQ5Sample.java mq5.js mq5.py
|
||||
nrf24l01-receiver.cxx NRF24L01_receiverSample.java nrf24l01-receiver.js nrf24l01-receiver.py
|
||||
nrf24l01-transmitter.cxx NRF24L01_transmitterSample.java nrf24l01-transmitter.js nrf24l01-transmitter.py
|
||||
nunchuck.cxx NUNCHUCKSample.java nunchuck.js nunchuck.py
|
||||
otp538u.cxx OTP538USample.java otp538u.js otp538u.py
|
||||
ppd42ns.cxx PPD42NSSample.java ppd42ns.js ppd42ns.py
|
||||
pulsensor.cxx PulsensorSample.java pulsensor.js pulsensor.py
|
||||
relay.cxx RelaySample.java relay.js relay.py
|
||||
rfr359f.cxx RFR359FSample.java rfr359f.js rfr359f.py
|
||||
rotary.cxx RotarySample.java rotary.js rotary.py
|
||||
rotaryencoder.cxx RotaryEncoderSample.java rotaryencoder.js rotaryencoder.py
|
||||
rpr220.cxx RPR220Sample.java rpr220.js rpr220.py
|
||||
rpr220-intr.cxx RPR220_intrSample.java rpr220-intr.js rpr220-intr.py
|
||||
slide.cxx SlideSample.java slide.js slide.py
|
||||
speaker.cxx SpeakerSample.java speaker.js speaker.py
|
||||
i2clcd-ssd1308-oled.cxx SSD1308_oledSample.java ssd1308-oled.js ssd1308-oled.py
|
||||
i2clcd-ssd1327-oled.cxx SSD1327_oledSample.java ssd1327-oled.js ssd1327-oled.py
|
||||
st7735.cxx ST7735Sample.java st7735.js st7735.py
|
||||
stepmotor.cxx StepMotorSample.java stepmotor.js stepmotor.py
|
||||
tm1637.cxx TM1637Sample.java tm1637.js tm1637.py
|
||||
gas-tp401.cxx TP401Sample.java tp401.js tp401.py
|
||||
tsl2561.cxx TSL2561Sample.java tsl2561.js tsl2561.py
|
||||
ttp223.cxx TTP223Sample.java ttp223.js ttp223.py
|
||||
uln200xa.cxx ULN200XASample.java uln200xa.js uln200xa.py
|
||||
vdiv.cxx VDivSample.java vdiv.js vdiv.py
|
||||
water.cxx WaterSample.java water.js water.py
|
||||
wt5001.cxx WT5001Sample.java wt5001.js wt5001.py
|
||||
yg1006.cxx YG1006Sample.java yg1006.js yg1006.py
|
||||
sensortemplate.cxx SensorTemplateSample.java sensortemplate.js sensortemplate.py
|
||||
p9813.cxx P9813Sample.java p9813.js p9813.py
|
||||
a110x.cxx A110X_Example.java a110x.js a110x.py
|
||||
a110x-intr.cxx A110X_intr_Example.java a110x-intr.js a110x-intr.py
|
||||
adc121c021.cxx ADC121C021_Example.java adc121c021.js adc121c021.py
|
||||
adxl345.cxx Adxl345_Example.java adxl345.js adxl345.py
|
||||
bh1749.cxx BH1749_Example.java bh1749.js bh1749.py
|
||||
bh1750.cxx BH1750_Example.java bh1750.js bh1750.py
|
||||
bh1792.cxx BH1792_Example.java bh1792.js bh1792.py
|
||||
biss0001.cxx BISS0001_Example.java biss0001.js biss0001.py
|
||||
bmpx8x.cxx BMPX8X_Example.java bmpx8x.js bmpx8x.py
|
||||
bno055.cxx BNO055_Example.java bno055.js bno055.py
|
||||
button.cxx Button_Example.java button.js button.py
|
||||
buzzer.cxx Buzzer_Example.java buzzer.js buzzer.py
|
||||
cjq4435.cxx CJQ4435_Example.java cjq4435.js cjq4435.py
|
||||
ds1307.cxx DS1307_Example.java ds1307.js ds1307.py
|
||||
enc03r.cxx ENC03R_Example.java enc03r.js enc03r.py
|
||||
servo-es08a.cxx ES08A_Example.java es08a.js es08a.py
|
||||
groveehr.cxx GroveEHR_Example.java groveehr.js groveehr.py
|
||||
my9221-groveledbar.cxx GroveLEDBar_Example.java groveledbar.js groveledbar.py
|
||||
grove-groveled.cxx GroveLED_Example.java groveled.js groveled.py
|
||||
grovelinefinder.cxx GroveLineFinder_Example.java grovelinefinder.js grovelinefinder.py
|
||||
grovemoisture.cxx GroveMoisture_Example.java grovemoisture.js grovemoisture.py
|
||||
grovescam.cxx GROVESCAM_Example.java grovescam.js grovescam.py
|
||||
grovewfs.cxx GroveWFS_Example.java grovewfs.js grovewfs.py
|
||||
guvas12d.cxx GUVAS12D_Example.java guvas12d.js guvas12d.py
|
||||
h3lis331dl.cxx H3LIS331DL_Example.java h3lis331dl.js h3lis331dl.py
|
||||
hcsr04.cxx HCSR04_Example.java hcsr04.js hcsr04.py
|
||||
hm11.cxx HM11_Example.java hm11.js hm11.py
|
||||
hmc5883l.cxx Hmc5883l_Example.java hmc5883l.js hmc5883l.py
|
||||
htu21d.cxx HTU21D_Example.java htu21d.js htu21d.py
|
||||
ims.cxx IMS_Example.java ims.js ims.py
|
||||
itg3200.cxx Itg3200_Example.java itg3200.js itg3200.py
|
||||
jhd1313m1-lcd.cxx Jhd1313m1_lcd_Example.java jhd1313m1-lcd.js jhd1313m1-lcd.py
|
||||
joystick12.cxx Joystick12_Example.java joystick12.js joystick12.py
|
||||
lcm1602-i2c.cxx Lcm1602_i2c_Example.java lcm1602-i2c.js lcm1602-i2c.py
|
||||
ldt0028.cxx LDT0028_Example.java ldt0028.js ldt0028.py
|
||||
light.cxx Light_Example.java light.js light.py
|
||||
lol.cxx LoL_Example.java lol.js lol.py
|
||||
lsm303dlh.cxx LSM303DLH_Example.java lsm303dlh.js lsm303dlh.py
|
||||
m24lr64e.cxx M24LR64E_Example.java m24lr64e.js m24lr64e.py
|
||||
max44000.cxx MAX44000_Example.java max44000.js max44000.py
|
||||
mic.cxx Microphone_Example.java mic.js mic.py
|
||||
mma7455.cxx MMA7455_Example.java mma7455.js mma7455.py
|
||||
mma7660.cxx MMA7660_Example.java mma7660.js mma7660.py
|
||||
mpl3115a2.cxx MPL3115A2_Example.java mpl3115a2.js mpl3115a2.py
|
||||
mpr121.cxx MPR121_Example.java mpr121.js mpr121.py
|
||||
mpu9150.cxx MPU9150_Example.java mpu9150.js mpu9150.py
|
||||
gas-mq2.cxx MQ2_Example.java mq2.js mq2.py
|
||||
mq303a.cxx MQ303A_Example.java mq303a.js mq303a.py
|
||||
gas-mq5.cxx MQ5_Example.java mq5.js mq5.py
|
||||
nrf24l01-receiver.cxx NRF24L01_receiver_Example.java nrf24l01-receiver.js nrf24l01-receiver.py
|
||||
nrf24l01-transmitter.cxx NRF24L01_transmitter_Example.java nrf24l01-transmitter.js nrf24l01-transmitter.py
|
||||
nunchuck.cxx NUNCHUCK_Example.java nunchuck.js nunchuck.py
|
||||
otp538u.cxx OTP538U_Example.java otp538u.js otp538u.py
|
||||
ppd42ns.cxx PPD42NS_Example.java ppd42ns.js ppd42ns.py
|
||||
pulsensor.cxx Pulsensor_Example.java pulsensor.js pulsensor.py
|
||||
relay.cxx Relay_Example.java relay.js relay.py
|
||||
rfr359f.cxx RFR359F_Example.java rfr359f.js rfr359f.py
|
||||
rotary.cxx Rotary_Example.java rotary.js rotary.py
|
||||
rotaryencoder.cxx RotaryEncoder_Example.java rotaryencoder.js rotaryencoder.py
|
||||
rpr220.cxx RPR220_Example.java rpr220.js rpr220.py
|
||||
rpr220-intr.cxx RPR220_intr_Example.java rpr220-intr.js rpr220-intr.py
|
||||
slide.cxx Slide_Example.java slide.js slide.py
|
||||
speaker.cxx Speaker_Example.java speaker.js speaker.py
|
||||
lcd-ssd1308-oled.cxx SSD1308_oled_Example.java ssd1308-oled.js ssd1308-oled.py
|
||||
lcd-ssd1327-oled.cxx SSD1327_oled_Example.java ssd1327-oled.js ssd1327-oled.py
|
||||
st7735.cxx ST7735_Example.java st7735.js st7735.py
|
||||
stepmotor.cxx StepMotor_Example.java stepmotor.js stepmotor.py
|
||||
tm1637.cxx TM1637_Example.java tm1637.js tm1637.py
|
||||
gas-tp401.cxx TP401_Example.java tp401.js tp401.py
|
||||
tsl2561.cxx TSL2561_Example.java tsl2561.js tsl2561.py
|
||||
ttp223.cxx TTP223_Example.java ttp223.js ttp223.py
|
||||
uln200xa.cxx ULN200XA_Example.java uln200xa.js uln200xa.py
|
||||
vdiv.cxx VDiv_Example.java vdiv.js vdiv.py
|
||||
water.cxx Water_Example.java water.js water.py
|
||||
wt5001.cxx WT5001_Example.java wt5001.js wt5001.py
|
||||
yg1006.cxx YG1006_Example.java yg1006.js yg1006.py
|
||||
sensortemplate.cxx SensorTemplate_Example.java sensortemplate.js sensortemplate.py
|
||||
p9813.cxx P9813_Example.java p9813.js p9813.py
|
||||
tcs37727.cxx tcs37727.py
|
||||
tmp006.cxx tmp006.py
|
||||
mma8x5x.cxx mma8x5x.py
|
||||
|
@ -41,7 +41,7 @@
|
||||
# a110x.c Requires libupmc-a110x
|
||||
# lcm1602-i2c.c Requires libupmc-lcm1602
|
||||
# bmp280-bme280.c Requires libupmc-bmp280
|
||||
# i2clcd-eboled.cxx Requires libupm-i2clcd
|
||||
# lcd-eboled.cxx Requires libupm-lcd
|
||||
#
|
||||
#
|
||||
function (add_example example_src)
|
||||
@ -117,4 +117,16 @@ if(BUILDEXAMPLES)
|
||||
if(BUILDSWIGJAVA)
|
||||
add_subdirectory (java)
|
||||
endif()
|
||||
|
||||
# Add all examples as an install component (if building examples)
|
||||
install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/upm
|
||||
COMPONENT ${CMAKE_PROJECT_NAME}-examples
|
||||
FILES_MATCHING
|
||||
PATTERN "*.c"
|
||||
PATTERN "*.cxx"
|
||||
PATTERN "*.hpp"
|
||||
PATTERN "*.java"
|
||||
PATTERN "*.js"
|
||||
PATTERN "*.py")
|
||||
endif()
|
||||
|
71
examples/c++/bh1749.cxx
Executable file
71
examples/c++/bh1749.cxx
Executable file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Assam Boudjelthia
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <stdexcept>
|
||||
#include <signal.h>
|
||||
#include <vector>
|
||||
#include "bh1749.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
bool isStopped;
|
||||
upm::BH1749 dev;
|
||||
|
||||
void signal_int_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
isStopped = true;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
void PrintData(void *args)
|
||||
{
|
||||
std::vector<uint16_t> result = dev.GetMeasurements();
|
||||
std::cout << "R: " << result.at(0) <<
|
||||
", G: " << result.at(1) <<
|
||||
", B: " << result.at(2) <<
|
||||
", IR: " << result.at(3) <<
|
||||
", G2: " << result.at(4) << std::endl;
|
||||
dev.ResetInterrupt();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, signal_int_handler);
|
||||
dev.SoftReset();
|
||||
dev.SensorInit(INT_JUDGE_1, MEAS_240MS, RGB_GAIN_1X, IR_GAIN_1X, RED);
|
||||
dev.SetThresholdHigh(511);
|
||||
std::cout << "Installing ISR" << std::endl;
|
||||
dev.InstallISR(MRAA_GPIO_EDGE_FALLING, 33, &PrintData, NULL);
|
||||
dev.EnableInterrupt();
|
||||
dev.Enable();
|
||||
|
||||
while(!isStopped) {
|
||||
upm_delay_ms(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//! [Interesting]
|
81
examples/c++/bh1792.cxx
Executable file
81
examples/c++/bh1792.cxx
Executable file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Assam Boudjelthia
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include "bh1792.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
bool isStopped;
|
||||
upm::BH1792 dev;
|
||||
|
||||
void signal_int_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
isStopped = true;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
void PrintData(void *args)
|
||||
{
|
||||
std::vector<std::vector<int>> fifo;
|
||||
struct timespec now;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
||||
try {
|
||||
fifo = dev.GetFifoData();
|
||||
|
||||
std::cout << "\nHeart beat sensor FIFO data:" << std::endl;
|
||||
for(int i = 0; i < 32; i++)
|
||||
std::cout << i << ": off: " << fifo.at(i).at(0) << ", on: " <<
|
||||
fifo.at(i).at(1) << std::endl;
|
||||
|
||||
std::cout << "timestamp " << now.tv_sec << " sec, " << now.tv_nsec <<
|
||||
" nsec" << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cout << "Failed to read FIFO data" << std::endl;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
float measTime;
|
||||
|
||||
signal(SIGINT, signal_int_handler);
|
||||
dev.SoftReset();
|
||||
dev.EnableSyncMode(256, 32);
|
||||
std::cout << "Installing ISR" << std::endl;
|
||||
dev.InstallISR(MRAA_GPIO_EDGE_FALLING, 33, &PrintData, NULL);
|
||||
measTime = dev.GetMeasurementTimeMS();
|
||||
dev.StartMeasurement();
|
||||
|
||||
while(!isStopped) {
|
||||
usleep(measTime * 1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//! [Interesting]
|
65
examples/c++/kx122.cxx
Normal file
65
examples/c++/kx122.cxx
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Samuli Rissanen <samuli.rissanen@hotmail.com>
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "kx122.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT){
|
||||
shouldRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT,sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
upm::KX122 sensor(0,-1,24);
|
||||
|
||||
sensor.softwareReset();
|
||||
sensor.deviceInit(KX122_ODR_50,HIGH_RES,KX122_RANGE_2G);
|
||||
|
||||
float x,y,z;
|
||||
int wait_time = sensor.getSamplePeriod() * MICRO_S;
|
||||
if (wait_time < 0) wait_time = 1000;
|
||||
|
||||
while(shouldRun){
|
||||
sensor.getAccelerationData(&x,&y,&z);
|
||||
|
||||
printf("%.02f | %.02f | %.02f\n",x,y,z);
|
||||
upm_delay_us(wait_time);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
73
examples/c++/kxtj3.cxx
Executable file
73
examples/c++/kxtj3.cxx
Executable file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Assam Boudjelthia
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "kxtj3.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
#define SENSOR_ADDR 0x0f
|
||||
#define I2C_BUS 0
|
||||
#define SAMPLE_COUNT 10
|
||||
|
||||
bool isStopped = false;
|
||||
|
||||
void signal_int_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
isStopped = true;
|
||||
}
|
||||
|
||||
void print_acceleration_data(upm::KXTJ3 &dev)
|
||||
{
|
||||
float wait_time = dev.GetAccelerationSamplePeriod() * SECOND_IN_MICRO_S;
|
||||
int sample_counter = SAMPLE_COUNT;
|
||||
std::vector<float> xyz;
|
||||
while ((sample_counter-- > 0) && !isStopped)
|
||||
{
|
||||
xyz = dev.GetAccelerationVector();
|
||||
std::cout << std::fixed << std::setprecision(3)
|
||||
<< xyz[0] << " | " << xyz[1] << " | " << xyz[2] << std::endl;
|
||||
upm_delay_us(wait_time);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, signal_int_handler);
|
||||
|
||||
std::cout << "Sensor init" << std::endl;
|
||||
upm::KXTJ3 dev(I2C_BUS, SENSOR_ADDR);
|
||||
|
||||
std::cout << "Setting settings:\nODR: 25 Hz\nResolution: "
|
||||
<< "High\nAcceleration range: 16g with 14bits" << std::endl;
|
||||
dev.SensorInit(KXTJ3_ODR_25, HIGH_RES, KXTJ3_RANGE_16G_14);
|
||||
std::cout << "Showing acceleration data:" << std::endl;
|
||||
print_acceleration_data(dev);
|
||||
|
||||
std::cout << "Closing sensor" << std::endl;
|
||||
return 0;
|
||||
}
|
81
examples/c++/lis3dh.cxx
Normal file
81
examples/c++/lis3dh.cxx
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2018 Alex Tereschenko.
|
||||
*
|
||||
* Based on LIS2DS12 example by
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "lis3dh.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate an LIS3DH using default I2C parameters
|
||||
upm::LIS3DH sensor;
|
||||
|
||||
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
|
||||
// for CS: LIS3DH(0, -1, 10);
|
||||
|
||||
// now output data every 250 milliseconds
|
||||
while (shouldRun) {
|
||||
float x, y, z;
|
||||
|
||||
sensor.update();
|
||||
|
||||
sensor.getAccelerometer(&x, &y, &z);
|
||||
cout << "Accelerometer x: " << x << " y: " << y << " z: " << z << " g" << endl;
|
||||
|
||||
// we show both C and F for temperature
|
||||
cout << "Compensation Temperature: " << sensor.getTemperature() << " C / "
|
||||
<< sensor.getTemperature(true) << " F" << endl;
|
||||
|
||||
cout << endl;
|
||||
|
||||
upm_delay_us(250000);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -46,22 +46,33 @@ sig_handler(int signo)
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
void
|
||||
nrf_handler()
|
||||
class mycb : public virtual Callback
|
||||
{
|
||||
std::cout << "Reciever :: " << *((uint32_t*) &(comm.m_rxBuffer[0])) << std::endl;
|
||||
}
|
||||
public:
|
||||
mycb(upm::NRF24L01 *com) : _com(com) {}
|
||||
virtual void run()
|
||||
{
|
||||
if (_com != NULL)
|
||||
std::cout << "Reciever :: " << *((uint32_t*) &(_com->m_rxBuffer[0])) << std::endl;
|
||||
else
|
||||
std::cout << "Example callback!" << std::endl;
|
||||
}
|
||||
private:
|
||||
upm::NRF24L01* _com;
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mycb cb(&comm);
|
||||
|
||||
comm.setSourceAddress((uint8_t*) local_address);
|
||||
comm.setDestinationAddress((uint8_t*) broadcast_address);
|
||||
comm.setPayload(MAX_BUFFER);
|
||||
comm.configure();
|
||||
comm.setSpeedRate(upm::NRF_250KBPS);
|
||||
comm.setChannel(99);
|
||||
comm.setDataReceivedHandler(nrf_handler);
|
||||
comm.setDataReceivedHandler(&cb);
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
|
@ -46,10 +46,21 @@ sig_handler(int signo)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nrf_handler()
|
||||
class mycb : public virtual Callback
|
||||
{
|
||||
}
|
||||
public:
|
||||
mycb(upm::NRF24L01 *com) : _com(com) {}
|
||||
virtual void run()
|
||||
{
|
||||
if (_com != NULL)
|
||||
std::cout << "Reciever :: " << *((uint32_t*) &(_com->m_rxBuffer[0])) << std::endl;
|
||||
else
|
||||
std::cout << "Example callback!" << std::endl;
|
||||
}
|
||||
private:
|
||||
upm::NRF24L01* _com;
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
@ -57,12 +68,14 @@ main(int argc, char** argv)
|
||||
//! [Interesting]
|
||||
uint32_t dummyData = 0;
|
||||
upm::NRF24L01 comm(7, 8);
|
||||
mycb cb(&comm);
|
||||
|
||||
comm.setSourceAddress((uint8_t*) srcAddress);
|
||||
comm.setDestinationAddress((uint8_t*) destAddress);
|
||||
comm.setPayload(MAX_BUFFER);
|
||||
comm.setChannel(99);
|
||||
comm.configure();
|
||||
comm.setDataReceivedHandler(nrf_handler);
|
||||
comm.setDataReceivedHandler(&cb);
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
|
@ -42,17 +42,24 @@ sig_handler(int signo)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handler(clbk_data data)
|
||||
|
||||
//! [Interesting]
|
||||
class mycb : public virtual Callback
|
||||
{
|
||||
printf("callback data (%d)\n", data.is_heart_beat);
|
||||
}
|
||||
public:
|
||||
virtual void run(clbk_data arg)
|
||||
{
|
||||
printf("callback data (%d)\n", arg.is_heart_beat);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mycb cb;
|
||||
//! [Interesting]
|
||||
Pulsensor sensor(handler);
|
||||
Pulsensor sensor(&cb);
|
||||
|
||||
sensor.start_sampler();
|
||||
while (!doWork) {
|
||||
|
@ -49,7 +49,7 @@ main(int argc, char** argv)
|
||||
int timezone = -7; // Your UTC offset
|
||||
time_t rawtime;
|
||||
struct tm* gmt;
|
||||
char myTime[5];
|
||||
char myTime[15];
|
||||
|
||||
fprintf(stdout, "TM1637 Display Example\n");
|
||||
signal(SIGINT, sig_handler);
|
||||
@ -66,7 +66,7 @@ main(int argc, char** argv)
|
||||
int hour = (gmt) ? gmt->tm_hour : 0;
|
||||
int min = (gmt) ? gmt->tm_min : 0;
|
||||
// Format and store the time in 24 hour format
|
||||
snprintf(myTime, 5, "%2d%02d", (hour + timezone + 24) % 24, min);
|
||||
snprintf(myTime, 15, "%2d%02d", (hour + timezone + 24) % 24, min);
|
||||
|
||||
myDisplay.write(myTime); // Write to display as string
|
||||
myDisplay.setColon(point ^= true); // Toggle the dots on the display
|
||||
|
@ -38,7 +38,7 @@ main(int argc, char** argv)
|
||||
upm::ZFM20 fp(0);
|
||||
|
||||
// make sure port is initialized properly. 57600 baud is the default.
|
||||
if (!fp.setupTty(B57600)) {
|
||||
if (!fp.setupTty(57600)) {
|
||||
cerr << "Failed to setup tty port parameters" << endl;
|
||||
return 1;
|
||||
}
|
||||
@ -83,7 +83,7 @@ main(int argc, char** argv)
|
||||
|
||||
// we search for a print matching slot 1, where we shored our last
|
||||
// converted fingerprint
|
||||
if ((rv = fp.search(1, &id, &score)) != ZFM20::ERR_OK) {
|
||||
if ((rv = fp.search(1, id, score)) != ZFM20::ERR_OK) {
|
||||
if (rv == ZFM20::ERR_FP_NOTFOUND) {
|
||||
cout << "Finger Print not found" << endl;
|
||||
return 0;
|
||||
|
73
examples/c/bh1749.c
Executable file
73
examples/c/bh1749.c
Executable file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Assam Boudjelthia
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <signal.h>
|
||||
#include "bh1749.h"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
bool isStopped;
|
||||
#define SENSOR_ADDR 0x39
|
||||
#define I2C_BUS 0
|
||||
|
||||
void signal_int_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
isStopped = true;
|
||||
}
|
||||
|
||||
void print_data(void *dev)
|
||||
{
|
||||
uint16_t result[5];
|
||||
bh1749_get_measurements((bh1749_context)dev, result);
|
||||
printf("R: %d, G: %d, B: %d, IR: %d, G2: %d\n", result[0],
|
||||
result[1], result[2], result[3], result[4]);
|
||||
bh1749_reset_interrupt(dev);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, signal_int_handler);
|
||||
|
||||
bh1749_context dev = bh1749_init(I2C_BUS, SENSOR_ADDR);
|
||||
if (!dev) {
|
||||
printf("bh1749_init() failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
bh1749_soft_reset(dev);
|
||||
bh1749_sensor_init(dev, INT_JUDGE_1, MEAS_240MS, RGB_GAIN_1X, IR_GAIN_1X, RED);
|
||||
bh1749_set_threshold_high(dev, 511);
|
||||
bh1749_enable_interrupt(dev);
|
||||
printf("Installing ISR\n");
|
||||
bh1749_install_isr(dev, MRAA_GPIO_EDGE_FALLING, 33, &print_data, (void *)dev);
|
||||
bh1749_enable(dev);
|
||||
|
||||
while(!isStopped) {
|
||||
upm_delay_ms(1000);
|
||||
}
|
||||
|
||||
bh1749_close(dev);
|
||||
return 0;
|
||||
}
|
86
examples/c/bh1792.c
Executable file
86
examples/c/bh1792.c
Executable file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Assam Boudjelthia
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <signal.h>
|
||||
#include "bh1792.h"
|
||||
#include <sys/time.h>
|
||||
#include "upm_utilities.h"
|
||||
|
||||
bool isStopped;
|
||||
#define SENSOR_ADDR 0x5b
|
||||
#define I2C_BUS 0
|
||||
|
||||
void signal_int_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
isStopped = true;
|
||||
}
|
||||
|
||||
void print_data(void *args)
|
||||
{
|
||||
bh1792_context dev = (bh1792_context)args;
|
||||
uint16_t led_on[32], led_off[32];
|
||||
struct timespec now;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
||||
|
||||
if(bh1792_get_fifo_data(dev, led_off, led_on) == UPM_SUCCESS) {
|
||||
printf("\nFIFO data:\n");
|
||||
for(int i = 0; i < 32; i++)
|
||||
printf("%d: off: %d, on: %d\n", i, led_off[i], led_on[i]);
|
||||
|
||||
printf("timestamp %ld sec, %ld nsec\n", now.tv_sec, now.tv_nsec);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
float meas_time;
|
||||
|
||||
signal(SIGINT, signal_int_handler);
|
||||
|
||||
bh1792_context dev = bh1792_init(I2C_BUS, SENSOR_ADDR);
|
||||
if (!dev) {
|
||||
printf("bh1792_init() failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Software reset\n");
|
||||
bh1792_soft_reset(dev);
|
||||
|
||||
bh1792_enable_sync_mode(dev, 256, 32);
|
||||
bh1792_install_isr(dev, MRAA_GPIO_EDGE_FALLING, 33, &print_data, dev);
|
||||
bh1792_get_meas_time_ms(dev, &meas_time);
|
||||
bh1792_start_measurement(dev);
|
||||
|
||||
printf("Heart beat sensor data\n");
|
||||
|
||||
while(!isStopped) {
|
||||
usleep(meas_time * 1000);
|
||||
}
|
||||
|
||||
bh1792_close(dev);
|
||||
return 0;
|
||||
}
|
@ -62,8 +62,7 @@ int main(int argc, char **argv)
|
||||
// update our values for all sensors
|
||||
ds18b20_update(sensor, -1);
|
||||
|
||||
int i;
|
||||
for (i=0; i<ds18b20_devices_found(sensor); i++)
|
||||
for (unsigned int i=0; i<ds18b20_devices_found(sensor); i++)
|
||||
{
|
||||
printf("Device %02d: Temperature: %f C\n",
|
||||
i, ds18b20_get_temperature(sensor, i));
|
||||
|
@ -51,7 +51,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
int ndx = 0;
|
||||
char str[20];
|
||||
char str[23];
|
||||
uint8_t rgb[7][3] = {
|
||||
{0xd1, 0x00, 0x00},
|
||||
{0xff, 0x66, 0x22},
|
||||
|
71
examples/c/kx122.c
Normal file
71
examples/c/kx122.c
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Samuli Rissanen <samuli.rissanen@hotmail.com>
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "kx122.h"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if(signo == SIGINT){
|
||||
shouldRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT,sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
kx122_context sensor = kx122_init(0, -1, 24, 10000);
|
||||
if (!sensor)
|
||||
{
|
||||
printf("kx122_init() failed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
kx122_sensor_software_reset(sensor);
|
||||
kx122_device_init(sensor,KX122_ODR_50,HIGH_RES,KX122_RANGE_2G);
|
||||
|
||||
float x,y,z;
|
||||
int wait_time = (kx122_get_sample_period(sensor) * MICRO_S);
|
||||
if (wait_time < 0) wait_time = 1000;
|
||||
|
||||
while(shouldRun){
|
||||
kx122_get_acceleration_data(sensor,&x,&y,&z);
|
||||
|
||||
printf("%.02f | %.02f | %.02f\n",x,y,z);
|
||||
upm_delay_us(wait_time);
|
||||
}
|
||||
|
||||
kx122_close(sensor);
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
75
examples/c/kxtj3.c
Executable file
75
examples/c/kxtj3.c
Executable file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Assam Boudjelthia
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* 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 "kxtj3.h"
|
||||
|
||||
#define SENSOR_ADDR 0x0f
|
||||
#define I2C_BUS 0
|
||||
#define SAMPLE_COUNT 10
|
||||
|
||||
bool isStopped = false;
|
||||
|
||||
void signal_int_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
isStopped = true;
|
||||
}
|
||||
|
||||
void print_acceleration_data(kxtj3_context dev)
|
||||
{
|
||||
float wait_time = kxtj3_get_acceleration_sampling_period(dev) * SECOND_IN_MICRO_S;
|
||||
uint8_t sample_counter = 0;
|
||||
float x, y, z;
|
||||
while (sample_counter < SAMPLE_COUNT && !isStopped)
|
||||
{
|
||||
kxtj3_get_acceleration_data(dev, &x, &y, &z);
|
||||
printf("%.02f | %.02f | %.02f\n", x, y, z);
|
||||
usleep(wait_time);
|
||||
sample_counter++;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, signal_int_handler);
|
||||
|
||||
printf("Sensor init\n");
|
||||
kxtj3_context dev = kxtj3_init(I2C_BUS, SENSOR_ADDR);
|
||||
if (!dev)
|
||||
{
|
||||
printf("kxtj3_init() failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Setting settings:\nODR: 25 Hz\nResolution: High\nAcceleration range: 16g with 14bits");
|
||||
kxtj3_sensor_init(dev, KXTJ3_ODR_25, HIGH_RES, KXTJ3_RANGE_16G_14);
|
||||
printf("Showing acceleration data:\n");
|
||||
print_acceleration_data(dev);
|
||||
|
||||
printf("Closing sensor\n");
|
||||
kxtj3_close(dev);
|
||||
return 0;
|
||||
}
|
97
examples/c/lis3dh.c
Normal file
97
examples/c/lis3dh.c
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2018 Alex Tereschenko.
|
||||
*
|
||||
* Based on LIS2DS12 example by
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lis3dh.h"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
|
||||
#if defined(CONFIG_BOARD_ARDUINO_101_SSS)
|
||||
// ARDUINO_101_SSS (ARC core) must use I2C
|
||||
// Instantiate a LIS3DH instance using default i2c bus and address
|
||||
lis3dh_context sensor = lis3dh_init(LIS3DH_DEFAULT_I2C_BUS, LIS3DH_DEFAULT_I2C_ADDR, -1);
|
||||
#elif defined(CONFIG_BOARD_ARDUINO_101)
|
||||
// ARDUINO_101 (Quark core) must use SPI
|
||||
// Instantiate a LIS3DH instance using default SPI bus and pin 10 as CS
|
||||
lis3dh_context sensor = lis3dh_init(LIS3DH_DEFAULT_SPI_BUS, -1, 10);
|
||||
#else
|
||||
// everything else use I2C by default
|
||||
// Instantiate a LIS3DH instance using default i2c bus and address
|
||||
lis3dh_context sensor = lis3dh_init(LIS3DH_DEFAULT_I2C_BUS, LIS3DH_DEFAULT_I2C_ADDR, -1);
|
||||
#endif
|
||||
|
||||
if (!sensor) {
|
||||
printf("lis3dh_init() failed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// now output data every 250 milliseconds
|
||||
while (shouldRun) {
|
||||
float x, y, z;
|
||||
|
||||
if (lis3dh_update(sensor)) {
|
||||
printf("lis3dh_update() failed\n");
|
||||
lis3dh_close(sensor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lis3dh_get_accelerometer(sensor, &x, &y, &z);
|
||||
printf("Acceleration x: %f y: %f z: %f g\n", x, y, z);
|
||||
|
||||
printf("Compensation Temperature: %f C\n\n", lis3dh_get_temperature(sensor));
|
||||
|
||||
upm_delay_ms(250);
|
||||
}
|
||||
|
||||
printf("Exiting...\n");
|
||||
|
||||
lis3dh_close(sensor);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class A110XSample {
|
||||
public class A110X_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
@ -22,10 +22,13 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class A110X_intrSample {
|
||||
public class A110X_intr_Example {
|
||||
|
||||
public static int counter=0;
|
||||
|
||||
private static int counter=0;
|
||||
|
||||
public static void incrementCounter() {
|
||||
counter++;
|
||||
}
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate an A110X sensor on digital pin D2
|
||||
@ -52,6 +55,6 @@ class A110XISR implements Runnable {
|
||||
super();
|
||||
}
|
||||
public void run(){
|
||||
A110X_intrSample.counter++;
|
||||
A110X_intr_Example.incrementCounter();
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class ADC121C021Sample {
|
||||
public class ADC121C021_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
import upm_am2315.AM2315;
|
||||
|
||||
public class AM2315Example {
|
||||
public class AM2315_Example {
|
||||
|
||||
static {
|
||||
try {
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class APA102Sample {
|
||||
public class APA102_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
import upm_ad8232.AD8232;
|
||||
|
||||
public class Ad8232Example {
|
||||
public class Ad8232_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
@ -31,7 +31,7 @@ import java.io.*;
|
||||
import java.util.concurrent.*;
|
||||
import upm_ads1x15.*;
|
||||
|
||||
public class Ads1015Sample
|
||||
public class Ads1015_Example
|
||||
{
|
||||
static boolean running = true;
|
||||
static int id = 0; // Sample number
|
@ -30,7 +30,7 @@ import java.io.*;
|
||||
import java.util.concurrent.*;
|
||||
import upm_ads1x15.*;
|
||||
|
||||
public class Ads1115Sample
|
||||
public class Ads1115_Example
|
||||
{
|
||||
static boolean running = true;
|
||||
static int id = 0; // Sample number
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class Adxl345Sample {
|
||||
public class Adxl345_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -24,7 +24,7 @@
|
||||
|
||||
import upm_apds9002.APDS9002;
|
||||
|
||||
public class Apds9002 {
|
||||
public class Apds9002_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
53
examples/java/BH1749_Example.java
Executable file
53
examples/java/BH1749_Example.java
Executable file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Assam Boudjelthia
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* 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 BH1749_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
int sampleCounter = 10;
|
||||
long waitTime;
|
||||
upm_bh1749.BH1749 bh1749;
|
||||
upm_bh1749.uint16Vector result;
|
||||
|
||||
bh1749 = new upm_bh1749.BH1749();
|
||||
bh1749.SensorInit(upm_bh1749.OPERATING_MODES.INT_JUDGE_1,
|
||||
upm_bh1749.MEAS_TIMES.MEAS_240MS, upm_bh1749.RGB_GAINS.RGB_GAIN_1X,
|
||||
upm_bh1749.IR_GAINS.IR_GAIN_1X, upm_bh1749.INT_SOURCES.RED);
|
||||
bh1749.SetThresholdHigh(511);
|
||||
bh1749.Enable();
|
||||
|
||||
waitTime = bh1749.GetMeasurementTime();
|
||||
System.out.println("Color readings");
|
||||
while (sampleCounter-- > 0) {
|
||||
result = bh1749.GetMeasurements();
|
||||
System.out.println("R: " + result.get(0) + ", G: " + result.get(1) +
|
||||
", B: " + result.get(2) + ", IR: " + result.get(3) +
|
||||
", G2: " + result.get(4));
|
||||
|
||||
Thread.sleep((long) waitTime);
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
}
|
69
examples/java/BH1792_Example.java
Executable file
69
examples/java/BH1792_Example.java
Executable file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: Assam Boudjelthia
|
||||
* Copyright (c) 2018 Rohm Semiconductor.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//! [Interesting]
|
||||
public class BH1792_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
int sampleCounter = 20;
|
||||
float waitTime;
|
||||
upm_bh1792.BH1792 bh1792;
|
||||
|
||||
bh1792 = new upm_bh1792.BH1792();
|
||||
BH1792ISR callback = new BH1792ISR(bh1792);
|
||||
|
||||
bh1792.SoftReset();
|
||||
bh1792.EnableSyncMode(256, 32);
|
||||
|
||||
bh1792.InstallISR(33, callback);
|
||||
|
||||
waitTime = bh1792.GetMeasurementTimeMS();
|
||||
bh1792.StartMeasurement();
|
||||
|
||||
System.out.println("Heart rate sensor readings");
|
||||
while (true) {
|
||||
Thread.sleep((long) waitTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BH1792ISR implements Runnable {
|
||||
|
||||
upm_bh1792.intVector2D result;
|
||||
upm_bh1792.BH1792 bh1792;
|
||||
|
||||
public BH1792ISR(upm_bh1792.BH1792 bh1792) {
|
||||
super();
|
||||
this.bh1792 = bh1792;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
result = this.bh1792.GetFifoData();
|
||||
for(int i = 0; i < 32; i++)
|
||||
System.out.println(i + ": off: " + result.get(i).get(0) +
|
||||
", on: " + result.get(i).get(1));
|
||||
System.out.println("Timestamp: " + System.nanoTime() + " nsec\n");
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class BISS0001Sample{
|
||||
public class BISS0001_Example{
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class BMA220Sample {
|
||||
public class BMA220_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -26,7 +26,7 @@
|
||||
import upm_bmp280.*;
|
||||
import upm_interfaces.*;
|
||||
|
||||
public class BME280_InterfaceExample
|
||||
public class BME280_Interface_Example
|
||||
{
|
||||
public static void main(String[] args) throws InterruptedException
|
||||
{
|
@ -23,7 +23,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class BMPX8XSample {
|
||||
public class BMPX8X_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class ButtonSample {
|
||||
public class Button_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -22,11 +22,14 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class Button_intrSample {
|
||||
public class Button_intr_Example {
|
||||
|
||||
public static int counter = 0;
|
||||
private static int counter = 0;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
public static void incrementCounter() {
|
||||
counter++;
|
||||
}
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_button.Button b = new upm_button.Button(2);
|
||||
|
||||
@ -47,7 +50,7 @@ class ButtonISR implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
Button_intrSample.counter++;
|
||||
Button_intr_Example.incrementCounter();
|
||||
System.out.println("Button pressed!");
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
import upm_buzzer.Buzzer;
|
||||
public class BuzzerSample {
|
||||
public class Buzzer_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class CJQ4435Sample {
|
||||
public class CJQ4435_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
|
@ -1,223 +1,264 @@
|
||||
# The purpose of this CMakeLists.txt is to compile all listed JAVA examples
|
||||
# during build time (ensuring that ALL examples compile against their
|
||||
# dependency JAVA packages).
|
||||
|
||||
find_package(Java REQUIRED)
|
||||
include(UseJava)
|
||||
|
||||
macro(add_example example_name jar_name)
|
||||
set(example_src "${example_name}.java")
|
||||
set(example_jar "${CMAKE_CURRENT_BINARY_DIR}/../../src/${jar_name}/upm_${jar_name}.jar")
|
||||
# Add a JAVA example target for the provided JAVA source file which depends
|
||||
# on UPM JAVA targets.
|
||||
#
|
||||
# Usage:
|
||||
# add_example(example_class_name upm_target_dependency_list)
|
||||
#
|
||||
# Parameters:
|
||||
# example_class_name: JAVA class name. This name MUST match the JAVA
|
||||
# example file name.
|
||||
# <example_class_name>.java
|
||||
# upm_target_dependency_list: One or more UPM library targets. This
|
||||
# function assumes a javaupm_<target> also exists.
|
||||
#
|
||||
# Examples:
|
||||
# # Creates SensorFooExample JAVA target, depends on target: sensorfoo,
|
||||
# # and will add upm_sensorfoo.jar to the javac classpath.
|
||||
# add_example(SensorFooExample sensorfoo)
|
||||
#
|
||||
# # Creates SensorFooExample JAVA target, depends on targets: sensorfoo,
|
||||
# # and interfaces and will add both upm_sensorfoo.jar and upm_interfaces.jar
|
||||
# # to the javac classpath.
|
||||
# add_example(SensorFooExample "sensorfoo;interfaces"")
|
||||
#
|
||||
function(add_example example_class_name dependency_list)
|
||||
set(example_file "${example_class_name}.java")
|
||||
|
||||
add_jar(${example_name} SOURCES ${example_src} INCLUDE_JARS ${example_jar})
|
||||
add_dependencies(${example_name} javaupm_${jar_name})
|
||||
endmacro()
|
||||
# Build a list of all dependency jar files
|
||||
set(jar_file_list "")
|
||||
|
||||
macro(add_example_with_path example_name jar_path jar_name)
|
||||
set(example_src "${example_name}.java")
|
||||
set(example_jar "${CMAKE_CURRENT_BINARY_DIR}/../../src/${jar_path}/upm_${jar_name}.jar")
|
||||
# Build a list of all dependency java target names
|
||||
set(java_targets_list "")
|
||||
|
||||
add_jar(${example_name} SOURCES ${example_src} INCLUDE_JARS ${example_jar})
|
||||
add_dependencies(${example_name} javaupm_${jar_name})
|
||||
endmacro()
|
||||
# Iterate over the dependencies
|
||||
foreach(dependency ${dependency_list})
|
||||
set(java_target "javaupm_${dependency}")
|
||||
|
||||
macro(add_example_multiple_jars example_name example_jar_name jar_name_list)
|
||||
set(example_src "${example_name}.java")
|
||||
# Append to the targets list
|
||||
list(APPEND java_targets_list ${java_target})
|
||||
|
||||
set(list_of_jars "")
|
||||
foreach(jar_name ${jar_name_list})
|
||||
set(example_jar "${CMAKE_CURRENT_BINARY_DIR}/../../src/${jar_name}/upm_${jar_name}.jar")
|
||||
list(APPEND list_of_jars ${example_jar})
|
||||
# If a dependency target does NOT exist, print a warning and skip
|
||||
if (NOT TARGET ${java_target})
|
||||
message(STATUS "Example ${example_file} is missing a required CMake target (${java_target}), skipping...")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Get the jar for this java_target (saved as a property)
|
||||
get_target_property(jar_file ${java_target} JAR_FILE_ABSOLUTE)
|
||||
|
||||
# Append to the jar list
|
||||
list(APPEND jar_file_list ${jar_file})
|
||||
endforeach()
|
||||
|
||||
add_jar(${example_name} SOURCES ${example_src} INCLUDE_JARS ${list_of_jars})
|
||||
add_dependencies(${example_name} javaupm_${example_jar_name})
|
||||
endmacro()
|
||||
# Add the jar/s
|
||||
add_jar(${example_class_name} SOURCES ${example_file} INCLUDE_JARS ${jar_file_list})
|
||||
|
||||
add_example(A110X_intrSample a110x)
|
||||
add_example(A110XSample a110x)
|
||||
add_example(ADC121C021Sample adc121c021)
|
||||
add_example(Adxl345Sample adxl345)
|
||||
add_example(Apds9002 apds9002)
|
||||
add_example(BISS0001Sample biss0001)
|
||||
add_example_multiple_jars(BMPX8XSample bmpx8x "bmpx8x;interfaces")
|
||||
add_example(BuzzerSample buzzer)
|
||||
add_example(CJQ4435Sample cjq4435)
|
||||
add_example(DS1307Sample ds1307)
|
||||
add_example(ENC03RSample enc03r)
|
||||
add_example(ES08ASample servo)
|
||||
add_example(ButtonSample button)
|
||||
add_example(GroveButtonSample grove)
|
||||
add_example(Button_intrSample button)
|
||||
add_example(GroveButton_intrSample grove)
|
||||
add_example(Collision collision)
|
||||
add_example(EHRSample ehr)
|
||||
add_example(GroveEHRSample groveehr)
|
||||
add_example(Emg emg)
|
||||
add_example(GroveEmg groveemg)
|
||||
add_example(Gsr gsr)
|
||||
add_example(GroveGsr grovegsr)
|
||||
add_example(LEDSample led)
|
||||
add_example(LightSample light)
|
||||
add_example(GroveLightSample grove)
|
||||
add_example(GroveLineFinderSample grovelinefinder)
|
||||
add_example(LineFinderSample linefinder)
|
||||
add_example(GroveLed_multiSample grove)
|
||||
add_example(GroveLEDSample grove)
|
||||
add_example(GroveMDSample grovemd)
|
||||
add_example(MDSample md)
|
||||
add_example(MoistureSample moisture)
|
||||
add_example(GroveMoistureSample grovemoisture)
|
||||
add_example(GroveMQ3 gas)
|
||||
add_example(GroveMQ9 gas)
|
||||
add_example(O2Example o2)
|
||||
add_example(GroveO2Example groveo2)
|
||||
add_example(GroveQTouch at42qt1070)
|
||||
add_example(RelaySample relay)
|
||||
add_example(GroveRelaySample grove)
|
||||
add_example(RotarySample rotary)
|
||||
add_example(GroveRotarySample grove)
|
||||
add_example(GROVESCAMSample grovescam)
|
||||
add_example(SCAMSample scam)
|
||||
add_example(SlideSample slide)
|
||||
add_example(GroveSlideSample grove)
|
||||
add_example(SpeakerSample speaker)
|
||||
add_example(GroveSpeakerSample grovespeaker)
|
||||
add_example(TemperatureSample temperature)
|
||||
add_example(GroveTempSample grove)
|
||||
add_example(VDivSample vdiv)
|
||||
add_example(GroveVDivSample grovevdiv)
|
||||
add_example(WaterSample water)
|
||||
add_example(GroveWaterSample grovewater)
|
||||
add_example(GroveWFSSample grovewfs)
|
||||
add_example(WFSSample wfs)
|
||||
add_example(GUVAS12DSample guvas12d)
|
||||
add_example(H3LIS331DLSample h3lis331dl)
|
||||
add_example(HCSR04Sample hcsr04)
|
||||
add_example(HM11Sample hm11)
|
||||
add_example(Hmc5883lSample hmc5883l)
|
||||
add_example(HMTRPSample hmtrp)
|
||||
add_example(HP20xExample hp20x)
|
||||
add_example(HTU21DSample htu21d)
|
||||
add_example(Itg3200Sample itg3200)
|
||||
add_example(Joystick12Sample joystick12)
|
||||
add_example(LDT0028Sample ldt0028)
|
||||
add_example(LoLSample lol)
|
||||
add_example(LSM303DLHSample lsm303dlh)
|
||||
add_example(M24LR64ESample m24lr64e)
|
||||
add_example(MAX44000Sample max44000)
|
||||
add_example(MHZ16Sample mhz16)
|
||||
add_example(MicrophoneSample mic)
|
||||
add_example(MMA7455Sample mma7455)
|
||||
add_example(MMA7660Sample mma7660)
|
||||
add_example(MPL3115A2Sample mpl3115a2)
|
||||
add_example(MPR121Sample mpr121)
|
||||
add_example(MPU9150Sample mpu9150)
|
||||
add_example(MQ2Sample gas)
|
||||
add_example(MQ303ASample mq303a)
|
||||
add_example(MQ5Sample gas)
|
||||
add_example(GroveLEDBar my9221)
|
||||
add_example(NRF24L01_receiverSample nrf24l01)
|
||||
add_example(NRF24L01_transmitterSample nrf24l01)
|
||||
add_example(NUNCHUCKSample nunchuck)
|
||||
add_example(OTP538USample otp538u)
|
||||
add_example(PPD42NSSample ppd42ns)
|
||||
add_example(PulsensorSample pulsensor)
|
||||
add_example(RFR359FSample rfr359f)
|
||||
add_example(RotaryEncoderSample rotaryencoder)
|
||||
add_example(RPR220_intrSample rpr220)
|
||||
add_example(RPR220Sample rpr220)
|
||||
add_example(ST7735Sample st7735)
|
||||
if (NOT ANDROID)
|
||||
add_example(StepMotorSample stepmotor)
|
||||
endif ()
|
||||
add_example(TM1637Sample tm1637)
|
||||
add_example(TP401Sample gas)
|
||||
add_example(TSL2561Sample tsl2561)
|
||||
add_example(TTP223Sample ttp223)
|
||||
add_example(ULN200XASample uln200xa)
|
||||
add_example(WaterLevelSensor waterlevel)
|
||||
add_example(WT5001Sample wt5001)
|
||||
add_example(YG1006Sample yg1006)
|
||||
add_example(ZFM20Sample zfm20)
|
||||
add_example(Ad8232Example ad8232)
|
||||
add_example(Gp2y0aExample gp2y0a)
|
||||
add_example(Th02Example th02)
|
||||
add_example(FlexSensorExample flex)
|
||||
add_example(CWLSXXA_Example cwlsxxa)
|
||||
add_example(TEAMS_Example teams)
|
||||
add_example(APA102Sample apa102)
|
||||
add_example(TEX00_Example tex00)
|
||||
add_example(BMI160_Example bmi160)
|
||||
add_example(Tsl2561 tsl2561)
|
||||
add_example(AM2315Example am2315)
|
||||
add_example(MAX31855Example max31855)
|
||||
add_example(MAX5487Example max5487)
|
||||
add_example(MAXds3231mExample maxds3231m)
|
||||
add_example(ECS1030Example ecs1030)
|
||||
add_example(SM130Example sm130)
|
||||
if (MODBUS_FOUND)
|
||||
add_example(H803X_Example h803x)
|
||||
endif()
|
||||
if (BACNET_FOUND)
|
||||
add_example(E50HX_Example e50hx)
|
||||
add_example(T8100_Example t8100)
|
||||
add_example(TB7300_Example tb7300)
|
||||
endif()
|
||||
if (JPEG_FOUND)
|
||||
add_example(VCAP_Example vcap)
|
||||
endif()
|
||||
add_example_multiple_jars(BMP280_Example bmp280 "bmp280;interfaces")
|
||||
add_example(BNO055_Example bno055)
|
||||
add_example(BMX055_Example bmx055)
|
||||
add_example(NMEAGPS_Example nmea_gps)
|
||||
add_example(MMA7361_Example mma7361)
|
||||
# Add a dependency from this jar to all dependency java targets
|
||||
add_dependencies(${example_class_name} ${java_targets_list})
|
||||
endfunction()
|
||||
|
||||
add_example(A110X_Example a110x)
|
||||
add_example(A110X_intr_Example a110x)
|
||||
add_example(Ad8232_Example ad8232)
|
||||
add_example(ADC121C021_Example adc121c021)
|
||||
add_example(Ads1015_Example "ads1x15;interfaces")
|
||||
add_example(Ads1115_Example ads1x15)
|
||||
add_example(Adxl345_Example adxl345)
|
||||
add_example(AM2315_Example am2315)
|
||||
add_example(APA102_Example apa102)
|
||||
add_example(Apds9002_Example apds9002)
|
||||
add_example(BH1749_Example bh1749)
|
||||
add_example(BH1750_Example bh1750)
|
||||
add_example(HKA5_Example hka5)
|
||||
add_example(DFRORP_Example dfrorp)
|
||||
add_example(DFREC_Example dfrec)
|
||||
add_example(SHT1X_Example sht1x)
|
||||
add_example(MS5803_Example ms5803)
|
||||
add_example(ECEZO_Example ecezo)
|
||||
add_example(IMS_Example ims)
|
||||
add_example(MB704X_Example mb704x)
|
||||
add_example(MCP2515_Example mcp2515)
|
||||
add_example_multiple_jars(Ads1015Sample ads1x15 "ads1x15;interfaces")
|
||||
add_example(MAX30100_Example max30100)
|
||||
add_example(Ads1115Sample ads1x15)
|
||||
add_example(SensorTemplateSample sensortemplate)
|
||||
add_example(P9813Sample p9813)
|
||||
add_example(BMG160_Example bmg160)
|
||||
add_example(BH1792_Example bh1792)
|
||||
add_example(BISS0001_Example biss0001)
|
||||
add_example(BMA250E_Example bma250e)
|
||||
add_example(BMC150_Example bmx055)
|
||||
add_example(BME280_Example "bmp280;interfaces")
|
||||
add_example(BMG160_Example bmg160)
|
||||
add_example(BMI055_Example bmx055)
|
||||
add_example(BMI160_Example bmi160)
|
||||
add_example(BMM150_Example bmm150)
|
||||
add_example(BMP280_Example "bmp280;interfaces")
|
||||
add_example(BMPX8X_Example "bmpx8x;interfaces")
|
||||
add_example(BMX055_Example bmx055)
|
||||
add_example(BNO055_Example bno055)
|
||||
add_example(Button_Example button)
|
||||
add_example(Button_intr_Example button)
|
||||
add_example(Buzzer_Example buzzer)
|
||||
add_example(CJQ4435_Example cjq4435)
|
||||
add_example(Collision_Example collision)
|
||||
add_example(CWLSXXA_Example cwlsxxa)
|
||||
add_example(DFREC_Example dfrec)
|
||||
add_example(DFRORP_Example dfrorp)
|
||||
add_example(DS1307_Example ds1307)
|
||||
add_example(ECEZO_Example ecezo)
|
||||
add_example(ECS1030_Example ecs1030)
|
||||
add_example(EHR_Example ehr)
|
||||
add_example(Emg_Example emg)
|
||||
add_example(ENC03R_Example enc03r)
|
||||
add_example(ES08A_Example "servo;interfaces")
|
||||
add_example(FlexSensor_Example flex)
|
||||
add_example(Gp2y0a_Example gp2y0a)
|
||||
add_example(GroveButton_Example grove)
|
||||
add_example(GroveButton_intr_Example grove)
|
||||
add_example(GroveEHR_Example groveehr)
|
||||
add_example(GroveEmg_Example groveemg)
|
||||
add_example(GroveGsr_Example grovegsr)
|
||||
add_example(GroveLEDBar_Example my9221)
|
||||
add_example(GroveLED_Example grove)
|
||||
add_example(GroveLed_multi_Example grove)
|
||||
add_example(GroveLight_Example grove)
|
||||
add_example(GroveLineFinder_Example grovelinefinder)
|
||||
add_example(GroveMD_Example grovemd)
|
||||
add_example(GroveMoisture_Example grovemoisture)
|
||||
add_example(GroveMQ3_Example gas)
|
||||
add_example(GroveMQ9_Example gas)
|
||||
add_example(GroveO2_Example groveo2)
|
||||
add_example(GroveQTouch_Example at42qt1070)
|
||||
add_example(GroveRelay_Example grove)
|
||||
add_example(GroveRotary_Example grove)
|
||||
add_example(GROVESCAM_Example grovescam)
|
||||
add_example(GroveSlide_Example grove)
|
||||
add_example(GroveSpeaker_Example grovespeaker)
|
||||
add_example(GroveTemp_Example grove)
|
||||
add_example(GroveVDiv_Example grovevdiv)
|
||||
add_example(GroveWater_Example grovewater)
|
||||
add_example(GroveWFS_Example grovewfs)
|
||||
add_example(Gsr_Example gsr)
|
||||
add_example(GUVAS12D_Example guvas12d)
|
||||
add_example(H3LIS331DL_Example h3lis331dl)
|
||||
add_example(HCSR04_Example hcsr04)
|
||||
add_example(HKA5_Example hka5)
|
||||
add_example(HM11_Example hm11)
|
||||
add_example(Hmc5883l_Example hmc5883l)
|
||||
add_example(HMTRP_Example hmtrp)
|
||||
add_example(HP20x_Example hp20x)
|
||||
add_example(HTU21D_Example htu21d)
|
||||
add_example(Itg3200_Example itg3200)
|
||||
add_example(Jhd1313m1_Example jhd1313m1)
|
||||
add_example(Jhd1313m1_lcd_Example jhd1313m1)
|
||||
add_example(Joystick12_Example joystick12)
|
||||
add_example(KX122_Example kx122)
|
||||
add_example(KXTJ3_Example kxtj3)
|
||||
add_example(Lcm1602_i2c_Example lcm1602)
|
||||
add_example(Lcm1602_parallel_Example lcm1602)
|
||||
add_example(LDT0028_Example ldt0028)
|
||||
add_example(LE910_Example uartat)
|
||||
add_example(LED_Example led)
|
||||
add_example(Light_Example light)
|
||||
add_example(LineFinder_Example linefinder)
|
||||
add_example(LIS2DS12_Example lis2ds12)
|
||||
add_example(LoL_Example lol)
|
||||
add_example(LSM303AGR_Example lsm303agr)
|
||||
add_example(LSM303D_Example lsm303d)
|
||||
add_example(VEML6070Sample veml6070)
|
||||
add_example(RN2903_Example rn2903)
|
||||
add_example(LIS2DS12_Example lis2ds12)
|
||||
add_example(LSM303DLH_Example lsm303dlh)
|
||||
add_example(LSM6DS3H_Example lsm6ds3h)
|
||||
add_example(LSM6DSL_Example lsm6dsl)
|
||||
|
||||
add_example_with_path(Jhd1313m1_lcdSample jhd1313m1 jhd1313m1)
|
||||
add_example_with_path(Jhd1313m1Sample jhd1313m1 jhd1313m1)
|
||||
add_example_with_path(Lcm1602_i2cSample lcm1602 lcm1602)
|
||||
add_example_with_path(Lcm1602_parallelSample lcm1602 lcm1602)
|
||||
add_example_with_path(SSD1308_oledSample lcd i2clcd)
|
||||
add_example_with_path(SSD1327_oledSample lcd i2clcd)
|
||||
add_example_multiple_jars(BME280_Example bmp280 "bmp280;interfaces")
|
||||
add_example(M24LR64E_Example m24lr64e)
|
||||
add_example(MAX30100_Example max30100)
|
||||
add_example(MAX31855_Example max31855)
|
||||
add_example(MAX44000_Example max44000)
|
||||
add_example(MAX5487_Example max5487)
|
||||
add_example(MAXds3231m_Example maxds3231m)
|
||||
add_example(MB704X_Example mb704x)
|
||||
add_example(MCP2515_Example mcp2515)
|
||||
add_example(MCP2515_TXRX_Example mcp2515)
|
||||
add_example(MD_Example md)
|
||||
add_example(MHZ16_Example mhz16)
|
||||
add_example(Microphone_Example mic)
|
||||
add_example(MMA7361_Example mma7361)
|
||||
add_example(MMA7455_Example mma7455)
|
||||
add_example(MMA7660_Example mma7660)
|
||||
add_example(Moisture_Example moisture)
|
||||
add_example(MPL3115A2_Example mpl3115a2)
|
||||
add_example(MPR121_Example mpr121)
|
||||
add_example(MPU9150_Example mpu9150)
|
||||
add_example(MQ2_Example gas)
|
||||
add_example(MQ303A_Example mq303a)
|
||||
add_example(MQ5_Example gas)
|
||||
add_example(MS5803_Example ms5803)
|
||||
add_example(NMEAGPS_Example nmea_gps)
|
||||
add_example(NMEAGPS_I2C_Example nmea_gps)
|
||||
add_example(NRF24L01_receiver_Example nrf24l01)
|
||||
add_example(NRF24L01_transmitter_Example nrf24l01)
|
||||
add_example(NUNCHUCK_Example nunchuck)
|
||||
add_example(O2_Example o2)
|
||||
add_example(OTP538U_Example otp538u)
|
||||
add_example(P9813_Example p9813)
|
||||
add_example(PPD42NS_Example ppd42ns)
|
||||
add_example(Pulsensor_Example pulsensor)
|
||||
add_example(Relay_Example relay)
|
||||
add_example(RFR359F_Example rfr359f)
|
||||
add_example(RN2903_Example rn2903)
|
||||
add_example(RN2903_P2P_RX_Example rn2903)
|
||||
add_example(RN2903_P2P_TX_Example rn2903)
|
||||
add_example(RotaryEncoder_Example rotaryencoder)
|
||||
add_example(Rotary_Example rotary)
|
||||
add_example(RPR220_Example rpr220)
|
||||
add_example(RPR220_intr_Example rpr220)
|
||||
add_example(SCAM_Example scam)
|
||||
add_example(SensorTemplate_Example sensortemplate)
|
||||
add_example(SHT1X_Example sht1x)
|
||||
add_example(Slide_Example slide)
|
||||
add_example(SM130_Example sm130)
|
||||
add_example(Speaker_Example speaker)
|
||||
add_example(SpeakerPWM_Example speaker)
|
||||
add_example(SSD1308_oled_Example lcd)
|
||||
add_example(SSD1327_oled_Example lcd)
|
||||
add_example(ST7735_Example st7735)
|
||||
add_example(TEAMS_Example teams)
|
||||
add_example(Temperature_Example temperature)
|
||||
add_example(TEX00_Example tex00)
|
||||
add_example(Th02_Example th02)
|
||||
add_example(TM1637_Example tm1637)
|
||||
add_example(TP401_Example gas)
|
||||
add_example(TSL2561_Example tsl2561)
|
||||
add_example(TTP223_Example ttp223)
|
||||
add_example(ULN200XA_Example uln200xa)
|
||||
add_example(VDiv_Example vdiv)
|
||||
add_example(VEML6070_Example veml6070)
|
||||
add_example(Water_Example water)
|
||||
add_example(WaterLevelSensor_Example waterlevel)
|
||||
add_example(WFS_Example wfs)
|
||||
add_example(WT5001_Example wt5001)
|
||||
add_example(YG1006_Example yg1006)
|
||||
add_example(ZFM20_Example zfm20)
|
||||
|
||||
if(SWIG_VERSION VERSION_GREATER 3.0.8)
|
||||
add_example_multiple_jars(BME280_InterfaceExample bmp280 "bmp280;interfaces")
|
||||
add_example(BME280_Interface_Example "bmp280;interfaces")
|
||||
add_example(IMS_Example "ims;interfaces")
|
||||
add_example(RHUSB_Example "rhusb;interfaces")
|
||||
endif()
|
||||
|
||||
add_example_with_path(BMC150_Example bmx055 bmx055)
|
||||
add_example_with_path(BMI055_Example bmx055 bmx055)
|
||||
if (OPENZWAVE_FOUND)
|
||||
add_example_with_path(AeotecSS6_Example ozw ozw)
|
||||
add_example_with_path(AeotecSDG2_Example ozw ozw)
|
||||
add_example_with_path(AeotecDW2E_Example ozw ozw)
|
||||
add_example_with_path(AeotecDSB09104_Example ozw ozw)
|
||||
add_example_with_path(TZEMT400_Example ozw ozw)
|
||||
add_example(AeotecDSB09104_Example ozw)
|
||||
add_example(AeotecDW2E_Example ozw)
|
||||
add_example(AeotecSDG2_Example ozw)
|
||||
add_example(AeotecSS6_Example ozw)
|
||||
add_example(TZEMT400_Example ozw)
|
||||
endif()
|
||||
add_example_with_path(NMEAGPS_I2C_Example nmea_gps nmea_gps)
|
||||
add_example_with_path(MCP2515_TXRX_Example mcp2515 mcp2515)
|
||||
add_example_with_path(LE910_Example uartat uartat)
|
||||
add_example_with_path(SpeakerPWMSample speaker speaker)
|
||||
add_example_with_path(RN2903_P2P_RX_Example rn2903 rn2903)
|
||||
add_example_with_path(RN2903_P2P_TX_Example rn2903 rn2903)
|
||||
|
||||
if (MODBUS_FOUND)
|
||||
add_example(H803X_Example h803x)
|
||||
endif()
|
||||
|
||||
if (BACNET_FOUND)
|
||||
add_example(E50HX_Example e50hx)
|
||||
add_example(T8100_Example t8100)
|
||||
add_example(TB7300_Example tb7300)
|
||||
endif()
|
||||
|
||||
if (JPEG_FOUND)
|
||||
add_example(VCAP_Example vcap)
|
||||
endif()
|
||||
|
||||
if (NOT ANDROID)
|
||||
add_example(StepMotor_Example stepmotor)
|
||||
endif ()
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
import upm_collision.*;
|
||||
|
||||
public class Collision {
|
||||
public class Collision_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Initializing the sensor on D2 on the Base Shield
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class DFRPHSample {
|
||||
public class DFRPH_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class DS1307Sample {
|
||||
public class DS1307_Example {
|
||||
|
||||
static private void printTime(upm_ds1307.DS1307 rtc) {
|
||||
System.out.print("The time is: " + rtc.getMonth() + "/" + rtc.getDayOfMonth() + "/"
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
import upm_ecs1030.ECS1030;
|
||||
|
||||
public class ECS1030Example {
|
||||
public class ECS1030_Example {
|
||||
|
||||
static {
|
||||
try {
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class EHRSample {
|
||||
public class EHR_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
|
||||
public class ENC03RSample {
|
||||
public class ENC03R_Example {
|
||||
private static final long CALIBRATION_SAMPLES = 1000;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class ES08ASample {
|
||||
public class ES08A_Example {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_servo.ES08A servo = new upm_servo.ES08A(6);
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
import upm_emg.EMG;
|
||||
|
||||
public class Emg {
|
||||
public class Emg_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
@ -1,6 +1,6 @@
|
||||
import upm_flex.Flex;
|
||||
|
||||
public class FlexSensorExample {
|
||||
public class FlexSensor_Example {
|
||||
|
||||
static {
|
||||
try {
|
||||
@ -32,7 +32,7 @@ public class FlexSensorExample {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.out.println(e.toString());
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class GROVESCAMSample {
|
||||
public class GROVESCAM_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -23,7 +23,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GUVAS12DSample {
|
||||
public class GUVAS12D_Example {
|
||||
// analog voltage, usually 3.3 or 5.0
|
||||
private static final float GUVAS12D_AREF = 5;
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
import upm_gp2y0a.GP2Y0A;
|
||||
|
||||
public class Gp2y0aExample {
|
||||
public class Gp2y0a_Example {
|
||||
|
||||
public static final float GP2Y0A_AREF = 5;
|
||||
public static final short SAMPLES_PER_QUERY = 20;
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveButtonSample {
|
||||
public class GroveButton_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -22,10 +22,13 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveButton_intrSample {
|
||||
public class GroveButton_intr_Example {
|
||||
|
||||
public static int counter = 0;
|
||||
private static int counter = 0;
|
||||
|
||||
public static void incrementCounter() {
|
||||
counter++;
|
||||
}
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_grove.GroveButton b = new upm_grove.GroveButton(2);
|
||||
@ -47,7 +50,7 @@ class ButtonISR implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
GroveButton_intrSample.counter++;
|
||||
GroveButton_intr_Example.incrementCounter();
|
||||
System.out.println("Button pressed!");
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
|
||||
import upm_grovecollision.*;
|
||||
|
||||
public class GroveCollision {
|
||||
public class GroveCollision_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Initializing the sensor on D2 on the Base Shield
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class GroveEHRSample {
|
||||
public class GroveEHR_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
import upm_groveemg.GroveEMG;
|
||||
|
||||
public class GroveEmg {
|
||||
public class GroveEmg_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
@ -24,7 +24,7 @@
|
||||
|
||||
import upm_grovegsr.GroveGSR;
|
||||
|
||||
public class GroveGsr {
|
||||
public class GroveGsr_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveLEDBar {
|
||||
public class GroveLEDBar_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveLEDSample {
|
||||
public class GroveLED_Example {
|
||||
public static void main (String args[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
upm_grove.GroveLed led = new upm_grove.GroveLed(2);
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class GroveLed_multiSample {
|
||||
public class GroveLed_multi_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveLightSample {
|
||||
public class GroveLight_Example {
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_grove.GroveLight gl = new upm_grove.GroveLight(2);
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveLineFinderSample {
|
||||
public class GroveLineFinder_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveMDSample {
|
||||
public class GroveMD_Example {
|
||||
private static final short speed50 = 127;
|
||||
private static final short speed0 = 0;
|
||||
|
@ -34,7 +34,7 @@ import upm_gas.MQ9;
|
||||
import upm_gas.TP401;
|
||||
import upm_gas.thresholdContext;
|
||||
|
||||
public class GroveMQ3 {
|
||||
public class GroveMQ3_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
@ -34,7 +34,7 @@ import upm_gas.MQ9;
|
||||
import upm_gas.TP401;
|
||||
import upm_gas.thresholdContext;
|
||||
|
||||
public class GroveMQ9 {
|
||||
public class GroveMQ9_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveMoistureSample {
|
||||
public class GroveMoisture_Example {
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_grovemoisture.GroveMoisture gm = new upm_grovemoisture.GroveMoisture(1);
|
@ -24,7 +24,7 @@
|
||||
|
||||
import upm_groveo2.GroveO2;
|
||||
|
||||
public class GroveO2Example {
|
||||
public class GroveO2_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
@ -24,7 +24,7 @@
|
||||
|
||||
import upm_at42qt1070.AT42QT1070;
|
||||
|
||||
public class GroveQTouch {
|
||||
public class GroveQTouch_Example {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
@ -40,7 +40,7 @@ public class GroveQTouch {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.out.println(e.toString());
|
||||
}
|
||||
}
|
||||
// ! [Interesting]
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveRelaySample {
|
||||
public class GroveRelay_Example {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
// Create the button object using UART
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveRotarySample {
|
||||
public class GroveRotary_Example {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveSlideSample {
|
||||
public class GroveSlide_Example {
|
||||
public static void main (String args[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// Instantiate new grove slide potentiometer on analog pin A0
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user