diff -Nru upm-1.6.0/cmake/modules/FindUpmCordovaGenerator.cmake upm-1.7.1/cmake/modules/FindUpmCordovaGenerator.cmake --- upm-1.6.0/cmake/modules/FindUpmCordovaGenerator.cmake 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/cmake/modules/FindUpmCordovaGenerator.cmake 2018-10-12 04:47:41.000000000 +0000 @@ -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) diff -Nru upm-1.6.0/CMakeLists.txt upm-1.7.1/CMakeLists.txt --- upm-1.6.0/CMakeLists.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -8,6 +8,7 @@ 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 @@ # 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) @@ -125,7 +130,7 @@ # Force a libmraa search and minimum required version every time a config is generated unset(MRAA_FOUND CACHE) -set(MRAA_MINIMUM 1.9.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}) @@ -165,6 +170,17 @@ 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) @@ -213,7 +229,7 @@ git_describe (VERSION "--tags") # If git_describe fails, use a dirty version if (${VERSION} MATCHES -NOTFOUND) - set (VERSION "v1.6.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 () @@ -275,37 +291,36 @@ 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") @@ -317,12 +332,17 @@ 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 C/C++ 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") @@ -335,11 +355,28 @@ # 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 -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 \; @@ -348,10 +385,12 @@ 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||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 Python 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 () @@ -361,19 +400,22 @@ 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 Javascript 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 @@ -455,7 +497,12 @@ 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 COMPONENT ${CMAKE_PROJECT_NAME}-dev - FILES_MATCHING PATTERN "*.h") + FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp") diff -Nru upm-1.6.0/debian/changelog upm-1.7.1/debian/changelog --- upm-1.6.0/debian/changelog 2018-02-20 16:37:24.000000000 +0000 +++ upm-1.7.1/debian/changelog 2018-10-18 15:17:10.000000000 +0000 @@ -1,3 +1,9 @@ +upm (1.7.1-1~ubuntu18.04) bionic; urgency=medium + + * Update to upm 1.7.1 + + -- Tom Ingleby Thu, 18 Oct 2018 15:16:39 +0000 + upm (1.6.0-1~ubuntu18.04) bionic; urgency=medium * Upgrade to upm 1.6.0 diff -Nru upm-1.6.0/debian/patches/make-yuidoc-optional.patch upm-1.7.1/debian/patches/make-yuidoc-optional.patch --- upm-1.6.0/debian/patches/make-yuidoc-optional.patch 2018-02-20 16:47:49.000000000 +0000 +++ upm-1.7.1/debian/patches/make-yuidoc-optional.patch 2018-10-18 15:38:03.000000000 +0000 @@ -1,20 +1,20 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -359,7 +359,7 @@ +@@ -398,7 +398,7 @@ # Check if Yuidoc is installed and add target for API documentation if(BUILDSWIGNODE) - find_package (Yuidoc 0.10 REQUIRED) + find_package (Yuidoc 0.10) if (YUIDOC_FOUND AND YUIDOC_VERSION VERSION_GREATER "0.10") - add_custom_target (jsdoc ALL - COMMAND ${CMAKE_SOURCE_DIR}/doxy/doxygen2jsdoc/docgen.js -m upm -i xml -o jsdoc -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../ -@@ -370,7 +370,7 @@ - COMMENT "Generating Javascript API documentation with Yuidoc" VERBATIM - ) + add_custom_command ( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/jsdoc/jsdoc.stamp +@@ -412,7 +412,7 @@ + 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") + message (INFO "ERROR - Failed to find a compatible version of Yuidoc. Node.js API doc will not be generated") endif () endif(BUILDSWIGNODE) - endif (BUILDDOC) + endfunction() diff -Nru upm-1.6.0/docker-compose.yaml upm-1.7.1/docker-compose.yaml --- upm-1.6.0/docker-compose.yaml 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/docker-compose.yaml 2018-10-12 04:47:41.000000000 +0000 @@ -13,8 +13,10 @@ - BUILDFTI=${BUILDFTI:-ON} - BUILDSWIGPYTHON=${BUILDSWIGPYTHON:-OFF} - BUILDSWIGJAVA=${BUILDSWIGJAVA:-OFF} + - BUILDCORDOVA=${BUILDCORDOVA:-OFF} - BUILDSWIGNODE=${BUILDSWIGNODE:-OFF} - BUILDEXAMPLES=${BUILDEXAMPLES:-OFF} + - CMAKE_BUILD_TYPE - IPK=${IPK:-OFF} - RPM=${RPM:-OFF} - NPM=${NPM:-OFF} @@ -30,6 +32,12 @@ extends: base 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: @@ -107,6 +115,13 @@ - 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: inteliotdevkit/upm-node4 diff -Nru upm-1.6.0/docs/apichanges.md upm-1.7.1/docs/apichanges.md --- upm-1.6.0/docs/apichanges.md 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/docs/apichanges.md 2018-10-12 04:47:41.000000000 +0000 @@ -4,6 +4,18 @@ 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 diff -Nru upm-1.6.0/docs/building.md upm-1.7.1/docs/building.md --- upm-1.6.0/docs/building.md 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/docs/building.md 2018-10-12 04:47:41.000000000 +0000 @@ -96,13 +96,16 @@ 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 diff -Nru upm-1.6.0/docs/changelog.md upm-1.7.1/docs/changelog.md --- upm-1.6.0/docs/changelog.md 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/docs/changelog.md 2018-10-12 04:47:41.000000000 +0000 @@ -4,6 +4,22 @@ 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 diff -Nru upm-1.6.0/docs/creating_java_bindings.md upm-1.7.1/docs/creating_java_bindings.md --- upm-1.6.0/docs/creating_java_bindings.md 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/docs/creating_java_bindings.md 2018-10-12 04:47:41.000000000 +0000 @@ -259,7 +259,7 @@ 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/javaupm_a110x.i: +src/a110x/a110x.i: ```c++ JAVA_ADD_INSTALLISR(upm::A110X) ``` Binary files /tmp/tmpkLMFjy/Z8hOxu4eBa/upm-1.6.0/docs/icons/allides.png and /tmp/tmpkLMFjy/8mUJE6mPoN/upm-1.7.1/docs/icons/allides.png differ Binary files /tmp/tmpkLMFjy/Z8hOxu4eBa/upm-1.6.0/docs/icons/wyliodrin.png and /tmp/tmpkLMFjy/8mUJE6mPoN/upm-1.7.1/docs/icons/wyliodrin.png differ Binary files /tmp/tmpkLMFjy/Z8hOxu4eBa/upm-1.6.0/docs/icons/xdk.png and /tmp/tmpkLMFjy/8mUJE6mPoN/upm-1.7.1/docs/icons/xdk.png differ Binary files /tmp/tmpkLMFjy/Z8hOxu4eBa/upm-1.6.0/docs/images/kxtj3.png and /tmp/tmpkLMFjy/8mUJE6mPoN/upm-1.7.1/docs/images/kxtj3.png differ diff -Nru upm-1.6.0/docs/images/LICENSE_CC_3_0.txt upm-1.7.1/docs/images/LICENSE_CC_3_0.txt --- upm-1.6.0/docs/images/LICENSE_CC_3_0.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/docs/images/LICENSE_CC_3_0.txt 1970-01-01 00:00:00.000000000 +0000 @@ -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/. - diff -Nru upm-1.6.0/docs/installing.md upm-1.7.1/docs/installing.md --- upm-1.6.0/docs/installing.md 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/docs/installing.md 2018-10-12 04:47:41.000000000 +0000 @@ -54,6 +54,18 @@ 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. diff -Nru upm-1.6.0/docs/max31855.md upm-1.7.1/docs/max31855.md --- upm-1.6.0/docs/max31855.md 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/docs/max31855.md 2018-10-12 04:47:41.000000000 +0000 @@ -14,8 +14,7 @@ * 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. diff -Nru upm-1.6.0/doxy/index.rst upm-1.7.1/doxy/index.rst --- upm-1.6.0/doxy/index.rst 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/doxy/index.rst 2018-10-12 04:47:41.000000000 +0000 @@ -23,15 +23,6 @@ Individual sensor usage examples for Python are available `here `_. -``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`` ############################## diff -Nru upm-1.6.0/doxy/node/generators/yuidoc/tmpl/partials/index.handlebars upm-1.7.1/doxy/node/generators/yuidoc/tmpl/partials/index.handlebars --- upm-1.6.0/doxy/node/generators/yuidoc/tmpl/partials/index.handlebars 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/doxy/node/generators/yuidoc/tmpl/partials/index.handlebars 2018-10-12 04:47:41.000000000 +0000 @@ -36,19 +36,6 @@ href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here.

-
-

IDE Compatibility - UPM*

- - -

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.
- -

-

Building UPM +#include +#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; +} \ No newline at end of file diff -Nru upm-1.6.0/examples/c/bh1792.c upm-1.7.1/examples/c/bh1792.c --- upm-1.6.0/examples/c/bh1792.c 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/c/bh1792.c 2018-10-12 04:47:41.000000000 +0000 @@ -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 +#include +#include "bh1792.h" +#include +#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; +} \ No newline at end of file diff -Nru upm-1.6.0/examples/c/jhd1313m1.c upm-1.7.1/examples/c/jhd1313m1.c --- upm-1.6.0/examples/c/jhd1313m1.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/c/jhd1313m1.c 2018-10-12 04:47:41.000000000 +0000 @@ -51,7 +51,7 @@ } int ndx = 0; - char str[20]; + char str[23]; uint8_t rgb[7][3] = { {0xd1, 0x00, 0x00}, {0xff, 0x66, 0x22}, diff -Nru upm-1.6.0/examples/c/kx122.c upm-1.7.1/examples/c/kx122.c --- upm-1.6.0/examples/c/kx122.c 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/c/kx122.c 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,71 @@ +/* +* The MIT License (MIT) +* +* Author: Samuli Rissanen +* 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 +#include +#include + +#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; +} diff -Nru upm-1.6.0/examples/c/kxtj3.c upm-1.7.1/examples/c/kxtj3.c --- upm-1.6.0/examples/c/kxtj3.c 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/c/kxtj3.c 2018-10-12 04:47:41.000000000 +0000 @@ -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 +#include +#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; +} diff -Nru upm-1.6.0/examples/c++/bh1749.cxx upm-1.7.1/examples/c++/bh1749.cxx --- upm-1.6.0/examples/c++/bh1749.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/c++/bh1749.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -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 +#include +#include +#include +#include +#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 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] diff -Nru upm-1.6.0/examples/c++/bh1792.cxx upm-1.7.1/examples/c++/bh1792.cxx --- upm-1.6.0/examples/c++/bh1792.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/c++/bh1792.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -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 +#include +#include +#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> 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] diff -Nru upm-1.6.0/examples/c++/kx122.cxx upm-1.7.1/examples/c++/kx122.cxx --- upm-1.6.0/examples/c++/kx122.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/c++/kx122.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,65 @@ +/* +* The MIT License (MIT) +* +* Author: Samuli Rissanen +* 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 + +#include +#include + +#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; +} diff -Nru upm-1.6.0/examples/c++/kxtj3.cxx upm-1.7.1/examples/c++/kxtj3.cxx --- upm-1.6.0/examples/c++/kxtj3.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/c++/kxtj3.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -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 +#include +#include +#include +#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 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; +} diff -Nru upm-1.6.0/examples/c++/tm1637.cxx upm-1.7.1/examples/c++/tm1637.cxx --- upm-1.6.0/examples/c++/tm1637.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/c++/tm1637.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -49,7 +49,7 @@ 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 @@ 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 diff -Nru upm-1.6.0/examples/CMakeLists.txt upm-1.7.1/examples/CMakeLists.txt --- upm-1.6.0/examples/CMakeLists.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -120,7 +120,7 @@ # Add all examples as an install component (if building examples) install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples - DESTINATION ${CMAKE_INSTALL_DATADIR}/upm/ + DESTINATION ${CMAKE_INSTALL_DATADIR}/upm COMPONENT ${CMAKE_PROJECT_NAME}-examples FILES_MATCHING PATTERN "*.c" diff -Nru upm-1.6.0/examples/java/A110X_Example.java upm-1.7.1/examples/java/A110X_Example.java --- upm-1.6.0/examples/java/A110X_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/A110X_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class A110X_Example { + + public static void main(String[] args) throws InterruptedException { + //! [Interesting] + // Instantiate an A110X sensor on digital pin D2 + upm_a110x.A110X hall = new upm_a110x.A110X(2); + + // check every second for the presence of a magnetic field (south polarity) + while(true){ + if(hall.magnetDetected()) + System.out.println("Magnet (south polarity) detected."); + else + System.out.println("No magnet detected."); + + Thread.sleep(1000); + } + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/A110X_intr_Example.java upm-1.7.1/examples/java/A110X_intr_Example.java --- upm-1.6.0/examples/java/A110X_intr_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/A110X_intr_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class A110X_intr_Example { + + 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 + upm_a110x.A110X hall = new upm_a110x.A110X(2); + + // This example uses a user-supplied interrupt handler to count + // pulses that occur when a magnetic field of the correct polarity + // is detected. This could be used to measure the rotations per + // minute (RPM) of a rotor for example. + + A110XISR callback = new A110XISR(); + hall.installISR(callback); + + while(true){ + System.out.println("Counter: " + counter); + Thread.sleep(1000); + } + //! [Interesting] + } +} + +class A110XISR implements Runnable { + public A110XISR(){ + super(); + } + public void run(){ + A110X_intr_Example.incrementCounter(); + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/A110X_intrSample.java upm-1.7.1/examples/java/A110X_intrSample.java --- upm-1.6.0/examples/java/A110X_intrSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/A110X_intrSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class A110X_intrSample { - - public static int counter=0; - - public static void main(String[] args) throws InterruptedException { - //! [Interesting] - // Instantiate an A110X sensor on digital pin D2 - upm_a110x.A110X hall = new upm_a110x.A110X(2); - - // This example uses a user-supplied interrupt handler to count - // pulses that occur when a magnetic field of the correct polarity - // is detected. This could be used to measure the rotations per - // minute (RPM) of a rotor for example. - - A110XISR callback = new A110XISR(); - hall.installISR(callback); - - while(true){ - System.out.println("Counter: " + counter); - Thread.sleep(1000); - } - //! [Interesting] - } -} - -class A110XISR implements Runnable { - public A110XISR(){ - super(); - } - public void run(){ - A110X_intrSample.counter++; - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/A110XSample.java upm-1.7.1/examples/java/A110XSample.java --- upm-1.6.0/examples/java/A110XSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/A110XSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class A110XSample { - - public static void main(String[] args) throws InterruptedException { - //! [Interesting] - // Instantiate an A110X sensor on digital pin D2 - upm_a110x.A110X hall = new upm_a110x.A110X(2); - - // check every second for the presence of a magnetic field (south polarity) - while(true){ - if(hall.magnetDetected()) - System.out.println("Magnet (south polarity) detected."); - else - System.out.println("No magnet detected."); - - Thread.sleep(1000); - } - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Ad8232_Example.java upm-1.7.1/examples/java/Ad8232_Example.java --- upm-1.6.0/examples/java/Ad8232_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Ad8232_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* +* Author: Abhishek Malik +* Copyright (c) 2016 Intel Corporation. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +import upm_ad8232.AD8232; + +public class Ad8232_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // Instantiate a Ad8232 sensor on digital pins 10 (LO+), 11 (LO-) + // and an analog pin, 0 (OUTPUT) + AD8232 ad8232 = new AD8232(10, 11, 0); + while(true){ + // Output the raw numbers from the ADC, for plotting elsewhere. + // A return of 0 indicates a Lead Off (LO) condition. + // In theory, this data could be fed to software like Processing + // (https://www.processing.org/) to plot the data just like an + // EKG you would see in a hospital. + System.out.println(ad8232.value()); + try { + Thread.sleep(1); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following error has occurred: "+e.getMessage()); + } + } + } + +} diff -Nru upm-1.6.0/examples/java/Ad8232Example.java upm-1.7.1/examples/java/Ad8232Example.java --- upm-1.6.0/examples/java/Ad8232Example.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Ad8232Example.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* -* Author: Abhishek Malik -* Copyright (c) 2016 Intel Corporation. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -import upm_ad8232.AD8232; - -public class Ad8232Example { - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // Instantiate a Ad8232 sensor on digital pins 10 (LO+), 11 (LO-) - // and an analog pin, 0 (OUTPUT) - AD8232 ad8232 = new AD8232(10, 11, 0); - while(true){ - // Output the raw numbers from the ADC, for plotting elsewhere. - // A return of 0 indicates a Lead Off (LO) condition. - // In theory, this data could be fed to software like Processing - // (https://www.processing.org/) to plot the data just like an - // EKG you would see in a hospital. - System.out.println(ad8232.value()); - try { - Thread.sleep(1); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following error has occurred: "+e.getMessage()); - } - } - } - -} diff -Nru upm-1.6.0/examples/java/ADC121C021_Example.java upm-1.7.1/examples/java/ADC121C021_Example.java --- upm-1.6.0/examples/java/ADC121C021_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/ADC121C021_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class ADC121C021_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate an ADC121C021 on I2C bus 0 + upm_adc121c021.ADC121C021 adc = new upm_adc121c021.ADC121C021(0); + + // An analog sensor, such as a Grove light sensor, + // must be attached to the adc + // Prints the value and corresponding voltage every 50 milliseconds + while (true) { + int val = adc.value(); + + System.out.println("ADC value: " + val + "Volts = " + adc.valueToVolts(val)); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/ADC121C021Sample.java upm-1.7.1/examples/java/ADC121C021Sample.java --- upm-1.6.0/examples/java/ADC121C021Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/ADC121C021Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class ADC121C021Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate an ADC121C021 on I2C bus 0 - upm_adc121c021.ADC121C021 adc = new upm_adc121c021.ADC121C021(0); - - // An analog sensor, such as a Grove light sensor, - // must be attached to the adc - // Prints the value and corresponding voltage every 50 milliseconds - while (true) { - int val = adc.value(); - - System.out.println("ADC value: " + val + "Volts = " + adc.valueToVolts(val)); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/Ads1015_Example.java upm-1.7.1/examples/java/Ads1015_Example.java --- upm-1.6.0/examples/java/Ads1015_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Ads1015_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,100 @@ +/* + * Author: Mihai Tudor Panu + * Copyright (c) 2016 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. + */ + +/* This example demonstrates how to use one the ADS1015 ADC on the Grove Joule + * Shield or the Sparkfun ADC Block for Edison with devices that output a small + * differential voltage (e.g. geophones, piezoelectric bands or pads, + * thermocouples). + */ +import java.io.*; +import java.util.concurrent.*; +import upm_ads1x15.*; + +public class Ads1015_Example +{ + static boolean running = true; + static int id = 0; // Sample number + static String fileName = "./ads1015.data"; // Output filename + + public static void main(String[] args) throws InterruptedException + { + // Open the output file + FileWriter fw = null; + BufferedWriter bw = null; + try { + fw = new FileWriter(fileName); + bw = new BufferedWriter(fw); + } catch (IOException e) { + System.out.println("Failed to open output file for writing: " + e.toString()); + System.exit(1); + } + + // Initialize and configure the ADS1015 + ADS1015 ads1015 = new ADS1015(0, (short)0x48); + + // Put the ADC into differential mode for pins A0 and A1 + ads1015.getSample(ADS1X15.ADSMUXMODE.DIFF_0_1); + + // Set the gain based on expected VIN range to -/+ 2.048 V + // Can be adjusted based on application to as low as -/+ 0.256 V, see API + // documentation for details + ads1015.setGain(ADS1X15.ADSGAIN.GAIN_TWO); + + // Set the sample rate to 3300 samples per second (max) and turn on continuous + // sampling + ads1015.setSPS(ADS1015.ADSSAMPLERATE.SPS_3300); + ads1015.setContinuous(true); + + // Schedule a task to stop logging after 10 seconds + Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() { + @Override + public void run() { + running = false; + } + }, 10, TimeUnit.SECONDS); + + // Read from sensor and write to file every ms + while(running){ + try { + bw.write(id + " " + String.format("%.7f", ads1015.getLastSample()) + "\n"); + } catch (IOException e) { + System.out.println("Failed to write sample " + id + " to file: "+ e.toString()); + System.exit(1); + } + id++; + Thread.sleep(1); + } + + // Close and exit + try { + bw.close(); + fw.close(); + } catch (IOException e) { + System.out.println("Failed to close output file cleanly: " + e.toString()); + System.exit(1); + } + System.out.println("Wrote " + id + " samples to file: " + fileName); + System.exit(0); + } +} diff -Nru upm-1.6.0/examples/java/Ads1015Sample.java upm-1.7.1/examples/java/Ads1015Sample.java --- upm-1.6.0/examples/java/Ads1015Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Ads1015Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -/* - * Author: Mihai Tudor Panu - * Copyright (c) 2016 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. - */ - -/* This example demonstrates how to use one the ADS1015 ADC on the Grove Joule - * Shield or the Sparkfun ADC Block for Edison with devices that output a small - * differential voltage (e.g. geophones, piezoelectric bands or pads, - * thermocouples). - */ -import java.io.*; -import java.util.concurrent.*; -import upm_ads1x15.*; - -public class Ads1015Sample -{ - static boolean running = true; - static int id = 0; // Sample number - static String fileName = "./ads1015.data"; // Output filename - - public static void main(String[] args) throws InterruptedException - { - // Open the output file - FileWriter fw = null; - BufferedWriter bw = null; - try { - fw = new FileWriter(fileName); - bw = new BufferedWriter(fw); - } catch (IOException e) { - System.out.println("Failed to open output file for writing: " + e.toString()); - System.exit(1); - } - - // Initialize and configure the ADS1015 - ADS1015 ads1015 = new ADS1015(0, (short)0x48); - - // Put the ADC into differential mode for pins A0 and A1 - ads1015.getSample(ADS1X15.ADSMUXMODE.DIFF_0_1); - - // Set the gain based on expected VIN range to -/+ 2.048 V - // Can be adjusted based on application to as low as -/+ 0.256 V, see API - // documentation for details - ads1015.setGain(ADS1X15.ADSGAIN.GAIN_TWO); - - // Set the sample rate to 3300 samples per second (max) and turn on continuous - // sampling - ads1015.setSPS(ADS1015.ADSSAMPLERATE.SPS_3300); - ads1015.setContinuous(true); - - // Schedule a task to stop logging after 10 seconds - Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() { - @Override - public void run() { - running = false; - } - }, 10, TimeUnit.SECONDS); - - // Read from sensor and write to file every ms - while(running){ - try { - bw.write(id + " " + String.format("%.7f", ads1015.getLastSample()) + "\n"); - } catch (IOException e) { - System.out.println("Failed to write sample " + id + " to file: "+ e.toString()); - System.exit(1); - } - id++; - Thread.sleep(1); - } - - // Close and exit - try { - bw.close(); - fw.close(); - } catch (IOException e) { - System.out.println("Failed to close output file cleanly: " + e.toString()); - System.exit(1); - } - System.out.println("Wrote " + id + " samples to file: " + fileName); - System.exit(0); - } -} diff -Nru upm-1.6.0/examples/java/Ads1115_Example.java upm-1.7.1/examples/java/Ads1115_Example.java --- upm-1.6.0/examples/java/Ads1115_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Ads1115_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,103 @@ +/* + * Author: Mihai Tudor Panu + * Copyright (c) 2016 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. + */ + +/* This example demonstrates how to use one of the ADS1115 ADCs on the + * DFRobot Joule Shield with devices that output a small differential + * voltage (e.g. geophones, piezoelectric bands or pads, thermocouples). + */ +import java.io.*; +import java.util.concurrent.*; +import upm_ads1x15.*; + +public class Ads1115_Example +{ + static boolean running = true; + static int id = 0; // Sample number + static String fileName = "./ads1115.data"; // Output filename + + public static void main(String[] args) throws InterruptedException + { + // Open the output file + FileWriter fw = null; + BufferedWriter bw = null; + try { + fw = new FileWriter(fileName); + bw = new BufferedWriter(fw); + } catch (IOException e) { + System.out.println("Failed to open output file for writing: " + e.toString()); + System.exit(1); + } + + // Initialize and configure the ADS1115 for the SM-24 Geophone + // There are two ADS1115 chips on the DFRobot Joule Shield on the same I2C bus + // - 0x48 gives access to pins A0 - A3 + // - 0x49 gives access to pins A4 - A7 + ADS1115 ads1115 = new ADS1115(0, (short)0x48); + + // Put the ADC into differential mode for pins A0 and A1, + // the SM-24 Geophone is connected to these pins + ads1115.getSample(ADS1X15.ADSMUXMODE.DIFF_0_1); + + // Set the gain based on expected VIN range to -/+ 2.048 V + // Can be adjusted based on application to as low as -/+ 0.256 V, see API + // documentation for details + ads1115.setGain(ADS1X15.ADSGAIN.GAIN_TWO); + + // Set the sample rate to 860 samples per second (max) and turn on continuous + // sampling + ads1115.setSPS(ADS1115.ADSDATARATE.SPS_860); + ads1115.setContinuous(true); + + // Schedule a task to stop logging after 10 seconds + Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() { + @Override + public void run() { + running = false; + } + }, 10, TimeUnit.SECONDS); + + // Read from sensor and write to file every ms + while(running){ + try { + bw.write(id + " " + String.format("%.7f", ads1115.getLastSample()) + "\n"); + } catch (IOException e) { + System.out.println("Failed to write sample " + id + " to file: "+ e.toString()); + System.exit(1); + } + id++; + Thread.sleep(1); + } + + // Close and exit + try { + bw.close(); + fw.close(); + } catch (IOException e) { + System.out.println("Failed to close output file cleanly: " + e.toString()); + System.exit(1); + } + System.out.println("Wrote " + id + " samples to file: " + fileName); + System.exit(0); + } +} diff -Nru upm-1.6.0/examples/java/Ads1115Sample.java upm-1.7.1/examples/java/Ads1115Sample.java --- upm-1.6.0/examples/java/Ads1115Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Ads1115Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -/* - * Author: Mihai Tudor Panu - * Copyright (c) 2016 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. - */ - -/* This example demonstrates how to use one of the ADS1115 ADCs on the - * DFRobot Joule Shield with devices that output a small differential - * voltage (e.g. geophones, piezoelectric bands or pads, thermocouples). - */ -import java.io.*; -import java.util.concurrent.*; -import upm_ads1x15.*; - -public class Ads1115Sample -{ - static boolean running = true; - static int id = 0; // Sample number - static String fileName = "./ads1115.data"; // Output filename - - public static void main(String[] args) throws InterruptedException - { - // Open the output file - FileWriter fw = null; - BufferedWriter bw = null; - try { - fw = new FileWriter(fileName); - bw = new BufferedWriter(fw); - } catch (IOException e) { - System.out.println("Failed to open output file for writing: " + e.toString()); - System.exit(1); - } - - // Initialize and configure the ADS1115 for the SM-24 Geophone - // There are two ADS1115 chips on the DFRobot Joule Shield on the same I2C bus - // - 0x48 gives access to pins A0 - A3 - // - 0x49 gives access to pins A4 - A7 - ADS1115 ads1115 = new ADS1115(0, (short)0x48); - - // Put the ADC into differential mode for pins A0 and A1, - // the SM-24 Geophone is connected to these pins - ads1115.getSample(ADS1X15.ADSMUXMODE.DIFF_0_1); - - // Set the gain based on expected VIN range to -/+ 2.048 V - // Can be adjusted based on application to as low as -/+ 0.256 V, see API - // documentation for details - ads1115.setGain(ADS1X15.ADSGAIN.GAIN_TWO); - - // Set the sample rate to 860 samples per second (max) and turn on continuous - // sampling - ads1115.setSPS(ADS1115.ADSDATARATE.SPS_860); - ads1115.setContinuous(true); - - // Schedule a task to stop logging after 10 seconds - Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() { - @Override - public void run() { - running = false; - } - }, 10, TimeUnit.SECONDS); - - // Read from sensor and write to file every ms - while(running){ - try { - bw.write(id + " " + String.format("%.7f", ads1115.getLastSample()) + "\n"); - } catch (IOException e) { - System.out.println("Failed to write sample " + id + " to file: "+ e.toString()); - System.exit(1); - } - id++; - Thread.sleep(1); - } - - // Close and exit - try { - bw.close(); - fw.close(); - } catch (IOException e) { - System.out.println("Failed to close output file cleanly: " + e.toString()); - System.exit(1); - } - System.out.println("Wrote " + id + " samples to file: " + fileName); - System.exit(0); - } -} diff -Nru upm-1.6.0/examples/java/Adxl345_Example.java upm-1.7.1/examples/java/Adxl345_Example.java --- upm-1.6.0/examples/java/Adxl345_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Adxl345_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,51 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class Adxl345_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + short[] val; + float[] accel; + + // Note: Sensor only works at 3.3V on the Intel Edison with Arduino + // breakout + upm_adxl345.Adxl345 sensor = new upm_adxl345.Adxl345(0); + + while (true) { + sensor.update(); + val = sensor.getRawValues(); + accel = sensor.getAcceleration(); + + System.out.println("Current scale: " + sensor.getScale()); + System.out.println("Raw Values: X: " + val[0] + " Y: " + val[1] + " Z: " + val[2]); + System.out.println("Acceleration: X: " + accel[0] + "g Y: " + accel[1] + "g Z: " + + accel[2] + "g"); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Adxl345Sample.java upm-1.7.1/examples/java/Adxl345Sample.java --- upm-1.6.0/examples/java/Adxl345Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Adxl345Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class Adxl345Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - short[] val; - float[] accel; - - // Note: Sensor only works at 3.3V on the Intel Edison with Arduino - // breakout - upm_adxl345.Adxl345 sensor = new upm_adxl345.Adxl345(0); - - while (true) { - sensor.update(); - val = sensor.getRawValues(); - accel = sensor.getAcceleration(); - - System.out.println("Current scale: " + sensor.getScale()); - System.out.println("Raw Values: X: " + val[0] + " Y: " + val[1] + " Z: " + val[2]); - System.out.println("Acceleration: X: " + accel[0] + "g Y: " + accel[1] + "g Z: " - + accel[2] + "g"); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/AM2315_Example.java upm-1.7.1/examples/java/AM2315_Example.java --- upm-1.6.0/examples/java/AM2315_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/AM2315_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import upm_am2315.AM2315; + +public class AM2315_Example { + + static { + try { + System.loadLibrary("javaupm_am2315"); + System.loadLibrary("mraajava"); + } catch (UnsatisfiedLinkError e) { + System.err.println( + "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + + e); + System.exit(1); + } + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + float humidity = 0; + float temperature = 0; + + // Instantiate the sensor + AM2315 sensor = new AM2315(0, upm_am2315.javaupm_am2315Constants.AM2315_I2C_ADDRESS); + sensor.testSensor(); + + while(true){ + // retrieving the humidity and temperature values + humidity = sensor.getHumidity(); + temperature = sensor.getTemperature(); + + System.out.println("Temperature : "+temperature+" Humidity: "+humidity); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/AM2315Example.java upm-1.7.1/examples/java/AM2315Example.java --- upm-1.6.0/examples/java/AM2315Example.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/AM2315Example.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_am2315.AM2315; - -public class AM2315Example { - - static { - try { - System.loadLibrary("javaupm_am2315"); - System.loadLibrary("mraajava"); - } catch (UnsatisfiedLinkError e) { - System.err.println( - "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + - e); - System.exit(1); - } - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - float humidity = 0; - float temperature = 0; - - // Instantiate the sensor - AM2315 sensor = new AM2315(0, upm_am2315.javaupm_am2315Constants.AM2315_I2C_ADDRESS); - sensor.testSensor(); - - while(true){ - // retrieving the humidity and temperature values - humidity = sensor.getHumidity(); - temperature = sensor.getTemperature(); - - System.out.println("Temperature : "+temperature+" Humidity: "+humidity); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/APA102_Example.java upm-1.7.1/examples/java/APA102_Example.java --- upm-1.6.0/examples/java/APA102_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/APA102_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Author: Yannick Adam + * Copyright (c) 2016 Yannick Adam + * + * 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 APA102_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a strip of 30 LEDs on SPI bus 0 + upm_apa102.APA102 ledStrip = + new upm_apa102.APA102(30, (short)0, false, (byte)-1); + + System.out.println("Set all LEDs to blue"); + ledStrip.setAllLeds((short)31, (short)0, (short)0, (short)255); + + System.out.println("Set LEDs between 10 and 20 to green"); + ledStrip.setLeds(10, 20, (short)31, (short)0, (short)255, (short)0); + + System.out.println("Set a single LED to red at index 15"); + ledStrip.setLed(15, (short)31, (short)255, (short)0, (short)0); + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/APA102Sample.java upm-1.7.1/examples/java/APA102Sample.java --- upm-1.6.0/examples/java/APA102Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/APA102Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Yannick Adam - * Copyright (c) 2016 Yannick Adam - * - * 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 APA102Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a strip of 30 LEDs on SPI bus 0 - upm_apa102.APA102 ledStrip = - new upm_apa102.APA102(30, (short)0, false, (byte)-1); - - System.out.println("Set all LEDs to blue"); - ledStrip.setAllLeds((short)31, (short)0, (short)0, (short)255); - - System.out.println("Set LEDs between 10 and 20 to green"); - ledStrip.setLeds(10, 20, (short)31, (short)0, (short)255, (short)0); - - System.out.println("Set a single LED to red at index 15"); - ledStrip.setLed(15, (short)31, (short)255, (short)0, (short)0); - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Apds9002_Example.java upm-1.7.1/examples/java/Apds9002_Example.java --- upm-1.6.0/examples/java/Apds9002_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Apds9002_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_apds9002.APDS9002; + +public class Apds9002_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // Instantiate the APDS9002 (Grove luminance sensor) on the Analog pin A0 + APDS9002 lum = new APDS9002(0); + + while(true){ + System.out.println("The Luminance value is : "+lum.value()); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/Apds9002.java upm-1.7.1/examples/java/Apds9002.java --- upm-1.6.0/examples/java/Apds9002.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Apds9002.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_apds9002.APDS9002; - -public class Apds9002 { - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // Instantiate the APDS9002 (Grove luminance sensor) on the Analog pin A0 - APDS9002 lum = new APDS9002(0); - - while(true){ - System.out.println("The Luminance value is : "+lum.value()); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/BH1749_Example.java upm-1.7.1/examples/java/BH1749_Example.java --- upm-1.6.0/examples/java/BH1749_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/BH1749_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -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] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/BH1792_Example.java upm-1.7.1/examples/java/BH1792_Example.java --- upm-1.6.0/examples/java/BH1792_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/BH1792_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -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] diff -Nru upm-1.6.0/examples/java/BISS0001_Example.java upm-1.7.1/examples/java/BISS0001_Example.java --- upm-1.6.0/examples/java/BISS0001_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/BISS0001_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class BISS0001_Example{ + + public static void main(String[] args) throws InterruptedException { +//! [Interesting] + // Instantiate a Grove Motion sensor on GPIO pin D7 + upm_biss0001.BISS0001 motion = new upm_biss0001.BISS0001(7); + + while (true) { + boolean value = motion.value(); + + if(value) + System.out.println("Detecting moving object"); + else + System.out.println("No moving objects detected"); + + Thread.sleep(1000); + } +//! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/BISS0001Sample.java upm-1.7.1/examples/java/BISS0001Sample.java --- upm-1.6.0/examples/java/BISS0001Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/BISS0001Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class BISS0001Sample{ - - public static void main(String[] args) throws InterruptedException { -//! [Interesting] - // Instantiate a Grove Motion sensor on GPIO pin D7 - upm_biss0001.BISS0001 motion = new upm_biss0001.BISS0001(7); - - while (true) { - boolean value = motion.value(); - - if(value) - System.out.println("Detecting moving object"); - else - System.out.println("No moving objects detected"); - - Thread.sleep(1000); - } -//! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/BMA220_Example.java upm-1.7.1/examples/java/BMA220_Example.java --- upm-1.6.0/examples/java/BMA220_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/BMA220_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class BMA220_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + // Instantiate an BMA220 using default parameters (bus 0, addr 0x0a) + upm_bma220.BMA220 sensor = new upm_bma220.BMA220(); + + while (true) { + float acc[]; + + sensor.update(); + acc = sensor.getAccelerometer(); + System.out.print("Accelerometer: "); + System.out.println("AX: " + acc[0] + "AY: " + acc[1] + "AZ: " + acc[2]); + + Thread.sleep(1000); + } + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/BMA220Sample.java upm-1.7.1/examples/java/BMA220Sample.java --- upm-1.6.0/examples/java/BMA220Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/BMA220Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class BMA220Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - // Instantiate an BMA220 using default parameters (bus 0, addr 0x0a) - upm_bma220.BMA220 sensor = new upm_bma220.BMA220(); - - while (true) { - float acc[]; - - sensor.update(); - acc = sensor.getAccelerometer(); - System.out.print("Accelerometer: "); - System.out.println("AX: " + acc[0] + "AY: " + acc[1] + "AZ: " + acc[2]); - - Thread.sleep(1000); - } - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/BME280_Interface_Example.java upm-1.7.1/examples/java/BME280_Interface_Example.java --- upm-1.6.0/examples/java/BME280_Interface_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/BME280_Interface_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,71 @@ +/* + * Author: Jon Trulson + * Author: Sisinty Sasmita Patra + * Copyright (c) 2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_bmp280.*; +import upm_interfaces.*; + +public class BME280_Interface_Example +{ + public static void main(String[] args) throws InterruptedException + { +// ! [Interesting] + + // Instantiate a BME280 instance using default i2c bus and address + BME280 sensor = new BME280(); + + ITemperatureSensor t_sensor = sensor; + IHumiditySensor h_sensor = sensor; + IPressureSensor p_sensor = sensor; + + // For SPI, bus 0, you would pass -1 as the address, and a + // valid pin for CS: + // BME280(0, -1, 10); + + while (true) + { + // update our values from the sensor + sensor.update(); + + System.out.println("Calling Interface Functions: "); + + System.out.println("Compensation Temperature: " + + t_sensor.getTemperatureCelsius() + + " C / "); + + System.out.println("Pressure: " + + p_sensor.getPressurePa() + + " Pa"); + + System.out.println("Humidity: " + + h_sensor.getHumidityRelative() + + " %RH"); + + System.out.println(); + Thread.sleep(1000); + } + +// ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/BME280_InterfaceExample.java upm-1.7.1/examples/java/BME280_InterfaceExample.java --- upm-1.6.0/examples/java/BME280_InterfaceExample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/BME280_InterfaceExample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -/* - * Author: Jon Trulson - * Author: Sisinty Sasmita Patra - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_bmp280.*; -import upm_interfaces.*; - -public class BME280_InterfaceExample -{ - public static void main(String[] args) throws InterruptedException - { -// ! [Interesting] - - // Instantiate a BME280 instance using default i2c bus and address - BME280 sensor = new BME280(); - - ITemperatureSensor t_sensor = sensor; - IHumiditySensor h_sensor = sensor; - IPressureSensor p_sensor = sensor; - - // For SPI, bus 0, you would pass -1 as the address, and a - // valid pin for CS: - // BME280(0, -1, 10); - - while (true) - { - // update our values from the sensor - sensor.update(); - - System.out.println("Calling Interface Functions: "); - - System.out.println("Compensation Temperature: " - + t_sensor.getTemperatureCelsius() - + " C / "); - - System.out.println("Pressure: " - + p_sensor.getPressurePa() - + " Pa"); - - System.out.println("Humidity: " - + h_sensor.getHumidityRelative() - + " %RH"); - - System.out.println(); - Thread.sleep(1000); - } - -// ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/BMPX8X_Example.java upm-1.7.1/examples/java/BMPX8X_Example.java --- upm-1.6.0/examples/java/BMPX8X_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/BMPX8X_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,55 @@ +/* + * Author: Stefan Andritoiu + * Author: Jon Trulson + * Copyright (c) 2015-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. + */ + +public class BMPX8X_Example { + + public static void main(String[] args) throws InterruptedException { +// ! [Interesting] + + // Instantiate a BMPX8X sensor on I2C using defaults. + upm_bmpx8x.BMPX8X sensor = new upm_bmpx8x.BMPX8X(); + + // Print the pressure, altitude, sea level, and + // temperature values every .5 seconds + while (true) + { + sensor.update(); + + System.out.println("Pressure: " + + sensor.getPressure() + + " Pa, Temperature: " + + sensor.getTemperature() + + " C, Altitude: " + + sensor.getAltitude() + + " m, Sea level: " + + sensor.getSealevelPressure() + + " Pa"); + + Thread.sleep(500); + } +// ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/BMPX8XSample.java upm-1.7.1/examples/java/BMPX8XSample.java --- upm-1.6.0/examples/java/BMPX8XSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/BMPX8XSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Author: Jon Trulson - * Copyright (c) 2015-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. - */ - -public class BMPX8XSample { - - public static void main(String[] args) throws InterruptedException { -// ! [Interesting] - - // Instantiate a BMPX8X sensor on I2C using defaults. - upm_bmpx8x.BMPX8X sensor = new upm_bmpx8x.BMPX8X(); - - // Print the pressure, altitude, sea level, and - // temperature values every .5 seconds - while (true) - { - sensor.update(); - - System.out.println("Pressure: " - + sensor.getPressure() - + " Pa, Temperature: " - + sensor.getTemperature() - + " C, Altitude: " - + sensor.getAltitude() - + " m, Sea level: " - + sensor.getSealevelPressure() - + " Pa"); - - Thread.sleep(500); - } -// ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/Button_Example.java upm-1.7.1/examples/java/Button_Example.java --- upm-1.6.0/examples/java/Button_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Button_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Button_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Create the button object using GPIO pin 2 + upm_button.Button button = new upm_button.Button(2); + + while (true) { + System.out.println(button.name() + " value is " + button.value()); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/Button_intr_Example.java upm-1.7.1/examples/java/Button_intr_Example.java --- upm-1.6.0/examples/java/Button_intr_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Button_intr_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Button_intr_Example { + + private static int counter = 0; + + public static void incrementCounter() { + counter++; + } + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_button.Button b = new upm_button.Button(2); + + ButtonISR callback = new ButtonISR(); + b.installISR(2, callback); + + while (true) { + System.out.println("Counter: " + counter); + Thread.sleep(1000); + } + // ! [Interesting] + } +} + +class ButtonISR implements Runnable { + public ButtonISR() { + super(); + } + + public void run() { + Button_intr_Example.incrementCounter(); + System.out.println("Button pressed!"); + } +} diff -Nru upm-1.6.0/examples/java/Button_intrSample.java upm-1.7.1/examples/java/Button_intrSample.java --- upm-1.6.0/examples/java/Button_intrSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Button_intrSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class Button_intrSample { - - public static int counter = 0; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_button.Button b = new upm_button.Button(2); - - ButtonISR callback = new ButtonISR(); - b.installISR(2, callback); - - while (true) { - System.out.println("Counter: " + counter); - Thread.sleep(1000); - } - // ! [Interesting] - } -} - -class ButtonISR implements Runnable { - public ButtonISR() { - super(); - } - - public void run() { - Button_intrSample.counter++; - System.out.println("Button pressed!"); - } -} diff -Nru upm-1.6.0/examples/java/ButtonSample.java upm-1.7.1/examples/java/ButtonSample.java --- upm-1.6.0/examples/java/ButtonSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/ButtonSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class ButtonSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Create the button object using GPIO pin 2 - upm_button.Button button = new upm_button.Button(2); - - while (true) { - System.out.println(button.name() + " value is " + button.value()); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/Buzzer_Example.java upm-1.7.1/examples/java/Buzzer_Example.java --- upm-1.6.0/examples/java/Buzzer_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Buzzer_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_buzzer.Buzzer; +public class Buzzer_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + int chord[] = { + upm_buzzer.javaupm_buzzer.BUZZER_DO, + upm_buzzer.javaupm_buzzer.BUZZER_RE, + upm_buzzer.javaupm_buzzer.BUZZER_MI, + upm_buzzer.javaupm_buzzer.BUZZER_FA, + upm_buzzer.javaupm_buzzer.BUZZER_SOL, + upm_buzzer.javaupm_buzzer.BUZZER_LA, + upm_buzzer.javaupm_buzzer.BUZZER_SI}; + + // Instantiate a buzzer on digital pin D5 + Buzzer sound = new Buzzer(5); + + // print sensor name + System.out.println(sound.name()); + + for (int i = 0; i < chord.length; i++) { + // play each note for one half second + int note = sound.playSound(chord[i], 500000); + System.out.println(note); + + Thread.sleep(100); + } + // ! [Interesting] + sound.stopSound(); + } + +} diff -Nru upm-1.6.0/examples/java/BuzzerSample.java upm-1.7.1/examples/java/BuzzerSample.java --- upm-1.6.0/examples/java/BuzzerSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/BuzzerSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_buzzer.Buzzer; -public class BuzzerSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - int chord[] = { - upm_buzzer.javaupm_buzzer.BUZZER_DO, - upm_buzzer.javaupm_buzzer.BUZZER_RE, - upm_buzzer.javaupm_buzzer.BUZZER_MI, - upm_buzzer.javaupm_buzzer.BUZZER_FA, - upm_buzzer.javaupm_buzzer.BUZZER_SOL, - upm_buzzer.javaupm_buzzer.BUZZER_LA, - upm_buzzer.javaupm_buzzer.BUZZER_SI}; - - // Instantiate a buzzer on digital pin D5 - Buzzer sound = new Buzzer(5); - - // print sensor name - System.out.println(sound.name()); - - for (int i = 0; i < chord.length; i++) { - // play each note for one half second - int note = sound.playSound(chord[i], 500000); - System.out.println(note); - - Thread.sleep(100); - } - // ! [Interesting] - sound.stopSound(); - } - -} diff -Nru upm-1.6.0/examples/java/CJQ4435_Example.java upm-1.7.1/examples/java/CJQ4435_Example.java --- upm-1.6.0/examples/java/CJQ4435_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/CJQ4435_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class CJQ4435_Example { + + public static void main(String[] args) throws InterruptedException { + // Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3 + upm_cjq4435.CJQ4435 mosfet = new upm_cjq4435.CJQ4435(3); + + mosfet.setPeriodMS(10); + mosfet.enable(true); + + while (true) { + // start with a duty cycle of 0.0 (off) and increment to 1.0 (on) + for (float i = 0; i <= 1; i += 0.1) { + mosfet.setDutyCycle(i); + Thread.sleep(100); + } + Thread.sleep(1000); + + // Now take it back down + // start with a duty cycle of 1.0 (on) and decrement to 0.0 (off) + for (float i = 1; i >= 0; i -= 0.1) { + mosfet.setDutyCycle(i); + Thread.sleep(100); + } + Thread.sleep(1000); + } + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/CJQ4435Sample.java upm-1.7.1/examples/java/CJQ4435Sample.java --- upm-1.6.0/examples/java/CJQ4435Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/CJQ4435Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class CJQ4435Sample { - - public static void main(String[] args) throws InterruptedException { - // Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3 - upm_cjq4435.CJQ4435 mosfet = new upm_cjq4435.CJQ4435(3); - - mosfet.setPeriodMS(10); - mosfet.enable(true); - - while (true) { - // start with a duty cycle of 0.0 (off) and increment to 1.0 (on) - for (float i = 0; i <= 1; i += 0.1) { - mosfet.setDutyCycle(i); - Thread.sleep(100); - } - Thread.sleep(1000); - - // Now take it back down - // start with a duty cycle of 1.0 (on) and decrement to 0.0 (off) - for (float i = 1; i >= 0; i -= 0.1) { - mosfet.setDutyCycle(i); - Thread.sleep(100); - } - Thread.sleep(1000); - } - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/CMakeLists.txt upm-1.7.1/examples/java/CMakeLists.txt --- upm-1.6.0/examples/java/CMakeLists.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -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_jar(${example_name} SOURCES ${example_src} INCLUDE_JARS ${example_jar}) - add_dependencies(${example_name} javaupm_${jar_name}) -endmacro() - -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") - - add_jar(${example_name} SOURCES ${example_src} INCLUDE_JARS ${example_jar}) - add_dependencies(${example_name} javaupm_${jar_name}) -endmacro() - -macro(add_example_multiple_jars example_name example_jar_name jar_name_list) - set(example_src "${example_name}.java") - - 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}) +# 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. +# .java +# upm_target_dependency_list: One or more UPM library targets. This +# function assumes a javaupm_ 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") + + # Build a list of all dependency jar files + set(jar_file_list "") + + # Build a list of all dependency java target names + set(java_targets_list "") + + # Iterate over the dependencies + foreach(dependency ${dependency_list}) + set(java_target "javaupm_${dependency}") + + # Append to the targets list + list(APPEND java_targets_list ${java_target}) + + # 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_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 the jar/s + add_jar(${example_class_name} SOURCES ${example_file} INCLUDE_JARS ${jar_file_list}) + + # 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(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(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(BMM150_Example bmm150) +add_example(BMP280_Example "bmp280;interfaces") +add_example(BMPX8X_Example "bmpx8x;interfaces") add_example(BMX055_Example bmx055) -add_example(NMEAGPS_Example nmea_gps) -add_example(MMA7361_Example mma7361) -add_example(BH1750_Example bh1750) -add_example(HKA5_Example hka5) -add_example(DFRORP_Example dfrorp) +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(SHT1X_Example sht1x) -add_example(MS5803_Example ms5803) +add_example(DFRORP_Example dfrorp) +add_example(DS1307_Example ds1307) 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(BMA250E_Example bma250e) -add_example(BMM150_Example bmm150) +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 lcd) -add_example_with_path(SSD1327_oledSample lcd lcd) -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() + +if (MODBUS_FOUND) + add_example(H803X_Example h803x) 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 (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 () diff -Nru upm-1.6.0/examples/java/Collision_Example.java upm-1.7.1/examples/java/Collision_Example.java --- upm-1.6.0/examples/java/Collision_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Collision_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_collision.*; + +public class Collision_Example { + + public static void main(String[] args) { + // Initializing the sensor on D2 on the Base Shield + upm_collision.Collision collision = new upm_collision.Collision(2); + boolean collisionState = false; + + // ! [Interesting] + while(true){ + if(collision.isColliding() && !collisionState){ + System.out.println("Collision!!"); + collisionState = true; + } + else if (collisionState){ + System.out.println("No Collision!"); + collisionState = false; + } + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/Collision.java upm-1.7.1/examples/java/Collision.java --- upm-1.6.0/examples/java/Collision.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Collision.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_collision.*; - -public class Collision { - - public static void main(String[] args) { - // Initializing the sensor on D2 on the Base Shield - upm_collision.Collision collision = new upm_collision.Collision(2); - boolean collisionState = false; - - // ! [Interesting] - while(true){ - if(collision.isColliding() && !collisionState){ - System.out.println("Collision!!"); - collisionState = true; - } - else if (collisionState){ - System.out.println("No Collision!"); - collisionState = false; - } - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/DFRPH_Example.java upm-1.7.1/examples/java/DFRPH_Example.java --- upm-1.6.0/examples/java/DFRPH_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/DFRPH_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class DFRPH_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + // Instantiate a DFRPH sensor on analog pin A0, with an analog + // reference voltage of 5.0 V + upm_dfrph.DFRPH sensor = new upm_dfrph.DFRPH(0, 5.0f); + + // After calibration, set the offset (based on calibration with a pH + // 7.0 buffer solution). See the UPM sensor documentation for + // calibrations instructions. + sensor.setOffset(0.065f); + + // Every second, sample the pH and output it's corresponding + // analog voltage. + while (true) { + System.out.println("Detected volts: = " + sensor.volts()); + System.out.println("pH value: " + sensor.pH()); + Thread.sleep(1000); + } + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/DFRPHSample.java upm-1.7.1/examples/java/DFRPHSample.java --- upm-1.6.0/examples/java/DFRPHSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/DFRPHSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class DFRPHSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - // Instantiate a DFRPH sensor on analog pin A0, with an analog - // reference voltage of 5.0 V - upm_dfrph.DFRPH sensor = new upm_dfrph.DFRPH(0, 5.0f); - - // After calibration, set the offset (based on calibration with a pH - // 7.0 buffer solution). See the UPM sensor documentation for - // calibrations instructions. - sensor.setOffset(0.065f); - - // Every second, sample the pH and output it's corresponding - // analog voltage. - while (true) { - System.out.println("Detected volts: = " + sensor.volts()); - System.out.println("pH value: " + sensor.pH()); - Thread.sleep(1000); - } - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/DS1307_Example.java upm-1.7.1/examples/java/DS1307_Example.java --- upm-1.6.0/examples/java/DS1307_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/DS1307_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,74 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class DS1307_Example { + + static private void printTime(upm_ds1307.DS1307 rtc) { + System.out.print("The time is: " + rtc.getMonth() + "/" + rtc.getDayOfMonth() + "/" + + rtc.getYear() + " " + rtc.getHours() + ":" + rtc.getMinutes() + ":" + + rtc.getSeconds()); + + if (rtc.getAmPmMode()) { + if (rtc.getAmPmMode()) + System.out.print(" PM"); + else + System.out.print(" AM"); + } + + System.out.println(); + + if (rtc.getAmPmMode()) + System.out.println("Clock is in AM/PM mode"); + else + System.out.println("Clock is in 24h mode"); + + } + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a DS1037 on I2C bus 0 + upm_ds1307.DS1307 rtc = new upm_ds1307.DS1307(0); + + // always do this first + System.out.println("Loading the current time..."); + if (!rtc.loadTime()) { + System.err.println("rtc->loadTime() failed."); + System.exit(-1); + } + + printTime(rtc); + + // set the year as an example + System.out.println("setting the year to 50"); + rtc.setYear(50); + rtc.setTime(); + + // reload the time and print it + rtc.loadTime(); + printTime(rtc); + + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/DS1307Sample.java upm-1.7.1/examples/java/DS1307Sample.java --- upm-1.6.0/examples/java/DS1307Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/DS1307Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class DS1307Sample { - - static private void printTime(upm_ds1307.DS1307 rtc) { - System.out.print("The time is: " + rtc.getMonth() + "/" + rtc.getDayOfMonth() + "/" - + rtc.getYear() + " " + rtc.getHours() + ":" + rtc.getMinutes() + ":" - + rtc.getSeconds()); - - if (rtc.getAmPmMode()) { - if (rtc.getAmPmMode()) - System.out.print(" PM"); - else - System.out.print(" AM"); - } - - System.out.println(); - - if (rtc.getAmPmMode()) - System.out.println("Clock is in AM/PM mode"); - else - System.out.println("Clock is in 24h mode"); - - } - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a DS1037 on I2C bus 0 - upm_ds1307.DS1307 rtc = new upm_ds1307.DS1307(0); - - // always do this first - System.out.println("Loading the current time..."); - if (!rtc.loadTime()) { - System.err.println("rtc->loadTime() failed."); - System.exit(-1); - } - - printTime(rtc); - - // set the year as an example - System.out.println("setting the year to 50"); - rtc.setYear(50); - rtc.setTime(); - - // reload the time and print it - rtc.loadTime(); - printTime(rtc); - - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/ECS1030_Example.java upm-1.7.1/examples/java/ECS1030_Example.java --- upm-1.6.0/examples/java/ECS1030_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/ECS1030_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import upm_ecs1030.ECS1030; + +public class ECS1030_Example { + + static { + try { + System.loadLibrary("javaupm_ecs1030"); + System.loadLibrary("mraajava"); + } catch (UnsatisfiedLinkError e) { + System.err.println( + "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + + e); + System.exit(1); + } + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + ECS1030 sensor = new ECS1030((short)0); + + while(true){ + System.out.println("I = "+sensor.getCurrency_A()+", Power = "+sensor.getPower_A()); + System.out.println("I = "+sensor.getCurrency_B()+", Power = "+sensor.getPower_B()); + } + //! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/ECS1030Example.java upm-1.7.1/examples/java/ECS1030Example.java --- upm-1.6.0/examples/java/ECS1030Example.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/ECS1030Example.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_ecs1030.ECS1030; - -public class ECS1030Example { - - static { - try { - System.loadLibrary("javaupm_ecs1030"); - System.loadLibrary("mraajava"); - } catch (UnsatisfiedLinkError e) { - System.err.println( - "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + - e); - System.exit(1); - } - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - ECS1030 sensor = new ECS1030((short)0); - - while(true){ - System.out.println("I = "+sensor.getCurrency_A()+", Power = "+sensor.getPower_A()); - System.out.println("I = "+sensor.getCurrency_B()+", Power = "+sensor.getPower_B()); - } - //! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/EHR_Example.java upm-1.7.1/examples/java/EHR_Example.java --- upm-1.6.0/examples/java/EHR_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/EHR_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class EHR_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Ear-clip Heart Rate sensor on digital pin D2 + upm_ehr.EHR heart = new upm_ehr.EHR(2); + + // set the beat counter to 0, init the clock and start counting beats + heart.clearBeatCounter(); + heart.initClock(); + heart.startBeatCounter(); + + while (true) { + long millis = heart.getMillis(); + long beats = heart.beatCounter(); + + // heartRate() requires that at least 5 seconds pass before + // returning anything other than 0 + int hr = heart.heartRate(); + + // output milliseconds passed, beat count, and computed heart rate + System.out.println("Millis: " + millis + ", Beats: " + beats + ", Heart rate: " + hr); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/EHRSample.java upm-1.7.1/examples/java/EHRSample.java --- upm-1.6.0/examples/java/EHRSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/EHRSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class EHRSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Ear-clip Heart Rate sensor on digital pin D2 - upm_ehr.EHR heart = new upm_ehr.EHR(2); - - // set the beat counter to 0, init the clock and start counting beats - heart.clearBeatCounter(); - heart.initClock(); - heart.startBeatCounter(); - - while (true) { - long millis = heart.getMillis(); - long beats = heart.beatCounter(); - - // heartRate() requires that at least 5 seconds pass before - // returning anything other than 0 - int hr = heart.heartRate(); - - // output milliseconds passed, beat count, and computed heart rate - System.out.println("Millis: " + millis + ", Beats: " + beats + ", Heart rate: " + hr); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Emg_Example.java upm-1.7.1/examples/java/Emg_Example.java --- upm-1.6.0/examples/java/Emg_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Emg_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import upm_emg.EMG; + +public class Emg_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // Instantiating the Grove EMG sensor on Analog pin 0 + EMG emg = new EMG(0); + System.out.println("Calibrating ... "); + emg.calibrate(); + + while(true){ + System.out.println("EMG Val: "+emg.value()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + } + //! [Interesting] +} diff -Nru upm-1.6.0/examples/java/Emg.java upm-1.7.1/examples/java/Emg.java --- upm-1.6.0/examples/java/Emg.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Emg.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_emg.EMG; - -public class Emg { - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // Instantiating the Grove EMG sensor on Analog pin 0 - EMG emg = new EMG(0); - System.out.println("Calibrating ... "); - emg.calibrate(); - - while(true){ - System.out.println("EMG Val: "+emg.value()); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - } - //! [Interesting] -} diff -Nru upm-1.6.0/examples/java/ENC03R_Example.java upm-1.7.1/examples/java/ENC03R_Example.java --- upm-1.6.0/examples/java/ENC03R_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/ENC03R_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +public class ENC03R_Example { + private static final long CALIBRATION_SAMPLES = 1000; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + // Instantiate a ENC03R on analog pin A0 + upm_enc03r.ENC03R gyro = new upm_enc03r.ENC03R(0); + + System.out.println("Please place the sensor in a stable location, and do not"); + System.out.println("move it while calibration takes place"); + System.out.println("This may take a couple of minutes."); + + gyro.calibrate(CALIBRATION_SAMPLES); + System.out.println("Calibration complete. Reference value: " + gyro.calibrationValue()); + + // Read the input and print both the raw value and the angular velocity, + // waiting 1 second between readings + while (true) { + gyro.update(); + + System.out.println("Angular velocity: " + + gyro.angularVelocity() + + " deg/s"); + + Thread.sleep(100); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/ENC03RSample.java upm-1.7.1/examples/java/ENC03RSample.java --- upm-1.6.0/examples/java/ENC03RSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/ENC03RSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -public class ENC03RSample { - private static final long CALIBRATION_SAMPLES = 1000; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - // Instantiate a ENC03R on analog pin A0 - upm_enc03r.ENC03R gyro = new upm_enc03r.ENC03R(0); - - System.out.println("Please place the sensor in a stable location, and do not"); - System.out.println("move it while calibration takes place"); - System.out.println("This may take a couple of minutes."); - - gyro.calibrate(CALIBRATION_SAMPLES); - System.out.println("Calibration complete. Reference value: " + gyro.calibrationValue()); - - // Read the input and print both the raw value and the angular velocity, - // waiting 1 second between readings - while (true) { - gyro.update(); - - System.out.println("Angular velocity: " - + gyro.angularVelocity() - + " deg/s"); - - Thread.sleep(100); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/ES08A_Example.java upm-1.7.1/examples/java/ES08A_Example.java --- upm-1.6.0/examples/java/ES08A_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/ES08A_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class ES08A_Example { + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_servo.ES08A servo = new upm_servo.ES08A(6); + + // Sets the shaft to 180, then to 90, then to 0, + // then back to 90, and finally back to 180, + // pausing for a second in between each angle + servo.setAngle(180); + System.out.println("Set angle to 180"); + Thread.sleep(1000); + + servo.setAngle(90); + System.out.println("Set angle to 90"); + Thread.sleep(1000); + + servo.setAngle(0); + System.out.println("Set angle to 0"); + Thread.sleep(1000); + + servo.setAngle(90); + System.out.println("Set angle to 90"); + Thread.sleep(1000); + + servo.setAngle(180); + System.out.println("Set angle to 180"); + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/ES08ASample.java upm-1.7.1/examples/java/ES08ASample.java --- upm-1.6.0/examples/java/ES08ASample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/ES08ASample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class ES08ASample { - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_servo.ES08A servo = new upm_servo.ES08A(6); - - // Sets the shaft to 180, then to 90, then to 0, - // then back to 90, and finally back to 180, - // pausing for a second in between each angle - servo.setAngle(180); - System.out.println("Set angle to 180"); - Thread.sleep(1000); - - servo.setAngle(90); - System.out.println("Set angle to 90"); - Thread.sleep(1000); - - servo.setAngle(0); - System.out.println("Set angle to 0"); - Thread.sleep(1000); - - servo.setAngle(90); - System.out.println("Set angle to 90"); - Thread.sleep(1000); - - servo.setAngle(180); - System.out.println("Set angle to 180"); - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/FlexSensor_Example.java upm-1.7.1/examples/java/FlexSensor_Example.java --- upm-1.6.0/examples/java/FlexSensor_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/FlexSensor_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,41 @@ +import upm_flex.Flex; + +public class FlexSensor_Example { + + static { + try { + System.loadLibrary("javaupm_flex"); + System.loadLibrary("mraajava"); + } catch (UnsatisfiedLinkError e) { + System.err.println( + "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + + e); + System.exit(1); + } + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // The was tested with a Spectra Symbol flex sensor. + // We attached a 22K resistor to a breadboard, + // with 1 end attached to GND and the other connected to + // both the flex sensor and A0. + // The flex sensor was connected on 1 pin to the 22K resistor and A0 + // and on the other pin to 5V. + + // Instantiate a Flex sensor on analog pin A0 + Flex flex = new Flex(0); + while(true){ + System.out.println("Flex Sensor value is: "+flex.value()); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println(e.toString()); + } + } + //! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/FlexSensorExample.java upm-1.7.1/examples/java/FlexSensorExample.java --- upm-1.6.0/examples/java/FlexSensorExample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/FlexSensorExample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -import upm_flex.Flex; - -public class FlexSensorExample { - - static { - try { - System.loadLibrary("javaupm_flex"); - System.loadLibrary("mraajava"); - } catch (UnsatisfiedLinkError e) { - System.err.println( - "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + - e); - System.exit(1); - } - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // The was tested with a Spectra Symbol flex sensor. - // We attached a 22K resistor to a breadboard, - // with 1 end attached to GND and the other connected to - // both the flex sensor and A0. - // The flex sensor was connected on 1 pin to the 22K resistor and A0 - // and on the other pin to 5V. - - // Instantiate a Flex sensor on analog pin A0 - Flex flex = new Flex(0); - while(true){ - System.out.println("Flex Sensor value is: "+flex.value()); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - //! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Gp2y0a_Example.java upm-1.7.1/examples/java/Gp2y0a_Example.java --- upm-1.6.0/examples/java/Gp2y0a_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Gp2y0a_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,68 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import upm_gp2y0a.GP2Y0A; + +public class Gp2y0a_Example { + + public static final float GP2Y0A_AREF = 5; + public static final short SAMPLES_PER_QUERY = 20; + + static { + try { + System.loadLibrary("javaupm_gp2y0a"); + System.loadLibrary("mraajava"); + } catch (UnsatisfiedLinkError e) { + System.err.println( + "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + + e); + System.exit(1); + } + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // Note, for the Grove 80cm version of this sensor, due to the way + // it is wired, you need to plug this into the A0 port, where it + // will use the available A1 pin for data. + + // Instantiate a GP2Y0A on analog pin A1 + GP2Y0A gp2y0a = new GP2Y0A(1); + + // The higher the voltage (closer to AREF) the closer the object is. NOTE: + // the measured voltage will probably not exceed 3.3 volts. + // Every second, print the averaged voltage value (averaged over 20 samples). + while(true){ + System.out.println("AREF: " + GP2Y0A_AREF + "\t, Voltage Value (Higher means Closer): "+ gp2y0a.value(GP2Y0A_AREF, SAMPLES_PER_QUERY)); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + //! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Gp2y0aExample.java upm-1.7.1/examples/java/Gp2y0aExample.java --- upm-1.6.0/examples/java/Gp2y0aExample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Gp2y0aExample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_gp2y0a.GP2Y0A; - -public class Gp2y0aExample { - - public static final float GP2Y0A_AREF = 5; - public static final short SAMPLES_PER_QUERY = 20; - - static { - try { - System.loadLibrary("javaupm_gp2y0a"); - System.loadLibrary("mraajava"); - } catch (UnsatisfiedLinkError e) { - System.err.println( - "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + - e); - System.exit(1); - } - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // Note, for the Grove 80cm version of this sensor, due to the way - // it is wired, you need to plug this into the A0 port, where it - // will use the available A1 pin for data. - - // Instantiate a GP2Y0A on analog pin A1 - GP2Y0A gp2y0a = new GP2Y0A(1); - - // The higher the voltage (closer to AREF) the closer the object is. NOTE: - // the measured voltage will probably not exceed 3.3 volts. - // Every second, print the averaged voltage value (averaged over 20 samples). - while(true){ - System.out.println("AREF: " + GP2Y0A_AREF + "\t, Voltage Value (Higher means Closer): "+ gp2y0a.value(GP2Y0A_AREF, SAMPLES_PER_QUERY)); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - //! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveButton_Example.java upm-1.7.1/examples/java/GroveButton_Example.java --- upm-1.6.0/examples/java/GroveButton_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveButton_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveButton_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Create the button object using GPIO pin 2 + upm_grove.GroveButton button = new upm_grove.GroveButton(2); + + while (true) { + System.out.println(button.name() + " value is " + button.value()); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveButton_intr_Example.java upm-1.7.1/examples/java/GroveButton_intr_Example.java --- upm-1.6.0/examples/java/GroveButton_intr_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveButton_intr_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveButton_intr_Example { + + 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); + + ButtonISR callback = new ButtonISR(); + b.installISR(2, callback); + + while (true) { + System.out.println("Counter: " + counter); + Thread.sleep(1000); + } + // ! [Interesting] + } +} + +class ButtonISR implements Runnable { + public ButtonISR() { + super(); + } + + public void run() { + GroveButton_intr_Example.incrementCounter(); + System.out.println("Button pressed!"); + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveButton_intrSample.java upm-1.7.1/examples/java/GroveButton_intrSample.java --- upm-1.6.0/examples/java/GroveButton_intrSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveButton_intrSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveButton_intrSample { - - public static int counter = 0; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_grove.GroveButton b = new upm_grove.GroveButton(2); - - ButtonISR callback = new ButtonISR(); - b.installISR(2, callback); - - while (true) { - System.out.println("Counter: " + counter); - Thread.sleep(1000); - } - // ! [Interesting] - } -} - -class ButtonISR implements Runnable { - public ButtonISR() { - super(); - } - - public void run() { - GroveButton_intrSample.counter++; - System.out.println("Button pressed!"); - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveButtonSample.java upm-1.7.1/examples/java/GroveButtonSample.java --- upm-1.6.0/examples/java/GroveButtonSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveButtonSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveButtonSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Create the button object using GPIO pin 2 - upm_grove.GroveButton button = new upm_grove.GroveButton(2); - - while (true) { - System.out.println(button.name() + " value is " + button.value()); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveCollision_Example.java upm-1.7.1/examples/java/GroveCollision_Example.java --- upm-1.6.0/examples/java/GroveCollision_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveCollision_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_grovecollision.*; + +public class GroveCollision_Example { + + public static void main(String[] args) { + // Initializing the sensor on D2 on the Base Shield + upm_grovecollision.GroveCollision collision = new upm_grovecollision.GroveCollision(2); + boolean collisionState = false; + + // ! [Interesting] + while(true){ + if(collision.isColliding() && !collisionState){ + System.out.println("Collision!!"); + collisionState = true; + } + else if (collisionState){ + System.out.println("No Collision!"); + collisionState = false; + } + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/GroveCollision.java upm-1.7.1/examples/java/GroveCollision.java --- upm-1.6.0/examples/java/GroveCollision.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveCollision.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_grovecollision.*; - -public class GroveCollision { - - public static void main(String[] args) { - // Initializing the sensor on D2 on the Base Shield - upm_grovecollision.GroveCollision collision = new upm_grovecollision.GroveCollision(2); - boolean collisionState = false; - - // ! [Interesting] - while(true){ - if(collision.isColliding() && !collisionState){ - System.out.println("Collision!!"); - collisionState = true; - } - else if (collisionState){ - System.out.println("No Collision!"); - collisionState = false; - } - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/GroveEHR_Example.java upm-1.7.1/examples/java/GroveEHR_Example.java --- upm-1.6.0/examples/java/GroveEHR_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveEHR_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class GroveEHR_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2 + upm_groveehr.GroveEHR heart = new upm_groveehr.GroveEHR(2); + + // set the beat counter to 0, init the clock and start counting beats + heart.clearBeatCounter(); + heart.initClock(); + heart.startBeatCounter(); + + while (true) { + long millis = heart.getMillis(); + long beats = heart.beatCounter(); + + // heartRate() requires that at least 5 seconds pass before + // returning anything other than 0 + int hr = heart.heartRate(); + + // output milliseconds passed, beat count, and computed heart rate + System.out.println("Millis: " + millis + ", Beats: " + beats + ", Heart rate: " + hr); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveEHRSample.java upm-1.7.1/examples/java/GroveEHRSample.java --- upm-1.6.0/examples/java/GroveEHRSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveEHRSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class GroveEHRSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2 - upm_groveehr.GroveEHR heart = new upm_groveehr.GroveEHR(2); - - // set the beat counter to 0, init the clock and start counting beats - heart.clearBeatCounter(); - heart.initClock(); - heart.startBeatCounter(); - - while (true) { - long millis = heart.getMillis(); - long beats = heart.beatCounter(); - - // heartRate() requires that at least 5 seconds pass before - // returning anything other than 0 - int hr = heart.heartRate(); - - // output milliseconds passed, beat count, and computed heart rate - System.out.println("Millis: " + millis + ", Beats: " + beats + ", Heart rate: " + hr); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveEmg_Example.java upm-1.7.1/examples/java/GroveEmg_Example.java --- upm-1.6.0/examples/java/GroveEmg_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveEmg_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import upm_groveemg.GroveEMG; + +public class GroveEmg_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // Instantiating the Grove EMG sensor on Analog pin 0 + GroveEMG emg = new GroveEMG(0); + System.out.println("Calibrating ... "); + emg.calibrate(); + + while(true){ + System.out.println("EMG Val: "+emg.value()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + } + //! [Interesting] +} diff -Nru upm-1.6.0/examples/java/GroveEmg.java upm-1.7.1/examples/java/GroveEmg.java --- upm-1.6.0/examples/java/GroveEmg.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveEmg.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_groveemg.GroveEMG; - -public class GroveEmg { - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // Instantiating the Grove EMG sensor on Analog pin 0 - GroveEMG emg = new GroveEMG(0); - System.out.println("Calibrating ... "); - emg.calibrate(); - - while(true){ - System.out.println("EMG Val: "+emg.value()); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - } - //! [Interesting] -} diff -Nru upm-1.6.0/examples/java/GroveGsr_Example.java upm-1.7.1/examples/java/GroveGsr_Example.java --- upm-1.6.0/examples/java/GroveGsr_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveGsr_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_grovegsr.GroveGSR; + +public class GroveGsr_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + //! [Interesting] + // Instantiate a Grove GSR sensor on analog pin A0 + GroveGSR gsr = new GroveGSR(0); + System.out.println("Calibrating..."); + gsr.calibrate(); + + while(true){ + System.out.println("Value: "+gsr.value()); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/GroveGsr.java upm-1.7.1/examples/java/GroveGsr.java --- upm-1.6.0/examples/java/GroveGsr.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveGsr.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_grovegsr.GroveGSR; - -public class GroveGsr { - - public static void main(String[] args) { - // TODO Auto-generated method stub - - //! [Interesting] - // Instantiate a Grove GSR sensor on analog pin A0 - GroveGSR gsr = new GroveGSR(0); - System.out.println("Calibrating..."); - gsr.calibrate(); - - while(true){ - System.out.println("Value: "+gsr.value()); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/GroveLEDBar_Example.java upm-1.7.1/examples/java/GroveLEDBar_Example.java --- upm-1.6.0/examples/java/GroveLEDBar_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLEDBar_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,41 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveLEDBar_Example { + + public static void main(String[] args) throws InterruptedException { + //! [Interesting] + // Instantiate a Grove LED Bar, with Data pin D8 and Clock pin D9 + upm_my9221.GroveLEDBar bar = new upm_my9221.GroveLEDBar((short) 8, (short) 9); + + while (true) { + for (short idx = 1; idx < 11; idx++) { + bar.setBarLevel(idx); + Thread.sleep(100); + } + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/GroveLEDBar.java upm-1.7.1/examples/java/GroveLEDBar.java --- upm-1.6.0/examples/java/GroveLEDBar.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLEDBar.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveLEDBar { - - public static void main(String[] args) throws InterruptedException { - //! [Interesting] - // Instantiate a Grove LED Bar, with Data pin D8 and Clock pin D9 - upm_my9221.GroveLEDBar bar = new upm_my9221.GroveLEDBar((short) 8, (short) 9); - - while (true) { - for (short idx = 1; idx < 11; idx++) { - bar.setBarLevel(idx); - Thread.sleep(100); - } - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/GroveLED_Example.java upm-1.7.1/examples/java/GroveLED_Example.java --- upm-1.6.0/examples/java/GroveLED_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLED_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Author: Andrei Vasiliu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveLED_Example { + public static void main (String args[]) throws InterruptedException { + //! [Interesting] + upm_grove.GroveLed led = new upm_grove.GroveLed(2); + + for (int i = 0; i < 10; ++i) { + led.on(); + Thread.sleep(1000); + led.off(); + Thread.sleep(1000); + } + led.delete(); + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/GroveLed_multi_Example.java upm-1.7.1/examples/java/GroveLed_multi_Example.java --- upm-1.6.0/examples/java/GroveLed_multi_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLed_multi_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class GroveLed_multi_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a grove LED on D2. Here we are controlling a Grove + // Multi-color flash LED. We just just need to turn it on - it will + // then cycle through various colors (red, green, blue, purple) on it's + // own until turned off. + upm_grove.GroveLed led = new upm_grove.GroveLed(2); + + // start the light show + led.on(); + + // just sleep until interrupted + while (true) { + Thread.sleep(1); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveLed_multiSample.java upm-1.7.1/examples/java/GroveLed_multiSample.java --- upm-1.6.0/examples/java/GroveLed_multiSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLed_multiSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class GroveLed_multiSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a grove LED on D2. Here we are controlling a Grove - // Multi-color flash LED. We just just need to turn it on - it will - // then cycle through various colors (red, green, blue, purple) on it's - // own until turned off. - upm_grove.GroveLed led = new upm_grove.GroveLed(2); - - // start the light show - led.on(); - - // just sleep until interrupted - while (true) { - Thread.sleep(1); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveLEDSample.java upm-1.7.1/examples/java/GroveLEDSample.java --- upm-1.6.0/examples/java/GroveLEDSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLEDSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* - * Author: Andrei Vasiliu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveLEDSample { - public static void main (String args[]) throws InterruptedException { - //! [Interesting] - upm_grove.GroveLed led = new upm_grove.GroveLed(2); - - for (int i = 0; i < 10; ++i) { - led.on(); - Thread.sleep(1000); - led.off(); - Thread.sleep(1000); - } - led.delete(); - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/GroveLight_Example.java upm-1.7.1/examples/java/GroveLight_Example.java --- upm-1.6.0/examples/java/GroveLight_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLight_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,41 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveLight_Example { + public static void main(String args[]) throws InterruptedException { + // ! [Interesting] + upm_grove.GroveLight gl = new upm_grove.GroveLight(2); + + while (true) { + float raw_value = gl.raw_value(); + float value = gl.value(); + + System.out.println("raw value: " + raw_value); + System.out.println("value: " + value); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveLightSample.java upm-1.7.1/examples/java/GroveLightSample.java --- upm-1.6.0/examples/java/GroveLightSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLightSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveLightSample { - public static void main(String args[]) throws InterruptedException { - // ! [Interesting] - upm_grove.GroveLight gl = new upm_grove.GroveLight(2); - - while (true) { - float raw_value = gl.raw_value(); - float value = gl.value(); - - System.out.println("raw value: " + raw_value); - System.out.println("value: " + value); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveLineFinder_Example.java upm-1.7.1/examples/java/GroveLineFinder_Example.java --- upm-1.6.0/examples/java/GroveLineFinder_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLineFinder_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveLineFinder_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Grove Line Finder sensor on digital pin D2 + upm_grovelinefinder.GroveLineFinder finder = new upm_grovelinefinder.GroveLineFinder(2); + // check every second for the presence of white detection + while (true) { + boolean val = finder.whiteDetected(); + if (val) { + System.out.println("White detected"); + } else { + System.out.println("Black detected"); + } + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveLineFinderSample.java upm-1.7.1/examples/java/GroveLineFinderSample.java --- upm-1.6.0/examples/java/GroveLineFinderSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveLineFinderSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveLineFinderSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Grove Line Finder sensor on digital pin D2 - upm_grovelinefinder.GroveLineFinder finder = new upm_grovelinefinder.GroveLineFinder(2); - // check every second for the presence of white detection - while (true) { - boolean val = finder.whiteDetected(); - if (val) { - System.out.println("White detected"); - } else { - System.out.println("Black detected"); - } - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveMD_Example.java upm-1.7.1/examples/java/GroveMD_Example.java --- upm-1.6.0/examples/java/GroveMD_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveMD_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveMD_Example { + private static final short speed50 = 127; + private static final short speed0 = 0; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate an I2C Grove Motor Driver on I2C bus 0 + upm_grovemd.GroveMD motors = new upm_grovemd.GroveMD(); + + // set direction to clockwise (CW) and set speed to 50% + System.out.println("Spin M1 and M2 at half speed for 3 seconds"); + motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW, + upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW); + motors.setMotorSpeeds(speed50, speed50); + Thread.sleep(3000); + + // counter clockwise (CCW) + System.out.println("Reversing M1 and M2 for 3 seconds"); + motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW, + upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW); + Thread.sleep(3000); + + // stop motors + System.out.println("Stopping motors"); + motors.setMotorSpeeds(speed0, speed0); + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveMDSample.java upm-1.7.1/examples/java/GroveMDSample.java --- upm-1.6.0/examples/java/GroveMDSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveMDSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveMDSample { - private static final short speed50 = 127; - private static final short speed0 = 0; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate an I2C Grove Motor Driver on I2C bus 0 - upm_grovemd.GroveMD motors = new upm_grovemd.GroveMD(); - - // set direction to clockwise (CW) and set speed to 50% - System.out.println("Spin M1 and M2 at half speed for 3 seconds"); - motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW, - upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW); - motors.setMotorSpeeds(speed50, speed50); - Thread.sleep(3000); - - // counter clockwise (CCW) - System.out.println("Reversing M1 and M2 for 3 seconds"); - motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW, - upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW); - Thread.sleep(3000); - - // stop motors - System.out.println("Stopping motors"); - motors.setMotorSpeeds(speed0, speed0); - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveMoisture_Example.java upm-1.7.1/examples/java/GroveMoisture_Example.java --- upm-1.6.0/examples/java/GroveMoisture_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveMoisture_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveMoisture_Example { + public static void main(String args[]) throws InterruptedException { + // ! [Interesting] + upm_grovemoisture.GroveMoisture gm = new upm_grovemoisture.GroveMoisture(1); + + while (true) { + int moisture_val = gm.value(); + String result; + + if (moisture_val >= 0 && moisture_val < 300) + result = "Dry"; + else if ((moisture_val >= 0 && moisture_val < 300)) + result = "Moist"; + else + result = "Wet"; + + System.out.println("Moisture Value: " + moisture_val + ", " + result); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveMoistureSample.java upm-1.7.1/examples/java/GroveMoistureSample.java --- upm-1.6.0/examples/java/GroveMoistureSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveMoistureSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveMoistureSample { - public static void main(String args[]) throws InterruptedException { - // ! [Interesting] - upm_grovemoisture.GroveMoisture gm = new upm_grovemoisture.GroveMoisture(1); - - while (true) { - int moisture_val = gm.value(); - String result; - - if (moisture_val >= 0 && moisture_val < 300) - result = "Dry"; - else if ((moisture_val >= 0 && moisture_val < 300)) - result = "Moist"; - else - result = "Wet"; - - System.out.println("Moisture Value: " + moisture_val + ", " + result); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveMQ3_Example.java upm-1.7.1/examples/java/GroveMQ3_Example.java --- upm-1.6.0/examples/java/GroveMQ3_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveMQ3_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,70 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_gas.Gas; +import upm_gas.MQ2; +import upm_gas.MQ3; +import upm_gas.MQ4; +import upm_gas.MQ5; +import upm_gas.MQ6; +import upm_gas.MQ7; +import upm_gas.MQ8; +import upm_gas.MQ9; +import upm_gas.TP401; +import upm_gas.thresholdContext; + +public class GroveMQ3_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // initialize the sensor on A0 + MQ3 mq3 = new MQ3(0); + + short[] buffer = new short[128]; + + thresholdContext context = new thresholdContext(); + + context.setAverageReading(0); + context.setRunningAverage(0); + context.setAveragedOver(2); + + int len; + int thres; + while(true){ + len = mq3.getSampledWindow((long)2, buffer); + + if(len != 0){ + thres = mq3.findThreshold(context, 30, buffer); + mq3.printGraph(context, (short)5); + if(thres != 0){ + // do something + System.out.println("threshold is crossed"); + } + } + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/GroveMQ3.java upm-1.7.1/examples/java/GroveMQ3.java --- upm-1.6.0/examples/java/GroveMQ3.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveMQ3.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_gas.Gas; -import upm_gas.MQ2; -import upm_gas.MQ3; -import upm_gas.MQ4; -import upm_gas.MQ5; -import upm_gas.MQ6; -import upm_gas.MQ7; -import upm_gas.MQ8; -import upm_gas.MQ9; -import upm_gas.TP401; -import upm_gas.thresholdContext; - -public class GroveMQ3 { - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // initialize the sensor on A0 - MQ3 mq3 = new MQ3(0); - - short[] buffer = new short[128]; - - thresholdContext context = new thresholdContext(); - - context.setAverageReading(0); - context.setRunningAverage(0); - context.setAveragedOver(2); - - int len; - int thres; - while(true){ - len = mq3.getSampledWindow((long)2, buffer); - - if(len != 0){ - thres = mq3.findThreshold(context, 30, buffer); - mq3.printGraph(context, (short)5); - if(thres != 0){ - // do something - System.out.println("threshold is crossed"); - } - } - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/GroveMQ9_Example.java upm-1.7.1/examples/java/GroveMQ9_Example.java --- upm-1.6.0/examples/java/GroveMQ9_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveMQ9_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,70 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_gas.Gas; +import upm_gas.MQ2; +import upm_gas.MQ3; +import upm_gas.MQ4; +import upm_gas.MQ5; +import upm_gas.MQ6; +import upm_gas.MQ7; +import upm_gas.MQ8; +import upm_gas.MQ9; +import upm_gas.TP401; +import upm_gas.thresholdContext; + +public class GroveMQ9_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // initialize the sensor on A0 + MQ9 mq9 = new MQ9(0); + + short[] buffer = new short[128]; + + thresholdContext context = new thresholdContext(); + + context.setAverageReading(0); + context.setRunningAverage(0); + context.setAveragedOver(2); + + int len; + int thres; + while(true){ + len = mq9.getSampledWindow((long)2, buffer); + + if(len != 0){ + thres = mq9.findThreshold(context, 30, buffer); + mq9.printGraph(context, (short)5); + if(thres != 0){ + // do something + System.out.println("threshold is crossed"); + } + } + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/GroveMQ9.java upm-1.7.1/examples/java/GroveMQ9.java --- upm-1.6.0/examples/java/GroveMQ9.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveMQ9.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_gas.Gas; -import upm_gas.MQ2; -import upm_gas.MQ3; -import upm_gas.MQ4; -import upm_gas.MQ5; -import upm_gas.MQ6; -import upm_gas.MQ7; -import upm_gas.MQ8; -import upm_gas.MQ9; -import upm_gas.TP401; -import upm_gas.thresholdContext; - -public class GroveMQ9 { - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // initialize the sensor on A0 - MQ9 mq9 = new MQ9(0); - - short[] buffer = new short[128]; - - thresholdContext context = new thresholdContext(); - - context.setAverageReading(0); - context.setRunningAverage(0); - context.setAveragedOver(2); - - int len; - int thres; - while(true){ - len = mq9.getSampledWindow((long)2, buffer); - - if(len != 0){ - thres = mq9.findThreshold(context, 30, buffer); - mq9.printGraph(context, (short)5); - if(thres != 0){ - // do something - System.out.println("threshold is crossed"); - } - } - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/GroveO2_Example.java upm-1.7.1/examples/java/GroveO2_Example.java --- upm-1.6.0/examples/java/GroveO2_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveO2_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_groveo2.GroveO2; + +public class GroveO2_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // Initializing the Grove O2 sensor on the A) analog pin + GroveO2 o2 = new GroveO2(0); + + while(true){ + System.out.println("The output voltage is: "+o2.voltageValue()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception has occurred: "+e.getMessage()); + } + } + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/GroveO2Example.java upm-1.7.1/examples/java/GroveO2Example.java --- upm-1.6.0/examples/java/GroveO2Example.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveO2Example.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_groveo2.GroveO2; - -public class GroveO2Example { - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // Initializing the Grove O2 sensor on the A) analog pin - GroveO2 o2 = new GroveO2(0); - - while(true){ - System.out.println("The output voltage is: "+o2.voltageValue()); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception has occurred: "+e.getMessage()); - } - } - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/GroveQTouch_Example.java upm-1.7.1/examples/java/GroveQTouch_Example.java --- upm-1.6.0/examples/java/GroveQTouch_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveQTouch_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,69 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_at42qt1070.AT42QT1070; + +public class GroveQTouch_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + // Instantiating the Q Touch sensor on the I2C bus 0 + AT42QT1070 touch = new AT42QT1070(0, (short) 0x1b); + short pressedButtons; + + // ! [Interesting] + while(true){ + touch.updateState(); + printButtons(touch.getButtons()); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println(e.toString()); + } + } + // ! [Interesting] + } + + /** + * This function prints out the button numbers from 0 through 6 + * @param buttonNumber + */ + public static void printButtons(int buttonNumber){ + boolean buttonPressed = false; + System.out.print("Button Pressed: "); + for(int i=0;i<7;i++){ + if((buttonNumber & (1< - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_at42qt1070.AT42QT1070; - -public class GroveQTouch { - - public static void main(String[] args) { - // TODO Auto-generated method stub - // Instantiating the Q Touch sensor on the I2C bus 0 - AT42QT1070 touch = new AT42QT1070(0, (short) 0x1b); - short pressedButtons; - - // ! [Interesting] - while(true){ - touch.updateState(); - printButtons(touch.getButtons()); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - // ! [Interesting] - } - - /** - * This function prints out the button numbers from 0 through 6 - * @param buttonNumber - */ - public static void printButtons(int buttonNumber){ - boolean buttonPressed = false; - System.out.print("Button Pressed: "); - for(int i=0;i<7;i++){ - if((buttonNumber & (1< + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveRelay_Example { + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Create the button object using UART + upm_grove.GroveRelay relay = new upm_grove.GroveRelay(5); + + for (int i = 0; i < 3; i++) { + relay.on(); + if (relay.isOn()) + System.out.println("Relay is on"); + Thread.sleep(1000); + + relay.off(); + if (relay.isOff()) + System.out.println("Relay is off"); + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveRelaySample.java upm-1.7.1/examples/java/GroveRelaySample.java --- upm-1.6.0/examples/java/GroveRelaySample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveRelaySample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveRelaySample { - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Create the button object using UART - upm_grove.GroveRelay relay = new upm_grove.GroveRelay(5); - - for (int i = 0; i < 3; i++) { - relay.on(); - if (relay.isOn()) - System.out.println("Relay is on"); - Thread.sleep(1000); - - relay.off(); - if (relay.isOff()) - System.out.println("Relay is off"); - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveRotary_Example.java upm-1.7.1/examples/java/GroveRotary_Example.java --- upm-1.6.0/examples/java/GroveRotary_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveRotary_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveRotary_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_grove.GroveRotary knob = new upm_grove.GroveRotary(0); + + while (true) { + float abs_value = knob.abs_value(); // Absolute raw value + float abs_deg = knob.abs_deg(); // Absolute degrees + float abs_rad = knob.abs_rad(); // Absolute radians + float rel_value = knob.rel_value(); // Relative raw value + float rel_deg = knob.rel_deg(); // Relative degrees + float rel_rad = knob.rel_rad(); // Relative radians + + System.out.println("Absolute: " + abs_value + " raw, " + abs_deg + " deg, " + abs_rad + + " rad"); + System.out.println("Relative: " + rel_value + " raw, " + rel_deg + " deg, " + rel_rad + + " rad"); + + Thread.sleep(3000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveRotarySample.java upm-1.7.1/examples/java/GroveRotarySample.java --- upm-1.6.0/examples/java/GroveRotarySample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveRotarySample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveRotarySample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_grove.GroveRotary knob = new upm_grove.GroveRotary(0); - - while (true) { - float abs_value = knob.abs_value(); // Absolute raw value - float abs_deg = knob.abs_deg(); // Absolute degrees - float abs_rad = knob.abs_rad(); // Absolute radians - float rel_value = knob.rel_value(); // Relative raw value - float rel_deg = knob.rel_deg(); // Relative degrees - float rel_rad = knob.rel_rad(); // Relative radians - - System.out.println("Absolute: " + abs_value + " raw, " + abs_deg + " deg, " + abs_rad - + " rad"); - System.out.println("Relative: " + rel_value + " raw, " + rel_deg + " deg, " + rel_rad - + " rad"); - - Thread.sleep(3000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GROVESCAM_Example.java upm-1.7.1/examples/java/GROVESCAM_Example.java --- upm-1.6.0/examples/java/GROVESCAM_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GROVESCAM_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class GROVESCAM_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Grove Serial Camera on UART 0 + upm_grovescam.GROVESCAM camera = new upm_grovescam.GROVESCAM(0); + + // make sure port is initialized properly. 115200 baud is the default. + if (!camera.setupTty()) { + System.err.println("Failed to setup tty port parameters"); + System.exit(-1); + } + + if (camera.init()) + System.out.println("Initialized..."); + else + System.out.println("Initialization failed"); + + if (camera.preCapture()) + System.out.println("preCapture succeeded..."); + else + System.out.println("preCapture failed."); + + if (camera.doCapture()) + System.out.println("doCapture succeeded..."); + else + System.out.println("doCapture failed."); + + if (camera.getImageSize() > 0) { + System.out.println("Storing image.jpg..."); + + if (camera.storeImage("image.jpg")) + System.out.println("storeImage succeeded..."); + else + System.out.println("storeImage failed."); + + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GROVESCAMSample.java upm-1.7.1/examples/java/GROVESCAMSample.java --- upm-1.6.0/examples/java/GROVESCAMSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GROVESCAMSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class GROVESCAMSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Grove Serial Camera on UART 0 - upm_grovescam.GROVESCAM camera = new upm_grovescam.GROVESCAM(0); - - // make sure port is initialized properly. 115200 baud is the default. - if (!camera.setupTty()) { - System.err.println("Failed to setup tty port parameters"); - System.exit(-1); - } - - if (camera.init()) - System.out.println("Initialized..."); - else - System.out.println("Initialization failed"); - - if (camera.preCapture()) - System.out.println("preCapture succeeded..."); - else - System.out.println("preCapture failed."); - - if (camera.doCapture()) - System.out.println("doCapture succeeded..."); - else - System.out.println("doCapture failed."); - - if (camera.getImageSize() > 0) { - System.out.println("Storing image.jpg..."); - - if (camera.storeImage("image.jpg")) - System.out.println("storeImage succeeded..."); - else - System.out.println("storeImage failed."); - - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveSlide_Example.java upm-1.7.1/examples/java/GroveSlide_Example.java --- upm-1.6.0/examples/java/GroveSlide_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveSlide_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Author: Andrei Vasiliu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveSlide_Example { + public static void main (String args[]) throws InterruptedException { + //! [Interesting] + // Instantiate new grove slide potentiometer on analog pin A0 + upm_grove.GroveSlide slide = new upm_grove.GroveSlide(0); + + while (true) { + float raw_value = slide.raw_value(); + float value = slide.voltage_value(); + + System.out.println("raw value: " + raw_value); + System.out.println("value: " + value); + + Thread.sleep(2500); + } + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/GroveSlideSample.java upm-1.7.1/examples/java/GroveSlideSample.java --- upm-1.6.0/examples/java/GroveSlideSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveSlideSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - * Author: Andrei Vasiliu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveSlideSample { - public static void main (String args[]) throws InterruptedException { - //! [Interesting] - // Instantiate new grove slide potentiometer on analog pin A0 - upm_grove.GroveSlide slide = new upm_grove.GroveSlide(0); - - while (true) { - float raw_value = slide.raw_value(); - float value = slide.voltage_value(); - - System.out.println("raw value: " + raw_value); - System.out.println("value: " + value); - - Thread.sleep(2500); - } - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/GroveSpeaker_Example.java upm-1.7.1/examples/java/GroveSpeaker_Example.java --- upm-1.6.0/examples/java/GroveSpeaker_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveSpeaker_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Author: Andrei Vasiliu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveSpeaker_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Grove Speaker on digital pin D2 + upm_grovespeaker.GroveSpeaker speaker = new upm_grovespeaker.GroveSpeaker(2); + + // Play all 7 of the lowest notes + speaker.playAll(); + + // Play a medium C-sharp + speaker.playSound('c', true, "med"); + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveSpeakerSample.java upm-1.7.1/examples/java/GroveSpeakerSample.java --- upm-1.6.0/examples/java/GroveSpeakerSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveSpeakerSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* - * Author: Andrei Vasiliu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveSpeakerSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Grove Speaker on digital pin D2 - upm_grovespeaker.GroveSpeaker speaker = new upm_grovespeaker.GroveSpeaker(2); - - // Play all 7 of the lowest notes - speaker.playAll(); - - // Play a medium C-sharp - speaker.playSound('c', true, "med"); - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveTemp_Example.java upm-1.7.1/examples/java/GroveTemp_Example.java --- upm-1.6.0/examples/java/GroveTemp_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveTemp_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Author: Andrei Vasiliu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveTemp_Example { + public static void main (String args[]) throws InterruptedException { + //! [Interesting] + upm_grove.GroveTemp temp = new upm_grove.GroveTemp(3); + + for (int i = 0; i < 10; ++i) { + + int celsius = temp.value(); + int fahrneheit = celsius * 2 + 32; + + System.out.println("Celsius: " + celsius); + System.out.println("Fahrneheit: " + fahrneheit); + + Thread.sleep(1000); + } + temp.delete(); + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/GroveTempSample.java upm-1.7.1/examples/java/GroveTempSample.java --- upm-1.6.0/examples/java/GroveTempSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveTempSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* - * Author: Andrei Vasiliu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveTempSample { - public static void main (String args[]) throws InterruptedException { - //! [Interesting] - upm_grove.GroveTemp temp = new upm_grove.GroveTemp(3); - - for (int i = 0; i < 10; ++i) { - - int celsius = temp.value(); - int fahrneheit = celsius * 2 + 32; - - System.out.println("Celsius: " + celsius); - System.out.println("Fahrneheit: " + fahrneheit); - - Thread.sleep(1000); - } - temp.delete(); - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/GroveUltraSonic_Example.java upm-1.7.1/examples/java/GroveUltraSonic_Example.java --- upm-1.6.0/examples/java/GroveUltraSonic_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveUltraSonic_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,41 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class GroveUltraSonic_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + upm_groveultrasonic.GroveUltraSonic sonar = new upm_groveultrasonic.GroveUltraSonic(2); + + while (true) { + int width = sonar.getDistance(); + System.out.println("Echo width = " + width); + System.out.println("Distance inches = " + width / 148.0); + Thread.sleep(1000); + } + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/GroveUltraSonicSample.java upm-1.7.1/examples/java/GroveUltraSonicSample.java --- upm-1.6.0/examples/java/GroveUltraSonicSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveUltraSonicSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class GroveUltraSonicSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - upm_groveultrasonic.GroveUltraSonic sonar = new upm_groveultrasonic.GroveUltraSonic(2); - - while (true) { - int width = sonar.getDistance(); - System.out.println("Echo width = " + width); - System.out.println("Distance inches = " + width / 148.0); - Thread.sleep(1000); - } - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/GroveVDiv_Example.java upm-1.7.1/examples/java/GroveVDiv_Example.java --- upm-1.6.0/examples/java/GroveVDiv_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveVDiv_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class GroveVDiv_Example { + private static final short gain3 = 3; + private static final short gain10 = 10; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Grove Voltage Divider sensor on analog pin A0 + upm_grovevdiv.GroveVDiv vDiv = new upm_grovevdiv.GroveVDiv(0); + + // collect data and output measured voltage according to the setting + // of the scaling switch (3 or 10) + while (true) { + long val = vDiv.value(100); + float gain3val = vDiv.computedValue(gain3, val); + float gain10val = vDiv.computedValue(gain10, val); + + System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: " + + gain10val); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveVDivSample.java upm-1.7.1/examples/java/GroveVDivSample.java --- upm-1.6.0/examples/java/GroveVDivSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveVDivSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class GroveVDivSample { - private static final short gain3 = 3; - private static final short gain10 = 10; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Grove Voltage Divider sensor on analog pin A0 - upm_grovevdiv.GroveVDiv vDiv = new upm_grovevdiv.GroveVDiv(0); - - // collect data and output measured voltage according to the setting - // of the scaling switch (3 or 10) - while (true) { - long val = vDiv.value(100); - float gain3val = vDiv.computedValue(gain3, val); - float gain10val = vDiv.computedValue(gain10, val); - - System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: " - + gain10val); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveWater_Example.java upm-1.7.1/examples/java/GroveWater_Example.java --- upm-1.6.0/examples/java/GroveWater_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveWater_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GroveWater_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Grove Water sensor on digital pin D2 + upm_grovewater.GroveWater water = new upm_grovewater.GroveWater(2); + + while (true) { + boolean val = water.isWet(); + if (val) { + System.out.println("Sensor is wet"); + } else { + System.out.println("Sensor is dry"); + } + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveWaterSample.java upm-1.7.1/examples/java/GroveWaterSample.java --- upm-1.6.0/examples/java/GroveWaterSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveWaterSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GroveWaterSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Grove Water sensor on digital pin D2 - upm_grovewater.GroveWater water = new upm_grovewater.GroveWater(2); - - while (true) { - boolean val = water.isWet(); - if (val) { - System.out.println("Sensor is wet"); - } else { - System.out.println("Sensor is dry"); - } - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveWFS_Example.java upm-1.7.1/examples/java/GroveWFS_Example.java --- upm-1.6.0/examples/java/GroveWFS_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GroveWFS_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class GroveWFS_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Grove Water Flow Sensor on digital pin D2 + upm_grovewfs.GroveWFS flow = new upm_grovewfs.GroveWFS(2); + + flow.clearFlowCounter(); + flow.startFlowCounter(); + + while (true) { + System.out.print("Millis: " + flow.getMillis() + " FlowCount: " + flow.flowCounter()); + System.out.println(" Flow Rate: " + flow.flowRate() + " LPM"); + + Thread.sleep(2000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/GroveWFSSample.java upm-1.7.1/examples/java/GroveWFSSample.java --- upm-1.6.0/examples/java/GroveWFSSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GroveWFSSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class GroveWFSSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Grove Water Flow Sensor on digital pin D2 - upm_grovewfs.GroveWFS flow = new upm_grovewfs.GroveWFS(2); - - flow.clearFlowCounter(); - flow.startFlowCounter(); - - while (true) { - System.out.print("Millis: " + flow.getMillis() + " FlowCount: " + flow.flowCounter()); - System.out.println(" Flow Rate: " + flow.flowRate() + " LPM"); - - Thread.sleep(2000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Gsr_Example.java upm-1.7.1/examples/java/Gsr_Example.java --- upm-1.6.0/examples/java/Gsr_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Gsr_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_gsr.GSR; + +public class Gsr_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + //! [Interesting] + // Instantiate a Grove GSR sensor on analog pin A0 + GSR gsr = new GSR(0); + System.out.println("Calibrating..."); + gsr.calibrate(); + + while(true){ + System.out.println("Value: "+gsr.value()); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/Gsr.java upm-1.7.1/examples/java/Gsr.java --- upm-1.6.0/examples/java/Gsr.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Gsr.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_gsr.GSR; - -public class Gsr { - - public static void main(String[] args) { - // TODO Auto-generated method stub - - //! [Interesting] - // Instantiate a Grove GSR sensor on analog pin A0 - GSR gsr = new GSR(0); - System.out.println("Calibrating..."); - gsr.calibrate(); - - while(true){ - System.out.println("Value: "+gsr.value()); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/GUVAS12D_Example.java upm-1.7.1/examples/java/GUVAS12D_Example.java --- upm-1.6.0/examples/java/GUVAS12D_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/GUVAS12D_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * Author: Stefan Andritoiu + * Jon Trulson + * Copyright (c) 2015-2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class GUVAS12D_Example { + // analog voltage, usually 3.3 or 5.0 + private static final float GUVAS12D_AREF = 5; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a GUVAS12D on analog pin A0 + upm_guvas12d.GUVAS12D volts = new upm_guvas12d.GUVAS12D(0, + GUVAS12D_AREF); + + while (true) + { + System.out.println("Volts: " + + volts.volts() + + ", Intensity: " + + volts.intensity() + + " mW/m^2"); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/GUVAS12DSample.java upm-1.7.1/examples/java/GUVAS12DSample.java --- upm-1.6.0/examples/java/GUVAS12DSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/GUVAS12DSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Jon Trulson - * Copyright (c) 2015-2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GUVAS12DSample { - // analog voltage, usually 3.3 or 5.0 - private static final float GUVAS12D_AREF = 5; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a GUVAS12D on analog pin A0 - upm_guvas12d.GUVAS12D volts = new upm_guvas12d.GUVAS12D(0, - GUVAS12D_AREF); - - while (true) - { - System.out.println("Volts: " - + volts.volts() - + ", Intensity: " - + volts.intensity() - + " mW/m^2"); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/H3LIS331DL_Example.java upm-1.7.1/examples/java/H3LIS331DL_Example.java --- upm-1.6.0/examples/java/H3LIS331DL_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/H3LIS331DL_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,54 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! + +import java.util.AbstractList; +import java.lang.Float; + +public class H3LIS331DL_Example { + + public static void main(String[] args) throws InterruptedException { + //! [Interesting] + + // Instantiate an H3LIS331DL on I2C bus 0 + upm_h3lis331dl.H3LIS331DL sensor = new upm_h3lis331dl.H3LIS331DL(0); + + // Initialize the device with default values + sensor.init(); + + while(true){ + sensor.update(); + + upm_h3lis331dl.IntVector val = sensor.getRawXYZ(); + System.out.println( "Raw: X: " + val.get(0) + " Y: " + val.get(1) + " Z: " + val.get(2) ); + + upm_h3lis331dl.FloatVector accel = sensor.getAcceleration(); + System.out.println( "Acceleration: X: " + accel.get(0) + " Y: " + accel.get(1) + " Z: " + accel.get(2) ); + + Thread.sleep(1000); + } + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/H3LIS331DLSample.java upm-1.7.1/examples/java/H3LIS331DLSample.java --- upm-1.6.0/examples/java/H3LIS331DLSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/H3LIS331DLSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! - -import java.util.AbstractList; -import java.lang.Float; - -public class H3LIS331DLSample { - - public static void main(String[] args) throws InterruptedException { - //! [Interesting] - - // Instantiate an H3LIS331DL on I2C bus 0 - upm_h3lis331dl.H3LIS331DL sensor = new upm_h3lis331dl.H3LIS331DL(0); - - // Initialize the device with default values - sensor.init(); - - while(true){ - sensor.update(); - - upm_h3lis331dl.IntVector val = sensor.getRawXYZ(); - System.out.println( "Raw: X: " + val.get(0) + " Y: " + val.get(1) + " Z: " + val.get(2) ); - - upm_h3lis331dl.FloatVector accel = sensor.getAcceleration(); - System.out.println( "Acceleration: X: " + accel.get(0) + " Y: " + accel.get(1) + " Z: " + accel.get(2) ); - - Thread.sleep(1000); - } - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/HCSR04_Example.java upm-1.7.1/examples/java/HCSR04_Example.java --- upm-1.6.0/examples/java/HCSR04_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/HCSR04_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +import upm_hcsr04.*; + +public class HCSR04_Example { + + // ! [Interesting] + public static void main(String[] args) throws InterruptedException { + HCSR04 sonar = new HCSR04((short) 2, (short) 4); + + Thread.sleep(1000); + + while (true) { + System.out.println("Get distance"); + double distance = sonar.getDistance(HCSR04_U.swigToEnum(0)); + System.out.println("Distance: " + distance); + + Thread.sleep(5000); + } + } +} +// ! [Interesting] \ No newline at end of file diff -Nru upm-1.6.0/examples/java/HCSR04Sample.java upm-1.7.1/examples/java/HCSR04Sample.java --- upm-1.6.0/examples/java/HCSR04Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/HCSR04Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -import upm_hcsr04.*; - -public class HCSR04Sample { - - // ! [Interesting] - public static void main(String[] args) throws InterruptedException { - HCSR04 sonar = new HCSR04((short) 2, (short) 4); - - Thread.sleep(1000); - - while (true) { - System.out.println("Get distance"); - double distance = sonar.getDistance(HCSR04_U.swigToEnum(0)); - System.out.println("Distance: " + distance); - - Thread.sleep(5000); - } - } -} -// ! [Interesting] \ No newline at end of file diff -Nru upm-1.6.0/examples/java/HM11_Example.java upm-1.7.1/examples/java/HM11_Example.java --- upm-1.6.0/examples/java/HM11_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/HM11_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,96 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class HM11_Example { + + private static final int BUFSIZ = 1024; + + private static void printUsage() { + System.out.println("Usage: java HM11_Example [AT command]"); + + System.out.println("If an argument is supplied on the command line, that argument is"); + System.out.println("sent to the module and the response is printed out."); + System.out.println("If no argument is used, then the address and PIN of the module"); + System.out.println("are queried and the results printed out."); + + } + + private static void sendCommand(upm_hm11.HM11 ble, byte[] cmd) { + byte[] buffer = new byte[BUFSIZ]; + ble.writeData(cmd); + + // wait up to 1 second + if (ble.dataAvailable(1000)) { + ble.readData(buffer); + } else { + System.err.println("Timed out waiting for response"); + } + + } + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a HM11 BLE Module on UART 0 + upm_hm11.HM11 ble = new upm_hm11.HM11(0); + + // make sure port is initialized properly. 9600 baud is the default. + if (!ble.setupTty()) { + System.err.println("Failed to setup tty port parameters"); + System.exit(-1); + } + + printUsage(); + + if (args.length > 0) { + System.out.println("Sending command line argument (" + args[0] + ")..."); + sendCommand(ble, args[0].getBytes()); + } else { + // query the module address + String addr = "AT+ADDR?"; + System.out.println("Querying module address (" + addr + ")..."); + sendCommand(ble, addr.getBytes()); + + Thread.sleep(1000); + + // query the module address + String pin = "AT+PASS?"; + System.out.println("Querying module pin (" + pin + ")..."); + sendCommand(ble, pin.getBytes()); + + // Other potentially useful commands are: + // + // AT+VERS? - query module version + // AT+ROLE0 - set as slave + // AT+ROLE1 - set as master + // AT+CLEAR - clear all previous settings + // AT+RESET - restart the device + // + // A comprehensive list is available from the datasheet at: + // http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf + + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/HM11Sample.java upm-1.7.1/examples/java/HM11Sample.java --- upm-1.6.0/examples/java/HM11Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/HM11Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class HM11Sample { - - private static final int BUFSIZ = 1024; - - private static void printUsage() { - System.out.println("Usage: java HM11Sample [AT command]"); - - System.out.println("If an argument is supplied on the command line, that argument is"); - System.out.println("sent to the module and the response is printed out."); - System.out.println("If no argument is used, then the address and PIN of the module"); - System.out.println("are queried and the results printed out."); - - } - - private static void sendCommand(upm_hm11.HM11 ble, byte[] cmd) { - byte[] buffer = new byte[BUFSIZ]; - ble.writeData(cmd); - - // wait up to 1 second - if (ble.dataAvailable(1000)) { - ble.readData(buffer); - } else { - System.err.println("Timed out waiting for response"); - } - - } - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a HM11 BLE Module on UART 0 - upm_hm11.HM11 ble = new upm_hm11.HM11(0); - - // make sure port is initialized properly. 9600 baud is the default. - if (!ble.setupTty()) { - System.err.println("Failed to setup tty port parameters"); - System.exit(-1); - } - - printUsage(); - - if (args.length > 0) { - System.out.println("Sending command line argument (" + args[0] + ")..."); - sendCommand(ble, args[0].getBytes()); - } else { - // query the module address - String addr = "AT+ADDR?"; - System.out.println("Querying module address (" + addr + ")..."); - sendCommand(ble, addr.getBytes()); - - Thread.sleep(1000); - - // query the module address - String pin = "AT+PASS?"; - System.out.println("Querying module pin (" + pin + ")..."); - sendCommand(ble, pin.getBytes()); - - // Other potentially useful commands are: - // - // AT+VERS? - query module version - // AT+ROLE0 - set as slave - // AT+ROLE1 - set as master - // AT+CLEAR - clear all previous settings - // AT+RESET - restart the device - // - // A comprehensive list is available from the datasheet at: - // http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf - - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Hmc5883l_Example.java upm-1.7.1/examples/java/Hmc5883l_Example.java --- upm-1.6.0/examples/java/Hmc5883l_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Hmc5883l_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Hmc5883l_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate on I2C + upm_hmc5883l.Hmc5883l compas = new upm_hmc5883l.Hmc5883l(0); + + short[] pos; + + // Set your declination from true north in radians + compas.set_declination(0.2749f); + + while (true) { + // Update the coordinates + compas.update(); + + pos = compas.coordinates(); + System.out.println("Coor: " + pos[0] + " " + pos[1] + " " + pos[2]); + System.out.println("Heading: " + compas.heading() + " Direction:" + compas.direction()); + + Thread.sleep(2000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Hmc5883lSample.java upm-1.7.1/examples/java/Hmc5883lSample.java --- upm-1.6.0/examples/java/Hmc5883lSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Hmc5883lSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class Hmc5883lSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate on I2C - upm_hmc5883l.Hmc5883l compas = new upm_hmc5883l.Hmc5883l(0); - - short[] pos; - - // Set your declination from true north in radians - compas.set_declination(0.2749f); - - while (true) { - // Update the coordinates - compas.update(); - - pos = compas.coordinates(); - System.out.println("Coor: " + pos[0] + " " + pos[1] + " " + pos[2]); - System.out.println("Heading: " + compas.heading() + " Direction:" + compas.direction()); - - Thread.sleep(2000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/HMTRP_Example.java upm-1.7.1/examples/java/HMTRP_Example.java --- upm-1.6.0/examples/java/HMTRP_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/HMTRP_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,122 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class HMTRP_Example { + + static private final int bufferLength = 255; + + private static void printUsage() { + System.out.println("Usage:"); + System.out.println("Pass a commandline argument (any argument) to this program"); + System.out.println("to query the radio configuration and output it. NOTE: the"); + System.out.println("radio must be in CONFIG mode for this to work."); + System.out.println("Running this program without arguments will simply transmit"); + System.out.println("'Hello World!' every second, and output any data received from"); + System.out.println("another radio."); + } + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a HMTRP radio device on uart 0 + upm_hmtrp.HMTRP radio = new upm_hmtrp.HMTRP(0); + + // make sure port is initialized properly. 9600 baud is the default. + if (!radio.setupTty()) { + System.err.println("Failed to setup tty port parameters"); + System.exit(-1); + } + printUsage(); + + // By default, this radio simply transmits data sent via writeData() + // and reads any available data via readData(). + + // It can be placed into a configuration mode by grounding the + // CONFIG pin on the module. When this is done, the various + // configuration query and config methods can be used. In this + // example, by default, we just read any data available fom the + // device, and periodically transmit "Hello World". + + // If any argument was specified on the command line, do a simple + // configuration query and output the results. The radio must be in + // CONFIG mode for this to work. + + if (args.length > 0) { + // config mode + long[] freq = {0}; + long[] dataRate = {0}; + int[] rxBandwidth = {0}; + short[] modulation = {0}; + short[] txPower = {0}; + long[] uartBaud = {0}; + + if (radio.getConfig(freq, dataRate, rxBandwidth, modulation, txPower, uartBaud)) { + System.out.println("Radio configuration:"); + System.out.println("freq: " + freq[0] + " dataRate: " + dataRate[0] + + " rxBandwidth: " + rxBandwidth[0] + "Khz"); + System.out.println("modulation: " + modulation[0] + "Khz txPower: " + txPower[0] + + " uartBaud: " + uartBaud[0]); + } else { + System.err.println("getConfig() failed. Make sure the radio is in CONFIG mode."); + } + } else { + // normal read/write mode + byte[] radioBuffer = new byte[bufferLength]; + byte[] hello = "Hello World".getBytes(); + int counter = 0; + + System.out.println("Running in normal read/write mode."); + + while (true) { + // we don't want the read to block in this example, so always + // check to see if data is available first. + if (radio.dataAvailable()) { + int rv = radio.readData(radioBuffer); + + if (rv > 0) { + System.out.print("Received: "); + for (int i = 0; i < radioBuffer.length; i++) + System.out.print((char) radioBuffer[i]); + System.out.println(); + } else { + System.err.println("Port read error."); + break; + } + continue; + } + + Thread.sleep(100); + + counter++; + // every second, transmit "Hello World!" + if (counter > 10) { + System.out.println("Transmitting hello world..."); + radio.writeData(hello); + counter = 0; + } + } + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/HMTRPSample.java upm-1.7.1/examples/java/HMTRPSample.java --- upm-1.6.0/examples/java/HMTRPSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/HMTRPSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class HMTRPSample { - - static private final int bufferLength = 255; - - private static void printUsage() { - System.out.println("Usage:"); - System.out.println("Pass a commandline argument (any argument) to this program"); - System.out.println("to query the radio configuration and output it. NOTE: the"); - System.out.println("radio must be in CONFIG mode for this to work."); - System.out.println("Running this program without arguments will simply transmit"); - System.out.println("'Hello World!' every second, and output any data received from"); - System.out.println("another radio."); - } - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a HMTRP radio device on uart 0 - upm_hmtrp.HMTRP radio = new upm_hmtrp.HMTRP(0); - - // make sure port is initialized properly. 9600 baud is the default. - if (!radio.setupTty()) { - System.err.println("Failed to setup tty port parameters"); - System.exit(-1); - } - printUsage(); - - // By default, this radio simply transmits data sent via writeData() - // and reads any available data via readData(). - - // It can be placed into a configuration mode by grounding the - // CONFIG pin on the module. When this is done, the various - // configuration query and config methods can be used. In this - // example, by default, we just read any data available fom the - // device, and periodically transmit "Hello World". - - // If any argument was specified on the command line, do a simple - // configuration query and output the results. The radio must be in - // CONFIG mode for this to work. - - if (args.length > 0) { - // config mode - long[] freq = {0}; - long[] dataRate = {0}; - int[] rxBandwidth = {0}; - short[] modulation = {0}; - short[] txPower = {0}; - long[] uartBaud = {0}; - - if (radio.getConfig(freq, dataRate, rxBandwidth, modulation, txPower, uartBaud)) { - System.out.println("Radio configuration:"); - System.out.println("freq: " + freq[0] + " dataRate: " + dataRate[0] - + " rxBandwidth: " + rxBandwidth[0] + "Khz"); - System.out.println("modulation: " + modulation[0] + "Khz txPower: " + txPower[0] - + " uartBaud: " + uartBaud[0]); - } else { - System.err.println("getConfig() failed. Make sure the radio is in CONFIG mode."); - } - } else { - // normal read/write mode - byte[] radioBuffer = new byte[bufferLength]; - byte[] hello = "Hello World".getBytes(); - int counter = 0; - - System.out.println("Running in normal read/write mode."); - - while (true) { - // we don't want the read to block in this example, so always - // check to see if data is available first. - if (radio.dataAvailable()) { - int rv = radio.readData(radioBuffer); - - if (rv > 0) { - System.out.print("Received: "); - for (int i = 0; i < radioBuffer.length; i++) - System.out.print((char) radioBuffer[i]); - System.out.println(); - } else { - System.err.println("Port read error."); - break; - } - continue; - } - - Thread.sleep(100); - - counter++; - // every second, transmit "Hello World!" - if (counter > 10) { - System.out.println("Transmitting hello world..."); - radio.writeData(hello); - counter = 0; - } - } - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/HP20x_Example.java upm-1.7.1/examples/java/HP20x_Example.java --- upm-1.6.0/examples/java/HP20x_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/HP20x_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_hp20x.HP20X; + +public class HP20x_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + //! [Interesting] + // Instantiate the sensor on the default I2C bus and sensor + HP20X hp20x = new HP20X(); + + // Initializing the sensor with the default values + hp20x.init(); + + while(true){ + System.out.println("Temperature: "+hp20x.getTemperature()+"\tPressure: "+hp20x.getPressure()+"\tAltitude: "+hp20x.getAltitude()); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/HP20xExample.java upm-1.7.1/examples/java/HP20xExample.java --- upm-1.6.0/examples/java/HP20xExample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/HP20xExample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_hp20x.HP20X; - -public class HP20xExample { - - public static void main(String[] args) { - // TODO Auto-generated method stub - - //! [Interesting] - // Instantiate the sensor on the default I2C bus and sensor - HP20X hp20x = new HP20X(); - - // Initializing the sensor with the default values - hp20x.init(); - - while(true){ - System.out.println("Temperature: "+hp20x.getTemperature()+"\tPressure: "+hp20x.getPressure()+"\tAltitude: "+hp20x.getAltitude()); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/HTU21D_Example.java upm-1.7.1/examples/java/HTU21D_Example.java --- upm-1.6.0/examples/java/HTU21D_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/HTU21D_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class HTU21D_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_htu21d.HTU21D sensor = new upm_htu21d.HTU21D(0); + sensor.testSensor(); + + while (true) { + sensor.sampleData(); + + System.out.println("Humidity: " + sensor.getHumidity() + "%"); + System.out.println("Compensated RH: " + sensor.getCompRH() + "%"); + System.out.println("Temperature: " + sensor.getTemperature() + "C"); + System.out.println("Dew Point: " + sensor.getDewPoint() + "C"); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/HTU21DSample.java upm-1.7.1/examples/java/HTU21DSample.java --- upm-1.6.0/examples/java/HTU21DSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/HTU21DSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class HTU21DSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_htu21d.HTU21D sensor = new upm_htu21d.HTU21D(0); - sensor.testSensor(); - - while (true) { - sensor.sampleData(); - - System.out.println("Humidity: " + sensor.getHumidity() + "%"); - System.out.println("Compensated RH: " + sensor.getCompRH() + "%"); - System.out.println("Temperature: " + sensor.getTemperature() + "C"); - System.out.println("Dew Point: " + sensor.getDewPoint() + "C"); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/Itg3200_Example.java upm-1.7.1/examples/java/Itg3200_Example.java --- upm-1.6.0/examples/java/Itg3200_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Itg3200_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,51 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class Itg3200_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + short[] rot; + float[] ang; + + // Note: Sensor not supported on Intel Edison with Arduino breakout + upm_itg3200.Itg3200 gyro = new upm_itg3200.Itg3200(0); + + while (true) { + gyro.update(); + rot = gyro.getRawValues(); + ang = gyro.getRotation(); + + System.out.println("Raw Values: X: " + rot[0] + " Y: " + rot[1] + " Z: " + rot[2]); + System.out.println("Angular Velocities: X: " + ang[0] + " Y: " + ang[1] + " Z: " + + ang[2]); + + System.out.println("Temp: " + gyro.getTemperature() + ", Raw: " + gyro.getRawTemp()); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Itg3200Sample.java upm-1.7.1/examples/java/Itg3200Sample.java --- upm-1.6.0/examples/java/Itg3200Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Itg3200Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class Itg3200Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - short[] rot; - float[] ang; - - // Note: Sensor not supported on Intel Edison with Arduino breakout - upm_itg3200.Itg3200 gyro = new upm_itg3200.Itg3200(0); - - while (true) { - gyro.update(); - rot = gyro.getRawValues(); - ang = gyro.getRotation(); - - System.out.println("Raw Values: X: " + rot[0] + " Y: " + rot[1] + " Z: " + rot[2]); - System.out.println("Angular Velocities: X: " + ang[0] + " Y: " + ang[1] + " Z: " - + ang[2]); - - System.out.println("Temp: " + gyro.getTemperature() + ", Raw: " + gyro.getRawTemp()); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Jhd1313m1_Example.java upm-1.7.1/examples/java/Jhd1313m1_Example.java --- upm-1.6.0/examples/java/Jhd1313m1_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Jhd1313m1_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Jhd1313m1_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_jhd1313m1.Jhd1313m1 lcd = new upm_jhd1313m1.Jhd1313m1(0); + + lcd.setCursor(0, 0); + lcd.write("Hello World"); + lcd.setCursor(1, 2); + lcd.write("Hello World"); + + System.out.println("Sleeping for 5 seconds"); + Thread.sleep(5000); + lcd.clear(); + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/Jhd1313m1_lcd_Example.java upm-1.7.1/examples/java/Jhd1313m1_lcd_Example.java --- upm-1.6.0/examples/java/Jhd1313m1_lcd_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Jhd1313m1_lcd_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Jhd1313m1_lcd_Example{ + + public static void main(String[] args) throws InterruptedException { + //! [Interesting] + upm_jhd1313m1.Jhd1313m1 lcd = + new upm_jhd1313m1.Jhd1313m1(1, 0x3E, 0x62); + + lcd.setCursor(0,0); + lcd.write("Hello World"); + lcd.setCursor(1,2); + lcd.write("Hello World"); + + System.out.println("Sleeping for 5 seconds"); + Thread.sleep(5000); + lcd.clear(); + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/Jhd1313m1_lcdSample.java upm-1.7.1/examples/java/Jhd1313m1_lcdSample.java --- upm-1.6.0/examples/java/Jhd1313m1_lcdSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Jhd1313m1_lcdSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class Jhd1313m1_lcdSample{ - - public static void main(String[] args) throws InterruptedException { - //! [Interesting] - upm_jhd1313m1.Jhd1313m1 lcd = - new upm_jhd1313m1.Jhd1313m1(1, 0x3E, 0x62); - - lcd.setCursor(0,0); - lcd.write("Hello World"); - lcd.setCursor(1,2); - lcd.write("Hello World"); - - System.out.println("Sleeping for 5 seconds"); - Thread.sleep(5000); - lcd.clear(); - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/Jhd1313m1Sample.java upm-1.7.1/examples/java/Jhd1313m1Sample.java --- upm-1.6.0/examples/java/Jhd1313m1Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Jhd1313m1Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class Jhd1313m1Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_jhd1313m1.Jhd1313m1 lcd = new upm_jhd1313m1.Jhd1313m1(0); - - lcd.setCursor(0, 0); - lcd.write("Hello World"); - lcd.setCursor(1, 2); - lcd.write("Hello World"); - - System.out.println("Sleeping for 5 seconds"); - Thread.sleep(5000); - lcd.clear(); - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/Joystick12_example_Example.java upm-1.7.1/examples/java/Joystick12_example_Example.java --- upm-1.6.0/examples/java/Joystick12_example_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Joystick12_example_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Joystick12_example_Example { + + public static void main(String[] args) throws InterruptedException { + //! [Interesting] + // Instantiate a joystick on analog pins A0 and A1 + upm_joystick12.Joystick12 joystick = new upm_joystick12.Joystick12(0,1); + + // Print the X and Y input values every second + while(true){ + float x = joystick.getXInput(); + float y = joystick.getYInput(); + + System.out.println("Driving X: " + x + " , and Y: " + y ); + + Thread.sleep(1000); + } + //! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Joystick12_Example.java upm-1.7.1/examples/java/Joystick12_Example.java --- upm-1.6.0/examples/java/Joystick12_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Joystick12_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Joystick12_Example { + + public static void main(String[] args) throws InterruptedException { + //! [Interesting] + // Instantiate a joystick on analog pins A0 and A1 + upm_joystick12.Joystick12 joystick = new upm_joystick12.Joystick12(0,1); + + // Print the X and Y input values every second + while(true){ + float x = joystick.getXInput(); + float y = joystick.getYInput(); + + System.out.println("Driving X: " + x + " , and Y: " + y ); + + Thread.sleep(1000); + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/Joystick12_exampleSample.java upm-1.7.1/examples/java/Joystick12_exampleSample.java --- upm-1.6.0/examples/java/Joystick12_exampleSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Joystick12_exampleSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class Joystick12_exampleSample { - - public static void main(String[] args) throws InterruptedException { - //! [Interesting] - // Instantiate a joystick on analog pins A0 and A1 - upm_joystick12.Joystick12 joystick = new upm_joystick12.Joystick12(0,1); - - // Print the X and Y input values every second - while(true){ - float x = joystick.getXInput(); - float y = joystick.getYInput(); - - System.out.println("Driving X: " + x + " , and Y: " + y ); - - Thread.sleep(1000); - } - //! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Joystick12Sample.java upm-1.7.1/examples/java/Joystick12Sample.java --- upm-1.6.0/examples/java/Joystick12Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Joystick12Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class Joystick12Sample { - - public static void main(String[] args) throws InterruptedException { - //! [Interesting] - // Instantiate a joystick on analog pins A0 and A1 - upm_joystick12.Joystick12 joystick = new upm_joystick12.Joystick12(0,1); - - // Print the X and Y input values every second - while(true){ - float x = joystick.getXInput(); - float y = joystick.getYInput(); - - System.out.println("Driving X: " + x + " , and Y: " + y ); - - Thread.sleep(1000); - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/KX122_Example.java upm-1.7.1/examples/java/KX122_Example.java --- upm-1.6.0/examples/java/KX122_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/KX122_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Author: Noel Eck + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class KX122_Example { + public static void main(String[] args) throws InterruptedException { + //! [Interesting] + // Instantiate a KX122 + upm_kx122.KX122 kx122 = new upm_kx122.KX122(0, -1, 24); + + // Reset the device + kx122.softwareReset(); + + // Initialize the device + kx122.deviceInit(upm_kx122.KX122_ODR_T.KX122_ODR_50, + upm_kx122.KX122_RES_T.HIGH_RES, + upm_kx122.KX122_RANGE_T.KX122_RANGE_2G); + + // Print the acceleration + while(true){ + upm_kx122.floatVector xyz = kx122.getAccelerationDataVector(); + System.out.println("Acceleration: x = " + xyz.get(0) + + " y = " + xyz.get(1) + + " z = " + xyz.get(2)); + + Thread.sleep(1000); + } + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/KXTJ3_Example.java upm-1.7.1/examples/java/KXTJ3_Example.java --- upm-1.6.0/examples/java/KXTJ3_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/KXTJ3_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,49 @@ +/* +* 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 KXTJ3_Example { + + public static void main(String[] args) throws InterruptedException { + + upm_kxtj3.KXTJ3 kxtj3 = new upm_kxtj3.KXTJ3(0); + + kxtj3.SensorInit(upm_kxtj3.KXTJ3_ODR_T.KXTJ3_ODR_25, + upm_kxtj3.KXTJ3_RESOLUTION_T.HIGH_RES, + upm_kxtj3.KXTJ3_G_RANGE_T.KXTJ3_RANGE_16G_14); + + float waitTime = kxtj3.GetAccelerationSamplePeriod() * 1000; + int sampleCounter = 10; + System.out.println("Setting settings:\nODR: 25 Hz\nResolution: " + + "High\nAcceleration range: 16g with 14bits"); + System.out.println("Acceleration"); + upm_kxtj3.floatVector xyz; + while (sampleCounter-- > 0) { + xyz = kxtj3.GetAccelerationVector(); + System.out.println("x = " + xyz.get(0) + " y = " + xyz.get(1) + + " z = " + xyz.get(2)); + + Thread.sleep((long) waitTime); + } + } +} diff -Nru upm-1.6.0/examples/java/LCD_EBOLED_Example.java upm-1.7.1/examples/java/LCD_EBOLED_Example.java --- upm-1.6.0/examples/java/LCD_EBOLED_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LCD_EBOLED_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class LCD_EBOLED_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + // Instantiate an Edison Block OLED using default values + upm_lcd.EBOLED lcd = new upm_lcd.EBOLED(); + + lcd.clear(); + lcd.setCursor(10, 15); + lcd.write("Hello"); + lcd.setCursor(30, 15); + lcd.write("World!"); + lcd.refresh(); + + System.out.println("Sleeping for 5 secconds..."); + Thread.sleep(5000); + + lcd.delete(); + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/LCD_EBOLEDSample.java upm-1.7.1/examples/java/LCD_EBOLEDSample.java --- upm-1.6.0/examples/java/LCD_EBOLEDSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LCD_EBOLEDSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class LCD_EBOLEDSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - // Instantiate an Edison Block OLED using default values - upm_lcd.EBOLED lcd = new upm_lcd.EBOLED(); - - lcd.clear(); - lcd.setCursor(10, 15); - lcd.write("Hello"); - lcd.setCursor(30, 15); - lcd.write("World!"); - lcd.refresh(); - - System.out.println("Sleeping for 5 secconds..."); - Thread.sleep(5000); - - lcd.delete(); - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/LCD_SSD1306_Example.java upm-1.7.1/examples/java/LCD_SSD1306_Example.java --- upm-1.6.0/examples/java/LCD_SSD1306_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LCD_SSD1306_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,146 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class LCD_SSD1306_Example { + + static private final int[] intel_logo = new int[]{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -128, -128, -128, 192, 192, 192, 224, + 224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, 60, + 62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, + 30, 62, 62, 62, 62, 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240, + 224, 224, 224, 192, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, + 128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195, + 195, 7, 15, 15, 63, 127, 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0, + 0, 0, 0, 0, 0, 128, 192, 192, 240, 248, 124, 124, 60, 0, 0, 0, 0, 159, 159, + 159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, + 0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128, + 128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128, + 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, + 0, 0, 0, 0, 3, 7, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255, + 255, 255, 0, 0, 224, 248, 252, 252, 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, + 255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, 255, 255, + 255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, + 15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143, + 135, 135, 143, 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255, + 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, + 224, 248, 248, 255, 255, 255, 255, 255, 127, 15, 255, 255, 255, 255, 255, + 255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, + 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, + 255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255, + 255, 255, 255, 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231, + 231, 231, 199, 135, 0, 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0, + 0, 0, 224, 240, 248, 248, 252, 254, 255, 255, 255, 127, 63, 63, 31, 15, 7, + 7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, 240, 192, 192, 128, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7, + 7, 7, 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7, + 7, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15, + 31, 127, 127, 127, 255, 255, 252, 252, 252, 248, 240, 240, 240, 224, 224, + 224, 192, 192, 192, 192, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192, + 224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, 252, + 254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 3, 3, 3, 7, 7, 7, 15, 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127, + 127, 127, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, + 255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 127, 127, 127, 127, + 63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, 3, 3, + 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 + }; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + upm_lcd.SSD1306 lcd = new upm_lcd.SSD1306(0x0, 0x3D); + + byte[] image = new byte[intel_logo.length]; + for (int i = 0; i < intel_logo.length; i++) + image[i] = (byte) intel_logo[i]; + + lcd.clear(); + lcd.stopscroll(); + lcd.draw(image); + + Thread.sleep(5000); + + lcd.clear(); + lcd.setCursor(2, 0); + lcd.write("Hello"); + lcd.setCursor(3,0); + lcd.write("World"); + + Thread.sleep(3000); + + lcd.invert(true); + + Thread.sleep(3000); + + lcd.dim(true); + + Thread.sleep(3000); + + lcd.dim(false); + + Thread.sleep(3000); + + lcd.invert(false); + lcd.startscrollright((short) 0x00, (short) 0x0F); + + Thread.sleep(5000); + + lcd.stopscroll(); + lcd.startscrollleft((short) 0x00, (short) 0x0F); + + Thread.sleep(5000); + + lcd.stopscroll(); + lcd.startscrolldiagleft((short) 0x00, (short) 0x0F); + + Thread.sleep(5000);; + + lcd.stopscroll(); + lcd.startscrolldiagright((short) 0x00,(short) 0x0F); + + Thread.sleep(5000); + + lcd.stopscroll(); + + lcd.delete(); + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/LCD_SSD1306Sample.java upm-1.7.1/examples/java/LCD_SSD1306Sample.java --- upm-1.6.0/examples/java/LCD_SSD1306Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LCD_SSD1306Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class LCD_SSD1306Sample { - - static private final int[] intel_logo = new int[]{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -128, -128, -128, 192, 192, 192, 224, - 224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, 60, - 62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, - 30, 62, 62, 62, 62, 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240, - 224, 224, 224, 192, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, - 128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195, - 195, 7, 15, 15, 63, 127, 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0, - 0, 0, 0, 0, 0, 128, 192, 192, 240, 248, 124, 124, 60, 0, 0, 0, 0, 159, 159, - 159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, - 0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128, - 128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128, - 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, - 0, 0, 0, 0, 3, 7, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255, - 255, 255, 0, 0, 224, 248, 252, 252, 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, - 255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, 255, 255, - 255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, - 15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143, - 135, 135, 143, 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255, - 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, - 224, 248, 248, 255, 255, 255, 255, 255, 127, 15, 255, 255, 255, 255, 255, - 255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, - 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, - 255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255, - 255, 255, 255, 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231, - 231, 231, 199, 135, 0, 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0, - 0, 0, 224, 240, 248, 248, 252, 254, 255, 255, 255, 127, 63, 63, 31, 15, 7, - 7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, 240, 192, 192, 128, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7, - 7, 7, 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7, - 7, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15, - 31, 127, 127, 127, 255, 255, 252, 252, 252, 248, 240, 240, 240, 224, 224, - 224, 192, 192, 192, 192, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192, - 224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, 252, - 254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 3, 3, 3, 7, 7, 7, 15, 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127, - 127, 127, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 127, 127, 127, 127, - 63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, 3, 3, - 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 - }; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - upm_lcd.SSD1306 lcd = new upm_lcd.SSD1306(0x0, 0x3D); - - byte[] image = new byte[intel_logo.length]; - for (int i = 0; i < intel_logo.length; i++) - image[i] = (byte) intel_logo[i]; - - lcd.clear(); - lcd.stopscroll(); - lcd.draw(image); - - Thread.sleep(5000); - - lcd.clear(); - lcd.setCursor(2, 0); - lcd.write("Hello"); - lcd.setCursor(3,0); - lcd.write("World"); - - Thread.sleep(3000); - - lcd.invert(true); - - Thread.sleep(3000); - - lcd.dim(true); - - Thread.sleep(3000); - - lcd.dim(false); - - Thread.sleep(3000); - - lcd.invert(false); - lcd.startscrollright((short) 0x00, (short) 0x0F); - - Thread.sleep(5000); - - lcd.stopscroll(); - lcd.startscrollleft((short) 0x00, (short) 0x0F); - - Thread.sleep(5000); - - lcd.stopscroll(); - lcd.startscrolldiagleft((short) 0x00, (short) 0x0F); - - Thread.sleep(5000);; - - lcd.stopscroll(); - lcd.startscrolldiagright((short) 0x00,(short) 0x0F); - - Thread.sleep(5000); - - lcd.stopscroll(); - - lcd.delete(); - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Lcm1602_i2c_Example.java upm-1.7.1/examples/java/Lcm1602_i2c_Example.java --- upm-1.6.0/examples/java/Lcm1602_i2c_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Lcm1602_i2c_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class Lcm1602_i2c_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_lcm1602.Lcm1602 lcd = new upm_lcm1602.Lcm1602(0, 0x27); + + lcd.setCursor(0, 0); + lcd.write("Hello World"); + Thread.sleep(3000); + + lcd.setCursor(1, 2); + lcd.write("Hello World"); + Thread.sleep(3000); + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/Lcm1602_i2cSample.java upm-1.7.1/examples/java/Lcm1602_i2cSample.java --- upm-1.6.0/examples/java/Lcm1602_i2cSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Lcm1602_i2cSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class Lcm1602_i2cSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_lcm1602.Lcm1602 lcd = new upm_lcm1602.Lcm1602(0, 0x27); - - lcd.setCursor(0, 0); - lcd.write("Hello World"); - Thread.sleep(3000); - - lcd.setCursor(1, 2); - lcd.write("Hello World"); - Thread.sleep(3000); - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Lcm1602_parallel_Example.java upm-1.7.1/examples/java/Lcm1602_parallel_Example.java --- upm-1.6.0/examples/java/Lcm1602_parallel_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Lcm1602_parallel_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class Lcm1602_parallel_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // LCD connection: + // LCD RS pin to digital pin 8 + // LCD Enable pin to digital pin 13 + // LCD D4 pin to digital pin 2 + // LCD D5 pin to digital pin 3 + // LCD D6 pin to digital pin 4 + // LCD D7 pin to digital pin 5 + // LCD R/W pin to ground + // 10K trimmer potentiometer: + // ends to +5V and ground + // wiper to LCD VO pin (pin 3) + upm_lcm1602.Lcm1602 lcd = + new upm_lcm1602.Lcm1602(8, 13, 2, 3, 4, 5, (short) 16, (short) 2); + + lcd.setCursor(0, 0); + lcd.write("Hello World"); + lcd.setCursor(1, 2); + lcd.write("Hello World"); + + System.out.println("Sleeping for 5 seconds"); + Thread.sleep(5000); + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/Lcm1602_parallelSample.java upm-1.7.1/examples/java/Lcm1602_parallelSample.java --- upm-1.6.0/examples/java/Lcm1602_parallelSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Lcm1602_parallelSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class Lcm1602_parallelSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // LCD connection: - // LCD RS pin to digital pin 8 - // LCD Enable pin to digital pin 13 - // LCD D4 pin to digital pin 2 - // LCD D5 pin to digital pin 3 - // LCD D6 pin to digital pin 4 - // LCD D7 pin to digital pin 5 - // LCD R/W pin to ground - // 10K trimmer potentiometer: - // ends to +5V and ground - // wiper to LCD VO pin (pin 3) - upm_lcm1602.Lcm1602 lcd = - new upm_lcm1602.Lcm1602(8, 13, 2, 3, 4, 5, (short) 16, (short) 2); - - lcd.setCursor(0, 0); - lcd.write("Hello World"); - lcd.setCursor(1, 2); - lcd.write("Hello World"); - - System.out.println("Sleeping for 5 seconds"); - Thread.sleep(5000); - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/LDT0028_Example.java upm-1.7.1/examples/java/LDT0028_Example.java --- upm-1.6.0/examples/java/LDT0028_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LDT0028_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class LDT0028_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + // Create the LDT0-028 Piezo Vibration Sensor object using AIO pin 0 + upm_ldt0028.LDT0028 sensor = new upm_ldt0028.LDT0028(0); + + System.out.println("Sensor name: " + sensor.name()); + + while (true) { + System.out.println("Sample value: " + sensor.getSample()); + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/LDT0028Sample.java upm-1.7.1/examples/java/LDT0028Sample.java --- upm-1.6.0/examples/java/LDT0028Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LDT0028Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class LDT0028Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - // Create the LDT0-028 Piezo Vibration Sensor object using AIO pin 0 - upm_ldt0028.LDT0028 sensor = new upm_ldt0028.LDT0028(0); - - System.out.println("Sensor name: " + sensor.name()); - - while (true) { - System.out.println("Sample value: " + sensor.getSample()); - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/LED_Example.java upm-1.7.1/examples/java/LED_Example.java --- upm-1.6.0/examples/java/LED_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LED_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Author: Andrei Vasiliu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class LED_Example { + public static void main (String args[]) throws InterruptedException { + //! [Interesting] + upm_led.Led led = new upm_led.Led(2); + + for (int i = 0; i < 10; ++i) { + led.on(); + Thread.sleep(1000); + led.off(); + Thread.sleep(1000); + } + led.delete(); + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/LEDSample.java upm-1.7.1/examples/java/LEDSample.java --- upm-1.6.0/examples/java/LEDSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LEDSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* - * Author: Andrei Vasiliu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class LEDSample { - public static void main (String args[]) throws InterruptedException { - //! [Interesting] - upm_led.Led led = new upm_led.Led(2); - - for (int i = 0; i < 10; ++i) { - led.on(); - Thread.sleep(1000); - led.off(); - Thread.sleep(1000); - } - led.delete(); - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Light_Example.java upm-1.7.1/examples/java/Light_Example.java --- upm-1.6.0/examples/java/Light_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Light_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,41 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Light_Example { + public static void main(String args[]) throws InterruptedException { + // ! [Interesting] + upm_light.Light gl = new upm_light.Light(0); + + while (true) { + float raw_value = gl.getNormalized(); + float value = gl.value(); + + System.out.println("normalized: " + raw_value); + System.out.println("value: " + value); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/LightSample.java upm-1.7.1/examples/java/LightSample.java --- upm-1.6.0/examples/java/LightSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LightSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class LightSample { - public static void main(String args[]) throws InterruptedException { - // ! [Interesting] - upm_light.Light gl = new upm_light.Light(0); - - while (true) { - float raw_value = gl.getNormalized(); - float value = gl.value(); - - System.out.println("normalized: " + raw_value); - System.out.println("value: " + value); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/LineFinder_Example.java upm-1.7.1/examples/java/LineFinder_Example.java --- upm-1.6.0/examples/java/LineFinder_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LineFinder_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class LineFinder_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Line Finder sensor on digital pin D2 + upm_linefinder.LineFinder finder = new upm_linefinder.LineFinder(2); + // check every second for the presence of white detection + while (true) { + boolean val = finder.whiteDetected(); + if (val) { + System.out.println("White detected"); + } else { + System.out.println("Black detected"); + } + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/LineFinderSample.java upm-1.7.1/examples/java/LineFinderSample.java --- upm-1.6.0/examples/java/LineFinderSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LineFinderSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class LineFinderSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Line Finder sensor on digital pin D2 - upm_linefinder.LineFinder finder = new upm_linefinder.LineFinder(2); - // check every second for the presence of white detection - while (true) { - boolean val = finder.whiteDetected(); - if (val) { - System.out.println("White detected"); - } else { - System.out.println("Black detected"); - } - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/LM35_Example.java upm-1.7.1/examples/java/LM35_Example.java --- upm-1.6.0/examples/java/LM35_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LM35_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class LM35_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + // Instantiate a LM35 on analog pin A0, with a default analog + // reference voltage of 5.0 + upm_lm35.LM35 sensor = new upm_lm35.LM35(0); + + // Every half second, sample the sensor and output the temperature + + while (true) { + System.out.println("Temperature: " + sensor.getTemperature() + " C"); + Thread.sleep(500); + } + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/LM35Sample.java upm-1.7.1/examples/java/LM35Sample.java --- upm-1.6.0/examples/java/LM35Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LM35Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class LM35Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - // Instantiate a LM35 on analog pin A0, with a default analog - // reference voltage of 5.0 - upm_lm35.LM35 sensor = new upm_lm35.LM35(0); - - // Every half second, sample the sensor and output the temperature - - while (true) { - System.out.println("Temperature: " + sensor.getTemperature() + " C"); - Thread.sleep(500); - } - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/LoL_example_Example.java upm-1.7.1/examples/java/LoL_example_Example.java --- upm-1.6.0/examples/java/LoL_example_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LoL_example_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class LoL_example_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_lol.LoL sensor = new upm_lol.LoL(); + + int x = 0, y = 0; + while (true) { + // revert pixel + sensor.setPixel(x, y, sensor.getPixel(x, y)); + + if (++x == 13) { + x = 0; + y++; + } + if (y == 9) + y = 0; + Thread.sleep(10); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/LoL_Example.java upm-1.7.1/examples/java/LoL_Example.java --- upm-1.6.0/examples/java/LoL_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LoL_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class LoL_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_lol.LoL sensor = new upm_lol.LoL(); + + int x = 0, y = 0; + while (true) { + // revert pixel + sensor.setPixel(x, y, sensor.getPixel(x, y)); + + if (++x == 13) { + x = 0; + y++; + } + if (y == 9) + y = 0; + Thread.sleep(10); + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/LoL_exampleSample.java upm-1.7.1/examples/java/LoL_exampleSample.java --- upm-1.6.0/examples/java/LoL_exampleSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LoL_exampleSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class LoL_exampleSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_lol.LoL sensor = new upm_lol.LoL(); - - int x = 0, y = 0; - while (true) { - // revert pixel - sensor.setPixel(x, y, sensor.getPixel(x, y)); - - if (++x == 13) { - x = 0; - y++; - } - if (y == 9) - y = 0; - Thread.sleep(10); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/LoLSample.java upm-1.7.1/examples/java/LoLSample.java --- upm-1.6.0/examples/java/LoLSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LoLSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class LoLSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_lol.LoL sensor = new upm_lol.LoL(); - - int x = 0, y = 0; - while (true) { - // revert pixel - sensor.setPixel(x, y, sensor.getPixel(x, y)); - - if (++x == 13) { - x = 0; - y++; - } - if (y == 9) - y = 0; - Thread.sleep(10); - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Loudness_Example.java upm-1.7.1/examples/java/Loudness_Example.java --- upm-1.6.0/examples/java/Loudness_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Loudness_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class Loudness_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Loudness sensor on analog pin A0, with an analog + // reference voltage of 5.0V + upm_loudness.Loudness loud = new upm_loudness.Loudness(0, (float) 5.0); + + // Every tenth of a second, sample the loudness and output it's + // corresponding analog voltage. + + while (true) { + System.out.println("Detected loudness (volts): " + loud.loudness()); + Thread.sleep(100); + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/LoudnessSample.java upm-1.7.1/examples/java/LoudnessSample.java --- upm-1.6.0/examples/java/LoudnessSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LoudnessSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class LoudnessSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Loudness sensor on analog pin A0, with an analog - // reference voltage of 5.0V - upm_loudness.Loudness loud = new upm_loudness.Loudness(0, (float) 5.0); - - // Every tenth of a second, sample the loudness and output it's - // corresponding analog voltage. - - while (true) { - System.out.println("Detected loudness (volts): " + loud.loudness()); - Thread.sleep(100); - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/LSM303DLH_Example.java upm-1.7.1/examples/java/LSM303DLH_Example.java --- upm-1.6.0/examples/java/LSM303DLH_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LSM303DLH_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,59 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class LSM303DLH_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate LSM303DLH compass on I2C + upm_lsm303dlh.LSM303DLH sensor = new upm_lsm303dlh.LSM303DLH(0); + + // Get the coordinate data + sensor.getCoordinates(); + short[] coor = sensor.getRawCoorData(); // in XYZ order. + // The sensor returns XZY, but the driver compensates and makes it XYZ + + // Print out the X, Y, and Z coordinate data using two different methods + System.out.println("coor: rX " + coor[0] + " - rY " + coor[1] + " - rZ " + coor[2]); + System.out.println("coor: gX " + sensor.getCoorX() + " - gY " + sensor.getCoorY() + + " - gZ " + sensor.getCoorZ()); + + // Get and print out the heading + System.out.println("heading: " + sensor.getHeading()); + + // Get the acceleration + sensor.getAcceleration(); + short[] accel = sensor.getRawAccelData(); + + // Print out the X, Y, and Z acceleration data using two different + // methods + System.out.println("acc: rX " + accel[0] + " - rY " + accel[1] + " - rZ " + accel[2]); + System.out.println("acc: gX " + sensor.getAccelX() + " - gY " + sensor.getAccelY() + + " - gZ " + sensor.getAccelZ()); + + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/LSM303DLHSample.java upm-1.7.1/examples/java/LSM303DLHSample.java --- upm-1.6.0/examples/java/LSM303DLHSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LSM303DLHSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class LSM303DLHSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate LSM303DLH compass on I2C - upm_lsm303dlh.LSM303DLH sensor = new upm_lsm303dlh.LSM303DLH(0); - - // Get the coordinate data - sensor.getCoordinates(); - short[] coor = sensor.getRawCoorData(); // in XYZ order. - // The sensor returns XZY, but the driver compensates and makes it XYZ - - // Print out the X, Y, and Z coordinate data using two different methods - System.out.println("coor: rX " + coor[0] + " - rY " + coor[1] + " - rZ " + coor[2]); - System.out.println("coor: gX " + sensor.getCoorX() + " - gY " + sensor.getCoorY() - + " - gZ " + sensor.getCoorZ()); - - // Get and print out the heading - System.out.println("heading: " + sensor.getHeading()); - - // Get the acceleration - sensor.getAcceleration(); - short[] accel = sensor.getRawAccelData(); - - // Print out the X, Y, and Z acceleration data using two different - // methods - System.out.println("acc: rX " + accel[0] + " - rY " + accel[1] + " - rZ " + accel[2]); - System.out.println("acc: gX " + sensor.getAccelX() + " - gY " + sensor.getAccelY() - + " - gZ " + sensor.getAccelZ()); - - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/LSM9DS0_Example.java upm-1.7.1/examples/java/LSM9DS0_Example.java --- upm-1.6.0/examples/java/LSM9DS0_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/LSM9DS0_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,59 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class LSM9DS0_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting + + // Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b, + // xm addr 1d) + + upm_lsm9ds0.LSM9DS0 sensor = new upm_lsm9ds0.LSM9DS0(); + + sensor.init(); + + while (true) { + sensor.update(); + + float[] accel = sensor.getAccelerometer(); + System.out.println("Accelerometer: "); + System.out.println("AX: " + accel[0] + "; AY: " + accel[1] + "; AZ: " + accel[2]); + + float[] gyro = sensor.getGyroscope(); + System.out.println("Gyroscope: "); + System.out.println("GX: " + gyro[0] + "; GY: " + gyro[1] + "; GZ: " + gyro[2]); + + float[] magnet = sensor.getMagnetometer(); + System.out.println("Magnetometer: "); + System.out.println("MX: " + magnet[0] + "; MY: " + magnet[1] + "; MZ: " + magnet[2]); + + System.out.println("Temperature: " + sensor.getTemperature()); + + Thread.sleep(500); + } + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/LSM9DS0Sample.java upm-1.7.1/examples/java/LSM9DS0Sample.java --- upm-1.6.0/examples/java/LSM9DS0Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/LSM9DS0Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class LSM9DS0Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting - - // Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b, - // xm addr 1d) - - upm_lsm9ds0.LSM9DS0 sensor = new upm_lsm9ds0.LSM9DS0(); - - sensor.init(); - - while (true) { - sensor.update(); - - float[] accel = sensor.getAccelerometer(); - System.out.println("Accelerometer: "); - System.out.println("AX: " + accel[0] + "; AY: " + accel[1] + "; AZ: " + accel[2]); - - float[] gyro = sensor.getGyroscope(); - System.out.println("Gyroscope: "); - System.out.println("GX: " + gyro[0] + "; GY: " + gyro[1] + "; GZ: " + gyro[2]); - - float[] magnet = sensor.getMagnetometer(); - System.out.println("Magnetometer: "); - System.out.println("MX: " + magnet[0] + "; MY: " + magnet[1] + "; MZ: " + magnet[2]); - - System.out.println("Temperature: " + sensor.getTemperature()); - - Thread.sleep(500); - } - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/M24LR64E_Example.java upm-1.7.1/examples/java/M24LR64E_Example.java --- upm-1.6.0/examples/java/M24LR64E_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/M24LR64E_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,55 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class M24LR64E_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate an M24LR64E on I2C bus 0 + upm_m24lr64e.M24LR64E nfcTag = new upm_m24lr64e.M24LR64E(0); + + // This example accesses the device in the 'user' (default) mode, + // reads the last byte of data in the EEPROM, inverts it, writes + // it back, and then re-reads it. + + // Read the last byte of the EEPROM area + int addr = upm_m24lr64e.M24LR64E.EEPROM_I2C_LENGTH - 1; + System.out.println("Address: " + addr); + short read = nfcTag.readByte(addr); + System.out.println("Read: " + read); + + // Now change it to it's opposite and write it + read = (short) (~read & 0xff); + nfcTag.writeByte(addr, read); + System.out.println("Wrote: " + read); + + // Now read it back + read = nfcTag.readByte(addr); + System.out.println("Read: " + read); + + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/M24LR64ESample.java upm-1.7.1/examples/java/M24LR64ESample.java --- upm-1.6.0/examples/java/M24LR64ESample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/M24LR64ESample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class M24LR64ESample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate an M24LR64E on I2C bus 0 - upm_m24lr64e.M24LR64E nfcTag = new upm_m24lr64e.M24LR64E(0); - - // This example accesses the device in the 'user' (default) mode, - // reads the last byte of data in the EEPROM, inverts it, writes - // it back, and then re-reads it. - - // Read the last byte of the EEPROM area - int addr = upm_m24lr64e.M24LR64E.EEPROM_I2C_LENGTH - 1; - System.out.println("Address: " + addr); - short read = nfcTag.readByte(addr); - System.out.println("Read: " + read); - - // Now change it to it's opposite and write it - read = (short) (~read & 0xff); - nfcTag.writeByte(addr, read); - System.out.println("Wrote: " + read); - - // Now read it back - read = nfcTag.readByte(addr); - System.out.println("Read: " + read); - - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MAX31855_Example.java upm-1.7.1/examples/java/MAX31855_Example.java --- upm-1.6.0/examples/java/MAX31855_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MAX31855_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import upm_max31855.MAX31855; + +public class MAX31855_Example { + + static { + try { + System.loadLibrary("javaupm_max31855"); + System.loadLibrary("mraajava"); + } catch (UnsatisfiedLinkError e) { + System.err.println( + "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + + e); + System.exit(1); + } + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + MAX31855 sensor = new MAX31855(0, 8); + while(true){ + System.out.println("Temperature: "+sensor.getTemp()); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + //! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MAX31855Example.java upm-1.7.1/examples/java/MAX31855Example.java --- upm-1.6.0/examples/java/MAX31855Example.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MAX31855Example.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_max31855.MAX31855; - -public class MAX31855Example { - - static { - try { - System.loadLibrary("javaupm_max31855"); - System.loadLibrary("mraajava"); - } catch (UnsatisfiedLinkError e) { - System.err.println( - "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + - e); - System.exit(1); - } - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - MAX31855 sensor = new MAX31855(0, 8); - while(true){ - System.out.println("Temperature: "+sensor.getTemp()); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - //! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MAX44000_Example.java upm-1.7.1/examples/java/MAX44000_Example.java --- upm-1.6.0/examples/java/MAX44000_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MAX44000_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,38 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class MAX44000_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_max44000.MAX44000 sensor = new upm_max44000.MAX44000(0); + + while (true) { + System.out.println("proximity value = " + sensor.getAmbient()); + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MAX44000Sample.java upm-1.7.1/examples/java/MAX44000Sample.java --- upm-1.6.0/examples/java/MAX44000Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MAX44000Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class MAX44000Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_max44000.MAX44000 sensor = new upm_max44000.MAX44000(0); - - while (true) { - System.out.println("proximity value = " + sensor.getAmbient()); - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MAX5487_Example.java upm-1.7.1/examples/java/MAX5487_Example.java --- upm-1.6.0/examples/java/MAX5487_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MAX5487_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,71 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import upm_max5487.MAX5487; + +public class MAX5487_Example { + + static { + try { + System.loadLibrary("javaupm_max5487"); + System.loadLibrary("mraajava"); + } catch (UnsatisfiedLinkError e) { + System.err.println( + "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + + e); + System.exit(1); + } + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + MAX5487 sensor = new MAX5487(7); + + // Power LED UP + for(int i=0; i<255; i++){ + sensor.setWiperA((short)i); + try { + Thread.sleep(5); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following Exception occurred: "+e.getMessage()); + } + } + + // Power LED DOWN + for(int i=0; i<255; i++){ + sensor.setWiperA((short)(255 - i)); + try { + Thread.sleep(5); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + + System.out.println("Exiting..."); + //! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MAX5487Example.java upm-1.7.1/examples/java/MAX5487Example.java --- upm-1.6.0/examples/java/MAX5487Example.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MAX5487Example.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_max5487.MAX5487; - -public class MAX5487Example { - - static { - try { - System.loadLibrary("javaupm_max5487"); - System.loadLibrary("mraajava"); - } catch (UnsatisfiedLinkError e) { - System.err.println( - "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + - e); - System.exit(1); - } - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - MAX5487 sensor = new MAX5487(7); - - // Power LED UP - for(int i=0; i<255; i++){ - sensor.setWiperA((short)i); - try { - Thread.sleep(5); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following Exception occurred: "+e.getMessage()); - } - } - - // Power LED DOWN - for(int i=0; i<255; i++){ - sensor.setWiperA((short)(255 - i)); - try { - Thread.sleep(5); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - - System.out.println("Exiting..."); - //! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MAXds3231m_Example.java upm-1.7.1/examples/java/MAXds3231m_Example.java --- upm-1.6.0/examples/java/MAXds3231m_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MAXds3231m_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,79 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import upm_maxds3231m.MAXDS3231M; +import upm_maxds3231m.Time3231; + +public class MAXds3231m_Example { + + static { + try { + System.loadLibrary("javaupm_maxds3231m"); + System.loadLibrary("mraajava"); + } catch (UnsatisfiedLinkError e) { + System.err.println( + "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + + e); + System.exit(1); + } + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + MAXDS3231M sensor = new MAXDS3231M(upm_maxds3231m.javaupm_maxds3231mConstants.ADDR); + Time3231 t = new Time3231(); + + t.setSecond((short)1); + t.setMinute((short)3); + t.setHour((short)3); + t.setDay((short)3); + t.setMonth((short)3); + t.setYear((short)3); + t.setWeekDay((short)3); + + sensor.setDate(t); + + try { + Thread.sleep(500); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + + while(true){ + if(sensor.getDate(t)){ + System.out.println(t.getHour()+":"+t.getMinute()+":"+t.getSecond()); + } + System.out.println("Temperature: "+sensor.getTemperature()); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occcured: "+e.getMessage()); + } + } + //! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MAXds3231mExample.java upm-1.7.1/examples/java/MAXds3231mExample.java --- upm-1.6.0/examples/java/MAXds3231mExample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MAXds3231mExample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_maxds3231m.MAXDS3231M; -import upm_maxds3231m.Time3231; - -public class MAXds3231mExample { - - static { - try { - System.loadLibrary("javaupm_maxds3231m"); - System.loadLibrary("mraajava"); - } catch (UnsatisfiedLinkError e) { - System.err.println( - "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + - e); - System.exit(1); - } - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - MAXDS3231M sensor = new MAXDS3231M(upm_maxds3231m.javaupm_maxds3231mConstants.ADDR); - Time3231 t = new Time3231(); - - t.setSecond((short)1); - t.setMinute((short)3); - t.setHour((short)3); - t.setDay((short)3); - t.setMonth((short)3); - t.setYear((short)3); - t.setWeekDay((short)3); - - sensor.setDate(t); - - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - - while(true){ - if(sensor.getDate(t)){ - System.out.println(t.getHour()+":"+t.getMinute()+":"+t.getSecond()); - } - System.out.println("Temperature: "+sensor.getTemperature()); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occcured: "+e.getMessage()); - } - } - //! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MCP9808_Example.java upm-1.7.1/examples/java/MCP9808_Example.java --- upm-1.6.0/examples/java/MCP9808_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MCP9808_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,216 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ +import java.io.*; +import upm_mcp9808.MCP9808; + +public class MCP9808_Example { + + public static void main(String[] args) throws InterruptedException, IOException { + // ! [Interesting] + + int command; + upm_mcp9808.MCP9808 temp = new upm_mcp9808.MCP9808(6); + BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); + + do { + System.out.println("1 - read temp"); + System.out.println("2 - sleep mode"); + System.out.println("3 - wake up"); + System.out.println("4 - set mode to " + (temp.isCelsius() == true ? "Fahrenheit" : "Celsius")); + System.out.println("5 - show status bits"); + System.out.println("6 - Set Tcrit"); + System.out.println("7 - Set Tupper"); + System.out.println("8 - Set Tlower"); + System.out.println("9 - Display monitor temps"); + System.out.println("10 - Enable alert default"); + System.out.println("11 - Enable alert interrupt"); + System.out.println("12 - Clear interrupt"); + System.out.println("13 - Clear alert mode"); + System.out.println("14 - Get Hysteresis"); + System.out.println("15 - Set Hysteresis"); + System.out.println("16 - Get Resolution"); + System.out.println("17 - Set Resolution"); + System.out.println("18 - Get Manufacturer ID"); + System.out.println("19 - Get Device ID"); + System.out.println("-1 - exit"); + System.out.print("Enter a command:"); + + try { + command = Integer.parseInt(read.readLine()); + } catch (Exception e) { + System.err.println("Not valid command"); + command = -1; + } + + float t; + switch (command) { + case 1: + System.out.println("Temp: " + temp.getTemp() + " degrees " + (temp.isCelsius() ? "Celsius" : "Fahrenheit")); + break; + case 2: + System.out.println("shutdown sensor (sleep mode)"); + temp.shutDown(); + break; + case 3: + System.out.println("wake up sensor"); + temp.shutDown(false); + break; + case 4: + System.out.println("set mode to " + (temp.isCelsius() ? "Fahrenheit" : "Celsius")); + temp.setMode(!temp.isCelsius()); + break; + case 5: + System.out.println("Tcrit = " + temp.isTcrit()); + System.out.println("Tupper = " + temp.isTupper()); + System.out.println("Tlower = " + temp.isTlower()); + break; + case 6: + System.out.print("Enter a value: "); + try { + t = Float.valueOf(read.readLine()).floatValue(); + } catch (Exception e) { + System.err.println("\nNot a valid value\n"); + break; + } + temp.setMonitorReg(MCP9808.MCP9808_REG.CRIT_TEMP, t); + break; + case 7: + System.out.print("Enter a value: "); + try { + t = Float.valueOf(read.readLine()).floatValue(); + } catch (Exception e) { + System.err.println("\nNot a valid value\n"); + break; + } + temp.setMonitorReg(MCP9808.MCP9808_REG.UPPER_TEMP, t); + break; + case 8: + System.out.print("Enter a value: "); + try { + t = Float.valueOf(read.readLine()).floatValue(); + } catch (Exception e) { + System.err.println("\nNot a valid value\n"); + break; + } + temp.setMonitorReg(MCP9808.MCP9808_REG.LOWER_TEMP, t); + break; + case 9: + System.out.println("Tcrit = " + temp.getMonitorReg(MCP9808.MCP9808_REG.CRIT_TEMP)); + System.out.println("Tupper = " + temp.getMonitorReg(MCP9808.MCP9808_REG.UPPER_TEMP)); + System.out.println("Tlower = " + temp.getMonitorReg(MCP9808.MCP9808_REG.LOWER_TEMP)); + break; + case 10: + System.out.println("Set alert mode default"); + temp.setAlertMode(MCP9808.MCP9808_CONFIG.ALERTCTRL.swigValue()); + break; + case 11: + System.out.println("Set alert mode interrupt"); + temp.setAlertMode( + MCP9808.MCP9808_CONFIG.ALERTMODE.swigValue() | MCP9808.MCP9808_CONFIG.ALERTCTRL.swigValue()); + break; + case 12: + temp.clearInterrupt(); + break; + case 13: + System.out.println("Clear alerts"); + temp.clearAlertMode(); + break; + case 14: + System.out.println("Hysteresis: " + temp.getHysteresis()); + break; + case 15: + int u; + System.out.print("Enter 1 to 4: "); + try { + u = Integer.parseInt(read.readLine()); + } catch (Exception e) { + System.err.println("\nNot a valid command\n"); + break; + } + switch (u) { + case 1: + temp.setHysteresis(MCP9808.MCP9808_CONFIG.HYST_0); + break; + case 2: + temp.setHysteresis(MCP9808.MCP9808_CONFIG.HYST_1_5); + break; + case 3: + temp.setHysteresis(MCP9808.MCP9808_CONFIG.HYST_3_0); + break; + case 4: + temp.setHysteresis(MCP9808.MCP9808_CONFIG.HYST_6_0); + break; + default: + System.out.println("\nNot a valid option\n"); + break; + } + break; + case 16: + System.out.println("Resolution: " + temp.getResolution()); + break; + case 17: + int v; + System.out.print("Enter 1 to 4: "); + try { + v = Integer.parseInt(read.readLine()); + } catch (Exception e) { + System.err.println("\nNot a valid command\n"); + break; + } + switch (v) { + case 1: + temp.setResolution(MCP9808.MCP9808_RESOLUTION.RES_LOW); + break; + case 2: + temp.setResolution(MCP9808.MCP9808_RESOLUTION.RES_MEDIUM); + break; + case 3: + temp.setResolution(MCP9808.MCP9808_RESOLUTION.RES_HIGH); + break; + case 4: + temp.setResolution(MCP9808.MCP9808_RESOLUTION.RES_PRECISION); + break; + default: + System.out.println("\nNot a valid option\n"); + break; + } + break; + case 18: + System.out.println("Manufacturer ID: " + temp.getManufacturer()); + break; + case 19: + System.out.println("Get device ID: " + temp.getDevicedId()); + break; + case -1: + break; + default: + System.out.println("That option is not available. Try again"); + break; + } + } while (command != -1); + + // ! [Interesting] + } +} + diff -Nru upm-1.6.0/examples/java/MCP9808Sample.java upm-1.7.1/examples/java/MCP9808Sample.java --- upm-1.6.0/examples/java/MCP9808Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MCP9808Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,216 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ -import java.io.*; -import upm_mcp9808.MCP9808; - -public class MCP9808Sample { - - public static void main(String[] args) throws InterruptedException, IOException { - // ! [Interesting] - - int command; - upm_mcp9808.MCP9808 temp = new upm_mcp9808.MCP9808(6); - BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); - - do { - System.out.println("1 - read temp"); - System.out.println("2 - sleep mode"); - System.out.println("3 - wake up"); - System.out.println("4 - set mode to " + (temp.isCelsius() == true ? "Fahrenheit" : "Celsius")); - System.out.println("5 - show status bits"); - System.out.println("6 - Set Tcrit"); - System.out.println("7 - Set Tupper"); - System.out.println("8 - Set Tlower"); - System.out.println("9 - Display monitor temps"); - System.out.println("10 - Enable alert default"); - System.out.println("11 - Enable alert interrupt"); - System.out.println("12 - Clear interrupt"); - System.out.println("13 - Clear alert mode"); - System.out.println("14 - Get Hysteresis"); - System.out.println("15 - Set Hysteresis"); - System.out.println("16 - Get Resolution"); - System.out.println("17 - Set Resolution"); - System.out.println("18 - Get Manufacturer ID"); - System.out.println("19 - Get Device ID"); - System.out.println("-1 - exit"); - System.out.print("Enter a command:"); - - try { - command = Integer.parseInt(read.readLine()); - } catch (Exception e) { - System.err.println("Not valid command"); - command = -1; - } - - float t; - switch (command) { - case 1: - System.out.println("Temp: " + temp.getTemp() + " degrees " + (temp.isCelsius() ? "Celsius" : "Fahrenheit")); - break; - case 2: - System.out.println("shutdown sensor (sleep mode)"); - temp.shutDown(); - break; - case 3: - System.out.println("wake up sensor"); - temp.shutDown(false); - break; - case 4: - System.out.println("set mode to " + (temp.isCelsius() ? "Fahrenheit" : "Celsius")); - temp.setMode(!temp.isCelsius()); - break; - case 5: - System.out.println("Tcrit = " + temp.isTcrit()); - System.out.println("Tupper = " + temp.isTupper()); - System.out.println("Tlower = " + temp.isTlower()); - break; - case 6: - System.out.print("Enter a value: "); - try { - t = Float.valueOf(read.readLine()).floatValue(); - } catch (Exception e) { - System.err.println("\nNot a valid value\n"); - break; - } - temp.setMonitorReg(MCP9808.MCP9808_REG.CRIT_TEMP, t); - break; - case 7: - System.out.print("Enter a value: "); - try { - t = Float.valueOf(read.readLine()).floatValue(); - } catch (Exception e) { - System.err.println("\nNot a valid value\n"); - break; - } - temp.setMonitorReg(MCP9808.MCP9808_REG.UPPER_TEMP, t); - break; - case 8: - System.out.print("Enter a value: "); - try { - t = Float.valueOf(read.readLine()).floatValue(); - } catch (Exception e) { - System.err.println("\nNot a valid value\n"); - break; - } - temp.setMonitorReg(MCP9808.MCP9808_REG.LOWER_TEMP, t); - break; - case 9: - System.out.println("Tcrit = " + temp.getMonitorReg(MCP9808.MCP9808_REG.CRIT_TEMP)); - System.out.println("Tupper = " + temp.getMonitorReg(MCP9808.MCP9808_REG.UPPER_TEMP)); - System.out.println("Tlower = " + temp.getMonitorReg(MCP9808.MCP9808_REG.LOWER_TEMP)); - break; - case 10: - System.out.println("Set alert mode default"); - temp.setAlertMode(MCP9808.MCP9808_CONFIG.ALERTCTRL.swigValue()); - break; - case 11: - System.out.println("Set alert mode interrupt"); - temp.setAlertMode( - MCP9808.MCP9808_CONFIG.ALERTMODE.swigValue() | MCP9808.MCP9808_CONFIG.ALERTCTRL.swigValue()); - break; - case 12: - temp.clearInterrupt(); - break; - case 13: - System.out.println("Clear alerts"); - temp.clearAlertMode(); - break; - case 14: - System.out.println("Hysteresis: " + temp.getHysteresis()); - break; - case 15: - int u; - System.out.print("Enter 1 to 4: "); - try { - u = Integer.parseInt(read.readLine()); - } catch (Exception e) { - System.err.println("\nNot a valid command\n"); - break; - } - switch (u) { - case 1: - temp.setHysteresis(MCP9808.MCP9808_CONFIG.HYST_0); - break; - case 2: - temp.setHysteresis(MCP9808.MCP9808_CONFIG.HYST_1_5); - break; - case 3: - temp.setHysteresis(MCP9808.MCP9808_CONFIG.HYST_3_0); - break; - case 4: - temp.setHysteresis(MCP9808.MCP9808_CONFIG.HYST_6_0); - break; - default: - System.out.println("\nNot a valid option\n"); - break; - } - break; - case 16: - System.out.println("Resolution: " + temp.getResolution()); - break; - case 17: - int v; - System.out.print("Enter 1 to 4: "); - try { - v = Integer.parseInt(read.readLine()); - } catch (Exception e) { - System.err.println("\nNot a valid command\n"); - break; - } - switch (v) { - case 1: - temp.setResolution(MCP9808.MCP9808_RESOLUTION.RES_LOW); - break; - case 2: - temp.setResolution(MCP9808.MCP9808_RESOLUTION.RES_MEDIUM); - break; - case 3: - temp.setResolution(MCP9808.MCP9808_RESOLUTION.RES_HIGH); - break; - case 4: - temp.setResolution(MCP9808.MCP9808_RESOLUTION.RES_PRECISION); - break; - default: - System.out.println("\nNot a valid option\n"); - break; - } - break; - case 18: - System.out.println("Manufacturer ID: " + temp.getManufacturer()); - break; - case 19: - System.out.println("Get device ID: " + temp.getDevicedId()); - break; - case -1: - break; - default: - System.out.println("That option is not available. Try again"); - break; - } - } while (command != -1); - - // ! [Interesting] - } -} - diff -Nru upm-1.6.0/examples/java/MD_Example.java upm-1.7.1/examples/java/MD_Example.java --- upm-1.6.0/examples/java/MD_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MD_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class MD_Example { + private static final short speed50 = 127; + private static final short speed0 = 0; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate an I2C Motor Driver on I2C bus 0 + upm_md.MD motors = new upm_md.MD(); + + // set direction to clockwise (CW) and set speed to 50% + System.out.println("Spin M1 and M2 at half speed for 3 seconds"); + motors.setMotorDirections(upm_md.MD_DC_DIRECTION_T.MD_DIR_CW, + upm_md.MD_DC_DIRECTION_T.MD_DIR_CW); + motors.setMotorSpeeds(speed50, speed50); + Thread.sleep(3000); + + // counter clockwise (CCW) + System.out.println("Reversing M1 and M2 for 3 seconds"); + motors.setMotorDirections(upm_md.MD_DC_DIRECTION_T.MD_DIR_CCW, + upm_md.MD_DC_DIRECTION_T.MD_DIR_CCW); + Thread.sleep(3000); + + // stop motors + System.out.println("Stopping motors"); + motors.setMotorSpeeds(speed0, speed0); + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/MDSample.java upm-1.7.1/examples/java/MDSample.java --- upm-1.6.0/examples/java/MDSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MDSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class MDSample { - private static final short speed50 = 127; - private static final short speed0 = 0; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate an I2C Motor Driver on I2C bus 0 - upm_md.MD motors = new upm_md.MD(); - - // set direction to clockwise (CW) and set speed to 50% - System.out.println("Spin M1 and M2 at half speed for 3 seconds"); - motors.setMotorDirections(upm_md.MD_DC_DIRECTION_T.MD_DIR_CW, - upm_md.MD_DC_DIRECTION_T.MD_DIR_CW); - motors.setMotorSpeeds(speed50, speed50); - Thread.sleep(3000); - - // counter clockwise (CCW) - System.out.println("Reversing M1 and M2 for 3 seconds"); - motors.setMotorDirections(upm_md.MD_DC_DIRECTION_T.MD_DIR_CCW, - upm_md.MD_DC_DIRECTION_T.MD_DIR_CCW); - Thread.sleep(3000); - - // stop motors - System.out.println("Stopping motors"); - motors.setMotorSpeeds(speed0, speed0); - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/MG811_Example.java upm-1.7.1/examples/java/MG811_Example.java --- upm-1.6.0/examples/java/MG811_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MG811_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class MG811_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + // Instantiate an MG811 on analog pin A0, and digital pin D2 with an + // analog reference voltage of 5.0V + upm_mg811.MG811 sensor = new upm_mg811.MG811(0, 2, (float) 5.0); + + // Every tenth of a second, sample the sensor and output it's + // detected CO2 concentration in parts per million (ppm) + + while (true) { + System.out.println("CO2 concentration in PPM: " + sensor.ppm()); + Thread.sleep(100); + } + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/MG811Sample.java upm-1.7.1/examples/java/MG811Sample.java --- upm-1.6.0/examples/java/MG811Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MG811Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class MG811Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - // Instantiate an MG811 on analog pin A0, and digital pin D2 with an - // analog reference voltage of 5.0V - upm_mg811.MG811 sensor = new upm_mg811.MG811(0, 2, (float) 5.0); - - // Every tenth of a second, sample the sensor and output it's - // detected CO2 concentration in parts per million (ppm) - - while (true) { - System.out.println("CO2 concentration in PPM: " + sensor.ppm()); - Thread.sleep(100); - } - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/MHZ16_Example.java upm-1.7.1/examples/java/MHZ16_Example.java --- upm-1.6.0/examples/java/MHZ16_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MHZ16_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class MHZ16_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a MHZ16 serial CO2 sensor on uart 0. + upm_mhz16.MHZ16 co2 = new upm_mhz16.MHZ16(0); + + System.out.println("Make sure that the sensor has had at least 3 minutes to warm up"); + System.out.println("or you will not get valid results."); + System.out.println("The temperature reported is not the ambient temperature,"); + System.out.println("but rather the temperature of the sensor elements."); + + while (true) { + if (!co2.getData()) { + System.out.println("Failed to retrieve data"); + continue; + } + System.out.println("CO2 concentration: " + co2.getGas() + "PPM, Temperature (in C): " + + co2.getTemperature()); + + Thread.sleep(2000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MHZ16Sample.java upm-1.7.1/examples/java/MHZ16Sample.java --- upm-1.6.0/examples/java/MHZ16Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MHZ16Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class MHZ16Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a MHZ16 serial CO2 sensor on uart 0. - upm_mhz16.MHZ16 co2 = new upm_mhz16.MHZ16(0); - - System.out.println("Make sure that the sensor has had at least 3 minutes to warm up"); - System.out.println("or you will not get valid results."); - System.out.println("The temperature reported is not the ambient temperature,"); - System.out.println("but rather the temperature of the sensor elements."); - - while (true) { - if (!co2.getData()) { - System.out.println("Failed to retrieve data"); - continue; - } - System.out.println("CO2 concentration: " + co2.getGas() + "PPM, Temperature (in C): " - + co2.getTemperature()); - - Thread.sleep(2000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Microphone_Example.java upm-1.7.1/examples/java/Microphone_Example.java --- upm-1.6.0/examples/java/Microphone_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Microphone_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Microphone_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + short[] buffer = new short[128]; + + // Attach microphone to analog port A0 + upm_mic.Microphone sensor = new upm_mic.Microphone(0); + + upm_mic.thresholdContext ctx = new upm_mic.thresholdContext(); + ctx.setAverageReading(0); + ctx.setRunningAverage(0); + ctx.setAveragedOver(2); + + // Repeatedly, take a sample every 2 microseconds; + // find the average of 128 samples; and + // print a running graph of the averages + while (true) { + int len = sensor.getSampledWindow(2, buffer); + + if (len != 0) { + int thresh = sensor.findThreshold(ctx, 30, buffer); + sensor.printGraph(ctx); + if (thresh != 0) { + System.out.println("---Threshold reached--- " + ctx.getRunningAverage() + " " + + ctx.getAverageReading()); + } + } + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MicrophoneSample.java upm-1.7.1/examples/java/MicrophoneSample.java --- upm-1.6.0/examples/java/MicrophoneSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MicrophoneSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class MicrophoneSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - short[] buffer = new short[128]; - - // Attach microphone to analog port A0 - upm_mic.Microphone sensor = new upm_mic.Microphone(0); - - upm_mic.thresholdContext ctx = new upm_mic.thresholdContext(); - ctx.setAverageReading(0); - ctx.setRunningAverage(0); - ctx.setAveragedOver(2); - - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of the averages - while (true) { - int len = sensor.getSampledWindow(2, buffer); - - if (len != 0) { - int thresh = sensor.findThreshold(ctx, 30, buffer); - sensor.printGraph(ctx); - if (thresh != 0) { - System.out.println("---Threshold reached--- " + ctx.getRunningAverage() + " " - + ctx.getAverageReading()); - } - } - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MMA7455_Example.java upm-1.7.1/examples/java/MMA7455_Example.java --- upm-1.6.0/examples/java/MMA7455_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MMA7455_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,41 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class MMA7455_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_mma7455.MMA7455 sensor = new upm_mma7455.MMA7455(0); + + while (true) { + upm_mma7455.ShortVector val = sensor.readData(); + System.out.println("Accelerometer X: " + val.get(0) + ", Y: " + val.get(1) + ", Z: " + val.get(2)); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/MMA7455Sample.java upm-1.7.1/examples/java/MMA7455Sample.java --- upm-1.6.0/examples/java/MMA7455Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MMA7455Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class MMA7455Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_mma7455.MMA7455 sensor = new upm_mma7455.MMA7455(0); - - while (true) { - upm_mma7455.ShortVector val = sensor.readData(); - System.out.println("Accelerometer X: " + val.get(0) + ", Y: " + val.get(1) + ", Z: " + val.get(2)); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/MMA7660_Example.java upm-1.7.1/examples/java/MMA7660_Example.java --- upm-1.6.0/examples/java/MMA7660_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MMA7660_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,61 @@ +/* + * Author: Stefan Andritoiu + * Jon Trulson + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_mma7660.MMA7660; + +public class MMA7660_Example +{ + public static void main(String[] args) throws InterruptedException + { + // ! [Interesting] + // Instantiate an MMA7660 on I2C bus 0 + MMA7660 accel = new MMA7660(0); + + // place device in standby mode so we can write registers + accel.setModeStandby(); + + // enable 64 samples per second + accel.setSampleRate(upm_mma7660.MMA7660_AUTOSLEEP_T.MMA7660_AUTOSLEEP_64); + + // place device into active mode + accel.setModeActive(); + + while (true) + { + upm_mma7660.FloatVector acceleration = accel.getAcceleration(); + System.out.println("Acceleration: x = " + + acceleration.get(0) + + " y = " + + acceleration.get(1) + + " x = " + + acceleration.get(2)); + + System.out.println(); + + Thread.sleep(500); + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/MMA7660Sample.java upm-1.7.1/examples/java/MMA7660Sample.java --- upm-1.6.0/examples/java/MMA7660Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MMA7660Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Jon Trulson - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_mma7660.MMA7660; - -public class MMA7660Sample -{ - public static void main(String[] args) throws InterruptedException - { - // ! [Interesting] - // Instantiate an MMA7660 on I2C bus 0 - MMA7660 accel = new MMA7660(0); - - // place device in standby mode so we can write registers - accel.setModeStandby(); - - // enable 64 samples per second - accel.setSampleRate(upm_mma7660.MMA7660_AUTOSLEEP_T.MMA7660_AUTOSLEEP_64); - - // place device into active mode - accel.setModeActive(); - - while (true) - { - upm_mma7660.FloatVector acceleration = accel.getAcceleration(); - System.out.println("Acceleration: x = " - + acceleration.get(0) - + " y = " - + acceleration.get(1) - + " x = " - + acceleration.get(2)); - - System.out.println(); - - Thread.sleep(500); - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Moisture_Example.java upm-1.7.1/examples/java/Moisture_Example.java --- upm-1.6.0/examples/java/Moisture_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Moisture_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Moisture_Example { + public static void main(String args[]) throws InterruptedException { + // ! [Interesting] + upm_moisture.Moisture gm = new upm_moisture.Moisture(1); + + while (true) { + int moisture_val = gm.value(); + String result; + + if (moisture_val >= 0 && moisture_val < 300) + result = "Dry"; + else if ((moisture_val >= 0 && moisture_val < 300)) + result = "Moist"; + else + result = "Wet"; + + System.out.println("Moisture Value: " + moisture_val + ", " + result); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MoistureSample.java upm-1.7.1/examples/java/MoistureSample.java --- upm-1.6.0/examples/java/MoistureSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MoistureSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class MoistureSample { - public static void main(String args[]) throws InterruptedException { - // ! [Interesting] - upm_moisture.Moisture gm = new upm_moisture.Moisture(1); - - while (true) { - int moisture_val = gm.value(); - String result; - - if (moisture_val >= 0 && moisture_val < 300) - result = "Dry"; - else if ((moisture_val >= 0 && moisture_val < 300)) - result = "Moist"; - else - result = "Wet"; - - System.out.println("Moisture Value: " + moisture_val + ", " + result); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MPL3115A2_Example.java upm-1.7.1/examples/java/MPL3115A2_Example.java --- upm-1.6.0/examples/java/MPL3115A2_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MPL3115A2_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class MPL3115A2_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a MPL3115A2 sensor on I2C + upm_mpl3115a2.MPL3115A2 sensor = new upm_mpl3115a2.MPL3115A2(0); + + while (true) { + System.out.println("Pressure: " + sensor.getPressure()); + System.out.println("Altitude: " + sensor.getAltitude()); + System.out.println("Sealevel pressure: " + sensor.getSealevelPressure()); + System.out.println("Temperature: " + sensor.getTemperature()); + System.out.println(); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MPL3115A2Sample.java upm-1.7.1/examples/java/MPL3115A2Sample.java --- upm-1.6.0/examples/java/MPL3115A2Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MPL3115A2Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class MPL3115A2Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a MPL3115A2 sensor on I2C - upm_mpl3115a2.MPL3115A2 sensor = new upm_mpl3115a2.MPL3115A2(0); - - while (true) { - System.out.println("Pressure: " + sensor.getPressure()); - System.out.println("Altitude: " + sensor.getAltitude()); - System.out.println("Sealevel pressure: " + sensor.getSealevelPressure()); - System.out.println("Temperature: " + sensor.getTemperature()); - System.out.println(); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MPR121_Example.java upm-1.7.1/examples/java/MPR121_Example.java --- upm-1.6.0/examples/java/MPR121_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MPR121_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,34 @@ +public class MPR121_Example { + + private static void printButtons(upm_mpr121.MPR121 touch) { + boolean buttonPresed = false; + + System.out.print("Buttons pressed: "); + for (int i = 0; i < 12; i++) { + if ((touch.getM_buttonStates() & (1 << i)) != 0) { + System.out.print(i + " "); + buttonPresed = true; + } + } + + if (!buttonPresed) + System.out.print("None "); + + System.out.println(); + } + + public static void main(String[] args) throws InterruptedException { + // Instantiate an MPR121 on I2C bus 0 + upm_mpr121.MPR121 touch = new upm_mpr121.MPR121(0); + + // init according to AN3944 defaults + touch.configAN3944(); + + while (true) { + touch.readButtons(); + printButtons(touch); + Thread.sleep(1000); + } + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MPR121Sample.java upm-1.7.1/examples/java/MPR121Sample.java --- upm-1.6.0/examples/java/MPR121Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MPR121Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -public class MPR121Sample { - - private static void printButtons(upm_mpr121.MPR121 touch) { - boolean buttonPresed = false; - - System.out.print("Buttons pressed: "); - for (int i = 0; i < 12; i++) { - if ((touch.getM_buttonStates() & (1 << i)) != 0) { - System.out.print(i + " "); - buttonPresed = true; - } - } - - if (!buttonPresed) - System.out.print("None "); - - System.out.println(); - } - - public static void main(String[] args) throws InterruptedException { - // Instantiate an MPR121 on I2C bus 0 - upm_mpr121.MPR121 touch = new upm_mpr121.MPR121(0); - - // init according to AN3944 defaults - touch.configAN3944(); - - while (true) { - touch.readButtons(); - printButtons(touch); - Thread.sleep(1000); - } - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MPU9150_Example.java upm-1.7.1/examples/java/MPU9150_Example.java --- upm-1.6.0/examples/java/MPU9150_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MPU9150_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class MPU9150_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_mpu9150.MPU9150 sensor = new upm_mpu9150.MPU9150(); + + sensor.init(); + + while (true) { + sensor.update(); + +// These don't exist +// float[] accel = sensor.getAccelerometer(); +// System.out.println("Accelerometer: " + "AX: " + accel[0] + " AY: " + accel[1] + " AZ: " +// + accel[2]); +// +// float[] gyro = sensor.getGyroscope(); +// System.out.println("Gryoscope: " + "GX: " + gyro[0] + " GY: " + gyro[1] + " GZ: " +// + gyro[2]); + + upm_mpu9150.FloatVector magn = sensor.getMagnetometer(); + System.out.println("Magnetometer: " + "MX: " + magn.get(0) + " MY: " + magn.get(1) + " MZ: " + magn.get(2)); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/MPU9150Sample.java upm-1.7.1/examples/java/MPU9150Sample.java --- upm-1.6.0/examples/java/MPU9150Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MPU9150Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class MPU9150Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_mpu9150.MPU9150 sensor = new upm_mpu9150.MPU9150(); - - sensor.init(); - - while (true) { - sensor.update(); - -// These don't exist -// float[] accel = sensor.getAccelerometer(); -// System.out.println("Accelerometer: " + "AX: " + accel[0] + " AY: " + accel[1] + " AZ: " -// + accel[2]); -// -// float[] gyro = sensor.getGyroscope(); -// System.out.println("Gryoscope: " + "GX: " + gyro[0] + " GY: " + gyro[1] + " GZ: " -// + gyro[2]); - - upm_mpu9150.FloatVector magn = sensor.getMagnetometer(); - System.out.println("Magnetometer: " + "MX: " + magn.get(0) + " MY: " + magn.get(1) + " MZ: " + magn.get(2)); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/MQ2_Example.java upm-1.7.1/examples/java/MQ2_Example.java --- upm-1.6.0/examples/java/MQ2_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MQ2_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class MQ2_Example { + private static final short resolution = 5; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + short[] buffer = new short[128]; + + // Attach gas sensor to A0 + upm_gas.MQ2 sensor = new upm_gas.MQ2(0); + + upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); + ctx.setAverageReading(0); + ctx.setRunningAverage(0); + ctx.setAveragedOver(2); + + while (true) { + int len = sensor.getSampledWindow(2, buffer); + + if (len != 0) { + int thresh = sensor.findThreshold(ctx, 30, buffer); + sensor.printGraph(ctx, resolution); + if (thresh != 0) { + System.out.println("---Threshold reached---"); + } + } + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MQ2Sample.java upm-1.7.1/examples/java/MQ2Sample.java --- upm-1.6.0/examples/java/MQ2Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MQ2Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class MQ2Sample { - private static final short resolution = 5; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - short[] buffer = new short[128]; - - // Attach gas sensor to A0 - upm_gas.MQ2 sensor = new upm_gas.MQ2(0); - - upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); - ctx.setAverageReading(0); - ctx.setRunningAverage(0); - ctx.setAveragedOver(2); - - while (true) { - int len = sensor.getSampledWindow(2, buffer); - - if (len != 0) { - int thresh = sensor.findThreshold(ctx, 30, buffer); - sensor.printGraph(ctx, resolution); - if (thresh != 0) { - System.out.println("---Threshold reached---"); - } - } - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MQ303A_Example.java upm-1.7.1/examples/java/MQ303A_Example.java --- upm-1.6.0/examples/java/MQ303A_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MQ303A_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class MQ303A_Example { + + public static void main(String[] args) throws InterruptedException { + // Instantiate an mq303a sensor on analog pin A0 + + // This device uses a heater powered from an analog I/O pin. + // If using A0 as the data pin, then you need to use A1, as the heater + // pin (if using a grove mq303a). For A1, we can use the D15 gpio, + // setup as an output, and drive it low to power the heater. + upm_mq303a.MQ303A mq303a = new upm_mq303a.MQ303A(1, 15); + + System.out.println("Enabling heater and waiting 2 minutes for warmup."); + mq303a.heaterEnable(true); + Thread.sleep(120000); + + System.out.println("This sensor may need to warm until the value drops below about 450."); + + for (int i = 1; i < 10; i++) { + int val = mq303a.value(); + System.out.println("Alcohol detected (higher means stronger alcohol): " + val); + + Thread.sleep(1000); + } + + mq303a.heaterEnable(false); + System.out.println("Exiting"); + } + +} diff -Nru upm-1.6.0/examples/java/MQ303ASample.java upm-1.7.1/examples/java/MQ303ASample.java --- upm-1.6.0/examples/java/MQ303ASample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MQ303ASample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class MQ303ASample { - - public static void main(String[] args) throws InterruptedException { - // Instantiate an mq303a sensor on analog pin A0 - - // This device uses a heater powered from an analog I/O pin. - // If using A0 as the data pin, then you need to use A1, as the heater - // pin (if using a grove mq303a). For A1, we can use the D15 gpio, - // setup as an output, and drive it low to power the heater. - upm_mq303a.MQ303A mq303a = new upm_mq303a.MQ303A(1, 15); - - System.out.println("Enabling heater and waiting 2 minutes for warmup."); - mq303a.heaterEnable(true); - Thread.sleep(120000); - - System.out.println("This sensor may need to warm until the value drops below about 450."); - - for (int i = 1; i < 10; i++) { - int val = mq303a.value(); - System.out.println("Alcohol detected (higher means stronger alcohol): " + val); - - Thread.sleep(1000); - } - - mq303a.heaterEnable(false); - System.out.println("Exiting"); - } - -} diff -Nru upm-1.6.0/examples/java/MQ4_Example.java upm-1.7.1/examples/java/MQ4_Example.java --- upm-1.6.0/examples/java/MQ4_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MQ4_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class MQ4_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + short[] buffer = new short[128]; + + // Attach gas sensor to A0 + upm_gas.MQ4 sensor = new upm_gas.MQ4(0); + + upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); + ctx.setAverageReading(0); + ctx.setRunningAverage(0); + ctx.setAveragedOver(2); + + // Infinite loop, ends when script is cancelled + // Repeatedly, take a sample every 2 microseconds; + // find the average of 128 samples; and + // print a running graph of asterisks as averages + while (true) { + int len = sensor.getSampledWindow(2, buffer); + + if (len != 0) { + int thresh = sensor.findThreshold(ctx, 30, buffer); + sensor.printGraph(ctx, (short) 5); + if (thresh != 0) { + // do something... + } + } + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/MQ4Sample.java upm-1.7.1/examples/java/MQ4Sample.java --- upm-1.6.0/examples/java/MQ4Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MQ4Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class MQ4Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - short[] buffer = new short[128]; - - // Attach gas sensor to A0 - upm_gas.MQ4 sensor = new upm_gas.MQ4(0); - - upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); - ctx.setAverageReading(0); - ctx.setRunningAverage(0); - ctx.setAveragedOver(2); - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of asterisks as averages - while (true) { - int len = sensor.getSampledWindow(2, buffer); - - if (len != 0) { - int thresh = sensor.findThreshold(ctx, 30, buffer); - sensor.printGraph(ctx, (short) 5); - if (thresh != 0) { - // do something... - } - } - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/MQ5_Example.java upm-1.7.1/examples/java/MQ5_Example.java --- upm-1.6.0/examples/java/MQ5_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MQ5_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,55 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class MQ5_Example { + private static final short resolution = 7; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + short[] buffer = new short[128]; + + // Attach gas sensor to A0 + upm_gas.MQ5 sensor = new upm_gas.MQ5(0); + + upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); + ctx.setAverageReading(0); + ctx.setRunningAverage(0); + ctx.setAveragedOver(2); + + while (true) { + int len = sensor.getSampledWindow(2, buffer); + + if (len != 0) { + int thresh = sensor.findThreshold(ctx, 30, buffer); + sensor.printGraph(ctx, resolution); + if (thresh != 0) { + System.out.println("---Threshold reached---"); + } + } + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MQ5Sample.java upm-1.7.1/examples/java/MQ5Sample.java --- upm-1.6.0/examples/java/MQ5Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MQ5Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class MQ5Sample { - private static final short resolution = 7; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - short[] buffer = new short[128]; - - // Attach gas sensor to A0 - upm_gas.MQ5 sensor = new upm_gas.MQ5(0); - - upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); - ctx.setAverageReading(0); - ctx.setRunningAverage(0); - ctx.setAveragedOver(2); - - while (true) { - int len = sensor.getSampledWindow(2, buffer); - - if (len != 0) { - int thresh = sensor.findThreshold(ctx, 30, buffer); - sensor.printGraph(ctx, resolution); - if (thresh != 0) { - System.out.println("---Threshold reached---"); - } - } - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/MQ6_Example.java upm-1.7.1/examples/java/MQ6_Example.java --- upm-1.6.0/examples/java/MQ6_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MQ6_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class MQ6_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + short[] buffer = new short[128]; + + // Attach gas sensor to A0 + upm_gas.MQ6 sensor = new upm_gas.MQ6(0); + + upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); + ctx.setAverageReading(0); + ctx.setRunningAverage(0); + ctx.setAveragedOver(2); + + // Infinite loop, ends when script is cancelled + // Repeatedly, take a sample every 2 microseconds; + // find the average of 128 samples; and + // print a running graph of asterisks as averages + while (true) { + int len = sensor.getSampledWindow(2, buffer); + + if (len != 0) { + int thresh = sensor.findThreshold(ctx, 30, buffer); + sensor.printGraph(ctx, (short) 5); + if (thresh != 0) { + // do something .... + } + } + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/MQ6Sample.java upm-1.7.1/examples/java/MQ6Sample.java --- upm-1.6.0/examples/java/MQ6Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MQ6Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class MQ6Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - short[] buffer = new short[128]; - - // Attach gas sensor to A0 - upm_gas.MQ6 sensor = new upm_gas.MQ6(0); - - upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); - ctx.setAverageReading(0); - ctx.setRunningAverage(0); - ctx.setAveragedOver(2); - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of asterisks as averages - while (true) { - int len = sensor.getSampledWindow(2, buffer); - - if (len != 0) { - int thresh = sensor.findThreshold(ctx, 30, buffer); - sensor.printGraph(ctx, (short) 5); - if (thresh != 0) { - // do something .... - } - } - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/MQ7_Example.java upm-1.7.1/examples/java/MQ7_Example.java --- upm-1.6.0/examples/java/MQ7_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MQ7_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,57 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class MQ7_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + short[] buffer = new short[128]; + + // Attach gas sensor to A0 + upm_gas.MQ7 sensor = new upm_gas.MQ7(0); + + upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); + ctx.setAverageReading(0); + ctx.setRunningAverage(0); + ctx.setAveragedOver(2); + + // Infinite loop, ends when script is cancelled + // Repeatedly, take a sample every 2 microseconds; + // find the average of 128 samples; and + // print a running graph of asterisks as averages + + while (true) { + int len = sensor.getSampledWindow(2, buffer); + + if (len != 0) { + int thresh = sensor.findThreshold(ctx, 30, buffer); + sensor.printGraph(ctx, (short) 5); + if (thresh != 0) { + // do something... + } + } + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/MQ7Sample.java upm-1.7.1/examples/java/MQ7Sample.java --- upm-1.6.0/examples/java/MQ7Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MQ7Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class MQ7Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - short[] buffer = new short[128]; - - // Attach gas sensor to A0 - upm_gas.MQ7 sensor = new upm_gas.MQ7(0); - - upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); - ctx.setAverageReading(0); - ctx.setRunningAverage(0); - ctx.setAveragedOver(2); - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of asterisks as averages - - while (true) { - int len = sensor.getSampledWindow(2, buffer); - - if (len != 0) { - int thresh = sensor.findThreshold(ctx, 30, buffer); - sensor.printGraph(ctx, (short) 5); - if (thresh != 0) { - // do something... - } - } - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/MQ8_Example.java upm-1.7.1/examples/java/MQ8_Example.java --- upm-1.6.0/examples/java/MQ8_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/MQ8_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class MQ8_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + short[] buffer = new short[128]; + + // Attach gas sensor to A0 + upm_gas.MQ8 sensor = new upm_gas.MQ8(0); + + upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); + ctx.setAverageReading(0); + ctx.setRunningAverage(0); + ctx.setAveragedOver(2); + + // Infinite loop, ends when script is cancelled + // Repeatedly, take a sample every 2 microseconds; + // find the average of 128 samples; and + // print a running graph of asterisks as averages + while (true) { + int len = sensor.getSampledWindow(2, buffer); + + if (len != 0) { + int thresh = sensor.findThreshold(ctx, 30, buffer); + sensor.printGraph(ctx, (short) 5); + if (thresh != 0) { + // do something... + } + } + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/MQ8Sample.java upm-1.7.1/examples/java/MQ8Sample.java --- upm-1.6.0/examples/java/MQ8Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/MQ8Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class MQ8Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - short[] buffer = new short[128]; - - // Attach gas sensor to A0 - upm_gas.MQ8 sensor = new upm_gas.MQ8(0); - - upm_gas.thresholdContext ctx = new upm_gas.thresholdContext(); - ctx.setAverageReading(0); - ctx.setRunningAverage(0); - ctx.setAveragedOver(2); - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of asterisks as averages - while (true) { - int len = sensor.getSampledWindow(2, buffer); - - if (len != 0) { - int thresh = sensor.findThreshold(ctx, 30, buffer); - sensor.printGraph(ctx, (short) 5); - if (thresh != 0) { - // do something... - } - } - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/NLGPIO16_Example.java upm-1.7.1/examples/java/NLGPIO16_Example.java --- upm-1.6.0/examples/java/NLGPIO16_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/NLGPIO16_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class NLGPIO16_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + // Instantiate a NLGPIO16 Module on the default UART (/dev/ttyACM0) + upm_nlgpio16.NLGPIO16 sensor = new upm_nlgpio16.NLGPIO16(); + + // get the Version + System.out.println("Device Version: " + sensor.getVersion()); + // read the gpio at pin 3 + System.out.println("GPIO 3 Value: " + sensor.gpioRead(3)); + // read the analog voltage at pin 5 + System.out.println("Analog 5 Voltage: " + sensor.analogReadVolts(5)); + // set the gpio at pin 14 to HIGH + sensor.gpioSet(14); + + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/NLGPIO16Sample.java upm-1.7.1/examples/java/NLGPIO16Sample.java --- upm-1.6.0/examples/java/NLGPIO16Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/NLGPIO16Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class NLGPIO16Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - // Instantiate a NLGPIO16 Module on the default UART (/dev/ttyACM0) - upm_nlgpio16.NLGPIO16 sensor = new upm_nlgpio16.NLGPIO16(); - - // get the Version - System.out.println("Device Version: " + sensor.getVersion()); - // read the gpio at pin 3 - System.out.println("GPIO 3 Value: " + sensor.gpioRead(3)); - // read the analog voltage at pin 5 - System.out.println("Analog 5 Voltage: " + sensor.analogReadVolts(5)); - // set the gpio at pin 14 to HIGH - sensor.gpioSet(14); - - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/NRF24L01_receiver_Example.java upm-1.7.1/examples/java/NRF24L01_receiver_Example.java --- upm-1.6.0/examples/java/NRF24L01_receiver_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/NRF24L01_receiver_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,75 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_nrf24l01.Callback; + +//NOT TESTED!!! +public class NRF24L01_receiver_Example { + + static private final byte[] local_address = {0x01, 0x01, 0x01, 0x01, 0x01}; + static private final byte[] broadcast_address = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF}; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_nrf24l01.NRF24L01 comm = new upm_nrf24l01.NRF24L01((short) 7, (short) 8); + + Callback callback = new ReceiverCallback(comm); + + comm.setSourceAddress(local_address); + comm.setDestinationAddress(broadcast_address); + comm.setPayload((short) upm_nrf24l01.javaupm_nrf24l01Constants.MAX_BUFFER); + comm.configure(); + comm.setSpeedRate(upm_nrf24l01.speed_rate_t.NRF_250KBPS); + comm.setChannel((short) 99); + comm.setDataReceivedHandler(callback); + + while (true) { + comm.pollListener(); + } + + // ! [Interesting] + } +} + +class ReceiverCallback extends Callback { + + private upm_nrf24l01.NRF24L01 comm = null; + + public ReceiverCallback(upm_nrf24l01.NRF24L01 comm) { + super(); + this.comm = comm; + } + public void run() { + if (comm != null) { + short[] rx_buffer = comm.getM_rxBuffer(); + System.out.print("Received: "); + for (int i = 0; i < rx_buffer.length; i++) + System.out.print(rx_buffer[i]); + System.out.println(); + } else { + System.out.println("No NRF24L01 instance given to callback"); + } + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/NRF24L01_receiverSample.java upm-1.7.1/examples/java/NRF24L01_receiverSample.java --- upm-1.6.0/examples/java/NRF24L01_receiverSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/NRF24L01_receiverSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_nrf24l01.Callback; - -//NOT TESTED!!! -public class NRF24L01_receiverSample { - - static private final byte[] local_address = {0x01, 0x01, 0x01, 0x01, 0x01}; - static private final byte[] broadcast_address = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, - (byte) 0xFF, (byte) 0xFF}; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_nrf24l01.NRF24L01 comm = new upm_nrf24l01.NRF24L01((short) 7, (short) 8); - - Callback callback = new ReceiverCallback(comm); - - comm.setSourceAddress(local_address); - comm.setDestinationAddress(broadcast_address); - comm.setPayload((short) upm_nrf24l01.javaupm_nrf24l01Constants.MAX_BUFFER); - comm.configure(); - comm.setSpeedRate(upm_nrf24l01.speed_rate_t.NRF_250KBPS); - comm.setChannel((short) 99); - comm.setDataReceivedHandler(callback); - - while (true) { - comm.pollListener(); - } - - // ! [Interesting] - } -} - -class ReceiverCallback extends Callback { - - private upm_nrf24l01.NRF24L01 comm = null; - - public ReceiverCallback(upm_nrf24l01.NRF24L01 comm) { - super(); - this.comm = comm; - } - public void run() { - if (comm != null) { - short[] rx_buffer = comm.getM_rxBuffer(); - System.out.print("Received: "); - for (int i = 0; i < rx_buffer.length; i++) - System.out.print(rx_buffer[i]); - System.out.println(); - } else { - System.out.println("No NRF24L01 instance given to callback"); - } - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/NRF24L01_transmitter_Example.java upm-1.7.1/examples/java/NRF24L01_transmitter_Example.java --- upm-1.6.0/examples/java/NRF24L01_transmitter_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/NRF24L01_transmitter_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_nrf24l01.Callback; + +//NOT TESTED!!! +public class NRF24L01_transmitter_Example { + + static private final byte[] destAddress = {0x01, 0x01, 0x01, 0x01, 0x01}; + static private final byte[] srcAddress = {0x01, 0x01, 0x01, 0x01, 0x01}; + static private byte[] tx_buffer = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x00}; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_nrf24l01.NRF24L01 comm = new upm_nrf24l01.NRF24L01((short) 7, (short) 8); + + Callback callback = new TransmitterCallback(); + + comm.setSourceAddress(srcAddress); + comm.setDestinationAddress(destAddress); + comm.setPayload((short) upm_nrf24l01.javaupm_nrf24l01Constants.MAX_BUFFER); + comm.setChannel((short) 99); + comm.configure(); + comm.setDataReceivedHandler(callback); + + while (true) { + comm.send(tx_buffer); + System.out.println("devi2 :: sending data ...."); + for (int i = 0; i < tx_buffer.length; i++) + System.out.print(tx_buffer[i]); + System.out.println(); + Thread.sleep(3000); + } + // ! [Interesting] + } +} + +class TransmitterCallback extends Callback { + public TransmitterCallback() { + super(); + } + public void run() { + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/NRF24L01_transmitterSample.java upm-1.7.1/examples/java/NRF24L01_transmitterSample.java --- upm-1.6.0/examples/java/NRF24L01_transmitterSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/NRF24L01_transmitterSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_nrf24l01.Callback; - -//NOT TESTED!!! -public class NRF24L01_transmitterSample { - - static private final byte[] destAddress = {0x01, 0x01, 0x01, 0x01, 0x01}; - static private final byte[] srcAddress = {0x01, 0x01, 0x01, 0x01, 0x01}; - static private byte[] tx_buffer = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, - 0x00}; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_nrf24l01.NRF24L01 comm = new upm_nrf24l01.NRF24L01((short) 7, (short) 8); - - Callback callback = new TransmitterCallback(); - - comm.setSourceAddress(srcAddress); - comm.setDestinationAddress(destAddress); - comm.setPayload((short) upm_nrf24l01.javaupm_nrf24l01Constants.MAX_BUFFER); - comm.setChannel((short) 99); - comm.configure(); - comm.setDataReceivedHandler(callback); - - while (true) { - comm.send(tx_buffer); - System.out.println("devi2 :: sending data ...."); - for (int i = 0; i < tx_buffer.length; i++) - System.out.print(tx_buffer[i]); - System.out.println(); - Thread.sleep(3000); - } - // ! [Interesting] - } -} - -class TransmitterCallback extends Callback { - public TransmitterCallback() { - super(); - } - public void run() { - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/NUNCHUCK_Example.java upm-1.7.1/examples/java/NUNCHUCK_Example.java --- upm-1.6.0/examples/java/NUNCHUCK_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/NUNCHUCK_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,61 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class NUNCHUCK_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a nunchuck controller bus 0 + upm_nunchuck.NUNCHUCK nunchuck = new upm_nunchuck.NUNCHUCK(3); + + while (true) + { + nunchuck.update(); + System.out.println("stickX: " + + nunchuck.getStickX() + + ", stickY: " + + nunchuck.getStickY()); + System.out.println("accelX: " + + nunchuck.getAccelX() + + ", accelY: " + + nunchuck.getAccelY() + + ", accelZ: " + + nunchuck.getAccelZ()); + + if (nunchuck.getButtonC()) + System.out.println("Button C pressed"); + else + System.out.println("Button C not pressed"); + + if (nunchuck.getButtonZ()) + System.out.println("Button Z pressed"); + else + System.out.println("Button Z not pressed"); + + Thread.sleep(100); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/NUNCHUCKSample.java upm-1.7.1/examples/java/NUNCHUCKSample.java --- upm-1.6.0/examples/java/NUNCHUCKSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/NUNCHUCKSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class NUNCHUCKSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a nunchuck controller bus 0 - upm_nunchuck.NUNCHUCK nunchuck = new upm_nunchuck.NUNCHUCK(3); - - while (true) - { - nunchuck.update(); - System.out.println("stickX: " - + nunchuck.getStickX() - + ", stickY: " - + nunchuck.getStickY()); - System.out.println("accelX: " - + nunchuck.getAccelX() - + ", accelY: " - + nunchuck.getAccelY() - + ", accelZ: " - + nunchuck.getAccelZ()); - - if (nunchuck.getButtonC()) - System.out.println("Button C pressed"); - else - System.out.println("Button C not pressed"); - - if (nunchuck.getButtonZ()) - System.out.println("Button Z pressed"); - else - System.out.println("Button Z not pressed"); - - Thread.sleep(100); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/O2_Example.java upm-1.7.1/examples/java/O2_Example.java --- upm-1.6.0/examples/java/O2_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/O2_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_o2.O2; + +public class O2_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // Initializing the Grove O2 sensor on the A) analog pin + O2 o2 = new O2(0); + + while(true){ + System.out.println("The output voltage is: "+o2.voltageValue()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception has occurred: "+e.getMessage()); + } + } + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/O2Example.java upm-1.7.1/examples/java/O2Example.java --- upm-1.6.0/examples/java/O2Example.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/O2Example.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_o2.O2; - -public class O2Example { - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // Initializing the Grove O2 sensor on the A) analog pin - O2 o2 = new O2(0); - - while(true){ - System.out.println("The output voltage is: "+o2.voltageValue()); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception has occurred: "+e.getMessage()); - } - } - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/OTP538U_Example.java upm-1.7.1/examples/java/OTP538U_Example.java --- upm-1.6.0/examples/java/OTP538U_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/OTP538U_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class OTP538U_Example { + private static final float OTP538U_AREF = 5; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a OTP538U on analog pins A0 and A1 + // A0 is used for the Ambient Temperature and A1 is used for the Object + // temperature. + upm_otp538u.OTP538U temps = new upm_otp538u.OTP538U(0, 1, OTP538U_AREF); + + while (true) { + System.out.println("Ambient temp: " + temps.ambientTemperature() + " C"); + System.out.println("Object temp: " + temps.objectTemperature() + " C"); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/OTP538USample.java upm-1.7.1/examples/java/OTP538USample.java --- upm-1.6.0/examples/java/OTP538USample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/OTP538USample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class OTP538USample { - private static final float OTP538U_AREF = 5; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a OTP538U on analog pins A0 and A1 - // A0 is used for the Ambient Temperature and A1 is used for the Object - // temperature. - upm_otp538u.OTP538U temps = new upm_otp538u.OTP538U(0, 1, OTP538U_AREF); - - while (true) { - System.out.println("Ambient temp: " + temps.ambientTemperature() + " C"); - System.out.println("Object temp: " + temps.objectTemperature() + " C"); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/P9813_Example.java upm-1.7.1/examples/java/P9813_Example.java --- upm-1.6.0/examples/java/P9813_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/P9813_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Author: Sergey Kiselev + * Copyright (c) 2017 Sergey Kiselev + * Based on the apa102 driver writen by Yannick Adam + * + * 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 P9813_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a chain of 2 LEDs using pin 2 for clock and pin 3 for data + upm_p9813.P9813 ledChain = + new upm_p9813.P9813(2, (short)2, (short)3, false); + + System.out.println("Set all LEDs to blue"); + ledChain.setAllLeds((short)0, (short)0, (short)255); + + System.out.println("Set a single LED to red at index 1"); + ledChain.setLed(1, (short)255, (short)0, (short)0); + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/P9813Sample.java upm-1.7.1/examples/java/P9813Sample.java --- upm-1.6.0/examples/java/P9813Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/P9813Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - * Author: Sergey Kiselev - * Copyright (c) 2017 Sergey Kiselev - * Based on the apa102 driver writen by Yannick Adam - * - * 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 P9813Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a chain of 2 LEDs using pin 2 for clock and pin 3 for data - upm_p9813.P9813 ledChain = - new upm_p9813.P9813(2, (short)2, (short)3, false); - - System.out.println("Set all LEDs to blue"); - ledChain.setAllLeds((short)0, (short)0, (short)255); - - System.out.println("Set a single LED to red at index 1"); - ledChain.setLed(1, (short)255, (short)0, (short)0); - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/PN532_Example.java upm-1.7.1/examples/java/PN532_Example.java --- upm-1.6.0/examples/java/PN532_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/PN532_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,76 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class PN532_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the + // IRQ, and gpio 2 for the reset pin. + + upm_pn532.PN532 nfc = new upm_pn532.PN532(3, 2); + + if (!nfc.init()) + System.out.println("init() failed"); + + long vers = nfc.getFirmwareVersion(); + + if (vers != 0) + System.out.println("Got firmware version: " + String.format("0x%08x", vers)); + else { + System.out.println("Could not identify PN532\n"); + return; + } + + // Now scan and identify any cards that come in range (1 for now) + + // Retry forever + nfc.setPassiveActivationRetries((short) 0xff); + + nfc.SAMConfig(); + + short[] uidSize = new short[1]; + byte[] uid = new byte[7]; + + while (true) { + if (nfc.readPassiveTargetID(PN532.BAUD_T.BAUD_MIFARE_ISO14443A, uid, uidSize, 2000)) { + // found a card + System.out.println("Found a card: UID len " + uidSize[0]); + System.out.print("UID: "); + + for (int i = 0; i < uidSize[0]; i++) + System.out.print(String.format("%02x", uid[i]) + " "); + + System.out.println("\nSAK: " + String.format("0x%02x", nfc.getSAK())); + System.out.println("ATQA: " + String.format("0x%04x\n\n", nfc.getATQA())); + + Thread.sleep(1000); + } else { + System.out.println("Waiting for a card..."); + } + } + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/PN532Sample.java upm-1.7.1/examples/java/PN532Sample.java --- upm-1.6.0/examples/java/PN532Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/PN532Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class PN532Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the - // IRQ, and gpio 2 for the reset pin. - - upm_pn532.PN532 nfc = new upm_pn532.PN532(3, 2); - - if (!nfc.init()) - System.out.println("init() failed"); - - long vers = nfc.getFirmwareVersion(); - - if (vers != 0) - System.out.println("Got firmware version: " + String.format("0x%08x", vers)); - else { - System.out.println("Could not identify PN532\n"); - return; - } - - // Now scan and identify any cards that come in range (1 for now) - - // Retry forever - nfc.setPassiveActivationRetries((short) 0xff); - - nfc.SAMConfig(); - - short[] uidSize = new short[1]; - byte[] uid = new byte[7]; - - while (true) { - if (nfc.readPassiveTargetID(PN532.BAUD_T.BAUD_MIFARE_ISO14443A, uid, uidSize, 2000)) { - // found a card - System.out.println("Found a card: UID len " + uidSize[0]); - System.out.print("UID: "); - - for (int i = 0; i < uidSize[0]; i++) - System.out.print(String.format("%02x", uid[i]) + " "); - - System.out.println("\nSAK: " + String.format("0x%02x", nfc.getSAK())); - System.out.println("ATQA: " + String.format("0x%04x\n\n", nfc.getATQA())); - - Thread.sleep(1000); - } else { - System.out.println("Waiting for a card..."); - } - } - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/PN532_writeurl_Example.java upm-1.7.1/examples/java/PN532_writeurl_Example.java --- upm-1.6.0/examples/java/PN532_writeurl_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/PN532_writeurl_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,97 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +// NOT TESTED!!! +public class PN532_writeurl_Example { + + static private final String url = "iotdk.intel.com"; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the + // IRQ, and gpio 2 for the reset pin. + + upm_pn532.PN532 nfc = new upm_pn532.PN532(3, 2); + + if (!nfc.init()) + System.out.println("init() failed"); + + long vers = nfc.getFirmwareVersion(); + + if (vers != 0) + System.out.println("Got firmware version: " + String.format("0x%08x", vers)); + else { + System.out.println("Could not identify PN532\n"); + return; + } + + // Now scan and identify any cards that come in range (1 for now) + + // Retry forever + nfc.setPassiveActivationRetries((short) 0xff); + + nfc.SAMConfig(); + + short[] uidSize = new short[1]; + byte[] uid = new byte[7]; + + boolean foundCard = false; + while (!foundCard) { + if (nfc.readPassiveTargetID(PN532.BAUD_T.BAUD_MIFARE_ISO14443A, uid, uidSize, 2000)) { + // found a card + System.out.println("Found a card: UID len " + uidSize[0]); + System.out.print("UID: "); + + for (int i = 0; i < uidSize[0]; i++) + System.out.print(String.format("%02x", uid[i]) + " "); + + System.out.println("\nSAK: " + String.format("0x%02x", nfc.getSAK())); + System.out.println("ATQA: " + String.format("0x%04x\n\n", nfc.getATQA())); + + foundCard = true; + } else { + System.out.println("Waiting for a card..."); + } + } + + if (uidSize[0] != 7) { + System.out.println("This example will only write an NDEF URI to preformatted"); + System.out.println("Mifare Ultralight or NTAG2XX tags\n"); + return; + } + + // 48 bytes is maximum data area on ultralight cards, so we use that + // as the maximum datasize here. Obviously if you have a bigger + // card, you can write more data. + if (!nfc.ntag2xx_WriteNDEFURI(PN532.NDEF_URI_T.NDEF_URIPREFIX_HTTP, url, (short) 48)) { + // failure + System.out.println("Failed to write NDEF record tag.\n"); + return; + } + + System.out.println("Success, URL record written to tag.\n"); + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/PN532_writeurlSample.java upm-1.7.1/examples/java/PN532_writeurlSample.java --- upm-1.6.0/examples/java/PN532_writeurlSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/PN532_writeurlSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -// NOT TESTED!!! -public class PN532_writeurlSample { - - static private final String url = "iotdk.intel.com"; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the - // IRQ, and gpio 2 for the reset pin. - - upm_pn532.PN532 nfc = new upm_pn532.PN532(3, 2); - - if (!nfc.init()) - System.out.println("init() failed"); - - long vers = nfc.getFirmwareVersion(); - - if (vers != 0) - System.out.println("Got firmware version: " + String.format("0x%08x", vers)); - else { - System.out.println("Could not identify PN532\n"); - return; - } - - // Now scan and identify any cards that come in range (1 for now) - - // Retry forever - nfc.setPassiveActivationRetries((short) 0xff); - - nfc.SAMConfig(); - - short[] uidSize = new short[1]; - byte[] uid = new byte[7]; - - boolean foundCard = false; - while (!foundCard) { - if (nfc.readPassiveTargetID(PN532.BAUD_T.BAUD_MIFARE_ISO14443A, uid, uidSize, 2000)) { - // found a card - System.out.println("Found a card: UID len " + uidSize[0]); - System.out.print("UID: "); - - for (int i = 0; i < uidSize[0]; i++) - System.out.print(String.format("%02x", uid[i]) + " "); - - System.out.println("\nSAK: " + String.format("0x%02x", nfc.getSAK())); - System.out.println("ATQA: " + String.format("0x%04x\n\n", nfc.getATQA())); - - foundCard = true; - } else { - System.out.println("Waiting for a card..."); - } - } - - if (uidSize[0] != 7) { - System.out.println("This example will only write an NDEF URI to preformatted"); - System.out.println("Mifare Ultralight or NTAG2XX tags\n"); - return; - } - - // 48 bytes is maximum data area on ultralight cards, so we use that - // as the maximum datasize here. Obviously if you have a bigger - // card, you can write more data. - if (!nfc.ntag2xx_WriteNDEFURI(PN532.NDEF_URI_T.NDEF_URIPREFIX_HTTP, url, (short) 48)) { - // failure - System.out.println("Failed to write NDEF record tag.\n"); - return; - } - - System.out.println("Success, URL record written to tag.\n"); - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/PPD42NS_Example.java upm-1.7.1/examples/java/PPD42NS_Example.java --- upm-1.6.0/examples/java/PPD42NS_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/PPD42NS_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class PPD42NS_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a dust sensor on GPIO pin D8 + upm_ppd42ns.PPD42NS dust = new upm_ppd42ns.PPD42NS(8); + upm_ppd42ns.ppd42ns_dust_data data; + + System.out.println("This program will give readings every 30 seconds until you stop it"); + + while (true) { + data = dust.getData(); + + System.out.println("Low pulse occupancy: " + data.getLowPulseOccupancy()); + System.out.println("Ratio: " + data.getRatio()); + System.out.println("Concentration: " + data.getConcentration()); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/PPD42NSSample.java upm-1.7.1/examples/java/PPD42NSSample.java --- upm-1.6.0/examples/java/PPD42NSSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/PPD42NSSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class PPD42NSSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a dust sensor on GPIO pin D8 - upm_ppd42ns.PPD42NS dust = new upm_ppd42ns.PPD42NS(8); - upm_ppd42ns.ppd42ns_dust_data data; - - System.out.println("This program will give readings every 30 seconds until you stop it"); - - while (true) { - data = dust.getData(); - - System.out.println("Low pulse occupancy: " + data.getLowPulseOccupancy()); - System.out.println("Ratio: " + data.getRatio()); - System.out.println("Concentration: " + data.getConcentration()); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/Pulsensor_Example.java upm-1.7.1/examples/java/Pulsensor_Example.java --- upm-1.6.0/examples/java/Pulsensor_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Pulsensor_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Author: Andrei Vasiliu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_pulsensor.*; + +public class Pulsensor_Example { + static class PulsensorCallback extends Callback { + public PulsensorCallback() { + super(); + } + public void run (clbk_data arg) { + System.out.println(); + } + } + + public static void main (String[] args) throws InterruptedException { + // ! [Interesting] + Callback obj_call = new PulsensorCallback(); + Pulsensor p = new Pulsensor(obj_call); + p.start_sampler(); + Thread.sleep(1000); + p.stop_sampler(); + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/PulsensorSample.java upm-1.7.1/examples/java/PulsensorSample.java --- upm-1.6.0/examples/java/PulsensorSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/PulsensorSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - * Author: Andrei Vasiliu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_pulsensor.*; - -public class PulsensorSample { - static class PulsensorCallback extends Callback { - public PulsensorCallback() { - super(); - } - public void run (clbk_data arg) { - System.out.println(); - } - } - - public static void main (String[] args) throws InterruptedException { - // ! [Interesting] - Callback obj_call = new PulsensorCallback(); - Pulsensor p = new Pulsensor(obj_call); - p.start_sampler(); - Thread.sleep(1000); - p.stop_sampler(); - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Relay_Example.java upm-1.7.1/examples/java/Relay_Example.java --- upm-1.6.0/examples/java/Relay_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Relay_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Relay_Example { + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Create the button object using UART + upm_relay.Relay relay = new upm_relay.Relay(5); + + for (int i = 0; i < 3; i++) { + relay.on(); + if (relay.isOn()) + System.out.println("Relay is on"); + Thread.sleep(1000); + + relay.off(); + if (relay.isOff()) + System.out.println("Relay is off"); + Thread.sleep(1000); + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/RelaySample.java upm-1.7.1/examples/java/RelaySample.java --- upm-1.6.0/examples/java/RelaySample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/RelaySample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class RelaySample { - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Create the button object using UART - upm_relay.Relay relay = new upm_relay.Relay(5); - - for (int i = 0; i < 3; i++) { - relay.on(); - if (relay.isOn()) - System.out.println("Relay is on"); - Thread.sleep(1000); - - relay.off(); - if (relay.isOff()) - System.out.println("Relay is off"); - Thread.sleep(1000); - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/RFR359F_Example.java upm-1.7.1/examples/java/RFR359F_Example.java --- upm-1.6.0/examples/java/RFR359F_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/RFR359F_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class RFR359F_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate an RFR359F digital pin D2 + upm_rfr359f.RFR359F dInterruptor = new upm_rfr359f.RFR359F(2); + + while (true) { + if (dInterruptor.objectDetected()) { + System.out.println("Object detected"); + } else { + System.out.println("Area is clear!"); + } + + Thread.sleep(100); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/RFR359FSample.java upm-1.7.1/examples/java/RFR359FSample.java --- upm-1.6.0/examples/java/RFR359FSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/RFR359FSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class RFR359FSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate an RFR359F digital pin D2 - upm_rfr359f.RFR359F dInterruptor = new upm_rfr359f.RFR359F(2); - - while (true) { - if (dInterruptor.objectDetected()) { - System.out.println("Object detected"); - } else { - System.out.println("Area is clear!"); - } - - Thread.sleep(100); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/RHUSB_Example.java upm-1.7.1/examples/java/RHUSB_Example.java --- upm-1.6.0/examples/java/RHUSB_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/RHUSB_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class RHUSB_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + + String defaultDev = "/dev/ttyUSB0"; + + // if an argument was specified, use it as the device instead + if (args.length > 0) + defaultDev = args[0]; + + System.out.println("Using device " + defaultDev); + System.out.println("Initializing..."); + + // Instantiate an RHUSB instance on defaultDev + upm_rhusb.RHUSB sensor = new upm_rhusb.RHUSB(defaultDev); + + // output the firmware ID + System.out.println("Firmware ID: " + sensor.getFirmwareID()); + + // update and print available values every second + while (true) { + // update our values from the sensor + sensor.update(); + + // we show both C and F for temperature + System.out.println("Temperature: " + sensor.getTemperature() + " C / " + sensor.getTemperature(true) + " F"); + + System.out.println("Humidity: " + sensor.getHumidity() + " %"); + + Thread.sleep(1000); + } + + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/RHUSBSample.java upm-1.7.1/examples/java/RHUSBSample.java --- upm-1.6.0/examples/java/RHUSBSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/RHUSBSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class RHUSBSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - - String defaultDev = "/dev/ttyUSB0"; - - // if an argument was specified, use it as the device instead - if (args.length > 0) - defaultDev = args[0]; - - System.out.println("Using device " + defaultDev); - System.out.println("Initializing..."); - - // Instantiate an RHUSB instance on defaultDev - upm_rhusb.RHUSB sensor = new upm_rhusb.RHUSB(defaultDev); - - // output the firmware ID - System.out.println("Firmware ID: " + sensor.getFirmwareID()); - - // update and print available values every second - while (true) { - // update our values from the sensor - sensor.update(); - - // we show both C and F for temperature - System.out.println("Temperature: " + sensor.getTemperature() + " C / " + sensor.getTemperature(true) + " F"); - - System.out.println("Humidity: " + sensor.getHumidity() + " %"); - - Thread.sleep(1000); - } - - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/RotaryEncoder_Example.java upm-1.7.1/examples/java/RotaryEncoder_Example.java --- upm-1.6.0/examples/java/RotaryEncoder_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/RotaryEncoder_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class RotaryEncoder_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Grove Rotary Encoder, using signal pins D2 and D3 + upm_rotaryencoder.RotaryEncoder rotaryencoder = new upm_rotaryencoder.RotaryEncoder(2, 3); + + while (true) { + System.out.println("Position: " + rotaryencoder.position()); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/RotaryEncoderSample.java upm-1.7.1/examples/java/RotaryEncoderSample.java --- upm-1.6.0/examples/java/RotaryEncoderSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/RotaryEncoderSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class RotaryEncoderSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Grove Rotary Encoder, using signal pins D2 and D3 - upm_rotaryencoder.RotaryEncoder rotaryencoder = new upm_rotaryencoder.RotaryEncoder(2, 3); - - while (true) { - System.out.println("Position: " + rotaryencoder.position()); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Rotary_Example.java upm-1.7.1/examples/java/Rotary_Example.java --- upm-1.6.0/examples/java/Rotary_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Rotary_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Rotary_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_rotary.Rotary knob = new upm_rotary.Rotary(0); + + while (true) { + float abs_value = knob.abs_value(); // Absolute raw value + float abs_deg = knob.abs_deg(); // Absolute degrees + float abs_rad = knob.abs_rad(); // Absolute radians + float rel_value = knob.rel_value(); // Relative raw value + float rel_deg = knob.rel_deg(); // Relative degrees + float rel_rad = knob.rel_rad(); // Relative radians + + System.out.println("Absolute: " + abs_value + " raw, " + abs_deg + " deg, " + abs_rad + + " rad"); + System.out.println("Relative: " + rel_value + " raw, " + rel_deg + " deg, " + rel_rad + + " rad"); + + Thread.sleep(3000); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/RotarySample.java upm-1.7.1/examples/java/RotarySample.java --- upm-1.6.0/examples/java/RotarySample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/RotarySample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class RotarySample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_rotary.Rotary knob = new upm_rotary.Rotary(0); - - while (true) { - float abs_value = knob.abs_value(); // Absolute raw value - float abs_deg = knob.abs_deg(); // Absolute degrees - float abs_rad = knob.abs_rad(); // Absolute radians - float rel_value = knob.rel_value(); // Relative raw value - float rel_deg = knob.rel_deg(); // Relative degrees - float rel_rad = knob.rel_rad(); // Relative radians - - System.out.println("Absolute: " + abs_value + " raw, " + abs_deg + " deg, " + abs_rad - + " rad"); - System.out.println("Relative: " + rel_value + " raw, " + rel_deg + " deg, " + rel_rad - + " rad"); - - Thread.sleep(3000); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/RPR220_Example.java upm-1.7.1/examples/java/RPR220_Example.java --- upm-1.6.0/examples/java/RPR220_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/RPR220_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class RPR220_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // This example uses a simple method to determine current status + + // Instantiate an RPR220 digital pin D2 + upm_rpr220.RPR220 sensor = new upm_rpr220.RPR220(2); + + while (true) { + if (sensor.blackDetected()) + System.out.println("Black detected"); + else + System.out.println("Black NOT detected"); + + Thread.sleep(100); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/RPR220_intr_Example.java upm-1.7.1/examples/java/RPR220_intr_Example.java --- upm-1.6.0/examples/java/RPR220_intr_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/RPR220_intr_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,57 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class RPR220_intr_Example { + + private static int counter = 0; + + public static void incrementCounter() { + counter++; + } + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // This example uses an interrupt handler to increment a counter + + // Instantiate an RPR220 digital pin D2 + upm_rpr220.RPR220 sensor = new upm_rpr220.RPR220(2); + + RPRISR callback = new RPRISR(); + sensor.installISR(callback); + + while (true) { + System.out.println("Counter: " + counter); + Thread.sleep(1000); + } + // ! [Interesting] + } +} + +class RPRISR implements Runnable { + public RPRISR() { + super(); + } + public void run() { + RPR220_intr_Example.incrementCounter(); + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/RPR220_intrSample.java upm-1.7.1/examples/java/RPR220_intrSample.java --- upm-1.6.0/examples/java/RPR220_intrSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/RPR220_intrSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class RPR220_intrSample { - - public static int counter = 0; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // This example uses an interrupt handler to increment a counter - - // Instantiate an RPR220 digital pin D2 - upm_rpr220.RPR220 sensor = new upm_rpr220.RPR220(2); - - RPRISR callback = new RPRISR(); - sensor.installISR(callback); - - while (true) { - System.out.println("Counter: " + counter); - Thread.sleep(1000); - } - // ! [Interesting] - } -} - -class RPRISR implements Runnable { - public RPRISR() { - super(); - } - public void run() { - RPR220_intrSample.counter++; - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/RPR220Sample.java upm-1.7.1/examples/java/RPR220Sample.java --- upm-1.6.0/examples/java/RPR220Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/RPR220Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class RPR220Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // This example uses a simple method to determine current status - - // Instantiate an RPR220 digital pin D2 - upm_rpr220.RPR220 sensor = new upm_rpr220.RPR220(2); - - while (true) { - if (sensor.blackDetected()) - System.out.println("Black detected"); - else - System.out.println("Black NOT detected"); - - Thread.sleep(100); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/SCAM_Example.java upm-1.7.1/examples/java/SCAM_Example.java --- upm-1.6.0/examples/java/SCAM_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/SCAM_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class SCAM_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Serial Camera on UART 0 + upm_scam.SCAM camera = new upm_scam.SCAM(0); + + // make sure port is initialized properly. 115200 baud is the default. + if (!camera.setupTty()) { + System.err.println("Failed to setup tty port parameters"); + System.exit(-1); + } + + if (camera.init()) + System.out.println("Initialized..."); + else + System.out.println("Initialization failed"); + + if (camera.preCapture()) + System.out.println("preCapture succeeded..."); + else + System.out.println("preCapture failed."); + + if (camera.doCapture()) + System.out.println("doCapture succeeded..."); + else + System.out.println("doCapture failed."); + + if (camera.getImageSize() > 0) { + System.out.println("Storing image.jpg..."); + + if (camera.storeImage("image.jpg")) + System.out.println("storeImage succeeded..."); + else + System.out.println("storeImage failed."); + + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/SCAMSample.java upm-1.7.1/examples/java/SCAMSample.java --- upm-1.6.0/examples/java/SCAMSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/SCAMSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class SCAMSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Serial Camera on UART 0 - upm_scam.SCAM camera = new upm_scam.SCAM(0); - - // make sure port is initialized properly. 115200 baud is the default. - if (!camera.setupTty()) { - System.err.println("Failed to setup tty port parameters"); - System.exit(-1); - } - - if (camera.init()) - System.out.println("Initialized..."); - else - System.out.println("Initialization failed"); - - if (camera.preCapture()) - System.out.println("preCapture succeeded..."); - else - System.out.println("preCapture failed."); - - if (camera.doCapture()) - System.out.println("doCapture succeeded..."); - else - System.out.println("doCapture failed."); - - if (camera.getImageSize() > 0) { - System.out.println("Storing image.jpg..."); - - if (camera.storeImage("image.jpg")) - System.out.println("storeImage succeeded..."); - else - System.out.println("storeImage failed."); - - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/SensorTemplate_Example.java upm-1.7.1/examples/java/SensorTemplate_Example.java --- upm-1.6.0/examples/java/SensorTemplate_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/SensorTemplate_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Author: Your Full Name + * Copyright (c) + * + * 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 SensorTemplate_Example { + public static void main (String args[]) throws InterruptedException { + //! [Interesting] + // Instantiate new sensor instance + upm_sensortemplate.SensorTemplate sensor = new upm_sensortemplate.SensorTemplate(0); + + while (true) { + + System.out.println("SensorTemplate says: " + sensor.helloWorld()); + + // Repeate every 2 seconds + Thread.sleep(2000); + } + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/SensorTemplateSample.java upm-1.7.1/examples/java/SensorTemplateSample.java --- upm-1.6.0/examples/java/SensorTemplateSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/SensorTemplateSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - * The MIT License (MIT) - * - * Author: Your Full Name - * Copyright (c) - * - * 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 SensorTemplateSample { - public static void main (String args[]) throws InterruptedException { - //! [Interesting] - // Instantiate new sensor instance - upm_sensortemplate.SensorTemplate sensor = new upm_sensortemplate.SensorTemplate(0); - - while (true) { - - System.out.println("SensorTemplate says: " + sensor.helloWorld()); - - // Repeate every 2 seconds - Thread.sleep(2000); - } - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Slide_Example.java upm-1.7.1/examples/java/Slide_Example.java --- upm-1.6.0/examples/java/Slide_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Slide_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Author: Andrei Vasiliu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Slide_Example { + public static void main (String args[]) throws InterruptedException { + //! [Interesting] + // Instantiate new grove slide potentiometer on analog pin A0 + upm_slide.Slide slide = new upm_slide.Slide(0); + + while (true) { + float raw_value = slide.raw_value(); + float value = slide.voltage_value(); + + System.out.println("raw value: " + raw_value); + System.out.println("value: " + value); + + Thread.sleep(2500); + } + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/SlideSample.java upm-1.7.1/examples/java/SlideSample.java --- upm-1.6.0/examples/java/SlideSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/SlideSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - * Author: Andrei Vasiliu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class SlideSample { - public static void main (String args[]) throws InterruptedException { - //! [Interesting] - // Instantiate new grove slide potentiometer on analog pin A0 - upm_slide.Slide slide = new upm_slide.Slide(0); - - while (true) { - float raw_value = slide.raw_value(); - float value = slide.voltage_value(); - - System.out.println("raw value: " + raw_value); - System.out.println("value: " + value); - - Thread.sleep(2500); - } - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/SM130_Example.java upm-1.7.1/examples/java/SM130_Example.java --- upm-1.6.0/examples/java/SM130_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/SM130_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,69 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import upm_sm130.SM130; + +public class SM130_Example { + + static { + try { + System.loadLibrary("javaupm_sm130"); + System.loadLibrary("mraajava"); + } catch (UnsatisfiedLinkError e) { + System.err.println( + "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + + e); + System.exit(1); + } + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // Instantiate a UART based SM130 RFID Module using defaults + SM130 sensor = new SM130(); + + // set the baud rate. 19200 baud is the default. + if(sensor.setBaudRate(19200) == 1){ + System.out.println("Failed to set baud rate"); + return; + } + + System.out.println("Resetting..."); + sensor.reset(); + + System.out.println("Firmware revision: "+sensor.getFirmwareVersion()); + System.out.println("Waiting up to 5 seconds for a tag..."); + + if(sensor.waitForTag(5000)){ + System.out.println("Found tag, UID: "+sensor.string2HexString(sensor.getUID())); + System.out.println("Tag Type: "+sensor.tag2String(sensor.getTagType())); + } + else{ + // error + System.out.println("waitForTag failed: "+sensor.getLastErrorString()); + } + //! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/SM130Example.java upm-1.7.1/examples/java/SM130Example.java --- upm-1.6.0/examples/java/SM130Example.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/SM130Example.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_sm130.SM130; - -public class SM130Example { - - static { - try { - System.loadLibrary("javaupm_sm130"); - System.loadLibrary("mraajava"); - } catch (UnsatisfiedLinkError e) { - System.err.println( - "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + - e); - System.exit(1); - } - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // Instantiate a UART based SM130 RFID Module using defaults - SM130 sensor = new SM130(); - - // set the baud rate. 19200 baud is the default. - if(sensor.setBaudRate(19200) == 1){ - System.out.println("Failed to set baud rate"); - return; - } - - System.out.println("Resetting..."); - sensor.reset(); - - System.out.println("Firmware revision: "+sensor.getFirmwareVersion()); - System.out.println("Waiting up to 5 seconds for a tag..."); - - if(sensor.waitForTag(5000)){ - System.out.println("Found tag, UID: "+sensor.string2HexString(sensor.getUID())); - System.out.println("Tag Type: "+sensor.tag2String(sensor.getTagType())); - } - else{ - // error - System.out.println("waitForTag failed: "+sensor.getLastErrorString()); - } - //! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Speaker_Example.java upm-1.7.1/examples/java/Speaker_Example.java --- upm-1.6.0/examples/java/Speaker_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Speaker_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Author: Andrei Vasiliu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Speaker_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Speaker on digital pin D2 + upm_speaker.Speaker speaker = new upm_speaker.Speaker(2); + + // Play all 7 of the lowest notes + speaker.playAll(); + + // Play a medium C-sharp + speaker.playSound('c', true, "med"); + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/SpeakerPWM_Example.java upm-1.7.1/examples/java/SpeakerPWM_Example.java --- upm-1.6.0/examples/java/SpeakerPWM_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/SpeakerPWM_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Author: Jon Trulson + * 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. + */ + +public class SpeakerPWM_Example { + + public static void main(String[] args) throws InterruptedException { +// ! [Interesting] + // Instantiate a Speaker (PWM) pin D3 in PWM mode + upm_speaker.Speaker speaker = new upm_speaker.Speaker(3, true); + + // emit a series of frequencies for 500ms each + speaker.emit(50, 500); + speaker.emit(75, 500); + speaker.emit(125, 500); + speaker.emit(250, 500); + speaker.emit(500, 500); + speaker.emit(1000, 500); + speaker.emit(2000, 500); + speaker.emit(3000, 500); + speaker.emit(5000, 500); + speaker.emit(10000, 500); +// ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/SpeakerPWMSample.java upm-1.7.1/examples/java/SpeakerPWMSample.java --- upm-1.6.0/examples/java/SpeakerPWMSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/SpeakerPWMSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - * Author: Jon Trulson - * 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. - */ - -public class SpeakerPWMSample { - - public static void main(String[] args) throws InterruptedException { -// ! [Interesting] - // Instantiate a Speaker (PWM) pin D3 in PWM mode - upm_speaker.Speaker speaker = new upm_speaker.Speaker(3, true); - - // emit a series of frequencies for 500ms each - speaker.emit(50, 500); - speaker.emit(75, 500); - speaker.emit(125, 500); - speaker.emit(250, 500); - speaker.emit(500, 500); - speaker.emit(1000, 500); - speaker.emit(2000, 500); - speaker.emit(3000, 500); - speaker.emit(5000, 500); - speaker.emit(10000, 500); -// ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/SpeakerSample.java upm-1.7.1/examples/java/SpeakerSample.java --- upm-1.6.0/examples/java/SpeakerSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/SpeakerSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* - * Author: Andrei Vasiliu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class SpeakerSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Speaker on digital pin D2 - upm_speaker.Speaker speaker = new upm_speaker.Speaker(2); - - // Play all 7 of the lowest notes - speaker.playAll(); - - // Play a medium C-sharp - speaker.playSound('c', true, "med"); - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/SSD1308_oled_Example.java upm-1.7.1/examples/java/SSD1308_oled_Example.java --- upm-1.6.0/examples/java/SSD1308_oled_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/SSD1308_oled_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,89 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class SSD1308_oled_Example { + + static private final int[] IntelLogo = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 192, + 192, 192, 224, 224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, + 60, 62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, 30, 62, 62, 62, 62, + 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240, 224, 224, 224, 192, 128, 128, + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, + 128, 128, 128, 128, 128, 128, 128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 192, + 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195, 195, 7, 15, 15, 63, 127, + 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 192, 240, + 248, 124, 124, 60, 0, 0, 0, 0, 159, 159, 159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 0, 0, 0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128, + 128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 3, 7, 3, 3, + 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255, 255, 255, 0, 0, 224, 248, 252, 252, + 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, + 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, + 255, 255, 255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, + 15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143, 135, 135, 143, + 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255, 255, 255, 255, 255, 255, + 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 224, 248, 248, 255, 255, 255, 255, + 255, 127, 15, 255, 255, 255, 255, 255, 255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, + 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, + 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, + 255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255, 255, 255, 255, + 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231, 231, 231, 199, 135, 0, 0, + 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 224, 240, 248, 248, 252, 254, + 255, 255, 255, 127, 63, 63, 31, 15, 7, 7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, + 240, 192, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, + 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7, 7, 7, + 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7, 7, 3, 3, 3, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15, 31, 127, 127, 127, 255, 255, + 252, 252, 252, 248, 240, 240, 240, 224, 224, 224, 192, 192, 192, 192, 128, 128, 128, + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, + 192, 192, 192, 224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, + 252, 254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 15, + 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127, 127, 127, 255, 255, 255, 255, 254, + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, + 127, 127, 127, 127, 63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, + 3, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0}; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_lcd.SSD1308 lcd = new upm_lcd.SSD1308(0); + + byte[] image = new byte[IntelLogo.length]; + for (int i = 0; i < IntelLogo.length; i++) + image[i] = (byte) IntelLogo[i]; + + lcd.clear(); + lcd.draw(image); + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/SSD1308_oledSample.java upm-1.7.1/examples/java/SSD1308_oledSample.java --- upm-1.6.0/examples/java/SSD1308_oledSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/SSD1308_oledSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class SSD1308_oledSample { - - static private final int[] IntelLogo = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 192, - 192, 192, 224, 224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, - 60, 62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, 30, 62, 62, 62, 62, - 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240, 224, 224, 224, 192, 128, 128, - 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, - 128, 128, 128, 128, 128, 128, 128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 192, - 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195, 195, 7, 15, 15, 63, 127, - 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 192, 240, - 248, 124, 124, 60, 0, 0, 0, 0, 159, 159, 159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 0, 0, 0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128, - 128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128, 128, 128, - 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 3, 7, 3, 3, - 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255, 255, 255, 0, 0, 224, 248, 252, 252, - 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, - 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, - 255, 255, 255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, - 15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143, 135, 135, 143, - 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255, 255, 255, 255, 255, 255, - 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 224, 248, 248, 255, 255, 255, 255, - 255, 127, 15, 255, 255, 255, 255, 255, 255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, - 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, - 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, - 255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255, 255, 255, 255, - 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231, 231, 231, 199, 135, 0, 0, - 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 224, 240, 248, 248, 252, 254, - 255, 255, 255, 127, 63, 63, 31, 15, 7, 7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, - 240, 192, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, - 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7, 7, 7, - 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7, 7, 3, 3, 3, 1, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15, 31, 127, 127, 127, 255, 255, - 252, 252, 252, 248, 240, 240, 240, 224, 224, 224, 192, 192, 192, 192, 128, 128, 128, - 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, - 192, 192, 192, 224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, - 252, 254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 15, - 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127, 127, 127, 255, 255, 255, 255, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, - 127, 127, 127, 127, 63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, - 3, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0}; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_lcd.SSD1308 lcd = new upm_lcd.SSD1308(0); - - byte[] image = new byte[IntelLogo.length]; - for (int i = 0; i < IntelLogo.length; i++) - image[i] = (byte) IntelLogo[i]; - - lcd.clear(); - lcd.draw(image); - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/SSD1327_oled_Example.java upm-1.7.1/examples/java/SSD1327_oled_Example.java --- upm-1.6.0/examples/java/SSD1327_oled_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/SSD1327_oled_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,135 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class SSD1327_oled_Example { + + static private final int[] SeeedLogo = new int[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x03, + 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xC0, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x07, 0x80, 0x01, 0xE0, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x0F, 0x80, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x30, 0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, + 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, + 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x38, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x80, 0x01, 0xE0, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3C, 0x0F, 0x80, 0x01, 0xE0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3E, 0x0F, 0x80, 0x03, 0xE0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x07, + 0x80, 0x03, 0xE0, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x07, 0x80, 0x03, + 0xE0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x07, 0x80, 0x03, 0xC1, 0xF0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x87, 0xC0, 0x07, 0xC1, 0xF0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x83, 0xC0, 0x07, 0x83, 0xE0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0F, 0xC3, 0xC0, 0x07, 0x87, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0xE1, 0xE0, 0x07, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF0, + 0xE0, 0x0F, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF8, 0xF0, 0x0E, + 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF8, 0x70, 0x1C, 0x3F, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x30, 0x18, 0x7E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x18, 0x30, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1F, 0x88, 0x21, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0F, 0xC4, 0x47, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0xE0, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x3E, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x06, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x06, 0x00, 0x00, 0x60, 0x00, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xDF, 0xE1, + 0x9F, 0xEC, 0x7E, 0xE6, 0x73, 0x9C, 0xE7, 0x39, 0xCE, 0x1C, 0xDF, 0xE1, 0xB9, 0xEC, + 0xE7, 0xE0, 0x61, 0xD8, 0x66, 0x1B, 0x86, 0x1C, 0x06, 0x61, 0xB0, 0x6D, 0xC3, 0x7C, + 0x7F, 0xFF, 0xFF, 0xFF, 0x06, 0x0F, 0x86, 0x61, 0xB0, 0x6D, 0x83, 0x3E, 0x7F, 0xFF, + 0xFF, 0xFF, 0x06, 0x07, 0xC6, 0x61, 0xB0, 0x6D, 0x83, 0xC3, 0x61, 0x18, 0x46, 0x03, + 0x86, 0x18, 0x66, 0x61, 0xB0, 0x6D, 0xC3, 0xFE, 0x7F, 0x9F, 0xE7, 0xF9, 0xFE, 0x1F, + 0xE6, 0x3F, 0x9F, 0xEC, 0xFE, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xC6, 0x3F, + 0x9F, 0xEC, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x20, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x44, 0x00, 0x00, 0x20, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, + 0xF3, 0xCF, 0x70, 0x9E, 0x79, 0xE7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x9E, 0x68, + 0x20, 0xB2, 0xC8, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x9E, 0x6F, 0x20, 0xB2, + 0xF9, 0xE7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x46, 0x9A, 0x61, 0x20, 0xB2, 0xCB, 0x60, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xF3, 0xCF, 0x30, 0x9E, 0x79, 0xE7, 0x90, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7C, 0x02, 0x00, 0x00, 0x82, 0x60, 0x00, 0x00, 0xF8, 0x00, 0x00, + 0x40, 0x40, 0x02, 0x00, 0x00, 0x83, 0x60, 0x00, 0x00, 0x8C, 0x00, 0x00, 0x40, 0x60, + 0xB7, 0x79, 0xE7, 0x81, 0xC7, 0x92, 0x70, 0x89, 0xE7, 0x9E, 0x78, 0x7C, 0xE2, 0xC9, + 0x2C, 0x81, 0xCC, 0xD2, 0x40, 0xFB, 0x21, 0xB2, 0x48, 0x40, 0x62, 0xF9, 0x2C, 0x80, + 0x8C, 0xD2, 0x40, 0x8B, 0xE7, 0xB0, 0x48, 0x40, 0xE2, 0xC9, 0x2C, 0x80, 0x84, 0xD2, + 0x40, 0x8B, 0x2D, 0x92, 0x48, 0x7D, 0xB3, 0x79, 0x27, 0x80, 0x87, 0x9E, 0x40, 0x8D, + 0xE7, 0x9E, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_lcd.SSD1327 lcd = new upm_lcd.SSD1327(0); + + // If you don't set the display to be white, the seeed logo will appear + // jagged + lcd.setGrayLevel((short) 12); + + byte[] image = new byte[SeeedLogo.length]; + for (int i = 0; i < SeeedLogo.length; i++) + image[i] = (byte) SeeedLogo[i]; + + lcd.draw(image); + + // Simple print hello world + for (short i = 0; i < 12; i++) { + lcd.setCursor(i, 0); + lcd.setGrayLevel(i); + lcd.write("Hello World"); + } + + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/SSD1327_oledSample.java upm-1.7.1/examples/java/SSD1327_oledSample.java --- upm-1.6.0/examples/java/SSD1327_oledSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/SSD1327_oledSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class SSD1327_oledSample { - - static private final int[] SeeedLogo = new int[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, - 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x03, - 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xC0, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x07, 0x80, 0x01, 0xE0, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x0F, 0x80, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x30, 0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, - 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, - 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x38, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x80, 0x01, 0xE0, 0x38, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x0F, 0x80, 0x01, 0xE0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3E, 0x0F, 0x80, 0x03, 0xE0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x07, - 0x80, 0x03, 0xE0, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x07, 0x80, 0x03, - 0xE0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x07, 0x80, 0x03, 0xC1, 0xF0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x87, 0xC0, 0x07, 0xC1, 0xF0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0F, 0x83, 0xC0, 0x07, 0x83, 0xE0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0F, 0xC3, 0xC0, 0x07, 0x87, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x07, 0xE1, 0xE0, 0x07, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF0, - 0xE0, 0x0F, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF8, 0xF0, 0x0E, - 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF8, 0x70, 0x1C, 0x3F, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x30, 0x18, 0x7E, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x18, 0x30, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0x88, 0x21, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0F, 0xC4, 0x47, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, - 0xE0, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x3E, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x06, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x06, 0x00, 0x00, 0x60, 0x00, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xDF, 0xE1, - 0x9F, 0xEC, 0x7E, 0xE6, 0x73, 0x9C, 0xE7, 0x39, 0xCE, 0x1C, 0xDF, 0xE1, 0xB9, 0xEC, - 0xE7, 0xE0, 0x61, 0xD8, 0x66, 0x1B, 0x86, 0x1C, 0x06, 0x61, 0xB0, 0x6D, 0xC3, 0x7C, - 0x7F, 0xFF, 0xFF, 0xFF, 0x06, 0x0F, 0x86, 0x61, 0xB0, 0x6D, 0x83, 0x3E, 0x7F, 0xFF, - 0xFF, 0xFF, 0x06, 0x07, 0xC6, 0x61, 0xB0, 0x6D, 0x83, 0xC3, 0x61, 0x18, 0x46, 0x03, - 0x86, 0x18, 0x66, 0x61, 0xB0, 0x6D, 0xC3, 0xFE, 0x7F, 0x9F, 0xE7, 0xF9, 0xFE, 0x1F, - 0xE6, 0x3F, 0x9F, 0xEC, 0xFE, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xC6, 0x3F, - 0x9F, 0xEC, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x20, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x44, 0x00, 0x00, 0x20, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, - 0xF3, 0xCF, 0x70, 0x9E, 0x79, 0xE7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x9E, 0x68, - 0x20, 0xB2, 0xC8, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x9E, 0x6F, 0x20, 0xB2, - 0xF9, 0xE7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x46, 0x9A, 0x61, 0x20, 0xB2, 0xCB, 0x60, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xF3, 0xCF, 0x30, 0x9E, 0x79, 0xE7, 0x90, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x7C, 0x02, 0x00, 0x00, 0x82, 0x60, 0x00, 0x00, 0xF8, 0x00, 0x00, - 0x40, 0x40, 0x02, 0x00, 0x00, 0x83, 0x60, 0x00, 0x00, 0x8C, 0x00, 0x00, 0x40, 0x60, - 0xB7, 0x79, 0xE7, 0x81, 0xC7, 0x92, 0x70, 0x89, 0xE7, 0x9E, 0x78, 0x7C, 0xE2, 0xC9, - 0x2C, 0x81, 0xCC, 0xD2, 0x40, 0xFB, 0x21, 0xB2, 0x48, 0x40, 0x62, 0xF9, 0x2C, 0x80, - 0x8C, 0xD2, 0x40, 0x8B, 0xE7, 0xB0, 0x48, 0x40, 0xE2, 0xC9, 0x2C, 0x80, 0x84, 0xD2, - 0x40, 0x8B, 0x2D, 0x92, 0x48, 0x7D, 0xB3, 0x79, 0x27, 0x80, 0x87, 0x9E, 0x40, 0x8D, - 0xE7, 0x9E, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_lcd.SSD1327 lcd = new upm_lcd.SSD1327(0); - - // If you don't set the display to be white, the seeed logo will appear - // jagged - lcd.setGrayLevel((short) 12); - - byte[] image = new byte[SeeedLogo.length]; - for (int i = 0; i < SeeedLogo.length; i++) - image[i] = (byte) SeeedLogo[i]; - - lcd.draw(image); - - // Simple print hello world - for (short i = 0; i < 12; i++) { - lcd.setCursor(i, 0); - lcd.setGrayLevel(i); - lcd.write("Hello World"); - } - - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/ST7735_Example.java upm-1.7.1/examples/java/ST7735_Example.java --- upm-1.6.0/examples/java/ST7735_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/ST7735_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,77 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class ST7735_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_st7735.ST7735 lcd = new upm_st7735.ST7735((short) 7, (short) 4, (short) 9, (short) 8); + + lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_RED); + lcd.refresh(); + + lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_CYAN); + lcd.refresh(); + + lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_BLACK); + lcd.refresh(); + + lcd.drawLine((short) 10, (short) 10, (short) 10, (short) 100, + upm_st7735.javaupm_st7735Constants.ST7735_MAGENTA); + lcd.drawLine((short) 20, (short) 20, (short) 10, (short) 100, + upm_st7735.javaupm_st7735Constants.ST7735_YELLOW); + lcd.drawLine((short) 30, (short) 30, (short) 50, (short) 100, + upm_st7735.javaupm_st7735Constants.ST7735_WHITE); + lcd.refresh(); + + lcd.drawPixel((short) 20, (short) 20, upm_st7735.javaupm_st7735Constants.ST7735_GREEN); + lcd.refresh(); + + lcd.drawTriangle((short) 50, (short) 50, (short) 80, (short) 80, (short) 60, (short) 90, + upm_st7735.javaupm_st7735Constants.ST7735_GREEN); + lcd.refresh(); + + lcd.drawCircle((short) 100, (short) 110, (short) 10, + upm_st7735.javaupm_st7735Constants.ST7735_BLUE); + lcd.refresh(); + + lcd.setTextWrap((short) 0); + + lcd.setCursor((short) 0, (short) 30); + lcd.setTextColor(upm_st7735.javaupm_st7735Constants.ST7735_RED, + upm_st7735.javaupm_st7735Constants.ST7735_RED); + lcd.setTextSize((short) 1); + lcd.print("Hello World!"); + + lcd.setCursor((short) 10, (short) 50); + lcd.setTextColor(upm_st7735.javaupm_st7735Constants.ST7735_RED, + upm_st7735.javaupm_st7735Constants.ST7735_YELLOW); + lcd.setTextSize((short) 2); + lcd.print("BIG"); + + lcd.refresh(); + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/ST7735Sample.java upm-1.7.1/examples/java/ST7735Sample.java --- upm-1.6.0/examples/java/ST7735Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/ST7735Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class ST7735Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_st7735.ST7735 lcd = new upm_st7735.ST7735((short) 7, (short) 4, (short) 9, (short) 8); - - lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_RED); - lcd.refresh(); - - lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_CYAN); - lcd.refresh(); - - lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_BLACK); - lcd.refresh(); - - lcd.drawLine((short) 10, (short) 10, (short) 10, (short) 100, - upm_st7735.javaupm_st7735Constants.ST7735_MAGENTA); - lcd.drawLine((short) 20, (short) 20, (short) 10, (short) 100, - upm_st7735.javaupm_st7735Constants.ST7735_YELLOW); - lcd.drawLine((short) 30, (short) 30, (short) 50, (short) 100, - upm_st7735.javaupm_st7735Constants.ST7735_WHITE); - lcd.refresh(); - - lcd.drawPixel((short) 20, (short) 20, upm_st7735.javaupm_st7735Constants.ST7735_GREEN); - lcd.refresh(); - - lcd.drawTriangle((short) 50, (short) 50, (short) 80, (short) 80, (short) 60, (short) 90, - upm_st7735.javaupm_st7735Constants.ST7735_GREEN); - lcd.refresh(); - - lcd.drawCircle((short) 100, (short) 110, (short) 10, - upm_st7735.javaupm_st7735Constants.ST7735_BLUE); - lcd.refresh(); - - lcd.setTextWrap((short) 0); - - lcd.setCursor((short) 0, (short) 30); - lcd.setTextColor(upm_st7735.javaupm_st7735Constants.ST7735_RED, - upm_st7735.javaupm_st7735Constants.ST7735_RED); - lcd.setTextSize((short) 1); - lcd.print("Hello World!"); - - lcd.setCursor((short) 10, (short) 50); - lcd.setTextColor(upm_st7735.javaupm_st7735Constants.ST7735_RED, - upm_st7735.javaupm_st7735Constants.ST7735_YELLOW); - lcd.setTextSize((short) 2); - lcd.print("BIG"); - - lcd.refresh(); - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/StepMotor_Example.java upm-1.7.1/examples/java/StepMotor_Example.java --- upm-1.6.0/examples/java/StepMotor_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/StepMotor_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class StepMotor_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_stepmotor.StepMotor sensor = new upm_stepmotor.StepMotor(2, 3); + + while (true) { + System.out.println("One complete rotation forward and back at 60 rpm."); + sensor.setSpeed(60); + sensor.stepForward(200); + Thread.sleep(1000); + sensor.stepBackward(200); + Thread.sleep(1000); + + System.out.println("One complete rotation forward and back at 150 rpm."); + sensor.setSpeed(150); + sensor.stepForward(200); + Thread.sleep(1000); + sensor.stepBackward(200); + Thread.sleep(1000); + + System.out.println("One complete rotation forward and back at 300 rpm."); + sensor.setSpeed(300); + sensor.stepForward(200); + Thread.sleep(1000); + sensor.stepBackward(200); + Thread.sleep(1000); + } + // ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/StepMotorSample.java upm-1.7.1/examples/java/StepMotorSample.java --- upm-1.6.0/examples/java/StepMotorSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/StepMotorSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class StepMotorSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_stepmotor.StepMotor sensor = new upm_stepmotor.StepMotor(2, 3); - - while (true) { - System.out.println("One complete rotation forward and back at 60 rpm."); - sensor.setSpeed(60); - sensor.stepForward(200); - Thread.sleep(1000); - sensor.stepBackward(200); - Thread.sleep(1000); - - System.out.println("One complete rotation forward and back at 150 rpm."); - sensor.setSpeed(150); - sensor.stepForward(200); - Thread.sleep(1000); - sensor.stepBackward(200); - Thread.sleep(1000); - - System.out.println("One complete rotation forward and back at 300 rpm."); - sensor.setSpeed(300); - sensor.stepForward(200); - Thread.sleep(1000); - sensor.stepBackward(200); - Thread.sleep(1000); - } - // ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Temperature_Example.java upm-1.7.1/examples/java/Temperature_Example.java --- upm-1.6.0/examples/java/Temperature_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Temperature_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Author: Andrei Vasiliu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Temperature_Example { + public static void main (String args[]) throws InterruptedException { + //! [Interesting] + upm_temperature.Temperature temp = new upm_temperature.Temperature(3); + + for (int i = 0; i < 10; ++i) { + + int celsius = temp.value(); + int fahrneheit = celsius * 2 + 32; + + System.out.println("Celsius: " + celsius); + System.out.println("Fahrneheit: " + fahrneheit); + + Thread.sleep(1000); + } + temp.delete(); + //! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/TemperatureSample.java upm-1.7.1/examples/java/TemperatureSample.java --- upm-1.6.0/examples/java/TemperatureSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/TemperatureSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* - * Author: Andrei Vasiliu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class TemperatureSample { - public static void main (String args[]) throws InterruptedException { - //! [Interesting] - upm_temperature.Temperature temp = new upm_temperature.Temperature(3); - - for (int i = 0; i < 10; ++i) { - - int celsius = temp.value(); - int fahrneheit = celsius * 2 + 32; - - System.out.println("Celsius: " + celsius); - System.out.println("Fahrneheit: " + fahrneheit); - - Thread.sleep(1000); - } - temp.delete(); - //! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/Th02_Example.java upm-1.7.1/examples/java/Th02_Example.java --- upm-1.6.0/examples/java/Th02_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Th02_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* +* Author: Abhishek Malik +* Copyright (c) 2016 Intel Corporation. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +import upm_th02.TH02; + +public class Th02_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + float temperature = 0; + float humidity = 0; + + TH02 sensor = new TH02(); + while(true){ + temperature = sensor.getTemperature(); + humidity = sensor.getHumidity(); + System.out.println("Temperature = "+temperature+", Humidity = "+humidity); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception has occurred: "+e.getMessage()); + } + } + } + +} diff -Nru upm-1.6.0/examples/java/Th02Example.java upm-1.7.1/examples/java/Th02Example.java --- upm-1.6.0/examples/java/Th02Example.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Th02Example.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* -* Author: Abhishek Malik -* Copyright (c) 2016 Intel Corporation. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -import upm_th02.TH02; - -public class Th02Example { - - public static void main(String[] args) { - // TODO Auto-generated method stub - float temperature = 0; - float humidity = 0; - - TH02 sensor = new TH02(); - while(true){ - temperature = sensor.getTemperature(); - humidity = sensor.getHumidity(); - System.out.println("Temperature = "+temperature+", Humidity = "+humidity); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception has occurred: "+e.getMessage()); - } - } - } - -} diff -Nru upm-1.6.0/examples/java/TM1637_Example.java upm-1.7.1/examples/java/TM1637_Example.java --- upm-1.6.0/examples/java/TM1637_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/TM1637_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,58 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import java.time.LocalDateTime; + +//NOT TESTED!!! +public class TM1637_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // TM1637 on pins 0 (clk) and 1 (dio) + upm_tm1637.TM1637 myDisplay = new upm_tm1637.TM1637(0, 1); + + // Start a box using 7-segment encoding + myDisplay.write(0x39, 0x09, 0x09); + + // Finish box using writeAt function + myDisplay.writeAt(3, ']'); + + // Wait 3 seconds + Thread.sleep(3000); + + LocalDateTime now; + while (true) { + now = LocalDateTime.now(); + int hour = now.getHour(); + int min = now.getMinute(); + int sec = now.getSecond(); + + System.out.println(hour + ":" + min + ":" + sec); + myDisplay.writeString(hour + ":" + min); + + Thread.sleep(1000); + } + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/TM1637Sample.java upm-1.7.1/examples/java/TM1637Sample.java --- upm-1.6.0/examples/java/TM1637Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/TM1637Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import java.time.LocalDateTime; - -//NOT TESTED!!! -public class TM1637Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // TM1637 on pins 0 (clk) and 1 (dio) - upm_tm1637.TM1637 myDisplay = new upm_tm1637.TM1637(0, 1); - - // Start a box using 7-segment encoding - myDisplay.write(0x39, 0x09, 0x09); - - // Finish box using writeAt function - myDisplay.writeAt(3, ']'); - - // Wait 3 seconds - Thread.sleep(3000); - - LocalDateTime now; - while (true) { - now = LocalDateTime.now(); - int hour = now.getHour(); - int min = now.getMinute(); - int sec = now.getSecond(); - - System.out.println(hour + ":" + min + ":" + sec); - myDisplay.writeString(hour + ":" + min); - - Thread.sleep(1000); - } - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/TP401_Example.java upm-1.7.1/examples/java/TP401_Example.java --- upm-1.6.0/examples/java/TP401_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/TP401_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class TP401_Example { + private static String airQuality(int value) { + if (value < 50) + return "Fresh Air"; + if (value < 200) + return "Normal Indoor Air"; + if (value < 400) + return "Low Pollution"; + if (value < 600) + return "High Pollution - Action Recommended"; + return "Very High Pollution - Take Action Immediately"; + } + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate new grove air quality sensor on analog pin A0 + upm_gas.TP401 airSensor = new upm_gas.TP401(0); + + System.out.println(airSensor.name()); + + System.out.println("Heating sensor for 3 minutes..."); + // wait 3 minutes for sensor to warm up + for (int i = 0; i < 3; i++) { + if (i != 0) + System.out.println("Please wait, " + i + " minute(s) passed.."); + Thread.sleep(60000); + } + System.out.println("Sensor ready!"); + + while (true) { + int value = airSensor.getSample(); // Read raw value + float ppm = airSensor.getPPM(); // Read CO ppm (can vary slightly + // from previous read) + + System.out.println("raw: " + value + " ppm: " + ppm + " " + airQuality(value)); + + Thread.sleep(100); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/TP401Sample.java upm-1.7.1/examples/java/TP401Sample.java --- upm-1.6.0/examples/java/TP401Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/TP401Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class TP401Sample { - private static String airQuality(int value) { - if (value < 50) - return "Fresh Air"; - if (value < 200) - return "Normal Indoor Air"; - if (value < 400) - return "Low Pollution"; - if (value < 600) - return "High Pollution - Action Recommended"; - return "Very High Pollution - Take Action Immediately"; - } - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate new grove air quality sensor on analog pin A0 - upm_gas.TP401 airSensor = new upm_gas.TP401(0); - - System.out.println(airSensor.name()); - - System.out.println("Heating sensor for 3 minutes..."); - // wait 3 minutes for sensor to warm up - for (int i = 0; i < 3; i++) { - if (i != 0) - System.out.println("Please wait, " + i + " minute(s) passed.."); - Thread.sleep(60000); - } - System.out.println("Sensor ready!"); - - while (true) { - int value = airSensor.getSample(); // Read raw value - float ppm = airSensor.getPPM(); // Read CO ppm (can vary slightly - // from previous read) - - System.out.println("raw: " + value + " ppm: " + ppm + " " + airQuality(value)); - - Thread.sleep(100); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/TSL2561_Example.java upm-1.7.1/examples/java/TSL2561_Example.java --- upm-1.6.0/examples/java/TSL2561_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/TSL2561_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class TSL2561_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a TSL2561 Digital Light Sensor on I2C + upm_tsl2561.TSL2561 sensor = new upm_tsl2561.TSL2561(); + + while (true) { + System.out.println("Lux = " + sensor.getLux()); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/Tsl2561.java upm-1.7.1/examples/java/Tsl2561.java --- upm-1.6.0/examples/java/Tsl2561.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/Tsl2561.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -import upm_tsl2561.TSL2561; - -public class Tsl2561 { - - static { - try { - System.loadLibrary("javaupm_tsl2561"); - System.loadLibrary("mraajava"); - } catch (UnsatisfiedLinkError e) { - System.err.println( - "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + - e); - System.exit(1); - } - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - TSL2561 sensor = null; - int loopCount = 100; - // Instantiate the sensor object - sensor = new TSL2561(); - - for (int i=0; i - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class TSL2561Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a TSL2561 Digital Light Sensor on I2C - upm_tsl2561.TSL2561 sensor = new upm_tsl2561.TSL2561(); - - while (true) { - System.out.println("Lux = " + sensor.getLux()); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/TTP223_Example.java upm-1.7.1/examples/java/TTP223_Example.java --- upm-1.6.0/examples/java/TTP223_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/TTP223_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class TTP223_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_ttp223.TTP223 touch = new upm_ttp223.TTP223(7); + + while (true) { + if (touch.isPressed()) + System.out.println(touch.name() + " is pressed"); + else + System.out.println(touch.name() + " is not pressed"); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/TTP223Sample.java upm-1.7.1/examples/java/TTP223Sample.java --- upm-1.6.0/examples/java/TTP223Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/TTP223Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class TTP223Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_ttp223.TTP223 touch = new upm_ttp223.TTP223(7); - - while (true) { - if (touch.isPressed()) - System.out.println(touch.name() + " is pressed"); - else - System.out.println(touch.name() + " is not pressed"); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/ULN200XA_Example.java upm-1.7.1/examples/java/ULN200XA_Example.java --- upm-1.6.0/examples/java/ULN200XA_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/ULN200XA_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class ULN200XA_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Stepper motor on a ULN200XA Dual H-Bridge. + // Wire the pins so that I1 is pin D8, I2 is pin D9, I3 is pin D10 and + // I4 is pin D11 + upm_uln200xa.ULN200XA uln200xa = new upm_uln200xa.ULN200XA(4096, 8, 9, 10, 11); + + uln200xa.setSpeed(5); + System.out.println("Rotating 1 revolution clockwise."); + uln200xa.setDirection(upm_uln200xa.ULN200XA_DIRECTION_T.ULN200XA_DIR_CW); + uln200xa.stepperSteps(4096); + + System.out.println("Sleeping for 2 seconds..."); + Thread.sleep(2000); + + System.out.println("Rotating 1/2 revolution counter clockwise."); + uln200xa.setDirection(upm_uln200xa.ULN200XA_DIRECTION_T.ULN200XA_DIR_CCW); + uln200xa.stepperSteps(2048); + + // turn off the power + uln200xa.release(); + // ! [Interesting] + + System.out.println("Exiting..."); + } + +} diff -Nru upm-1.6.0/examples/java/ULN200XASample.java upm-1.7.1/examples/java/ULN200XASample.java --- upm-1.6.0/examples/java/ULN200XASample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/ULN200XASample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class ULN200XASample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Stepper motor on a ULN200XA Dual H-Bridge. - // Wire the pins so that I1 is pin D8, I2 is pin D9, I3 is pin D10 and - // I4 is pin D11 - upm_uln200xa.ULN200XA uln200xa = new upm_uln200xa.ULN200XA(4096, 8, 9, 10, 11); - - uln200xa.setSpeed(5); - System.out.println("Rotating 1 revolution clockwise."); - uln200xa.setDirection(upm_uln200xa.ULN200XA_DIRECTION_T.ULN200XA_DIR_CW); - uln200xa.stepperSteps(4096); - - System.out.println("Sleeping for 2 seconds..."); - Thread.sleep(2000); - - System.out.println("Rotating 1/2 revolution counter clockwise."); - uln200xa.setDirection(upm_uln200xa.ULN200XA_DIRECTION_T.ULN200XA_DIR_CCW); - uln200xa.stepperSteps(2048); - - // turn off the power - uln200xa.release(); - // ! [Interesting] - - System.out.println("Exiting..."); - } - -} diff -Nru upm-1.6.0/examples/java/VDiv_Example.java upm-1.7.1/examples/java/VDiv_Example.java --- upm-1.6.0/examples/java/VDiv_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/VDiv_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class VDiv_Example { + private static final short gain3 = 3; + private static final short gain10 = 10; + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Grove Voltage Divider sensor on analog pin A0 + upm_vdiv.VDiv vDiv = new upm_vdiv.VDiv(0); + + // collect data and output measured voltage according to the setting + // of the scaling switch (3 or 10) + while (true) { + long val = vDiv.value(100); + float gain3val = vDiv.computedValue(gain3, val); + float gain10val = vDiv.computedValue(gain10, val); + + System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: " + + gain10val); + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/VDivSample.java upm-1.7.1/examples/java/VDivSample.java --- upm-1.6.0/examples/java/VDivSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/VDivSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class VDivSample { - private static final short gain3 = 3; - private static final short gain10 = 10; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Grove Voltage Divider sensor on analog pin A0 - upm_vdiv.VDiv vDiv = new upm_vdiv.VDiv(0); - - // collect data and output measured voltage according to the setting - // of the scaling switch (3 or 10) - while (true) { - long val = vDiv.value(100); - float gain3val = vDiv.computedValue(gain3, val); - float gain10val = vDiv.computedValue(gain10, val); - - System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: " - + gain10val); - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/VEML6070_Example.java upm-1.7.1/examples/java/VEML6070_Example.java --- upm-1.6.0/examples/java/VEML6070_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/VEML6070_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * Author: Abhishek Malik + * 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. + */ + +import upm_veml6070.VEML6070; + +public class VEML6070_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + //! [Interesting] + // Instantiate a VEML6070 UV sensor + VEML6070 veml = new VEML6070(0); + + while(true){ + System.out.println("UV Value: "+veml.getUVIntensity()); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/VEML6070Sample.java upm-1.7.1/examples/java/VEML6070Sample.java --- upm-1.6.0/examples/java/VEML6070Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/VEML6070Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - * Author: Abhishek Malik - * 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. - */ - -import upm_veml6070.VEML6070; - -public class VEML6070Sample { - - public static void main(String[] args) { - // TODO Auto-generated method stub - - //! [Interesting] - // Instantiate a VEML6070 UV sensor - VEML6070 veml = new VEML6070(0); - - while(true){ - System.out.println("UV Value: "+veml.getUVIntensity()); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/Water_Example.java upm-1.7.1/examples/java/Water_Example.java --- upm-1.6.0/examples/java/Water_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/Water_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class Water_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a Water sensor on digital pin D2 + upm_water.Water water = new upm_water.Water(2); + + while (true) { + boolean val = water.isWet(); + if (val) { + System.out.println("Sensor is wet"); + } else { + System.out.println("Sensor is dry"); + } + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/WaterLevelSensor_Example.java upm-1.7.1/examples/java/WaterLevelSensor_Example.java --- upm-1.6.0/examples/java/WaterLevelSensor_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/WaterLevelSensor_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import upm_waterlevel.WaterLevel; + +public class WaterLevelSensor_Example { + + public static void main(String[] args) { + // TODO Auto-generated method stub + //! [Interesting] + // Instantiating the sensor on Digital Pin 2 + WaterLevel level = new WaterLevel(2); + + while(true){ + if(level.isSubmerged()){ + System.out.println("The sensor is submerged"); + } + else{ + System.out.println("The sensor is above water level"); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + System.out.println("The following exception occurred: "+e.getMessage()); + } + } + //! [Interesting] + } + +} diff -Nru upm-1.6.0/examples/java/WaterLevelSensor.java upm-1.7.1/examples/java/WaterLevelSensor.java --- upm-1.6.0/examples/java/WaterLevelSensor.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/WaterLevelSensor.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* - * Author: Abhishek Malik - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import upm_waterlevel.WaterLevel; - -public class WaterLevelSensor { - - public static void main(String[] args) { - // TODO Auto-generated method stub - //! [Interesting] - // Instantiating the sensor on Digital Pin 2 - WaterLevel level = new WaterLevel(2); - - while(true){ - if(level.isSubmerged()){ - System.out.println("The sensor is submerged"); - } - else{ - System.out.println("The sensor is above water level"); - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - System.out.println("The following exception occurred: "+e.getMessage()); - } - } - //! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/WaterSample.java upm-1.7.1/examples/java/WaterSample.java --- upm-1.6.0/examples/java/WaterSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/WaterSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class WaterSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Water sensor on digital pin D2 - upm_water.Water water = new upm_water.Water(2); - - while (true) { - boolean val = water.isWet(); - if (val) { - System.out.println("Sensor is wet"); - } else { - System.out.println("Sensor is dry"); - } - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} diff -Nru upm-1.6.0/examples/java/WFS_Example.java upm-1.7.1/examples/java/WFS_Example.java --- upm-1.6.0/examples/java/WFS_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/WFS_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class WFS_Example { + + public static void main(String[] args) throws InterruptedException { +// ! [Interesting] + + // Instantiate a Water Flow Sensor on + // digital pin D2. This must be an + // interrupt capable pin. + upm_wfs.WFS flow = new upm_wfs.WFS(2); + + flow.clearFlowCounter(); + flow.startFlowCounter(); + + while (true) { + System.out.print("Millis: " + flow.getMillis() + " FlowCount: " + flow.flowCounter()); + System.out.println(" Flow Rate: " + flow.flowRate() + " LPM"); + + Thread.sleep(2000); + } +// ! [Interesting] + } +} diff -Nru upm-1.6.0/examples/java/WFSSample.java upm-1.7.1/examples/java/WFSSample.java --- upm-1.6.0/examples/java/WFSSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/WFSSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class WFSSample { - - public static void main(String[] args) throws InterruptedException { -// ! [Interesting] - - // Instantiate a Water Flow Sensor on - // digital pin D2. This must be an - // interrupt capable pin. - upm_wfs.WFS flow = new upm_wfs.WFS(2); - - flow.clearFlowCounter(); - flow.startFlowCounter(); - - while (true) { - System.out.print("Millis: " + flow.getMillis() + " FlowCount: " + flow.flowCounter()); - System.out.println(" Flow Rate: " + flow.flowRate() + " LPM"); - - Thread.sleep(2000); - } -// ! [Interesting] - } -} diff -Nru upm-1.6.0/examples/java/WheelEncoder_Example.java upm-1.7.1/examples/java/WheelEncoder_Example.java --- upm-1.6.0/examples/java/WheelEncoder_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/WheelEncoder_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * 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. + */ + +public class WheelEncoder_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a DFRobot Wheel Encoder on digital pin D2 + upm_wheelencoder.WheelEncoder sensor = new upm_wheelencoder.WheelEncoder(2); + + // set the counter to 0 and start counting + sensor.clearCounter(); + sensor.startCounter(); + + while (true) { + // output milliseconds passed and current sensor count + System.out.println("Millis: " + sensor.getMillis() + "; Count: " + sensor.counter()); + Thread.sleep(1000); + } + + // ! [Interesting] + } +} + diff -Nru upm-1.6.0/examples/java/WheelEncoderSample.java upm-1.7.1/examples/java/WheelEncoderSample.java --- upm-1.6.0/examples/java/WheelEncoderSample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/WheelEncoderSample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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. - */ - -public class WheelEncoderSample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a DFRobot Wheel Encoder on digital pin D2 - upm_wheelencoder.WheelEncoder sensor = new upm_wheelencoder.WheelEncoder(2); - - // set the counter to 0 and start counting - sensor.clearCounter(); - sensor.startCounter(); - - while (true) { - // output milliseconds passed and current sensor count - System.out.println("Millis: " + sensor.getMillis() + "; Count: " + sensor.counter()); - Thread.sleep(1000); - } - - // ! [Interesting] - } -} - diff -Nru upm-1.6.0/examples/java/WT5001_Example.java upm-1.7.1/examples/java/WT5001_Example.java --- upm-1.6.0/examples/java/WT5001_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/WT5001_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,130 @@ +import java.io.IOException; + +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class WT5001_Example { + + static private void printUsage() { + System.out.println("Usage: java WT5001_Example "); + System.out.println("Commands:"); + System.out.println("0 - stop playing"); + System.out.println("1 - start playing track 1"); + System.out.println("2 - pause/un-pause playback"); + System.out.println("3 - next track"); + System.out.println("4 - previous track"); + } + + public static void main(String[] args) { + // ! [Interesting] + // Instantiate a WT5001 serial MP3 player on uart 0 + upm_wt5001.WT5001 mp3 = new upm_wt5001.WT5001(0); + + int cmd = -1; + if (args.length > 0) + cmd = Integer.parseInt(args[0]); + + // make sure port is initialized properly. 9600 baud is the default + if (!mp3.setupTty()) { + System.err.println("error in loading native library"); + System.exit(-1); + } + + switch (cmd) { + case 0 : + mp3.stop(); + break; + + case 1 : + mp3.play(upm_wt5001.WT5001.WT5001_PLAYSOURCE_T.SD, 1); + break; + + case 2 : + mp3.pause(); + break; + + case 3 : + mp3.next(); + break; + + case 4 : + mp3.previous(); + break; + + default : + // nothing, just output usage, and info below + printUsage(); + break; + } + + // print out some information + try { + short vol; + vol = mp3.getVolume(); + System.out.println("The current volume is: " + vol); + } catch (IOException e) { + System.out.println(e.toString()); + } + + try { + short ps; + ps = mp3.getPlayState(); + System.out.println("The current play state is: " + ps); + } catch (IOException e) { + System.out.println(e.toString()); + } + + try { + int numf; + numf = mp3.getNumFiles(upm_wt5001.WT5001.WT5001_PLAYSOURCE_T.SD); + System.out.println("The number of files on the SD card is: " + numf); + } catch (IOException e) { + System.out.println(e.toString()); + } + + try { + int curf; + curf = mp3.getCurrentFile(); + System.out.println("The current file is: " + curf); + } catch (IOException e) { + System.out.println(e.toString()); + } + + int year[] = new int[1]; + short month[] = new short[1]; + short day[] = new short[1]; + if (mp3.getDate(year, month, day)) + System.out.println("The device date is: " + year[0] + "/" + month[0] + "/" + day[0]); + + short hour[] = new short[1]; + short minute[] = new short[1]; + short second[] = new short[1]; + if (mp3.getTime(hour, minute, second)) + System.out + .println("The device time is: " + hour[0] + ":" + minute[0] + ":" + second[0]); + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/WT5001Sample.java upm-1.7.1/examples/java/WT5001Sample.java --- upm-1.6.0/examples/java/WT5001Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/WT5001Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ -import java.io.IOException; - -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class WT5001Sample { - - static private void printUsage() { - System.out.println("Usage: java WT5001Sample "); - System.out.println("Commands:"); - System.out.println("0 - stop playing"); - System.out.println("1 - start playing track 1"); - System.out.println("2 - pause/un-pause playback"); - System.out.println("3 - next track"); - System.out.println("4 - previous track"); - } - - public static void main(String[] args) { - // ! [Interesting] - // Instantiate a WT5001 serial MP3 player on uart 0 - upm_wt5001.WT5001 mp3 = new upm_wt5001.WT5001(0); - - int cmd = -1; - if (args.length > 0) - cmd = Integer.parseInt(args[0]); - - // make sure port is initialized properly. 9600 baud is the default - if (!mp3.setupTty()) { - System.err.println("error in loading native library"); - System.exit(-1); - } - - switch (cmd) { - case 0 : - mp3.stop(); - break; - - case 1 : - mp3.play(upm_wt5001.WT5001.WT5001_PLAYSOURCE_T.SD, 1); - break; - - case 2 : - mp3.pause(); - break; - - case 3 : - mp3.next(); - break; - - case 4 : - mp3.previous(); - break; - - default : - // nothing, just output usage, and info below - printUsage(); - break; - } - - // print out some information - try { - short vol; - vol = mp3.getVolume(); - System.out.println("The current volume is: " + vol); - } catch (IOException e) { - e.printStackTrace(); - } - - try { - short ps; - ps = mp3.getPlayState(); - System.out.println("The current play state is: " + ps); - } catch (IOException e) { - e.printStackTrace(); - } - - try { - int numf; - numf = mp3.getNumFiles(upm_wt5001.WT5001.WT5001_PLAYSOURCE_T.SD); - System.out.println("The number of files on the SD card is: " + numf); - } catch (IOException e) { - e.printStackTrace(); - } - - try { - int curf; - curf = mp3.getCurrentFile(); - System.out.println("The current file is: " + curf); - } catch (IOException e) { - e.printStackTrace(); - } - - int year[] = new int[1]; - short month[] = new short[1]; - short day[] = new short[1]; - if (mp3.getDate(year, month, day)) - System.out.println("The device date is: " + year[0] + "/" + month[0] + "/" + day[0]); - - short hour[] = new short[1]; - short minute[] = new short[1]; - short second[] = new short[1]; - if (mp3.getTime(hour, minute, second)) - System.out - .println("The device time is: " + hour[0] + ":" + minute[0] + ":" + second[0]); - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/YG1006_Example.java upm-1.7.1/examples/java/YG1006_Example.java --- upm-1.6.0/examples/java/YG1006_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/YG1006_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +public class YG1006_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a yg1006 flame sensor on digital pin D2 + upm_yg1006.YG1006 flame = new upm_yg1006.YG1006(2); + + while (true) { + boolean val = flame.flameDetected(); + if (val) { + System.out.println("Flame detected"); + } else { + System.out.println("No flame detected"); + } + + Thread.sleep(1000); + } + // ! [Interesting] + } + +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/YG1006Sample.java upm-1.7.1/examples/java/YG1006Sample.java --- upm-1.6.0/examples/java/YG1006Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/YG1006Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class YG1006Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a yg1006 flame sensor on digital pin D2 - upm_yg1006.YG1006 flame = new upm_yg1006.YG1006(2); - - while (true) { - boolean val = flame.flameDetected(); - if (val) { - System.out.println("Flame detected"); - } else { - System.out.println("No flame detected"); - } - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/ZFM20_Example.java upm-1.7.1/examples/java/ZFM20_Example.java --- upm-1.6.0/examples/java/ZFM20_Example.java 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/java/ZFM20_Example.java 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,88 @@ +/* + * Author: Stefan Andritoiu + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//NOT TESTED!!! +public class ZFM20_Example { + + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // Instantiate a ZFM20 Fingerprint reader on UART 0 + upm_zfm20.ZFM20 fp = new upm_zfm20.ZFM20(0); + + // make sure port is initialized properly. 57600 baud is the default + if (!fp.setupTty()) { + System.err.println("Failed to setup tty port parameters"); + System.exit(-1); + } + + // first, set the default password and address + fp.setPassword(upm_zfm20.javaupm_zfm20.ZFM20_DEFAULT_PASSWORD); + fp.setAddress(upm_zfm20.javaupm_zfm20.ZFM20_DEFAULT_ADDRESS); + + // now verify the password. If this fails, any other commands + // will be ignored, so we just bail. + if (fp.verifyPassword()) { + System.out.println("Password verified."); + } else { + System.err.println("Password verification failed."); + System.exit(-1); + } + + // how many valid stored templates (fingerprints) do we have? + System.out.println("Total stored templates: " + fp.getNumTemplates()); + + // now spin waiting for a fingerprint to successfully image + System.out.println("Waiting for finger print..."); + while (fp.generateImage() == upm_zfm20.ZFM20.ZFM20_ERRORS_T.ERR_NO_FINGER.swigValue()); + + // in theory, we have an image + System.out.println("Image captured, converting..."); + short rv = fp.image2Tz(1); + if (rv != upm_zfm20.ZFM20.ZFM20_ERRORS_T.ERR_OK.swigValue()) { + System.err.println("Image conversion failed with error code " + rv); + System.exit(-1); + } + System.out.println("Image conversion succeeded"); + + // we search for a print matching slot 1, where we shored our last + // converted fingerprint + int[] id = new int[1]; + int[] score = new int[1]; + rv = fp.search(1, id, score); + if (rv != upm_zfm20.ZFM20.ZFM20_ERRORS_T.ERR_OK.swigValue()) { + if (rv == upm_zfm20.ZFM20.ZFM20_ERRORS_T.ERR_FP_NOTFOUND.swigValue()) { + System.out.println("Fingerprint not found"); + System.exit(0); + } else { + System.err.println("Search failed with error code " + rv); + System.exit(-1); + } + } + + System.out.println("Fingerprint found!"); + System.out.println("ID: " + id[0] + ", Score: " + score[0]); + + // ! [Interesting] + } +} \ No newline at end of file diff -Nru upm-1.6.0/examples/java/ZFM20Sample.java upm-1.7.1/examples/java/ZFM20Sample.java --- upm-1.6.0/examples/java/ZFM20Sample.java 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/java/ZFM20Sample.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//NOT TESTED!!! -public class ZFM20Sample { - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a ZFM20 Fingerprint reader on UART 0 - upm_zfm20.ZFM20 fp = new upm_zfm20.ZFM20(0); - - // make sure port is initialized properly. 57600 baud is the default - if (!fp.setupTty()) { - System.err.println("Failed to setup tty port parameters"); - System.exit(-1); - } - - // first, set the default password and address - fp.setPassword(upm_zfm20.javaupm_zfm20.ZFM20_DEFAULT_PASSWORD); - fp.setAddress(upm_zfm20.javaupm_zfm20.ZFM20_DEFAULT_ADDRESS); - - // now verify the password. If this fails, any other commands - // will be ignored, so we just bail. - if (fp.verifyPassword()) { - System.out.println("Password verified."); - } else { - System.err.println("Password verification failed."); - System.exit(-1); - } - - // how many valid stored templates (fingerprints) do we have? - System.out.println("Total stored templates: " + fp.getNumTemplates()); - - // now spin waiting for a fingerprint to successfully image - System.out.println("Waiting for finger print..."); - while (fp.generateImage() == upm_zfm20.ZFM20.ZFM20_ERRORS_T.ERR_NO_FINGER.swigValue()); - - // in theory, we have an image - System.out.println("Image captured, converting..."); - short rv = fp.image2Tz(1); - if (rv != upm_zfm20.ZFM20.ZFM20_ERRORS_T.ERR_OK.swigValue()) { - System.err.println("Image conversion failed with error code " + rv); - System.exit(-1); - } - System.out.println("Image conversion succeeded"); - - // we search for a print matching slot 1, where we shored our last - // converted fingerprint - int[] id = new int[1]; - int[] score = new int[1]; - rv = fp.search(1, id, score); - if (rv != upm_zfm20.ZFM20.ZFM20_ERRORS_T.ERR_OK.swigValue()) { - if (rv == upm_zfm20.ZFM20.ZFM20_ERRORS_T.ERR_FP_NOTFOUND.swigValue()) { - System.out.println("Fingerprint not found"); - System.exit(0); - } else { - System.err.println("Search failed with error code " + rv); - System.exit(-1); - } - } - - System.out.println("Fingerprint found!"); - System.out.println("ID: " + id[0] + ", Score: " + score[0]); - - // ! [Interesting] - } -} \ No newline at end of file diff -Nru upm-1.6.0/examples/javascript/bh1749.js upm-1.7.1/examples/javascript/bh1749.js --- upm-1.6.0/examples/javascript/bh1749.js 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/javascript/bh1749.js 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,57 @@ +/* +* 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. +*/ + +var bh1749 = require("jsupm_bh1749"); + +var bh1749_sensor = new bh1749.BH1749(); + +bh1749_sensor.SensorInit( + bh1749.INT_JUDGE_1, + bh1749.MEAS_240MS, + bh1749.RGB_GAIN_1X, + bh1749.IR_GAIN_1X, + bh1749.RED); +bh1749_sensor.SetThresholdHigh(511); +bh1749_sensor.Enable(); + +var waitTime = bh1749_sensor.GetMeasurementTime(); +var counter = 10; +console.log("Color readings: "); +var interval = setInterval(function() { + data = bh1749_sensor.GetMeasurements(); + console.log( + "R: " + data.get(0) + ", G: " + data.get(1) + ", B: " + data.get(2) + + ", IR: " + data.get(3) + ", G2: " + data.get(4) + ); + counter--; + if (counter == 0) { + clearInterval(interval); + } +}, waitTime); + +process.on("SIGINT", function() { + clearInterval(interval); + console.log("Exiting..."); + process.exit(0); +}); diff -Nru upm-1.6.0/examples/javascript/bh1792.js upm-1.7.1/examples/javascript/bh1792.js --- upm-1.6.0/examples/javascript/bh1792.js 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/javascript/bh1792.js 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,50 @@ +/* +* 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. +*/ + +var bh1792 = require("/usr/include/nodejs/lib/node_modules/jsupm_bh1792"); + +var bh1792_sensor = new bh1792.BH1792(); + +bh1792_sensor.SoftReset(); +bh1792_sensor.EnableSyncMode(256, 32); +bh1792_sensor.StartMeasurement(); + +var waitTime = bh1792_sensor.GetMeasurementTimeMS(); +var counter = 10; +console.log("Heart beat sensor readings: "); +var interval = setInterval(function() { + data = bh1792_sensor.GetGreenData(); + console.log("off: " + data.get(0) + ", on: " + data.get(1) + + ", timestamp: " + Date.now() + " msec"); + counter--; + if (counter == 0) { + clearInterval(interval); + } +}, waitTime); + +process.on("SIGINT", function() { + clearInterval(interval); + console.log("Exiting..."); + process.exit(0); +}); diff -Nru upm-1.6.0/examples/javascript/kx122.js upm-1.7.1/examples/javascript/kx122.js --- upm-1.6.0/examples/javascript/kx122.js 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/javascript/kx122.js 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,52 @@ +/* +* Author: Noel Eck +* 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. +*/ + +var kx122 = require("jsupm_kx122"); + +// Instantiate a KX122 +var kx122_sensor = new kx122.KX122(0, -1, 24); + +// Reset the device +kx122_sensor.softwareReset(); + +// Reset the device +kx122_sensor.deviceInit(kx122.KX122_ODR_50, + kx122.HIGH_RES, + kx122.KX122_RANGE_2G); + +var myInterval = setInterval(function() +{ + data = kx122_sensor.getAccelerationDataVector(); + console.log("Acceleration x: " + data.get(0) + + " y: " + data.get(1) + + " z: " + data.get(2)); +}, 1000); + +// When exiting: clear interval and print message +process.on('SIGINT', function() +{ + clearInterval(myInterval); + console.log("Exiting..."); + process.exit(0); +}); diff -Nru upm-1.6.0/examples/javascript/kxtj3.js upm-1.7.1/examples/javascript/kxtj3.js --- upm-1.6.0/examples/javascript/kxtj3.js 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/javascript/kxtj3.js 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,54 @@ +/* +* 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. +*/ + +var kxtj3 = require("jsupm_kxtj3"); + +var kxtj3_sensor = new kxtj3.KXTJ3(0x0, 0x0f); + +kxtj3_sensor.SensorInit( + kxtj3.KXTJ3_ODR_25, + kxtj3.HIGH_RES, + kxtj3.KXTJ3_RANGE_16G_14); + +var waitTime = kxtj3_sensor.GetAccelerationSamplePeriod(); +var counter = 10; +console.log("Setting settings:\nODR: 25 Hz\nResolution: \ + High\nAcceleration range: 16g with 14bits"); +console.log("Acceleration: "); +var interval = setInterval(function() { + data = kxtj3_sensor.GetAccelerationVector(); + console.log( + "x: " + data.get(0) + " y: " + data.get(1) + " z: " + data.get(2) + ); + counter--; + if (counter == 0) { + clearInterval(interval); + } +}, waitTime * 1000); + +process.on("SIGINT", function() { + clearInterval(interval); + console.log("Exiting..."); + process.exit(0); +}); diff -Nru upm-1.6.0/examples/python/bh1749.py upm-1.7.1/examples/python/bh1749.py --- upm-1.6.0/examples/python/bh1749.py 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/python/bh1749.py 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,60 @@ +# 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. + +import time, sys, signal, atexit +from upm import pyupm_bh1749 + + +def main(): + bh1749_sensor = pyupm_bh1749.BH1749() + + bh1749_sensor.SensorInit(pyupm_bh1749.INT_JUDGE_1, + pyupm_bh1749.MEAS_240MS, + pyupm_bh1749.RGB_GAIN_1X, + pyupm_bh1749.IR_GAIN_1X, + pyupm_bh1749.RED) + bh1749_sensor.SetThresholdHigh(511) + + # Prevent stack printing on CTRL^C + def SIGINTHandler(signum, frame): + raise SystemExit + + def exitHandler(): + print("Exiting") + sys.exit(0) + + atexit.register(exitHandler) + signal.signal(signal.SIGINT, SIGINTHandler) + + sampleCounter = 10 + waitTime = bh1749_sensor.GetMeasurementTime() + print("Color readings: ") + while sampleCounter > 0: + [r, g, b, ir, g2] = bh1749_sensor.GetMeasurements() + print ("R: %d, y: %d, G: %d, IR: %d, G2: %d" % (r, g, b, ir, g2)) + + time.sleep(waitTime / 1000.0) + sampleCounter -= 1 + + +if __name__ == '__main__': + main() diff -Nru upm-1.6.0/examples/python/bh1792.py upm-1.7.1/examples/python/bh1792.py --- upm-1.6.0/examples/python/bh1792.py 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/python/bh1792.py 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,58 @@ +# 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. + +import time, datetime +import sys +import signal +import atexit +from upm import pyupm_bh1792 + +def main(): + bh1792_sensor = pyupm_bh1792.BH1792() + bh1792_sensor.SoftReset() + bh1792_sensor.EnableSyncMode(256, 32) + bh1792_sensor.StartMeasurement() + + # Prevent stack printing on CTRL^C + def SIGINTHandler(signum, frame): + raise SystemExit + + def exitHandler(): + print("Exiting") + sys.exit(0) + + atexit.register(exitHandler) + signal.signal(signal.SIGINT, SIGINTHandler) + + sampleCounter = 10 + waitTime = bh1792_sensor.GetMeasurementTimeMS() + + print("Heart beat sensor readings: ") + while sampleCounter > 0: + [off, on] = bh1792_sensor.GetGreenData() + print ("off: %d, on: %d, timestamp: %d msec" % (off, on, time.time() * 1000)) + time.sleep(waitTime / 1000.0) + sampleCounter -= 1 + + +if __name__ == '__main__': + main() diff -Nru upm-1.6.0/examples/python/kx122.py upm-1.7.1/examples/python/kx122.py --- upm-1.6.0/examples/python/kx122.py 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/python/kx122.py 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# Author: Noel Eck +# 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. + +from __future__ import print_function +import time, sys, signal, atexit +from upm import pyupm_kx122 + + +def main(): + # Instantiate a KX122 + kx122_sensor = pyupm_kx122.KX122(0, -1, 24) + + # Reset the device + kx122_sensor.softwareReset() + + # Initialize the device + kx122_sensor.deviceInit(pyupm_kx122.KX122_ODR_50, + pyupm_kx122.HIGH_RES, + pyupm_kx122.KX122_RANGE_2G) + + # This function stops python from printing a stacktrace when you hit ctrl-C + def SIGINTHandler(signum, frame): + raise SystemExit + + # Exit handler + def exitHandler(): + print("Exiting") + sys.exit(0) + + # Register exit handlers + atexit.register(exitHandler) + signal.signal(signal.SIGINT, SIGINTHandler) + + # Print the acceleration + while True: + [x, y, z] = kx122_sensor.getAccelerationData() + + print ("x: %0.02f, y: %0.02f, z: %0.02f" % (x, y, z)) + + time.sleep(1) + + +if __name__ == '__main__': + main() diff -Nru upm-1.6.0/examples/python/kxtj3.py upm-1.7.1/examples/python/kxtj3.py --- upm-1.6.0/examples/python/kxtj3.py 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/examples/python/kxtj3.py 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,61 @@ +#!/usr/bin/env python + +# 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 + +import time, sys, signal, atexit +from upm import pyupm_kxtj3 + + +def main(): + kxtj3_sensor = pyupm_kxtj3.KXTJ3(0x0, 0x0f) + + kxtj3_sensor.SensorInit(pyupm_kxtj3.KXTJ3_ODR_25, + pyupm_kxtj3.HIGH_RES, + pyupm_kxtj3.KXTJ3_RANGE_16G_14) + + # Prevent stack printing on CTRL^C + def SIGINTHandler(signum, frame): + raise SystemExit + + def exitHandler(): + print("Exiting") + sys.exit(0) + + atexit.register(exitHandler) + signal.signal(signal.SIGINT, SIGINTHandler) + + sampleCounter = 10 + waitTime = kxtj3_sensor.GetAccelerationSamplePeriod() + print("Setting settings:\nODR: 25 Hz\nResolution: " + "High\nAcceleration range: 16g with 14bits") + print("Acceleration:") + while sampleCounter > 0: + [x, y, z] = kxtj3_sensor.GetAccelerationVector() + + print ("x: %0.02f, y: %0.02f, z: %0.02f" % (x, y, z)) + + time.sleep(waitTime) + sampleCounter -= 1 + + +if __name__ == '__main__': + main() diff -Nru upm-1.6.0/examples/python/rsc.py upm-1.7.1/examples/python/rsc.py --- upm-1.6.0/examples/python/rsc.py 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/examples/python/rsc.py 2018-10-12 04:47:41.000000000 +0000 @@ -25,6 +25,11 @@ import time, sys, signal, atexit from upm import pyupm_rsc as rsc +# Since CI loads each python example, the following would fail if the types +# from rsc_regs.h are NOT exposed in the pyupm_rsc module +mode = rsc.NORMAL_MODE +dr = rsc.N_DR_20_SPS + def main(): # Instantiate a Honeywell RSC Pressure sensor on the SPI bus 0 rsc_sensor = rsc.RSC(0, 9, 8); diff -Nru upm-1.6.0/include/external/json/json.hpp upm-1.7.1/include/external/json/json.hpp --- upm-1.6.0/include/external/json/json.hpp 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/include/external/json/json.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14874 @@ +/* + __ _____ _____ _____ + __| | __| | | | JSON for Modern C++ +| | |__ | | | | | | version 3.0.1 +|_____|_____|_____|_|___| https://github.com/nlohmann/json + +Licensed under the MIT License . +Copyright (c) 2013-2017 Niels Lohmann . + +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. +*/ + +#ifndef NLOHMANN_JSON_HPP +#define NLOHMANN_JSON_HPP + +#include // all_of, copy, fill, find, for_each, generate_n, none_of, remove, reverse, transform +#include // array +#include // assert +#include // and, not, or +#include // lconv, localeconv +#include // isfinite, labs, ldexp, signbit +#include // nullptr_t, ptrdiff_t, size_t +#include // int64_t, uint64_t +#include // abort, strtod, strtof, strtold, strtoul, strtoll, strtoull +#include // memcpy, strlen +#include // forward_list +#include // function, hash, less +#include // initializer_list +#include // hex +#include // istream, ostream +#include // advance, begin, back_inserter, bidirectional_iterator_tag, distance, end, inserter, iterator, iterator_traits, next, random_access_iterator_tag, reverse_iterator +#include // numeric_limits +#include // locale +#include // map +#include // addressof, allocator, allocator_traits, unique_ptr +#include // accumulate +#include // stringstream +#include // getline, stoi, string, to_string +#include // add_pointer, conditional, decay, enable_if, false_type, integral_constant, is_arithmetic, is_base_of, is_const, is_constructible, is_convertible, is_default_constructible, is_enum, is_floating_point, is_integral, is_nothrow_move_assignable, is_nothrow_move_constructible, is_pointer, is_reference, is_same, is_scalar, is_signed, remove_const, remove_cv, remove_pointer, remove_reference, true_type, underlying_type +#include // declval, forward, make_pair, move, pair, swap +#include // valarray +#include // vector + +// exclude unsupported compilers +#if defined(__clang__) + #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 + #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" + #endif +#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) + #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900 + #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" + #endif +#endif + +// disable float-equal warnings on GCC/clang +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + +// disable documentation warnings on clang +#if defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdocumentation" +#endif + +// allow for portable deprecation warnings +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #define JSON_DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) + #define JSON_DEPRECATED __declspec(deprecated) +#else + #define JSON_DEPRECATED +#endif + +// allow to disable exceptions +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) + #define JSON_THROW(exception) throw exception + #define JSON_TRY try + #define JSON_CATCH(exception) catch(exception) +#else + #define JSON_THROW(exception) std::abort() + #define JSON_TRY if(true) + #define JSON_CATCH(exception) if(false) +#endif + +// manual branch prediction +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #define JSON_LIKELY(x) __builtin_expect(!!(x), 1) + #define JSON_UNLIKELY(x) __builtin_expect(!!(x), 0) +#else + #define JSON_LIKELY(x) x + #define JSON_UNLIKELY(x) x +#endif + +// C++ language standard detection +#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 +#endif + +/*! +@brief namespace for Niels Lohmann +@see https://github.com/nlohmann +@since version 1.0.0 +*/ +namespace nlohmann +{ +template +struct adl_serializer; + +// forward declaration of basic_json (required to split the class) +template class ObjectType = std::map, + template class ArrayType = std::vector, + class StringType = std::string, class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = adl_serializer> +class basic_json; + +// Ugly macros to avoid uglier copy-paste when specializing basic_json. They +// may be removed in the future once the class is split. + +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template class ArrayType, \ + class StringType, class BooleanType, class NumberIntegerType, \ + class NumberUnsignedType, class NumberFloatType, \ + template class AllocatorType, \ + template class JSONSerializer> + +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json + + +/*! +@brief unnamed namespace with internal helper functions + +This namespace collects some functions that could not be defined inside the +@ref basic_json class. + +@since version 2.1.0 +*/ +namespace detail +{ +//////////////// +// exceptions // +//////////////// + +/*! +@brief general exception of the @ref basic_json class + +This class is an extension of `std::exception` objects with a member @a id for +exception ids. It is used as the base class for all exceptions thrown by the +@ref basic_json class. This class can hence be used as "wildcard" to catch +exceptions. + +Subclasses: +- @ref parse_error for exceptions indicating a parse error +- @ref invalid_iterator for exceptions indicating errors with iterators +- @ref type_error for exceptions indicating executing a member function with + a wrong type +- @ref out_of_range for exceptions indicating access out of the defined range +- @ref other_error for exceptions indicating other library errors + +@internal +@note To have nothrow-copy-constructible exceptions, we internally use + `std::runtime_error` which can cope with arbitrary-length error messages. + Intermediate strings are built with static functions and then passed to + the actual constructor. +@endinternal + +@liveexample{The following code shows how arbitrary library exceptions can be +caught.,exception} + +@since version 3.0.0 +*/ +class exception : public std::exception +{ + public: + /// returns the explanatory string + const char* what() const noexcept override + { + return m.what(); + } + + /// the id of the exception + const int id; + + protected: + exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} + + static std::string name(const std::string& ename, int id_) + { + return "[json.exception." + ename + "." + std::to_string(id_) + "] "; + } + + private: + /// an exception object as storage for error messages + std::runtime_error m; +}; + +/*! +@brief exception indicating a parse error + +This exception is thrown by the library when a parse error occurs. Parse errors +can occur during the deserialization of JSON text, CBOR, MessagePack, as well +as when using JSON Patch. + +Member @a byte holds the byte index of the last read character in the input +file. + +Exceptions have ids 1xx. + +name / id | example message | description +------------------------------ | --------------- | ------------------------- +json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. +json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. +json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. +json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. +json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. +json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. +json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. +json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. +json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. +json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. +json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. +json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. + +@note For an input with n bytes, 1 is the index of the first character and n+1 + is the index of the terminating null byte or the end of file. This also + holds true when reading a byte vector (CBOR or MessagePack). + +@liveexample{The following code shows how a `parse_error` exception can be +caught.,parse_error} + +@sa @ref exception for the base class of the library exceptions +@sa @ref invalid_iterator for exceptions indicating errors with iterators +@sa @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa @ref out_of_range for exceptions indicating access out of the defined range +@sa @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class parse_error : public exception +{ + public: + /*! + @brief create a parse error exception + @param[in] id_ the id of the exception + @param[in] byte_ the byte index where the error occurred (or 0 if the + position cannot be determined) + @param[in] what_arg the explanatory string + @return parse_error object + */ + static parse_error create(int id_, std::size_t byte_, const std::string& what_arg) + { + std::string w = exception::name("parse_error", id_) + "parse error" + + (byte_ != 0 ? (" at " + std::to_string(byte_)) : "") + + ": " + what_arg; + return parse_error(id_, byte_, w.c_str()); + } + + /*! + @brief byte index of the parse error + + The byte index of the last read character in the input file. + + @note For an input with n bytes, 1 is the index of the first character and + n+1 is the index of the terminating null byte or the end of file. + This also holds true when reading a byte vector (CBOR or MessagePack). + */ + const std::size_t byte; + + private: + parse_error(int id_, std::size_t byte_, const char* what_arg) + : exception(id_, what_arg), byte(byte_) {} +}; + +/*! +@brief exception indicating errors with iterators + +This exception is thrown if iterators passed to a library function do not match +the expected semantics. + +Exceptions have ids 2xx. + +name / id | example message | description +----------------------------------- | --------------- | ------------------------- +json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. +json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. +json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. +json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. +json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. +json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. +json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. +json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. +json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. +json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. +json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. +json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. +json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. +json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). + +@liveexample{The following code shows how an `invalid_iterator` exception can be +caught.,invalid_iterator} + +@sa @ref exception for the base class of the library exceptions +@sa @ref parse_error for exceptions indicating a parse error +@sa @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa @ref out_of_range for exceptions indicating access out of the defined range +@sa @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class invalid_iterator : public exception +{ + public: + static invalid_iterator create(int id_, const std::string& what_arg) + { + std::string w = exception::name("invalid_iterator", id_) + what_arg; + return invalid_iterator(id_, w.c_str()); + } + + private: + invalid_iterator(int id_, const char* what_arg) + : exception(id_, what_arg) {} +}; + +/*! +@brief exception indicating executing a member function with a wrong type + +This exception is thrown in case of a type error; that is, a library function is +executed on a JSON value whose type does not match the expected semantics. + +Exceptions have ids 3xx. + +name / id | example message | description +----------------------------- | --------------- | ------------------------- +json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. +json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. +json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t&. +json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. +json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. +json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. +json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. +json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. +json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. +json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. +json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. +json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. +json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. +json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. +json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. +json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | + +@liveexample{The following code shows how a `type_error` exception can be +caught.,type_error} + +@sa @ref exception for the base class of the library exceptions +@sa @ref parse_error for exceptions indicating a parse error +@sa @ref invalid_iterator for exceptions indicating errors with iterators +@sa @ref out_of_range for exceptions indicating access out of the defined range +@sa @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class type_error : public exception +{ + public: + static type_error create(int id_, const std::string& what_arg) + { + std::string w = exception::name("type_error", id_) + what_arg; + return type_error(id_, w.c_str()); + } + + private: + type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} +}; + +/*! +@brief exception indicating access out of the defined range + +This exception is thrown in case a library function is called on an input +parameter that exceeds the expected range, for instance in case of array +indices or nonexisting object keys. + +Exceptions have ids 4xx. + +name / id | example message | description +------------------------------- | --------------- | ------------------------- +json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. +json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. +json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. +json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. +json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. +json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. + +@liveexample{The following code shows how an `out_of_range` exception can be +caught.,out_of_range} + +@sa @ref exception for the base class of the library exceptions +@sa @ref parse_error for exceptions indicating a parse error +@sa @ref invalid_iterator for exceptions indicating errors with iterators +@sa @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class out_of_range : public exception +{ + public: + static out_of_range create(int id_, const std::string& what_arg) + { + std::string w = exception::name("out_of_range", id_) + what_arg; + return out_of_range(id_, w.c_str()); + } + + private: + out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} +}; + +/*! +@brief exception indicating other library errors + +This exception is thrown in case of errors that cannot be classified with the +other exception types. + +Exceptions have ids 5xx. + +name / id | example message | description +------------------------------ | --------------- | ------------------------- +json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. + +@sa @ref exception for the base class of the library exceptions +@sa @ref parse_error for exceptions indicating a parse error +@sa @ref invalid_iterator for exceptions indicating errors with iterators +@sa @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa @ref out_of_range for exceptions indicating access out of the defined range + +@liveexample{The following code shows how an `other_error` exception can be +caught.,other_error} + +@since version 3.0.0 +*/ +class other_error : public exception +{ + public: + static other_error create(int id_, const std::string& what_arg) + { + std::string w = exception::name("other_error", id_) + what_arg; + return other_error(id_, w.c_str()); + } + + private: + other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} +}; + + + +/////////////////////////// +// JSON type enumeration // +/////////////////////////// + +/*! +@brief the JSON type enumeration + +This enumeration collects the different JSON types. It is internally used to +distinguish the stored values, and the functions @ref basic_json::is_null(), +@ref basic_json::is_object(), @ref basic_json::is_array(), +@ref basic_json::is_string(), @ref basic_json::is_boolean(), +@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), +@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), +@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and +@ref basic_json::is_structured() rely on it. + +@note There are three enumeration entries (number_integer, number_unsigned, and +number_float), because the library distinguishes these three types for numbers: +@ref basic_json::number_unsigned_t is used for unsigned integers, +@ref basic_json::number_integer_t is used for signed integers, and +@ref basic_json::number_float_t is used for floating-point numbers or to +approximate integers which do not fit in the limits of their respective type. + +@sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON +value with the default value for a given type + +@since version 1.0.0 +*/ +enum class value_t : uint8_t +{ + null, ///< null value + object, ///< object (unordered set of name/value pairs) + array, ///< array (ordered collection of values) + string, ///< string value + boolean, ///< boolean value + number_integer, ///< number value (signed integer) + number_unsigned, ///< number value (unsigned integer) + number_float, ///< number value (floating-point) + discarded ///< discarded by the the parser callback function +}; + +/*! +@brief comparison operator for JSON types + +Returns an ordering that is similar to Python: +- order: null < boolean < number < object < array < string +- furthermore, each type is not smaller than itself +- discarded values are not comparable + +@since version 1.0.0 +*/ +inline bool operator<(const value_t lhs, const value_t rhs) noexcept +{ + static constexpr std::array order = {{ + 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, + 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */ + } + }; + + const auto l_index = static_cast(lhs); + const auto r_index = static_cast(rhs); + return l_index < order.size() and r_index < order.size() and order[l_index] < order[r_index]; +} + + +///////////// +// helpers // +///////////// + +template struct is_basic_json : std::false_type {}; + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +struct is_basic_json : std::true_type {}; + +// alias templates to reduce boilerplate +template +using enable_if_t = typename std::enable_if::type; + +template +using uncvref_t = typename std::remove_cv::type>::type; + +// implementation of C++14 index_sequence and affiliates +// source: https://stackoverflow.com/a/32223343 +template +struct index_sequence +{ + using type = index_sequence; + using value_type = std::size_t; + static constexpr std::size_t size() noexcept + { + return sizeof...(Ints); + } +}; + +template +struct merge_and_renumber; + +template +struct merge_and_renumber, index_sequence> + : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; + +template +struct make_index_sequence + : merge_and_renumber < typename make_index_sequence < N / 2 >::type, + typename make_index_sequence < N - N / 2 >::type > {}; + +template<> struct make_index_sequence<0> : index_sequence<> {}; +template<> struct make_index_sequence<1> : index_sequence<0> {}; + +template +using index_sequence_for = make_index_sequence; + +/* +Implementation of two C++17 constructs: conjunction, negation. This is needed +to avoid evaluating all the traits in a condition + +For example: not std::is_same::value and has_value_type::value +will not compile when T = void (on MSVC at least). Whereas +conjunction>, has_value_type>::value will +stop evaluating if negation<...>::value == false + +Please note that those constructs must be used with caution, since symbols can +become very long quickly (which can slow down compilation and cause MSVC +internal compiler errors). Only use it when you have to (see example ahead). +*/ +template struct conjunction : std::true_type {}; +template struct conjunction : B1 {}; +template +struct conjunction : std::conditional, B1>::type {}; + +template struct negation : std::integral_constant {}; + +// dispatch utility (taken from ranges-v3) +template struct priority_tag : priority_tag < N - 1 > {}; +template<> struct priority_tag<0> {}; + + +////////////////// +// constructors // +////////////////// + +template struct external_constructor; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept + { + j.m_type = value_t::boolean; + j.m_value = b; + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) + { + j.m_type = value_t::string; + j.m_value = s; + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) + { + j.m_type = value_t::string; + j.m_value = std::move(s); + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept + { + j.m_type = value_t::number_float; + j.m_value = val; + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept + { + j.m_type = value_t::number_unsigned; + j.m_value = val; + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept + { + j.m_type = value_t::number_integer; + j.m_value = val; + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) + { + j.m_type = value_t::array; + j.m_value = arr; + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) + { + j.m_type = value_t::array; + j.m_value = std::move(arr); + j.assert_invariant(); + } + + template::value, + int> = 0> + static void construct(BasicJsonType& j, const CompatibleArrayType& arr) + { + using std::begin; + using std::end; + j.m_type = value_t::array; + j.m_value.array = j.template create(begin(arr), end(arr)); + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, const std::vector& arr) + { + j.m_type = value_t::array; + j.m_value = value_t::array; + j.m_value.array->reserve(arr.size()); + for (const bool x : arr) + { + j.m_value.array->push_back(x); + } + j.assert_invariant(); + } + + template::value, int> = 0> + static void construct(BasicJsonType& j, const std::valarray& arr) + { + j.m_type = value_t::array; + j.m_value = value_t::array; + j.m_value.array->resize(arr.size()); + std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) + { + j.m_type = value_t::object; + j.m_value = obj; + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) + { + j.m_type = value_t::object; + j.m_value = std::move(obj); + j.assert_invariant(); + } + + template::value, int> = 0> + static void construct(BasicJsonType& j, const CompatibleObjectType& obj) + { + using std::begin; + using std::end; + + j.m_type = value_t::object; + j.m_value.object = j.template create(begin(obj), end(obj)); + j.assert_invariant(); + } +}; + + +//////////////////////// +// has_/is_ functions // +//////////////////////// + +/*! +@brief Helper to determine whether there's a key_type for T. + +This helper is used to tell associative containers apart from other containers +such as sequence containers. For instance, `std::map` passes the test as it +contains a `mapped_type`, whereas `std::vector` fails the test. + +@sa http://stackoverflow.com/a/7728728/266378 +@since version 1.0.0, overworked in version 2.0.6 +*/ +#define NLOHMANN_JSON_HAS_HELPER(type) \ + template struct has_##type { \ + private: \ + template \ + static int detect(U &&); \ + static void detect(...); \ + public: \ + static constexpr bool value = \ + std::is_integral()))>::value; \ + } + +NLOHMANN_JSON_HAS_HELPER(mapped_type); +NLOHMANN_JSON_HAS_HELPER(key_type); +NLOHMANN_JSON_HAS_HELPER(value_type); +NLOHMANN_JSON_HAS_HELPER(iterator); + +#undef NLOHMANN_JSON_HAS_HELPER + + +template +struct is_compatible_object_type_impl : std::false_type {}; + +template +struct is_compatible_object_type_impl +{ + static constexpr auto value = + std::is_constructible::value and + std::is_constructible::value; +}; + +template +struct is_compatible_object_type +{ + static auto constexpr value = is_compatible_object_type_impl < + conjunction>, + has_mapped_type, + has_key_type>::value, + typename BasicJsonType::object_t, CompatibleObjectType >::value; +}; + +template +struct is_basic_json_nested_type +{ + static auto constexpr value = std::is_same::value or + std::is_same::value or + std::is_same::value or + std::is_same::value; +}; + +template +struct is_compatible_array_type +{ + static auto constexpr value = + conjunction>, + negation>, + negation>, + negation>, + has_value_type, + has_iterator>::value; +}; + +template +struct is_compatible_integer_type_impl : std::false_type {}; + +template +struct is_compatible_integer_type_impl +{ + // is there an assert somewhere on overflows? + using RealLimits = std::numeric_limits; + using CompatibleLimits = std::numeric_limits; + + static constexpr auto value = + std::is_constructible::value and + CompatibleLimits::is_integer and + RealLimits::is_signed == CompatibleLimits::is_signed; +}; + +template +struct is_compatible_integer_type +{ + static constexpr auto value = + is_compatible_integer_type_impl < + std::is_integral::value and + not std::is_same::value, + RealIntegerType, CompatibleNumberIntegerType >::value; +}; + + +// trait checking if JSONSerializer::from_json(json const&, udt&) exists +template +struct has_from_json +{ + private: + // also check the return type of from_json + template::from_json( + std::declval(), std::declval()))>::value>> + static int detect(U&&); + static void detect(...); + + public: + static constexpr bool value = std::is_integral>()))>::value; +}; + +// This trait checks if JSONSerializer::from_json(json const&) exists +// this overload is used for non-default-constructible user-defined-types +template +struct has_non_default_from_json +{ + private: + template::from_json(std::declval()))>::value>> + static int detect(U&&); + static void detect(...); + + public: + static constexpr bool value = std::is_integral>()))>::value; +}; + +// This trait checks if BasicJsonType::json_serializer::to_json exists +template +struct has_to_json +{ + private: + template::to_json( + std::declval(), std::declval()))> + static int detect(U&&); + static void detect(...); + + public: + static constexpr bool value = std::is_integral>()))>::value; +}; + + +///////////// +// to_json // +///////////// + +template::value, int> = 0> +void to_json(BasicJsonType& j, T b) noexcept +{ + external_constructor::construct(j, b); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, const CompatibleString& s) +{ + external_constructor::construct(j, s); +} + +template +void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) +{ + external_constructor::construct(j, std::move(s)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, FloatType val) noexcept +{ + external_constructor::construct(j, static_cast(val)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept +{ + external_constructor::construct(j, static_cast(val)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept +{ + external_constructor::construct(j, static_cast(val)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, EnumType e) noexcept +{ + using underlying_type = typename std::underlying_type::type; + external_constructor::construct(j, static_cast(e)); +} + +template +void to_json(BasicJsonType& j, const std::vector& e) +{ + external_constructor::construct(j, e); +} + +template::value or + std::is_same::value, + int> = 0> +void to_json(BasicJsonType& j, const CompatibleArrayType& arr) +{ + external_constructor::construct(j, arr); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, std::valarray arr) +{ + external_constructor::construct(j, std::move(arr)); +} + +template +void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) +{ + external_constructor::construct(j, std::move(arr)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, const CompatibleObjectType& obj) +{ + external_constructor::construct(j, obj); +} + +template +void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) +{ + external_constructor::construct(j, std::move(obj)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, T (&arr)[N]) +{ + external_constructor::construct(j, arr); +} + +template +void to_json(BasicJsonType& j, const std::pair& p) +{ + j = {p.first, p.second}; +} + +template +void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence) +{ + j = {std::get(t)...}; +} + +template +void to_json(BasicJsonType& j, const std::tuple& t) +{ + to_json_tuple_impl(j, t, index_sequence_for {}); +} + +/////////////// +// from_json // +/////////////// + +// overloads for basic_json template parameters +template::value and + not std::is_same::value, + int> = 0> +void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) +{ + switch (static_cast(j)) + { + case value_t::number_unsigned: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::number_integer: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::number_float: + { + val = static_cast(*j.template get_ptr()); + break; + } + + default: + JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); + } +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) +{ + if (JSON_UNLIKELY(not j.is_boolean())) + { + JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); + } + b = *j.template get_ptr(); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) +{ + if (JSON_UNLIKELY(not j.is_string())) + { + JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); + } + s = *j.template get_ptr(); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) +{ + get_arithmetic_value(j, val); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) +{ + get_arithmetic_value(j, val); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) +{ + get_arithmetic_value(j, val); +} + +template::value, int> = 0> +void from_json(const BasicJsonType& j, EnumType& e) +{ + typename std::underlying_type::type val; + get_arithmetic_value(j, val); + e = static_cast(val); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::array_t& arr) +{ + if (JSON_UNLIKELY(not j.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); + } + arr = *j.template get_ptr(); +} + +// forward_list doesn't have an insert method +template::value, int> = 0> +void from_json(const BasicJsonType& j, std::forward_list& l) +{ + if (JSON_UNLIKELY(not j.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); + } + std::transform(j.rbegin(), j.rend(), + std::front_inserter(l), [](const BasicJsonType & i) + { + return i.template get(); + }); +} + +// valarray doesn't have an insert method +template::value, int> = 0> +void from_json(const BasicJsonType& j, std::valarray& l) +{ + if (JSON_UNLIKELY(not j.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); + } + l.resize(j.size()); + std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l)); +} + +template +void from_json_array_impl(const BasicJsonType& j, CompatibleArrayType& arr, priority_tag<0> /*unused*/) +{ + using std::end; + + std::transform(j.begin(), j.end(), + std::inserter(arr, end(arr)), [](const BasicJsonType & i) + { + // get() returns *this, this won't call a from_json + // method when value_type is BasicJsonType + return i.template get(); + }); +} + +template +auto from_json_array_impl(const BasicJsonType& j, CompatibleArrayType& arr, priority_tag<1> /*unused*/) +-> decltype( + arr.reserve(std::declval()), + void()) +{ + using std::end; + + arr.reserve(j.size()); + std::transform(j.begin(), j.end(), + std::inserter(arr, end(arr)), [](const BasicJsonType & i) + { + // get() returns *this, this won't call a from_json + // method when value_type is BasicJsonType + return i.template get(); + }); +} + +template +void from_json_array_impl(const BasicJsonType& j, std::array& arr, priority_tag<2> /*unused*/) +{ + for (std::size_t i = 0; i < N; ++i) + { + arr[i] = j.at(i).template get(); + } +} + +template::value and + std::is_convertible::value and + not std::is_same::value, int> = 0> +void from_json(const BasicJsonType& j, CompatibleArrayType& arr) +{ + if (JSON_UNLIKELY(not j.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); + } + + from_json_array_impl(j, arr, priority_tag<2> {}); +} + +template::value, int> = 0> +void from_json(const BasicJsonType& j, CompatibleObjectType& obj) +{ + if (JSON_UNLIKELY(not j.is_object())) + { + JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); + } + + auto inner_object = j.template get_ptr(); + using value_type = typename CompatibleObjectType::value_type; + std::transform( + inner_object->begin(), inner_object->end(), + std::inserter(obj, obj.begin()), + [](typename BasicJsonType::object_t::value_type const & p) + { + return value_type(p.first, p.second.template get()); + }); +} + +// overload for arithmetic types, not chosen for basic_json template arguments +// (BooleanType, etc..); note: Is it really necessary to provide explicit +// overloads for boolean_t etc. in case of a custom BooleanType which is not +// an arithmetic type? +template::value and + not std::is_same::value and + not std::is_same::value and + not std::is_same::value and + not std::is_same::value, + int> = 0> +void from_json(const BasicJsonType& j, ArithmeticType& val) +{ + switch (static_cast(j)) + { + case value_t::number_unsigned: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::number_integer: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::number_float: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::boolean: + { + val = static_cast(*j.template get_ptr()); + break; + } + + default: + JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); + } +} + +template +void from_json(const BasicJsonType& j, std::pair& p) +{ + p = {j.at(0).template get(), j.at(1).template get()}; +} + +template +void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence) +{ + t = std::make_tuple(j.at(Idx).template get::type>()...); +} + +template +void from_json(const BasicJsonType& j, std::tuple& t) +{ + from_json_tuple_impl(j, t, index_sequence_for {}); +} + +struct to_json_fn +{ + private: + template + auto call(BasicJsonType& j, T&& val, priority_tag<1> /*unused*/) const noexcept(noexcept(to_json(j, std::forward(val)))) + -> decltype(to_json(j, std::forward(val)), void()) + { + return to_json(j, std::forward(val)); + } + + template + void call(BasicJsonType& /*unused*/, T&& /*unused*/, priority_tag<0> /*unused*/) const noexcept + { + static_assert(sizeof(BasicJsonType) == 0, + "could not find to_json() method in T's namespace"); + +#ifdef _MSC_VER + // MSVC does not show a stacktrace for the above assert + using decayed = uncvref_t; + static_assert(sizeof(typename decayed::force_msvc_stacktrace) == 0, + "forcing MSVC stacktrace to show which T we're talking about."); +#endif + } + + public: + template + void operator()(BasicJsonType& j, T&& val) const + noexcept(noexcept(std::declval().call(j, std::forward(val), priority_tag<1> {}))) + { + return call(j, std::forward(val), priority_tag<1> {}); + } +}; + +struct from_json_fn +{ + private: + template + auto call(const BasicJsonType& j, T& val, priority_tag<1> /*unused*/) const + noexcept(noexcept(from_json(j, val))) + -> decltype(from_json(j, val), void()) + { + return from_json(j, val); + } + + template + void call(const BasicJsonType& /*unused*/, T& /*unused*/, priority_tag<0> /*unused*/) const noexcept + { + static_assert(sizeof(BasicJsonType) == 0, + "could not find from_json() method in T's namespace"); +#ifdef _MSC_VER + // MSVC does not show a stacktrace for the above assert + using decayed = uncvref_t; + static_assert(sizeof(typename decayed::force_msvc_stacktrace) == 0, + "forcing MSVC stacktrace to show which T we're talking about."); +#endif + } + + public: + template + void operator()(const BasicJsonType& j, T& val) const + noexcept(noexcept(std::declval().call(j, val, priority_tag<1> {}))) + { + return call(j, val, priority_tag<1> {}); + } +}; + +// taken from ranges-v3 +template +struct static_const +{ + static constexpr T value{}; +}; + +template +constexpr T static_const::value; + +//////////////////// +// input adapters // +//////////////////// + +/*! +@brief abstract input adapter interface + +Produces a stream of std::char_traits::int_type characters from a +std::istream, a buffer, or some other input type. Accepts the return of exactly +one non-EOF character for future input. The int_type characters returned +consist of all valid char values as positive values (typically unsigned char), +plus an EOF value outside that range, specified by the value of the function +std::char_traits::eof(). This value is typically -1, but could be any +arbitrary value which is not a valid char value. +*/ +struct input_adapter_protocol +{ + /// get a character [0,255] or std::char_traits::eof(). + virtual std::char_traits::int_type get_character() = 0; + /// restore the last non-eof() character to input + virtual void unget_character() = 0; + virtual ~input_adapter_protocol() = default; +}; + +/// a type to simplify interfaces +using input_adapter_t = std::shared_ptr; + +/*! +Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at +beginning of input. Does not support changing the underlying std::streambuf +in mid-input. Maintains underlying std::istream and std::streambuf to support +subsequent use of standard std::istream operations to process any input +characters following those used in parsing the JSON input. Clears the +std::istream flags; any input errors (e.g., EOF) will be detected by the first +subsequent call for input from the std::istream. +*/ +class input_stream_adapter : public input_adapter_protocol +{ + public: + ~input_stream_adapter() override + { + // clear stream flags; we use underlying streambuf I/O, do not + // maintain ifstream flags + is.clear(); + } + + explicit input_stream_adapter(std::istream& i) + : is(i), sb(*i.rdbuf()) + { + // skip byte order mark + std::char_traits::int_type c; + if ((c = get_character()) == 0xEF) + { + if ((c = get_character()) == 0xBB) + { + if ((c = get_character()) == 0xBF) + { + return; // Ignore BOM + } + else if (c != std::char_traits::eof()) + { + is.unget(); + } + is.putback('\xBB'); + } + else if (c != std::char_traits::eof()) + { + is.unget(); + } + is.putback('\xEF'); + } + else if (c != std::char_traits::eof()) + { + is.unget(); // no byte order mark; process as usual + } + } + + // delete because of pointer members + input_stream_adapter(const input_stream_adapter&) = delete; + input_stream_adapter& operator=(input_stream_adapter&) = delete; + + // std::istream/std::streambuf use std::char_traits::to_int_type, to + // ensure that std::char_traits::eof() and the character 0xFF do not + // end up as the same value, eg. 0xFFFFFFFF. + std::char_traits::int_type get_character() override + { + return sb.sbumpc(); + } + + void unget_character() override + { + sb.sungetc(); // is.unget() avoided for performance + } + + private: + /// the associated input stream + std::istream& is; + std::streambuf& sb; +}; + +/// input adapter for buffer input +class input_buffer_adapter : public input_adapter_protocol +{ + public: + input_buffer_adapter(const char* b, const std::size_t l) + : cursor(b), limit(b + l), start(b) + { + // skip byte order mark + if (l >= 3 and b[0] == '\xEF' and b[1] == '\xBB' and b[2] == '\xBF') + { + cursor += 3; + } + } + + // delete because of pointer members + input_buffer_adapter(const input_buffer_adapter&) = delete; + input_buffer_adapter& operator=(input_buffer_adapter&) = delete; + + std::char_traits::int_type get_character() noexcept override + { + if (JSON_LIKELY(cursor < limit)) + { + return std::char_traits::to_int_type(*(cursor++)); + } + + return std::char_traits::eof(); + } + + void unget_character() noexcept override + { + if (JSON_LIKELY(cursor > start)) + { + --cursor; + } + } + + private: + /// pointer to the current character + const char* cursor; + /// pointer past the last character + const char* limit; + /// pointer to the first character + const char* start; +}; + +class input_adapter +{ + public: + // native support + + /// input adapter for input stream + input_adapter(std::istream& i) + : ia(std::make_shared(i)) {} + + /// input adapter for input stream + input_adapter(std::istream&& i) + : ia(std::make_shared(i)) {} + + /// input adapter for buffer + template::value and + std::is_integral::type>::value and + sizeof(typename std::remove_pointer::type) == 1, + int>::type = 0> + input_adapter(CharT b, std::size_t l) + : ia(std::make_shared(reinterpret_cast(b), l)) {} + + // derived support + + /// input adapter for string literal + template::value and + std::is_integral::type>::value and + sizeof(typename std::remove_pointer::type) == 1, + int>::type = 0> + input_adapter(CharT b) + : input_adapter(reinterpret_cast(b), + std::strlen(reinterpret_cast(b))) {} + + /// input adapter for iterator range with contiguous storage + template::iterator_category, std::random_access_iterator_tag>::value, + int>::type = 0> + input_adapter(IteratorType first, IteratorType last) + { + // assertion to check that the iterator range is indeed contiguous, + // see http://stackoverflow.com/a/35008842/266378 for more discussion + assert(std::accumulate( + first, last, std::pair(true, 0), + [&first](std::pair res, decltype(*first) val) + { + res.first &= (val == *(std::next(std::addressof(*first), res.second++))); + return res; + }).first); + + // assertion to check that each element is 1 byte long + static_assert( + sizeof(typename std::iterator_traits::value_type) == 1, + "each element in the iterator range must have the size of 1 byte"); + + const auto len = static_cast(std::distance(first, last)); + if (JSON_LIKELY(len > 0)) + { + // there is at least one element: use the address of first + ia = std::make_shared(reinterpret_cast(&(*first)), len); + } + else + { + // the address of first cannot be used: use nullptr + ia = std::make_shared(nullptr, len); + } + } + + /// input adapter for array + template + input_adapter(T (&array)[N]) + : input_adapter(std::begin(array), std::end(array)) {} + + /// input adapter for contiguous container + template::value and + std::is_base_of()))>::iterator_category>::value, + int>::type = 0> + input_adapter(const ContiguousContainer& c) + : input_adapter(std::begin(c), std::end(c)) {} + + operator input_adapter_t() + { + return ia; + } + + private: + /// the actual adapter + input_adapter_t ia = nullptr; +}; + +////////////////////// +// lexer and parser // +////////////////////// + +/*! +@brief lexical analysis + +This class organizes the lexical analysis during JSON deserialization. +*/ +template +class lexer +{ + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + + public: + /// token types for the parser + enum class token_type + { + uninitialized, ///< indicating the scanner is uninitialized + literal_true, ///< the `true` literal + literal_false, ///< the `false` literal + literal_null, ///< the `null` literal + value_string, ///< a string -- use get_string() for actual value + value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value + value_integer, ///< a signed integer -- use get_number_integer() for actual value + value_float, ///< an floating point number -- use get_number_float() for actual value + begin_array, ///< the character for array begin `[` + begin_object, ///< the character for object begin `{` + end_array, ///< the character for array end `]` + end_object, ///< the character for object end `}` + name_separator, ///< the name separator `:` + value_separator, ///< the value separator `,` + parse_error, ///< indicating a parse error + end_of_input, ///< indicating the end of the input buffer + literal_or_value ///< a literal or the begin of a value (only for diagnostics) + }; + + /// return name of values of type token_type (only used for errors) + static const char* token_type_name(const token_type t) noexcept + { + switch (t) + { + case token_type::uninitialized: + return ""; + case token_type::literal_true: + return "true literal"; + case token_type::literal_false: + return "false literal"; + case token_type::literal_null: + return "null literal"; + case token_type::value_string: + return "string literal"; + case lexer::token_type::value_unsigned: + case lexer::token_type::value_integer: + case lexer::token_type::value_float: + return "number literal"; + case token_type::begin_array: + return "'['"; + case token_type::begin_object: + return "'{'"; + case token_type::end_array: + return "']'"; + case token_type::end_object: + return "'}'"; + case token_type::name_separator: + return "':'"; + case token_type::value_separator: + return "','"; + case token_type::parse_error: + return ""; + case token_type::end_of_input: + return "end of input"; + case token_type::literal_or_value: + return "'[', '{', or a literal"; + default: // catch non-enum values + return "unknown token"; // LCOV_EXCL_LINE + } + } + + explicit lexer(detail::input_adapter_t adapter) + : ia(std::move(adapter)), decimal_point_char(get_decimal_point()) {} + + // delete because of pointer members + lexer(const lexer&) = delete; + lexer& operator=(lexer&) = delete; + + private: + ///////////////////// + // locales + ///////////////////// + + /// return the locale-dependent decimal point + static char get_decimal_point() noexcept + { + const auto loc = localeconv(); + assert(loc != nullptr); + return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); + } + + ///////////////////// + // scan functions + ///////////////////// + + /*! + @brief get codepoint from 4 hex characters following `\u` + + For input "\u c1 c2 c3 c4" the codepoint is: + (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4 + = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0) + + Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f' + must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The + conversion is done by subtracting the offset (0x30, 0x37, and 0x57) + between the ASCII value of the character and the desired integer value. + + @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or + non-hex character) + */ + int get_codepoint() + { + // this function only makes sense after reading `\u` + assert(current == 'u'); + int codepoint = 0; + + const auto factors = { 12, 8, 4, 0 }; + for (const auto factor : factors) + { + get(); + + if (current >= '0' and current <= '9') + { + codepoint += ((current - 0x30) << factor); + } + else if (current >= 'A' and current <= 'F') + { + codepoint += ((current - 0x37) << factor); + } + else if (current >= 'a' and current <= 'f') + { + codepoint += ((current - 0x57) << factor); + } + else + { + return -1; + } + } + + assert(0x0000 <= codepoint and codepoint <= 0xFFFF); + return codepoint; + } + + /*! + @brief check if the next byte(s) are inside a given range + + Adds the current byte and, for each passed range, reads a new byte and + checks if it is inside the range. If a violation was detected, set up an + error message and return false. Otherwise, return true. + + @param[in] ranges list of integers; interpreted as list of pairs of + inclusive lower and upper bound, respectively + + @pre The passed list @a ranges must have 2, 4, or 6 elements; that is, + 1, 2, or 3 pairs. This precondition is enforced by an assertion. + + @return true if and only if no range violation was detected + */ + bool next_byte_in_range(std::initializer_list ranges) + { + assert(ranges.size() == 2 or ranges.size() == 4 or ranges.size() == 6); + add(current); + + for (auto range = ranges.begin(); range != ranges.end(); ++range) + { + get(); + if (JSON_LIKELY(*range <= current and current <= *(++range))) + { + add(current); + } + else + { + error_message = "invalid string: ill-formed UTF-8 byte"; + return false; + } + } + + return true; + } + + /*! + @brief scan a string literal + + This function scans a string according to Sect. 7 of RFC 7159. While + scanning, bytes are escaped and copied into buffer yytext. Then the function + returns successfully, yytext is *not* null-terminated (as it may contain \0 + bytes), and yytext.size() is the number of bytes in the string. + + @return token_type::value_string if string could be successfully scanned, + token_type::parse_error otherwise + + @note In case of errors, variable error_message contains a textual + description. + */ + token_type scan_string() + { + // reset yytext (ignore opening quote) + reset(); + + // we entered the function by reading an open quote + assert(current == '\"'); + + while (true) + { + // get next character + switch (get()) + { + // end of file while parsing string + case std::char_traits::eof(): + { + error_message = "invalid string: missing closing quote"; + return token_type::parse_error; + } + + // closing quote + case '\"': + { + return token_type::value_string; + } + + // escapes + case '\\': + { + switch (get()) + { + // quotation mark + case '\"': + add('\"'); + break; + // reverse solidus + case '\\': + add('\\'); + break; + // solidus + case '/': + add('/'); + break; + // backspace + case 'b': + add('\b'); + break; + // form feed + case 'f': + add('\f'); + break; + // line feed + case 'n': + add('\n'); + break; + // carriage return + case 'r': + add('\r'); + break; + // tab + case 't': + add('\t'); + break; + + // unicode escapes + case 'u': + { + const int codepoint1 = get_codepoint(); + int codepoint = codepoint1; // start with codepoint1 + + if (JSON_UNLIKELY(codepoint1 == -1)) + { + error_message = "invalid string: '\\u' must be followed by 4 hex digits"; + return token_type::parse_error; + } + + // check if code point is a high surrogate + if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF) + { + // expect next \uxxxx entry + if (JSON_LIKELY(get() == '\\' and get() == 'u')) + { + const int codepoint2 = get_codepoint(); + + if (JSON_UNLIKELY(codepoint2 == -1)) + { + error_message = "invalid string: '\\u' must be followed by 4 hex digits"; + return token_type::parse_error; + } + + // check if codepoint2 is a low surrogate + if (JSON_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) + { + // overwrite codepoint + codepoint = + // high surrogate occupies the most significant 22 bits + (codepoint1 << 10) + // low surrogate occupies the least significant 15 bits + + codepoint2 + // there is still the 0xD800, 0xDC00 and 0x10000 noise + // in the result so we have to subtract with: + // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 + - 0x35FDC00; + } + else + { + error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF"; + return token_type::parse_error; + } + } + else + { + error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF"; + return token_type::parse_error; + } + } + else + { + if (JSON_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) + { + error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; + return token_type::parse_error; + } + } + + // result of the above calculation yields a proper codepoint + assert(0x00 <= codepoint and codepoint <= 0x10FFFF); + + // translate codepoint into bytes + if (codepoint < 0x80) + { + // 1-byte characters: 0xxxxxxx (ASCII) + add(codepoint); + } + else if (codepoint <= 0x7FF) + { + // 2-byte characters: 110xxxxx 10xxxxxx + add(0xC0 | (codepoint >> 6)); + add(0x80 | (codepoint & 0x3F)); + } + else if (codepoint <= 0xFFFF) + { + // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx + add(0xE0 | (codepoint >> 12)); + add(0x80 | ((codepoint >> 6) & 0x3F)); + add(0x80 | (codepoint & 0x3F)); + } + else + { + // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + add(0xF0 | (codepoint >> 18)); + add(0x80 | ((codepoint >> 12) & 0x3F)); + add(0x80 | ((codepoint >> 6) & 0x3F)); + add(0x80 | (codepoint & 0x3F)); + } + + break; + } + + // other characters after escape + default: + error_message = "invalid string: forbidden character after backslash"; + return token_type::parse_error; + } + + break; + } + + // invalid control characters + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + { + error_message = "invalid string: control character must be escaped"; + return token_type::parse_error; + } + + // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace)) + case 0x20: + case 0x21: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x59: + case 0x5A: + case 0x5B: + case 0x5D: + case 0x5E: + case 0x5F: + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: + case 0x79: + case 0x7A: + case 0x7B: + case 0x7C: + case 0x7D: + case 0x7E: + case 0x7F: + { + add(current); + break; + } + + // U+0080..U+07FF: bytes C2..DF 80..BF + case 0xC2: + case 0xC3: + case 0xC4: + case 0xC5: + case 0xC6: + case 0xC7: + case 0xC8: + case 0xC9: + case 0xCA: + case 0xCB: + case 0xCC: + case 0xCD: + case 0xCE: + case 0xCF: + case 0xD0: + case 0xD1: + case 0xD2: + case 0xD3: + case 0xD4: + case 0xD5: + case 0xD6: + case 0xD7: + case 0xD8: + case 0xD9: + case 0xDA: + case 0xDB: + case 0xDC: + case 0xDD: + case 0xDE: + case 0xDF: + { + if (JSON_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) + { + return token_type::parse_error; + } + break; + } + + // U+0800..U+0FFF: bytes E0 A0..BF 80..BF + case 0xE0: + { + if (JSON_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF + // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF + case 0xE1: + case 0xE2: + case 0xE3: + case 0xE4: + case 0xE5: + case 0xE6: + case 0xE7: + case 0xE8: + case 0xE9: + case 0xEA: + case 0xEB: + case 0xEC: + case 0xEE: + case 0xEF: + { + if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+D000..U+D7FF: bytes ED 80..9F 80..BF + case 0xED: + { + if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF + case 0xF0: + { + if (JSON_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF + case 0xF1: + case 0xF2: + case 0xF3: + { + if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF + case 0xF4: + { + if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // remaining bytes (80..C1 and F5..FF) are ill-formed + default: + { + error_message = "invalid string: ill-formed UTF-8 byte"; + return token_type::parse_error; + } + } + } + } + + static void strtof(float& f, const char* str, char** endptr) noexcept + { + f = std::strtof(str, endptr); + } + + static void strtof(double& f, const char* str, char** endptr) noexcept + { + f = std::strtod(str, endptr); + } + + static void strtof(long double& f, const char* str, char** endptr) noexcept + { + f = std::strtold(str, endptr); + } + + /*! + @brief scan a number literal + + This function scans a string according to Sect. 6 of RFC 7159. + + The function is realized with a deterministic finite state machine derived + from the grammar described in RFC 7159. Starting in state "init", the + input is read and used to determined the next state. Only state "done" + accepts the number. State "error" is a trap state to model errors. In the + table below, "anything" means any character but the ones listed before. + + state | 0 | 1-9 | e E | + | - | . | anything + ---------|----------|----------|----------|---------|---------|----------|----------- + init | zero | any1 | [error] | [error] | minus | [error] | [error] + minus | zero | any1 | [error] | [error] | [error] | [error] | [error] + zero | done | done | exponent | done | done | decimal1 | done + any1 | any1 | any1 | exponent | done | done | decimal1 | done + decimal1 | decimal2 | [error] | [error] | [error] | [error] | [error] | [error] + decimal2 | decimal2 | decimal2 | exponent | done | done | done | done + exponent | any2 | any2 | [error] | sign | sign | [error] | [error] + sign | any2 | any2 | [error] | [error] | [error] | [error] | [error] + any2 | any2 | any2 | done | done | done | done | done + + The state machine is realized with one label per state (prefixed with + "scan_number_") and `goto` statements between them. The state machine + contains cycles, but any cycle can be left when EOF is read. Therefore, + the function is guaranteed to terminate. + + During scanning, the read bytes are stored in yytext. This string is + then converted to a signed integer, an unsigned integer, or a + floating-point number. + + @return token_type::value_unsigned, token_type::value_integer, or + token_type::value_float if number could be successfully scanned, + token_type::parse_error otherwise + + @note The scanner is independent of the current locale. Internally, the + locale's decimal point is used instead of `.` to work with the + locale-dependent converters. + */ + token_type scan_number() + { + // reset yytext to store the number's bytes + reset(); + + // the type of the parsed number; initially set to unsigned; will be + // changed if minus sign, decimal point or exponent is read + token_type number_type = token_type::value_unsigned; + + // state (init): we just found out we need to scan a number + switch (current) + { + case '-': + { + add(current); + goto scan_number_minus; + } + + case '0': + { + add(current); + goto scan_number_zero; + } + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any1; + } + + default: + { + // all other characters are rejected outside scan_number() + assert(false); // LCOV_EXCL_LINE + } + } + +scan_number_minus: + // state: we just parsed a leading minus sign + number_type = token_type::value_integer; + switch (get()) + { + case '0': + { + add(current); + goto scan_number_zero; + } + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any1; + } + + default: + { + error_message = "invalid number; expected digit after '-'"; + return token_type::parse_error; + } + } + +scan_number_zero: + // state: we just parse a zero (maybe with a leading minus sign) + switch (get()) + { + case '.': + { + add(decimal_point_char); + goto scan_number_decimal1; + } + + case 'e': + case 'E': + { + add(current); + goto scan_number_exponent; + } + + default: + goto scan_number_done; + } + +scan_number_any1: + // state: we just parsed a number 0-9 (maybe with a leading minus sign) + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any1; + } + + case '.': + { + add(decimal_point_char); + goto scan_number_decimal1; + } + + case 'e': + case 'E': + { + add(current); + goto scan_number_exponent; + } + + default: + goto scan_number_done; + } + +scan_number_decimal1: + // state: we just parsed a decimal point + number_type = token_type::value_float; + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_decimal2; + } + + default: + { + error_message = "invalid number; expected digit after '.'"; + return token_type::parse_error; + } + } + +scan_number_decimal2: + // we just parsed at least one number after a decimal point + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_decimal2; + } + + case 'e': + case 'E': + { + add(current); + goto scan_number_exponent; + } + + default: + goto scan_number_done; + } + +scan_number_exponent: + // we just parsed an exponent + number_type = token_type::value_float; + switch (get()) + { + case '+': + case '-': + { + add(current); + goto scan_number_sign; + } + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any2; + } + + default: + { + error_message = + "invalid number; expected '+', '-', or digit after exponent"; + return token_type::parse_error; + } + } + +scan_number_sign: + // we just parsed an exponent sign + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any2; + } + + default: + { + error_message = "invalid number; expected digit after exponent sign"; + return token_type::parse_error; + } + } + +scan_number_any2: + // we just parsed a number after the exponent or exponent sign + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any2; + } + + default: + goto scan_number_done; + } + +scan_number_done: + // unget the character after the number (we only read it to know that + // we are done scanning a number) + unget(); + + char* endptr = nullptr; + errno = 0; + + // try to parse integers first and fall back to floats + if (number_type == token_type::value_unsigned) + { + const auto x = std::strtoull(yytext.data(), &endptr, 10); + + // we checked the number format before + assert(endptr == yytext.data() + yytext.size()); + + if (errno == 0) + { + value_unsigned = static_cast(x); + if (value_unsigned == x) + { + return token_type::value_unsigned; + } + } + } + else if (number_type == token_type::value_integer) + { + const auto x = std::strtoll(yytext.data(), &endptr, 10); + + // we checked the number format before + assert(endptr == yytext.data() + yytext.size()); + + if (errno == 0) + { + value_integer = static_cast(x); + if (value_integer == x) + { + return token_type::value_integer; + } + } + } + + // this code is reached if we parse a floating-point number or if an + // integer conversion above failed + strtof(value_float, yytext.data(), &endptr); + + // we checked the number format before + assert(endptr == yytext.data() + yytext.size()); + + return token_type::value_float; + } + + /*! + @param[in] literal_text the literal text to expect + @param[in] length the length of the passed literal text + @param[in] return_type the token type to return on success + */ + token_type scan_literal(const char* literal_text, const std::size_t length, + token_type return_type) + { + assert(current == literal_text[0]); + for (std::size_t i = 1; i < length; ++i) + { + if (JSON_UNLIKELY(get() != literal_text[i])) + { + error_message = "invalid literal"; + return token_type::parse_error; + } + } + return return_type; + } + + ///////////////////// + // input management + ///////////////////// + + /// reset yytext; current character is beginning of token + void reset() noexcept + { + yytext.clear(); + token_string.clear(); + token_string.push_back(std::char_traits::to_char_type(current)); + } + + /* + @brief get next character from the input + + This function provides the interface to the used input adapter. It does + not throw in case the input reached EOF, but returns a + `std::char_traits::eof()` in that case. Stores the scanned characters + for use in error messages. + + @return character read from the input + */ + std::char_traits::int_type get() + { + ++chars_read; + current = ia->get_character(); + if (JSON_LIKELY(current != std::char_traits::eof())) + { + token_string.push_back(std::char_traits::to_char_type(current)); + } + return current; + } + + /// unget current character (return it again on next get) + void unget() + { + --chars_read; + if (JSON_LIKELY(current != std::char_traits::eof())) + { + ia->unget_character(); + assert(token_string.size() != 0); + token_string.pop_back(); + } + } + + /// add a character to yytext + void add(int c) + { + yytext.push_back(std::char_traits::to_char_type(c)); + } + + public: + ///////////////////// + // value getters + ///////////////////// + + /// return integer value + constexpr number_integer_t get_number_integer() const noexcept + { + return value_integer; + } + + /// return unsigned integer value + constexpr number_unsigned_t get_number_unsigned() const noexcept + { + return value_unsigned; + } + + /// return floating-point value + constexpr number_float_t get_number_float() const noexcept + { + return value_float; + } + + /// return current string value (implicitly resets the token; useful only once) + std::string move_string() + { + return std::move(yytext); + } + + ///////////////////// + // diagnostics + ///////////////////// + + /// return position of last read token + constexpr std::size_t get_position() const noexcept + { + return chars_read; + } + + /// return the last read token (for errors only). Will never contain EOF + /// (an arbitrary value that is not a valid char value, often -1), because + /// 255 may legitimately occur. May contain NUL, which should be escaped. + std::string get_token_string() const + { + // escape control characters + std::string result; + for (const auto c : token_string) + { + if ('\x00' <= c and c <= '\x1F') + { + // escape control characters + std::stringstream ss; + ss << "(c) << ">"; + result += ss.str(); + } + else + { + // add character as is + result.push_back(c); + } + } + + return result; + } + + /// return syntax error message + constexpr const char* get_error_message() const noexcept + { + return error_message; + } + + ///////////////////// + // actual scanner + ///////////////////// + + token_type scan() + { + // read next character and ignore whitespace + do + { + get(); + } + while (current == ' ' or current == '\t' or current == '\n' or current == '\r'); + + switch (current) + { + // structural characters + case '[': + return token_type::begin_array; + case ']': + return token_type::end_array; + case '{': + return token_type::begin_object; + case '}': + return token_type::end_object; + case ':': + return token_type::name_separator; + case ',': + return token_type::value_separator; + + // literals + case 't': + return scan_literal("true", 4, token_type::literal_true); + case 'f': + return scan_literal("false", 5, token_type::literal_false); + case 'n': + return scan_literal("null", 4, token_type::literal_null); + + // string + case '\"': + return scan_string(); + + // number + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return scan_number(); + + // end of input (the null byte is needed when parsing from + // string literals) + case '\0': + case std::char_traits::eof(): + return token_type::end_of_input; + + // error + default: + error_message = "invalid literal"; + return token_type::parse_error; + } + } + + private: + /// input adapter + detail::input_adapter_t ia = nullptr; + + /// the current character + std::char_traits::int_type current = std::char_traits::eof(); + + /// the number of characters read + std::size_t chars_read = 0; + + /// raw input token string (for error messages) + std::vector token_string {}; + + /// buffer for variable-length tokens (numbers, strings) + std::string yytext {}; + + /// a description of occurred lexer errors + const char* error_message = ""; + + // number values + number_integer_t value_integer = 0; + number_unsigned_t value_unsigned = 0; + number_float_t value_float = 0; + + /// the decimal point + const char decimal_point_char = '.'; +}; + +/*! +@brief syntax analysis + +This class implements a recursive decent parser. +*/ +template +class parser +{ + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using lexer_t = lexer; + using token_type = typename lexer_t::token_type; + + public: + enum class parse_event_t : uint8_t + { + /// the parser read `{` and started to process a JSON object + object_start, + /// the parser read `}` and finished processing a JSON object + object_end, + /// the parser read `[` and started to process a JSON array + array_start, + /// the parser read `]` and finished processing a JSON array + array_end, + /// the parser read a key of a value in an object + key, + /// the parser finished reading a JSON value + value + }; + + using parser_callback_t = + std::function; + + /// a parser reading from an input adapter + explicit parser(detail::input_adapter_t adapter, + const parser_callback_t cb = nullptr, + const bool allow_exceptions_ = true) + : callback(cb), m_lexer(adapter), allow_exceptions(allow_exceptions_) + {} + + /*! + @brief public parser interface + + @param[in] strict whether to expect the last token to be EOF + @param[in,out] result parsed JSON value + + @throw parse_error.101 in case of an unexpected token + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + */ + void parse(const bool strict, BasicJsonType& result) + { + // read first token + get_token(); + + parse_internal(true, result); + result.assert_invariant(); + + // in strict mode, input must be completely read + if (strict) + { + get_token(); + expect(token_type::end_of_input); + } + + // in case of an error, return discarded value + if (errored) + { + result = value_t::discarded; + return; + } + + // set top-level value to null if it was discarded by the callback + // function + if (result.is_discarded()) + { + result = nullptr; + } + } + + /*! + @brief public accept interface + + @param[in] strict whether to expect the last token to be EOF + @return whether the input is a proper JSON text + */ + bool accept(const bool strict = true) + { + // read first token + get_token(); + + if (not accept_internal()) + { + return false; + } + + // strict => last token must be EOF + return not strict or (get_token() == token_type::end_of_input); + } + + private: + /*! + @brief the actual parser + @throw parse_error.101 in case of an unexpected token + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + */ + void parse_internal(bool keep, BasicJsonType& result) + { + // never parse after a parse error was detected + assert(not errored); + + // start with a discarded value + if (not result.is_discarded()) + { + result.m_value.destroy(result.m_type); + result.m_type = value_t::discarded; + } + + switch (last_token) + { + case token_type::begin_object: + { + if (keep) + { + if (callback) + { + keep = callback(depth++, parse_event_t::object_start, result); + } + + if (not callback or keep) + { + // explicitly set result to object to cope with {} + result.m_type = value_t::object; + result.m_value = value_t::object; + } + } + + // read next token + get_token(); + + // closing } -> we are done + if (last_token == token_type::end_object) + { + if (keep and callback and not callback(--depth, parse_event_t::object_end, result)) + { + result.m_value.destroy(result.m_type); + result.m_type = value_t::discarded; + } + break; + } + + // parse values + std::string key; + BasicJsonType value; + while (true) + { + // store key + if (not expect(token_type::value_string)) + { + return; + } + key = m_lexer.move_string(); + + bool keep_tag = false; + if (keep) + { + if (callback) + { + BasicJsonType k(key); + keep_tag = callback(depth, parse_event_t::key, k); + } + else + { + keep_tag = true; + } + } + + // parse separator (:) + get_token(); + if (not expect(token_type::name_separator)) + { + return; + } + + // parse and add value + get_token(); + value.m_value.destroy(value.m_type); + value.m_type = value_t::discarded; + parse_internal(keep, value); + + if (JSON_UNLIKELY(errored)) + { + return; + } + + if (keep and keep_tag and not value.is_discarded()) + { + result.m_value.object->emplace(std::move(key), std::move(value)); + } + + // comma -> next value + get_token(); + if (last_token == token_type::value_separator) + { + get_token(); + continue; + } + + // closing } + if (not expect(token_type::end_object)) + { + return; + } + break; + } + + if (keep and callback and not callback(--depth, parse_event_t::object_end, result)) + { + result.m_value.destroy(result.m_type); + result.m_type = value_t::discarded; + } + break; + } + + case token_type::begin_array: + { + if (keep) + { + if (callback) + { + keep = callback(depth++, parse_event_t::array_start, result); + } + + if (not callback or keep) + { + // explicitly set result to array to cope with [] + result.m_type = value_t::array; + result.m_value = value_t::array; + } + } + + // read next token + get_token(); + + // closing ] -> we are done + if (last_token == token_type::end_array) + { + if (callback and not callback(--depth, parse_event_t::array_end, result)) + { + result.m_value.destroy(result.m_type); + result.m_type = value_t::discarded; + } + break; + } + + // parse values + BasicJsonType value; + while (true) + { + // parse value + value.m_value.destroy(value.m_type); + value.m_type = value_t::discarded; + parse_internal(keep, value); + + if (JSON_UNLIKELY(errored)) + { + return; + } + + if (keep and not value.is_discarded()) + { + result.m_value.array->push_back(std::move(value)); + } + + // comma -> next value + get_token(); + if (last_token == token_type::value_separator) + { + get_token(); + continue; + } + + // closing ] + if (not expect(token_type::end_array)) + { + return; + } + break; + } + + if (keep and callback and not callback(--depth, parse_event_t::array_end, result)) + { + result.m_value.destroy(result.m_type); + result.m_type = value_t::discarded; + } + break; + } + + case token_type::literal_null: + { + result.m_type = value_t::null; + break; + } + + case token_type::value_string: + { + result.m_type = value_t::string; + result.m_value = m_lexer.move_string(); + break; + } + + case token_type::literal_true: + { + result.m_type = value_t::boolean; + result.m_value = true; + break; + } + + case token_type::literal_false: + { + result.m_type = value_t::boolean; + result.m_value = false; + break; + } + + case token_type::value_unsigned: + { + result.m_type = value_t::number_unsigned; + result.m_value = m_lexer.get_number_unsigned(); + break; + } + + case token_type::value_integer: + { + result.m_type = value_t::number_integer; + result.m_value = m_lexer.get_number_integer(); + break; + } + + case token_type::value_float: + { + result.m_type = value_t::number_float; + result.m_value = m_lexer.get_number_float(); + + // throw in case of infinity or NAN + if (JSON_UNLIKELY(not std::isfinite(result.m_value.number_float))) + { + if (allow_exceptions) + { + JSON_THROW(out_of_range::create(406, "number overflow parsing '" + + m_lexer.get_token_string() + "'")); + } + expect(token_type::uninitialized); + } + break; + } + + case token_type::parse_error: + { + // using "uninitialized" to avoid "expected" message + if (not expect(token_type::uninitialized)) + { + return; + } + break; // LCOV_EXCL_LINE + } + + default: + { + // the last token was unexpected; we expected a value + if (not expect(token_type::literal_or_value)) + { + return; + } + break; // LCOV_EXCL_LINE + } + } + + if (keep and callback and not callback(depth, parse_event_t::value, result)) + { + result.m_type = value_t::discarded; + } + } + + /*! + @brief the actual acceptor + + @invariant 1. The last token is not yet processed. Therefore, the caller + of this function must make sure a token has been read. + 2. When this function returns, the last token is processed. + That is, the last read character was already considered. + + This invariant makes sure that no token needs to be "unput". + */ + bool accept_internal() + { + switch (last_token) + { + case token_type::begin_object: + { + // read next token + get_token(); + + // closing } -> we are done + if (last_token == token_type::end_object) + { + return true; + } + + // parse values + while (true) + { + // parse key + if (last_token != token_type::value_string) + { + return false; + } + + // parse separator (:) + get_token(); + if (last_token != token_type::name_separator) + { + return false; + } + + // parse value + get_token(); + if (not accept_internal()) + { + return false; + } + + // comma -> next value + get_token(); + if (last_token == token_type::value_separator) + { + get_token(); + continue; + } + + // closing } + return (last_token == token_type::end_object); + } + } + + case token_type::begin_array: + { + // read next token + get_token(); + + // closing ] -> we are done + if (last_token == token_type::end_array) + { + return true; + } + + // parse values + while (true) + { + // parse value + if (not accept_internal()) + { + return false; + } + + // comma -> next value + get_token(); + if (last_token == token_type::value_separator) + { + get_token(); + continue; + } + + // closing ] + return (last_token == token_type::end_array); + } + } + + case token_type::value_float: + { + // reject infinity or NAN + return std::isfinite(m_lexer.get_number_float()); + } + + case token_type::literal_false: + case token_type::literal_null: + case token_type::literal_true: + case token_type::value_integer: + case token_type::value_string: + case token_type::value_unsigned: + return true; + + default: // the last token was unexpected + return false; + } + } + + /// get next token from lexer + token_type get_token() + { + return (last_token = m_lexer.scan()); + } + + /*! + @throw parse_error.101 if expected token did not occur + */ + bool expect(token_type t) + { + if (JSON_UNLIKELY(t != last_token)) + { + errored = true; + expected = t; + if (allow_exceptions) + { + throw_exception(); + } + else + { + return false; + } + } + + return true; + } + + [[noreturn]] void throw_exception() const + { + std::string error_msg = "syntax error - "; + if (last_token == token_type::parse_error) + { + error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + + m_lexer.get_token_string() + "'"; + } + else + { + error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); + } + + if (expected != token_type::uninitialized) + { + error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); + } + + JSON_THROW(parse_error::create(101, m_lexer.get_position(), error_msg)); + } + + private: + /// current level of recursion + int depth = 0; + /// callback function + const parser_callback_t callback = nullptr; + /// the type of the last read token + token_type last_token = token_type::uninitialized; + /// the lexer + lexer_t m_lexer; + /// whether a syntax error occurred + bool errored = false; + /// possible reason for the syntax error + token_type expected = token_type::uninitialized; + /// whether to throw exceptions in case of errors + const bool allow_exceptions = true; +}; + +/////////////// +// iterators // +/////////////// + +/*! +@brief an iterator for primitive JSON types + +This class models an iterator for primitive JSON types (boolean, number, +string). It's only purpose is to allow the iterator/const_iterator classes +to "iterate" over primitive values. Internally, the iterator is modeled by +a `difference_type` variable. Value begin_value (`0`) models the begin, +end_value (`1`) models past the end. +*/ +class primitive_iterator_t +{ + public: + using difference_type = std::ptrdiff_t; + + constexpr difference_type get_value() const noexcept + { + return m_it; + } + + /// set iterator to a defined beginning + void set_begin() noexcept + { + m_it = begin_value; + } + + /// set iterator to a defined past the end + void set_end() noexcept + { + m_it = end_value; + } + + /// return whether the iterator can be dereferenced + constexpr bool is_begin() const noexcept + { + return m_it == begin_value; + } + + /// return whether the iterator is at end + constexpr bool is_end() const noexcept + { + return m_it == end_value; + } + + friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept + { + return lhs.m_it == rhs.m_it; + } + + friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept + { + return lhs.m_it < rhs.m_it; + } + + primitive_iterator_t operator+(difference_type i) + { + auto result = *this; + result += i; + return result; + } + + friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept + { + return lhs.m_it - rhs.m_it; + } + + friend std::ostream& operator<<(std::ostream& os, primitive_iterator_t it) + { + return os << it.m_it; + } + + primitive_iterator_t& operator++() + { + ++m_it; + return *this; + } + + primitive_iterator_t const operator++(int) + { + auto result = *this; + m_it++; + return result; + } + + primitive_iterator_t& operator--() + { + --m_it; + return *this; + } + + primitive_iterator_t const operator--(int) + { + auto result = *this; + m_it--; + return result; + } + + primitive_iterator_t& operator+=(difference_type n) + { + m_it += n; + return *this; + } + + primitive_iterator_t& operator-=(difference_type n) + { + m_it -= n; + return *this; + } + + private: + static constexpr difference_type begin_value = 0; + static constexpr difference_type end_value = begin_value + 1; + + /// iterator as signed integer type + difference_type m_it = (std::numeric_limits::min)(); +}; + +/*! +@brief an iterator value + +@note This structure could easily be a union, but MSVC currently does not allow +unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. +*/ +template struct internal_iterator +{ + /// iterator for JSON objects + typename BasicJsonType::object_t::iterator object_iterator {}; + /// iterator for JSON arrays + typename BasicJsonType::array_t::iterator array_iterator {}; + /// generic iterator for all other types + primitive_iterator_t primitive_iterator {}; +}; + +template class iteration_proxy; + +/*! +@brief a template for a bidirectional iterator for the @ref basic_json class + +This class implements a both iterators (iterator and const_iterator) for the +@ref basic_json class. + +@note An iterator is called *initialized* when a pointer to a JSON value has + been set (e.g., by a constructor or a copy assignment). If the iterator is + default-constructed, it is *uninitialized* and most methods are undefined. + **The library uses assertions to detect calls on uninitialized iterators.** + +@requirement The class satisfies the following concept requirements: +- +[BidirectionalIterator](http://en.cppreference.com/w/cpp/concept/BidirectionalIterator): + The iterator that can be moved can be moved in both directions (i.e. + incremented and decremented). + +@since version 1.0.0, simplified in version 2.0.9, change to bidirectional + iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) +*/ +template +class iter_impl +{ + /// allow basic_json to access private members + friend iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; + friend BasicJsonType; + friend iteration_proxy; + + using object_t = typename BasicJsonType::object_t; + using array_t = typename BasicJsonType::array_t; + // make sure BasicJsonType is basic_json or const basic_json + static_assert(is_basic_json::type>::value, + "iter_impl only accepts (const) basic_json"); + + public: + + /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. + /// The C++ Standard has never required user-defined iterators to derive from std::iterator. + /// A user-defined iterator should provide publicly accessible typedefs named + /// iterator_category, value_type, difference_type, pointer, and reference. + /// Note that value_type is required to be non-const, even for constant iterators. + using iterator_category = std::bidirectional_iterator_tag; + + /// the type of the values when the iterator is dereferenced + using value_type = typename BasicJsonType::value_type; + /// a type to represent differences between iterators + using difference_type = typename BasicJsonType::difference_type; + /// defines a pointer to the type iterated over (value_type) + using pointer = typename std::conditional::value, + typename BasicJsonType::const_pointer, + typename BasicJsonType::pointer>::type; + /// defines a reference to the type iterated over (value_type) + using reference = + typename std::conditional::value, + typename BasicJsonType::const_reference, + typename BasicJsonType::reference>::type; + + /// default constructor + iter_impl() = default; + + /*! + @brief constructor for a given JSON instance + @param[in] object pointer to a JSON object for this iterator + @pre object != nullptr + @post The iterator is initialized; i.e. `m_object != nullptr`. + */ + explicit iter_impl(pointer object) noexcept : m_object(object) + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + m_it.object_iterator = typename object_t::iterator(); + break; + } + + case value_t::array: + { + m_it.array_iterator = typename array_t::iterator(); + break; + } + + default: + { + m_it.primitive_iterator = primitive_iterator_t(); + break; + } + } + } + + /*! + @note The conventional copy constructor and copy assignment are implicitly + defined. Combined with the following converting constructor and + assignment, they support: (1) copy from iterator to iterator, (2) + copy from const iterator to const iterator, and (3) conversion from + iterator to const iterator. However conversion from const iterator + to iterator is not defined. + */ + + /*! + @brief converting constructor + @param[in] other non-const iterator to copy from + @note It is not checked whether @a other is initialized. + */ + iter_impl(const iter_impl::type>& other) noexcept + : m_object(other.m_object), m_it(other.m_it) {} + + /*! + @brief converting assignment + @param[in,out] other non-const iterator to copy from + @return const/non-const iterator + @note It is not checked whether @a other is initialized. + */ + iter_impl& operator=(const iter_impl::type>& other) noexcept + { + m_object = other.m_object; + m_it = other.m_it; + return *this; + } + + private: + /*! + @brief set the iterator to the first value + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + void set_begin() noexcept + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + m_it.object_iterator = m_object->m_value.object->begin(); + break; + } + + case value_t::array: + { + m_it.array_iterator = m_object->m_value.array->begin(); + break; + } + + case value_t::null: + { + // set to end so begin()==end() is true: null is empty + m_it.primitive_iterator.set_end(); + break; + } + + default: + { + m_it.primitive_iterator.set_begin(); + break; + } + } + } + + /*! + @brief set the iterator past the last value + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + void set_end() noexcept + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + m_it.object_iterator = m_object->m_value.object->end(); + break; + } + + case value_t::array: + { + m_it.array_iterator = m_object->m_value.array->end(); + break; + } + + default: + { + m_it.primitive_iterator.set_end(); + break; + } + } + } + + public: + /*! + @brief return a reference to the value pointed to by the iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + reference operator*() const + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + assert(m_it.object_iterator != m_object->m_value.object->end()); + return m_it.object_iterator->second; + } + + case value_t::array: + { + assert(m_it.array_iterator != m_object->m_value.array->end()); + return *m_it.array_iterator; + } + + case value_t::null: + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + + default: + { + if (JSON_LIKELY(m_it.primitive_iterator.is_begin())) + { + return *m_object; + } + + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + } + } + } + + /*! + @brief dereference the iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + pointer operator->() const + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + assert(m_it.object_iterator != m_object->m_value.object->end()); + return &(m_it.object_iterator->second); + } + + case value_t::array: + { + assert(m_it.array_iterator != m_object->m_value.array->end()); + return &*m_it.array_iterator; + } + + default: + { + if (JSON_LIKELY(m_it.primitive_iterator.is_begin())) + { + return m_object; + } + + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + } + } + } + + /*! + @brief post-increment (it++) + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl const operator++(int) + { + auto result = *this; + ++(*this); + return result; + } + + /*! + @brief pre-increment (++it) + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl& operator++() + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + std::advance(m_it.object_iterator, 1); + break; + } + + case value_t::array: + { + std::advance(m_it.array_iterator, 1); + break; + } + + default: + { + ++m_it.primitive_iterator; + break; + } + } + + return *this; + } + + /*! + @brief post-decrement (it--) + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl const operator--(int) + { + auto result = *this; + --(*this); + return result; + } + + /*! + @brief pre-decrement (--it) + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl& operator--() + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + std::advance(m_it.object_iterator, -1); + break; + } + + case value_t::array: + { + std::advance(m_it.array_iterator, -1); + break; + } + + default: + { + --m_it.primitive_iterator; + break; + } + } + + return *this; + } + + /*! + @brief comparison: equal + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator==(const iter_impl& other) const + { + // if objects are not the same, the comparison is undefined + if (JSON_UNLIKELY(m_object != other.m_object)) + { + JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); + } + + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + return (m_it.object_iterator == other.m_it.object_iterator); + + case value_t::array: + return (m_it.array_iterator == other.m_it.array_iterator); + + default: + return (m_it.primitive_iterator == other.m_it.primitive_iterator); + } + } + + /*! + @brief comparison: not equal + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator!=(const iter_impl& other) const + { + return not operator==(other); + } + + /*! + @brief comparison: smaller + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator<(const iter_impl& other) const + { + // if objects are not the same, the comparison is undefined + if (JSON_UNLIKELY(m_object != other.m_object)) + { + JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); + } + + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators")); + + case value_t::array: + return (m_it.array_iterator < other.m_it.array_iterator); + + default: + return (m_it.primitive_iterator < other.m_it.primitive_iterator); + } + } + + /*! + @brief comparison: less than or equal + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator<=(const iter_impl& other) const + { + return not other.operator < (*this); + } + + /*! + @brief comparison: greater than + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator>(const iter_impl& other) const + { + return not operator<=(other); + } + + /*! + @brief comparison: greater than or equal + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator>=(const iter_impl& other) const + { + return not operator<(other); + } + + /*! + @brief add to iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl& operator+=(difference_type i) + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators")); + + case value_t::array: + { + std::advance(m_it.array_iterator, i); + break; + } + + default: + { + m_it.primitive_iterator += i; + break; + } + } + + return *this; + } + + /*! + @brief subtract from iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl& operator-=(difference_type i) + { + return operator+=(-i); + } + + /*! + @brief add to iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl operator+(difference_type i) const + { + auto result = *this; + result += i; + return result; + } + + /*! + @brief addition of distance and iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + friend iter_impl operator+(difference_type i, const iter_impl& it) + { + auto result = it; + result += i; + return result; + } + + /*! + @brief subtract from iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl operator-(difference_type i) const + { + auto result = *this; + result -= i; + return result; + } + + /*! + @brief return difference + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + difference_type operator-(const iter_impl& other) const + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators")); + + case value_t::array: + return m_it.array_iterator - other.m_it.array_iterator; + + default: + return m_it.primitive_iterator - other.m_it.primitive_iterator; + } + } + + /*! + @brief access to successor + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + reference operator[](difference_type n) const + { + assert(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators")); + + case value_t::array: + return *std::next(m_it.array_iterator, n); + + case value_t::null: + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + + default: + { + if (JSON_LIKELY(m_it.primitive_iterator.get_value() == -n)) + { + return *m_object; + } + + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + } + } + } + + /*! + @brief return the key of an object iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + typename object_t::key_type key() const + { + assert(m_object != nullptr); + + if (JSON_LIKELY(m_object->is_object())) + { + return m_it.object_iterator->first; + } + + JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators")); + } + + /*! + @brief return the value of an iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + reference value() const + { + return operator*(); + } + + private: + /// associated JSON instance + pointer m_object = nullptr; + /// the actual iterator of the associated instance + internal_iterator::type> m_it = {}; +}; + +/// proxy class for the iterator_wrapper functions +template class iteration_proxy +{ + private: + /// helper class for iteration + class iteration_proxy_internal + { + private: + /// the iterator + IteratorType anchor; + /// an index for arrays (used to create key names) + std::size_t array_index = 0; + + public: + explicit iteration_proxy_internal(IteratorType it) noexcept : anchor(it) {} + + /// dereference operator (needed for range-based for) + iteration_proxy_internal& operator*() + { + return *this; + } + + /// increment operator (needed for range-based for) + iteration_proxy_internal& operator++() + { + ++anchor; + ++array_index; + + return *this; + } + + /// inequality operator (needed for range-based for) + bool operator!=(const iteration_proxy_internal& o) const noexcept + { + return anchor != o.anchor; + } + + /// return key of the iterator + std::string key() const + { + assert(anchor.m_object != nullptr); + + switch (anchor.m_object->type()) + { + // use integer array index as key + case value_t::array: + return std::to_string(array_index); + + // use key from the object + case value_t::object: + return anchor.key(); + + // use an empty key for all primitive types + default: + return ""; + } + } + + /// return value of the iterator + typename IteratorType::reference value() const + { + return anchor.value(); + } + }; + + /// the container to iterate + typename IteratorType::reference container; + + public: + /// construct iteration proxy from a container + explicit iteration_proxy(typename IteratorType::reference cont) + : container(cont) {} + + /// return iterator begin (needed for range-based for) + iteration_proxy_internal begin() noexcept + { + return iteration_proxy_internal(container.begin()); + } + + /// return iterator end (needed for range-based for) + iteration_proxy_internal end() noexcept + { + return iteration_proxy_internal(container.end()); + } +}; + +/*! +@brief a template for a reverse iterator class + +@tparam Base the base iterator type to reverse. Valid types are @ref +iterator (to create @ref reverse_iterator) and @ref const_iterator (to +create @ref const_reverse_iterator). + +@requirement The class satisfies the following concept requirements: +- +[BidirectionalIterator](http://en.cppreference.com/w/cpp/concept/BidirectionalIterator): + The iterator that can be moved can be moved in both directions (i.e. + incremented and decremented). +- [OutputIterator](http://en.cppreference.com/w/cpp/concept/OutputIterator): + It is possible to write to the pointed-to element (only if @a Base is + @ref iterator). + +@since version 1.0.0 +*/ +template +class json_reverse_iterator : public std::reverse_iterator +{ + public: + using difference_type = std::ptrdiff_t; + /// shortcut to the reverse iterator adapter + using base_iterator = std::reverse_iterator; + /// the reference type for the pointed-to element + using reference = typename Base::reference; + + /// create reverse iterator from iterator + json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept + : base_iterator(it) {} + + /// create reverse iterator from base class + json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} + + /// post-increment (it++) + json_reverse_iterator const operator++(int) + { + return static_cast(base_iterator::operator++(1)); + } + + /// pre-increment (++it) + json_reverse_iterator& operator++() + { + return static_cast(base_iterator::operator++()); + } + + /// post-decrement (it--) + json_reverse_iterator const operator--(int) + { + return static_cast(base_iterator::operator--(1)); + } + + /// pre-decrement (--it) + json_reverse_iterator& operator--() + { + return static_cast(base_iterator::operator--()); + } + + /// add to iterator + json_reverse_iterator& operator+=(difference_type i) + { + return static_cast(base_iterator::operator+=(i)); + } + + /// add to iterator + json_reverse_iterator operator+(difference_type i) const + { + return static_cast(base_iterator::operator+(i)); + } + + /// subtract from iterator + json_reverse_iterator operator-(difference_type i) const + { + return static_cast(base_iterator::operator-(i)); + } + + /// return difference + difference_type operator-(const json_reverse_iterator& other) const + { + return base_iterator(*this) - base_iterator(other); + } + + /// access to successor + reference operator[](difference_type n) const + { + return *(this->operator+(n)); + } + + /// return the key of an object iterator + auto key() const -> decltype(std::declval().key()) + { + auto it = --this->base(); + return it.key(); + } + + /// return the value of an iterator + reference value() const + { + auto it = --this->base(); + return it.operator * (); + } +}; + +///////////////////// +// output adapters // +///////////////////// + +/// abstract output adapter interface +template struct output_adapter_protocol +{ + virtual void write_character(CharType c) = 0; + virtual void write_characters(const CharType* s, std::size_t length) = 0; + virtual ~output_adapter_protocol() = default; +}; + +/// a type to simplify interfaces +template +using output_adapter_t = std::shared_ptr>; + +/// output adapter for byte vectors +template +class output_vector_adapter : public output_adapter_protocol +{ + public: + explicit output_vector_adapter(std::vector& vec) : v(vec) {} + + void write_character(CharType c) override + { + v.push_back(c); + } + + void write_characters(const CharType* s, std::size_t length) override + { + std::copy(s, s + length, std::back_inserter(v)); + } + + private: + std::vector& v; +}; + +/// output adapter for output streams +template +class output_stream_adapter : public output_adapter_protocol +{ + public: + explicit output_stream_adapter(std::basic_ostream& s) : stream(s) {} + + void write_character(CharType c) override + { + stream.put(c); + } + + void write_characters(const CharType* s, std::size_t length) override + { + stream.write(s, static_cast(length)); + } + + private: + std::basic_ostream& stream; +}; + +/// output adapter for basic_string +template +class output_string_adapter : public output_adapter_protocol +{ + public: + explicit output_string_adapter(std::basic_string& s) : str(s) {} + + void write_character(CharType c) override + { + str.push_back(c); + } + + void write_characters(const CharType* s, std::size_t length) override + { + str.append(s, length); + } + + private: + std::basic_string& str; +}; + +template +class output_adapter +{ + public: + output_adapter(std::vector& vec) + : oa(std::make_shared>(vec)) {} + + output_adapter(std::basic_ostream& s) + : oa(std::make_shared>(s)) {} + + output_adapter(std::basic_string& s) + : oa(std::make_shared>(s)) {} + + operator output_adapter_t() + { + return oa; + } + + private: + output_adapter_t oa = nullptr; +}; + +////////////////////////////// +// binary reader and writer // +////////////////////////////// + +/*! +@brief deserialization of CBOR and MessagePack values +*/ +template +class binary_reader +{ + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + + public: + /*! + @brief create a binary reader + + @param[in] adapter input adapter to read from + */ + explicit binary_reader(input_adapter_t adapter) : ia(std::move(adapter)) + { + assert(ia); + } + + /*! + @brief create a JSON value from CBOR input + + @param[in] strict whether to expect the input to be consumed completed + @return JSON value created from CBOR input + + @throw parse_error.110 if input ended unexpectedly or the end of file was + not reached when @a strict was set to true + @throw parse_error.112 if unsupported byte was read + */ + BasicJsonType parse_cbor(const bool strict) + { + const auto res = parse_cbor_internal(); + if (strict) + { + get(); + check_eof(true); + } + return res; + } + + /*! + @brief create a JSON value from MessagePack input + + @param[in] strict whether to expect the input to be consumed completed + @return JSON value created from MessagePack input + + @throw parse_error.110 if input ended unexpectedly or the end of file was + not reached when @a strict was set to true + @throw parse_error.112 if unsupported byte was read + */ + BasicJsonType parse_msgpack(const bool strict) + { + const auto res = parse_msgpack_internal(); + if (strict) + { + get(); + check_eof(true); + } + return res; + } + + /*! + @brief determine system byte order + + @return true if and only if system's byte order is little endian + + @note from http://stackoverflow.com/a/1001328/266378 + */ + static constexpr bool little_endianess(int num = 1) noexcept + { + return (*reinterpret_cast(&num) == 1); + } + + private: + /*! + @param[in] get_char whether a new character should be retrieved from the + input (true, default) or whether the last read + character should be considered instead + */ + BasicJsonType parse_cbor_internal(const bool get_char = true) + { + switch (get_char ? get() : current) + { + // EOF + case std::char_traits::eof(): + JSON_THROW(parse_error::create(110, chars_read, "unexpected end of input")); + + // Integer 0x00..0x17 (0..23) + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + return static_cast(current); + + case 0x18: // Unsigned integer (one-byte uint8_t follows) + return get_number(); + + case 0x19: // Unsigned integer (two-byte uint16_t follows) + return get_number(); + + case 0x1A: // Unsigned integer (four-byte uint32_t follows) + return get_number(); + + case 0x1B: // Unsigned integer (eight-byte uint64_t follows) + return get_number(); + + // Negative integer -1-0x00..-1-0x17 (-1..-24) + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + return static_cast(0x20 - 1 - current); + + case 0x38: // Negative integer (one-byte uint8_t follows) + { + // must be uint8_t ! + return static_cast(-1) - get_number(); + } + + case 0x39: // Negative integer -1-n (two-byte uint16_t follows) + { + return static_cast(-1) - get_number(); + } + + case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) + { + return static_cast(-1) - get_number(); + } + + case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) + { + return static_cast(-1) - + static_cast(get_number()); + } + + // UTF-8 string (0x00..0x17 bytes follow) + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: // UTF-8 string (one-byte uint8_t for n follows) + case 0x79: // UTF-8 string (two-byte uint16_t for n follow) + case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) + case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) + case 0x7F: // UTF-8 string (indefinite length) + { + return get_cbor_string(); + } + + // array (0x00..0x17 data items follow) + case 0x80: + case 0x81: + case 0x82: + case 0x83: + case 0x84: + case 0x85: + case 0x86: + case 0x87: + case 0x88: + case 0x89: + case 0x8A: + case 0x8B: + case 0x8C: + case 0x8D: + case 0x8E: + case 0x8F: + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + { + return get_cbor_array(current & 0x1F); + } + + case 0x98: // array (one-byte uint8_t for n follows) + { + return get_cbor_array(get_number()); + } + + case 0x99: // array (two-byte uint16_t for n follow) + { + return get_cbor_array(get_number()); + } + + case 0x9A: // array (four-byte uint32_t for n follow) + { + return get_cbor_array(get_number()); + } + + case 0x9B: // array (eight-byte uint64_t for n follow) + { + return get_cbor_array(get_number()); + } + + case 0x9F: // array (indefinite length) + { + BasicJsonType result = value_t::array; + while (get() != 0xFF) + { + result.push_back(parse_cbor_internal(false)); + } + return result; + } + + // map (0x00..0x17 pairs of data items follow) + case 0xA0: + case 0xA1: + case 0xA2: + case 0xA3: + case 0xA4: + case 0xA5: + case 0xA6: + case 0xA7: + case 0xA8: + case 0xA9: + case 0xAA: + case 0xAB: + case 0xAC: + case 0xAD: + case 0xAE: + case 0xAF: + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + { + return get_cbor_object(current & 0x1F); + } + + case 0xB8: // map (one-byte uint8_t for n follows) + { + return get_cbor_object(get_number()); + } + + case 0xB9: // map (two-byte uint16_t for n follow) + { + return get_cbor_object(get_number()); + } + + case 0xBA: // map (four-byte uint32_t for n follow) + { + return get_cbor_object(get_number()); + } + + case 0xBB: // map (eight-byte uint64_t for n follow) + { + return get_cbor_object(get_number()); + } + + case 0xBF: // map (indefinite length) + { + BasicJsonType result = value_t::object; + while (get() != 0xFF) + { + auto key = get_cbor_string(); + result[key] = parse_cbor_internal(); + } + return result; + } + + case 0xF4: // false + { + return false; + } + + case 0xF5: // true + { + return true; + } + + case 0xF6: // null + { + return value_t::null; + } + + case 0xF9: // Half-Precision Float (two-byte IEEE 754) + { + const int byte1 = get(); + check_eof(); + const int byte2 = get(); + check_eof(); + + // code from RFC 7049, Appendix D, Figure 3: + // As half-precision floating-point numbers were only added + // to IEEE 754 in 2008, today's programming platforms often + // still only have limited support for them. It is very + // easy to include at least decoding support for them even + // without such support. An example of a small decoder for + // half-precision floating-point numbers in the C language + // is shown in Fig. 3. + const int half = (byte1 << 8) + byte2; + const int exp = (half >> 10) & 0x1F; + const int mant = half & 0x3FF; + double val; + if (exp == 0) + { + val = std::ldexp(mant, -24); + } + else if (exp != 31) + { + val = std::ldexp(mant + 1024, exp - 25); + } + else + { + val = (mant == 0) ? std::numeric_limits::infinity() + : std::numeric_limits::quiet_NaN(); + } + return (half & 0x8000) != 0 ? -val : val; + } + + case 0xFA: // Single-Precision Float (four-byte IEEE 754) + { + return get_number(); + } + + case 0xFB: // Double-Precision Float (eight-byte IEEE 754) + { + return get_number(); + } + + default: // anything else (0xFF is handled inside the other types) + { + std::stringstream ss; + ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current; + JSON_THROW(parse_error::create(112, chars_read, "error reading CBOR; last byte: 0x" + ss.str())); + } + } + } + + BasicJsonType parse_msgpack_internal() + { + switch (get()) + { + // EOF + case std::char_traits::eof(): + JSON_THROW(parse_error::create(110, chars_read, "unexpected end of input")); + + // positive fixint + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x59: + case 0x5A: + case 0x5B: + case 0x5C: + case 0x5D: + case 0x5E: + case 0x5F: + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: + case 0x79: + case 0x7A: + case 0x7B: + case 0x7C: + case 0x7D: + case 0x7E: + case 0x7F: + return static_cast(current); + + // fixmap + case 0x80: + case 0x81: + case 0x82: + case 0x83: + case 0x84: + case 0x85: + case 0x86: + case 0x87: + case 0x88: + case 0x89: + case 0x8A: + case 0x8B: + case 0x8C: + case 0x8D: + case 0x8E: + case 0x8F: + { + return get_msgpack_object(current & 0x0F); + } + + // fixarray + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + case 0x98: + case 0x99: + case 0x9A: + case 0x9B: + case 0x9C: + case 0x9D: + case 0x9E: + case 0x9F: + { + return get_msgpack_array(current & 0x0F); + } + + // fixstr + case 0xA0: + case 0xA1: + case 0xA2: + case 0xA3: + case 0xA4: + case 0xA5: + case 0xA6: + case 0xA7: + case 0xA8: + case 0xA9: + case 0xAA: + case 0xAB: + case 0xAC: + case 0xAD: + case 0xAE: + case 0xAF: + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + case 0xB8: + case 0xB9: + case 0xBA: + case 0xBB: + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + return get_msgpack_string(); + + case 0xC0: // nil + return value_t::null; + + case 0xC2: // false + return false; + + case 0xC3: // true + return true; + + case 0xCA: // float 32 + return get_number(); + + case 0xCB: // float 64 + return get_number(); + + case 0xCC: // uint 8 + return get_number(); + + case 0xCD: // uint 16 + return get_number(); + + case 0xCE: // uint 32 + return get_number(); + + case 0xCF: // uint 64 + return get_number(); + + case 0xD0: // int 8 + return get_number(); + + case 0xD1: // int 16 + return get_number(); + + case 0xD2: // int 32 + return get_number(); + + case 0xD3: // int 64 + return get_number(); + + case 0xD9: // str 8 + case 0xDA: // str 16 + case 0xDB: // str 32 + return get_msgpack_string(); + + case 0xDC: // array 16 + { + return get_msgpack_array(get_number()); + } + + case 0xDD: // array 32 + { + return get_msgpack_array(get_number()); + } + + case 0xDE: // map 16 + { + return get_msgpack_object(get_number()); + } + + case 0xDF: // map 32 + { + return get_msgpack_object(get_number()); + } + + // positive fixint + case 0xE0: + case 0xE1: + case 0xE2: + case 0xE3: + case 0xE4: + case 0xE5: + case 0xE6: + case 0xE7: + case 0xE8: + case 0xE9: + case 0xEA: + case 0xEB: + case 0xEC: + case 0xED: + case 0xEE: + case 0xEF: + case 0xF0: + case 0xF1: + case 0xF2: + case 0xF3: + case 0xF4: + case 0xF5: + case 0xF6: + case 0xF7: + case 0xF8: + case 0xF9: + case 0xFA: + case 0xFB: + case 0xFC: + case 0xFD: + case 0xFE: + case 0xFF: + return static_cast(current); + + default: // anything else + { + std::stringstream ss; + ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current; + JSON_THROW(parse_error::create(112, chars_read, + "error reading MessagePack; last byte: 0x" + ss.str())); + } + } + } + + /*! + @brief get next character from the input + + This function provides the interface to the used input adapter. It does + not throw in case the input reached EOF, but returns a -'ve valued + `std::char_traits::eof()` in that case. + + @return character read from the input + */ + int get() + { + ++chars_read; + return (current = ia->get_character()); + } + + /* + @brief read a number from the input + + @tparam NumberType the type of the number + + @return number of type @a NumberType + + @note This function needs to respect the system's endianess, because + bytes in CBOR and MessagePack are stored in network order (big + endian) and therefore need reordering on little endian systems. + + @throw parse_error.110 if input has less than `sizeof(NumberType)` bytes + */ + template NumberType get_number() + { + // step 1: read input into array with system's byte order + std::array vec; + for (std::size_t i = 0; i < sizeof(NumberType); ++i) + { + get(); + check_eof(); + + // reverse byte order prior to conversion if necessary + if (is_little_endian) + { + vec[sizeof(NumberType) - i - 1] = static_cast(current); + } + else + { + vec[i] = static_cast(current); // LCOV_EXCL_LINE + } + } + + // step 2: convert array into number of type T and return + NumberType result; + std::memcpy(&result, vec.data(), sizeof(NumberType)); + return result; + } + + /*! + @brief create a string by reading characters from the input + + @param[in] len number of bytes to read + + @note We can not reserve @a len bytes for the result, because @a len + may be too large. Usually, @ref check_eof() detects the end of + the input before we run out of string memory. + + @return string created by reading @a len bytes + + @throw parse_error.110 if input has less than @a len bytes + */ + template + std::string get_string(const NumberType len) + { + std::string result; + std::generate_n(std::back_inserter(result), len, [this]() + { + get(); + check_eof(); + return static_cast(current); + }); + return result; + } + + /*! + @brief reads a CBOR string + + This function first reads starting bytes to determine the expected + string length and then copies this number of bytes into a string. + Additionally, CBOR's strings with indefinite lengths are supported. + + @return string + + @throw parse_error.110 if input ended + @throw parse_error.113 if an unexpected byte is read + */ + std::string get_cbor_string() + { + check_eof(); + + switch (current) + { + // UTF-8 string (0x00..0x17 bytes follow) + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + { + return get_string(current & 0x1F); + } + + case 0x78: // UTF-8 string (one-byte uint8_t for n follows) + { + return get_string(get_number()); + } + + case 0x79: // UTF-8 string (two-byte uint16_t for n follow) + { + return get_string(get_number()); + } + + case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) + { + return get_string(get_number()); + } + + case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) + { + return get_string(get_number()); + } + + case 0x7F: // UTF-8 string (indefinite length) + { + std::string result; + while (get() != 0xFF) + { + check_eof(); + result.push_back(static_cast(current)); + } + return result; + } + + default: + { + std::stringstream ss; + ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current; + JSON_THROW(parse_error::create(113, chars_read, "expected a CBOR string; last byte: 0x" + ss.str())); + } + } + } + + template + BasicJsonType get_cbor_array(const NumberType len) + { + BasicJsonType result = value_t::array; + std::generate_n(std::back_inserter(*result.m_value.array), len, [this]() + { + return parse_cbor_internal(); + }); + return result; + } + + template + BasicJsonType get_cbor_object(const NumberType len) + { + BasicJsonType result = value_t::object; + std::generate_n(std::inserter(*result.m_value.object, + result.m_value.object->end()), + len, [this]() + { + get(); + auto key = get_cbor_string(); + auto val = parse_cbor_internal(); + return std::make_pair(std::move(key), std::move(val)); + }); + return result; + } + + /*! + @brief reads a MessagePack string + + This function first reads starting bytes to determine the expected + string length and then copies this number of bytes into a string. + + @return string + + @throw parse_error.110 if input ended + @throw parse_error.113 if an unexpected byte is read + */ + std::string get_msgpack_string() + { + check_eof(); + + switch (current) + { + // fixstr + case 0xA0: + case 0xA1: + case 0xA2: + case 0xA3: + case 0xA4: + case 0xA5: + case 0xA6: + case 0xA7: + case 0xA8: + case 0xA9: + case 0xAA: + case 0xAB: + case 0xAC: + case 0xAD: + case 0xAE: + case 0xAF: + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + case 0xB8: + case 0xB9: + case 0xBA: + case 0xBB: + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + { + return get_string(current & 0x1F); + } + + case 0xD9: // str 8 + { + return get_string(get_number()); + } + + case 0xDA: // str 16 + { + return get_string(get_number()); + } + + case 0xDB: // str 32 + { + return get_string(get_number()); + } + + default: + { + std::stringstream ss; + ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current; + JSON_THROW(parse_error::create(113, chars_read, + "expected a MessagePack string; last byte: 0x" + ss.str())); + } + } + } + + template + BasicJsonType get_msgpack_array(const NumberType len) + { + BasicJsonType result = value_t::array; + std::generate_n(std::back_inserter(*result.m_value.array), len, [this]() + { + return parse_msgpack_internal(); + }); + return result; + } + + template + BasicJsonType get_msgpack_object(const NumberType len) + { + BasicJsonType result = value_t::object; + std::generate_n(std::inserter(*result.m_value.object, + result.m_value.object->end()), + len, [this]() + { + get(); + auto key = get_msgpack_string(); + auto val = parse_msgpack_internal(); + return std::make_pair(std::move(key), std::move(val)); + }); + return result; + } + + /*! + @brief check if input ended + @throw parse_error.110 if input ended + */ + void check_eof(const bool expect_eof = false) const + { + if (expect_eof) + { + if (JSON_UNLIKELY(current != std::char_traits::eof())) + { + JSON_THROW(parse_error::create(110, chars_read, "expected end of input")); + } + } + else + { + if (JSON_UNLIKELY(current == std::char_traits::eof())) + { + JSON_THROW(parse_error::create(110, chars_read, "unexpected end of input")); + } + } + } + + private: + /// input adapter + input_adapter_t ia = nullptr; + + /// the current character + int current = std::char_traits::eof(); + + /// the number of characters read + std::size_t chars_read = 0; + + /// whether we can assume little endianess + const bool is_little_endian = little_endianess(); +}; + +/*! +@brief serialization to CBOR and MessagePack values +*/ +template +class binary_writer +{ + public: + /*! + @brief create a binary writer + + @param[in] adapter output adapter to write to + */ + explicit binary_writer(output_adapter_t adapter) : oa(adapter) + { + assert(oa); + } + + /*! + @brief[in] j JSON value to serialize + */ + void write_cbor(const BasicJsonType& j) + { + switch (j.type()) + { + case value_t::null: + { + oa->write_character(static_cast(0xF6)); + break; + } + + case value_t::boolean: + { + oa->write_character(j.m_value.boolean + ? static_cast(0xF5) + : static_cast(0xF4)); + break; + } + + case value_t::number_integer: + { + if (j.m_value.number_integer >= 0) + { + // CBOR does not differentiate between positive signed + // integers and unsigned integers. Therefore, we used the + // code from the value_t::number_unsigned case here. + if (j.m_value.number_integer <= 0x17) + { + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer <= (std::numeric_limits::max)()) + { + oa->write_character(static_cast(0x18)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer <= (std::numeric_limits::max)()) + { + oa->write_character(static_cast(0x19)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer <= (std::numeric_limits::max)()) + { + oa->write_character(static_cast(0x1A)); + write_number(static_cast(j.m_value.number_integer)); + } + else + { + oa->write_character(static_cast(0x1B)); + write_number(static_cast(j.m_value.number_integer)); + } + } + else + { + // The conversions below encode the sign in the first + // byte, and the value is converted to a positive number. + const auto positive_number = -1 - j.m_value.number_integer; + if (j.m_value.number_integer >= -24) + { + write_number(static_cast(0x20 + positive_number)); + } + else if (positive_number <= (std::numeric_limits::max)()) + { + oa->write_character(static_cast(0x38)); + write_number(static_cast(positive_number)); + } + else if (positive_number <= (std::numeric_limits::max)()) + { + oa->write_character(static_cast(0x39)); + write_number(static_cast(positive_number)); + } + else if (positive_number <= (std::numeric_limits::max)()) + { + oa->write_character(static_cast(0x3A)); + write_number(static_cast(positive_number)); + } + else + { + oa->write_character(static_cast(0x3B)); + write_number(static_cast(positive_number)); + } + } + break; + } + + case value_t::number_unsigned: + { + if (j.m_value.number_unsigned <= 0x17) + { + write_number(static_cast(j.m_value.number_unsigned)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + oa->write_character(static_cast(0x18)); + write_number(static_cast(j.m_value.number_unsigned)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + oa->write_character(static_cast(0x19)); + write_number(static_cast(j.m_value.number_unsigned)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + oa->write_character(static_cast(0x1A)); + write_number(static_cast(j.m_value.number_unsigned)); + } + else + { + oa->write_character(static_cast(0x1B)); + write_number(static_cast(j.m_value.number_unsigned)); + } + break; + } + + case value_t::number_float: // Double-Precision Float + { + oa->write_character(static_cast(0xFB)); + write_number(j.m_value.number_float); + break; + } + + case value_t::string: + { + // step 1: write control byte and the string length + const auto N = j.m_value.string->size(); + if (N <= 0x17) + { + write_number(static_cast(0x60 + N)); + } + else if (N <= 0xFF) + { + oa->write_character(static_cast(0x78)); + write_number(static_cast(N)); + } + else if (N <= 0xFFFF) + { + oa->write_character(static_cast(0x79)); + write_number(static_cast(N)); + } + else if (N <= 0xFFFFFFFF) + { + oa->write_character(static_cast(0x7A)); + write_number(static_cast(N)); + } + // LCOV_EXCL_START + else if (N <= 0xFFFFFFFFFFFFFFFF) + { + oa->write_character(static_cast(0x7B)); + write_number(static_cast(N)); + } + // LCOV_EXCL_STOP + + // step 2: write the string + oa->write_characters( + reinterpret_cast(j.m_value.string->c_str()), + j.m_value.string->size()); + break; + } + + case value_t::array: + { + // step 1: write control byte and the array size + const auto N = j.m_value.array->size(); + if (N <= 0x17) + { + write_number(static_cast(0x80 + N)); + } + else if (N <= 0xFF) + { + oa->write_character(static_cast(0x98)); + write_number(static_cast(N)); + } + else if (N <= 0xFFFF) + { + oa->write_character(static_cast(0x99)); + write_number(static_cast(N)); + } + else if (N <= 0xFFFFFFFF) + { + oa->write_character(static_cast(0x9A)); + write_number(static_cast(N)); + } + // LCOV_EXCL_START + else if (N <= 0xFFFFFFFFFFFFFFFF) + { + oa->write_character(static_cast(0x9B)); + write_number(static_cast(N)); + } + // LCOV_EXCL_STOP + + // step 2: write each element + for (const auto& el : *j.m_value.array) + { + write_cbor(el); + } + break; + } + + case value_t::object: + { + // step 1: write control byte and the object size + const auto N = j.m_value.object->size(); + if (N <= 0x17) + { + write_number(static_cast(0xA0 + N)); + } + else if (N <= 0xFF) + { + oa->write_character(static_cast(0xB8)); + write_number(static_cast(N)); + } + else if (N <= 0xFFFF) + { + oa->write_character(static_cast(0xB9)); + write_number(static_cast(N)); + } + else if (N <= 0xFFFFFFFF) + { + oa->write_character(static_cast(0xBA)); + write_number(static_cast(N)); + } + // LCOV_EXCL_START + else if (N <= 0xFFFFFFFFFFFFFFFF) + { + oa->write_character(static_cast(0xBB)); + write_number(static_cast(N)); + } + // LCOV_EXCL_STOP + + // step 2: write each element + for (const auto& el : *j.m_value.object) + { + write_cbor(el.first); + write_cbor(el.second); + } + break; + } + + default: + break; + } + } + + /*! + @brief[in] j JSON value to serialize + */ + void write_msgpack(const BasicJsonType& j) + { + switch (j.type()) + { + case value_t::null: // nil + { + oa->write_character(static_cast(0xC0)); + break; + } + + case value_t::boolean: // true and false + { + oa->write_character(j.m_value.boolean + ? static_cast(0xC3) + : static_cast(0xC2)); + break; + } + + case value_t::number_integer: + { + if (j.m_value.number_integer >= 0) + { + // MessagePack does not differentiate between positive + // signed integers and unsigned integers. Therefore, we used + // the code from the value_t::number_unsigned case here. + if (j.m_value.number_unsigned < 128) + { + // positive fixnum + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 8 + oa->write_character(static_cast(0xCC)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 16 + oa->write_character(static_cast(0xCD)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 32 + oa->write_character(static_cast(0xCE)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 64 + oa->write_character(static_cast(0xCF)); + write_number(static_cast(j.m_value.number_integer)); + } + } + else + { + if (j.m_value.number_integer >= -32) + { + // negative fixnum + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer >= (std::numeric_limits::min)() and + j.m_value.number_integer <= (std::numeric_limits::max)()) + { + // int 8 + oa->write_character(static_cast(0xD0)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer >= (std::numeric_limits::min)() and + j.m_value.number_integer <= (std::numeric_limits::max)()) + { + // int 16 + oa->write_character(static_cast(0xD1)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer >= (std::numeric_limits::min)() and + j.m_value.number_integer <= (std::numeric_limits::max)()) + { + // int 32 + oa->write_character(static_cast(0xD2)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer >= (std::numeric_limits::min)() and + j.m_value.number_integer <= (std::numeric_limits::max)()) + { + // int 64 + oa->write_character(static_cast(0xD3)); + write_number(static_cast(j.m_value.number_integer)); + } + } + break; + } + + case value_t::number_unsigned: + { + if (j.m_value.number_unsigned < 128) + { + // positive fixnum + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 8 + oa->write_character(static_cast(0xCC)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 16 + oa->write_character(static_cast(0xCD)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 32 + oa->write_character(static_cast(0xCE)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 64 + oa->write_character(static_cast(0xCF)); + write_number(static_cast(j.m_value.number_integer)); + } + break; + } + + case value_t::number_float: // float 64 + { + oa->write_character(static_cast(0xCB)); + write_number(j.m_value.number_float); + break; + } + + case value_t::string: + { + // step 1: write control byte and the string length + const auto N = j.m_value.string->size(); + if (N <= 31) + { + // fixstr + write_number(static_cast(0xA0 | N)); + } + else if (N <= 255) + { + // str 8 + oa->write_character(static_cast(0xD9)); + write_number(static_cast(N)); + } + else if (N <= 65535) + { + // str 16 + oa->write_character(static_cast(0xDA)); + write_number(static_cast(N)); + } + else if (N <= 4294967295) + { + // str 32 + oa->write_character(static_cast(0xDB)); + write_number(static_cast(N)); + } + + // step 2: write the string + oa->write_characters( + reinterpret_cast(j.m_value.string->c_str()), + j.m_value.string->size()); + break; + } + + case value_t::array: + { + // step 1: write control byte and the array size + const auto N = j.m_value.array->size(); + if (N <= 15) + { + // fixarray + write_number(static_cast(0x90 | N)); + } + else if (N <= 0xFFFF) + { + // array 16 + oa->write_character(static_cast(0xDC)); + write_number(static_cast(N)); + } + else if (N <= 0xFFFFFFFF) + { + // array 32 + oa->write_character(static_cast(0xDD)); + write_number(static_cast(N)); + } + + // step 2: write each element + for (const auto& el : *j.m_value.array) + { + write_msgpack(el); + } + break; + } + + case value_t::object: + { + // step 1: write control byte and the object size + const auto N = j.m_value.object->size(); + if (N <= 15) + { + // fixmap + write_number(static_cast(0x80 | (N & 0xF))); + } + else if (N <= 65535) + { + // map 16 + oa->write_character(static_cast(0xDE)); + write_number(static_cast(N)); + } + else if (N <= 4294967295) + { + // map 32 + oa->write_character(static_cast(0xDF)); + write_number(static_cast(N)); + } + + // step 2: write each element + for (const auto& el : *j.m_value.object) + { + write_msgpack(el.first); + write_msgpack(el.second); + } + break; + } + + default: + break; + } + } + + private: + /* + @brief write a number to output input + + @param[in] n number of type @a NumberType + @tparam NumberType the type of the number + + @note This function needs to respect the system's endianess, because bytes + in CBOR and MessagePack are stored in network order (big endian) and + therefore need reordering on little endian systems. + */ + template void write_number(NumberType n) + { + // step 1: write number to array of length NumberType + std::array vec; + std::memcpy(vec.data(), &n, sizeof(NumberType)); + + // step 2: write array to output (with possible reordering) + if (is_little_endian) + { + // reverse byte order prior to conversion if necessary + std::reverse(vec.begin(), vec.end()); + } + + oa->write_characters(vec.data(), sizeof(NumberType)); + } + + private: + /// whether we can assume little endianess + const bool is_little_endian = binary_reader::little_endianess(); + + /// the output + output_adapter_t oa = nullptr; +}; + +/////////////////// +// serialization // +/////////////////// + +template +class serializer +{ + using string_t = typename BasicJsonType::string_t; + using number_float_t = typename BasicJsonType::number_float_t; + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + public: + /*! + @param[in] s output stream to serialize to + @param[in] ichar indentation character to use + */ + serializer(output_adapter_t s, const char ichar) + : o(std::move(s)), loc(std::localeconv()), + thousands_sep(loc->thousands_sep == nullptr ? '\0' : * (loc->thousands_sep)), + decimal_point(loc->decimal_point == nullptr ? '\0' : * (loc->decimal_point)), + indent_char(ichar), indent_string(512, indent_char) {} + + // delete because of pointer members + serializer(const serializer&) = delete; + serializer& operator=(const serializer&) = delete; + + /*! + @brief internal implementation of the serialization function + + This function is called by the public member function dump and organizes + the serialization internally. The indentation level is propagated as + additional parameter. In case of arrays and objects, the function is + called recursively. + + - strings and object keys are escaped using `escape_string()` + - integer numbers are converted implicitly via `operator<<` + - floating-point numbers are converted to a string using `"%g"` format + + @param[in] val value to serialize + @param[in] pretty_print whether the output shall be pretty-printed + @param[in] indent_step the indent level + @param[in] current_indent the current indent level (only used internally) + */ + void dump(const BasicJsonType& val, const bool pretty_print, + const bool ensure_ascii, + const unsigned int indent_step, + const unsigned int current_indent = 0) + { + switch (val.m_type) + { + case value_t::object: + { + if (val.m_value.object->empty()) + { + o->write_characters("{}", 2); + return; + } + + if (pretty_print) + { + o->write_characters("{\n", 2); + + // variable to hold indentation for recursive calls + const auto new_indent = current_indent + indent_step; + if (JSON_UNLIKELY(indent_string.size() < new_indent)) + { + indent_string.resize(indent_string.size() * 2, ' '); + } + + // first n-1 elements + auto i = val.m_value.object->cbegin(); + for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) + { + o->write_characters(indent_string.c_str(), new_indent); + o->write_character('\"'); + dump_escaped(i->first, ensure_ascii); + o->write_characters("\": ", 3); + dump(i->second, true, ensure_ascii, indent_step, new_indent); + o->write_characters(",\n", 2); + } + + // last element + assert(i != val.m_value.object->cend()); + assert(std::next(i) == val.m_value.object->cend()); + o->write_characters(indent_string.c_str(), new_indent); + o->write_character('\"'); + dump_escaped(i->first, ensure_ascii); + o->write_characters("\": ", 3); + dump(i->second, true, ensure_ascii, indent_step, new_indent); + + o->write_character('\n'); + o->write_characters(indent_string.c_str(), current_indent); + o->write_character('}'); + } + else + { + o->write_character('{'); + + // first n-1 elements + auto i = val.m_value.object->cbegin(); + for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) + { + o->write_character('\"'); + dump_escaped(i->first, ensure_ascii); + o->write_characters("\":", 2); + dump(i->second, false, ensure_ascii, indent_step, current_indent); + o->write_character(','); + } + + // last element + assert(i != val.m_value.object->cend()); + assert(std::next(i) == val.m_value.object->cend()); + o->write_character('\"'); + dump_escaped(i->first, ensure_ascii); + o->write_characters("\":", 2); + dump(i->second, false, ensure_ascii, indent_step, current_indent); + + o->write_character('}'); + } + + return; + } + + case value_t::array: + { + if (val.m_value.array->empty()) + { + o->write_characters("[]", 2); + return; + } + + if (pretty_print) + { + o->write_characters("[\n", 2); + + // variable to hold indentation for recursive calls + const auto new_indent = current_indent + indent_step; + if (JSON_UNLIKELY(indent_string.size() < new_indent)) + { + indent_string.resize(indent_string.size() * 2, ' '); + } + + // first n-1 elements + for (auto i = val.m_value.array->cbegin(); + i != val.m_value.array->cend() - 1; ++i) + { + o->write_characters(indent_string.c_str(), new_indent); + dump(*i, true, ensure_ascii, indent_step, new_indent); + o->write_characters(",\n", 2); + } + + // last element + assert(not val.m_value.array->empty()); + o->write_characters(indent_string.c_str(), new_indent); + dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent); + + o->write_character('\n'); + o->write_characters(indent_string.c_str(), current_indent); + o->write_character(']'); + } + else + { + o->write_character('['); + + // first n-1 elements + for (auto i = val.m_value.array->cbegin(); + i != val.m_value.array->cend() - 1; ++i) + { + dump(*i, false, ensure_ascii, indent_step, current_indent); + o->write_character(','); + } + + // last element + assert(not val.m_value.array->empty()); + dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent); + + o->write_character(']'); + } + + return; + } + + case value_t::string: + { + o->write_character('\"'); + dump_escaped(*val.m_value.string, ensure_ascii); + o->write_character('\"'); + return; + } + + case value_t::boolean: + { + if (val.m_value.boolean) + { + o->write_characters("true", 4); + } + else + { + o->write_characters("false", 5); + } + return; + } + + case value_t::number_integer: + { + dump_integer(val.m_value.number_integer); + return; + } + + case value_t::number_unsigned: + { + dump_integer(val.m_value.number_unsigned); + return; + } + + case value_t::number_float: + { + dump_float(val.m_value.number_float); + return; + } + + case value_t::discarded: + { + o->write_characters("", 11); + return; + } + + case value_t::null: + { + o->write_characters("null", 4); + return; + } + } + } + + private: + /*! + @brief returns the number of expected bytes following in UTF-8 string + + @param[in] u the first byte of a UTF-8 string + @return the number of expected bytes following + */ + static constexpr std::size_t bytes_following(const uint8_t u) + { + return ((u <= 127) ? 0 + : ((192 <= u and u <= 223) ? 1 + : ((224 <= u and u <= 239) ? 2 + : ((240 <= u and u <= 247) ? 3 : std::string::npos)))); + } + + /*! + @brief calculates the extra space to escape a JSON string + + @param[in] s the string to escape + @param[in] ensure_ascii whether to escape non-ASCII characters with + \uXXXX sequences + @return the number of characters required to escape string @a s + + @complexity Linear in the length of string @a s. + */ + static std::size_t extra_space(const string_t& s, + const bool ensure_ascii) noexcept + { + std::size_t res = 0; + + for (std::size_t i = 0; i < s.size(); ++i) + { + switch (s[i]) + { + // control characters that can be escaped with a backslash + case '"': + case '\\': + case '\b': + case '\f': + case '\n': + case '\r': + case '\t': + { + // from c (1 byte) to \x (2 bytes) + res += 1; + break; + } + + // control characters that need \uxxxx escaping + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x0B: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + { + // from c (1 byte) to \uxxxx (6 bytes) + res += 5; + break; + } + + default: + { + if (ensure_ascii and (s[i] & 0x80 or s[i] == 0x7F)) + { + const auto bytes = bytes_following(static_cast(s[i])); + // invalid characters will be detected by throw_if_invalid_utf8 + assert (bytes != std::string::npos); + + if (bytes == 3) + { + // codepoints that need 4 bytes (i.e., 3 additional + // bytes) in UTF-8 need a surrogate pair when \u + // escaping is used: from 4 bytes to \uxxxx\uxxxx + // (12 bytes) + res += (12 - bytes - 1); + } + else + { + // from x bytes to \uxxxx (6 bytes) + res += (6 - bytes - 1); + } + + // skip the additional bytes + i += bytes; + } + break; + } + } + } + + return res; + } + + static void escape_codepoint(int codepoint, string_t& result, std::size_t& pos) + { + // expecting a proper codepoint + assert(0x00 <= codepoint and codepoint <= 0x10FFFF); + + // the last written character was the backslash before the 'u' + assert(result[pos] == '\\'); + + // write the 'u' + result[++pos] = 'u'; + + // convert a number 0..15 to its hex representation (0..f) + static const std::array hexify = + { + { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' + } + }; + + if (codepoint < 0x10000) + { + // codepoints U+0000..U+FFFF can be represented as \uxxxx. + result[++pos] = hexify[(codepoint >> 12) & 0x0F]; + result[++pos] = hexify[(codepoint >> 8) & 0x0F]; + result[++pos] = hexify[(codepoint >> 4) & 0x0F]; + result[++pos] = hexify[codepoint & 0x0F]; + } + else + { + // codepoints U+10000..U+10FFFF need a surrogate pair to be + // represented as \uxxxx\uxxxx. + // http://www.unicode.org/faq/utf_bom.html#utf16-4 + codepoint -= 0x10000; + const int high_surrogate = 0xD800 | ((codepoint >> 10) & 0x3FF); + const int low_surrogate = 0xDC00 | (codepoint & 0x3FF); + result[++pos] = hexify[(high_surrogate >> 12) & 0x0F]; + result[++pos] = hexify[(high_surrogate >> 8) & 0x0F]; + result[++pos] = hexify[(high_surrogate >> 4) & 0x0F]; + result[++pos] = hexify[high_surrogate & 0x0F]; + ++pos; // backslash is already in output + result[++pos] = 'u'; + result[++pos] = hexify[(low_surrogate >> 12) & 0x0F]; + result[++pos] = hexify[(low_surrogate >> 8) & 0x0F]; + result[++pos] = hexify[(low_surrogate >> 4) & 0x0F]; + result[++pos] = hexify[low_surrogate & 0x0F]; + } + + ++pos; + } + + /*! + @brief dump escaped string + + Escape a string by replacing certain special characters by a sequence of an + escape character (backslash) and another character and other control + characters by a sequence of "\u" followed by a four-digit hex + representation. The escaped string is written to output stream @a o. + + @param[in] s the string to escape + @param[in] ensure_ascii whether to escape non-ASCII characters with + \uXXXX sequences + + @complexity Linear in the length of string @a s. + */ + void dump_escaped(const string_t& s, const bool ensure_ascii) const + { + throw_if_invalid_utf8(s); + + const auto space = extra_space(s, ensure_ascii); + if (space == 0) + { + o->write_characters(s.c_str(), s.size()); + return; + } + + // create a result string of necessary size + string_t result(s.size() + space, '\\'); + std::size_t pos = 0; + + for (std::size_t i = 0; i < s.size(); ++i) + { + switch (s[i]) + { + case '"': // quotation mark (0x22) + { + result[pos + 1] = '"'; + pos += 2; + break; + } + + case '\\': // reverse solidus (0x5C) + { + // nothing to change + pos += 2; + break; + } + + case '\b': // backspace (0x08) + { + result[pos + 1] = 'b'; + pos += 2; + break; + } + + case '\f': // formfeed (0x0C) + { + result[pos + 1] = 'f'; + pos += 2; + break; + } + + case '\n': // newline (0x0A) + { + result[pos + 1] = 'n'; + pos += 2; + break; + } + + case '\r': // carriage return (0x0D) + { + result[pos + 1] = 'r'; + pos += 2; + break; + } + + case '\t': // horizontal tab (0x09) + { + result[pos + 1] = 't'; + pos += 2; + break; + } + + default: + { + // escape control characters (0x00..0x1F) or, if + // ensure_ascii parameter is used, non-ASCII characters + if ((0x00 <= s[i] and s[i] <= 0x1F) or + (ensure_ascii and (s[i] & 0x80 or s[i] == 0x7F))) + { + const auto bytes = bytes_following(static_cast(s[i])); + // invalid characters will be detected by throw_if_invalid_utf8 + assert (bytes != std::string::npos); + + // check that the additional bytes are present + assert(i + bytes < s.size()); + + // to use \uxxxx escaping, we first need to calculate + // the codepoint from the UTF-8 bytes + int codepoint = 0; + + // bytes is unsigned type: + assert(bytes <= 3); + switch (bytes) + { + case 0: + { + codepoint = s[i] & 0xFF; + break; + } + + case 1: + { + codepoint = ((s[i] & 0x3F) << 6) + + (s[i + 1] & 0x7F); + break; + } + + case 2: + { + codepoint = ((s[i] & 0x1F) << 12) + + ((s[i + 1] & 0x7F) << 6) + + (s[i + 2] & 0x7F); + break; + } + + case 3: + { + codepoint = ((s[i] & 0xF) << 18) + + ((s[i + 1] & 0x7F) << 12) + + ((s[i + 2] & 0x7F) << 6) + + (s[i + 3] & 0x7F); + break; + } + + default: + break; // LCOV_EXCL_LINE + } + + escape_codepoint(codepoint, result, pos); + i += bytes; + } + else + { + // all other characters are added as-is + result[pos++] = s[i]; + } + break; + } + } + } + + assert(pos == result.size()); + o->write_characters(result.c_str(), result.size()); + } + + /*! + @brief dump an integer + + Dump a given integer to output stream @a o. Works internally with + @a number_buffer. + + @param[in] x integer number (signed or unsigned) to dump + @tparam NumberType either @a number_integer_t or @a number_unsigned_t + */ + template::value or + std::is_same::value, + int> = 0> + void dump_integer(NumberType x) + { + // special case for "0" + if (x == 0) + { + o->write_character('0'); + return; + } + + const bool is_negative = (x <= 0) and (x != 0); // see issue #755 + std::size_t i = 0; + + while (x != 0) + { + // spare 1 byte for '\0' + assert(i < number_buffer.size() - 1); + + const auto digit = std::labs(static_cast(x % 10)); + number_buffer[i++] = static_cast('0' + digit); + x /= 10; + } + + if (is_negative) + { + // make sure there is capacity for the '-' + assert(i < number_buffer.size() - 2); + number_buffer[i++] = '-'; + } + + std::reverse(number_buffer.begin(), number_buffer.begin() + i); + o->write_characters(number_buffer.data(), i); + } + + /*! + @brief dump a floating-point number + + Dump a given floating-point number to output stream @a o. Works internally + with @a number_buffer. + + @param[in] x floating-point number to dump + */ + void dump_float(number_float_t x) + { + // NaN / inf + if (not std::isfinite(x) or std::isnan(x)) + { + o->write_characters("null", 4); + return; + } + + // get number of digits for a text -> float -> text round-trip + static constexpr auto d = std::numeric_limits::digits10; + + // the actual conversion + std::ptrdiff_t len = snprintf(number_buffer.data(), number_buffer.size(), "%.*g", d, x); + + // negative value indicates an error + assert(len > 0); + // check if buffer was large enough + assert(static_cast(len) < number_buffer.size()); + + // erase thousands separator + if (thousands_sep != '\0') + { + const auto end = std::remove(number_buffer.begin(), + number_buffer.begin() + len, thousands_sep); + std::fill(end, number_buffer.end(), '\0'); + assert((end - number_buffer.begin()) <= len); + len = (end - number_buffer.begin()); + } + + // convert decimal point to '.' + if (decimal_point != '\0' and decimal_point != '.') + { + const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point); + if (dec_pos != number_buffer.end()) + { + *dec_pos = '.'; + } + } + + o->write_characters(number_buffer.data(), static_cast(len)); + + // determine if need to append ".0" + const bool value_is_int_like = + std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, + [](char c) + { + return (c == '.' or c == 'e'); + }); + + if (value_is_int_like) + { + o->write_characters(".0", 2); + } + } + + /*! + @brief check whether a string is UTF-8 encoded + + The function checks each byte of a string whether it is UTF-8 encoded. The + result of the check is stored in the @a state parameter. The function must + be called initially with state 0 (accept). State 1 means the string must + be rejected, because the current byte is not allowed. If the string is + completely processed, but the state is non-zero, the string ended + prematurely; that is, the last byte indicated more bytes should have + followed. + + @param[in,out] state the state of the decoding + @param[in] byte next byte to decode + + @note The function has been edited: a std::array is used and the code + point is not calculated. + + @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann + @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ + */ + static void decode(uint8_t& state, const uint8_t byte) + { + static const std::array utf8d = + { + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF + 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF + 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF + 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF + 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2 + 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4 + 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6 + 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8 + } + }; + + const uint8_t type = utf8d[byte]; + state = utf8d[256u + state * 16u + type]; + } + + /*! + @brief throw an exception if a string is not UTF-8 encoded + + @param[in] str UTF-8 string to check + @throw type_error.316 if passed string is not UTF-8 encoded + + @since version 3.0.0 + */ + static void throw_if_invalid_utf8(const std::string& str) + { + // start with state 0 (= accept) + uint8_t state = 0; + + for (size_t i = 0; i < str.size(); ++i) + { + const auto byte = static_cast(str[i]); + decode(state, byte); + if (state == 1) + { + // state 1 means reject + std::stringstream ss; + ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << static_cast(byte); + JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + ss.str())); + } + } + + if (state != 0) + { + // we finish reading, but do not accept: string was incomplete + std::stringstream ss; + ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << static_cast(static_cast(str.back())); + JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + ss.str())); + } + } + + private: + /// the output of the serializer + output_adapter_t o = nullptr; + + /// a (hopefully) large enough character buffer + std::array number_buffer{{}}; + + /// the locale + const std::lconv* loc = nullptr; + /// the locale's thousand separator character + const char thousands_sep = '\0'; + /// the locale's decimal point character + const char decimal_point = '\0'; + + /// the indentation character + const char indent_char; + + /// the indentation string + string_t indent_string; +}; + +template +class json_ref +{ + public: + using value_type = BasicJsonType; + + json_ref(value_type&& value) + : owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true) + {} + + json_ref(const value_type& value) + : value_ref(const_cast(&value)), is_rvalue(false) + {} + + json_ref(std::initializer_list init) + : owned_value(init), value_ref(&owned_value), is_rvalue(true) + {} + + template + json_ref(Args&& ... args) + : owned_value(std::forward(args)...), value_ref(&owned_value), is_rvalue(true) + {} + + // class should be movable only + json_ref(json_ref&&) = default; + json_ref(const json_ref&) = delete; + json_ref& operator=(const json_ref&) = delete; + + value_type moved_or_copied() const + { + if (is_rvalue) + { + return std::move(*value_ref); + } + return *value_ref; + } + + value_type const& operator*() const + { + return *static_cast(value_ref); + } + + value_type const* operator->() const + { + return static_cast(value_ref); + } + + private: + mutable value_type owned_value = nullptr; + value_type* value_ref = nullptr; + const bool is_rvalue; +}; + +} // namespace detail + +/// namespace to hold default `to_json` / `from_json` functions +namespace +{ +constexpr const auto& to_json = detail::static_const::value; +constexpr const auto& from_json = detail::static_const::value; +} + + +/*! +@brief default JSONSerializer template argument + +This serializer ignores the template arguments and uses ADL +([argument-dependent lookup](http://en.cppreference.com/w/cpp/language/adl)) +for serialization. +*/ +template +struct adl_serializer +{ + /*! + @brief convert a JSON value to any value type + + This function is usually called by the `get()` function of the + @ref basic_json class (either explicit or via conversion operators). + + @param[in] j JSON value to read from + @param[in,out] val value to write to + */ + template + static void from_json(BasicJsonType&& j, ValueType& val) noexcept( + noexcept(::nlohmann::from_json(std::forward(j), val))) + { + ::nlohmann::from_json(std::forward(j), val); + } + + /*! + @brief convert any value type to a JSON value + + This function is usually called by the constructors of the @ref basic_json + class. + + @param[in,out] j JSON value to write to + @param[in] val value to read from + */ + template + static void to_json(BasicJsonType& j, ValueType&& val) noexcept( + noexcept(::nlohmann::to_json(j, std::forward(val)))) + { + ::nlohmann::to_json(j, std::forward(val)); + } +}; + +/*! +@brief JSON Pointer + +A JSON pointer defines a string syntax for identifying a specific value +within a JSON document. It can be used with functions `at` and +`operator[]`. Furthermore, JSON pointers are the base for JSON patches. + +@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) + +@since version 2.0.0 +*/ +class json_pointer +{ + /// allow basic_json to access private members + NLOHMANN_BASIC_JSON_TPL_DECLARATION + friend class basic_json; + + public: + /*! + @brief create JSON pointer + + Create a JSON pointer according to the syntax described in + [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3). + + @param[in] s string representing the JSON pointer; if omitted, the empty + string is assumed which references the whole JSON value + + @throw parse_error.107 if the given JSON pointer @a s is nonempty and + does not begin with a slash (`/`); see example below + + @throw parse_error.108 if a tilde (`~`) in the given JSON pointer @a s + is not followed by `0` (representing `~`) or `1` (representing `/`); + see example below + + @liveexample{The example shows the construction several valid JSON + pointers as well as the exceptional behavior.,json_pointer} + + @since version 2.0.0 + */ + explicit json_pointer(const std::string& s = "") : reference_tokens(split(s)) {} + + /*! + @brief return a string representation of the JSON pointer + + @invariant For each JSON pointer `ptr`, it holds: + @code {.cpp} + ptr == json_pointer(ptr.to_string()); + @endcode + + @return a string representation of the JSON pointer + + @liveexample{The example shows the result of `to_string`., + json_pointer__to_string} + + @since version 2.0.0 + */ + std::string to_string() const noexcept + { + return std::accumulate(reference_tokens.begin(), reference_tokens.end(), + std::string{}, + [](const std::string & a, const std::string & b) + { + return a + "/" + escape(b); + }); + } + + /// @copydoc to_string() + operator std::string() const + { + return to_string(); + } + + /*! + @param[in] s reference token to be converted into an array index + + @return integer representation of @a s + + @throw out_of_range.404 if string @a s could not be converted to an integer + */ + static int array_index(const std::string& s) + { + size_t processed_chars = 0; + const int res = std::stoi(s, &processed_chars); + + // check if the string was completely read + if (JSON_UNLIKELY(processed_chars != s.size())) + { + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); + } + + return res; + } + + private: + /*! + @brief remove and return last reference pointer + @throw out_of_range.405 if JSON pointer has no parent + */ + std::string pop_back() + { + if (JSON_UNLIKELY(is_root())) + { + JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); + } + + auto last = reference_tokens.back(); + reference_tokens.pop_back(); + return last; + } + + /// return whether pointer points to the root document + bool is_root() const + { + return reference_tokens.empty(); + } + + json_pointer top() const + { + if (JSON_UNLIKELY(is_root())) + { + JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); + } + + json_pointer result = *this; + result.reference_tokens = {reference_tokens[0]}; + return result; + } + + /*! + @brief create and return a reference to the pointed to value + + @complexity Linear in the number of reference tokens. + + @throw parse_error.109 if array index is not a number + @throw type_error.313 if value cannot be unflattened + */ + NLOHMANN_BASIC_JSON_TPL_DECLARATION + NLOHMANN_BASIC_JSON_TPL& get_and_create(NLOHMANN_BASIC_JSON_TPL& j) const; + + /*! + @brief return a reference to the pointed to value + + @note This version does not throw if a value is not present, but tries to + create nested values instead. For instance, calling this function + with pointer `"/this/that"` on a null value is equivalent to calling + `operator[]("this").operator[]("that")` on that value, effectively + changing the null value to an object. + + @param[in] ptr a JSON value + + @return reference to the JSON value pointed to by the JSON pointer + + @complexity Linear in the length of the JSON pointer. + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.404 if the JSON pointer can not be resolved + */ + NLOHMANN_BASIC_JSON_TPL_DECLARATION + NLOHMANN_BASIC_JSON_TPL& get_unchecked(NLOHMANN_BASIC_JSON_TPL* ptr) const; + + /*! + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.402 if the array index '-' is used + @throw out_of_range.404 if the JSON pointer can not be resolved + */ + NLOHMANN_BASIC_JSON_TPL_DECLARATION + NLOHMANN_BASIC_JSON_TPL& get_checked(NLOHMANN_BASIC_JSON_TPL* ptr) const; + + /*! + @brief return a const reference to the pointed to value + + @param[in] ptr a JSON value + + @return const reference to the JSON value pointed to by the JSON + pointer + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.402 if the array index '-' is used + @throw out_of_range.404 if the JSON pointer can not be resolved + */ + NLOHMANN_BASIC_JSON_TPL_DECLARATION + const NLOHMANN_BASIC_JSON_TPL& get_unchecked(const NLOHMANN_BASIC_JSON_TPL* ptr) const; + + /*! + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.402 if the array index '-' is used + @throw out_of_range.404 if the JSON pointer can not be resolved + */ + NLOHMANN_BASIC_JSON_TPL_DECLARATION + const NLOHMANN_BASIC_JSON_TPL& get_checked(const NLOHMANN_BASIC_JSON_TPL* ptr) const; + + /*! + @brief split the string input to reference tokens + + @note This function is only called by the json_pointer constructor. + All exceptions below are documented there. + + @throw parse_error.107 if the pointer is not empty or begins with '/' + @throw parse_error.108 if character '~' is not followed by '0' or '1' + */ + static std::vector split(const std::string& reference_string) + { + std::vector result; + + // special case: empty reference string -> no reference tokens + if (reference_string.empty()) + { + return result; + } + + // check if nonempty reference string begins with slash + if (JSON_UNLIKELY(reference_string[0] != '/')) + { + JSON_THROW(detail::parse_error::create(107, 1, + "JSON pointer must be empty or begin with '/' - was: '" + + reference_string + "'")); + } + + // extract the reference tokens: + // - slash: position of the last read slash (or end of string) + // - start: position after the previous slash + for ( + // search for the first slash after the first character + std::size_t slash = reference_string.find_first_of('/', 1), + // set the beginning of the first reference token + start = 1; + // we can stop if start == string::npos+1 = 0 + start != 0; + // set the beginning of the next reference token + // (will eventually be 0 if slash == std::string::npos) + start = slash + 1, + // find next slash + slash = reference_string.find_first_of('/', start)) + { + // use the text between the beginning of the reference token + // (start) and the last slash (slash). + auto reference_token = reference_string.substr(start, slash - start); + + // check reference tokens are properly escaped + for (std::size_t pos = reference_token.find_first_of('~'); + pos != std::string::npos; + pos = reference_token.find_first_of('~', pos + 1)) + { + assert(reference_token[pos] == '~'); + + // ~ must be followed by 0 or 1 + if (JSON_UNLIKELY(pos == reference_token.size() - 1 or + (reference_token[pos + 1] != '0' and + reference_token[pos + 1] != '1'))) + { + JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); + } + } + + // finally, store the reference token + unescape(reference_token); + result.push_back(reference_token); + } + + return result; + } + + /*! + @brief replace all occurrences of a substring by another string + + @param[in,out] s the string to manipulate; changed so that all + occurrences of @a f are replaced with @a t + @param[in] f the substring to replace with @a t + @param[in] t the string to replace @a f + + @pre The search string @a f must not be empty. **This precondition is + enforced with an assertion.** + + @since version 2.0.0 + */ + static void replace_substring(std::string& s, const std::string& f, + const std::string& t) + { + assert(not f.empty()); + for (auto pos = s.find(f); // find first occurrence of f + pos != std::string::npos; // make sure f was found + s.replace(pos, f.size(), t), // replace with t, and + pos = s.find(f, pos + t.size())) // find next occurrence of f + {} + } + + /// escape "~"" to "~0" and "/" to "~1" + static std::string escape(std::string s) + { + replace_substring(s, "~", "~0"); + replace_substring(s, "/", "~1"); + return s; + } + + /// unescape "~1" to tilde and "~0" to slash (order is important!) + static void unescape(std::string& s) + { + replace_substring(s, "~1", "/"); + replace_substring(s, "~0", "~"); + } + + /*! + @param[in] reference_string the reference string to the current value + @param[in] value the value to consider + @param[in,out] result the result object to insert values to + + @note Empty objects or arrays are flattened to `null`. + */ + NLOHMANN_BASIC_JSON_TPL_DECLARATION + static void flatten(const std::string& reference_string, + const NLOHMANN_BASIC_JSON_TPL& value, + NLOHMANN_BASIC_JSON_TPL& result); + + /*! + @param[in] value flattened JSON + + @return unflattened JSON + + @throw parse_error.109 if array index is not a number + @throw type_error.314 if value is not an object + @throw type_error.315 if object values are not primitive + @throw type_error.313 if value cannot be unflattened + */ + NLOHMANN_BASIC_JSON_TPL_DECLARATION + static NLOHMANN_BASIC_JSON_TPL + unflatten(const NLOHMANN_BASIC_JSON_TPL& value); + + friend bool operator==(json_pointer const& lhs, + json_pointer const& rhs) noexcept; + + friend bool operator!=(json_pointer const& lhs, + json_pointer const& rhs) noexcept; + + /// the reference tokens + std::vector reference_tokens; +}; + +/*! +@brief a class to store JSON values + +@tparam ObjectType type for JSON objects (`std::map` by default; will be used +in @ref object_t) +@tparam ArrayType type for JSON arrays (`std::vector` by default; will be used +in @ref array_t) +@tparam StringType type for JSON strings and object keys (`std::string` by +default; will be used in @ref string_t) +@tparam BooleanType type for JSON booleans (`bool` by default; will be used +in @ref boolean_t) +@tparam NumberIntegerType type for JSON integer numbers (`int64_t` by +default; will be used in @ref number_integer_t) +@tparam NumberUnsignedType type for JSON unsigned integer numbers (@c +`uint64_t` by default; will be used in @ref number_unsigned_t) +@tparam NumberFloatType type for JSON floating-point numbers (`double` by +default; will be used in @ref number_float_t) +@tparam AllocatorType type of the allocator to use (`std::allocator` by +default) +@tparam JSONSerializer the serializer to resolve internal calls to `to_json()` +and `from_json()` (@ref adl_serializer by default) + +@requirement The class satisfies the following concept requirements: +- Basic + - [DefaultConstructible](http://en.cppreference.com/w/cpp/concept/DefaultConstructible): + JSON values can be default constructed. The result will be a JSON null + value. + - [MoveConstructible](http://en.cppreference.com/w/cpp/concept/MoveConstructible): + A JSON value can be constructed from an rvalue argument. + - [CopyConstructible](http://en.cppreference.com/w/cpp/concept/CopyConstructible): + A JSON value can be copy-constructed from an lvalue expression. + - [MoveAssignable](http://en.cppreference.com/w/cpp/concept/MoveAssignable): + A JSON value van be assigned from an rvalue argument. + - [CopyAssignable](http://en.cppreference.com/w/cpp/concept/CopyAssignable): + A JSON value can be copy-assigned from an lvalue expression. + - [Destructible](http://en.cppreference.com/w/cpp/concept/Destructible): + JSON values can be destructed. +- Layout + - [StandardLayoutType](http://en.cppreference.com/w/cpp/concept/StandardLayoutType): + JSON values have + [standard layout](http://en.cppreference.com/w/cpp/language/data_members#Standard_layout): + All non-static data members are private and standard layout types, the + class has no virtual functions or (virtual) base classes. +- Library-wide + - [EqualityComparable](http://en.cppreference.com/w/cpp/concept/EqualityComparable): + JSON values can be compared with `==`, see @ref + operator==(const_reference,const_reference). + - [LessThanComparable](http://en.cppreference.com/w/cpp/concept/LessThanComparable): + JSON values can be compared with `<`, see @ref + operator<(const_reference,const_reference). + - [Swappable](http://en.cppreference.com/w/cpp/concept/Swappable): + Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of + other compatible types, using unqualified function call @ref swap(). + - [NullablePointer](http://en.cppreference.com/w/cpp/concept/NullablePointer): + JSON values can be compared against `std::nullptr_t` objects which are used + to model the `null` value. +- Container + - [Container](http://en.cppreference.com/w/cpp/concept/Container): + JSON values can be used like STL containers and provide iterator access. + - [ReversibleContainer](http://en.cppreference.com/w/cpp/concept/ReversibleContainer); + JSON values can be used like STL containers and provide reverse iterator + access. + +@invariant The member variables @a m_value and @a m_type have the following +relationship: +- If `m_type == value_t::object`, then `m_value.object != nullptr`. +- If `m_type == value_t::array`, then `m_value.array != nullptr`. +- If `m_type == value_t::string`, then `m_value.string != nullptr`. +The invariants are checked by member function assert_invariant(). + +@internal +@note ObjectType trick from http://stackoverflow.com/a/9860911 +@endinternal + +@see [RFC 7159: The JavaScript Object Notation (JSON) Data Interchange +Format](http://rfc7159.net/rfc7159) + +@since version 1.0.0 + +@nosubgrouping +*/ +NLOHMANN_BASIC_JSON_TPL_DECLARATION +class basic_json +{ + private: + template friend struct detail::external_constructor; + friend ::nlohmann::json_pointer; + friend ::nlohmann::detail::parser; + friend ::nlohmann::detail::serializer; + template + friend class ::nlohmann::detail::iter_impl; + template + friend class ::nlohmann::detail::binary_writer; + template + friend class ::nlohmann::detail::binary_reader; + + /// workaround type for MSVC + using basic_json_t = NLOHMANN_BASIC_JSON_TPL; + + // convenience aliases for types residing in namespace detail; + using lexer = ::nlohmann::detail::lexer; + using parser = ::nlohmann::detail::parser; + + using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t; + template + using internal_iterator = ::nlohmann::detail::internal_iterator; + template + using iter_impl = ::nlohmann::detail::iter_impl; + template + using iteration_proxy = ::nlohmann::detail::iteration_proxy; + template using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator; + + template + using output_adapter_t = ::nlohmann::detail::output_adapter_t; + + using binary_reader = ::nlohmann::detail::binary_reader; + template using binary_writer = ::nlohmann::detail::binary_writer; + + using serializer = ::nlohmann::detail::serializer; + + public: + using value_t = detail::value_t; + /// @copydoc nlohmann::json_pointer + using json_pointer = ::nlohmann::json_pointer; + template + using json_serializer = JSONSerializer; + /// helper type for initializer lists of basic_json values + using initializer_list_t = std::initializer_list>; + + //////////////// + // exceptions // + //////////////// + + /// @name exceptions + /// Classes to implement user-defined exceptions. + /// @{ + + /// @copydoc detail::exception + using exception = detail::exception; + /// @copydoc detail::parse_error + using parse_error = detail::parse_error; + /// @copydoc detail::invalid_iterator + using invalid_iterator = detail::invalid_iterator; + /// @copydoc detail::type_error + using type_error = detail::type_error; + /// @copydoc detail::out_of_range + using out_of_range = detail::out_of_range; + /// @copydoc detail::other_error + using other_error = detail::other_error; + + /// @} + + + ///////////////////// + // container types // + ///////////////////// + + /// @name container types + /// The canonic container types to use @ref basic_json like any other STL + /// container. + /// @{ + + /// the type of elements in a basic_json container + using value_type = basic_json; + + /// the type of an element reference + using reference = value_type&; + /// the type of an element const reference + using const_reference = const value_type&; + + /// a type to represent differences between iterators + using difference_type = std::ptrdiff_t; + /// a type to represent container sizes + using size_type = std::size_t; + + /// the allocator type + using allocator_type = AllocatorType; + + /// the type of an element pointer + using pointer = typename std::allocator_traits::pointer; + /// the type of an element const pointer + using const_pointer = typename std::allocator_traits::const_pointer; + + /// an iterator for a basic_json container + using iterator = iter_impl; + /// a const iterator for a basic_json container + using const_iterator = iter_impl; + /// a reverse iterator for a basic_json container + using reverse_iterator = json_reverse_iterator; + /// a const reverse iterator for a basic_json container + using const_reverse_iterator = json_reverse_iterator; + + /// @} + + + /*! + @brief returns the allocator associated with the container + */ + static allocator_type get_allocator() + { + return allocator_type(); + } + + /*! + @brief returns version information on the library + + This function returns a JSON object with information about the library, + including the version number and information on the platform and compiler. + + @return JSON object holding version information + key | description + ----------- | --------------- + `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). + `copyright` | The copyright line for the library as string. + `name` | The name of the library as string. + `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. + `url` | The URL of the project as string. + `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string). + + @liveexample{The following code shows an example output of the `meta()` + function.,meta} + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @complexity Constant. + + @since 2.1.0 + */ + static basic_json meta() + { + basic_json result; + + result["copyright"] = "(C) 2013-2017 Niels Lohmann"; + result["name"] = "JSON for Modern C++"; + result["url"] = "https://github.com/nlohmann/json"; + result["version"] = + { + {"string", "3.0.1"}, {"major", 3}, {"minor", 0}, {"patch", 1} + }; + +#ifdef _WIN32 + result["platform"] = "win32"; +#elif defined __linux__ + result["platform"] = "linux"; +#elif defined __APPLE__ + result["platform"] = "apple"; +#elif defined __unix__ + result["platform"] = "unix"; +#else + result["platform"] = "unknown"; +#endif + +#if defined(__ICC) || defined(__INTEL_COMPILER) + result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}}; +#elif defined(__clang__) + result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}}; +#elif defined(__GNUC__) || defined(__GNUG__) + result["compiler"] = {{"family", "gcc"}, {"version", std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__)}}; +#elif defined(__HP_cc) || defined(__HP_aCC) + result["compiler"] = "hp" +#elif defined(__IBMCPP__) + result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}}; +#elif defined(_MSC_VER) + result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}}; +#elif defined(__PGI) + result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}}; +#elif defined(__SUNPRO_CC) + result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}}; +#else + result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; +#endif + +#ifdef __cplusplus + result["compiler"]["c++"] = std::to_string(__cplusplus); +#else + result["compiler"]["c++"] = "unknown"; +#endif + return result; + } + + + /////////////////////////// + // JSON value data types // + /////////////////////////// + + /// @name JSON value data types + /// The data types to store a JSON value. These types are derived from + /// the template arguments passed to class @ref basic_json. + /// @{ + +#if defined(JSON_HAS_CPP_14) + // Use transparent comparator if possible, combined with perfect forwarding + // on find() and count() calls prevents unnecessary string construction. + using object_comparator_t = std::less<>; +#else + using object_comparator_t = std::less; +#endif + + /*! + @brief a type for an object + + [RFC 7159](http://rfc7159.net/rfc7159) describes JSON objects as follows: + > An object is an unordered collection of zero or more name/value pairs, + > where a name is a string and a value is a string, number, boolean, null, + > object, or array. + + To store objects in C++, a type is defined by the template parameters + described below. + + @tparam ObjectType the container to store objects (e.g., `std::map` or + `std::unordered_map`) + @tparam StringType the type of the keys or names (e.g., `std::string`). + The comparison function `std::less` is used to order elements + inside the container. + @tparam AllocatorType the allocator to use for objects (e.g., + `std::allocator`) + + #### Default type + + With the default values for @a ObjectType (`std::map`), @a StringType + (`std::string`), and @a AllocatorType (`std::allocator`), the default + value for @a object_t is: + + @code {.cpp} + std::map< + std::string, // key_type + basic_json, // value_type + std::less, // key_compare + std::allocator> // allocator_type + > + @endcode + + #### Behavior + + The choice of @a object_t influences the behavior of the JSON class. With + the default type, objects have the following behavior: + + - When all names are unique, objects will be interoperable in the sense + that all software implementations receiving that object will agree on + the name-value mappings. + - When the names within an object are not unique, later stored name/value + pairs overwrite previously stored name/value pairs, leaving the used + names unique. For instance, `{"key": 1}` and `{"key": 2, "key": 1}` will + be treated as equal and both stored as `{"key": 1}`. + - Internally, name/value pairs are stored in lexicographical order of the + names. Objects will also be serialized (see @ref dump) in this order. + For instance, `{"b": 1, "a": 2}` and `{"a": 2, "b": 1}` will be stored + and serialized as `{"a": 2, "b": 1}`. + - When comparing objects, the order of the name/value pairs is irrelevant. + This makes objects interoperable in the sense that they will not be + affected by these differences. For instance, `{"b": 1, "a": 2}` and + `{"a": 2, "b": 1}` will be treated as equal. + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) specifies: + > An implementation may set limits on the maximum depth of nesting. + + In this class, the object's limit of nesting is not explicitly constrained. + However, a maximum depth of nesting may be introduced by the compiler or + runtime environment. A theoretical limit can be queried by calling the + @ref max_size function of a JSON object. + + #### Storage + + Objects are stored as pointers in a @ref basic_json type. That is, for any + access to object values, a pointer of type `object_t*` must be + dereferenced. + + @sa @ref array_t -- type for an array value + + @since version 1.0.0 + + @note The order name/value pairs are added to the object is *not* + preserved by the library. Therefore, iterating an object may return + name/value pairs in a different order than they were originally stored. In + fact, keys will be traversed in alphabetical order as `std::map` with + `std::less` is used by default. Please note this behavior conforms to [RFC + 7159](http://rfc7159.net/rfc7159), because any order implements the + specified "unordered" nature of JSON objects. + */ + using object_t = ObjectType>>; + + /*! + @brief a type for an array + + [RFC 7159](http://rfc7159.net/rfc7159) describes JSON arrays as follows: + > An array is an ordered sequence of zero or more values. + + To store objects in C++, a type is defined by the template parameters + explained below. + + @tparam ArrayType container type to store arrays (e.g., `std::vector` or + `std::list`) + @tparam AllocatorType allocator to use for arrays (e.g., `std::allocator`) + + #### Default type + + With the default values for @a ArrayType (`std::vector`) and @a + AllocatorType (`std::allocator`), the default value for @a array_t is: + + @code {.cpp} + std::vector< + basic_json, // value_type + std::allocator // allocator_type + > + @endcode + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) specifies: + > An implementation may set limits on the maximum depth of nesting. + + In this class, the array's limit of nesting is not explicitly constrained. + However, a maximum depth of nesting may be introduced by the compiler or + runtime environment. A theoretical limit can be queried by calling the + @ref max_size function of a JSON array. + + #### Storage + + Arrays are stored as pointers in a @ref basic_json type. That is, for any + access to array values, a pointer of type `array_t*` must be dereferenced. + + @sa @ref object_t -- type for an object value + + @since version 1.0.0 + */ + using array_t = ArrayType>; + + /*! + @brief a type for a string + + [RFC 7159](http://rfc7159.net/rfc7159) describes JSON strings as follows: + > A string is a sequence of zero or more Unicode characters. + + To store objects in C++, a type is defined by the template parameter + described below. Unicode values are split by the JSON class into + byte-sized characters during deserialization. + + @tparam StringType the container to store strings (e.g., `std::string`). + Note this container is used for keys/names in objects, see @ref object_t. + + #### Default type + + With the default values for @a StringType (`std::string`), the default + value for @a string_t is: + + @code {.cpp} + std::string + @endcode + + #### Encoding + + Strings are stored in UTF-8 encoding. Therefore, functions like + `std::string::size()` or `std::string::length()` return the number of + bytes in the string rather than the number of characters or glyphs. + + #### String comparison + + [RFC 7159](http://rfc7159.net/rfc7159) states: + > Software implementations are typically required to test names of object + > members for equality. Implementations that transform the textual + > representation into sequences of Unicode code units and then perform the + > comparison numerically, code unit by code unit, are interoperable in the + > sense that implementations will agree in all cases on equality or + > inequality of two strings. For example, implementations that compare + > strings with escaped characters unconverted may incorrectly find that + > `"a\\b"` and `"a\u005Cb"` are not equal. + + This implementation is interoperable as it does compare strings code unit + by code unit. + + #### Storage + + String values are stored as pointers in a @ref basic_json type. That is, + for any access to string values, a pointer of type `string_t*` must be + dereferenced. + + @since version 1.0.0 + */ + using string_t = StringType; + + /*! + @brief a type for a boolean + + [RFC 7159](http://rfc7159.net/rfc7159) implicitly describes a boolean as a + type which differentiates the two literals `true` and `false`. + + To store objects in C++, a type is defined by the template parameter @a + BooleanType which chooses the type to use. + + #### Default type + + With the default values for @a BooleanType (`bool`), the default value for + @a boolean_t is: + + @code {.cpp} + bool + @endcode + + #### Storage + + Boolean values are stored directly inside a @ref basic_json type. + + @since version 1.0.0 + */ + using boolean_t = BooleanType; + + /*! + @brief a type for a number (integer) + + [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: + > The representation of numbers is similar to that used in most + > programming languages. A number is represented in base 10 using decimal + > digits. It contains an integer component that may be prefixed with an + > optional minus sign, which may be followed by a fraction part and/or an + > exponent part. Leading zeros are not allowed. (...) Numeric values that + > cannot be represented in the grammar below (such as Infinity and NaN) + > are not permitted. + + This description includes both integer and floating-point numbers. + However, C++ allows more precise storage if it is known whether the number + is a signed integer, an unsigned integer or a floating-point number. + Therefore, three different types, @ref number_integer_t, @ref + number_unsigned_t and @ref number_float_t are used. + + To store integer numbers in C++, a type is defined by the template + parameter @a NumberIntegerType which chooses the type to use. + + #### Default type + + With the default values for @a NumberIntegerType (`int64_t`), the default + value for @a number_integer_t is: + + @code {.cpp} + int64_t + @endcode + + #### Default behavior + + - The restrictions about leading zeros is not enforced in C++. Instead, + leading zeros in integer literals lead to an interpretation as octal + number. Internally, the value will be stored as decimal number. For + instance, the C++ integer literal `010` will be serialized to `8`. + During deserialization, leading zeros yield an error. + - Not-a-number (NaN) values will be serialized to `null`. + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) specifies: + > An implementation may set limits on the range and precision of numbers. + + When the default type is used, the maximal integer number that can be + stored is `9223372036854775807` (INT64_MAX) and the minimal integer number + that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers + that are out of range will yield over/underflow when used in a + constructor. During deserialization, too large or small integer numbers + will be automatically be stored as @ref number_unsigned_t or @ref + number_float_t. + + [RFC 7159](http://rfc7159.net/rfc7159) further states: + > Note that when such software is used, numbers that are integers and are + > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense + > that implementations will agree exactly on their numeric values. + + As this range is a subrange of the exactly supported range [INT64_MIN, + INT64_MAX], this class's integer type is interoperable. + + #### Storage + + Integer number values are stored directly inside a @ref basic_json type. + + @sa @ref number_float_t -- type for number values (floating-point) + + @sa @ref number_unsigned_t -- type for number values (unsigned integer) + + @since version 1.0.0 + */ + using number_integer_t = NumberIntegerType; + + /*! + @brief a type for a number (unsigned) + + [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: + > The representation of numbers is similar to that used in most + > programming languages. A number is represented in base 10 using decimal + > digits. It contains an integer component that may be prefixed with an + > optional minus sign, which may be followed by a fraction part and/or an + > exponent part. Leading zeros are not allowed. (...) Numeric values that + > cannot be represented in the grammar below (such as Infinity and NaN) + > are not permitted. + + This description includes both integer and floating-point numbers. + However, C++ allows more precise storage if it is known whether the number + is a signed integer, an unsigned integer or a floating-point number. + Therefore, three different types, @ref number_integer_t, @ref + number_unsigned_t and @ref number_float_t are used. + + To store unsigned integer numbers in C++, a type is defined by the + template parameter @a NumberUnsignedType which chooses the type to use. + + #### Default type + + With the default values for @a NumberUnsignedType (`uint64_t`), the + default value for @a number_unsigned_t is: + + @code {.cpp} + uint64_t + @endcode + + #### Default behavior + + - The restrictions about leading zeros is not enforced in C++. Instead, + leading zeros in integer literals lead to an interpretation as octal + number. Internally, the value will be stored as decimal number. For + instance, the C++ integer literal `010` will be serialized to `8`. + During deserialization, leading zeros yield an error. + - Not-a-number (NaN) values will be serialized to `null`. + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) specifies: + > An implementation may set limits on the range and precision of numbers. + + When the default type is used, the maximal integer number that can be + stored is `18446744073709551615` (UINT64_MAX) and the minimal integer + number that can be stored is `0`. Integer numbers that are out of range + will yield over/underflow when used in a constructor. During + deserialization, too large or small integer numbers will be automatically + be stored as @ref number_integer_t or @ref number_float_t. + + [RFC 7159](http://rfc7159.net/rfc7159) further states: + > Note that when such software is used, numbers that are integers and are + > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense + > that implementations will agree exactly on their numeric values. + + As this range is a subrange (when considered in conjunction with the + number_integer_t type) of the exactly supported range [0, UINT64_MAX], + this class's integer type is interoperable. + + #### Storage + + Integer number values are stored directly inside a @ref basic_json type. + + @sa @ref number_float_t -- type for number values (floating-point) + @sa @ref number_integer_t -- type for number values (integer) + + @since version 2.0.0 + */ + using number_unsigned_t = NumberUnsignedType; + + /*! + @brief a type for a number (floating-point) + + [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: + > The representation of numbers is similar to that used in most + > programming languages. A number is represented in base 10 using decimal + > digits. It contains an integer component that may be prefixed with an + > optional minus sign, which may be followed by a fraction part and/or an + > exponent part. Leading zeros are not allowed. (...) Numeric values that + > cannot be represented in the grammar below (such as Infinity and NaN) + > are not permitted. + + This description includes both integer and floating-point numbers. + However, C++ allows more precise storage if it is known whether the number + is a signed integer, an unsigned integer or a floating-point number. + Therefore, three different types, @ref number_integer_t, @ref + number_unsigned_t and @ref number_float_t are used. + + To store floating-point numbers in C++, a type is defined by the template + parameter @a NumberFloatType which chooses the type to use. + + #### Default type + + With the default values for @a NumberFloatType (`double`), the default + value for @a number_float_t is: + + @code {.cpp} + double + @endcode + + #### Default behavior + + - The restrictions about leading zeros is not enforced in C++. Instead, + leading zeros in floating-point literals will be ignored. Internally, + the value will be stored as decimal number. For instance, the C++ + floating-point literal `01.2` will be serialized to `1.2`. During + deserialization, leading zeros yield an error. + - Not-a-number (NaN) values will be serialized to `null`. + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) states: + > This specification allows implementations to set limits on the range and + > precision of numbers accepted. Since software that implements IEEE + > 754-2008 binary64 (double precision) numbers is generally available and + > widely used, good interoperability can be achieved by implementations + > that expect no more precision or range than these provide, in the sense + > that implementations will approximate JSON numbers within the expected + > precision. + + This implementation does exactly follow this approach, as it uses double + precision floating-point numbers. Note values smaller than + `-1.79769313486232e+308` and values greater than `1.79769313486232e+308` + will be stored as NaN internally and be serialized to `null`. + + #### Storage + + Floating-point number values are stored directly inside a @ref basic_json + type. + + @sa @ref number_integer_t -- type for number values (integer) + + @sa @ref number_unsigned_t -- type for number values (unsigned integer) + + @since version 1.0.0 + */ + using number_float_t = NumberFloatType; + + /// @} + + private: + + /// helper for exception-safe object creation + template + static T* create(Args&& ... args) + { + AllocatorType alloc; + using AllocatorTraits = std::allocator_traits>; + + auto deleter = [&](T * object) + { + AllocatorTraits::deallocate(alloc, object, 1); + }; + std::unique_ptr object(AllocatorTraits::allocate(alloc, 1), deleter); + AllocatorTraits::construct(alloc, object.get(), std::forward(args)...); + assert(object != nullptr); + return object.release(); + } + + //////////////////////// + // JSON value storage // + //////////////////////// + + /*! + @brief a JSON value + + The actual storage for a JSON value of the @ref basic_json class. This + union combines the different storage types for the JSON value types + defined in @ref value_t. + + JSON type | value_t type | used type + --------- | --------------- | ------------------------ + object | object | pointer to @ref object_t + array | array | pointer to @ref array_t + string | string | pointer to @ref string_t + boolean | boolean | @ref boolean_t + number | number_integer | @ref number_integer_t + number | number_unsigned | @ref number_unsigned_t + number | number_float | @ref number_float_t + null | null | *no value is stored* + + @note Variable-length types (objects, arrays, and strings) are stored as + pointers. The size of the union should not exceed 64 bits if the default + value types are used. + + @since version 1.0.0 + */ + union json_value + { + /// object (stored with pointer to save storage) + object_t* object; + /// array (stored with pointer to save storage) + array_t* array; + /// string (stored with pointer to save storage) + string_t* string; + /// boolean + boolean_t boolean; + /// number (integer) + number_integer_t number_integer; + /// number (unsigned integer) + number_unsigned_t number_unsigned; + /// number (floating-point) + number_float_t number_float; + + /// default constructor (for null values) + json_value() = default; + /// constructor for booleans + json_value(boolean_t v) noexcept : boolean(v) {} + /// constructor for numbers (integer) + json_value(number_integer_t v) noexcept : number_integer(v) {} + /// constructor for numbers (unsigned) + json_value(number_unsigned_t v) noexcept : number_unsigned(v) {} + /// constructor for numbers (floating-point) + json_value(number_float_t v) noexcept : number_float(v) {} + /// constructor for empty values of a given type + json_value(value_t t) + { + switch (t) + { + case value_t::object: + { + object = create(); + break; + } + + case value_t::array: + { + array = create(); + break; + } + + case value_t::string: + { + string = create(""); + break; + } + + case value_t::boolean: + { + boolean = boolean_t(false); + break; + } + + case value_t::number_integer: + { + number_integer = number_integer_t(0); + break; + } + + case value_t::number_unsigned: + { + number_unsigned = number_unsigned_t(0); + break; + } + + case value_t::number_float: + { + number_float = number_float_t(0.0); + break; + } + + case value_t::null: + { + object = nullptr; // silence warning, see #821 + break; + } + + default: + { + object = nullptr; // silence warning, see #821 + if (JSON_UNLIKELY(t == value_t::null)) + { + JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.0.1")); // LCOV_EXCL_LINE + } + break; + } + } + } + + /// constructor for strings + json_value(const string_t& value) + { + string = create(value); + } + + /// constructor for rvalue strings + json_value(string_t&& value) + { + string = create(std::move(value)); + } + + /// constructor for objects + json_value(const object_t& value) + { + object = create(value); + } + + /// constructor for rvalue objects + json_value(object_t&& value) + { + object = create(std::move(value)); + } + + /// constructor for arrays + json_value(const array_t& value) + { + array = create(value); + } + + /// constructor for rvalue arrays + json_value(array_t&& value) + { + array = create(std::move(value)); + } + + void destroy(value_t t) + { + switch (t) + { + case value_t::object: + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, object); + std::allocator_traits::deallocate(alloc, object, 1); + break; + } + + case value_t::array: + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, array); + std::allocator_traits::deallocate(alloc, array, 1); + break; + } + + case value_t::string: + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, string); + std::allocator_traits::deallocate(alloc, string, 1); + break; + } + + default: + { + break; + } + } + } + }; + + /*! + @brief checks the class invariants + + This function asserts the class invariants. It needs to be called at the + end of every constructor to make sure that created objects respect the + invariant. Furthermore, it has to be called each time the type of a JSON + value is changed, because the invariant expresses a relationship between + @a m_type and @a m_value. + */ + void assert_invariant() const + { + assert(m_type != value_t::object or m_value.object != nullptr); + assert(m_type != value_t::array or m_value.array != nullptr); + assert(m_type != value_t::string or m_value.string != nullptr); + } + + public: + ////////////////////////// + // JSON parser callback // + ////////////////////////// + + /*! + @brief parser event types + + The parser callback distinguishes the following events: + - `object_start`: the parser read `{` and started to process a JSON object + - `key`: the parser read a key of a value in an object + - `object_end`: the parser read `}` and finished processing a JSON object + - `array_start`: the parser read `[` and started to process a JSON array + - `array_end`: the parser read `]` and finished processing a JSON array + - `value`: the parser finished reading a JSON value + + @image html callback_events.png "Example when certain parse events are triggered" + + @sa @ref parser_callback_t for more information and examples + */ + using parse_event_t = typename parser::parse_event_t; + + /*! + @brief per-element parser callback type + + With a parser callback function, the result of parsing a JSON text can be + influenced. When passed to @ref parse, it is called on certain events + (passed as @ref parse_event_t via parameter @a event) with a set recursion + depth @a depth and context JSON value @a parsed. The return value of the + callback function is a boolean indicating whether the element that emitted + the callback shall be kept or not. + + We distinguish six scenarios (determined by the event type) in which the + callback function can be called. The following table describes the values + of the parameters @a depth, @a event, and @a parsed. + + parameter @a event | description | parameter @a depth | parameter @a parsed + ------------------ | ----------- | ------------------ | ------------------- + parse_event_t::object_start | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded + parse_event_t::key | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key + parse_event_t::object_end | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object + parse_event_t::array_start | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded + parse_event_t::array_end | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array + parse_event_t::value | the parser finished reading a JSON value | depth of the value | the parsed JSON value + + @image html callback_events.png "Example when certain parse events are triggered" + + Discarding a value (i.e., returning `false`) has different effects + depending on the context in which function was called: + + - Discarded values in structured types are skipped. That is, the parser + will behave as if the discarded value was never read. + - In case a value outside a structured type is skipped, it is replaced + with `null`. This case happens if the top-level element is skipped. + + @param[in] depth the depth of the recursion during parsing + + @param[in] event an event of type parse_event_t indicating the context in + the callback function has been called + + @param[in,out] parsed the current intermediate parse result; note that + writing to this value has no effect for parse_event_t::key events + + @return Whether the JSON value which called the function during parsing + should be kept (`true`) or not (`false`). In the latter case, it is either + skipped completely or replaced by an empty discarded object. + + @sa @ref parse for examples + + @since version 1.0.0 + */ + using parser_callback_t = typename parser::parser_callback_t; + + + ////////////////// + // constructors // + ////////////////// + + /// @name constructors and destructors + /// Constructors of class @ref basic_json, copy/move constructor, copy + /// assignment, static functions creating objects, and the destructor. + /// @{ + + /*! + @brief create an empty value with a given type + + Create an empty JSON value with a given type. The value will be default + initialized with an empty value which depends on the type: + + Value type | initial value + ----------- | ------------- + null | `null` + boolean | `false` + string | `""` + number | `0` + object | `{}` + array | `[]` + + @param[in] v the type of the value to create + + @complexity Constant. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The following code shows the constructor for different @ref + value_t values,basic_json__value_t} + + @sa @ref clear() -- restores the postcondition of this constructor + + @since version 1.0.0 + */ + basic_json(const value_t v) + : m_type(v), m_value(v) + { + assert_invariant(); + } + + /*! + @brief create a null object + + Create a `null` JSON value. It either takes a null pointer as parameter + (explicitly creating `null`) or no parameter (implicitly creating `null`). + The passed null pointer itself is not read -- it is only used to choose + the right constructor. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this constructor never throws + exceptions. + + @liveexample{The following code shows the constructor with and without a + null pointer parameter.,basic_json__nullptr_t} + + @since version 1.0.0 + */ + basic_json(std::nullptr_t = nullptr) noexcept + : basic_json(value_t::null) + { + assert_invariant(); + } + + /*! + @brief create a JSON value + + This is a "catch all" constructor for all compatible JSON types; that is, + types for which a `to_json()` method exists. The constructor forwards the + parameter @a val to that method (to `json_serializer::to_json` method + with `U = uncvref_t`, to be exact). + + Template type @a CompatibleType includes, but is not limited to, the + following types: + - **arrays**: @ref array_t and all kinds of compatible containers such as + `std::vector`, `std::deque`, `std::list`, `std::forward_list`, + `std::array`, `std::valarray`, `std::set`, `std::unordered_set`, + `std::multiset`, and `std::unordered_multiset` with a `value_type` from + which a @ref basic_json value can be constructed. + - **objects**: @ref object_t and all kinds of compatible associative + containers such as `std::map`, `std::unordered_map`, `std::multimap`, + and `std::unordered_multimap` with a `key_type` compatible to + @ref string_t and a `value_type` from which a @ref basic_json value can + be constructed. + - **strings**: @ref string_t, string literals, and all compatible string + containers can be used. + - **numbers**: @ref number_integer_t, @ref number_unsigned_t, + @ref number_float_t, and all convertible number types such as `int`, + `size_t`, `int64_t`, `float` or `double` can be used. + - **boolean**: @ref boolean_t / `bool` can be used. + + See the examples below. + + @tparam CompatibleType a type such that: + - @a CompatibleType is not derived from `std::istream`, + - @a CompatibleType is not @ref basic_json (to avoid hijacking copy/move + constructors), + - @a CompatibleType is not a @ref basic_json nested type (e.g., + @ref json_pointer, @ref iterator, etc ...) + - @ref @ref json_serializer has a + `to_json(basic_json_t&, CompatibleType&&)` method + + @tparam U = `uncvref_t` + + @param[in] val the value to be forwarded to the respective constructor + + @complexity Usually linear in the size of the passed @a val, also + depending on the implementation of the called `to_json()` + method. + + @exceptionsafety Depends on the called constructor. For types directly + supported by the library (i.e., all types for which no `to_json()` function + was provided), strong guarantee holds: if an exception is thrown, there are + no changes to any JSON value. + + @liveexample{The following code shows the constructor with several + compatible types.,basic_json__CompatibleType} + + @since version 2.1.0 + */ + template, + detail::enable_if_t::value and + not std::is_same::value and + not detail::is_basic_json_nested_type< + basic_json_t, U>::value and + detail::has_to_json::value, + int> = 0> + basic_json(CompatibleType && val) noexcept(noexcept(JSONSerializer::to_json( + std::declval(), std::forward(val)))) + { + JSONSerializer::to_json(*this, std::forward(val)); + assert_invariant(); + } + + /*! + @brief create a container (array or object) from an initializer list + + Creates a JSON value of type array or object from the passed initializer + list @a init. In case @a type_deduction is `true` (default), the type of + the JSON value to be created is deducted from the initializer list @a init + according to the following rules: + + 1. If the list is empty, an empty JSON object value `{}` is created. + 2. If the list consists of pairs whose first element is a string, a JSON + object value is created where the first elements of the pairs are + treated as keys and the second elements are as values. + 3. In all other cases, an array is created. + + The rules aim to create the best fit between a C++ initializer list and + JSON values. The rationale is as follows: + + 1. The empty initializer list is written as `{}` which is exactly an empty + JSON object. + 2. C++ has no way of describing mapped types other than to list a list of + pairs. As JSON requires that keys must be of type string, rule 2 is the + weakest constraint one can pose on initializer lists to interpret them + as an object. + 3. In all other cases, the initializer list could not be interpreted as + JSON object type, so interpreting it as JSON array type is safe. + + With the rules described above, the following JSON values cannot be + expressed by an initializer list: + + - the empty array (`[]`): use @ref array(initializer_list_t) + with an empty initializer list in this case + - arrays whose elements satisfy rule 2: use @ref + array(initializer_list_t) with the same initializer list + in this case + + @note When used without parentheses around an empty initializer list, @ref + basic_json() is called instead of this function, yielding the JSON null + value. + + @param[in] init initializer list with JSON values + + @param[in] type_deduction internal parameter; when set to `true`, the type + of the JSON value is deducted from the initializer list @a init; when set + to `false`, the type provided via @a manual_type is forced. This mode is + used by the functions @ref array(initializer_list_t) and + @ref object(initializer_list_t). + + @param[in] manual_type internal parameter; when @a type_deduction is set + to `false`, the created JSON value will use the provided type (only @ref + value_t::array and @ref value_t::object are valid); when @a type_deduction + is set to `true`, this parameter has no effect + + @throw type_error.301 if @a type_deduction is `false`, @a manual_type is + `value_t::object`, but @a init contains an element which is not a pair + whose first element is a string. In this case, the constructor could not + create an object. If @a type_deduction would have be `true`, an array + would have been created. See @ref object(initializer_list_t) + for an example. + + @complexity Linear in the size of the initializer list @a init. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The example below shows how JSON values are created from + initializer lists.,basic_json__list_init_t} + + @sa @ref array(initializer_list_t) -- create a JSON array + value from an initializer list + @sa @ref object(initializer_list_t) -- create a JSON object + value from an initializer list + + @since version 1.0.0 + */ + basic_json(initializer_list_t init, + bool type_deduction = true, + value_t manual_type = value_t::array) + { + // check if each element is an array with two elements whose first + // element is a string + bool is_an_object = std::all_of(init.begin(), init.end(), + [](const detail::json_ref& element_ref) + { + return (element_ref->is_array() and element_ref->size() == 2 and (*element_ref)[0].is_string()); + }); + + // adjust type if type deduction is not wanted + if (not type_deduction) + { + // if array is wanted, do not create an object though possible + if (manual_type == value_t::array) + { + is_an_object = false; + } + + // if object is wanted but impossible, throw an exception + if (JSON_UNLIKELY(manual_type == value_t::object and not is_an_object)) + { + JSON_THROW(type_error::create(301, "cannot create object from initializer list")); + } + } + + if (is_an_object) + { + // the initializer list is a list of pairs -> create object + m_type = value_t::object; + m_value = value_t::object; + + std::for_each(init.begin(), init.end(), [this](const detail::json_ref& element_ref) + { + auto element = element_ref.moved_or_copied(); + m_value.object->emplace( + std::move(*((*element.m_value.array)[0].m_value.string)), + std::move((*element.m_value.array)[1])); + }); + } + else + { + // the initializer list describes an array -> create array + m_type = value_t::array; + m_value.array = create(init.begin(), init.end()); + } + + assert_invariant(); + } + + /*! + @brief explicitly create an array from an initializer list + + Creates a JSON array value from a given initializer list. That is, given a + list of values `a, b, c`, creates the JSON value `[a, b, c]`. If the + initializer list is empty, the empty array `[]` is created. + + @note This function is only needed to express two edge cases that cannot + be realized with the initializer list constructor (@ref + basic_json(initializer_list_t, bool, value_t)). These cases + are: + 1. creating an array whose elements are all pairs whose first element is a + string -- in this case, the initializer list constructor would create an + object, taking the first elements as keys + 2. creating an empty array -- passing the empty initializer list to the + initializer list constructor yields an empty object + + @param[in] init initializer list with JSON values to create an array from + (optional) + + @return JSON array value + + @complexity Linear in the size of @a init. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The following code shows an example for the `array` + function.,array} + + @sa @ref basic_json(initializer_list_t, bool, value_t) -- + create a JSON value from an initializer list + @sa @ref object(initializer_list_t) -- create a JSON object + value from an initializer list + + @since version 1.0.0 + */ + static basic_json array(initializer_list_t init = {}) + { + return basic_json(init, false, value_t::array); + } + + /*! + @brief explicitly create an object from an initializer list + + Creates a JSON object value from a given initializer list. The initializer + lists elements must be pairs, and their first elements must be strings. If + the initializer list is empty, the empty object `{}` is created. + + @note This function is only added for symmetry reasons. In contrast to the + related function @ref array(initializer_list_t), there are + no cases which can only be expressed by this function. That is, any + initializer list @a init can also be passed to the initializer list + constructor @ref basic_json(initializer_list_t, bool, value_t). + + @param[in] init initializer list to create an object from (optional) + + @return JSON object value + + @throw type_error.301 if @a init is not a list of pairs whose first + elements are strings. In this case, no object can be created. When such a + value is passed to @ref basic_json(initializer_list_t, bool, value_t), + an array would have been created from the passed initializer list @a init. + See example below. + + @complexity Linear in the size of @a init. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The following code shows an example for the `object` + function.,object} + + @sa @ref basic_json(initializer_list_t, bool, value_t) -- + create a JSON value from an initializer list + @sa @ref array(initializer_list_t) -- create a JSON array + value from an initializer list + + @since version 1.0.0 + */ + static basic_json object(initializer_list_t init = {}) + { + return basic_json(init, false, value_t::object); + } + + /*! + @brief construct an array with count copies of given value + + Constructs a JSON array value by creating @a cnt copies of a passed value. + In case @a cnt is `0`, an empty array is created. + + @param[in] cnt the number of JSON copies of @a val to create + @param[in] val the JSON value to copy + + @post `std::distance(begin(),end()) == cnt` holds. + + @complexity Linear in @a cnt. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The following code shows examples for the @ref + basic_json(size_type\, const basic_json&) + constructor.,basic_json__size_type_basic_json} + + @since version 1.0.0 + */ + basic_json(size_type cnt, const basic_json& val) + : m_type(value_t::array) + { + m_value.array = create(cnt, val); + assert_invariant(); + } + + /*! + @brief construct a JSON container given an iterator range + + Constructs the JSON value with the contents of the range `[first, last)`. + The semantics depends on the different types a JSON value can have: + - In case of a null type, invalid_iterator.206 is thrown. + - In case of other primitive types (number, boolean, or string), @a first + must be `begin()` and @a last must be `end()`. In this case, the value is + copied. Otherwise, invalid_iterator.204 is thrown. + - In case of structured types (array, object), the constructor behaves as + similar versions for `std::vector` or `std::map`; that is, a JSON array + or object is constructed from the values in the range. + + @tparam InputIT an input iterator type (@ref iterator or @ref + const_iterator) + + @param[in] first begin of the range to copy from (included) + @param[in] last end of the range to copy from (excluded) + + @pre Iterators @a first and @a last must be initialized. **This + precondition is enforced with an assertion (see warning).** If + assertions are switched off, a violation of this precondition yields + undefined behavior. + + @pre Range `[first, last)` is valid. Usually, this precondition cannot be + checked efficiently. Only certain edge cases are detected; see the + description of the exceptions below. A violation of this precondition + yields undefined behavior. + + @warning A precondition is enforced with a runtime assertion that will + result in calling `std::abort` if this precondition is not met. + Assertions can be disabled by defining `NDEBUG` at compile time. + See http://en.cppreference.com/w/cpp/error/assert for more + information. + + @throw invalid_iterator.201 if iterators @a first and @a last are not + compatible (i.e., do not belong to the same JSON value). In this case, + the range `[first, last)` is undefined. + @throw invalid_iterator.204 if iterators @a first and @a last belong to a + primitive type (number, boolean, or string), but @a first does not point + to the first element any more. In this case, the range `[first, last)` is + undefined. See example code below. + @throw invalid_iterator.206 if iterators @a first and @a last belong to a + null value. In this case, the range `[first, last)` is undefined. + + @complexity Linear in distance between @a first and @a last. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The example below shows several ways to create JSON values by + specifying a subrange with iterators.,basic_json__InputIt_InputIt} + + @since version 1.0.0 + */ + template::value or + std::is_same::value, int>::type = 0> + basic_json(InputIT first, InputIT last) + { + assert(first.m_object != nullptr); + assert(last.m_object != nullptr); + + // make sure iterator fits the current value + if (JSON_UNLIKELY(first.m_object != last.m_object)) + { + JSON_THROW(invalid_iterator::create(201, "iterators are not compatible")); + } + + // copy type from first iterator + m_type = first.m_object->m_type; + + // check if iterator range is complete for primitive values + switch (m_type) + { + case value_t::boolean: + case value_t::number_float: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::string: + { + if (JSON_UNLIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) + { + JSON_THROW(invalid_iterator::create(204, "iterators out of range")); + } + break; + } + + default: + break; + } + + switch (m_type) + { + case value_t::number_integer: + { + m_value.number_integer = first.m_object->m_value.number_integer; + break; + } + + case value_t::number_unsigned: + { + m_value.number_unsigned = first.m_object->m_value.number_unsigned; + break; + } + + case value_t::number_float: + { + m_value.number_float = first.m_object->m_value.number_float; + break; + } + + case value_t::boolean: + { + m_value.boolean = first.m_object->m_value.boolean; + break; + } + + case value_t::string: + { + m_value = *first.m_object->m_value.string; + break; + } + + case value_t::object: + { + m_value.object = create(first.m_it.object_iterator, + last.m_it.object_iterator); + break; + } + + case value_t::array: + { + m_value.array = create(first.m_it.array_iterator, + last.m_it.array_iterator); + break; + } + + default: + JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + + std::string(first.m_object->type_name()))); + } + + assert_invariant(); + } + + + /////////////////////////////////////// + // other constructors and destructor // + /////////////////////////////////////// + + /// @private + basic_json(const detail::json_ref& ref) + : basic_json(ref.moved_or_copied()) + {} + + /*! + @brief copy constructor + + Creates a copy of a given JSON value. + + @param[in] other the JSON value to copy + + @post `*this == other` + + @complexity Linear in the size of @a other. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is linear. + - As postcondition, it holds: `other == basic_json(other)`. + + @liveexample{The following code shows an example for the copy + constructor.,basic_json__basic_json} + + @since version 1.0.0 + */ + basic_json(const basic_json& other) + : m_type(other.m_type) + { + // check of passed value is valid + other.assert_invariant(); + + switch (m_type) + { + case value_t::object: + { + m_value = *other.m_value.object; + break; + } + + case value_t::array: + { + m_value = *other.m_value.array; + break; + } + + case value_t::string: + { + m_value = *other.m_value.string; + break; + } + + case value_t::boolean: + { + m_value = other.m_value.boolean; + break; + } + + case value_t::number_integer: + { + m_value = other.m_value.number_integer; + break; + } + + case value_t::number_unsigned: + { + m_value = other.m_value.number_unsigned; + break; + } + + case value_t::number_float: + { + m_value = other.m_value.number_float; + break; + } + + default: + break; + } + + assert_invariant(); + } + + /*! + @brief move constructor + + Move constructor. Constructs a JSON value with the contents of the given + value @a other using move semantics. It "steals" the resources from @a + other and leaves it as JSON null value. + + @param[in,out] other value to move to this object + + @post `*this` has the same value as @a other before the call. + @post @a other is a JSON null value. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this constructor never throws + exceptions. + + @requirement This function helps `basic_json` satisfying the + [MoveConstructible](http://en.cppreference.com/w/cpp/concept/MoveConstructible) + requirements. + + @liveexample{The code below shows the move constructor explicitly called + via std::move.,basic_json__moveconstructor} + + @since version 1.0.0 + */ + basic_json(basic_json&& other) noexcept + : m_type(std::move(other.m_type)), + m_value(std::move(other.m_value)) + { + // check that passed value is valid + other.assert_invariant(); + + // invalidate payload + other.m_type = value_t::null; + other.m_value = {}; + + assert_invariant(); + } + + /*! + @brief copy assignment + + Copy assignment operator. Copies a JSON value via the "copy and swap" + strategy: It is expressed in terms of the copy constructor, destructor, + and the `swap()` member function. + + @param[in] other value to copy from + + @complexity Linear. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is linear. + + @liveexample{The code below shows and example for the copy assignment. It + creates a copy of value `a` which is then swapped with `b`. Finally\, the + copy of `a` (which is the null value after the swap) is + destroyed.,basic_json__copyassignment} + + @since version 1.0.0 + */ + reference& operator=(basic_json other) noexcept ( + std::is_nothrow_move_constructible::value and + std::is_nothrow_move_assignable::value and + std::is_nothrow_move_constructible::value and + std::is_nothrow_move_assignable::value + ) + { + // check that passed value is valid + other.assert_invariant(); + + using std::swap; + swap(m_type, other.m_type); + swap(m_value, other.m_value); + + assert_invariant(); + return *this; + } + + /*! + @brief destructor + + Destroys the JSON value and frees all allocated memory. + + @complexity Linear. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is linear. + - All stored elements are destroyed and all memory is freed. + + @since version 1.0.0 + */ + ~basic_json() + { + assert_invariant(); + m_value.destroy(m_type); + } + + /// @} + + public: + /////////////////////// + // object inspection // + /////////////////////// + + /// @name object inspection + /// Functions to inspect the type of a JSON value. + /// @{ + + /*! + @brief serialization + + Serialization function for JSON values. The function tries to mimic + Python's `json.dumps()` function, and currently supports its @a indent + and @a ensure_ascii parameters. + + @param[in] indent If indent is nonnegative, then array elements and object + members will be pretty-printed with that indent level. An indent level of + `0` will only insert newlines. `-1` (the default) selects the most compact + representation. + @param[in] indent_char The character to use for indentation if @a indent is + greater than `0`. The default is ` ` (space). + @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters + in the output are escaped with `\uXXXX` sequences, and the result consists + of ASCII characters only. + + @return string containing the serialization of the JSON value + + @throw type_error.316 if a string stored inside the JSON value is not + UTF-8 encoded + + @complexity Linear. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @liveexample{The following example shows the effect of different @a indent\, + @a indent_char\, and @a ensure_ascii parameters to the result of the + serialization.,dump} + + @see https://docs.python.org/2/library/json.html#json.dump + + @since version 1.0.0; indentation character @a indent_char, option + @a ensure_ascii and exceptions added in version 3.0.0 + */ + string_t dump(const int indent = -1, const char indent_char = ' ', + const bool ensure_ascii = false) const + { + string_t result; + serializer s(detail::output_adapter(result), indent_char); + + if (indent >= 0) + { + s.dump(*this, true, ensure_ascii, static_cast(indent)); + } + else + { + s.dump(*this, false, ensure_ascii, 0); + } + + return result; + } + + /*! + @brief return the type of the JSON value (explicit) + + Return the type of the JSON value as a value from the @ref value_t + enumeration. + + @return the type of the JSON value + Value type | return value + ------------------------- | ------------------------- + null | value_t::null + boolean | value_t::boolean + string | value_t::string + number (integer) | value_t::number_integer + number (unsigned integer) | value_t::number_unsigned + number (floating-point) | value_t::number_float + object | value_t::object + array | value_t::array + discarded | value_t::discarded + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `type()` for all JSON + types.,type} + + @sa @ref operator value_t() -- return the type of the JSON value (implicit) + @sa @ref type_name() -- return the type as string + + @since version 1.0.0 + */ + constexpr value_t type() const noexcept + { + return m_type; + } + + /*! + @brief return whether type is primitive + + This function returns true if and only if the JSON type is primitive + (string, number, boolean, or null). + + @return `true` if type is primitive (string, number, boolean, or null), + `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_primitive()` for all JSON + types.,is_primitive} + + @sa @ref is_structured() -- returns whether JSON value is structured + @sa @ref is_null() -- returns whether JSON value is `null` + @sa @ref is_string() -- returns whether JSON value is a string + @sa @ref is_boolean() -- returns whether JSON value is a boolean + @sa @ref is_number() -- returns whether JSON value is a number + + @since version 1.0.0 + */ + constexpr bool is_primitive() const noexcept + { + return is_null() or is_string() or is_boolean() or is_number(); + } + + /*! + @brief return whether type is structured + + This function returns true if and only if the JSON type is structured + (array or object). + + @return `true` if type is structured (array or object), `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_structured()` for all JSON + types.,is_structured} + + @sa @ref is_primitive() -- returns whether value is primitive + @sa @ref is_array() -- returns whether value is an array + @sa @ref is_object() -- returns whether value is an object + + @since version 1.0.0 + */ + constexpr bool is_structured() const noexcept + { + return is_array() or is_object(); + } + + /*! + @brief return whether value is null + + This function returns true if and only if the JSON value is null. + + @return `true` if type is null, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_null()` for all JSON + types.,is_null} + + @since version 1.0.0 + */ + constexpr bool is_null() const noexcept + { + return (m_type == value_t::null); + } + + /*! + @brief return whether value is a boolean + + This function returns true if and only if the JSON value is a boolean. + + @return `true` if type is boolean, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_boolean()` for all JSON + types.,is_boolean} + + @since version 1.0.0 + */ + constexpr bool is_boolean() const noexcept + { + return (m_type == value_t::boolean); + } + + /*! + @brief return whether value is a number + + This function returns true if and only if the JSON value is a number. This + includes both integer (signed and unsigned) and floating-point values. + + @return `true` if type is number (regardless whether integer, unsigned + integer or floating-type), `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_number()` for all JSON + types.,is_number} + + @sa @ref is_number_integer() -- check if value is an integer or unsigned + integer number + @sa @ref is_number_unsigned() -- check if value is an unsigned integer + number + @sa @ref is_number_float() -- check if value is a floating-point number + + @since version 1.0.0 + */ + constexpr bool is_number() const noexcept + { + return is_number_integer() or is_number_float(); + } + + /*! + @brief return whether value is an integer number + + This function returns true if and only if the JSON value is a signed or + unsigned integer number. This excludes floating-point values. + + @return `true` if type is an integer or unsigned integer number, `false` + otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_number_integer()` for all + JSON types.,is_number_integer} + + @sa @ref is_number() -- check if value is a number + @sa @ref is_number_unsigned() -- check if value is an unsigned integer + number + @sa @ref is_number_float() -- check if value is a floating-point number + + @since version 1.0.0 + */ + constexpr bool is_number_integer() const noexcept + { + return (m_type == value_t::number_integer or m_type == value_t::number_unsigned); + } + + /*! + @brief return whether value is an unsigned integer number + + This function returns true if and only if the JSON value is an unsigned + integer number. This excludes floating-point and signed integer values. + + @return `true` if type is an unsigned integer number, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_number_unsigned()` for all + JSON types.,is_number_unsigned} + + @sa @ref is_number() -- check if value is a number + @sa @ref is_number_integer() -- check if value is an integer or unsigned + integer number + @sa @ref is_number_float() -- check if value is a floating-point number + + @since version 2.0.0 + */ + constexpr bool is_number_unsigned() const noexcept + { + return (m_type == value_t::number_unsigned); + } + + /*! + @brief return whether value is a floating-point number + + This function returns true if and only if the JSON value is a + floating-point number. This excludes signed and unsigned integer values. + + @return `true` if type is a floating-point number, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_number_float()` for all + JSON types.,is_number_float} + + @sa @ref is_number() -- check if value is number + @sa @ref is_number_integer() -- check if value is an integer number + @sa @ref is_number_unsigned() -- check if value is an unsigned integer + number + + @since version 1.0.0 + */ + constexpr bool is_number_float() const noexcept + { + return (m_type == value_t::number_float); + } + + /*! + @brief return whether value is an object + + This function returns true if and only if the JSON value is an object. + + @return `true` if type is object, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_object()` for all JSON + types.,is_object} + + @since version 1.0.0 + */ + constexpr bool is_object() const noexcept + { + return (m_type == value_t::object); + } + + /*! + @brief return whether value is an array + + This function returns true if and only if the JSON value is an array. + + @return `true` if type is array, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_array()` for all JSON + types.,is_array} + + @since version 1.0.0 + */ + constexpr bool is_array() const noexcept + { + return (m_type == value_t::array); + } + + /*! + @brief return whether value is a string + + This function returns true if and only if the JSON value is a string. + + @return `true` if type is string, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_string()` for all JSON + types.,is_string} + + @since version 1.0.0 + */ + constexpr bool is_string() const noexcept + { + return (m_type == value_t::string); + } + + /*! + @brief return whether value is discarded + + This function returns true if and only if the JSON value was discarded + during parsing with a callback function (see @ref parser_callback_t). + + @note This function will always be `false` for JSON values after parsing. + That is, discarded values can only occur during parsing, but will be + removed when inside a structured value or replaced by null in other cases. + + @return `true` if type is discarded, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_discarded()` for all JSON + types.,is_discarded} + + @since version 1.0.0 + */ + constexpr bool is_discarded() const noexcept + { + return (m_type == value_t::discarded); + } + + /*! + @brief return the type of the JSON value (implicit) + + Implicitly return the type of the JSON value as a value from the @ref + value_t enumeration. + + @return the type of the JSON value + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies the @ref value_t operator for + all JSON types.,operator__value_t} + + @sa @ref type() -- return the type of the JSON value (explicit) + @sa @ref type_name() -- return the type as string + + @since version 1.0.0 + */ + constexpr operator value_t() const noexcept + { + return m_type; + } + + /// @} + + private: + ////////////////// + // value access // + ////////////////// + + /// get a boolean (explicit) + boolean_t get_impl(boolean_t* /*unused*/) const + { + if (JSON_LIKELY(is_boolean())) + { + return m_value.boolean; + } + + JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name()))); + } + + /// get a pointer to the value (object) + object_t* get_impl_ptr(object_t* /*unused*/) noexcept + { + return is_object() ? m_value.object : nullptr; + } + + /// get a pointer to the value (object) + constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept + { + return is_object() ? m_value.object : nullptr; + } + + /// get a pointer to the value (array) + array_t* get_impl_ptr(array_t* /*unused*/) noexcept + { + return is_array() ? m_value.array : nullptr; + } + + /// get a pointer to the value (array) + constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept + { + return is_array() ? m_value.array : nullptr; + } + + /// get a pointer to the value (string) + string_t* get_impl_ptr(string_t* /*unused*/) noexcept + { + return is_string() ? m_value.string : nullptr; + } + + /// get a pointer to the value (string) + constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept + { + return is_string() ? m_value.string : nullptr; + } + + /// get a pointer to the value (boolean) + boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept + { + return is_boolean() ? &m_value.boolean : nullptr; + } + + /// get a pointer to the value (boolean) + constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept + { + return is_boolean() ? &m_value.boolean : nullptr; + } + + /// get a pointer to the value (integer number) + number_integer_t* get_impl_ptr(number_integer_t* /*unused*/) noexcept + { + return is_number_integer() ? &m_value.number_integer : nullptr; + } + + /// get a pointer to the value (integer number) + constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept + { + return is_number_integer() ? &m_value.number_integer : nullptr; + } + + /// get a pointer to the value (unsigned number) + number_unsigned_t* get_impl_ptr(number_unsigned_t* /*unused*/) noexcept + { + return is_number_unsigned() ? &m_value.number_unsigned : nullptr; + } + + /// get a pointer to the value (unsigned number) + constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept + { + return is_number_unsigned() ? &m_value.number_unsigned : nullptr; + } + + /// get a pointer to the value (floating-point number) + number_float_t* get_impl_ptr(number_float_t* /*unused*/) noexcept + { + return is_number_float() ? &m_value.number_float : nullptr; + } + + /// get a pointer to the value (floating-point number) + constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept + { + return is_number_float() ? &m_value.number_float : nullptr; + } + + /*! + @brief helper function to implement get_ref() + + This function helps to implement get_ref() without code duplication for + const and non-const overloads + + @tparam ThisType will be deduced as `basic_json` or `const basic_json` + + @throw type_error.303 if ReferenceType does not match underlying value + type of the current JSON + */ + template + static ReferenceType get_ref_impl(ThisType& obj) + { + // delegate the call to get_ptr<>() + auto ptr = obj.template get_ptr::type>(); + + if (JSON_LIKELY(ptr != nullptr)) + { + return *ptr; + } + + JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name()))); + } + + public: + /// @name value access + /// Direct access to the stored value of a JSON value. + /// @{ + + /*! + @brief get special-case overload + + This overloads avoids a lot of template boilerplate, it can be seen as the + identity method + + @tparam BasicJsonType == @ref basic_json + + @return a copy of *this + + @complexity Constant. + + @since version 2.1.0 + */ + template::type, basic_json_t>::value, + int> = 0> + basic_json get() const + { + return *this; + } + + /*! + @brief get a value (explicit) + + Explicit type conversion between the JSON value and a compatible value + which is [CopyConstructible](http://en.cppreference.com/w/cpp/concept/CopyConstructible) + and [DefaultConstructible](http://en.cppreference.com/w/cpp/concept/DefaultConstructible). + The value is converted by calling the @ref json_serializer + `from_json()` method. + + The function is equivalent to executing + @code {.cpp} + ValueType ret; + JSONSerializer::from_json(*this, ret); + return ret; + @endcode + + This overloads is chosen if: + - @a ValueType is not @ref basic_json, + - @ref json_serializer has a `from_json()` method of the form + `void from_json(const basic_json&, ValueType&)`, and + - @ref json_serializer does not have a `from_json()` method of + the form `ValueType from_json(const basic_json&)` + + @tparam ValueTypeCV the provided value type + @tparam ValueType the returned value type + + @return copy of the JSON value, converted to @a ValueType + + @throw what @ref json_serializer `from_json()` method throws + + @liveexample{The example below shows several conversions from JSON values + to other types. There a few things to note: (1) Floating-point numbers can + be converted to integers\, (2) A JSON array can be converted to a standard + `std::vector`\, (3) A JSON object can be converted to C++ + associative containers such as `std::unordered_map`.,get__ValueType_const} + + @since version 2.1.0 + */ + template, + detail::enable_if_t < + not std::is_same::value and + detail::has_from_json::value and + not detail::has_non_default_from_json::value, + int> = 0> + ValueType get() const noexcept(noexcept( + JSONSerializer::from_json(std::declval(), std::declval()))) + { + // we cannot static_assert on ValueTypeCV being non-const, because + // there is support for get(), which is why we + // still need the uncvref + static_assert(not std::is_reference::value, + "get() cannot be used with reference types, you might want to use get_ref()"); + static_assert(std::is_default_constructible::value, + "types must be DefaultConstructible when used with get()"); + + ValueType ret; + JSONSerializer::from_json(*this, ret); + return ret; + } + + /*! + @brief get a value (explicit); special case + + Explicit type conversion between the JSON value and a compatible value + which is **not** [CopyConstructible](http://en.cppreference.com/w/cpp/concept/CopyConstructible) + and **not** [DefaultConstructible](http://en.cppreference.com/w/cpp/concept/DefaultConstructible). + The value is converted by calling the @ref json_serializer + `from_json()` method. + + The function is equivalent to executing + @code {.cpp} + return JSONSerializer::from_json(*this); + @endcode + + This overloads is chosen if: + - @a ValueType is not @ref basic_json and + - @ref json_serializer has a `from_json()` method of the form + `ValueType from_json(const basic_json&)` + + @note If @ref json_serializer has both overloads of + `from_json()`, this one is chosen. + + @tparam ValueTypeCV the provided value type + @tparam ValueType the returned value type + + @return copy of the JSON value, converted to @a ValueType + + @throw what @ref json_serializer `from_json()` method throws + + @since version 2.1.0 + */ + template, + detail::enable_if_t::value and + detail::has_non_default_from_json::value, + int> = 0> + ValueType get() const noexcept(noexcept( + JSONSerializer::from_json(std::declval()))) + { + static_assert(not std::is_reference::value, + "get() cannot be used with reference types, you might want to use get_ref()"); + return JSONSerializer::from_json(*this); + } + + /*! + @brief get a pointer value (explicit) + + Explicit pointer access to the internally stored JSON value. No copies are + made. + + @warning The pointer becomes invalid if the underlying JSON object + changes. + + @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref + object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, + @ref number_unsigned_t, or @ref number_float_t. + + @return pointer to the internally stored JSON value if the requested + pointer type @a PointerType fits to the JSON value; `nullptr` otherwise + + @complexity Constant. + + @liveexample{The example below shows how pointers to internal values of a + JSON value can be requested. Note that no type conversions are made and a + `nullptr` is returned if the value and the requested pointer type does not + match.,get__PointerType} + + @sa @ref get_ptr() for explicit pointer-member access + + @since version 1.0.0 + */ + template::value, int>::type = 0> + PointerType get() noexcept + { + // delegate the call to get_ptr + return get_ptr(); + } + + /*! + @brief get a pointer value (explicit) + @copydoc get() + */ + template::value, int>::type = 0> + constexpr const PointerType get() const noexcept + { + // delegate the call to get_ptr + return get_ptr(); + } + + /*! + @brief get a pointer value (implicit) + + Implicit pointer access to the internally stored JSON value. No copies are + made. + + @warning Writing data to the pointee of the result yields an undefined + state. + + @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref + object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, + @ref number_unsigned_t, or @ref number_float_t. Enforced by a static + assertion. + + @return pointer to the internally stored JSON value if the requested + pointer type @a PointerType fits to the JSON value; `nullptr` otherwise + + @complexity Constant. + + @liveexample{The example below shows how pointers to internal values of a + JSON value can be requested. Note that no type conversions are made and a + `nullptr` is returned if the value and the requested pointer type does not + match.,get_ptr} + + @since version 1.0.0 + */ + template::value, int>::type = 0> + PointerType get_ptr() noexcept + { + // get the type of the PointerType (remove pointer and const) + using pointee_t = typename std::remove_const::type>::type>::type; + // make sure the type matches the allowed types + static_assert( + std::is_same::value + or std::is_same::value + or std::is_same::value + or std::is_same::value + or std::is_same::value + or std::is_same::value + or std::is_same::value + , "incompatible pointer type"); + + // delegate the call to get_impl_ptr<>() + return get_impl_ptr(static_cast(nullptr)); + } + + /*! + @brief get a pointer value (implicit) + @copydoc get_ptr() + */ + template::value and + std::is_const::type>::value, int>::type = 0> + constexpr const PointerType get_ptr() const noexcept + { + // get the type of the PointerType (remove pointer and const) + using pointee_t = typename std::remove_const::type>::type>::type; + // make sure the type matches the allowed types + static_assert( + std::is_same::value + or std::is_same::value + or std::is_same::value + or std::is_same::value + or std::is_same::value + or std::is_same::value + or std::is_same::value + , "incompatible pointer type"); + + // delegate the call to get_impl_ptr<>() const + return get_impl_ptr(static_cast(nullptr)); + } + + /*! + @brief get a reference value (implicit) + + Implicit reference access to the internally stored JSON value. No copies + are made. + + @warning Writing data to the referee of the result yields an undefined + state. + + @tparam ReferenceType reference type; must be a reference to @ref array_t, + @ref object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, or + @ref number_float_t. Enforced by static assertion. + + @return reference to the internally stored JSON value if the requested + reference type @a ReferenceType fits to the JSON value; throws + type_error.303 otherwise + + @throw type_error.303 in case passed type @a ReferenceType is incompatible + with the stored JSON value; see example below + + @complexity Constant. + + @liveexample{The example shows several calls to `get_ref()`.,get_ref} + + @since version 1.1.0 + */ + template::value, int>::type = 0> + ReferenceType get_ref() + { + // delegate call to get_ref_impl + return get_ref_impl(*this); + } + + /*! + @brief get a reference value (implicit) + @copydoc get_ref() + */ + template::value and + std::is_const::type>::value, int>::type = 0> + ReferenceType get_ref() const + { + // delegate call to get_ref_impl + return get_ref_impl(*this); + } + + /*! + @brief get a value (implicit) + + Implicit type conversion between the JSON value and a compatible value. + The call is realized by calling @ref get() const. + + @tparam ValueType non-pointer type compatible to the JSON value, for + instance `int` for JSON integer numbers, `bool` for JSON booleans, or + `std::vector` types for JSON arrays. The character type of @ref string_t + as well as an initializer list of this type is excluded to avoid + ambiguities as these types implicitly convert to `std::string`. + + @return copy of the JSON value, converted to type @a ValueType + + @throw type_error.302 in case passed type @a ValueType is incompatible + to the JSON value type (e.g., the JSON value is of type boolean, but a + string is requested); see example below + + @complexity Linear in the size of the JSON value. + + @liveexample{The example below shows several conversions from JSON values + to other types. There a few things to note: (1) Floating-point numbers can + be converted to integers\, (2) A JSON array can be converted to a standard + `std::vector`\, (3) A JSON object can be converted to C++ + associative containers such as `std::unordered_map`.,operator__ValueType} + + @since version 1.0.0 + */ + template < typename ValueType, typename std::enable_if < + not std::is_pointer::value and + not std::is_same>::value and + not std::is_same::value +#ifndef _MSC_VER // fix for issue #167 operator<< ambiguity under VS2015 + and not std::is_same>::value +#endif +#if defined(JSON_HAS_CPP_17) + and not std::is_same::value +#endif + , int >::type = 0 > + operator ValueType() const + { + // delegate the call to get<>() const + return get(); + } + + /// @} + + + //////////////////// + // element access // + //////////////////// + + /// @name element access + /// Access to the JSON value. + /// @{ + + /*! + @brief access specified array element with bounds checking + + Returns a reference to the element at specified location @a idx, with + bounds checking. + + @param[in] idx index of the element to access + + @return reference to the element at index @a idx + + @throw type_error.304 if the JSON value is not an array; in this case, + calling `at` with an index makes no sense. See example below. + @throw out_of_range.401 if the index @a idx is out of range of the array; + that is, `idx >= size()`. See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @since version 1.0.0 + + @liveexample{The example below shows how array elements can be read and + written using `at()`. It also demonstrates the different exceptions that + can be thrown.,at__size_type} + */ + reference at(size_type idx) + { + // at only works for arrays + if (JSON_LIKELY(is_array())) + { + JSON_TRY + { + return m_value.array->at(idx); + } + JSON_CATCH (std::out_of_range&) + { + // create better exception explanation + JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); + } + } + else + { + JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()))); + } + } + + /*! + @brief access specified array element with bounds checking + + Returns a const reference to the element at specified location @a idx, + with bounds checking. + + @param[in] idx index of the element to access + + @return const reference to the element at index @a idx + + @throw type_error.304 if the JSON value is not an array; in this case, + calling `at` with an index makes no sense. See example below. + @throw out_of_range.401 if the index @a idx is out of range of the array; + that is, `idx >= size()`. See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @since version 1.0.0 + + @liveexample{The example below shows how array elements can be read using + `at()`. It also demonstrates the different exceptions that can be thrown., + at__size_type_const} + */ + const_reference at(size_type idx) const + { + // at only works for arrays + if (JSON_LIKELY(is_array())) + { + JSON_TRY + { + return m_value.array->at(idx); + } + JSON_CATCH (std::out_of_range&) + { + // create better exception explanation + JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); + } + } + else + { + JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()))); + } + } + + /*! + @brief access specified object element with bounds checking + + Returns a reference to the element at with specified key @a key, with + bounds checking. + + @param[in] key key of the element to access + + @return reference to the element at key @a key + + @throw type_error.304 if the JSON value is not an object; in this case, + calling `at` with a key makes no sense. See example below. + @throw out_of_range.403 if the key @a key is is not stored in the object; + that is, `find(key) == end()`. See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Logarithmic in the size of the container. + + @sa @ref operator[](const typename object_t::key_type&) for unchecked + access by reference + @sa @ref value() for access by value with a default value + + @since version 1.0.0 + + @liveexample{The example below shows how object elements can be read and + written using `at()`. It also demonstrates the different exceptions that + can be thrown.,at__object_t_key_type} + */ + reference at(const typename object_t::key_type& key) + { + // at only works for objects + if (JSON_LIKELY(is_object())) + { + JSON_TRY + { + return m_value.object->at(key); + } + JSON_CATCH (std::out_of_range&) + { + // create better exception explanation + JSON_THROW(out_of_range::create(403, "key '" + key + "' not found")); + } + } + else + { + JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()))); + } + } + + /*! + @brief access specified object element with bounds checking + + Returns a const reference to the element at with specified key @a key, + with bounds checking. + + @param[in] key key of the element to access + + @return const reference to the element at key @a key + + @throw type_error.304 if the JSON value is not an object; in this case, + calling `at` with a key makes no sense. See example below. + @throw out_of_range.403 if the key @a key is is not stored in the object; + that is, `find(key) == end()`. See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Logarithmic in the size of the container. + + @sa @ref operator[](const typename object_t::key_type&) for unchecked + access by reference + @sa @ref value() for access by value with a default value + + @since version 1.0.0 + + @liveexample{The example below shows how object elements can be read using + `at()`. It also demonstrates the different exceptions that can be thrown., + at__object_t_key_type_const} + */ + const_reference at(const typename object_t::key_type& key) const + { + // at only works for objects + if (JSON_LIKELY(is_object())) + { + JSON_TRY + { + return m_value.object->at(key); + } + JSON_CATCH (std::out_of_range&) + { + // create better exception explanation + JSON_THROW(out_of_range::create(403, "key '" + key + "' not found")); + } + } + else + { + JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()))); + } + } + + /*! + @brief access specified array element + + Returns a reference to the element at specified location @a idx. + + @note If @a idx is beyond the range of the array (i.e., `idx >= size()`), + then the array is silently filled up with `null` values to make `idx` a + valid reference to the last stored element. + + @param[in] idx index of the element to access + + @return reference to the element at index @a idx + + @throw type_error.305 if the JSON value is not an array or null; in that + cases, using the [] operator with an index makes no sense. + + @complexity Constant if @a idx is in the range of the array. Otherwise + linear in `idx - size()`. + + @liveexample{The example below shows how array elements can be read and + written using `[]` operator. Note the addition of `null` + values.,operatorarray__size_type} + + @since version 1.0.0 + */ + reference operator[](size_type idx) + { + // implicitly convert null value to an empty array + if (is_null()) + { + m_type = value_t::array; + m_value.array = create(); + assert_invariant(); + } + + // operator[] only works for arrays + if (JSON_LIKELY(is_array())) + { + // fill up array with null values if given idx is outside range + if (idx >= m_value.array->size()) + { + m_value.array->insert(m_value.array->end(), + idx - m_value.array->size() + 1, + basic_json()); + } + + return m_value.array->operator[](idx); + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + } + + /*! + @brief access specified array element + + Returns a const reference to the element at specified location @a idx. + + @param[in] idx index of the element to access + + @return const reference to the element at index @a idx + + @throw type_error.305 if the JSON value is not an array; in that case, + using the [] operator with an index makes no sense. + + @complexity Constant. + + @liveexample{The example below shows how array elements can be read using + the `[]` operator.,operatorarray__size_type_const} + + @since version 1.0.0 + */ + const_reference operator[](size_type idx) const + { + // const operator[] only works for arrays + if (JSON_LIKELY(is_array())) + { + return m_value.array->operator[](idx); + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + } + + /*! + @brief access specified object element + + Returns a reference to the element at with specified key @a key. + + @note If @a key is not found in the object, then it is silently added to + the object and filled with a `null` value to make `key` a valid reference. + In case the value was `null` before, it is converted to an object. + + @param[in] key key of the element to access + + @return reference to the element at key @a key + + @throw type_error.305 if the JSON value is not an object or null; in that + cases, using the [] operator with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read and + written using the `[]` operator.,operatorarray__key_type} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.0.0 + */ + reference operator[](const typename object_t::key_type& key) + { + // implicitly convert null value to an empty object + if (is_null()) + { + m_type = value_t::object; + m_value.object = create(); + assert_invariant(); + } + + // operator[] only works for objects + if (JSON_LIKELY(is_object())) + { + return m_value.object->operator[](key); + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + } + + /*! + @brief read-only access specified object element + + Returns a const reference to the element at with specified key @a key. No + bounds checking is performed. + + @warning If the element with key @a key does not exist, the behavior is + undefined. + + @param[in] key key of the element to access + + @return const reference to the element at key @a key + + @pre The element with key @a key must exist. **This precondition is + enforced with an assertion.** + + @throw type_error.305 if the JSON value is not an object; in that case, + using the [] operator with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read using + the `[]` operator.,operatorarray__key_type_const} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.0.0 + */ + const_reference operator[](const typename object_t::key_type& key) const + { + // const operator[] only works for objects + if (JSON_LIKELY(is_object())) + { + assert(m_value.object->find(key) != m_value.object->end()); + return m_value.object->find(key)->second; + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + } + + /*! + @brief access specified object element + + Returns a reference to the element at with specified key @a key. + + @note If @a key is not found in the object, then it is silently added to + the object and filled with a `null` value to make `key` a valid reference. + In case the value was `null` before, it is converted to an object. + + @param[in] key key of the element to access + + @return reference to the element at key @a key + + @throw type_error.305 if the JSON value is not an object or null; in that + cases, using the [] operator with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read and + written using the `[]` operator.,operatorarray__key_type} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.1.0 + */ + template + reference operator[](T* key) + { + // implicitly convert null to object + if (is_null()) + { + m_type = value_t::object; + m_value = value_t::object; + assert_invariant(); + } + + // at only works for objects + if (JSON_LIKELY(is_object())) + { + return m_value.object->operator[](key); + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + } + + /*! + @brief read-only access specified object element + + Returns a const reference to the element at with specified key @a key. No + bounds checking is performed. + + @warning If the element with key @a key does not exist, the behavior is + undefined. + + @param[in] key key of the element to access + + @return const reference to the element at key @a key + + @pre The element with key @a key must exist. **This precondition is + enforced with an assertion.** + + @throw type_error.305 if the JSON value is not an object; in that case, + using the [] operator with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read using + the `[]` operator.,operatorarray__key_type_const} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.1.0 + */ + template + const_reference operator[](T* key) const + { + // at only works for objects + if (JSON_LIKELY(is_object())) + { + assert(m_value.object->find(key) != m_value.object->end()); + return m_value.object->find(key)->second; + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + } + + /*! + @brief access specified object element with default value + + Returns either a copy of an object's element at the specified key @a key + or a given default value if no element with key @a key exists. + + The function is basically equivalent to executing + @code {.cpp} + try { + return at(key); + } catch(out_of_range) { + return default_value; + } + @endcode + + @note Unlike @ref at(const typename object_t::key_type&), this function + does not throw if the given key @a key was not found. + + @note Unlike @ref operator[](const typename object_t::key_type& key), this + function does not implicitly add an element to the position defined by @a + key. This function is furthermore also applicable to const objects. + + @param[in] key key of the element to access + @param[in] default_value the value to return if @a key is not found + + @tparam ValueType type compatible to JSON values, for instance `int` for + JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for + JSON arrays. Note the type of the expected value at @a key and the default + value @a default_value must be compatible. + + @return copy of the element at key @a key or @a default_value if @a key + is not found + + @throw type_error.306 if the JSON value is not an object; in that case, + using `value()` with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be queried + with a default value.,basic_json__value} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref operator[](const typename object_t::key_type&) for unchecked + access by reference + + @since version 1.0.0 + */ + template::value, int>::type = 0> + ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const + { + // at only works for objects + if (JSON_LIKELY(is_object())) + { + // if key is found, return value and given default value otherwise + const auto it = find(key); + if (it != end()) + { + return *it; + } + + return default_value; + } + + JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()))); + } + + /*! + @brief overload for a default value of type const char* + @copydoc basic_json::value(const typename object_t::key_type&, ValueType) const + */ + string_t value(const typename object_t::key_type& key, const char* default_value) const + { + return value(key, string_t(default_value)); + } + + /*! + @brief access specified object element via JSON Pointer with default value + + Returns either a copy of an object's element at the specified key @a key + or a given default value if no element with key @a key exists. + + The function is basically equivalent to executing + @code {.cpp} + try { + return at(ptr); + } catch(out_of_range) { + return default_value; + } + @endcode + + @note Unlike @ref at(const json_pointer&), this function does not throw + if the given key @a key was not found. + + @param[in] ptr a JSON pointer to the element to access + @param[in] default_value the value to return if @a ptr found no value + + @tparam ValueType type compatible to JSON values, for instance `int` for + JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for + JSON arrays. Note the type of the expected value at @a key and the default + value @a default_value must be compatible. + + @return copy of the element at key @a key or @a default_value if @a key + is not found + + @throw type_error.306 if the JSON value is not an objec; in that case, + using `value()` with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be queried + with a default value.,basic_json__value_ptr} + + @sa @ref operator[](const json_pointer&) for unchecked access by reference + + @since version 2.0.2 + */ + template::value, int>::type = 0> + ValueType value(const json_pointer& ptr, const ValueType& default_value) const + { + // at only works for objects + if (JSON_LIKELY(is_object())) + { + // if pointer resolves a value, return it or use default value + JSON_TRY + { + return ptr.get_checked(this); + } + JSON_CATCH (out_of_range&) + { + return default_value; + } + } + + JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()))); + } + + /*! + @brief overload for a default value of type const char* + @copydoc basic_json::value(const json_pointer&, ValueType) const + */ + string_t value(const json_pointer& ptr, const char* default_value) const + { + return value(ptr, string_t(default_value)); + } + + /*! + @brief access the first element + + Returns a reference to the first element in the container. For a JSON + container `c`, the expression `c.front()` is equivalent to `*c.begin()`. + + @return In case of a structured type (array or object), a reference to the + first element is returned. In case of number, string, or boolean values, a + reference to the value is returned. + + @complexity Constant. + + @pre The JSON value must not be `null` (would throw `std::out_of_range`) + or an empty array or object (undefined behavior, **guarded by + assertions**). + @post The JSON value remains unchanged. + + @throw invalid_iterator.214 when called on `null` value + + @liveexample{The following code shows an example for `front()`.,front} + + @sa @ref back() -- access the last element + + @since version 1.0.0 + */ + reference front() + { + return *begin(); + } + + /*! + @copydoc basic_json::front() + */ + const_reference front() const + { + return *cbegin(); + } + + /*! + @brief access the last element + + Returns a reference to the last element in the container. For a JSON + container `c`, the expression `c.back()` is equivalent to + @code {.cpp} + auto tmp = c.end(); + --tmp; + return *tmp; + @endcode + + @return In case of a structured type (array or object), a reference to the + last element is returned. In case of number, string, or boolean values, a + reference to the value is returned. + + @complexity Constant. + + @pre The JSON value must not be `null` (would throw `std::out_of_range`) + or an empty array or object (undefined behavior, **guarded by + assertions**). + @post The JSON value remains unchanged. + + @throw invalid_iterator.214 when called on a `null` value. See example + below. + + @liveexample{The following code shows an example for `back()`.,back} + + @sa @ref front() -- access the first element + + @since version 1.0.0 + */ + reference back() + { + auto tmp = end(); + --tmp; + return *tmp; + } + + /*! + @copydoc basic_json::back() + */ + const_reference back() const + { + auto tmp = cend(); + --tmp; + return *tmp; + } + + /*! + @brief remove element given an iterator + + Removes the element specified by iterator @a pos. The iterator @a pos must + be valid and dereferenceable. Thus the `end()` iterator (which is valid, + but is not dereferenceable) cannot be used as a value for @a pos. + + If called on a primitive type other than `null`, the resulting JSON value + will be `null`. + + @param[in] pos iterator to the element to remove + @return Iterator following the last removed element. If the iterator @a + pos refers to the last element, the `end()` iterator is returned. + + @tparam IteratorType an @ref iterator or @ref const_iterator + + @post Invalidates iterators and references at or after the point of the + erase, including the `end()` iterator. + + @throw type_error.307 if called on a `null` value; example: `"cannot use + erase() with null"` + @throw invalid_iterator.202 if called on an iterator which does not belong + to the current JSON value; example: `"iterator does not fit current + value"` + @throw invalid_iterator.205 if called on a primitive type with invalid + iterator (i.e., any iterator which is not `begin()`); example: `"iterator + out of range"` + + @complexity The complexity depends on the type: + - objects: amortized constant + - arrays: linear in distance between @a pos and the end of the container + - strings: linear in the length of the string + - other types: constant + + @liveexample{The example shows the result of `erase()` for different JSON + types.,erase__IteratorType} + + @sa @ref erase(IteratorType, IteratorType) -- removes the elements in + the given range + @sa @ref erase(const typename object_t::key_type&) -- removes the element + from an object at the given key + @sa @ref erase(const size_type) -- removes the element from an array at + the given index + + @since version 1.0.0 + */ + template::value or + std::is_same::value, int>::type + = 0> + IteratorType erase(IteratorType pos) + { + // make sure iterator fits the current value + if (JSON_UNLIKELY(this != pos.m_object)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + IteratorType result = end(); + + switch (m_type) + { + case value_t::boolean: + case value_t::number_float: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::string: + { + if (JSON_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) + { + JSON_THROW(invalid_iterator::create(205, "iterator out of range")); + } + + if (is_string()) + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, m_value.string); + std::allocator_traits::deallocate(alloc, m_value.string, 1); + m_value.string = nullptr; + } + + m_type = value_t::null; + assert_invariant(); + break; + } + + case value_t::object: + { + result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator); + break; + } + + case value_t::array: + { + result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator); + break; + } + + default: + JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()))); + } + + return result; + } + + /*! + @brief remove elements given an iterator range + + Removes the element specified by the range `[first; last)`. The iterator + @a first does not need to be dereferenceable if `first == last`: erasing + an empty range is a no-op. + + If called on a primitive type other than `null`, the resulting JSON value + will be `null`. + + @param[in] first iterator to the beginning of the range to remove + @param[in] last iterator past the end of the range to remove + @return Iterator following the last removed element. If the iterator @a + second refers to the last element, the `end()` iterator is returned. + + @tparam IteratorType an @ref iterator or @ref const_iterator + + @post Invalidates iterators and references at or after the point of the + erase, including the `end()` iterator. + + @throw type_error.307 if called on a `null` value; example: `"cannot use + erase() with null"` + @throw invalid_iterator.203 if called on iterators which does not belong + to the current JSON value; example: `"iterators do not fit current value"` + @throw invalid_iterator.204 if called on a primitive type with invalid + iterators (i.e., if `first != begin()` and `last != end()`); example: + `"iterators out of range"` + + @complexity The complexity depends on the type: + - objects: `log(size()) + std::distance(first, last)` + - arrays: linear in the distance between @a first and @a last, plus linear + in the distance between @a last and end of the container + - strings: linear in the length of the string + - other types: constant + + @liveexample{The example shows the result of `erase()` for different JSON + types.,erase__IteratorType_IteratorType} + + @sa @ref erase(IteratorType) -- removes the element at a given position + @sa @ref erase(const typename object_t::key_type&) -- removes the element + from an object at the given key + @sa @ref erase(const size_type) -- removes the element from an array at + the given index + + @since version 1.0.0 + */ + template::value or + std::is_same::value, int>::type + = 0> + IteratorType erase(IteratorType first, IteratorType last) + { + // make sure iterator fits the current value + if (JSON_UNLIKELY(this != first.m_object or this != last.m_object)) + { + JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value")); + } + + IteratorType result = end(); + + switch (m_type) + { + case value_t::boolean: + case value_t::number_float: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::string: + { + if (JSON_LIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) + { + JSON_THROW(invalid_iterator::create(204, "iterators out of range")); + } + + if (is_string()) + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, m_value.string); + std::allocator_traits::deallocate(alloc, m_value.string, 1); + m_value.string = nullptr; + } + + m_type = value_t::null; + assert_invariant(); + break; + } + + case value_t::object: + { + result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator, + last.m_it.object_iterator); + break; + } + + case value_t::array: + { + result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator, + last.m_it.array_iterator); + break; + } + + default: + JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()))); + } + + return result; + } + + /*! + @brief remove element from a JSON object given a key + + Removes elements from a JSON object with the key value @a key. + + @param[in] key value of the elements to remove + + @return Number of elements removed. If @a ObjectType is the default + `std::map` type, the return value will always be `0` (@a key was not + found) or `1` (@a key was found). + + @post References and iterators to the erased elements are invalidated. + Other references and iterators are not affected. + + @throw type_error.307 when called on a type other than JSON object; + example: `"cannot use erase() with null"` + + @complexity `log(size()) + count(key)` + + @liveexample{The example shows the effect of `erase()`.,erase__key_type} + + @sa @ref erase(IteratorType) -- removes the element at a given position + @sa @ref erase(IteratorType, IteratorType) -- removes the elements in + the given range + @sa @ref erase(const size_type) -- removes the element from an array at + the given index + + @since version 1.0.0 + */ + size_type erase(const typename object_t::key_type& key) + { + // this erase only works for objects + if (JSON_LIKELY(is_object())) + { + return m_value.object->erase(key); + } + + JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()))); + } + + /*! + @brief remove element from a JSON array given an index + + Removes element from a JSON array at the index @a idx. + + @param[in] idx index of the element to remove + + @throw type_error.307 when called on a type other than JSON object; + example: `"cannot use erase() with null"` + @throw out_of_range.401 when `idx >= size()`; example: `"array index 17 + is out of range"` + + @complexity Linear in distance between @a idx and the end of the container. + + @liveexample{The example shows the effect of `erase()`.,erase__size_type} + + @sa @ref erase(IteratorType) -- removes the element at a given position + @sa @ref erase(IteratorType, IteratorType) -- removes the elements in + the given range + @sa @ref erase(const typename object_t::key_type&) -- removes the element + from an object at the given key + + @since version 1.0.0 + */ + void erase(const size_type idx) + { + // this erase only works for arrays + if (JSON_LIKELY(is_array())) + { + if (JSON_UNLIKELY(idx >= size())) + { + JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); + } + + m_value.array->erase(m_value.array->begin() + static_cast(idx)); + } + else + { + JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()))); + } + } + + /// @} + + + //////////// + // lookup // + //////////// + + /// @name lookup + /// @{ + + /*! + @brief find an element in a JSON object + + Finds an element in a JSON object with key equivalent to @a key. If the + element is not found or the JSON value is not an object, end() is + returned. + + @note This method always returns @ref end() when executed on a JSON type + that is not an object. + + @param[in] key key value of the element to search for. + + @return Iterator to an element with key equivalent to @a key. If no such + element is found or the JSON value is not an object, past-the-end (see + @ref end()) iterator is returned. + + @complexity Logarithmic in the size of the JSON object. + + @liveexample{The example shows how `find()` is used.,find__key_type} + + @since version 1.0.0 + */ + template + iterator find(KeyT&& key) + { + auto result = end(); + + if (is_object()) + { + result.m_it.object_iterator = m_value.object->find(std::forward(key)); + } + + return result; + } + + /*! + @brief find an element in a JSON object + @copydoc find(KeyT&&) + */ + template + const_iterator find(KeyT&& key) const + { + auto result = cend(); + + if (is_object()) + { + result.m_it.object_iterator = m_value.object->find(std::forward(key)); + } + + return result; + } + + /*! + @brief returns the number of occurrences of a key in a JSON object + + Returns the number of elements with key @a key. If ObjectType is the + default `std::map` type, the return value will always be `0` (@a key was + not found) or `1` (@a key was found). + + @note This method always returns `0` when executed on a JSON type that is + not an object. + + @param[in] key key value of the element to count + + @return Number of elements with key @a key. If the JSON value is not an + object, the return value will be `0`. + + @complexity Logarithmic in the size of the JSON object. + + @liveexample{The example shows how `count()` is used.,count} + + @since version 1.0.0 + */ + template + size_type count(KeyT&& key) const + { + // return 0 for all nonobject types + return is_object() ? m_value.object->count(std::forward(key)) : 0; + } + + /// @} + + + /////////////// + // iterators // + /////////////// + + /// @name iterators + /// @{ + + /*! + @brief returns an iterator to the first element + + Returns an iterator to the first element. + + @image html range-begin-end.svg "Illustration from cppreference.com" + + @return iterator to the first element + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is constant. + + @liveexample{The following code shows an example for `begin()`.,begin} + + @sa @ref cbegin() -- returns a const iterator to the beginning + @sa @ref end() -- returns an iterator to the end + @sa @ref cend() -- returns a const iterator to the end + + @since version 1.0.0 + */ + iterator begin() noexcept + { + iterator result(this); + result.set_begin(); + return result; + } + + /*! + @copydoc basic_json::cbegin() + */ + const_iterator begin() const noexcept + { + return cbegin(); + } + + /*! + @brief returns a const iterator to the first element + + Returns a const iterator to the first element. + + @image html range-begin-end.svg "Illustration from cppreference.com" + + @return const iterator to the first element + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is constant. + - Has the semantics of `const_cast(*this).begin()`. + + @liveexample{The following code shows an example for `cbegin()`.,cbegin} + + @sa @ref begin() -- returns an iterator to the beginning + @sa @ref end() -- returns an iterator to the end + @sa @ref cend() -- returns a const iterator to the end + + @since version 1.0.0 + */ + const_iterator cbegin() const noexcept + { + const_iterator result(this); + result.set_begin(); + return result; + } + + /*! + @brief returns an iterator to one past the last element + + Returns an iterator to one past the last element. + + @image html range-begin-end.svg "Illustration from cppreference.com" + + @return iterator one past the last element + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is constant. + + @liveexample{The following code shows an example for `end()`.,end} + + @sa @ref cend() -- returns a const iterator to the end + @sa @ref begin() -- returns an iterator to the beginning + @sa @ref cbegin() -- returns a const iterator to the beginning + + @since version 1.0.0 + */ + iterator end() noexcept + { + iterator result(this); + result.set_end(); + return result; + } + + /*! + @copydoc basic_json::cend() + */ + const_iterator end() const noexcept + { + return cend(); + } + + /*! + @brief returns a const iterator to one past the last element + + Returns a const iterator to one past the last element. + + @image html range-begin-end.svg "Illustration from cppreference.com" + + @return const iterator one past the last element + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is constant. + - Has the semantics of `const_cast(*this).end()`. + + @liveexample{The following code shows an example for `cend()`.,cend} + + @sa @ref end() -- returns an iterator to the end + @sa @ref begin() -- returns an iterator to the beginning + @sa @ref cbegin() -- returns a const iterator to the beginning + + @since version 1.0.0 + */ + const_iterator cend() const noexcept + { + const_iterator result(this); + result.set_end(); + return result; + } + + /*! + @brief returns an iterator to the reverse-beginning + + Returns an iterator to the reverse-beginning; that is, the last element. + + @image html range-rbegin-rend.svg "Illustration from cppreference.com" + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [ReversibleContainer](http://en.cppreference.com/w/cpp/concept/ReversibleContainer) + requirements: + - The complexity is constant. + - Has the semantics of `reverse_iterator(end())`. + + @liveexample{The following code shows an example for `rbegin()`.,rbegin} + + @sa @ref crbegin() -- returns a const reverse iterator to the beginning + @sa @ref rend() -- returns a reverse iterator to the end + @sa @ref crend() -- returns a const reverse iterator to the end + + @since version 1.0.0 + */ + reverse_iterator rbegin() noexcept + { + return reverse_iterator(end()); + } + + /*! + @copydoc basic_json::crbegin() + */ + const_reverse_iterator rbegin() const noexcept + { + return crbegin(); + } + + /*! + @brief returns an iterator to the reverse-end + + Returns an iterator to the reverse-end; that is, one before the first + element. + + @image html range-rbegin-rend.svg "Illustration from cppreference.com" + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [ReversibleContainer](http://en.cppreference.com/w/cpp/concept/ReversibleContainer) + requirements: + - The complexity is constant. + - Has the semantics of `reverse_iterator(begin())`. + + @liveexample{The following code shows an example for `rend()`.,rend} + + @sa @ref crend() -- returns a const reverse iterator to the end + @sa @ref rbegin() -- returns a reverse iterator to the beginning + @sa @ref crbegin() -- returns a const reverse iterator to the beginning + + @since version 1.0.0 + */ + reverse_iterator rend() noexcept + { + return reverse_iterator(begin()); + } + + /*! + @copydoc basic_json::crend() + */ + const_reverse_iterator rend() const noexcept + { + return crend(); + } + + /*! + @brief returns a const reverse iterator to the last element + + Returns a const iterator to the reverse-beginning; that is, the last + element. + + @image html range-rbegin-rend.svg "Illustration from cppreference.com" + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [ReversibleContainer](http://en.cppreference.com/w/cpp/concept/ReversibleContainer) + requirements: + - The complexity is constant. + - Has the semantics of `const_cast(*this).rbegin()`. + + @liveexample{The following code shows an example for `crbegin()`.,crbegin} + + @sa @ref rbegin() -- returns a reverse iterator to the beginning + @sa @ref rend() -- returns a reverse iterator to the end + @sa @ref crend() -- returns a const reverse iterator to the end + + @since version 1.0.0 + */ + const_reverse_iterator crbegin() const noexcept + { + return const_reverse_iterator(cend()); + } + + /*! + @brief returns a const reverse iterator to one before the first + + Returns a const reverse iterator to the reverse-end; that is, one before + the first element. + + @image html range-rbegin-rend.svg "Illustration from cppreference.com" + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [ReversibleContainer](http://en.cppreference.com/w/cpp/concept/ReversibleContainer) + requirements: + - The complexity is constant. + - Has the semantics of `const_cast(*this).rend()`. + + @liveexample{The following code shows an example for `crend()`.,crend} + + @sa @ref rend() -- returns a reverse iterator to the end + @sa @ref rbegin() -- returns a reverse iterator to the beginning + @sa @ref crbegin() -- returns a const reverse iterator to the beginning + + @since version 1.0.0 + */ + const_reverse_iterator crend() const noexcept + { + return const_reverse_iterator(cbegin()); + } + + public: + /*! + @brief wrapper to access iterator member functions in range-based for + + This function allows to access @ref iterator::key() and @ref + iterator::value() during range-based for loops. In these loops, a + reference to the JSON values is returned, so there is no access to the + underlying iterator. + + For loop without iterator_wrapper: + + @code{cpp} + for (auto it = j_object.begin(); it != j_object.end(); ++it) + { + std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; + } + @endcode + + Range-based for loop without iterator proxy: + + @code{cpp} + for (auto it : j_object) + { + // "it" is of type json::reference and has no key() member + std::cout << "value: " << it << '\n'; + } + @endcode + + Range-based for loop with iterator proxy: + + @code{cpp} + for (auto it : json::iterator_wrapper(j_object)) + { + std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; + } + @endcode + + @note When iterating over an array, `key()` will return the index of the + element as string (see example). + + @param[in] ref reference to a JSON value + @return iteration proxy object wrapping @a ref with an interface to use in + range-based for loops + + @liveexample{The following code shows how the wrapper is used,iterator_wrapper} + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @note The name of this function is not yet final and may change in the + future. + */ + static iteration_proxy iterator_wrapper(reference ref) + { + return iteration_proxy(ref); + } + + /*! + @copydoc iterator_wrapper(reference) + */ + static iteration_proxy iterator_wrapper(const_reference ref) + { + return iteration_proxy(ref); + } + + /// @} + + + ////////////// + // capacity // + ////////////// + + /// @name capacity + /// @{ + + /*! + @brief checks whether the container is empty. + + Checks if a JSON value has no elements (i.e. whether its @ref size is `0`). + + @return The return value depends on the different types and is + defined as follows: + Value type | return value + ----------- | ------------- + null | `true` + boolean | `false` + string | `false` + number | `false` + object | result of function `object_t::empty()` + array | result of function `array_t::empty()` + + @liveexample{The following code uses `empty()` to check if a JSON + object contains any elements.,empty} + + @complexity Constant, as long as @ref array_t and @ref object_t satisfy + the Container concept; that is, their `empty()` functions have constant + complexity. + + @iterators No changes. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @note This function does not return whether a string stored as JSON value + is empty - it returns whether the JSON container itself is empty which is + false in the case of a string. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is constant. + - Has the semantics of `begin() == end()`. + + @sa @ref size() -- returns the number of elements + + @since version 1.0.0 + */ + bool empty() const noexcept + { + switch (m_type) + { + case value_t::null: + { + // null values are empty + return true; + } + + case value_t::array: + { + // delegate call to array_t::empty() + return m_value.array->empty(); + } + + case value_t::object: + { + // delegate call to object_t::empty() + return m_value.object->empty(); + } + + default: + { + // all other types are nonempty + return false; + } + } + } + + /*! + @brief returns the number of elements + + Returns the number of elements in a JSON value. + + @return The return value depends on the different types and is + defined as follows: + Value type | return value + ----------- | ------------- + null | `0` + boolean | `1` + string | `1` + number | `1` + object | result of function object_t::size() + array | result of function array_t::size() + + @liveexample{The following code calls `size()` on the different value + types.,size} + + @complexity Constant, as long as @ref array_t and @ref object_t satisfy + the Container concept; that is, their size() functions have constant + complexity. + + @iterators No changes. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @note This function does not return the length of a string stored as JSON + value - it returns the number of elements in the JSON value which is 1 in + the case of a string. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is constant. + - Has the semantics of `std::distance(begin(), end())`. + + @sa @ref empty() -- checks whether the container is empty + @sa @ref max_size() -- returns the maximal number of elements + + @since version 1.0.0 + */ + size_type size() const noexcept + { + switch (m_type) + { + case value_t::null: + { + // null values are empty + return 0; + } + + case value_t::array: + { + // delegate call to array_t::size() + return m_value.array->size(); + } + + case value_t::object: + { + // delegate call to object_t::size() + return m_value.object->size(); + } + + default: + { + // all other types have size 1 + return 1; + } + } + } + + /*! + @brief returns the maximum possible number of elements + + Returns the maximum number of elements a JSON value is able to hold due to + system or library implementation limitations, i.e. `std::distance(begin(), + end())` for the JSON value. + + @return The return value depends on the different types and is + defined as follows: + Value type | return value + ----------- | ------------- + null | `0` (same as `size()`) + boolean | `1` (same as `size()`) + string | `1` (same as `size()`) + number | `1` (same as `size()`) + object | result of function `object_t::max_size()` + array | result of function `array_t::max_size()` + + @liveexample{The following code calls `max_size()` on the different value + types. Note the output is implementation specific.,max_size} + + @complexity Constant, as long as @ref array_t and @ref object_t satisfy + the Container concept; that is, their `max_size()` functions have constant + complexity. + + @iterators No changes. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @requirement This function helps `basic_json` satisfying the + [Container](http://en.cppreference.com/w/cpp/concept/Container) + requirements: + - The complexity is constant. + - Has the semantics of returning `b.size()` where `b` is the largest + possible JSON value. + + @sa @ref size() -- returns the number of elements + + @since version 1.0.0 + */ + size_type max_size() const noexcept + { + switch (m_type) + { + case value_t::array: + { + // delegate call to array_t::max_size() + return m_value.array->max_size(); + } + + case value_t::object: + { + // delegate call to object_t::max_size() + return m_value.object->max_size(); + } + + default: + { + // all other types have max_size() == size() + return size(); + } + } + } + + /// @} + + + /////////////// + // modifiers // + /////////////// + + /// @name modifiers + /// @{ + + /*! + @brief clears the contents + + Clears the content of a JSON value and resets it to the default value as + if @ref basic_json(value_t) would have been called with the current value + type from @ref type(): + + Value type | initial value + ----------- | ------------- + null | `null` + boolean | `false` + string | `""` + number | `0` + object | `{}` + array | `[]` + + @post Has the same effect as calling + @code {.cpp} + *this = basic_json(type()); + @endcode + + @liveexample{The example below shows the effect of `clear()` to different + JSON types.,clear} + + @complexity Linear in the size of the JSON value. + + @iterators All iterators, pointers and references related to this container + are invalidated. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @sa @ref basic_json(value_t) -- constructor that creates an object with the + same value than calling `clear()` + + @since version 1.0.0 + */ + void clear() noexcept + { + switch (m_type) + { + case value_t::number_integer: + { + m_value.number_integer = 0; + break; + } + + case value_t::number_unsigned: + { + m_value.number_unsigned = 0; + break; + } + + case value_t::number_float: + { + m_value.number_float = 0.0; + break; + } + + case value_t::boolean: + { + m_value.boolean = false; + break; + } + + case value_t::string: + { + m_value.string->clear(); + break; + } + + case value_t::array: + { + m_value.array->clear(); + break; + } + + case value_t::object: + { + m_value.object->clear(); + break; + } + + default: + break; + } + } + + /*! + @brief add an object to an array + + Appends the given element @a val to the end of the JSON value. If the + function is called on a JSON null value, an empty array is created before + appending @a val. + + @param[in] val the value to add to the JSON array + + @throw type_error.308 when called on a type other than JSON array or + null; example: `"cannot use push_back() with number"` + + @complexity Amortized constant. + + @liveexample{The example shows how `push_back()` and `+=` can be used to + add elements to a JSON array. Note how the `null` value was silently + converted to a JSON array.,push_back} + + @since version 1.0.0 + */ + void push_back(basic_json&& val) + { + // push_back only works for null objects or arrays + if (JSON_UNLIKELY(not(is_null() or is_array()))) + { + JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); + } + + // transform null object into an array + if (is_null()) + { + m_type = value_t::array; + m_value = value_t::array; + assert_invariant(); + } + + // add element to array (move semantics) + m_value.array->push_back(std::move(val)); + // invalidate object + val.m_type = value_t::null; + } + + /*! + @brief add an object to an array + @copydoc push_back(basic_json&&) + */ + reference operator+=(basic_json&& val) + { + push_back(std::move(val)); + return *this; + } + + /*! + @brief add an object to an array + @copydoc push_back(basic_json&&) + */ + void push_back(const basic_json& val) + { + // push_back only works for null objects or arrays + if (JSON_UNLIKELY(not(is_null() or is_array()))) + { + JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); + } + + // transform null object into an array + if (is_null()) + { + m_type = value_t::array; + m_value = value_t::array; + assert_invariant(); + } + + // add element to array + m_value.array->push_back(val); + } + + /*! + @brief add an object to an array + @copydoc push_back(basic_json&&) + */ + reference operator+=(const basic_json& val) + { + push_back(val); + return *this; + } + + /*! + @brief add an object to an object + + Inserts the given element @a val to the JSON object. If the function is + called on a JSON null value, an empty object is created before inserting + @a val. + + @param[in] val the value to add to the JSON object + + @throw type_error.308 when called on a type other than JSON object or + null; example: `"cannot use push_back() with number"` + + @complexity Logarithmic in the size of the container, O(log(`size()`)). + + @liveexample{The example shows how `push_back()` and `+=` can be used to + add elements to a JSON object. Note how the `null` value was silently + converted to a JSON object.,push_back__object_t__value} + + @since version 1.0.0 + */ + void push_back(const typename object_t::value_type& val) + { + // push_back only works for null objects or objects + if (JSON_UNLIKELY(not(is_null() or is_object()))) + { + JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); + } + + // transform null object into an object + if (is_null()) + { + m_type = value_t::object; + m_value = value_t::object; + assert_invariant(); + } + + // add element to array + m_value.object->insert(val); + } + + /*! + @brief add an object to an object + @copydoc push_back(const typename object_t::value_type&) + */ + reference operator+=(const typename object_t::value_type& val) + { + push_back(val); + return *this; + } + + /*! + @brief add an object to an object + + This function allows to use `push_back` with an initializer list. In case + + 1. the current value is an object, + 2. the initializer list @a init contains only two elements, and + 3. the first element of @a init is a string, + + @a init is converted into an object element and added using + @ref push_back(const typename object_t::value_type&). Otherwise, @a init + is converted to a JSON value and added using @ref push_back(basic_json&&). + + @param[in] init an initializer list + + @complexity Linear in the size of the initializer list @a init. + + @note This function is required to resolve an ambiguous overload error, + because pairs like `{"key", "value"}` can be both interpreted as + `object_t::value_type` or `std::initializer_list`, see + https://github.com/nlohmann/json/issues/235 for more information. + + @liveexample{The example shows how initializer lists are treated as + objects when possible.,push_back__initializer_list} + */ + void push_back(initializer_list_t init) + { + if (is_object() and init.size() == 2 and (*init.begin())->is_string()) + { + basic_json&& key = init.begin()->moved_or_copied(); + push_back(typename object_t::value_type( + std::move(key.get_ref()), (init.begin() + 1)->moved_or_copied())); + } + else + { + push_back(basic_json(init)); + } + } + + /*! + @brief add an object to an object + @copydoc push_back(initializer_list_t) + */ + reference operator+=(initializer_list_t init) + { + push_back(init); + return *this; + } + + /*! + @brief add an object to an array + + Creates a JSON value from the passed parameters @a args to the end of the + JSON value. If the function is called on a JSON null value, an empty array + is created before appending the value created from @a args. + + @param[in] args arguments to forward to a constructor of @ref basic_json + @tparam Args compatible types to create a @ref basic_json object + + @throw type_error.311 when called on a type other than JSON array or + null; example: `"cannot use emplace_back() with number"` + + @complexity Amortized constant. + + @liveexample{The example shows how `push_back()` can be used to add + elements to a JSON array. Note how the `null` value was silently converted + to a JSON array.,emplace_back} + + @since version 2.0.8 + */ + template + void emplace_back(Args&& ... args) + { + // emplace_back only works for null objects or arrays + if (JSON_UNLIKELY(not(is_null() or is_array()))) + { + JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()))); + } + + // transform null object into an array + if (is_null()) + { + m_type = value_t::array; + m_value = value_t::array; + assert_invariant(); + } + + // add element to array (perfect forwarding) + m_value.array->emplace_back(std::forward(args)...); + } + + /*! + @brief add an object to an object if key does not exist + + Inserts a new element into a JSON object constructed in-place with the + given @a args if there is no element with the key in the container. If the + function is called on a JSON null value, an empty object is created before + appending the value created from @a args. + + @param[in] args arguments to forward to a constructor of @ref basic_json + @tparam Args compatible types to create a @ref basic_json object + + @return a pair consisting of an iterator to the inserted element, or the + already-existing element if no insertion happened, and a bool + denoting whether the insertion took place. + + @throw type_error.311 when called on a type other than JSON object or + null; example: `"cannot use emplace() with number"` + + @complexity Logarithmic in the size of the container, O(log(`size()`)). + + @liveexample{The example shows how `emplace()` can be used to add elements + to a JSON object. Note how the `null` value was silently converted to a + JSON object. Further note how no value is added if there was already one + value stored with the same key.,emplace} + + @since version 2.0.8 + */ + template + std::pair emplace(Args&& ... args) + { + // emplace only works for null objects or arrays + if (JSON_UNLIKELY(not(is_null() or is_object()))) + { + JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()))); + } + + // transform null object into an object + if (is_null()) + { + m_type = value_t::object; + m_value = value_t::object; + assert_invariant(); + } + + // add element to array (perfect forwarding) + auto res = m_value.object->emplace(std::forward(args)...); + // create result iterator and set iterator to the result of emplace + auto it = begin(); + it.m_it.object_iterator = res.first; + + // return pair of iterator and boolean + return {it, res.second}; + } + + /*! + @brief inserts element + + Inserts element @a val before iterator @a pos. + + @param[in] pos iterator before which the content will be inserted; may be + the end() iterator + @param[in] val element to insert + @return iterator pointing to the inserted @a val. + + @throw type_error.309 if called on JSON values other than arrays; + example: `"cannot use insert() with string"` + @throw invalid_iterator.202 if @a pos is not an iterator of *this; + example: `"iterator does not fit current value"` + + @complexity Constant plus linear in the distance between @a pos and end of + the container. + + @liveexample{The example shows how `insert()` is used.,insert} + + @since version 1.0.0 + */ + iterator insert(const_iterator pos, const basic_json& val) + { + // insert only works for arrays + if (JSON_LIKELY(is_array())) + { + // check if iterator pos fits to this JSON value + if (JSON_UNLIKELY(pos.m_object != this)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + // insert to array and return iterator + iterator result(this); + result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val); + return result; + } + + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + /*! + @brief inserts element + @copydoc insert(const_iterator, const basic_json&) + */ + iterator insert(const_iterator pos, basic_json&& val) + { + return insert(pos, val); + } + + /*! + @brief inserts elements + + Inserts @a cnt copies of @a val before iterator @a pos. + + @param[in] pos iterator before which the content will be inserted; may be + the end() iterator + @param[in] cnt number of copies of @a val to insert + @param[in] val element to insert + @return iterator pointing to the first element inserted, or @a pos if + `cnt==0` + + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` + @throw invalid_iterator.202 if @a pos is not an iterator of *this; + example: `"iterator does not fit current value"` + + @complexity Linear in @a cnt plus linear in the distance between @a pos + and end of the container. + + @liveexample{The example shows how `insert()` is used.,insert__count} + + @since version 1.0.0 + */ + iterator insert(const_iterator pos, size_type cnt, const basic_json& val) + { + // insert only works for arrays + if (JSON_LIKELY(is_array())) + { + // check if iterator pos fits to this JSON value + if (JSON_UNLIKELY(pos.m_object != this)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + // insert to array and return iterator + iterator result(this); + result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val); + return result; + } + + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + /*! + @brief inserts elements + + Inserts elements from range `[first, last)` before iterator @a pos. + + @param[in] pos iterator before which the content will be inserted; may be + the end() iterator + @param[in] first begin of the range of elements to insert + @param[in] last end of the range of elements to insert + + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` + @throw invalid_iterator.202 if @a pos is not an iterator of *this; + example: `"iterator does not fit current value"` + @throw invalid_iterator.210 if @a first and @a last do not belong to the + same JSON value; example: `"iterators do not fit"` + @throw invalid_iterator.211 if @a first or @a last are iterators into + container for which insert is called; example: `"passed iterators may not + belong to container"` + + @return iterator pointing to the first element inserted, or @a pos if + `first==last` + + @complexity Linear in `std::distance(first, last)` plus linear in the + distance between @a pos and end of the container. + + @liveexample{The example shows how `insert()` is used.,insert__range} + + @since version 1.0.0 + */ + iterator insert(const_iterator pos, const_iterator first, const_iterator last) + { + // insert only works for arrays + if (JSON_UNLIKELY(not is_array())) + { + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + // check if iterator pos fits to this JSON value + if (JSON_UNLIKELY(pos.m_object != this)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + // check if range iterators belong to the same JSON object + if (JSON_UNLIKELY(first.m_object != last.m_object)) + { + JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); + } + + if (JSON_UNLIKELY(first.m_object == this)) + { + JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container")); + } + + // insert to array and return iterator + iterator result(this); + result.m_it.array_iterator = m_value.array->insert( + pos.m_it.array_iterator, + first.m_it.array_iterator, + last.m_it.array_iterator); + return result; + } + + /*! + @brief inserts elements + + Inserts elements from initializer list @a ilist before iterator @a pos. + + @param[in] pos iterator before which the content will be inserted; may be + the end() iterator + @param[in] ilist initializer list to insert the values from + + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` + @throw invalid_iterator.202 if @a pos is not an iterator of *this; + example: `"iterator does not fit current value"` + + @return iterator pointing to the first element inserted, or @a pos if + `ilist` is empty + + @complexity Linear in `ilist.size()` plus linear in the distance between + @a pos and end of the container. + + @liveexample{The example shows how `insert()` is used.,insert__ilist} + + @since version 1.0.0 + */ + iterator insert(const_iterator pos, initializer_list_t ilist) + { + // insert only works for arrays + if (JSON_UNLIKELY(not is_array())) + { + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + // check if iterator pos fits to this JSON value + if (JSON_UNLIKELY(pos.m_object != this)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + // insert to array and return iterator + iterator result(this); + result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist.begin(), ilist.end()); + return result; + } + + /*! + @brief inserts elements + + Inserts elements from range `[first, last)`. + + @param[in] first begin of the range of elements to insert + @param[in] last end of the range of elements to insert + + @throw type_error.309 if called on JSON values other than objects; example: + `"cannot use insert() with string"` + @throw invalid_iterator.202 if iterator @a first or @a last does does not + point to an object; example: `"iterators first and last must point to + objects"` + @throw invalid_iterator.210 if @a first and @a last do not belong to the + same JSON value; example: `"iterators do not fit"` + + @complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number + of elements to insert. + + @liveexample{The example shows how `insert()` is used.,insert__range_object} + + @since version 3.0.0 + */ + void insert(const_iterator first, const_iterator last) + { + // insert only works for objects + if (JSON_UNLIKELY(not is_object())) + { + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + // check if range iterators belong to the same JSON object + if (JSON_UNLIKELY(first.m_object != last.m_object)) + { + JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); + } + + // passed iterators must belong to objects + if (JSON_UNLIKELY(not first.m_object->is_object())) + { + JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); + } + + m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator); + } + + /*! + @brief updates a JSON object from another object, overwriting existing keys + + Inserts all values from JSON object @a j and overwrites existing keys. + + @param[in] j JSON object to read values from + + @throw type_error.312 if called on JSON values other than objects; example: + `"cannot use update() with string"` + + @complexity O(N*log(size() + N)), where N is the number of elements to + insert. + + @liveexample{The example shows how `update()` is used.,update} + + @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update + + @since version 3.0.0 + */ + void update(const_reference j) + { + // implicitly convert null value to an empty object + if (is_null()) + { + m_type = value_t::object; + m_value.object = create(); + assert_invariant(); + } + + if (JSON_UNLIKELY(not is_object())) + { + JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); + } + if (JSON_UNLIKELY(not j.is_object())) + { + JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()))); + } + + for (auto it = j.cbegin(); it != j.cend(); ++it) + { + m_value.object->operator[](it.key()) = it.value(); + } + } + + /*! + @brief updates a JSON object from another object, overwriting existing keys + + Inserts all values from from range `[first, last)` and overwrites existing + keys. + + @param[in] first begin of the range of elements to insert + @param[in] last end of the range of elements to insert + + @throw type_error.312 if called on JSON values other than objects; example: + `"cannot use update() with string"` + @throw invalid_iterator.202 if iterator @a first or @a last does does not + point to an object; example: `"iterators first and last must point to + objects"` + @throw invalid_iterator.210 if @a first and @a last do not belong to the + same JSON value; example: `"iterators do not fit"` + + @complexity O(N*log(size() + N)), where N is the number of elements to + insert. + + @liveexample{The example shows how `update()` is used__range.,update} + + @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update + + @since version 3.0.0 + */ + void update(const_iterator first, const_iterator last) + { + // implicitly convert null value to an empty object + if (is_null()) + { + m_type = value_t::object; + m_value.object = create(); + assert_invariant(); + } + + if (JSON_UNLIKELY(not is_object())) + { + JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); + } + + // check if range iterators belong to the same JSON object + if (JSON_UNLIKELY(first.m_object != last.m_object)) + { + JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); + } + + // passed iterators must belong to objects + if (JSON_UNLIKELY(not first.m_object->is_object() + or not first.m_object->is_object())) + { + JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); + } + + for (auto it = first; it != last; ++it) + { + m_value.object->operator[](it.key()) = it.value(); + } + } + + /*! + @brief exchanges the values + + Exchanges the contents of the JSON value with those of @a other. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. + + @param[in,out] other JSON value to exchange the contents with + + @complexity Constant. + + @liveexample{The example below shows how JSON values can be swapped with + `swap()`.,swap__reference} + + @since version 1.0.0 + */ + void swap(reference other) noexcept ( + std::is_nothrow_move_constructible::value and + std::is_nothrow_move_assignable::value and + std::is_nothrow_move_constructible::value and + std::is_nothrow_move_assignable::value + ) + { + std::swap(m_type, other.m_type); + std::swap(m_value, other.m_value); + assert_invariant(); + } + + /*! + @brief exchanges the values + + Exchanges the contents of a JSON array with those of @a other. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. + + @param[in,out] other array to exchange the contents with + + @throw type_error.310 when JSON value is not an array; example: `"cannot + use swap() with string"` + + @complexity Constant. + + @liveexample{The example below shows how arrays can be swapped with + `swap()`.,swap__array_t} + + @since version 1.0.0 + */ + void swap(array_t& other) + { + // swap only works for arrays + if (JSON_LIKELY(is_array())) + { + std::swap(*(m_value.array), other); + } + else + { + JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()))); + } + } + + /*! + @brief exchanges the values + + Exchanges the contents of a JSON object with those of @a other. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. + + @param[in,out] other object to exchange the contents with + + @throw type_error.310 when JSON value is not an object; example: + `"cannot use swap() with string"` + + @complexity Constant. + + @liveexample{The example below shows how objects can be swapped with + `swap()`.,swap__object_t} + + @since version 1.0.0 + */ + void swap(object_t& other) + { + // swap only works for objects + if (JSON_LIKELY(is_object())) + { + std::swap(*(m_value.object), other); + } + else + { + JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()))); + } + } + + /*! + @brief exchanges the values + + Exchanges the contents of a JSON string with those of @a other. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. + + @param[in,out] other string to exchange the contents with + + @throw type_error.310 when JSON value is not a string; example: `"cannot + use swap() with boolean"` + + @complexity Constant. + + @liveexample{The example below shows how strings can be swapped with + `swap()`.,swap__string_t} + + @since version 1.0.0 + */ + void swap(string_t& other) + { + // swap only works for strings + if (JSON_LIKELY(is_string())) + { + std::swap(*(m_value.string), other); + } + else + { + JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()))); + } + } + + /// @} + + public: + ////////////////////////////////////////// + // lexicographical comparison operators // + ////////////////////////////////////////// + + /// @name lexicographical comparison operators + /// @{ + + /*! + @brief comparison: equal + + Compares two JSON values for equality according to the following rules: + - Two JSON values are equal if (1) they are from the same type and (2) + their stored values are the same according to their respective + `operator==`. + - Integer and floating-point numbers are automatically converted before + comparison. Note than two NaN values are always treated as unequal. + - Two JSON null values are equal. + + @note Floating-point inside JSON values numbers are compared with + `json::number_float_t::operator==` which is `double::operator==` by + default. To compare floating-point while respecting an epsilon, an alternative + [comparison function](https://github.com/mariokonrad/marnav/blob/master/src/marnav/math/floatingpoint.hpp#L34-#L39) + could be used, for instance + @code {.cpp} + template::value, T>::type> + inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept + { + return std::abs(a - b) <= epsilon; + } + @endcode + + @note NaN values never compare equal to themselves or to other NaN values. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether the values @a lhs and @a rhs are equal + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @complexity Linear. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__equal} + + @since version 1.0.0 + */ + friend bool operator==(const_reference lhs, const_reference rhs) noexcept + { + const auto lhs_type = lhs.type(); + const auto rhs_type = rhs.type(); + + if (lhs_type == rhs_type) + { + switch (lhs_type) + { + case value_t::array: + return (*lhs.m_value.array == *rhs.m_value.array); + + case value_t::object: + return (*lhs.m_value.object == *rhs.m_value.object); + + case value_t::null: + return true; + + case value_t::string: + return (*lhs.m_value.string == *rhs.m_value.string); + + case value_t::boolean: + return (lhs.m_value.boolean == rhs.m_value.boolean); + + case value_t::number_integer: + return (lhs.m_value.number_integer == rhs.m_value.number_integer); + + case value_t::number_unsigned: + return (lhs.m_value.number_unsigned == rhs.m_value.number_unsigned); + + case value_t::number_float: + return (lhs.m_value.number_float == rhs.m_value.number_float); + + default: + return false; + } + } + else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float) + { + return (static_cast(lhs.m_value.number_integer) == rhs.m_value.number_float); + } + else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer) + { + return (lhs.m_value.number_float == static_cast(rhs.m_value.number_integer)); + } + else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float) + { + return (static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_float); + } + else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned) + { + return (lhs.m_value.number_float == static_cast(rhs.m_value.number_unsigned)); + } + else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer) + { + return (static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_integer); + } + else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned) + { + return (lhs.m_value.number_integer == static_cast(rhs.m_value.number_unsigned)); + } + + return false; + } + + /*! + @brief comparison: equal + @copydoc operator==(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept + { + return (lhs == basic_json(rhs)); + } + + /*! + @brief comparison: equal + @copydoc operator==(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept + { + return (basic_json(lhs) == rhs); + } + + /*! + @brief comparison: not equal + + Compares two JSON values for inequality by calculating `not (lhs == rhs)`. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether the values @a lhs and @a rhs are not equal + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__notequal} + + @since version 1.0.0 + */ + friend bool operator!=(const_reference lhs, const_reference rhs) noexcept + { + return not (lhs == rhs); + } + + /*! + @brief comparison: not equal + @copydoc operator!=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator!=(const_reference lhs, const ScalarType rhs) noexcept + { + return (lhs != basic_json(rhs)); + } + + /*! + @brief comparison: not equal + @copydoc operator!=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator!=(const ScalarType lhs, const_reference rhs) noexcept + { + return (basic_json(lhs) != rhs); + } + + /*! + @brief comparison: less than + + Compares whether one JSON value @a lhs is less than another JSON value @a + rhs according to the following rules: + - If @a lhs and @a rhs have the same type, the values are compared using + the default `<` operator. + - Integer and floating-point numbers are automatically converted before + comparison + - In case @a lhs and @a rhs have different types, the values are ignored + and the order of the types is considered, see + @ref operator<(const value_t, const value_t). + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether @a lhs is less than @a rhs + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__less} + + @since version 1.0.0 + */ + friend bool operator<(const_reference lhs, const_reference rhs) noexcept + { + const auto lhs_type = lhs.type(); + const auto rhs_type = rhs.type(); + + if (lhs_type == rhs_type) + { + switch (lhs_type) + { + case value_t::array: + return (*lhs.m_value.array) < (*rhs.m_value.array); + + case value_t::object: + return *lhs.m_value.object < *rhs.m_value.object; + + case value_t::null: + return false; + + case value_t::string: + return *lhs.m_value.string < *rhs.m_value.string; + + case value_t::boolean: + return lhs.m_value.boolean < rhs.m_value.boolean; + + case value_t::number_integer: + return lhs.m_value.number_integer < rhs.m_value.number_integer; + + case value_t::number_unsigned: + return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned; + + case value_t::number_float: + return lhs.m_value.number_float < rhs.m_value.number_float; + + default: + return false; + } + } + else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float) + { + return static_cast(lhs.m_value.number_integer) < rhs.m_value.number_float; + } + else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer) + { + return lhs.m_value.number_float < static_cast(rhs.m_value.number_integer); + } + else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float) + { + return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_float; + } + else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned) + { + return lhs.m_value.number_float < static_cast(rhs.m_value.number_unsigned); + } + else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned) + { + return lhs.m_value.number_integer < static_cast(rhs.m_value.number_unsigned); + } + else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer) + { + return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_integer; + } + + // We only reach this line if we cannot compare values. In that case, + // we compare types. Note we have to call the operator explicitly, + // because MSVC has problems otherwise. + return operator<(lhs_type, rhs_type); + } + + /*! + @brief comparison: less than + @copydoc operator<(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator<(const_reference lhs, const ScalarType rhs) noexcept + { + return (lhs < basic_json(rhs)); + } + + /*! + @brief comparison: less than + @copydoc operator<(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator<(const ScalarType lhs, const_reference rhs) noexcept + { + return (basic_json(lhs) < rhs); + } + + /*! + @brief comparison: less than or equal + + Compares whether one JSON value @a lhs is less than or equal to another + JSON value by calculating `not (rhs < lhs)`. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether @a lhs is less than or equal to @a rhs + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__greater} + + @since version 1.0.0 + */ + friend bool operator<=(const_reference lhs, const_reference rhs) noexcept + { + return not (rhs < lhs); + } + + /*! + @brief comparison: less than or equal + @copydoc operator<=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator<=(const_reference lhs, const ScalarType rhs) noexcept + { + return (lhs <= basic_json(rhs)); + } + + /*! + @brief comparison: less than or equal + @copydoc operator<=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator<=(const ScalarType lhs, const_reference rhs) noexcept + { + return (basic_json(lhs) <= rhs); + } + + /*! + @brief comparison: greater than + + Compares whether one JSON value @a lhs is greater than another + JSON value by calculating `not (lhs <= rhs)`. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether @a lhs is greater than to @a rhs + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__lessequal} + + @since version 1.0.0 + */ + friend bool operator>(const_reference lhs, const_reference rhs) noexcept + { + return not (lhs <= rhs); + } + + /*! + @brief comparison: greater than + @copydoc operator>(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator>(const_reference lhs, const ScalarType rhs) noexcept + { + return (lhs > basic_json(rhs)); + } + + /*! + @brief comparison: greater than + @copydoc operator>(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator>(const ScalarType lhs, const_reference rhs) noexcept + { + return (basic_json(lhs) > rhs); + } + + /*! + @brief comparison: greater than or equal + + Compares whether one JSON value @a lhs is greater than or equal to another + JSON value by calculating `not (lhs < rhs)`. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether @a lhs is greater than or equal to @a rhs + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__greaterequal} + + @since version 1.0.0 + */ + friend bool operator>=(const_reference lhs, const_reference rhs) noexcept + { + return not (lhs < rhs); + } + + /*! + @brief comparison: greater than or equal + @copydoc operator>=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator>=(const_reference lhs, const ScalarType rhs) noexcept + { + return (lhs >= basic_json(rhs)); + } + + /*! + @brief comparison: greater than or equal + @copydoc operator>=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator>=(const ScalarType lhs, const_reference rhs) noexcept + { + return (basic_json(lhs) >= rhs); + } + + /// @} + + /////////////////// + // serialization // + /////////////////// + + /// @name serialization + /// @{ + + /*! + @brief serialize to stream + + Serialize the given JSON value @a j to the output stream @a o. The JSON + value will be serialized using the @ref dump member function. + + - The indentation of the output can be controlled with the member variable + `width` of the output stream @a o. For instance, using the manipulator + `std::setw(4)` on @a o sets the indentation level to `4` and the + serialization result is the same as calling `dump(4)`. + + - The indentation character can be controlled with the member variable + `fill` of the output stream @a o. For instance, the manipulator + `std::setfill('\\t')` sets indentation to use a tab character rather than + the default space character. + + @param[in,out] o stream to serialize to + @param[in] j JSON value to serialize + + @return the stream @a o + + @throw type_error.316 if a string stored inside the JSON value is not + UTF-8 encoded + + @complexity Linear. + + @liveexample{The example below shows the serialization with different + parameters to `width` to adjust the indentation level.,operator_serialize} + + @since version 1.0.0; indentation character added in version 3.0.0 + */ + friend std::ostream& operator<<(std::ostream& o, const basic_json& j) + { + // read width member and use it as indentation parameter if nonzero + const bool pretty_print = (o.width() > 0); + const auto indentation = (pretty_print ? o.width() : 0); + + // reset width to 0 for subsequent calls to this stream + o.width(0); + + // do the actual serialization + serializer s(detail::output_adapter(o), o.fill()); + s.dump(j, pretty_print, false, static_cast(indentation)); + return o; + } + + /*! + @brief serialize to stream + @deprecated This stream operator is deprecated and will be removed in a + future version of the library. Please use + @ref operator<<(std::ostream&, const basic_json&) + instead; that is, replace calls like `j >> o;` with `o << j;`. + @since version 1.0.0; deprecated since version 3.0.0 + */ + JSON_DEPRECATED + friend std::ostream& operator>>(const basic_json& j, std::ostream& o) + { + return o << j; + } + + /// @} + + + ///////////////////// + // deserialization // + ///////////////////// + + /// @name deserialization + /// @{ + + /*! + @brief deserialize from a compatible input + + This function reads from a compatible input. Examples are: + - an array of 1-byte values + - strings with character/literal type with size of 1 byte + - input streams + - container with contiguous storage of 1-byte values. Compatible container + types include `std::vector`, `std::string`, `std::array`, + `std::valarray`, and `std::initializer_list`. Furthermore, C-style + arrays can be used with `std::begin()`/`std::end()`. User-defined + containers can be used as long as they implement random-access iterators + and a contiguous storage. + + @pre Each element of the container has a size of 1 byte. Violating this + precondition yields undefined behavior. **This precondition is enforced + with a static assertion.** + + @pre The container storage is contiguous. Violating this precondition + yields undefined behavior. **This precondition is enforced with an + assertion.** + @pre Each element of the container has a size of 1 byte. Violating this + precondition yields undefined behavior. **This precondition is enforced + with a static assertion.** + + @warning There is no way to enforce all preconditions at compile-time. If + the function is called with a noncompliant container and with + assertions switched off, the behavior is undefined and will most + likely yield segmentation violation. + + @param[in] i input to read from + @param[in] cb a parser callback function of type @ref parser_callback_t + which is used to control the deserialization by filtering unwanted values + (optional) + + @return result of the deserialization + + @throw parse_error.101 if a parse error occurs; example: `""unexpected end + of input; expected string literal""` + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + + @complexity Linear in the length of the input. The parser is a predictive + LL(1) parser. The complexity can be higher if the parser callback function + @a cb has a super-linear complexity. + + @note A UTF-8 byte order mark is silently ignored. + + @liveexample{The example below demonstrates the `parse()` function reading + from an array.,parse__array__parser_callback_t} + + @liveexample{The example below demonstrates the `parse()` function with + and without callback function.,parse__string__parser_callback_t} + + @liveexample{The example below demonstrates the `parse()` function with + and without callback function.,parse__istream__parser_callback_t} + + @liveexample{The example below demonstrates the `parse()` function reading + from a contiguous container.,parse__contiguouscontainer__parser_callback_t} + + @since version 2.0.3 (contiguous containers) + */ + static basic_json parse(detail::input_adapter i, + const parser_callback_t cb = nullptr, + const bool allow_exceptions = true) + { + basic_json result; + parser(i, cb, allow_exceptions).parse(true, result); + return result; + } + + /*! + @copydoc basic_json parse(detail::input_adapter, const parser_callback_t) + */ + static basic_json parse(detail::input_adapter& i, + const parser_callback_t cb = nullptr, + const bool allow_exceptions = true) + { + basic_json result; + parser(i, cb, allow_exceptions).parse(true, result); + return result; + } + + static bool accept(detail::input_adapter i) + { + return parser(i).accept(true); + } + + static bool accept(detail::input_adapter& i) + { + return parser(i).accept(true); + } + + /*! + @brief deserialize from an iterator range with contiguous storage + + This function reads from an iterator range of a container with contiguous + storage of 1-byte values. Compatible container types include + `std::vector`, `std::string`, `std::array`, `std::valarray`, and + `std::initializer_list`. Furthermore, C-style arrays can be used with + `std::begin()`/`std::end()`. User-defined containers can be used as long + as they implement random-access iterators and a contiguous storage. + + @pre The iterator range is contiguous. Violating this precondition yields + undefined behavior. **This precondition is enforced with an assertion.** + @pre Each element in the range has a size of 1 byte. Violating this + precondition yields undefined behavior. **This precondition is enforced + with a static assertion.** + + @warning There is no way to enforce all preconditions at compile-time. If + the function is called with noncompliant iterators and with + assertions switched off, the behavior is undefined and will most + likely yield segmentation violation. + + @tparam IteratorType iterator of container with contiguous storage + @param[in] first begin of the range to parse (included) + @param[in] last end of the range to parse (excluded) + @param[in] cb a parser callback function of type @ref parser_callback_t + which is used to control the deserialization by filtering unwanted values + (optional) + @param[in] allow_exceptions whether to throw exceptions in case of a + parse error (optional, true by default) + + @return result of the deserialization + + @throw parse_error.101 in case of an unexpected token + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + + @complexity Linear in the length of the input. The parser is a predictive + LL(1) parser. The complexity can be higher if the parser callback function + @a cb has a super-linear complexity. + + @note A UTF-8 byte order mark is silently ignored. + + @liveexample{The example below demonstrates the `parse()` function reading + from an iterator range.,parse__iteratortype__parser_callback_t} + + @since version 2.0.3 + */ + template::iterator_category>::value, int>::type = 0> + static basic_json parse(IteratorType first, IteratorType last, + const parser_callback_t cb = nullptr, + const bool allow_exceptions = true) + { + basic_json result; + parser(detail::input_adapter(first, last), cb, allow_exceptions).parse(true, result); + return result; + } + + template::iterator_category>::value, int>::type = 0> + static bool accept(IteratorType first, IteratorType last) + { + return parser(detail::input_adapter(first, last)).accept(true); + } + + /*! + @brief deserialize from stream + @deprecated This stream operator is deprecated and will be removed in a + future version of the library. Please use + @ref operator>>(std::istream&, basic_json&) + instead; that is, replace calls like `j << i;` with `i >> j;`. + @since version 1.0.0; deprecated since version 3.0.0 + */ + JSON_DEPRECATED + friend std::istream& operator<<(basic_json& j, std::istream& i) + { + return operator>>(i, j); + } + + /*! + @brief deserialize from stream + + Deserializes an input stream to a JSON value. + + @param[in,out] i input stream to read a serialized JSON value from + @param[in,out] j JSON value to write the deserialized input to + + @throw parse_error.101 in case of an unexpected token + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + + @complexity Linear in the length of the input. The parser is a predictive + LL(1) parser. + + @note A UTF-8 byte order mark is silently ignored. + + @liveexample{The example below shows how a JSON value is constructed by + reading a serialization from a stream.,operator_deserialize} + + @sa parse(std::istream&, const parser_callback_t) for a variant with a + parser callback function to filter values while parsing + + @since version 1.0.0 + */ + friend std::istream& operator>>(std::istream& i, basic_json& j) + { + parser(detail::input_adapter(i)).parse(false, j); + return i; + } + + /// @} + + /////////////////////////// + // convenience functions // + /////////////////////////// + + /*! + @brief return the type as string + + Returns the type name as string to be used in error messages - usually to + indicate that a function was called on a wrong JSON type. + + @return a string representation of a the @a m_type member: + Value type | return value + ----------- | ------------- + null | `"null"` + boolean | `"boolean"` + string | `"string"` + number | `"number"` (for all number types) + object | `"object"` + array | `"array"` + discarded | `"discarded"` + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @complexity Constant. + + @liveexample{The following code exemplifies `type_name()` for all JSON + types.,type_name} + + @sa @ref type() -- return the type of the JSON value + @sa @ref operator value_t() -- return the type of the JSON value (implicit) + + @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` + since 3.0.0 + */ + const char* type_name() const noexcept + { + { + switch (m_type) + { + case value_t::null: + return "null"; + case value_t::object: + return "object"; + case value_t::array: + return "array"; + case value_t::string: + return "string"; + case value_t::boolean: + return "boolean"; + case value_t::discarded: + return "discarded"; + default: + return "number"; + } + } + } + + + private: + ////////////////////// + // member variables // + ////////////////////// + + /// the type of the current element + value_t m_type = value_t::null; + + /// the value of the current element + json_value m_value = {}; + + ////////////////////////////////////////// + // binary serialization/deserialization // + ////////////////////////////////////////// + + /// @name binary serialization/deserialization support + /// @{ + + public: + /*! + @brief create a CBOR serialization of a given JSON value + + Serializes a given JSON value @a j to a byte vector using the CBOR (Concise + Binary Object Representation) serialization format. CBOR is a binary + serialization format which aims to be more compact than JSON itself, yet + more efficient to parse. + + The library uses the following mapping from JSON values types to + CBOR types according to the CBOR specification (RFC 7049): + + JSON value type | value/range | CBOR type | first byte + --------------- | ------------------------------------------ | ---------------------------------- | --------------- + null | `null` | Null | 0xF6 + boolean | `true` | True | 0xF5 + boolean | `false` | False | 0xF4 + number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B + number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A + number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39 + number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38 + number_integer | -24..-1 | Negative integer | 0x20..0x37 + number_integer | 0..23 | Integer | 0x00..0x17 + number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18 + number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 + number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A + number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B + number_unsigned | 0..23 | Integer | 0x00..0x17 + number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18 + number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 + number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A + number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B + number_float | *any value* | Double-Precision Float | 0xFB + string | *length*: 0..23 | UTF-8 string | 0x60..0x77 + string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78 + string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79 + string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A + string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B + array | *size*: 0..23 | array | 0x80..0x97 + array | *size*: 23..255 | array (1 byte follow) | 0x98 + array | *size*: 256..65535 | array (2 bytes follow) | 0x99 + array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A + array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B + object | *size*: 0..23 | map | 0xA0..0xB7 + object | *size*: 23..255 | map (1 byte follow) | 0xB8 + object | *size*: 256..65535 | map (2 bytes follow) | 0xB9 + object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA + object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB + + @note The mapping is **complete** in the sense that any JSON value type + can be converted to a CBOR value. + + @note If NaN or Infinity are stored inside a JSON number, they are + serialized properly. This behavior differs from the @ref dump() + function which serializes NaN or Infinity to `null`. + + @note The following CBOR types are not used in the conversion: + - byte strings (0x40..0x5F) + - UTF-8 strings terminated by "break" (0x7F) + - arrays terminated by "break" (0x9F) + - maps terminated by "break" (0xBF) + - date/time (0xC0..0xC1) + - bignum (0xC2..0xC3) + - decimal fraction (0xC4) + - bigfloat (0xC5) + - tagged items (0xC6..0xD4, 0xD8..0xDB) + - expected conversions (0xD5..0xD7) + - simple values (0xE0..0xF3, 0xF8) + - undefined (0xF7) + - half and single-precision floats (0xF9-0xFA) + - break (0xFF) + + @param[in] j JSON value to serialize + @return MessagePack serialization as byte vector + + @complexity Linear in the size of the JSON value @a j. + + @liveexample{The example shows the serialization of a JSON value to a byte + vector in CBOR format.,to_cbor} + + @sa http://cbor.io + @sa @ref from_cbor(const std::vector&, const size_t) for the + analogous deserialization + @sa @ref to_msgpack(const basic_json&) for the related MessagePack format + + @since version 2.0.9 + */ + static std::vector to_cbor(const basic_json& j) + { + std::vector result; + to_cbor(j, result); + return result; + } + + static void to_cbor(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_cbor(j); + } + + static void to_cbor(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_cbor(j); + } + + /*! + @brief create a MessagePack serialization of a given JSON value + + Serializes a given JSON value @a j to a byte vector using the MessagePack + serialization format. MessagePack is a binary serialization format which + aims to be more compact than JSON itself, yet more efficient to parse. + + The library uses the following mapping from JSON values types to + MessagePack types according to the MessagePack specification: + + JSON value type | value/range | MessagePack type | first byte + --------------- | --------------------------------- | ---------------- | ---------- + null | `null` | nil | 0xC0 + boolean | `true` | true | 0xC3 + boolean | `false` | false | 0xC2 + number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3 + number_integer | -2147483648..-32769 | int32 | 0xD2 + number_integer | -32768..-129 | int16 | 0xD1 + number_integer | -128..-33 | int8 | 0xD0 + number_integer | -32..-1 | negative fixint | 0xE0..0xFF + number_integer | 0..127 | positive fixint | 0x00..0x7F + number_integer | 128..255 | uint 8 | 0xCC + number_integer | 256..65535 | uint 16 | 0xCD + number_integer | 65536..4294967295 | uint 32 | 0xCE + number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF + number_unsigned | 0..127 | positive fixint | 0x00..0x7F + number_unsigned | 128..255 | uint 8 | 0xCC + number_unsigned | 256..65535 | uint 16 | 0xCD + number_unsigned | 65536..4294967295 | uint 32 | 0xCE + number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF + number_float | *any value* | float 64 | 0xCB + string | *length*: 0..31 | fixstr | 0xA0..0xBF + string | *length*: 32..255 | str 8 | 0xD9 + string | *length*: 256..65535 | str 16 | 0xDA + string | *length*: 65536..4294967295 | str 32 | 0xDB + array | *size*: 0..15 | fixarray | 0x90..0x9F + array | *size*: 16..65535 | array 16 | 0xDC + array | *size*: 65536..4294967295 | array 32 | 0xDD + object | *size*: 0..15 | fix map | 0x80..0x8F + object | *size*: 16..65535 | map 16 | 0xDE + object | *size*: 65536..4294967295 | map 32 | 0xDF + + @note The mapping is **complete** in the sense that any JSON value type + can be converted to a MessagePack value. + + @note The following values can **not** be converted to a MessagePack value: + - strings with more than 4294967295 bytes + - arrays with more than 4294967295 elements + - objects with more than 4294967295 elements + + @note The following MessagePack types are not used in the conversion: + - bin 8 - bin 32 (0xC4..0xC6) + - ext 8 - ext 32 (0xC7..0xC9) + - float 32 (0xCA) + - fixext 1 - fixext 16 (0xD4..0xD8) + + @note Any MessagePack output created @ref to_msgpack can be successfully + parsed by @ref from_msgpack. + + @note If NaN or Infinity are stored inside a JSON number, they are + serialized properly. This behavior differs from the @ref dump() + function which serializes NaN or Infinity to `null`. + + @param[in] j JSON value to serialize + @return MessagePack serialization as byte vector + + @complexity Linear in the size of the JSON value @a j. + + @liveexample{The example shows the serialization of a JSON value to a byte + vector in MessagePack format.,to_msgpack} + + @sa http://msgpack.org + @sa @ref from_msgpack(const std::vector&, const size_t) for the + analogous deserialization + @sa @ref to_cbor(const basic_json& for the related CBOR format + + @since version 2.0.9 + */ + static std::vector to_msgpack(const basic_json& j) + { + std::vector result; + to_msgpack(j, result); + return result; + } + + static void to_msgpack(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_msgpack(j); + } + + static void to_msgpack(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_msgpack(j); + } + + /*! + @brief create a JSON value from an input in CBOR format + + Deserializes a given input @a i to a JSON value using the CBOR (Concise + Binary Object Representation) serialization format. + + The library maps CBOR types to JSON value types as follows: + + CBOR type | JSON value type | first byte + ---------------------- | --------------- | ---------- + Integer | number_unsigned | 0x00..0x17 + Unsigned integer | number_unsigned | 0x18 + Unsigned integer | number_unsigned | 0x19 + Unsigned integer | number_unsigned | 0x1A + Unsigned integer | number_unsigned | 0x1B + Negative integer | number_integer | 0x20..0x37 + Negative integer | number_integer | 0x38 + Negative integer | number_integer | 0x39 + Negative integer | number_integer | 0x3A + Negative integer | number_integer | 0x3B + Negative integer | number_integer | 0x40..0x57 + UTF-8 string | string | 0x60..0x77 + UTF-8 string | string | 0x78 + UTF-8 string | string | 0x79 + UTF-8 string | string | 0x7A + UTF-8 string | string | 0x7B + UTF-8 string | string | 0x7F + array | array | 0x80..0x97 + array | array | 0x98 + array | array | 0x99 + array | array | 0x9A + array | array | 0x9B + array | array | 0x9F + map | object | 0xA0..0xB7 + map | object | 0xB8 + map | object | 0xB9 + map | object | 0xBA + map | object | 0xBB + map | object | 0xBF + False | `false` | 0xF4 + True | `true` | 0xF5 + Nill | `null` | 0xF6 + Half-Precision Float | number_float | 0xF9 + Single-Precision Float | number_float | 0xFA + Double-Precision Float | number_float | 0xFB + + @warning The mapping is **incomplete** in the sense that not all CBOR + types can be converted to a JSON value. The following CBOR types + are not supported and will yield parse errors (parse_error.112): + - byte strings (0x40..0x5F) + - date/time (0xC0..0xC1) + - bignum (0xC2..0xC3) + - decimal fraction (0xC4) + - bigfloat (0xC5) + - tagged items (0xC6..0xD4, 0xD8..0xDB) + - expected conversions (0xD5..0xD7) + - simple values (0xE0..0xF3, 0xF8) + - undefined (0xF7) + + @warning CBOR allows map keys of any type, whereas JSON only allows + strings as keys in object values. Therefore, CBOR maps with keys + other than UTF-8 strings are rejected (parse_error.113). + + @note Any CBOR output created @ref to_cbor can be successfully parsed by + @ref from_cbor. + + @param[in] i an input in CBOR format convertible to an input adapter + @param[in] strict whether to expect the input to be consumed until EOF + (true by default) + @return deserialized JSON value + + @throw parse_error.110 if the given input ends prematurely or the end of + file was not reached when @a strict was set to true + @throw parse_error.112 if unsupported features from CBOR were + used in the given input @a v or if the input is not valid CBOR + @throw parse_error.113 if a string was expected as map key, but not found + + @complexity Linear in the size of the input @a i. + + @liveexample{The example shows the deserialization of a byte vector in CBOR + format to a JSON value.,from_cbor} + + @sa http://cbor.io + @sa @ref to_cbor(const basic_json&) for the analogous serialization + @sa @ref from_msgpack(detail::input_adapter, const bool) for the + related MessagePack format + + @since version 2.0.9; parameter @a start_index since 2.1.1; changed to + consume input adapters, removed start_index parameter, and added + @a strict parameter since 3.0.0 + */ + static basic_json from_cbor(detail::input_adapter i, + const bool strict = true) + { + return binary_reader(i).parse_cbor(strict); + } + + /*! + @copydoc from_cbor(detail::input_adapter, const bool) + */ + template::value, int> = 0> + static basic_json from_cbor(A1 && a1, A2 && a2, const bool strict = true) + { + return binary_reader(detail::input_adapter(std::forward(a1), std::forward(a2))).parse_cbor(strict); + } + + /*! + @brief create a JSON value from an input in MessagePack format + + Deserializes a given input @a i to a JSON value using the MessagePack + serialization format. + + The library maps MessagePack types to JSON value types as follows: + + MessagePack type | JSON value type | first byte + ---------------- | --------------- | ---------- + positive fixint | number_unsigned | 0x00..0x7F + fixmap | object | 0x80..0x8F + fixarray | array | 0x90..0x9F + fixstr | string | 0xA0..0xBF + nil | `null` | 0xC0 + false | `false` | 0xC2 + true | `true` | 0xC3 + float 32 | number_float | 0xCA + float 64 | number_float | 0xCB + uint 8 | number_unsigned | 0xCC + uint 16 | number_unsigned | 0xCD + uint 32 | number_unsigned | 0xCE + uint 64 | number_unsigned | 0xCF + int 8 | number_integer | 0xD0 + int 16 | number_integer | 0xD1 + int 32 | number_integer | 0xD2 + int 64 | number_integer | 0xD3 + str 8 | string | 0xD9 + str 16 | string | 0xDA + str 32 | string | 0xDB + array 16 | array | 0xDC + array 32 | array | 0xDD + map 16 | object | 0xDE + map 32 | object | 0xDF + negative fixint | number_integer | 0xE0-0xFF + + @warning The mapping is **incomplete** in the sense that not all + MessagePack types can be converted to a JSON value. The following + MessagePack types are not supported and will yield parse errors: + - bin 8 - bin 32 (0xC4..0xC6) + - ext 8 - ext 32 (0xC7..0xC9) + - fixext 1 - fixext 16 (0xD4..0xD8) + + @note Any MessagePack output created @ref to_msgpack can be successfully + parsed by @ref from_msgpack. + + @param[in] i an input in MessagePack format convertible to an input + adapter + @param[in] strict whether to expect the input to be consumed until EOF + (true by default) + + @throw parse_error.110 if the given input ends prematurely or the end of + file was not reached when @a strict was set to true + @throw parse_error.112 if unsupported features from MessagePack were + used in the given input @a i or if the input is not valid MessagePack + @throw parse_error.113 if a string was expected as map key, but not found + + @complexity Linear in the size of the input @a i. + + @liveexample{The example shows the deserialization of a byte vector in + MessagePack format to a JSON value.,from_msgpack} + + @sa http://msgpack.org + @sa @ref to_msgpack(const basic_json&) for the analogous serialization + @sa @ref from_cbor(detail::input_adapter, const bool) for the related CBOR + format + + @since version 2.0.9; parameter @a start_index since 2.1.1; changed to + consume input adapters, removed start_index parameter, and added + @a strict parameter since 3.0.0 + */ + static basic_json from_msgpack(detail::input_adapter i, + const bool strict = true) + { + return binary_reader(i).parse_msgpack(strict); + } + + /*! + @copydoc from_msgpack(detail::input_adapter, const bool) + */ + template::value, int> = 0> + static basic_json from_msgpack(A1 && a1, A2 && a2, const bool strict = true) + { + return binary_reader(detail::input_adapter(std::forward(a1), std::forward(a2))).parse_msgpack(strict); + } + + /// @} + + ////////////////////////// + // JSON Pointer support // + ////////////////////////// + + /// @name JSON Pointer functions + /// @{ + + /*! + @brief access specified element via JSON Pointer + + Uses a JSON pointer to retrieve a reference to the respective JSON value. + No bound checking is performed. Similar to @ref operator[](const typename + object_t::key_type&), `null` values are created in arrays and objects if + necessary. + + In particular: + - If the JSON pointer points to an object key that does not exist, it + is created an filled with a `null` value before a reference to it + is returned. + - If the JSON pointer points to an array index that does not exist, it + is created an filled with a `null` value before a reference to it + is returned. All indices between the current maximum and the given + index are also filled with `null`. + - The special value `-` is treated as a synonym for the index past the + end. + + @param[in] ptr a JSON pointer + + @return reference to the element pointed to by @a ptr + + @complexity Constant. + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.404 if the JSON pointer can not be resolved + + @liveexample{The behavior is shown in the example.,operatorjson_pointer} + + @since version 2.0.0 + */ + reference operator[](const json_pointer& ptr) + { + return ptr.get_unchecked(this); + } + + /*! + @brief access specified element via JSON Pointer + + Uses a JSON pointer to retrieve a reference to the respective JSON value. + No bound checking is performed. The function does not change the JSON + value; no `null` values are created. In particular, the the special value + `-` yields an exception. + + @param[in] ptr JSON pointer to the desired element + + @return const reference to the element pointed to by @a ptr + + @complexity Constant. + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.402 if the array index '-' is used + @throw out_of_range.404 if the JSON pointer can not be resolved + + @liveexample{The behavior is shown in the example.,operatorjson_pointer_const} + + @since version 2.0.0 + */ + const_reference operator[](const json_pointer& ptr) const + { + return ptr.get_unchecked(this); + } + + /*! + @brief access specified element via JSON Pointer + + Returns a reference to the element at with specified JSON pointer @a ptr, + with bounds checking. + + @param[in] ptr JSON pointer to the desired element + + @return reference to the element pointed to by @a ptr + + @throw parse_error.106 if an array index in the passed JSON pointer @a ptr + begins with '0'. See example below. + + @throw parse_error.109 if an array index in the passed JSON pointer @a ptr + is not a number. See example below. + + @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr + is out of range. See example below. + + @throw out_of_range.402 if the array index '-' is used in the passed JSON + pointer @a ptr. As `at` provides checked access (and no elements are + implicitly inserted), the index '-' is always invalid. See example below. + + @throw out_of_range.403 if the JSON pointer describes a key of an object + which cannot be found. See example below. + + @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. + See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @since version 2.0.0 + + @liveexample{The behavior is shown in the example.,at_json_pointer} + */ + reference at(const json_pointer& ptr) + { + return ptr.get_checked(this); + } + + /*! + @brief access specified element via JSON Pointer + + Returns a const reference to the element at with specified JSON pointer @a + ptr, with bounds checking. + + @param[in] ptr JSON pointer to the desired element + + @return reference to the element pointed to by @a ptr + + @throw parse_error.106 if an array index in the passed JSON pointer @a ptr + begins with '0'. See example below. + + @throw parse_error.109 if an array index in the passed JSON pointer @a ptr + is not a number. See example below. + + @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr + is out of range. See example below. + + @throw out_of_range.402 if the array index '-' is used in the passed JSON + pointer @a ptr. As `at` provides checked access (and no elements are + implicitly inserted), the index '-' is always invalid. See example below. + + @throw out_of_range.403 if the JSON pointer describes a key of an object + which cannot be found. See example below. + + @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. + See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @since version 2.0.0 + + @liveexample{The behavior is shown in the example.,at_json_pointer_const} + */ + const_reference at(const json_pointer& ptr) const + { + return ptr.get_checked(this); + } + + /*! + @brief return flattened JSON value + + The function creates a JSON object whose keys are JSON pointers (see [RFC + 6901](https://tools.ietf.org/html/rfc6901)) and whose values are all + primitive. The original JSON value can be restored using the @ref + unflatten() function. + + @return an object that maps JSON pointers to primitive values + + @note Empty objects and arrays are flattened to `null` and will not be + reconstructed correctly by the @ref unflatten() function. + + @complexity Linear in the size the JSON value. + + @liveexample{The following code shows how a JSON object is flattened to an + object whose keys consist of JSON pointers.,flatten} + + @sa @ref unflatten() for the reverse function + + @since version 2.0.0 + */ + basic_json flatten() const + { + basic_json result(value_t::object); + json_pointer::flatten("", *this, result); + return result; + } + + /*! + @brief unflatten a previously flattened JSON value + + The function restores the arbitrary nesting of a JSON value that has been + flattened before using the @ref flatten() function. The JSON value must + meet certain constraints: + 1. The value must be an object. + 2. The keys must be JSON pointers (see + [RFC 6901](https://tools.ietf.org/html/rfc6901)) + 3. The mapped values must be primitive JSON types. + + @return the original JSON from a flattened version + + @note Empty objects and arrays are flattened by @ref flatten() to `null` + values and can not unflattened to their original type. Apart from + this example, for a JSON value `j`, the following is always true: + `j == j.flatten().unflatten()`. + + @complexity Linear in the size the JSON value. + + @throw type_error.314 if value is not an object + @throw type_error.315 if object values are not primitive + + @liveexample{The following code shows how a flattened JSON object is + unflattened into the original nested JSON object.,unflatten} + + @sa @ref flatten() for the reverse function + + @since version 2.0.0 + */ + basic_json unflatten() const + { + return json_pointer::unflatten(*this); + } + + /// @} + + ////////////////////////// + // JSON Patch functions // + ////////////////////////// + + /// @name JSON Patch functions + /// @{ + + /*! + @brief applies a JSON patch + + [JSON Patch](http://jsonpatch.com) defines a JSON document structure for + expressing a sequence of operations to apply to a JSON) document. With + this function, a JSON Patch is applied to the current JSON value by + executing all operations from the patch. + + @param[in] json_patch JSON patch document + @return patched document + + @note The application of a patch is atomic: Either all operations succeed + and the patched document is returned or an exception is thrown. In + any case, the original value is not changed: the patch is applied + to a copy of the value. + + @throw parse_error.104 if the JSON patch does not consist of an array of + objects + + @throw parse_error.105 if the JSON patch is malformed (e.g., mandatory + attributes are missing); example: `"operation add must have member path"` + + @throw out_of_range.401 if an array index is out of range. + + @throw out_of_range.403 if a JSON pointer inside the patch could not be + resolved successfully in the current JSON value; example: `"key baz not + found"` + + @throw out_of_range.405 if JSON pointer has no parent ("add", "remove", + "move") + + @throw other_error.501 if "test" operation was unsuccessful + + @complexity Linear in the size of the JSON value and the length of the + JSON patch. As usually only a fraction of the JSON value is affected by + the patch, the complexity can usually be neglected. + + @liveexample{The following code shows how a JSON patch is applied to a + value.,patch} + + @sa @ref diff -- create a JSON patch by comparing two JSON values + + @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) + @sa [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) + + @since version 2.0.0 + */ + basic_json patch(const basic_json& json_patch) const + { + // make a working copy to apply the patch to + basic_json result = *this; + + // the valid JSON Patch operations + enum class patch_operations {add, remove, replace, move, copy, test, invalid}; + + const auto get_op = [](const std::string & op) + { + if (op == "add") + { + return patch_operations::add; + } + if (op == "remove") + { + return patch_operations::remove; + } + if (op == "replace") + { + return patch_operations::replace; + } + if (op == "move") + { + return patch_operations::move; + } + if (op == "copy") + { + return patch_operations::copy; + } + if (op == "test") + { + return patch_operations::test; + } + + return patch_operations::invalid; + }; + + // wrapper for "add" operation; add value at ptr + const auto operation_add = [&result](json_pointer & ptr, basic_json val) + { + // adding to the root of the target document means replacing it + if (ptr.is_root()) + { + result = val; + } + else + { + // make sure the top element of the pointer exists + json_pointer top_pointer = ptr.top(); + if (top_pointer != ptr) + { + result.at(top_pointer); + } + + // get reference to parent of JSON pointer ptr + const auto last_path = ptr.pop_back(); + basic_json& parent = result[ptr]; + + switch (parent.m_type) + { + case value_t::null: + case value_t::object: + { + // use operator[] to add value + parent[last_path] = val; + break; + } + + case value_t::array: + { + if (last_path == "-") + { + // special case: append to back + parent.push_back(val); + } + else + { + const auto idx = json_pointer::array_index(last_path); + if (JSON_UNLIKELY(static_cast(idx) > parent.size())) + { + // avoid undefined behavior + JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); + } + else + { + // default case: insert add offset + parent.insert(parent.begin() + static_cast(idx), val); + } + } + break; + } + + default: + { + // if there exists a parent it cannot be primitive + assert(false); // LCOV_EXCL_LINE + } + } + } + }; + + // wrapper for "remove" operation; remove value at ptr + const auto operation_remove = [&result](json_pointer & ptr) + { + // get reference to parent of JSON pointer ptr + const auto last_path = ptr.pop_back(); + basic_json& parent = result.at(ptr); + + // remove child + if (parent.is_object()) + { + // perform range check + auto it = parent.find(last_path); + if (JSON_LIKELY(it != parent.end())) + { + parent.erase(it); + } + else + { + JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found")); + } + } + else if (parent.is_array()) + { + // note erase performs range check + parent.erase(static_cast(json_pointer::array_index(last_path))); + } + }; + + // type check: top level value must be an array + if (JSON_UNLIKELY(not json_patch.is_array())) + { + JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); + } + + // iterate and apply the operations + for (const auto& val : json_patch) + { + // wrapper to get a value for an operation + const auto get_value = [&val](const std::string & op, + const std::string & member, + bool string_type) -> basic_json& + { + // find value + auto it = val.m_value.object->find(member); + + // context-sensitive error message + const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; + + // check if desired value is present + if (JSON_UNLIKELY(it == val.m_value.object->end())) + { + JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'")); + } + + // check if result is of type string + if (JSON_UNLIKELY(string_type and not it->second.is_string())) + { + JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'")); + } + + // no error: return value + return it->second; + }; + + // type check: every element of the array must be an object + if (JSON_UNLIKELY(not val.is_object())) + { + JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); + } + + // collect mandatory members + const std::string op = get_value("op", "op", true); + const std::string path = get_value(op, "path", true); + json_pointer ptr(path); + + switch (get_op(op)) + { + case patch_operations::add: + { + operation_add(ptr, get_value("add", "value", false)); + break; + } + + case patch_operations::remove: + { + operation_remove(ptr); + break; + } + + case patch_operations::replace: + { + // the "path" location must exist - use at() + result.at(ptr) = get_value("replace", "value", false); + break; + } + + case patch_operations::move: + { + const std::string from_path = get_value("move", "from", true); + json_pointer from_ptr(from_path); + + // the "from" location must exist - use at() + basic_json v = result.at(from_ptr); + + // The move operation is functionally identical to a + // "remove" operation on the "from" location, followed + // immediately by an "add" operation at the target + // location with the value that was just removed. + operation_remove(from_ptr); + operation_add(ptr, v); + break; + } + + case patch_operations::copy: + { + const std::string from_path = get_value("copy", "from", true); + const json_pointer from_ptr(from_path); + + // the "from" location must exist - use at() + basic_json v = result.at(from_ptr); + + // The copy is functionally identical to an "add" + // operation at the target location using the value + // specified in the "from" member. + operation_add(ptr, v); + break; + } + + case patch_operations::test: + { + bool success = false; + JSON_TRY + { + // check if "value" matches the one at "path" + // the "path" location must exist - use at() + success = (result.at(ptr) == get_value("test", "value", false)); + } + JSON_CATCH (out_of_range&) + { + // ignore out of range errors: success remains false + } + + // throw an exception if test fails + if (JSON_UNLIKELY(not success)) + { + JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump())); + } + + break; + } + + case patch_operations::invalid: + { + // op must be "add", "remove", "replace", "move", "copy", or + // "test" + JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid")); + } + } + } + + return result; + } + + /*! + @brief creates a diff as a JSON patch + + Creates a [JSON Patch](http://jsonpatch.com) so that value @a source can + be changed into the value @a target by calling @ref patch function. + + @invariant For two JSON values @a source and @a target, the following code + yields always `true`: + @code {.cpp} + source.patch(diff(source, target)) == target; + @endcode + + @note Currently, only `remove`, `add`, and `replace` operations are + generated. + + @param[in] source JSON value to compare from + @param[in] target JSON value to compare against + @param[in] path helper value to create JSON pointers + + @return a JSON patch to convert the @a source to @a target + + @complexity Linear in the lengths of @a source and @a target. + + @liveexample{The following code shows how a JSON patch is created as a + diff for two JSON values.,diff} + + @sa @ref patch -- apply a JSON patch + + @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) + + @since version 2.0.0 + */ + static basic_json diff(const basic_json& source, const basic_json& target, + const std::string& path = "") + { + // the patch + basic_json result(value_t::array); + + // if the values are the same, return empty patch + if (source == target) + { + return result; + } + + if (source.type() != target.type()) + { + // different types: replace value + result.push_back( + { + {"op", "replace"}, {"path", path}, {"value", target} + }); + } + else + { + switch (source.type()) + { + case value_t::array: + { + // first pass: traverse common elements + std::size_t i = 0; + while (i < source.size() and i < target.size()) + { + // recursive call to compare array values at index i + auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i)); + result.insert(result.end(), temp_diff.begin(), temp_diff.end()); + ++i; + } + + // i now reached the end of at least one array + // in a second pass, traverse the remaining elements + + // remove my remaining elements + const auto end_index = static_cast(result.size()); + while (i < source.size()) + { + // add operations in reverse order to avoid invalid + // indices + result.insert(result.begin() + end_index, object( + { + {"op", "remove"}, + {"path", path + "/" + std::to_string(i)} + })); + ++i; + } + + // add other remaining elements + while (i < target.size()) + { + result.push_back( + { + {"op", "add"}, + {"path", path + "/" + std::to_string(i)}, + {"value", target[i]} + }); + ++i; + } + + break; + } + + case value_t::object: + { + // first pass: traverse this object's elements + for (auto it = source.cbegin(); it != source.cend(); ++it) + { + // escape the key name to be used in a JSON patch + const auto key = json_pointer::escape(it.key()); + + if (target.find(it.key()) != target.end()) + { + // recursive call to compare object values at key it + auto temp_diff = diff(it.value(), target[it.key()], path + "/" + key); + result.insert(result.end(), temp_diff.begin(), temp_diff.end()); + } + else + { + // found a key that is not in o -> remove it + result.push_back(object( + { + {"op", "remove"}, {"path", path + "/" + key} + })); + } + } + + // second pass: traverse other object's elements + for (auto it = target.cbegin(); it != target.cend(); ++it) + { + if (source.find(it.key()) == source.end()) + { + // found a key that is not in this -> add it + const auto key = json_pointer::escape(it.key()); + result.push_back( + { + {"op", "add"}, {"path", path + "/" + key}, + {"value", it.value()} + }); + } + } + + break; + } + + default: + { + // both primitive type: replace value + result.push_back( + { + {"op", "replace"}, {"path", path}, {"value", target} + }); + break; + } + } + } + + return result; + } + + /// @} +}; + +///////////// +// presets // +///////////// + +/*! +@brief default JSON class + +This type is the default specialization of the @ref basic_json class which +uses the standard template types. + +@since version 1.0.0 +*/ +using json = basic_json<>; + +////////////////// +// json_pointer // +////////////////// + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +NLOHMANN_BASIC_JSON_TPL& +json_pointer::get_and_create(NLOHMANN_BASIC_JSON_TPL& j) const +{ + using size_type = typename NLOHMANN_BASIC_JSON_TPL::size_type; + auto result = &j; + + // in case no reference tokens exist, return a reference to the JSON value + // j which will be overwritten by a primitive value + for (const auto& reference_token : reference_tokens) + { + switch (result->m_type) + { + case detail::value_t::null: + { + if (reference_token == "0") + { + // start a new array if reference token is 0 + result = &result->operator[](0); + } + else + { + // start a new object otherwise + result = &result->operator[](reference_token); + } + break; + } + + case detail::value_t::object: + { + // create an entry in the object + result = &result->operator[](reference_token); + break; + } + + case detail::value_t::array: + { + // create an entry in the array + JSON_TRY + { + result = &result->operator[](static_cast(array_index(reference_token))); + } + JSON_CATCH(std::invalid_argument&) + { + JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); + } + break; + } + + /* + The following code is only reached if there exists a reference + token _and_ the current value is primitive. In this case, we have + an error situation, because primitive values may only occur as + single value; that is, with an empty list of reference tokens. + */ + default: + JSON_THROW(detail::type_error::create(313, "invalid value to unflatten")); + } + } + + return *result; +} + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +NLOHMANN_BASIC_JSON_TPL& +json_pointer::get_unchecked(NLOHMANN_BASIC_JSON_TPL* ptr) const +{ + using size_type = typename NLOHMANN_BASIC_JSON_TPL::size_type; + for (const auto& reference_token : reference_tokens) + { + // convert null values to arrays or objects before continuing + if (ptr->m_type == detail::value_t::null) + { + // check if reference token is a number + const bool nums = + std::all_of(reference_token.begin(), reference_token.end(), + [](const char x) + { + return (x >= '0' and x <= '9'); + }); + + // change value to array for numbers or "-" or to object otherwise + *ptr = (nums or reference_token == "-") + ? detail::value_t::array + : detail::value_t::object; + } + + switch (ptr->m_type) + { + case detail::value_t::object: + { + // use unchecked object access + ptr = &ptr->operator[](reference_token); + break; + } + + case detail::value_t::array: + { + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + { + JSON_THROW(detail::parse_error::create(106, 0, + "array index '" + reference_token + + "' must not begin with '0'")); + } + + if (reference_token == "-") + { + // explicitly treat "-" as index beyond the end + ptr = &ptr->operator[](ptr->m_value.array->size()); + } + else + { + // convert array index to number; unchecked access + JSON_TRY + { + ptr = &ptr->operator[]( + static_cast(array_index(reference_token))); + } + JSON_CATCH(std::invalid_argument&) + { + JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); + } + } + break; + } + + default: + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'")); + } + } + + return *ptr; +} + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +NLOHMANN_BASIC_JSON_TPL& +json_pointer::get_checked(NLOHMANN_BASIC_JSON_TPL* ptr) const +{ + using size_type = typename NLOHMANN_BASIC_JSON_TPL::size_type; + for (const auto& reference_token : reference_tokens) + { + switch (ptr->m_type) + { + case detail::value_t::object: + { + // note: at performs range check + ptr = &ptr->at(reference_token); + break; + } + + case detail::value_t::array: + { + if (JSON_UNLIKELY(reference_token == "-")) + { + // "-" always fails the range check + JSON_THROW(detail::out_of_range::create(402, + "array index '-' (" + std::to_string(ptr->m_value.array->size()) + + ") is out of range")); + } + + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + { + JSON_THROW(detail::parse_error::create(106, 0, + "array index '" + reference_token + + "' must not begin with '0'")); + } + + // note: at performs range check + JSON_TRY + { + ptr = &ptr->at(static_cast(array_index(reference_token))); + } + JSON_CATCH(std::invalid_argument&) + { + JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); + } + break; + } + + default: + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'")); + } + } + + return *ptr; +} + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +const NLOHMANN_BASIC_JSON_TPL& +json_pointer::get_unchecked(const NLOHMANN_BASIC_JSON_TPL* ptr) const +{ + using size_type = typename NLOHMANN_BASIC_JSON_TPL::size_type; + for (const auto& reference_token : reference_tokens) + { + switch (ptr->m_type) + { + case detail::value_t::object: + { + // use unchecked object access + ptr = &ptr->operator[](reference_token); + break; + } + + case detail::value_t::array: + { + if (JSON_UNLIKELY(reference_token == "-")) + { + // "-" cannot be used for const access + JSON_THROW(detail::out_of_range::create(402, + "array index '-' (" + std::to_string(ptr->m_value.array->size()) + + ") is out of range")); + } + + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + { + JSON_THROW(detail::parse_error::create(106, 0, + "array index '" + reference_token + + "' must not begin with '0'")); + } + + // use unchecked array access + JSON_TRY + { + ptr = &ptr->operator[]( + static_cast(array_index(reference_token))); + } + JSON_CATCH(std::invalid_argument&) + { + JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); + } + break; + } + + default: + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'")); + } + } + + return *ptr; +} + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +const NLOHMANN_BASIC_JSON_TPL& +json_pointer::get_checked(const NLOHMANN_BASIC_JSON_TPL* ptr) const +{ + using size_type = typename NLOHMANN_BASIC_JSON_TPL::size_type; + for (const auto& reference_token : reference_tokens) + { + switch (ptr->m_type) + { + case detail::value_t::object: + { + // note: at performs range check + ptr = &ptr->at(reference_token); + break; + } + + case detail::value_t::array: + { + if (JSON_UNLIKELY(reference_token == "-")) + { + // "-" always fails the range check + JSON_THROW(detail::out_of_range::create(402, + "array index '-' (" + std::to_string(ptr->m_value.array->size()) + + ") is out of range")); + } + + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + { + JSON_THROW(detail::parse_error::create(106, 0, + "array index '" + reference_token + + "' must not begin with '0'")); + } + + // note: at performs range check + JSON_TRY + { + ptr = &ptr->at(static_cast(array_index(reference_token))); + } + JSON_CATCH(std::invalid_argument&) + { + JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); + } + break; + } + + default: + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'")); + } + } + + return *ptr; +} + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +void json_pointer::flatten(const std::string& reference_string, + const NLOHMANN_BASIC_JSON_TPL& value, + NLOHMANN_BASIC_JSON_TPL& result) +{ + switch (value.m_type) + { + case detail::value_t::array: + { + if (value.m_value.array->empty()) + { + // flatten empty array as null + result[reference_string] = nullptr; + } + else + { + // iterate array and use index as reference string + for (std::size_t i = 0; i < value.m_value.array->size(); ++i) + { + flatten(reference_string + "/" + std::to_string(i), + value.m_value.array->operator[](i), result); + } + } + break; + } + + case detail::value_t::object: + { + if (value.m_value.object->empty()) + { + // flatten empty object as null + result[reference_string] = nullptr; + } + else + { + // iterate object and use keys as reference string + for (const auto& element : *value.m_value.object) + { + flatten(reference_string + "/" + escape(element.first), element.second, result); + } + } + break; + } + + default: + { + // add primitive value with its reference string + result[reference_string] = value; + break; + } + } +} + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +NLOHMANN_BASIC_JSON_TPL +json_pointer::unflatten(const NLOHMANN_BASIC_JSON_TPL& value) +{ + if (JSON_UNLIKELY(not value.is_object())) + { + JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); + } + + NLOHMANN_BASIC_JSON_TPL result; + + // iterate the JSON object values + for (const auto& element : *value.m_value.object) + { + if (JSON_UNLIKELY(not element.second.is_primitive())) + { + JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); + } + + // assign value to reference pointed to by JSON pointer; Note that if + // the JSON pointer is "" (i.e., points to the whole value), function + // get_and_create returns a reference to result itself. An assignment + // will then create a primitive value. + json_pointer(element.first).get_and_create(result) = element.second; + } + + return result; +} + +inline bool operator==(json_pointer const& lhs, json_pointer const& rhs) noexcept +{ + return (lhs.reference_tokens == rhs.reference_tokens); +} + +inline bool operator!=(json_pointer const& lhs, json_pointer const& rhs) noexcept +{ + return not (lhs == rhs); +} +} // namespace nlohmann + + +/////////////////////// +// nonmember support // +/////////////////////// + +// specialization of std::swap, and std::hash +namespace std +{ +/*! +@brief exchanges the values of two JSON objects + +@since version 1.0.0 +*/ +template<> +inline void swap(nlohmann::json& j1, + nlohmann::json& j2) noexcept( + is_nothrow_move_constructible::value and + is_nothrow_move_assignable::value + ) +{ + j1.swap(j2); +} + +/// hash value for JSON objects +template<> +struct hash +{ + /*! + @brief return a hash value for a JSON object + + @since version 1.0.0 + */ + std::size_t operator()(const nlohmann::json& j) const + { + // a naive hashing via the string representation + const auto& h = hash(); + return h(j.dump()); + } +}; + +/// specialization for std::less +/// @note: do not remove the space after '<', +/// see https://github.com/nlohmann/json/pull/679 +template<> +struct less< ::nlohmann::detail::value_t> +{ + /*! + @brief compare two value_t enum values + @since version 3.0.0 + */ + bool operator()(nlohmann::detail::value_t lhs, + nlohmann::detail::value_t rhs) const noexcept + { + return nlohmann::detail::operator<(lhs, rhs); + } +}; + +} // namespace std + +/*! +@brief user-defined string literal for JSON values + +This operator implements a user-defined string literal for JSON objects. It +can be used by adding `"_json"` to a string literal and returns a JSON object +if no parse error occurred. + +@param[in] s a string representation of a JSON object +@param[in] n the length of string @a s +@return a JSON object + +@since version 1.0.0 +*/ +inline nlohmann::json operator "" _json(const char* s, std::size_t n) +{ + return nlohmann::json::parse(s, s + n); +} + +/*! +@brief user-defined string literal for JSON pointer + +This operator implements a user-defined string literal for JSON Pointers. It +can be used by adding `"_json_pointer"` to a string literal and returns a JSON pointer +object if no parse error occurred. + +@param[in] s a string representation of a JSON Pointer +@param[in] n the length of string @a s +@return a JSON pointer object + +@since version 2.0.0 +*/ +inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) +{ + return nlohmann::json::json_pointer(std::string(s, n)); +} + +// restore GCC/clang diagnostic settings +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic pop +#endif +#if defined(__clang__) + #pragma GCC diagnostic pop +#endif + +// clean up +#undef JSON_CATCH +#undef JSON_THROW +#undef JSON_TRY +#undef JSON_LIKELY +#undef JSON_UNLIKELY +#undef JSON_DEPRECATED +#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION +#undef NLOHMANN_BASIC_JSON_TPL + +#endif diff -Nru upm-1.6.0/scripts/build-android.sh upm-1.7.1/scripts/build-android.sh --- upm-1.6.0/scripts/build-android.sh 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/scripts/build-android.sh 2018-10-12 04:47:41.000000000 +0000 @@ -66,7 +66,7 @@ make -j8 -Cbuild # Anotate the .java src from doxygen -find src/ -name "javaupm_*.i" > build/upm.i.list +find src/ -name "*.i" > build/upm.i.list #../doxy/doxyport build/upm.i.list \ # -s src/interfaces/,src/bacnetmstp,src/bmg160,src/bma250e,src/bmm150 \ # -m doxy/samples.mapping.txt \ @@ -77,7 +77,7 @@ gen_and_upload() { # Skip any directories without .java src files - if [ ! -f *.java ]; then + if [ $(ls *.java | wc -l) -eq "0" ]; then return fi diff -Nru upm-1.6.0/scripts/build-doc.sh upm-1.7.1/scripts/build-doc.sh --- upm-1.6.0/scripts/build-doc.sh 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/scripts/build-doc.sh 2018-10-12 04:47:41.000000000 +0000 @@ -22,10 +22,10 @@ cd ${ROOT_DIR} && make -j8 -Cbuild 2> ${BUILD_LOGS_DIR}/build-doc.log # Make Java Documentation -cd ${BUILD_DIR} && find ../src/ -name "javaupm_*.i" > upm.i.list && \ +cd ${BUILD_DIR} && find ../src/ -name "*.i" > upm.i.list && \ ../doxy/doxyport/doxyport upm.i.list \ --cmake ./compile_commands.json \ - --source ../src/interfaces/,../src/bacnetmstp \ + --source ../src/interfaces/,../src/bacnetmstp,src \ --destination src/ \ --convert-protected-to-private \ --output upm-java-files.txt \ diff -Nru upm-1.6.0/scripts/run-cmake.sh upm-1.7.1/scripts/run-cmake.sh --- upm-1.6.0/scripts/run-cmake.sh 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/scripts/run-cmake.sh 2018-10-12 04:47:41.000000000 +0000 @@ -12,6 +12,7 @@ -DBUILDSWIGPYTHON=$BUILDSWIGPYTHON \ -DBUILDSWIGNODE=$BUILDSWIGNODE \ -DBUILDSWIGJAVA=$BUILDSWIGJAVA \ + -DBUILDCORDOVA=$BUILDCORDOVA \ -DBUILDEXAMPLES=$BUILDEXAMPLES \ -DIPK=$IPK \ -DRPM=$RPM \ @@ -19,5 +20,6 @@ -DBUILDTESTS=$BUILDTESTS \ -DWERROR=$WERROR \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \ -H. \ -Bbuild diff -Nru upm-1.6.0/scripts/sonar-scan.sh upm-1.7.1/scripts/sonar-scan.sh --- upm-1.6.0/scripts/sonar-scan.sh 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/scripts/sonar-scan.sh 2018-10-12 04:47:41.000000000 +0000 @@ -53,8 +53,11 @@ -Dsonar.inclusions='CMakeLists.txt,examples/**/*,include/**/*,src/**/*,tests/**/*' \ -Dsonar.java.binaries='src' \ -Dsonar.coverage.exclusions='**/*' \ + -Dsonar.issue.ignore.multicriteria=r1 \ + -Dsonar.issue.ignore.multicriteria.r1.ruleKey=squid:S2189 \ + -Dsonar.issue.ignore.multicriteria.r1.resourceKey=**/*.java \ -Dsonar.cfamily.build-wrapper-output=${bw_output_path} \ - -Dsonar.host.url=https://sonarqube.com \ + -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.organization=${SONAR_ORG} \ -Dsonar.login=${SONAR_TOKEN} \ " diff -Nru upm-1.6.0/src/a110x/a110x.i upm-1.7.1/src/a110x/a110x.i --- upm-1.6.0/src/a110x/a110x.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/a110x/a110x.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +/* Macro for loading javaupm_a110x */ +JAVA_JNI_LOADLIBRARY(javaupm_a110x) + +/* Macro adding an installisr call w/JAVA runnable to A110X */ +JAVA_ADD_INSTALLISR(upm::A110X) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "a110x.hpp" +%} +%include "a110x.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/a110x/a110x.json upm-1.7.1/src/a110x/a110x.json --- upm-1.6.0/src/a110x/a110x.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/a110x/a110x.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,72 +1,72 @@ -{ - "Library": "a110x", - "Description": "A110X Hall Effect Library", - "Sensor Class": - { - "A110X": - { - "Name": "API for the A110X Hall Effect Sensors", - "Description": "UPM module for the A110X (A1101, A1102, A1103, A1104, and A1106) Hall Effect sensors. It outputs a digital signal indicating whether it is detecting a magnetic field with south polarity perpendicular to the sensor element.", - "Aliases": ["a1101", "a1102", "a1103", "a1104", "a1106"], - "Categories": ["halleffect"], - "Connections": ["gpio"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["seeed"], - "Kits": ["robok"], - "Image": "a110x.jpg", - "Examples": - { - "Java": ["A110XSample.java", "A110X_intrSample.java"], - "Python": ["a110x.py"], - "Node.js": ["a110x.js"], - "C++": ["a110x-intr.cxx", "a110x.cxx"], - "C": ["a110x.c"] - }, - "Specifications": - { - "Vcc": {"unit": "V", "low" : 3.8, "high": 24}, - "Ioutoff" : {"unit": "uA", "low" : 0.0, "high": 10}, - "Supply Current": {"unit": "mA", "low": 3.8, "high": 7.5}, - "a1101" : { - "Operate Point": {"unit": "G", "low": 50, "high": 160}, - "Release Point": {"unit": "G", "low": 10, "high": 130}, - "Hysteresis": {"unit": "G", "low": 20, "high": 80} - }, - "a1102" : { - "Operate Point": {"unit": "G", "low": 130, "high": 230}, - "Release Point": {"unit": "G", "low": 75, "high": 175}, - "Hysteresis": {"unit": "G", "low": 30, "high": 80} - }, - "a1103" : { - "Operate Point": {"unit": "G", "low": 220, "high": 340}, - "Release Point": {"unit": "G", "low": 165, "high": 285}, - "Hysteresis": {"unit": "G", "low": 30, "high": 80} - }, - "a1104" : { - "Operate Point": {"unit": "G", "low": 70, "high": 350}, - "Release Point": {"unit": "G", "low": 50, "high": 330}, - "Hysteresis": {"unit": "G", "low": 20} - }, - "a1106" : { - "Operate Point": {"unit": "G", "low": 280, "high": 400}, - "Release Point": {"unit": "G", "low": 180, "high": 300}, - "Hysteresis": {"unit": "G", "low": 70, "high": 140} - } - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/grove-hall-sensor-p-965.html"], - "Datasheets": ["http://www.allegromicro.com/en/Products/Part_Numbers/1101/1101.pdf"], - "Schematics": ["https://learn.adafruit.com/assets/26693"] - } - } - } -} +{ + "Library": "a110x", + "Description": "A110X Hall Effect Library", + "Sensor Class": + { + "A110X": + { + "Name": "API for the A110X Hall Effect Sensors", + "Description": "UPM module for the A110X (A1101, A1102, A1103, A1104, and A1106) Hall Effect sensors. It outputs a digital signal indicating whether it is detecting a magnetic field with south polarity perpendicular to the sensor element.", + "Aliases": ["a1101", "a1102", "a1103", "a1104", "a1106"], + "Categories": ["halleffect"], + "Connections": ["gpio"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["seeed"], + "Kits": ["robok"], + "Image": "a110x.jpg", + "Examples": + { + "Java": ["A110X_Example.java", "A110X_intr_Example.java"], + "Python": ["a110x.py"], + "Node.js": ["a110x.js"], + "C++": ["a110x-intr.cxx", "a110x.cxx"], + "C": ["a110x.c"] + }, + "Specifications": + { + "Vcc": {"unit": "V", "low" : 3.8, "high": 24}, + "Ioutoff" : {"unit": "uA", "low" : 0.0, "high": 10}, + "Supply Current": {"unit": "mA", "low": 3.8, "high": 7.5}, + "a1101" : { + "Operate Point": {"unit": "G", "low": 50, "high": 160}, + "Release Point": {"unit": "G", "low": 10, "high": 130}, + "Hysteresis": {"unit": "G", "low": 20, "high": 80} + }, + "a1102" : { + "Operate Point": {"unit": "G", "low": 130, "high": 230}, + "Release Point": {"unit": "G", "low": 75, "high": 175}, + "Hysteresis": {"unit": "G", "low": 30, "high": 80} + }, + "a1103" : { + "Operate Point": {"unit": "G", "low": 220, "high": 340}, + "Release Point": {"unit": "G", "low": 165, "high": 285}, + "Hysteresis": {"unit": "G", "low": 30, "high": 80} + }, + "a1104" : { + "Operate Point": {"unit": "G", "low": 70, "high": 350}, + "Release Point": {"unit": "G", "low": 50, "high": 330}, + "Hysteresis": {"unit": "G", "low": 20} + }, + "a1106" : { + "Operate Point": {"unit": "G", "low": 280, "high": 400}, + "Release Point": {"unit": "G", "low": 180, "high": 300}, + "Hysteresis": {"unit": "G", "low": 70, "high": 140} + } + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/grove-hall-sensor-p-965.html"], + "Datasheets": ["http://www.allegromicro.com/en/Products/Part_Numbers/1101/1101.pdf"], + "Schematics": ["https://learn.adafruit.com/assets/26693"] + } + } + } +} diff -Nru upm-1.6.0/src/a110x/common.i upm-1.7.1/src/a110x/common.i --- upm-1.6.0/src/a110x/common.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/a110x/common.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -%include "../upm.i" - -%{ -#include "a110x.hpp" -%} -%include "a110x.hpp" diff -Nru upm-1.6.0/src/a110x/javaupm_a110x.i upm-1.7.1/src/a110x/javaupm_a110x.i --- upm-1.6.0/src/a110x/javaupm_a110x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/a110x/javaupm_a110x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_a110x -%include "stdint.i" -%include "typemaps.i" - -%include "common.i" - -/* Macro for loading javaupm_a110x */ -JAVA_JNI_LOADLIBRARY(javaupm_a110x) - -/* Macro adding an installisr call w/JAVA runnable to A110X */ -JAVA_ADD_INSTALLISR(upm::A110X) diff -Nru upm-1.6.0/src/a110x/jsupm_a110x.i upm-1.7.1/src/a110x/jsupm_a110x.i --- upm-1.6.0/src/a110x/jsupm_a110x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/a110x/jsupm_a110x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -%module jsupm_a110x - -%include "common.i" diff -Nru upm-1.6.0/src/a110x/pyupm_a110x.i upm-1.7.1/src/a110x/pyupm_a110x.i --- upm-1.6.0/src/a110x/pyupm_a110x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/a110x/pyupm_a110x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -%include "pyupm_doxy2swig.i" -%module pyupm_a110x - -%include "common.i" diff -Nru upm-1.6.0/src/abp/abp.i upm-1.7.1/src/abp/abp.i --- upm-1.6.0/src/abp/abp.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/abp/abp.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_abp) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "abp.hpp" +%} +%include "abp.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/abp/javaupm_abp.i upm-1.7.1/src/abp/javaupm_abp.i --- upm-1.6.0/src/abp/javaupm_abp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/abp/javaupm_abp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_abp -%include "../upm.i" -%include "stdint.i" -%include "typemaps.i" - -%{ - #include "abp.hpp" -%} -%include "abp.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_abp) diff -Nru upm-1.6.0/src/abp/jsupm_abp.i upm-1.7.1/src/abp/jsupm_abp.i --- upm-1.6.0/src/abp/jsupm_abp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/abp/jsupm_abp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_abp -%include "../upm.i" - -%{ - #include "abp.hpp" -%} - -%include "abp.hpp" diff -Nru upm-1.6.0/src/abp/pyupm_abp.i upm-1.7.1/src/abp/pyupm_abp.i --- upm-1.6.0/src/abp/pyupm_abp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/abp/pyupm_abp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_abp -%include "../upm.i" - -%include "abp.hpp" -%{ - #include "abp.hpp" -%} diff -Nru upm-1.6.0/src/ad8232/ad8232.c upm-1.7.1/src/ad8232/ad8232.c --- upm-1.6.0/src/ad8232/ad8232.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ad8232/ad8232.c 2018-10-12 04:47:41.000000000 +0000 @@ -35,13 +35,9 @@ return NULL; } - dev->gpio_lo_plus_pin = lo_plus; - dev->gpio_lo_minus_pin = lo_minus; - dev->aio_pin = output; - - dev->aio = mraa_aio_init(dev->aio_pin); - dev->gpio_lo_plus = mraa_gpio_init(dev->gpio_lo_plus_pin); - dev->gpio_lo_minus = mraa_gpio_init(dev->gpio_lo_minus_pin); + dev->aio = mraa_aio_init(output); + dev->gpio_lo_plus = mraa_gpio_init(lo_plus); + dev->gpio_lo_minus = mraa_gpio_init(lo_minus); if (dev->aio == NULL || dev->gpio_lo_minus == NULL || dev->gpio_lo_plus == NULL){ diff -Nru upm-1.6.0/src/ad8232/ad8232.h upm-1.7.1/src/ad8232/ad8232.h --- upm-1.6.0/src/ad8232/ad8232.h 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ad8232/ad8232.h 2018-10-12 04:47:41.000000000 +0000 @@ -51,9 +51,6 @@ mraa_aio_context aio; mraa_gpio_context gpio_lo_plus; mraa_gpio_context gpio_lo_minus; - uint8_t aio_pin; - uint8_t gpio_lo_plus_pin; - uint8_t gpio_lo_minus_pin; int a_res; } *ad8232_context; diff -Nru upm-1.6.0/src/ad8232/ad8232.hpp upm-1.7.1/src/ad8232/ad8232.hpp --- upm-1.6.0/src/ad8232/ad8232.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ad8232/ad8232.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -65,8 +65,8 @@ * * @image html ad8232.jpg *
AD8232 Heart Rate Monitor image provided by SparkFun under - *
- * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet ad8232.cxx Interesting */ diff -Nru upm-1.6.0/src/ad8232/ad8232.json upm-1.7.1/src/ad8232/ad8232.json --- upm-1.6.0/src/ad8232/ad8232.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ad8232/ad8232.json 2018-10-12 04:47:41.000000000 +0000 @@ -16,7 +16,7 @@ "Image": "ad8232.jpg", "Examples": { - "Java": ["Ad8232Example.java"], + "Java": ["Ad8232_Example.java"], "Python": ["ad8232.py"], "Node.js": ["ad8232.js"], "C++": ["ad8232.cxx"] diff -Nru upm-1.6.0/src/ad8232/javaupm_ad8232.i upm-1.7.1/src/ad8232/javaupm_ad8232.i --- upm-1.6.0/src/ad8232/javaupm_ad8232.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ad8232/javaupm_ad8232.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_ad8232 -%include "../upm.i" - -%{ - #include "ad8232.hpp" -%} - -%include "ad8232.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ad8232) \ No newline at end of file diff -Nru upm-1.6.0/src/ad8232/jsupm_ad8232.i upm-1.7.1/src/ad8232/jsupm_ad8232.i --- upm-1.6.0/src/ad8232/jsupm_ad8232.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ad8232/jsupm_ad8232.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ad8232 -%include "../upm.i" - -%{ - #include "ad8232.hpp" -%} - -%include "ad8232.hpp" diff -Nru upm-1.6.0/src/ad8232/pyupm_ad8232.i upm-1.7.1/src/ad8232/pyupm_ad8232.i --- upm-1.6.0/src/ad8232/pyupm_ad8232.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ad8232/pyupm_ad8232.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ad8232 -%include "../upm.i" - -%include "ad8232.hpp" -%{ - #include "ad8232.hpp" -%} diff -Nru upm-1.6.0/src/adafruitms1438/adafruitms1438.json upm-1.7.1/src/adafruitms1438/adafruitms1438.json --- upm-1.6.0/src/adafruitms1438/adafruitms1438.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adafruitms1438/adafruitms1438.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,48 +1,48 @@ -{ - "Library": "adafruitms1438", - "Description": "Module for the Adafruit Motor Shield 1438", - "Sensor Class": - { - "AdafruitMS1438": - { - "Name": "API for the AdafruitMS1438 Motor Shield", - "Description": "This class implements support for the stepper and DC motors that can be connected to this Motor Shield.", - "Aliases": ["adafruitms1438"], - "Categories": ["motor"], - "Connections": ["i2c"], - "Project Type": ["motor"], - "Manufacturers": ["adafruit"], - "Kits": [], - "Image": "adafruitms1438.jpg", - "Examples": - { - "Java": [], - "Python": ["adafruitms1438-stepper.py", "adafruitms1438.py"], - "Node.js": ["adafruitms1438-stepper.js", "adafruitms1438.js"], - "C++": ["adafruitms1438-stepper.cxx", "adafruitms1438.cxx"], - "C": [] - }, - "Specifications": - { - "Vmotor": {"unit": "V", "low": 4.5, "high": 13.5}, - "Amotor": {"unit": "A", "high": 1.2}, - "Apeak": {"unit": "A", "high": 3}, - "Vlogic": {"unit": "V", "low": 3.3, "high": 5} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["The two servo connections are not controlled by the PCA9685 controller (or this class). They are connected directly to digital PWM pins 9 and 10 on the Arduino* breakout board."], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.adafruit.com/products/1438"], - "Datasheets": ["https://cdn-shop.adafruit.com/datasheets/TB6612FNG_datasheet_en_20121101.pdf"], - "Schematics": ["https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino"] - } - } - } -} +{ + "Library": "adafruitms1438", + "Description": "Module for the Adafruit Motor Shield 1438", + "Sensor Class": + { + "AdafruitMS1438": + { + "Name": "API for the AdafruitMS1438 Motor Shield", + "Description": "This class implements support for the stepper and DC motors that can be connected to this Motor Shield.", + "Aliases": ["adafruitms1438"], + "Categories": ["motor"], + "Connections": ["i2c"], + "Project Type": ["motor"], + "Manufacturers": ["adafruit"], + "Kits": [], + "Image": "adafruitms1438.jpg", + "Examples": + { + "Java": [], + "Python": ["adafruitms1438-stepper.py", "adafruitms1438.py"], + "Node.js": ["adafruitms1438-stepper.js", "adafruitms1438.js"], + "C++": ["adafruitms1438-stepper.cxx", "adafruitms1438.cxx"], + "C": [] + }, + "Specifications": + { + "Vmotor": {"unit": "V", "low": 4.5, "high": 13.5}, + "Amotor": {"unit": "A", "high": 1.2}, + "Apeak": {"unit": "A", "high": 3}, + "Vlogic": {"unit": "V", "low": 3.3, "high": 5} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["The two servo connections are not controlled by the PCA9685 controller (or this class). They are connected directly to digital PWM pins 9 and 10 on the Arduino* breakout board."], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.adafruit.com/products/1438"], + "Datasheets": ["https://cdn-shop.adafruit.com/datasheets/TB6612FNG_datasheet_en_20121101.pdf"], + "Schematics": ["https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino"] + } + } + } +} diff -Nru upm-1.6.0/src/adafruitms1438/javaupm_adafruitms1438.i upm-1.7.1/src/adafruitms1438/javaupm_adafruitms1438.i --- upm-1.6.0/src/adafruitms1438/javaupm_adafruitms1438.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adafruitms1438/javaupm_adafruitms1438.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_adafruitms1438 -%include "../upm.i" - -%{ - #include "adafruitms1438.hpp" -%} - -%include "adafruitms1438.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_adafruitms1438) \ No newline at end of file diff -Nru upm-1.6.0/src/adafruitms1438/jsupm_adafruitms1438.i upm-1.7.1/src/adafruitms1438/jsupm_adafruitms1438.i --- upm-1.6.0/src/adafruitms1438/jsupm_adafruitms1438.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adafruitms1438/jsupm_adafruitms1438.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_adafruitms1438 -%include "../upm.i" - -%{ - #include "adafruitms1438.hpp" -%} - -%include "adafruitms1438.hpp" diff -Nru upm-1.6.0/src/adafruitms1438/pyupm_adafruitms1438.i upm-1.7.1/src/adafruitms1438/pyupm_adafruitms1438.i --- upm-1.6.0/src/adafruitms1438/pyupm_adafruitms1438.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adafruitms1438/pyupm_adafruitms1438.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_adafruitms1438 -%include "../upm.i" - -%include "adafruitms1438.hpp" -%{ - #include "adafruitms1438.hpp" -%} diff -Nru upm-1.6.0/src/adafruitss/adafruitss.json upm-1.7.1/src/adafruitss/adafruitss.json --- upm-1.6.0/src/adafruitss/adafruitss.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adafruitss/adafruitss.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,47 +1,47 @@ -{ - "Library": "adafruitss", - "Description": "Adafruit Servo Shield", - "Sensor Class": - { - "adafruitss": - { - "Name": "Adafruit PCA9685-based Servo Shield library", - "Description": "UPM library for the PCA9685-based Adafruit 16-channel servo shield.", - "Aliases": ["adafruitss"], - "Categories": ["servos"], - "Connections": ["i2c"], - "Project Type": ["servos"], - "Manufacturers": ["adafruit"], - "Kits": [], - "Image": "adafruitss.jpg", - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["adafruitss.cxx"], - "C": [] - }, - "Specifications": - { - "Vmotor": {"unit": "v", "low": 0, "high": 6}, - "Vlogic": {"unit": "V", "low": 3.3, "high": 5}, - "PWM Frequency": {"unit": "KHz", "high": 1.6} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["If 3 or more GWS servos are attached, results could be unpredictable. Adafruit Industries recommend installing a capacitor on the board, which should alleviate the issue. Sizing depends on servos and their number."], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["http://www.adafruit.com/product/1411"], - "Datasheets": ["https://cdn-shop.adafruit.com/datasheets/PCA9685.pdf"], - "Schematics": ["https://learn.adafruit.com/assets/36081"] - } - } - } -} +{ + "Library": "adafruitss", + "Description": "Adafruit Servo Shield", + "Sensor Class": + { + "adafruitss": + { + "Name": "Adafruit PCA9685-based Servo Shield library", + "Description": "UPM library for the PCA9685-based Adafruit 16-channel servo shield.", + "Aliases": ["adafruitss"], + "Categories": ["servos"], + "Connections": ["i2c"], + "Project Type": ["servos"], + "Manufacturers": ["adafruit"], + "Kits": [], + "Image": "adafruitss.jpg", + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["adafruitss.cxx"], + "C": [] + }, + "Specifications": + { + "Vmotor": {"unit": "v", "low": 0, "high": 6}, + "Vlogic": {"unit": "V", "low": 3.3, "high": 5}, + "PWM Frequency": {"unit": "KHz", "high": 1.6} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["If 3 or more GWS servos are attached, results could be unpredictable. Adafruit Industries recommend installing a capacitor on the board, which should alleviate the issue. Sizing depends on servos and their number."], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["http://www.adafruit.com/product/1411"], + "Datasheets": ["https://cdn-shop.adafruit.com/datasheets/PCA9685.pdf"], + "Schematics": ["https://learn.adafruit.com/assets/36081"] + } + } + } +} diff -Nru upm-1.6.0/src/adafruitss/javaupm_adafruitss.i upm-1.7.1/src/adafruitss/javaupm_adafruitss.i --- upm-1.6.0/src/adafruitss/javaupm_adafruitss.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adafruitss/javaupm_adafruitss.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module javaupm_adafruitss -%include "../upm.i" - -%include "adafruitss.hpp" -%{ - #include "adafruitss.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_adafruitss) \ No newline at end of file diff -Nru upm-1.6.0/src/adafruitss/jsupm_adafruitss.i upm-1.7.1/src/adafruitss/jsupm_adafruitss.i --- upm-1.6.0/src/adafruitss/jsupm_adafruitss.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adafruitss/jsupm_adafruitss.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -%module jsupm_adafruitss -%include "../upm.i" - -%include "adafruitss.hpp" -%{ - #include "adafruitss.hpp" -%} diff -Nru upm-1.6.0/src/adafruitss/pyupm_adafruitss.i upm-1.7.1/src/adafruitss/pyupm_adafruitss.i --- upm-1.6.0/src/adafruitss/pyupm_adafruitss.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adafruitss/pyupm_adafruitss.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_adafruitss -%include "../upm.i" - -%include "adafruitss.hpp" -%{ - #include "adafruitss.hpp" -%} diff -Nru upm-1.6.0/src/adc121c021/adc121c021.i upm-1.7.1/src/adc121c021/adc121c021.i --- upm-1.6.0/src/adc121c021/adc121c021.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/adc121c021/adc121c021.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,20 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_adc121c021) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint16_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "adc121c021.hpp" +%} +%include "adc121c021.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/adc121c021/adc121c021.json upm-1.7.1/src/adc121c021/adc121c021.json --- upm-1.6.0/src/adc121c021/adc121c021.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adc121c021/adc121c021.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,47 +1,47 @@ -{ - "Library": "adc121c021", - "Description": "I2C 12-bit Analog to Digital Converter with Alert Pin", - "Sensor Class": - { - "ADC121C021": - { - "Name": "API for the ADC121C021 I2C Analog-to-Digital Converter", - "Description": "UPM module for the ADC121C021 12-bit analog-to-digital converter (ADC). By constantly providing a reference voltage, this sensor helps increase the accuracy of a value collected from an analog sensor.", - "Aliases": ["adc121c021"], - "Categories": ["aio"], - "Connections": ["i2c"], - "Project Type": ["prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "adc121c021.jpg", - "Examples": - { - "Java": ["ADC121C021Sample.java"], - "Python": ["adc121c021.py"], - "Node.js": ["adc121c021.js"], - "C++": ["adc121c021.cxx"], - "C": [] - }, - "Specifications": - { - "Working Voltage": {"unit": "v", "low" : 5.0, "high": 5.0}, - "Resolution" : {"unit": "Bit", "low" : 12, "high": 12}, - "Sample Rate": {"unit": "ksps", "low" : 188.9, "high": 188.9} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-I2C-ADC-p-1580.html"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-I2C_ADC/master/res/ADC121C021_Datasheet.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "adc121c021", + "Description": "I2C 12-bit Analog to Digital Converter with Alert Pin", + "Sensor Class": + { + "ADC121C021": + { + "Name": "API for the ADC121C021 I2C Analog-to-Digital Converter", + "Description": "UPM module for the ADC121C021 12-bit analog-to-digital converter (ADC). By constantly providing a reference voltage, this sensor helps increase the accuracy of a value collected from an analog sensor.", + "Aliases": ["adc121c021"], + "Categories": ["aio"], + "Connections": ["i2c"], + "Project Type": ["prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "adc121c021.jpg", + "Examples": + { + "Java": ["ADC121C021_Example.java"], + "Python": ["adc121c021.py"], + "Node.js": ["adc121c021.js"], + "C++": ["adc121c021.cxx"], + "C": [] + }, + "Specifications": + { + "Working Voltage": {"unit": "v", "low" : 5.0, "high": 5.0}, + "Resolution" : {"unit": "Bit", "low" : 12, "high": 12}, + "Sample Rate": {"unit": "ksps", "low" : 188.9, "high": 188.9} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-I2C-ADC-p-1580.html"], + "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-I2C_ADC/master/res/ADC121C021_Datasheet.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/adc121c021/javaupm_adc121c021.i upm-1.7.1/src/adc121c021/javaupm_adc121c021.i --- upm-1.6.0/src/adc121c021/javaupm_adc121c021.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adc121c021/javaupm_adc121c021.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_adc121c021 -%include "../upm.i" -/*%include "../carrays_uint16_t.i" -*/ -%{ - #include "adc121c021.hpp" -%} - -%include "adc121c021.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_adc121c021) \ No newline at end of file diff -Nru upm-1.6.0/src/adc121c021/jsupm_adc121c021.i upm-1.7.1/src/adc121c021/jsupm_adc121c021.i --- upm-1.6.0/src/adc121c021/jsupm_adc121c021.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adc121c021/jsupm_adc121c021.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_adc121c021 -%include "../upm.i" -%include "../carrays_uint16_t.i" - -%{ - #include "adc121c021.hpp" -%} - -%include "adc121c021.hpp" diff -Nru upm-1.6.0/src/adc121c021/pyupm_adc121c021.i upm-1.7.1/src/adc121c021/pyupm_adc121c021.i --- upm-1.6.0/src/adc121c021/pyupm_adc121c021.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adc121c021/pyupm_adc121c021.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_adc121c021 -%include "../upm.i" - -%include "adc121c021.hpp" -%{ - #include "adc121c021.hpp" -%} diff -Nru upm-1.6.0/src/adis16448/adis16448.json upm-1.7.1/src/adis16448/adis16448.json --- upm-1.6.0/src/adis16448/adis16448.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adis16448/adis16448.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,45 +1,45 @@ -{ - "Library": "adis16448", - "Description": "Industrial Grade Ten Degrees of Freedom Inertial Sensor", - "Sensor Class": - { - "ADIS16448": - { - "Name": "API for the Analog Devices ADIS16448 Accelerometer", - "Description": "This is an industrial-grade accelerometer by Analog Devices.", - "Aliases": ["adis16448"], - "Categories": ["imu"], - "Connections": ["spi"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["generic"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": ["adis16448.js"], - "C++": ["adis16448.cxx"], - "C": [] - }, - "Specifications": - { - "Working Voltage": {"unit": "v", "low": 3.15, "high": 3.45}, - "Working Current": {"unit": "mA", "low": 76, "high": 104} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["http://www.analog.com/en/products/sensors/inertial-measurement-units/adis16448.html"], - "Datasheets": ["http://www.analog.com/media/en/technical-documentation/data-sheets/ADIS16448.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "adis16448", + "Description": "Industrial Grade Ten Degrees of Freedom Inertial Sensor", + "Sensor Class": + { + "ADIS16448": + { + "Name": "API for the Analog Devices ADIS16448 Accelerometer", + "Description": "This is an industrial-grade accelerometer by Analog Devices.", + "Aliases": ["adis16448"], + "Categories": ["imu"], + "Connections": ["spi"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["generic"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": ["adis16448.js"], + "C++": ["adis16448.cxx"], + "C": [] + }, + "Specifications": + { + "Working Voltage": {"unit": "v", "low": 3.15, "high": 3.45}, + "Working Current": {"unit": "mA", "low": 76, "high": 104} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["http://www.analog.com/en/products/sensors/inertial-measurement-units/adis16448.html"], + "Datasheets": ["http://www.analog.com/media/en/technical-documentation/data-sheets/ADIS16448.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/adis16448/javaupm_adis16448.i upm-1.7.1/src/adis16448/javaupm_adis16448.i --- upm-1.6.0/src/adis16448/javaupm_adis16448.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adis16448/javaupm_adis16448.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_adis16448 -%include "../upm.i" - -%{ - #include "adis16448.hpp" -%} - -%include "adis16448.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_adis16448) \ No newline at end of file diff -Nru upm-1.6.0/src/adis16448/jsupm_adis16448.i upm-1.7.1/src/adis16448/jsupm_adis16448.i --- upm-1.6.0/src/adis16448/jsupm_adis16448.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adis16448/jsupm_adis16448.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_adis16448 -%include "../upm.i" - -%{ - #include "adis16448.hpp" -%} - -%include "adis16448.hpp" diff -Nru upm-1.6.0/src/adis16448/pyupm_adis16448.i upm-1.7.1/src/adis16448/pyupm_adis16448.i --- upm-1.6.0/src/adis16448/pyupm_adis16448.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adis16448/pyupm_adis16448.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_adis16448 -%include "../upm.i" - -%{ - #include "adis16448.hpp" -%} - -%include "adis16448.hpp" diff -Nru upm-1.6.0/src/ads1x15/ads1x15.i upm-1.7.1/src/ads1x15/ads1x15.i --- upm-1.6.0/src/ads1x15/ads1x15.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ads1x15/ads1x15.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,35 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%import "../interfaces/javaupm_iADC.i" +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} + +JAVA_JNI_LOADLIBRARY(javaupm_ads1x15) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "iModuleStatus.hpp" +%include "iADC.hpp" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "iModuleStatus.hpp" +%include "iADC.hpp" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ads1x15.hpp" +#include "ads1015.hpp" +#include "ads1115.hpp" +%} +%include "ads1x15.hpp" +%include "ads1115.hpp" +%include "ads1015.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ads1x15/ads1x15.json upm-1.7.1/src/ads1x15/ads1x15.json --- upm-1.6.0/src/ads1x15/ads1x15.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ads1x15/ads1x15.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,87 +1,87 @@ -{ - "Library": "ADS1x15", - "Description": "TI ADC Library", - "Sensor Class": - { - "ADS1015": - { - "Name": "12-bit ADC with Integrated MUX, PGA, Comparator, Oscillator, and Reference", - "Description": "The ADS1013, ADS1014, and ADS1015 are precision analog-to-digital converters (ADCs) with 12 bits of resolution offered in an ultra-small, leadless QFN-10 package or an MSOP-10 package. The ADS1013/4/5 are designed with precision, power, and ease of implementation in mind. The ADS1013/4/5 feature an onboard reference and oscillator. Data is transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1013/4/5 operate from a single power supply ranging from 2.0V to 5.5V. The ADS1013/4/5 can perform conversions at rates up to 3300 samples per second (SPS). An onboard PGA is available on the ADS1014 and ADS1015 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small signals to be measured with high resolution. The ADS1015 also features an input multiplexer (MUX) that provides two differential or four single-ended inputs. The ADS1013/4/5 operate either in continuous conversion mode or a single-shot mode that automatically powers down after a conversion and greatly reduces current consumption during idle periods. The ADS1013/4/5 are specified from -40 deg C to +125 deg C. Tested with Adafriut ADS1015 board.", - "Aliases": ["ads1015"], - "Categories": ["electric"], - "Connections": ["i2c"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["ti", "adafruit", "seeed", "sparkfun"], - "Image": "ads1015.jpg", - "Examples": - { - "Java": ["Ads1015Sample.java"], - "Python": ["ads1015.py"], - "Node.js": ["ads1115.js", "ads1x15.js"], - "C++": ["ads1x15-adc-sensor.cxx", "ads1x15-ads1015.cxx", "ads1x15.cxx"] - }, - "Specifications": - { - "Vdd": {"unit": "v", "low" : 2.0, "high": 5.5}, - "Data Rate":{"unit": "sps", "low": 128, "high": 3300}, - "I (continuous mode)" : {"unit": "uA", "typical": 150}, - "I2C Addresses": {"unit": "address", "low": "0x48", "high": "0x4B"} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["On SeeedStudio Grove Shield for Intel Joule"] - }, - "Intel Edison Module": - { - "Notes": ["On SparkFun Block for Intel Edison - ADC"] - } - }, - "Urls" : - { - "Product Pages": ["https://www.adafruit.com/product/1083", "http://wiki.seeed.cc/Grove_Shield_for_Intel_Joule/", "https://www.sparkfun.com/products/13770"], - "Datasheets": ["http://www.ti.com/lit/ds/symlink/ads1015.pdf"], - "Schematics": ["https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/signal-connections"] - } - }, - "ADS1115": - { - "Name": "16-bit ADC with Integrated MUX, PGA, Comparator, Oscillator, and Reference", - "Description": "The ADS1113, ADS1114, and ADS1115 are precision analog-to-digital converters (ADCs) with 16 bits of resolution offered in an ultra-small, leadless QFN-10 package or an MSOP-10 package. The ADS1113/4/5 are designed with precision, power, and ease of implementation in mind. The ADS1113/4/5 feature an onboard reference and oscillator. Data is transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1113/4/5 operate from a single power supply ranging from 2.0V to 5.5V. The ADS1113/4/5 can perform conversions at rates up to 860 samples per second (SPS). An onboard PGA is available on the ADS1114 and ADS1115 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small signals to be measured with high resolution. The ADS1115 also features an input multiplexer (MUX) that provides two differential or four single-ended inputs. The ADS1113/4/5 operate either in continuous conversion mode or a single-shot mode that automatically powers down after a conversion and greatly reduces current consumption during idle periods. The ADS1113/4/5 are specified from -40 deg C to +125 deg C. Tested with DIYMall ADS1115 board.", - "Aliases": ["ads1115"], - "Categories": ["electric"], - "Connections": ["i2c"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["ti", "adafruit", "dfrobot"], - "Image": "ads1115.jpg", - "Examples": - { - "Java": ["Ads1115Sample.java"], - "Python": ["ads1115.py"], - "Node.js": ["ads1115.js", "ads1x15.js"], - "C++": ["ads1x15-adc-sensor.cxx", "ads1x15-ads1115.cxx", "ads1x15.cxx"] - }, - "Specifications": - { - "Vdd": {"unit": "v", "low" : 2.0, "high": 5.5}, - "Data Rate":{"unit": "sps", "low": 8, "high": 860}, - "I (continuous mode)" : {"unit": "uA", "typical": 150}, - "I2C Addresses": {"unit": "address", "low": "0x48", "high": "0x4B"} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["On DFRobot Gravity Expansion Shield for Intel Joule"] - } - }, - "Urls" : - { - "Product Pages": ["https://www.adafruit.com/product/1085", "https://www.dfrobot.com/product-1560.html"], - "Datasheets": ["http://www.ti.com/lit/ds/symlink/ads1115.pdf"], - "Schematics": ["https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/signal-connections"] - } - } - } -} +{ + "Library": "ADS1x15", + "Description": "TI ADC Library", + "Sensor Class": + { + "ADS1015": + { + "Name": "12-bit ADC with Integrated MUX, PGA, Comparator, Oscillator, and Reference", + "Description": "The ADS1013, ADS1014, and ADS1015 are precision analog-to-digital converters (ADCs) with 12 bits of resolution offered in an ultra-small, leadless QFN-10 package or an MSOP-10 package. The ADS1013/4/5 are designed with precision, power, and ease of implementation in mind. The ADS1013/4/5 feature an onboard reference and oscillator. Data is transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1013/4/5 operate from a single power supply ranging from 2.0V to 5.5V. The ADS1013/4/5 can perform conversions at rates up to 3300 samples per second (SPS). An onboard PGA is available on the ADS1014 and ADS1015 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small signals to be measured with high resolution. The ADS1015 also features an input multiplexer (MUX) that provides two differential or four single-ended inputs. The ADS1013/4/5 operate either in continuous conversion mode or a single-shot mode that automatically powers down after a conversion and greatly reduces current consumption during idle periods. The ADS1013/4/5 are specified from -40 deg C to +125 deg C. Tested with Adafriut ADS1015 board.", + "Aliases": ["ads1015"], + "Categories": ["electric"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["ti", "adafruit", "seeed", "sparkfun"], + "Image": "ads1015.jpg", + "Examples": + { + "Java": ["Ads1015_Example.java"], + "Python": ["ads1015.py"], + "Node.js": ["ads1115.js", "ads1x15.js"], + "C++": ["ads1x15-adc-sensor.cxx", "ads1x15-ads1015.cxx", "ads1x15.cxx"] + }, + "Specifications": + { + "Vdd": {"unit": "v", "low" : 2.0, "high": 5.5}, + "Data Rate":{"unit": "sps", "low": 128, "high": 3300}, + "I (continuous mode)" : {"unit": "uA", "typical": 150}, + "I2C Addresses": {"unit": "address", "low": "0x48", "high": "0x4B"} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["On SeeedStudio Grove Shield for Intel Joule"] + }, + "Intel Edison Module": + { + "Notes": ["On SparkFun Block for Intel Edison - ADC"] + } + }, + "Urls" : + { + "Product Pages": ["https://www.adafruit.com/product/1083", "http://wiki.seeed.cc/Grove_Shield_for_Intel_Joule/", "https://www.sparkfun.com/products/13770"], + "Datasheets": ["http://www.ti.com/lit/ds/symlink/ads1015.pdf"], + "Schematics": ["https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/signal-connections"] + } + }, + "ADS1115": + { + "Name": "16-bit ADC with Integrated MUX, PGA, Comparator, Oscillator, and Reference", + "Description": "The ADS1113, ADS1114, and ADS1115 are precision analog-to-digital converters (ADCs) with 16 bits of resolution offered in an ultra-small, leadless QFN-10 package or an MSOP-10 package. The ADS1113/4/5 are designed with precision, power, and ease of implementation in mind. The ADS1113/4/5 feature an onboard reference and oscillator. Data is transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1113/4/5 operate from a single power supply ranging from 2.0V to 5.5V. The ADS1113/4/5 can perform conversions at rates up to 860 samples per second (SPS). An onboard PGA is available on the ADS1114 and ADS1115 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small signals to be measured with high resolution. The ADS1115 also features an input multiplexer (MUX) that provides two differential or four single-ended inputs. The ADS1113/4/5 operate either in continuous conversion mode or a single-shot mode that automatically powers down after a conversion and greatly reduces current consumption during idle periods. The ADS1113/4/5 are specified from -40 deg C to +125 deg C. Tested with DIYMall ADS1115 board.", + "Aliases": ["ads1115"], + "Categories": ["electric"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["ti", "adafruit", "dfrobot"], + "Image": "ads1115.jpg", + "Examples": + { + "Java": ["Ads1115_Example.java"], + "Python": ["ads1115.py"], + "Node.js": ["ads1115.js", "ads1x15.js"], + "C++": ["ads1x15-adc-sensor.cxx", "ads1x15-ads1115.cxx", "ads1x15.cxx"] + }, + "Specifications": + { + "Vdd": {"unit": "v", "low" : 2.0, "high": 5.5}, + "Data Rate":{"unit": "sps", "low": 8, "high": 860}, + "I (continuous mode)" : {"unit": "uA", "typical": 150}, + "I2C Addresses": {"unit": "address", "low": "0x48", "high": "0x4B"} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["On DFRobot Gravity Expansion Shield for Intel Joule"] + } + }, + "Urls" : + { + "Product Pages": ["https://www.adafruit.com/product/1085", "https://www.dfrobot.com/product-1560.html"], + "Datasheets": ["http://www.ti.com/lit/ds/symlink/ads1115.pdf"], + "Schematics": ["https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/signal-connections"] + } + } + } +} diff -Nru upm-1.6.0/src/ads1x15/javaupm_ads1x15.i upm-1.7.1/src/ads1x15/javaupm_ads1x15.i --- upm-1.6.0/src/ads1x15/javaupm_ads1x15.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ads1x15/javaupm_ads1x15.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -%module javaupm_ads1x15 -%include "../upm.i" -%include "typemaps.i" - -%import "../interfaces/javaupm_iADC.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%{ - #include "ads1x15.hpp" - #include "ads1015.hpp" - #include "ads1115.hpp" -%} - -%include "ads1x15.hpp" -%include "ads1015.hpp" -%include "ads1115.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ads1x15) diff -Nru upm-1.6.0/src/ads1x15/jsupm_ads1x15.i upm-1.7.1/src/ads1x15/jsupm_ads1x15.i --- upm-1.6.0/src/ads1x15/jsupm_ads1x15.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ads1x15/jsupm_ads1x15.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -%module jsupm_ads1x15 -%include "../upm.i" - -%include "iModuleStatus.hpp" -%include "iADC.hpp" - -%include "ads1x15.hpp" -%{ - #include "ads1x15.hpp" -%} - -%include "ads1015.hpp" -%{ - #include "ads1015.hpp" -%} - -%include "ads1115.hpp" -%{ - #include "ads1115.hpp" -%} diff -Nru upm-1.6.0/src/ads1x15/pyupm_ads1x15.i upm-1.7.1/src/ads1x15/pyupm_ads1x15.i --- upm-1.6.0/src/ads1x15/pyupm_ads1x15.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ads1x15/pyupm_ads1x15.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ads1x15 -%include "../upm.i" - -%include "iModuleStatus.hpp" -%include "iADC.hpp" - -%include "ads1x15.hpp" -%{ - #include "ads1x15.hpp" -%} - -%include "ads1015.hpp" -%{ - #include "ads1015.hpp" -%} - -%include "ads1115.hpp" -%{ - #include "ads1115.hpp" -%} diff -Nru upm-1.6.0/src/adxl335/adxl335.i upm-1.7.1/src/adxl335/adxl335.i --- upm-1.6.0/src/adxl335/adxl335.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/adxl335/adxl335.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,61 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%apply int *OUTPUT { int *xVal, int *yVal, int *zVal }; +%apply float *OUTPUT { float *xAccel, float *yAccel, float *zAccel }; + +%typemap(jni) float* "jfloatArray" +%typemap(jstype) float* "float[]" +%typemap(jtype) float* "float[]" + +%typemap(javaout) float* { + return $jnicall; +} + +%typemap(out) float *acceleration { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); +} + +%typemap(jni) int* "jintArray" +%typemap(jstype) int* "int[]" +%typemap(jtype) int* "int[]" + +%typemap(javaout) int* { + return $jnicall; +} + +%typemap(out) int *values { + $result = JCALL1(NewIntArray, jenv, 3); + JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const signed int*)$1); + delete [] $1; +} + +%ignore values(int *, int *, int *); +%ignore acceleration(float *, float *, float *); + +JAVA_JNI_LOADLIBRARY(javaupm_adxl335) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "adxl335.hpp" +%} +%include "adxl335.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/adxl335/adxl335.json upm-1.7.1/src/adxl335/adxl335.json --- upm-1.6.0/src/adxl335/adxl335.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxl335/adxl335.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,46 +1,46 @@ -{ - "Library": "adxl335", - "Description": "Low-power, 3-axis +/- 3 g Accelerometer", - "Sensor Class": - { - "ADXL335": - { - "Name": "API for the Analog Devices ADIS16448 Accelerometer", - "Description": "UPM module for the ADXL335 3-axis analog accelerometer. This was tested on a Grove 3-axis Analog Accelerometer. It uses 3 analog pins, one for each axis: X, Y, and Z.", - "Aliases": ["adxl335"], - "Categories": ["imu", "accelerometers"], - "Connections": ["analog"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "adxl335.jpg", - "Examples": - { - "Java": [], - "Python": ["adxl335.py"], - "Node.js": ["adxl335.js"], - "C++": ["adxl335.cxx"], - "C": [] - }, - "Specifications": - { - "Working Voltage": {"unit": "v", "low": 1.8, "high": 3.6}, - "Working Current": {"unit": "uA", "low": 350, "high": 350} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["http://www.analog.com/en/products/mems/accelerometers/adxl335.html"], - "Datasheets": ["http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL335.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "adxl335", + "Description": "Low-power, 3-axis +/- 3 g Accelerometer", + "Sensor Class": + { + "ADXL335": + { + "Name": "API for the Analog Devices ADIS16448 Accelerometer", + "Description": "UPM module for the ADXL335 3-axis analog accelerometer. This was tested on a Grove 3-axis Analog Accelerometer. It uses 3 analog pins, one for each axis: X, Y, and Z.", + "Aliases": ["adxl335"], + "Categories": ["imu", "accelerometers"], + "Connections": ["analog"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "adxl335.jpg", + "Examples": + { + "Java": [], + "Python": ["adxl335.py"], + "Node.js": ["adxl335.js"], + "C++": ["adxl335.cxx"], + "C": [] + }, + "Specifications": + { + "Working Voltage": {"unit": "v", "low": 1.8, "high": 3.6}, + "Working Current": {"unit": "uA", "low": 350, "high": 350} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["http://www.analog.com/en/products/mems/accelerometers/adxl335.html"], + "Datasheets": ["http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL335.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/adxl335/javaupm_adxl335.i upm-1.7.1/src/adxl335/javaupm_adxl335.i --- upm-1.6.0/src/adxl335/javaupm_adxl335.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxl335/javaupm_adxl335.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -%module javaupm_adxl335 -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" - -%apply int *OUTPUT { int *xVal, int *yVal, int *zVal }; -%apply float *OUTPUT { float *xAccel, float *yAccel, float *zAccel }; - -%{ - #include "adxl335.hpp" -%} - -%typemap(jni) float* "jfloatArray" -%typemap(jstype) float* "float[]" -%typemap(jtype) float* "float[]" - -%typemap(javaout) float* { - return $jnicall; -} - -%typemap(out) float *acceleration { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); -} - -%typemap(jni) int* "jintArray" -%typemap(jstype) int* "int[]" -%typemap(jtype) int* "int[]" - -%typemap(javaout) int* { - return $jnicall; -} - -%typemap(out) int *values { - $result = JCALL1(NewIntArray, jenv, 3); - JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const signed int*)$1); - delete [] $1; -} - -%ignore values(int *, int *, int *); -%ignore acceleration(float *, float *, float *); - -%include "adxl335.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_adxl335) \ No newline at end of file diff -Nru upm-1.6.0/src/adxl335/jsupm_adxl335.i upm-1.7.1/src/adxl335/jsupm_adxl335.i --- upm-1.6.0/src/adxl335/jsupm_adxl335.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxl335/jsupm_adxl335.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module jsupm_adxl335 -%include "../upm.i" -%include "cpointer.i" - -%pointer_functions(int, intPointer); -%pointer_functions(float, floatPointer); - -%{ - #include "adxl335.hpp" -%} - -%include "adxl335.hpp" diff -Nru upm-1.6.0/src/adxl335/pyupm_adxl335.i upm-1.7.1/src/adxl335/pyupm_adxl335.i --- upm-1.6.0/src/adxl335/pyupm_adxl335.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxl335/pyupm_adxl335.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_adxl335 -%include "../upm.i" -%include "cpointer.i" - -%pointer_functions(int, intPointer); -%pointer_functions(float, floatPointer); - -%include "adxl335.hpp" -%{ - #include "adxl335.hpp" -%} diff -Nru upm-1.6.0/src/adxl345/adxl345.i upm-1.7.1/src/adxl345/adxl345.i --- upm-1.6.0/src/adxl345/adxl345.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/adxl345/adxl345.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,73 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%typemap(jni) float* "jfloatArray" +%typemap(jstype) float* "float[]" +%typemap(jtype) float* "float[]" + +%typemap(javaout) float* { + return $jnicall; +} + +%typemap(out) float * { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); +} + +%typemap(jni) int16_t* "jshortArray" +%typemap(jstype) int16_t* "short[]" +%typemap(jtype) int16_t* "short[]" + +%typemap(javaout) int16_t* { + return $jnicall; +} + +%typemap(out) int16_t *getRawValues { + $result = JCALL1(NewShortArray, jenv, 3); + JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); + delete [] $1; +} + +JAVA_JNI_LOADLIBRARY(javaupm_adxl345) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_int16_t.i" +%include "../carrays_float.i" + +%typemap(out) int16_t * { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} + +%typemap(out) float * { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 ); +} + +%include +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_int16_t.i" +%include "../carrays_float.i" + +%typemap(out) int16_t * { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} + +%typemap(out) float * { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 ); +} +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "adxl345.hpp" +%} +%include "adxl345.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/adxl345/adxl345.json upm-1.7.1/src/adxl345/adxl345.json --- upm-1.6.0/src/adxl345/adxl345.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxl345/adxl345.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,46 +1,46 @@ -{ - "Library": "adxl345", - "Description": "3-axis, +/- 2/4/8/16 g Digital Accelerometer", - "Sensor Class": - { - "Adxl345": - { - "Name": "API for the ADXL345 3-Axis Digital Accelerometer", - "Description": "ADXL345 is a 3-axis digital accelerometer. The sensor has configurable resolutions to measure +/- 2g, +/- 4g, +/- 8g, or +/- 16g.", - "Aliases": ["adxl335"], - "Categories": ["imu", "accelerometers"], - "Connections": ["i2c"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "adxl335.jpg", - "Examples": - { - "Java": [], - "Python": ["adxl345.py"], - "Node.js": ["adxl345.js"], - "C++": ["adxl345.cxx"], - "C": [] - }, - "Specifications": - { - "Working Voltage": {"unit": "v", "low": 2, "high": 3.6}, - "Working Current": {"unit": "uA", "low": 30, "high": 140} - }, - "Platforms": - { - "Intel Edison": - { - "Notes": ["The Grove* version of the sensor is incompatible with and not detected on the I2C bus by the Intel(R) Edison using an Arduino* breakout board at 5V (3V works fine)."], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["http://www.analog.com/en/products/mems/accelerometers/adxl345.html"], - "Datasheets": ["http://www.seeedstudio.com/wiki/images/2/2c/ADXL345_datasheet.pdf", "http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "adxl345", + "Description": "3-axis, +/- 2/4/8/16 g Digital Accelerometer", + "Sensor Class": + { + "Adxl345": + { + "Name": "API for the ADXL345 3-Axis Digital Accelerometer", + "Description": "ADXL345 is a 3-axis digital accelerometer. The sensor has configurable resolutions to measure +/- 2g, +/- 4g, +/- 8g, or +/- 16g.", + "Aliases": ["adxl335"], + "Categories": ["imu", "accelerometers"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "adxl335.jpg", + "Examples": + { + "Java": [], + "Python": ["adxl345.py"], + "Node.js": ["adxl345.js"], + "C++": ["adxl345.cxx"], + "C": [] + }, + "Specifications": + { + "Working Voltage": {"unit": "v", "low": 2, "high": 3.6}, + "Working Current": {"unit": "uA", "low": 30, "high": 140} + }, + "Platforms": + { + "Intel Edison": + { + "Notes": ["The Grove* version of the sensor is incompatible with and not detected on the I2C bus by the Intel(R) Edison using an Arduino* breakout board at 5V (3V works fine)."], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["http://www.analog.com/en/products/mems/accelerometers/adxl345.html"], + "Datasheets": ["http://www.seeedstudio.com/wiki/images/2/2c/ADXL345_datasheet.pdf", "http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/adxl345/javaupm_adxl345.i upm-1.7.1/src/adxl345/javaupm_adxl345.i --- upm-1.6.0/src/adxl345/javaupm_adxl345.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxl345/javaupm_adxl345.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -%module javaupm_adxl345 -%include "../upm.i" - -%{ - #include "adxl345.hpp" -%} - -%typemap(jni) float* "jfloatArray" -%typemap(jstype) float* "float[]" -%typemap(jtype) float* "float[]" - -%typemap(javaout) float* { - return $jnicall; -} - -%typemap(out) float * { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); -} - - -%typemap(jni) int16_t* "jshortArray" -%typemap(jstype) int16_t* "short[]" -%typemap(jtype) int16_t* "short[]" - -%typemap(javaout) int16_t* { - return $jnicall; -} - -%typemap(out) int16_t *getRawValues { - $result = JCALL1(NewShortArray, jenv, 3); - JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); - delete [] $1; -} - -%include "adxl345.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_adxl345) \ No newline at end of file diff -Nru upm-1.6.0/src/adxl345/jsupm_adxl345.i upm-1.7.1/src/adxl345/jsupm_adxl345.i --- upm-1.6.0/src/adxl345/jsupm_adxl345.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxl345/jsupm_adxl345.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -%module jsupm_adxl345 -%include "../upm.i" -%include "../carrays_int16_t.i" -%include "../carrays_float.i" - -%{ - #include "adxl345.hpp" -%} - -%typemap(out) int16_t * { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%typemap(out) float * { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 ); -} - -%include "adxl345.hpp" - -%include diff -Nru upm-1.6.0/src/adxl345/pyupm_adxl345.i upm-1.7.1/src/adxl345/pyupm_adxl345.i --- upm-1.6.0/src/adxl345/pyupm_adxl345.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxl345/pyupm_adxl345.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_adxl345 -%include "../upm.i" -%include "../carrays_int16_t.i" -%include "../carrays_float.i" - -%typemap(out) int16_t * { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%typemap(out) float * { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 ); -} - -%include "adxl345.hpp" -%{ - #include "adxl345.hpp" -%} diff -Nru upm-1.6.0/src/adxrs610/adxrs610.json upm-1.7.1/src/adxrs610/adxrs610.json --- upm-1.6.0/src/adxrs610/adxrs610.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxrs610/adxrs610.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,46 +1,46 @@ -{ - "Library": "adxrs610", - "Description": "Gyro Breakout Board (300 Degrees/second)", - "Sensor Class": - { - "ADXRS610": - { - "Name": "DFRobot ADXRS610 Gyro Breakout Board", - "Description": "The ADXRS610 is a MEMS based single axis gyroscope with a range of +/- 300 degrees/sec. It also incorporates a temperature sensing unit that can be used for advanced calibration. This sensor returns an analog voltage proportional to the rotation about the Z-axis in degrees/sec. The temperature component returns a proportional analog values in degrees C. This driver was developed using the DFRobot ADXRS610 Gyro Beakout board.", - "Aliases": ["adxrs610"], - "Categories": ["imu", "gyroscope"], - "Connections": ["analog"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["dfrobot"], - "Kits": [], - "Image": "adxrs610.jpg", - "Examples": - { - "Java": [], - "Python": ["adxrs610.py"], - "Node.js": ["adxrs610.js"], - "C++": ["adxrs610.cxx"], - "C": [] - }, - "Specifications": - { - "Vdd": {"unit": "v", "low" : 5.0, "high": 5.0}, - "Quiescent Current": {"unit": "mA", "low": 3.5, "high": 4.5} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/product-642.html"], - "Datasheets": ["http://image.dfrobot.com/image/data/SEN0070/ADXRS610%20datasheet_EN.pdf"], - "Schematics": ["http://image.dfrobot.com/image/data/SEN0070/ADXRS610_Gyro_Breakout.pdf"] - } - } - } -} +{ + "Library": "adxrs610", + "Description": "Gyro Breakout Board (300 Degrees/second)", + "Sensor Class": + { + "ADXRS610": + { + "Name": "DFRobot ADXRS610 Gyro Breakout Board", + "Description": "The ADXRS610 is a MEMS based single axis gyroscope with a range of +/- 300 degrees/sec. It also incorporates a temperature sensing unit that can be used for advanced calibration. This sensor returns an analog voltage proportional to the rotation about the Z-axis in degrees/sec. The temperature component returns a proportional analog values in degrees C. This driver was developed using the DFRobot ADXRS610 Gyro Beakout board.", + "Aliases": ["adxrs610"], + "Categories": ["imu", "gyroscope"], + "Connections": ["analog"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["dfrobot"], + "Kits": [], + "Image": "adxrs610.jpg", + "Examples": + { + "Java": [], + "Python": ["adxrs610.py"], + "Node.js": ["adxrs610.js"], + "C++": ["adxrs610.cxx"], + "C": [] + }, + "Specifications": + { + "Vdd": {"unit": "v", "low" : 5.0, "high": 5.0}, + "Quiescent Current": {"unit": "mA", "low": 3.5, "high": 4.5} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/product-642.html"], + "Datasheets": ["http://image.dfrobot.com/image/data/SEN0070/ADXRS610%20datasheet_EN.pdf"], + "Schematics": ["http://image.dfrobot.com/image/data/SEN0070/ADXRS610_Gyro_Breakout.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/adxrs610/javaupm_adxrs610.i upm-1.7.1/src/adxrs610/javaupm_adxrs610.i --- upm-1.6.0/src/adxrs610/javaupm_adxrs610.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxrs610/javaupm_adxrs610.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_adxrs610 -%include "../upm.i" - -%{ - #include "adxrs610.hpp" -%} - -%include "adxrs610.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_adxrs610) \ No newline at end of file diff -Nru upm-1.6.0/src/adxrs610/jsupm_adxrs610.i upm-1.7.1/src/adxrs610/jsupm_adxrs610.i --- upm-1.6.0/src/adxrs610/jsupm_adxrs610.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxrs610/jsupm_adxrs610.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_adxrs610 -%include "../upm.i" - -%{ - #include "adxrs610.hpp" -%} - -%include "adxrs610.hpp" diff -Nru upm-1.6.0/src/adxrs610/pyupm_adxrs610.i upm-1.7.1/src/adxrs610/pyupm_adxrs610.i --- upm-1.6.0/src/adxrs610/pyupm_adxrs610.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/adxrs610/pyupm_adxrs610.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_adxrs610 -%include "../upm.i" - -%include "adxrs610.hpp" -%{ - #include "adxrs610.hpp" -%} diff -Nru upm-1.6.0/src/am2315/am2315.json upm-1.7.1/src/am2315/am2315.json --- upm-1.6.0/src/am2315/am2315.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/am2315/am2315.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,47 +1,47 @@ -{ - "Library": "am2315", - "Description": "Digital Temperature and Humidity Sensor", - "Sensor Class": - { - "AM2315": - { - "Name": "API for the AM2315 Temperature & Humidity Sensor", - "Description": "The AM2315 is a digital humidity sensor with temperature output. RH reports between 0 and 100%, and the temperature range is -40 to +125 degC. The sampling period of this sensor is 2 seconds. Reads occurring more often than that return cached data.", - "Aliases": ["am2315"], - "Categories": ["humidity", "temperature"], - "Connections": ["i2c"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["adafruit"], - "Kits": [], - "Examples": - { - "Java": ["AM2315Example.java"], - "Python": [], - "Node.js": [], - "C++": ["am2315.cxx"], - "C": [] - }, - "Specifications": - { - "Vcc": {"unit": "v", "low" : 3.5, "high": 5.5}, - "Current Draw": {"unit": "mA", "low": 0.0, "high": 10}, - "Temperature Sensor Range": {"unit": "degC", "low": -20, "high": 80}, - "Humidity Sensor Range": {"unit": "%", "low": 0, "high": 100} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["http://www.adafruit.com/products/1293"], - "Datasheets": ["https://cdn-shop.adafruit.com/datasheets/AM2315.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "am2315", + "Description": "Digital Temperature and Humidity Sensor", + "Sensor Class": + { + "AM2315": + { + "Name": "API for the AM2315 Temperature & Humidity Sensor", + "Description": "The AM2315 is a digital humidity sensor with temperature output. RH reports between 0 and 100%, and the temperature range is -40 to +125 degC. The sampling period of this sensor is 2 seconds. Reads occurring more often than that return cached data.", + "Aliases": ["am2315"], + "Categories": ["humidity", "temperature"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["adafruit"], + "Kits": [], + "Examples": + { + "Java": ["AM2315_Example.java"], + "Python": [], + "Node.js": [], + "C++": ["am2315.cxx"], + "C": [] + }, + "Specifications": + { + "Vcc": {"unit": "v", "low" : 3.5, "high": 5.5}, + "Current Draw": {"unit": "mA", "low": 0.0, "high": 10}, + "Temperature Sensor Range": {"unit": "degC", "low": -20, "high": 80}, + "Humidity Sensor Range": {"unit": "%", "low": 0, "high": 100} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["http://www.adafruit.com/products/1293"], + "Datasheets": ["https://cdn-shop.adafruit.com/datasheets/AM2315.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/am2315/javaupm_am2315.i upm-1.7.1/src/am2315/javaupm_am2315.i --- upm-1.6.0/src/am2315/javaupm_am2315.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/am2315/javaupm_am2315.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_am2315 -%include "../upm.i" - -%{ - #include "am2315.hpp" -%} - -%include "am2315.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_am2315) \ No newline at end of file diff -Nru upm-1.6.0/src/am2315/jsupm_am2315.i upm-1.7.1/src/am2315/jsupm_am2315.i --- upm-1.6.0/src/am2315/jsupm_am2315.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/am2315/jsupm_am2315.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_am2315 -%include "../upm.i" - -%{ - #include "am2315.hpp" -%} - -%include "am2315.hpp" diff -Nru upm-1.6.0/src/am2315/pyupm_am2315.i upm-1.7.1/src/am2315/pyupm_am2315.i --- upm-1.6.0/src/am2315/pyupm_am2315.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/am2315/pyupm_am2315.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_am2315 -%include "../upm.i" - -%include "am2315.hpp" -%{ - #include "am2315.hpp" -%} diff -Nru upm-1.6.0/src/apa102/apa102.i upm-1.7.1/src/apa102/apa102.i --- upm-1.6.0/src/apa102/apa102.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/apa102/apa102.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,52 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%typemap(jtype) (uint8_t *colors) "byte[]" +%typemap(jstype) (uint8_t *colors) "byte[]" +%typemap(jni) (uint8_t *colors) "jbyteArray" +%typemap(javain) (uint8_t *colors) "$javainput" + +%typemap(in) (uint8_t *colors) { + $1 = (uint8_t*)JCALL2(GetByteArrayElements, jenv, $input, NULL); +} + +JAVA_JNI_LOADLIBRARY(javaupm_apa102) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%inline %{ + #include +%} + +%typemap(in) (uint8_t *colors) { + if (!node::Buffer::HasInstance($input)) { + SWIG_exception_fail(SWIG_ERROR, "Expected a node Buffer"); + } + $1 = (uint8_t*) node::Buffer::Data($input); +} +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +// setLeds +%typemap(in) (uint8_t *colors) { + if (PyByteArray_Check($input)) { + $1 = (uint8_t*) PyByteArray_AsString($input); + } else { + PyErr_SetString(PyExc_ValueError, "bytearray expected"); + return NULL; + } +} +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "apa102.hpp" +%} +%include "apa102.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/apa102/apa102.json upm-1.7.1/src/apa102/apa102.json --- upm-1.6.0/src/apa102/apa102.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apa102/apa102.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Shiji Lighting", "Adafruit"], "Image": "apa102.jpg", "Examples": { - "Java": ["APA102Sample.java"], + "Java": ["APA102_Example.java"], "Python": ["apa102.py"], "Node.js": ["apa102.js"], "C++": ["apa102.cxx"] diff -Nru upm-1.6.0/src/apa102/javaupm_apa102.i upm-1.7.1/src/apa102/javaupm_apa102.i --- upm-1.6.0/src/apa102/javaupm_apa102.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apa102/javaupm_apa102.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -%module javaupm_apa102 - -%include "../upm.i" -%include "typemaps.i" - -%typemap(jtype) (uint8_t *colors) "byte[]" -%typemap(jstype) (uint8_t *colors) "byte[]" -%typemap(jni) (uint8_t *colors) "jbyteArray" -%typemap(javain) (uint8_t *colors) "$javainput" - -%typemap(in) (uint8_t *colors) { - $1 = (uint8_t*)JCALL2(GetByteArrayElements, jenv, $input, NULL); -} - -%{ - #include "apa102.hpp" -%} - -%include "apa102.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_apa102) diff -Nru upm-1.6.0/src/apa102/jsupm_apa102.i upm-1.7.1/src/apa102/jsupm_apa102.i --- upm-1.6.0/src/apa102/jsupm_apa102.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apa102/jsupm_apa102.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -%module jsupm_apa102 - -%include "../upm.i" -%inline %{ - #include -%} - -%typemap(in) (uint8_t *colors) { - if (!node::Buffer::HasInstance($input)) { - SWIG_exception_fail(SWIG_ERROR, "Expected a node Buffer"); - } - $1 = (uint8_t*) node::Buffer::Data($input); -} - -%include "apa102.hpp" - -%{ - #include "apa102.hpp" -%} diff -Nru upm-1.6.0/src/apa102/pyupm_apa102.i upm-1.7.1/src/apa102/pyupm_apa102.i --- upm-1.6.0/src/apa102/pyupm_apa102.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apa102/pyupm_apa102.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%module pyupm_apa102 - -%include "../upm.i" - -// setLeds -%typemap(in) (uint8_t *colors) { - if (PyByteArray_Check($input)) { - $1 = (uint8_t*) PyByteArray_AsString($input); - } else { - PyErr_SetString(PyExc_ValueError, "bytearray expected"); - return NULL; - } -} - -%include "apa102.hpp" - -%{ - - #include "apa102.hpp" -%} diff -Nru upm-1.6.0/src/apds9002/apds9002.json upm-1.7.1/src/apds9002/apds9002.json --- upm-1.6.0/src/apds9002/apds9002.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apds9002/apds9002.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Avago", "Seeed"], "Image": "apds9002.jpg", "Examples": { - "Java": ["Apds9002.java"], + "Java": ["Apds9002_Example.java"], "Python": ["apds9002.py"], "Node.js": ["apds9002.js"], "C++": ["apds9002.cxx"] diff -Nru upm-1.6.0/src/apds9002/javaupm_apds9002.i upm-1.7.1/src/apds9002/javaupm_apds9002.i --- upm-1.6.0/src/apds9002/javaupm_apds9002.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apds9002/javaupm_apds9002.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_apds9002 -%include "../upm.i" - -%{ - #include "apds9002.hpp" -%} - -%include "apds9002.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_apds9002) \ No newline at end of file diff -Nru upm-1.6.0/src/apds9002/jsupm_apds9002.i upm-1.7.1/src/apds9002/jsupm_apds9002.i --- upm-1.6.0/src/apds9002/jsupm_apds9002.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apds9002/jsupm_apds9002.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_apds9002 -%include "../upm.i" - -%{ - #include "apds9002.hpp" -%} - -%include "apds9002.hpp" diff -Nru upm-1.6.0/src/apds9002/pyupm_apds9002.i upm-1.7.1/src/apds9002/pyupm_apds9002.i --- upm-1.6.0/src/apds9002/pyupm_apds9002.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apds9002/pyupm_apds9002.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_apds9002 -%include "../upm.i" - -%include "apds9002.hpp" -%{ - #include "apds9002.hpp" -%} diff -Nru upm-1.6.0/src/apds9930/javaupm_apds9930.i upm-1.7.1/src/apds9930/javaupm_apds9930.i --- upm-1.6.0/src/apds9930/javaupm_apds9930.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apds9930/javaupm_apds9930.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module javaupm_apds9930 -%include "../upm.i" - -%{ - #include "apds9930.hpp" -%} -%include "apds9930.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_apds9930) diff -Nru upm-1.6.0/src/apds9930/jsupm_apds9930.i upm-1.7.1/src/apds9930/jsupm_apds9930.i --- upm-1.6.0/src/apds9930/jsupm_apds9930.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apds9930/jsupm_apds9930.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_apds9930 -%include "../upm.i" - -%{ - #include "apds9930.hpp" -%} - -%include "apds9930.hpp" diff -Nru upm-1.6.0/src/apds9930/pyupm_apds9930.i upm-1.7.1/src/apds9930/pyupm_apds9930.i --- upm-1.6.0/src/apds9930/pyupm_apds9930.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/apds9930/pyupm_apds9930.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module pyupm_apds9930 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%include "apds9930.hpp" -%{ - #include "apds9930.hpp" -%} diff -Nru upm-1.6.0/src/at42qt1070/javaupm_at42qt1070.i upm-1.7.1/src/at42qt1070/javaupm_at42qt1070.i --- upm-1.6.0/src/at42qt1070/javaupm_at42qt1070.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/at42qt1070/javaupm_at42qt1070.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_at42qt1070 -%include "../upm.i" - -%{ - #include "at42qt1070.hpp" -%} - -%include "at42qt1070.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_at42qt1070) \ No newline at end of file diff -Nru upm-1.6.0/src/at42qt1070/jsupm_at42qt1070.i upm-1.7.1/src/at42qt1070/jsupm_at42qt1070.i --- upm-1.6.0/src/at42qt1070/jsupm_at42qt1070.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/at42qt1070/jsupm_at42qt1070.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_at42qt1070 -%include "../upm.i" - -%{ - #include "at42qt1070.hpp" -%} - -%include "at42qt1070.hpp" diff -Nru upm-1.6.0/src/at42qt1070/pyupm_at42qt1070.i upm-1.7.1/src/at42qt1070/pyupm_at42qt1070.i --- upm-1.6.0/src/at42qt1070/pyupm_at42qt1070.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/at42qt1070/pyupm_at42qt1070.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_at42qt1070 -%include "../upm.i" - -%include "at42qt1070.hpp" -%{ - #include "at42qt1070.hpp" -%} diff -Nru upm-1.6.0/src/bacnetmstp/bacnetmstp.i upm-1.7.1/src/bacnetmstp/bacnetmstp.i --- upm-1.6.0/src/bacnetmstp/bacnetmstp.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bacnetmstp/bacnetmstp.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../carrays_uint32_t.i" +JAVA_JNI_LOADLIBRARY(javaupm_bacnetmstp) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(float, floatp); +%{ +#include "bacnetmstp.hpp" +%} +%include "bacnetmstp.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bacnetmstp/javaupm_bacnetmstp.i upm-1.7.1/src/bacnetmstp/javaupm_bacnetmstp.i --- upm-1.6.0/src/bacnetmstp/javaupm_bacnetmstp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bacnetmstp/javaupm_bacnetmstp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module javaupm_bacnetmstp -%include "../upm.i" -%include "typemaps.i" -%include "../carrays_uint32_t.i" - -%{ - #include "bacnetmstp.hpp" - #include "bacnetutil.hpp" -%} - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_bacnetmstp) diff -Nru upm-1.6.0/src/bacnetmstp/jsupm_bacnetmstp.i upm-1.7.1/src/bacnetmstp/jsupm_bacnetmstp.i --- upm-1.6.0/src/bacnetmstp/jsupm_bacnetmstp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bacnetmstp/jsupm_bacnetmstp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module jsupm_bacnetmstp -%include "../upm.i" -%include "stdint.i" -%include "cpointer.i" - -%pointer_functions(float, floatp); - -%include "bacnetmstp.hpp" -%{ - #include "bacnetmstp.hpp" -%} diff -Nru upm-1.6.0/src/bacnetmstp/pyupm_bacnetmstp.i upm-1.7.1/src/bacnetmstp/pyupm_bacnetmstp.i --- upm-1.6.0/src/bacnetmstp/pyupm_bacnetmstp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bacnetmstp/pyupm_bacnetmstp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bacnetmstp -%include "../upm.i" -%include "stdint.i" -%include "cpointer.i" - -%pointer_functions(float, floatp); - -%include "bacnetmstp.hpp" -%{ - #include "bacnetmstp.hpp" -%} diff -Nru upm-1.6.0/src/bh1749/bh1749.c upm-1.7.1/src/bh1749/bh1749.c --- upm-1.6.0/src/bh1749/bh1749.c 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1749/bh1749.c 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,702 @@ +/* +* 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 +#include "bh1749.h" + +#define DEFAULT_OP_MODE INT_JUDGE_1 +#define DEFAULT_MEAS_TIME MEAS_240MS +#define DEFAULT_RGB_GAIN RGB_GAIN_1X +#define DEFAULT_IR_GAIN IR_GAIN_1X +#define DEFAULT_INT_SOURCE RED +#define DEFUALT_THRESHOLD_HIGH 511 + +/** + * @brief Reads the value of a register + * + * @param dev The sensor context + * @param reg Register address + * @param data Pointer of uint8_t to save register value + * @return UPM result + */ +static upm_result_t bh1749_read_register(bh1749_context dev, uint8_t reg, uint8_t *data) +{ + uint8_t value = mraa_i2c_read_byte_data(dev->i2c, reg); + if(value < 0) { + printf("%s: mraa_i2c_read_byte_data() failed\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + *data = value; + return UPM_SUCCESS; +} + +/** + * @brief Reads the values of a set of registers + * + * @param dev The sensor context + * @param reg Register address + * @param data Pointer of uint8_t to save registers values + * @return UPM result + */ +static upm_result_t bh1749_read_registers(bh1749_context dev, uint8_t reg, uint8_t *data, uint8_t len) +{ + uint8_t value; + + for(int i = 0; i < len; i++) { + if(bh1749_read_register(dev, reg + i, &value) != UPM_SUCCESS) { + return UPM_ERROR_OPERATION_FAILED; + } + + *(data + i) = value; + } + + return UPM_SUCCESS; +} + +/** + * @brief Writes a value to a register + * + * @param dev The sensor context + * @param value Value to write + * @param reg Register address + * @return UPM result + */ +static upm_result_t bh1749_write_register(bh1749_context dev, uint8_t value, uint8_t reg) +{ + if (mraa_i2c_write_byte_data(dev->i2c, value, reg) != MRAA_SUCCESS) { + printf("%s: mraa_i2c_write_byte_data() failed\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + return UPM_SUCCESS; +} + +/** + * @brief Sets a bit on in a register with a bit mask + * + * @param dev The sensor context + * @param reg Register address + * @param bit_mask Mask to use + * @return UPM result + */ +static upm_result_t bh1749_set_bit_on(bh1749_context dev, uint8_t reg, uint8_t bit_mask) +{ + uint8_t reg_value; + int status; + + status = bh1749_read_register(dev, reg, ®_value); + if(status < 0) { + printf("%s: Failed to read register 0x%2X\n", __FUNCTION__, reg); + return UPM_ERROR_OPERATION_FAILED; + } + + reg_value |= bit_mask; + return bh1749_write_register(dev, reg_value, reg); +} + +/** + * @brief Sets a bit off in a register with a bit mask + * + * @param dev The sensor context + * @param reg Register address + * @param bit_mask Mask to use + * @return UPM result + */ +static upm_result_t bh1749_set_bit_off(bh1749_context dev, uint8_t reg, uint8_t bit_mask) +{ + uint8_t reg_value; + int status; + + status = bh1749_read_register(dev, reg, ®_value); + if(status < 0) { + printf("%s: Failed to read register 0x%2X\n", __FUNCTION__, reg); + return UPM_ERROR_OPERATION_FAILED; + } + + reg_value &= ~bit_mask; + return bh1749_write_register(dev, reg_value, reg); +} + +/** + * @brief Sets the value of a register as a given pattern with a bit mask + * + * @param dev The sensor context + * @param reg Register address + * @param value Value to write + * @param bit_mask Mask to use + * @return UPM result + */ +static upm_result_t bh1749_set_bits_with_mask(bh1749_context dev, uint8_t reg, uint8_t value, uint8_t bit_mask) +{ + uint8_t reg_value; + int status; + + status = bh1749_read_register(dev, reg, ®_value); + if(status < 0) { + printf("%s: Failed to read register 0x%2X\n", __FUNCTION__, reg); + return UPM_ERROR_OPERATION_FAILED; + } + + reg_value &= ~bit_mask; + reg_value |= value; + return bh1749_write_register(dev, reg_value, reg); +} + +upm_result_t bh1749_check_who_am_i(bh1749_context dev) +{ + uint8_t partId; + if(bh1749_read_register(dev, BH1749_SYSTEM_CONTROL, &partId) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + partId &= BH1749_SYSTEM_CONTROL_PART_MASK; + if(partId != BH1749_SYSTEM_CONTROL_PART_ID) { + printf("%s: wrong manufacturer ID\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + return UPM_SUCCESS; +} + +bh1749_context bh1749_init(int bus, int addr) +{ + bh1749_context dev = (bh1749_context)malloc(sizeof(struct _bh1749_context)); + if (!dev) + return NULL; + + dev->i2c = NULL; + dev->interrupt = NULL; + + if (mraa_init() != MRAA_SUCCESS) { + printf("%s: mraa_init() failed.\n", __FUNCTION__); + bh1749_close(dev); + return NULL; + } + + if (!(dev->i2c = mraa_i2c_init(bus))) { + printf("%s: mraa_i2c_init() failed.\n", __FUNCTION__); + bh1749_close(dev); + return NULL; + } + + if (mraa_i2c_address(dev->i2c, addr)) { + printf("%s: mraa_i2c_address() failed.\n", __FUNCTION__); + bh1749_close(dev); + return NULL; + } + + if(bh1749_check_who_am_i(dev) != UPM_SUCCESS) + return NULL; + + dev->enabled = false; + dev->isrEnabled = false; + if(bh1749_sensor_init(dev, DEFAULT_OP_MODE, DEFAULT_MEAS_TIME, + DEFAULT_RGB_GAIN, DEFAULT_IR_GAIN, DEFAULT_INT_SOURCE) != UPM_SUCCESS) + return NULL; + bh1749_set_threshold_high(dev, DEFUALT_THRESHOLD_HIGH); + + return dev; +} + +void bh1749_close(bh1749_context dev) +{ + if(dev->isrEnabled) + bh1749_remove_isr(dev); + + if (dev->i2c) + mraa_i2c_stop(dev->i2c); + + free(dev); +} + +upm_result_t bh1749_enable(bh1749_context dev) +{ + int status; + + status = bh1749_set_bit_on(dev, BH1749_MODE_CONTROL2, + BH1749_MODE_CONTROL2_RGB_MEASUREMENT_MASK); + if(status != UPM_SUCCESS) { + printf("%s: Failed to bh1749_enable RGB measurement\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + dev->enabled = true; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_disable(bh1749_context dev) +{ + int status; + + status = bh1749_set_bit_off(dev, BH1749_MODE_CONTROL2, + BH1749_MODE_CONTROL2_RGB_MEASUREMENT_MASK); + if(status != UPM_SUCCESS) { + printf("%s: Failed to bh1749_disable RGB measurement\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + dev->enabled = false; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_sensor_init(bh1749_context dev, OPERATING_MODES opMode, + MEAS_TIMES measTime, + RGB_GAINS rgbGain, + IR_GAINS irGain, + INT_SOURCES intSource) +{ + if(bh1749_set_operating_mode(dev, opMode) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + if(bh1749_set_measurement_time(dev, measTime) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + if(bh1749_set_rgb_gain(dev, rgbGain) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + if(bh1749_set_ir_gain(dev, irGain) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + return bh1749_set_int_source(dev, intSource); +} + +upm_result_t bh1749_set_operating_mode(bh1749_context dev, OPERATING_MODES opMode) +{ + if(bh1749_write_register(dev, opMode, BH1749_PERSISTENCE) != UPM_SUCCESS) { + printf("%s: Setting operating mode failed\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + dev->operating_mode = opMode; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_operating_mode(bh1749_context dev, uint8_t *opMode) +{ + uint8_t value; + + if(bh1749_read_register(dev, BH1749_PERSISTENCE, &value) != UPM_SUCCESS) { + printf("%s: Failed to read operating mode\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + value &= BH1749_PERSISTENCE_MODE_MASK; + if(value != INT_JUDGE_0 && value != INT_JUDGE_1 && + value != INT_JUDGE_4 && value != INT_JUDGE_4) { + printf("%s: Returned invalid mode\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + *opMode = value; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_set_measurement_time(bh1749_context dev, MEAS_TIMES measTime) +{ + if(bh1749_set_bits_with_mask(dev, BH1749_MODE_CONTROL1, measTime, + BH1749_MODE_CONTROL1_ODR_MASK) != UPM_SUCCESS) { + printf("%s: Failed setting measurement time\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + dev->meas_time = measTime; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_measurement_time(bh1749_context dev, uint8_t *meas_time) +{ + uint8_t time_reg; + + if(bh1749_read_register(dev, BH1749_MODE_CONTROL1, &time_reg) != UPM_SUCCESS) { + printf("%s: Failed to read measurement time\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + time_reg &= BH1749_MODE_CONTROL1_ODR_MASK; + if(time_reg == MEAS_35MS) + *meas_time = 35; + else if(time_reg == MEAS_120MS) + *meas_time = 120; + else if(time_reg == MEAS_240MS) + *meas_time = 240; + else { + printf("%s: Returned invalid time\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + return UPM_SUCCESS; +} + +upm_result_t bh1749_set_rgb_gain(bh1749_context dev, RGB_GAINS rgbGain) +{ + if(bh1749_set_bits_with_mask(dev, BH1749_MODE_CONTROL1, rgbGain, + BH1749_MODE_CONTROL1_RGB_GAIN_MASK) != UPM_SUCCESS) { + printf("%s: Failed setting RGB gain\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + dev->rgb_gain = rgbGain; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_rgb_gain(bh1749_context dev, uint8_t *gain) +{ + uint8_t rgb_gain; + + if(bh1749_read_register(dev, BH1749_MODE_CONTROL1, &rgb_gain) != UPM_SUCCESS) { + printf("%s: Failed to read rgb gain\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + rgb_gain &= BH1749_MODE_CONTROL1_RGB_GAIN_MASK; + if(rgb_gain == RGB_GAIN_1X) + *gain = 1; + else if(rgb_gain == RGB_GAIN_32X) + *gain = 32; + else { + printf("%s: Returned invalid gain\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + return UPM_SUCCESS; +} + +upm_result_t bh1749_set_ir_gain(bh1749_context dev, IR_GAINS irGain) +{ + if(bh1749_set_bits_with_mask(dev, BH1749_MODE_CONTROL1, irGain, + BH1749_MODE_CONTROL1_IR_GAIN_MASK) != UPM_SUCCESS) { + printf("%s: Failed setting IR gain\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + dev->ir_gain = irGain; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_ir_gain(bh1749_context dev, uint8_t *gain) +{ + uint8_t ir_gain; + + if(bh1749_read_register(dev, BH1749_MODE_CONTROL1, &ir_gain) != UPM_SUCCESS) { + printf("%s: Failed to read rgb gain\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + ir_gain &= BH1749_MODE_CONTROL1_IR_GAIN_MASK; + if(ir_gain == IR_GAIN_1X) + *gain = 1; + else if(ir_gain == IR_GAIN_32X) + *gain = 32; + else { + printf("%s: Returned invalid gain\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + return UPM_SUCCESS; +} + +upm_result_t bh1749_set_int_source(bh1749_context dev, INT_SOURCES intSource) +{ + if(bh1749_set_bits_with_mask(dev, BH1749_INTERRUPT, intSource, + BH1749_INTERRUPT_SOURCE_MASK) != UPM_SUCCESS) { + printf("%s: Failed setting interrupt source gain\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + dev->int_src = intSource; + + return UPM_SUCCESS; +} + +char bh1749_get_interrupt_source_char(bh1749_context dev) +{ + char intSourceChar = ' '; + uint8_t intSource; + + if(bh1749_read_register(dev, BH1749_INTERRUPT, &intSource) != UPM_SUCCESS) { + printf("%s: Failed to read interrupt source\n", __FUNCTION__); + return intSourceChar; + } + + intSource &= BH1749_INTERRUPT_SOURCE_MASK; + if(intSource == RED) + intSourceChar = 'r'; + else if(intSource == GREEN) + intSourceChar = 'g'; + else if(intSource == BLUE) + intSourceChar = 'b'; + else { + printf("%s: Returned invalid interrupt source\n", __FUNCTION__); + return intSourceChar; + } + + return intSourceChar; +} + +upm_result_t bh1749_enable_interrupt(bh1749_context dev) +{ + if(bh1749_set_bit_on(dev, BH1749_INTERRUPT, BH1749_INTERRUPT_EN_MASK) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + return bh1749_reset_interrupt(dev); +} + +upm_result_t bh1749_disable_interrupt(bh1749_context dev) +{ + return bh1749_set_bit_off(dev, BH1749_INTERRUPT, BH1749_INTERRUPT_EN_MASK); +} + +upm_result_t bh1749_reset_interrupt(bh1749_context dev) +{ + return bh1749_set_bit_on(dev, BH1749_SYSTEM_CONTROL, BH1749_SYSTEM_CONTROL_INT_RESET); +} + +bool bh1749_is_interrupted(bh1749_context dev) +{ + uint8_t intStatus; + + if(bh1749_read_register(dev, BH1749_INTERRUPT, &intStatus) != UPM_SUCCESS) { + printf("%s: Failed to read interrupt status\n", __FUNCTION__); + return false; + } + + intStatus &= BH1749_INTERRUPT_STATUS_MASK; + if(intStatus != BH1749_INTERRUPT_STATUS_ACTIVE) + return false; + + return true; +} + +bool bh1749_is_interrupt_enabled(bh1749_context dev) +{ + uint8_t intStatus; + + if(bh1749_read_register(dev, BH1749_INTERRUPT, &intStatus) != UPM_SUCCESS) { + printf("%s: Failed to read interrupt enabled\n", __FUNCTION__); + return false; + } + + intStatus &= BH1749_INTERRUPT_EN_MASK; + if(intStatus != BH1749_INTERRUPT_EN_ENABLE) + return false; + + return true; +} + +upm_result_t bh1749_soft_reset(bh1749_context dev) +{ + return bh1749_set_bit_on(dev, BH1749_SYSTEM_CONTROL, BH1749_SYSTEM_CONTROL_SW_RESET_MASK); +} + +upm_result_t bh1749_set_threshold_high(bh1749_context dev, uint16_t threshold) +{ + if(bh1749_write_register(dev, threshold, BH1749_TH_LSBS) != UPM_SUCCESS || + bh1749_write_register(dev, threshold >> 8, BH1749_TH_MSBS) != UPM_SUCCESS) { + printf("%s: Failed to write high threshold\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + dev->int_thh = threshold; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_threshold_high(bh1749_context dev, uint16_t *threshold) +{ + uint8_t data[2]; + + if(bh1749_read_register(dev, BH1749_TH_MSBS, &data[0]) || + bh1749_read_register(dev, BH1749_TH_LSBS, &data[1]) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *threshold = data[0] << 8 | data[1]; + return UPM_SUCCESS; +} + +upm_result_t bh1749_set_threshold_low(bh1749_context dev, uint16_t threshold) +{ + if(bh1749_write_register(dev, threshold, BH1749_TL_LSBS) != UPM_SUCCESS || + bh1749_write_register(dev, threshold >> 8, BH1749_TL_MSBS) != UPM_SUCCESS) { + printf("%s: Failed to write low threshold\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + dev->int_thl = threshold; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_threshold_low(bh1749_context dev, uint16_t *threshold) +{ + + uint8_t data[2]; + + if(bh1749_read_register(dev, BH1749_TL_MSBS, &data[0]) || + bh1749_read_register(dev, BH1749_TL_LSBS, &data[1]) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *threshold = data[0] << 8 | data[1]; + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_red(bh1749_context dev, uint16_t *red) +{ + uint8_t data[2]; + + if(bh1749_read_register(dev, BH1749_RED_DATA_MSBS, &data[0]) != UPM_SUCCESS || + bh1749_read_register(dev, BH1749_RED_DATA_LSBS, &data[1]) != UPM_SUCCESS) + return -UPM_ERROR_OPERATION_FAILED; + + *red = data[0] << 8 | data[1]; + + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_green(bh1749_context dev, uint16_t *green) +{ + uint8_t data[2]; + + if(bh1749_read_register(dev, BH1749_GREEN_DATA_MSBS, &data[0]) != UPM_SUCCESS || + bh1749_read_register(dev, BH1749_GREEN_DATA_LSBS, &data[1]) != UPM_SUCCESS) + return -UPM_ERROR_OPERATION_FAILED; + + *green = data[0] << 8 | data[1]; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_blue(bh1749_context dev, uint16_t *blue) +{ + uint8_t data[2]; + + if(bh1749_read_register(dev, BH1749_BLUE_DATA_MSBS, &data[0]) != UPM_SUCCESS || + bh1749_read_register(dev, BH1749_BLUE_DATA_LSBS, &data[1]) != UPM_SUCCESS) + return -UPM_ERROR_OPERATION_FAILED; + + *blue = data[0] << 8 | data[1]; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_ir(bh1749_context dev, uint16_t *ir) +{ + uint8_t data[2]; + + if(bh1749_read_register(dev, BH1749_IR_DATA_MSBS, &data[0]) != UPM_SUCCESS || + bh1749_read_register(dev, BH1749_IR_DATA_LSBS, &data[1]) != UPM_SUCCESS) + return -UPM_ERROR_OPERATION_FAILED; + + *ir = data[0] << 8 | data[1]; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_green2(bh1749_context dev, uint16_t *green2) +{ + uint8_t data[2]; + + if(bh1749_read_register(dev, BH1749_GREEN2_DATA_MSBS, &data[0]) != UPM_SUCCESS || + bh1749_read_register(dev, BH1749_GREEN2_DATA_LSBS, &data[1]) != UPM_SUCCESS) + return -UPM_ERROR_OPERATION_FAILED; + + *green2 = data[0] << 8 | data[1]; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_get_measurements(bh1749_context dev, uint16_t *result) +{ + uint16_t value; + int step = 0; + + if(bh1749_get_red(dev, &value) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + *(result + step++) = value; + if(bh1749_get_green(dev, &value) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + *(result + step++) = value; + if(bh1749_get_blue(dev, &value) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + *(result + step++) = value; + if(bh1749_get_ir(dev, &value) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + *(result + step++) = value; + if(bh1749_get_green2(dev, &value) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + *(result + step++) = value; + + return UPM_SUCCESS; +} + +upm_result_t bh1749_install_isr(bh1749_context dev, mraa_gpio_edge_t edge, int pin, + void (*isr)(void *), void *isr_args) +{ + if(dev->isrEnabled) + bh1749_remove_isr(dev); + + mraa_gpio_context isr_gpio = NULL; + + if (!(isr_gpio = mraa_gpio_init(pin))) { + printf("%s: mraa_gpio_init() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + mraa_gpio_dir(isr_gpio, MRAA_GPIO_IN); + + if (mraa_gpio_isr(isr_gpio, edge, isr, isr_args) != MRAA_SUCCESS) { + mraa_gpio_close(isr_gpio); + printf("%s: mraa_gpio_isr() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + dev->interrupt = isr_gpio; + dev->isrEnabled = true; + + return UPM_SUCCESS; +} + +void bh1749_remove_isr(bh1749_context dev) +{ + mraa_gpio_isr_exit(dev->interrupt); + mraa_gpio_close(dev->interrupt); + dev->interrupt = NULL; + dev->isrEnabled = false; +} + +upm_result_t bh1749_registers_dump(bh1749_context dev, char *dump) +{ + uint8_t reg_values[10]; + int count = 0; + int len = 3; + + if(bh1749_read_registers(dev, BH1749_SYSTEM_CONTROL, reg_values, len) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + count += snprintf(dump, 6, "0x40 "); + for(int i = 0; i < len; i++) + count += snprintf(dump + count, 4, "%02X ", reg_values[i]); + snprintf(dump + count - 1, 3, "\n"); + + len = 6; + if(bh1749_read_registers(dev, BH1749_INTERRUPT, reg_values, len) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + count += snprintf(dump + count, 6, "0x60 "); + for(int i = 0; i < len; i++) + count += snprintf(dump + count, 4, "%02X ", reg_values[i]); + + return UPM_SUCCESS; +} diff -Nru upm-1.6.0/src/bh1749/bh1749.cxx upm-1.7.1/src/bh1749/bh1749.cxx --- upm-1.6.0/src/bh1749/bh1749.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1749/bh1749.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,304 @@ +/* +* 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 +#include +#include +#include "bh1749.hpp" + +using namespace upm; + +void BH1749::CheckWhoAmI() +{ + if(bh1749_check_who_am_i(m_bh1749) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_check_who_am_i() failed"); +} + +BH1749::BH1749(int bus, int addr) : m_bh1749(bh1749_init(bus, addr)) +{ + if(!m_bh1749) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_init() failed"); +} + +BH1749::~BH1749() +{ + bh1749_close(m_bh1749); +} + +void BH1749::Enable() +{ + if(bh1749_enable(m_bh1749) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_enable() failed"); +} + +void BH1749::Disable() +{ + if(bh1749_disable(m_bh1749) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_disable() failed"); +} + +void BH1749::SensorInit(OPERATING_MODES opMode, + MEAS_TIMES measTime, + RGB_GAINS rgbGain, + IR_GAINS irGain, + INT_SOURCES intSource) +{ + if(bh1749_sensor_init(m_bh1749, opMode, measTime, rgbGain, irGain, intSource) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_sensor_init() failed"); +} + +void BH1749::SetOperatingMode(OPERATING_MODES opMode) +{ + if(bh1749_set_operating_mode(m_bh1749, opMode) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_set_operating_mode() failed"); +} + +int BH1749::GetOperatingMode() +{ + uint8_t opMode; + if(bh1749_get_operating_mode(m_bh1749, &opMode) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_operating_mode() failed"); + return opMode; +} + +void BH1749::SetMeasurementTime(MEAS_TIMES measTime) +{ + if(bh1749_set_measurement_time(m_bh1749, measTime) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_set_measurement_time() failed"); +} + +int BH1749::GetMeasurementTime() +{ + uint8_t measTime; + if(bh1749_get_measurement_time(m_bh1749, &measTime) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_measurement_time() failed"); + return measTime; +} + +void BH1749::SetRgbGain(RGB_GAINS rgbGain) +{ + if(bh1749_set_rgb_gain(m_bh1749, rgbGain) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_set_rgb_gain() failed"); +} + +int BH1749::GetRgbGain() +{ + uint8_t rgbGain; + if(bh1749_get_rgb_gain(m_bh1749, &rgbGain) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_rgb_gain() failed"); + return rgbGain; +} + +void BH1749::SetIrGain(IR_GAINS irGain) +{ + if(bh1749_set_ir_gain(m_bh1749, irGain) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_set_ir_gain() failed"); +} + +int BH1749::GetIrGain() +{ + uint8_t irGain; + if(bh1749_get_ir_gain(m_bh1749, &irGain) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_ir_gain() failed"); + return irGain; +} + +void BH1749::SetIntSource(INT_SOURCES intSource) +{ + if(bh1749_set_int_source(m_bh1749, intSource) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_set_int_source() failed"); +} + +char BH1749::GetInterruptSourceChar() +{ + char intSource = bh1749_get_interrupt_source_char(m_bh1749); + if( intSource == ' ') + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_interrupt_source_char() failed"); + return intSource; +} + +void BH1749::EnableInterrupt() +{ + if(bh1749_enable_interrupt(m_bh1749) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_enable_interrupt() failed"); +} + +void BH1749::DisableInterrupt() +{ + if(bh1749_disable_interrupt(m_bh1749) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_disable_interrupt() failed"); +} + +void BH1749::ResetInterrupt() +{ + if(bh1749_reset_interrupt(m_bh1749) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_reset_interrupt() failed"); +} + +bool BH1749::IsInterrupted() +{ + return bh1749_is_interrupted(m_bh1749); +} + +bool BH1749::IsInterruptEnabled() +{ + return bh1749_is_interrupt_enabled(m_bh1749); +} + +void BH1749::SoftReset() +{ + if(bh1749_soft_reset(m_bh1749) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_soft_reset() failed"); +} + +void BH1749::SetThresholdHigh(uint16_t threshold) +{ + if(bh1749_set_threshold_high(m_bh1749, threshold) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_set_threshold_high() failed"); +} + +int BH1749::GetThresholdHigh() +{ + uint16_t threhold; + if(bh1749_get_threshold_high(m_bh1749, &threhold) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_threshold_high() failed"); + return threhold; +} + +void BH1749::SetThresholdLow(uint16_t threshold) +{ + if(bh1749_set_threshold_low(m_bh1749, threshold) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_set_threshold_low() failed"); +} + +int BH1749::GetThresholdLow() +{ + uint16_t threhold; + if(bh1749_get_threshold_low(m_bh1749, &threhold) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_threshold_low() failed"); + return threhold; +} + +uint16_t BH1749::GetRed() +{ + uint16_t red; + if(bh1749_get_red(m_bh1749, &red) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_red() failed"); + return red; +} + +uint16_t BH1749::GetGreen() +{ + uint16_t green; + if(bh1749_get_green(m_bh1749, &green) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_green() failed"); + return green; +} + +uint16_t BH1749::GetBlue() +{ + uint16_t blue; + if(bh1749_get_blue(m_bh1749, &blue) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_blue() failed"); + return blue; +} + +uint16_t BH1749::GetIr() +{ + uint16_t ir; + if(bh1749_get_ir(m_bh1749, &ir) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_ir() failed"); + return ir; +} + +uint16_t BH1749::GetGeen2() +{ + uint16_t green2; + if(bh1749_get_green2(m_bh1749, &green2) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_green2() failed"); + return green2; +} + +std::vector BH1749::GetMeasurements() +{ + uint16_t res[5]; + if(bh1749_get_measurements(m_bh1749, res) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_get_measurements() failed"); + + std::vector result(res, res + sizeof res / sizeof res[0]); + return result; +} + +void BH1749::InstallISR(mraa_gpio_edge_t edge, int pin, void (*isr)(void *), void *isr_args) +{ + if(bh1749_install_isr(m_bh1749, edge, pin, isr, isr_args) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_install_isr() failed"); +} + +void BH1749::RemoveISR() +{ + bh1749_remove_isr(m_bh1749); +} + +std::string BH1749::RegistersDump() +{ + char dump[255]; + std::string dumpStr; + + if(bh1749_registers_dump(m_bh1749, dump) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1749_registers_dump() failed"); + dumpStr = dump; + return dumpStr; +} diff -Nru upm-1.6.0/src/bh1749/bh1749.h upm-1.7.1/src/bh1749/bh1749.h --- upm-1.6.0/src/bh1749/bh1749.h 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1749/bh1749.h 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,429 @@ +/* +* 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. +*/ + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include +#include +#include +#include "bh1749_registers.h" + +/** + * @file bh1749.h + * @library bh1749 + * @brief C API for the bh1749 driver + * + * @include bh1749.c + */ + +/** + * @brief Operation modes enum for interrupt modes (persistance) + */ +typedef enum { + INT_JUDGE_0 = BH1749_PERSISTENCE_MODE_STATUS_ACTIVE_AFTER_MEASUREMENT, + INT_JUDGE_1 = BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_MEASUREMENT, + INT_JUDGE_4 = BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_4_SAME, + INT_JUDGE_8 = BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_8_SAME, +} OPERATING_MODES; + +/** + * @brief Measuremnt time choices + */ +typedef enum { + MEAS_35MS = BH1749_MODE_CONTROL1_ODR_28P6, + MEAS_120MS = BH1749_MODE_CONTROL1_ODR_8P333, + MEAS_240MS = BH1749_MODE_CONTROL1_ODR_4P167 +} MEAS_TIMES; + +/** + * @brief RGB gain choices + */ +typedef enum { + RGB_GAIN_1X = BH1749_MODE_CONTROL1_RGB_GAIN_1X, + RGB_GAIN_32X = BH1749_MODE_CONTROL1_RGB_GAIN_32X +} RGB_GAINS; + +/** + * @brief IR gain choices + */ +typedef enum { + IR_GAIN_1X = BH1749_MODE_CONTROL1_IR_GAIN_1X, + IR_GAIN_32X = BH1749_MODE_CONTROL1_IR_GAIN_32X +} IR_GAINS; + +/** + * @brief Interrupt source choices + */ +typedef enum { + RED = BH1749_INTERRUPT_SOURCE_SELECT_RED, + GREEN = BH1749_INTERRUPT_SOURCE_SELECT_GREEN, + BLUE = BH1749_INTERRUPT_SOURCE_SELECT_BLUE +} INT_SOURCES; + +/** + * @brief The full sensor context + */ +typedef struct _bh1749_context +{ + mraa_i2c_context i2c; + mraa_gpio_context interrupt; + bool enabled; + bool isrEnabled; + uint16_t int_thh; + uint16_t int_thl; + INT_SOURCES int_src; + IR_GAINS ir_gain; + RGB_GAINS rgb_gain; + MEAS_TIMES meas_time; + OPERATING_MODES operating_mode; +} *bh1749_context; + +/** + * @brief Check "who am I" register value to identify the sensor + * + * @param dev Sensor context + * @return UPM result + */ +upm_result_t bh1749_check_who_am_i(bh1749_context dev); + +/** + * @brief Init the sensor with specific bus and address. This function calls + * the sensor_init() function to set default values for operating mode, gains, + * measurement time, interrupt source and then sets threshold high to 511. + * + * @param bus I2C bus number + * @param addr I2C sensor address + * @return context of initialized sensor + */ +bh1749_context bh1749_init(int bus, int addr); + +/** + * @brief Close and free sensor context + * + * @param dev Sensor context + */ +void bh1749_close(bh1749_context dev); + +/** + * @brief Enables RGB color measurement on the sensor + * + * @param dev Sensor context + * @return UPM result + */ +upm_result_t bh1749_enable(bh1749_context dev); + +/** + * @brief Disables RGB color measurement on the sensor + * + * @param dev Sensor context + * @return UPM result + */ +upm_result_t bh1749_disable(bh1749_context dev); + +/** + * @brief Initializes (writes) configuration values to sensor + * + * @param dev Sensor context + * @param opMode Operating mode choice, a value of OPERATING_MODES enum + * @param measTime Measurement time choice, a value of MEAS_TIMES enum + * @param rgbGain RGB gain choice, a value of RGB_GAINS enum + * @param irGain IR gain choice, a value of IR_GAINS enum + * @param intSource interrupt source choice, a value of INT_SOURCES enum + * @return UPM result + */ +upm_result_t bh1749_sensor_init(bh1749_context dev, OPERATING_MODES opMode, + MEAS_TIMES measTime, + RGB_GAINS rgbGain, + IR_GAINS irGain, + INT_SOURCES intSource); + +/** + * @brief Sets operating mode (interrupt persistance) + * + * @param dev Sensor context + * @param opMode Operating mode choice, a value of OPERATING_MODES enum + * @return UPM result + */ +upm_result_t bh1749_set_operating_mode(bh1749_context dev, OPERATING_MODES opMode); + +/** + * @brief Gets operating mode (interrupt persistance) value + * + * @param dev Sensor context + * @param opMode pointer (uint8_t) to save value + * @return UPM result + */ +upm_result_t bh1749_get_operating_mode(bh1749_context dev, uint8_t *opMode); + +/** + * @brief Sets measurement time (ODR) + * + * @param dev Sensor context + * @param measTime measurement time choice, a value of MEAS_TIMES enum + * @return UPM result + */ +upm_result_t bh1749_set_measurement_time(bh1749_context dev, MEAS_TIMES measTime); + +/** + * @brief Sets measurement time (ODR) + * + * @param dev Sensor context + * @param meas_time pointer (uint8_t) to save value + * @return UPM result + */ +upm_result_t bh1749_get_measurement_time(bh1749_context dev, uint8_t *meas_time); + +/** + * @brief Sets RGB gain values + * + * @param dev Sensor context + * @param rgbGain RGB gain choice, a value of RGB_GAINS enum + * @return UPM result + */ +upm_result_t bh1749_set_rgb_gain(bh1749_context dev, RGB_GAINS rgbGain); + +/** + * @brief Gets RGB gain value + * + * @param dev Sensor context + * @param gain pointer (uint8_t) to save value + * @return UPM result + */ +upm_result_t bh1749_get_rgb_gain(bh1749_context dev, uint8_t *gain); + +/** + * @brief Sets IR gain values + * + * @param dev Sensor context + * @param irGain IR gain choice, a value of IR_GAINS enum + * @return UPM result + */ +upm_result_t bh1749_set_ir_gain(bh1749_context dev, IR_GAINS irGain); + +/** + * @brief Gets IR gain value + * + * @param dev Sensor context + * @param gain pointer (uint8_t) to save value + * @return UPM result + */ +upm_result_t bh1749_get_ir_gain(bh1749_context dev, uint8_t *gain); + +/** + * @brief Sets interrupt source value + * + * @param dev Sensor context + * @param intSource interrupt source choice, a value of INT_SOURCES enum + * @return UPM result + */ +upm_result_t bh1749_set_int_source(bh1749_context dev, INT_SOURCES intSource); + +/** + * @brief Gets interrupt source value + * + * @param dev Sensor context + * @return character of interrupt source + */ +char bh1749_get_interrupt_source_char(bh1749_context dev); + +/** + * @brief Enables interrupt mode and resets the interrupt status (clear) + * + * @param dev Sensor context + * @return UPM result + */ +upm_result_t bh1749_enable_interrupt(bh1749_context dev); + +/** + * @brief Disables interrupt mode + * + * @param dev Sensor context + * @return UPM result + */ +upm_result_t bh1749_disable_interrupt(bh1749_context dev); + +/** + * @brief Resets interrupt status (clear) to allow new interrupts + * + * @param dev Sensor context + * @return UPM result + */ +upm_result_t bh1749_reset_interrupt(bh1749_context dev); + +/** + * @brief Checks the status of the interrupt + * + * @param dev Sensor context + * @return true if there is interrupt, otherwise false + */ +bool bh1749_is_interrupted(bh1749_context dev); + +/** + * @brief Checks whether interrupt mode is enabled + * + * @param dev Sensor context + * @return true if interrupt is enabled, otherwise false + */ +bool bh1749_is_interrupt_enabled(bh1749_context dev); + +/** + * @brief Initiates a software reset to the sensor. All register values will + * be written to their defaults, thus sensor_init() must be called after this, + * and thresholds also needs to be set. + * + * @param dev Sensor context + * @return UPM result + */ +upm_result_t bh1749_soft_reset(bh1749_context dev); + +/** + * @brief Sets interrupt threshold high value + * + * @param dev Sensor context + * @param threshold Value to be written, range 0-65536 + * @return UPM result + */ +upm_result_t bh1749_set_threshold_high(bh1749_context dev, uint16_t threshold); + +/** + * @brief Gets interrupt threshold high value + * + * @param dev Sensor context + * @param threshold Pointer (uint16_t) to write value + * @return UPM result + */ +upm_result_t bh1749_get_threshold_high(bh1749_context dev, uint16_t *threshold); + +/** + * @brief Sets interrupt threshold low value + * + * @param dev Sensor context + * @param threshold Value to be written, range 0-65536 + * @return UPM result + */ +upm_result_t bh1749_set_threshold_low(bh1749_context dev, uint16_t threshold); + +/** + * @brief Gets interrupt threshold low value + * + * @param dev Sensor context + * @param threshold Pointer (uint16_t) to write value + * @return UPM result + */ +upm_result_t bh1749_get_threshold_low(bh1749_context dev, uint16_t *threshold); + +/** + * @brief Gets value of Red color channel + * + * @param dev Sensor context + * @param red Pointer (uint16_t) to write value + * @return UPM result + */ +upm_result_t bh1749_get_red(bh1749_context dev, uint16_t *red); + +/** + * @brief Gets value of Green color channel + * + * @param dev Sensor context + * @param green Pointer (uint16_t) to write value + * @return UPM result + */ +upm_result_t bh1749_get_green(bh1749_context dev, uint16_t *green); + +/** + * @brief Gets value of Blue color channel + * + * @param dev Sensor context + * @param blue Pointer (uint16_t) to write value + * @return UPM result + */ +upm_result_t bh1749_get_blue(bh1749_context dev, uint16_t *blue); + +/** + * @brief Gets value of IR color channel + * + * @param dev Sensor context + * @param ir Pointer (uint16_t) to write value + * @return UPM result + */ +upm_result_t bh1749_get_ir(bh1749_context dev, uint16_t *ir); + +/** + * @brief Gets value of Green2 color channel + * + * @param dev Sensor context + * @param green Pointer (uint16_t) to write value + * @return UPM result + */ +upm_result_t bh1749_get_green2(bh1749_context dev, uint16_t *green2); + +/** + * @brief Gets all channels measurements values + * + * @param dev Sensor context + * @param result Pointer of uint16_t to write all values ordered as: + * Red, Green, Blue, IR, Green2 + * + * @return UPM result + */ +upm_result_t bh1749_get_measurements(bh1749_context dev, uint16_t *result); + +/** + * @brief Installs the ISR to a given GPIO pin + * + * @param dev Sensor context + * @param edge Edge type to raise ISR with, of type mraa_gpio_edge_t + * @param pin GPIO pin number + * @param isr Pointer to ISR function + * @param isr_args Arguments to pass the ISR function + * @return UPM result + */ +upm_result_t bh1749_install_isr(bh1749_context dev, mraa_gpio_edge_t edge, int pin, + void (*isr)(void *), void *isr_args); + +/** + * @brief Removes the ISR if it is installed + * + * @param dev Sensor context + */ +void bh1749_remove_isr(bh1749_context dev); + +/** + * @brief Gets a dump of configuration registers as a string + * + * @param dev Sensor context + * @param dump Pointer of char to save dump string + * @return UPM result + */ +upm_result_t bh1749_registers_dump(bh1749_context dev, char *dump); + +#ifdef __cplusplus +} +#endif diff -Nru upm-1.6.0/src/bh1749/bh1749.hpp upm-1.7.1/src/bh1749/bh1749.hpp --- upm-1.6.0/src/bh1749/bh1749.hpp 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1749/bh1749.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,345 @@ +/* +* 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. +*/ + +#pragma once + +#include +#include "bh1749.h" + +/** + * @brief BH1749 Color Sensor + * @defgroup bh1749 libupm-bh1749 + * @ingroup rohm i2c color + */ + +/** + * @library bh1749 + * @sensor bh1749 + * @comname Color Sensor + * @type color sensor + * @man rohm + * @con i2c + * + * @brief C++ API wrapper for the bh1749 driver + * + * @snippet bh1749.cxx Interesting + */ + +namespace upm { + class BH1749 { + public: + /** + * @brief Initialize a sensor instance with bus and address. + * + * This calls SensorInit() to set default values for operating mode, + * gains, measurement time, interrupt source and then sets threshold + * high to 511. + * + * @param bus I2C bus number + * @param addr I2C sensor address + * @throws std::runtime_error on initialization failure + */ + BH1749(int bus = 0, int addr = 0x39); + + /** + * @brief Close and free sensor + */ + virtual ~BH1749(); + + /** + * @brief Enables RGB color measurement on the sensor + * + * @throws std::runtime_error if bh1749_enable() fails + */ + void Enable(); + + /** + * @brief Disables RGB color measurement on the sensor + * + * @throws std::runtime_error if bh1749_disable() fails + */ + void Disable(); + + /** + * @brief Check "who am I" register value to identify the sensor + * + * @throws std::runtime_error if this value is incorrect + */ + void CheckWhoAmI(); + + /** + * @brief Initializes (writes) configuration values to sensor + * + * @param opMode Operating mode choice, a value of OPERATING_MODES enum + * @param measTime Measurement time choice, a value of MEAS_TIMES enum + * @param rgbGain RGB gain choice, a value of RGB_GAINS enum + * @param irGain IR gain choice, a value of IR_GAINS enum + * @param intSource interrupt source choice, a value of INT_SOURCES enum + * + * @throws std::runtime_error if one of values setting fails + */ + void SensorInit(OPERATING_MODES opMode, + MEAS_TIMES measTime, + RGB_GAINS rgbGain, + IR_GAINS irGain, + INT_SOURCES intSource); + + /** + * @brief Sets operating mode (interrupt persistance) + * + * @param opMode Operating mode choice, a value of OPERATING_MODES enum + * @throws std::runtime_error if writing value fails + */ + void SetOperatingMode(OPERATING_MODES opMode); + + /** + * @brief Gets operating mode (interrupt persistance) value + * + * @param opMode pointer (uint8_t) to save value + * @return operating mode value + * @throws std::runtime_error if reading the value fails + */ + int GetOperatingMode(); + + /** + * @brief Sets measurement time (ODR) + * + * @param measTime measurement time choice, a value of MEAS_TIMES enum + * @throws std::runtime_error if writing value fails + */ + void SetMeasurementTime(MEAS_TIMES measTime); + + /** + * @brief Gets measurement time (ODR) value + * + * @return measurement time value + * @throws std::runtime_error if reading the value fails + */ + int GetMeasurementTime(); + + /** + * @brief Sets RGB gain value + * + * @param rgbGain RGB gain choice, a value of RGB_GAINS enum + * @throws std::runtime_error if writing value fails + */ + void SetRgbGain(RGB_GAINS rgbGain); + + /** + * @brief Gets RGB gain value + * + * @return RGB gain value value + * @throws std::runtime_error if reading the value fails + */ + int GetRgbGain(); + + /** + * @brief Sets IR gain value + * + * @param irGain IR gain choice, a value of IR_GAINS enum + * @throws std::runtime_error if writing value fails + */ + void SetIrGain(IR_GAINS irGain); + + /** + * @brief Gets IR gain value + * + * @return IR gain value value + * @throws std::runtime_error if reading the value fails + */ + int GetIrGain(); + + /** + * @brief Sets interrupt source value + * + * @param intSource interrupt source choice, a value of INT_SOURCES enum + * @throws std::runtime_error if writing value fails + */ + void SetIntSource(INT_SOURCES intSource); + + /** + * @brief Gets interrupt source value + * + * @return interrupt source value + * @throws std::runtime_error if reading the value fails + */ + char GetInterruptSourceChar(); + + /** + * @brief Enables interrupt mode + * + * @throws std::runtime_error if writing enable bit fails + */ + void EnableInterrupt(); + + /** + * @brief Disables interrupt mode + * + * @throws std::runtime_error if writing disable bit fails + */ + void DisableInterrupt(); + + /** + * @brief Resets interrupt status (clear) to allow new interrupt reads + * + * @throws std::runtime_error if writing reset bit fails + */ + void ResetInterrupt(); + + /** + * @brief Gets interrupt status, whether interrupt is raised or not + * + * @return true if interrupt is raised, otherwise false + */ + bool IsInterrupted(); + + /** + * @brief Gets interrupt mode status + * + * @return true if interrupt is enabled, otherwise false + */ + bool IsInterruptEnabled(); + + /** + * @brief Initiates a software reset to the sensor. All register values + * will be written to their defaults, thus sensor_init() must be called + * after this, and thresholds also needs to be set. + * + * @throws std::runtime_error if writing reset bit fails + */ + void SoftReset(); + + /** + * @brief Sets threshold high value + * + * @param threshold interrupt threshold high value, range 0-65536 + * @throws std::runtime_error if writing value fails + */ + void SetThresholdHigh(uint16_t threshold); + + /** + * @brief Gets threshold high value + * + * @return threshold high value + * @throws std::runtime_error if reading the value fails + */ + int GetThresholdHigh(); + + /** + * @brief Sets threshold low value + * + * @param threshold interrupt threshold low value, range 0-65536 + * @throws std::runtime_error if writing value fails + */ + void SetThresholdLow(uint16_t threshold); + + /** + * @brief Gets threshold low value + * + * @return threshold low value + * @throws std::runtime_error if reading the value fails + */ + int GetThresholdLow(); + + /** + * @brief Gets value of Red color channel + * + * @return red channel value + * @throws std::runtime_error if reading the value fails + */ + uint16_t GetRed(); + + /** + * @brief Gets value of Green color channel + * + * @return green channel value + * @throws std::runtime_error if reading the value fails + */ + uint16_t GetGreen(); + + /** + * @brief Gets value of Blue color channel + * + * @return blue channel value + * @throws std::runtime_error if reading the value fails + */ + uint16_t GetBlue(); + + /** + * @brief Gets value of IR color channel + * + * @return ir channel value + * @throws std::runtime_error if reading the value fails + */ + uint16_t GetIr(); + + /** + * @brief Gets value of Green2 color channel + * + * @return green2 channel value + * @throws std::runtime_error if reading the value fails + */ + uint16_t GetGeen2(); + + /** + * @brief Gets all channels measurements values + * + * @return vector with all channels values ordered as: + * Red, Green, Blue, IR, Green2 + * @throws std::runtime_error if reading one of the values fails + */ + std::vector GetMeasurements(); + + /** + * @brief Installs the ISR to a given GPIO pin + * + * @param edge Edge type to raise ISR with, of type mraa_gpio_edge_t + * @param pin GPIO pin number + * @param isr Pointer to ISR function + * @param isr_args Arguments to pass the ISR function + * @throws std::runtime_error if installing ISR fails + */ + void InstallISR(mraa_gpio_edge_t edge, int pin, void (*isr)(void *), void *isr_args); + + /** + * @brief Removes the ISR if it is installed + */ + void RemoveISR(); + + /** + * @brief Gets a dump of configuration registers as a string + * + * @return string of dumped registers + * @throws std::runtime_error if reading one of the registers fails + */ + std::string RegistersDump(); + + private: + bh1749_context m_bh1749; + + /* Disable implicit copy and assignment operators */ + BH1749(const BH1749 &) = delete; + BH1749 &operator=(const BH1749 &) = delete; + }; +} \ No newline at end of file diff -Nru upm-1.6.0/src/bh1749/bh1749.i upm-1.7.1/src/bh1749/bh1749.i --- upm-1.6.0/src/bh1749/bh1749.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1749/bh1749.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_bh1749) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "std_vector.i" +%template(uint16Vector) std::vector; + +%{ +#include "bh1749.hpp" +%} +%include "bh1749.h" +%include "bh1749.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bh1749/bh1749.json upm-1.7.1/src/bh1749/bh1749.json --- upm-1.6.0/src/bh1749/bh1749.json 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1749/bh1749.json 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,49 @@ +{ + "Library": "BH1749", + "Description": "ROHM BH1749 Color sensor (16-bit) library", + "Sensor Class": { + "BH1749": { + "Name": "ROHM BH1749 Color sensor (16-bit)", + "Description": "BH1749NUC is a digital color sensor IC with I2C bus interface. This IC senses Red, Green, Blue (RGB) and Infrared and converts them to digital values. The high sensitivity, wide dynamic range and excellent Ircut characteristics make it possible for this IC to obtain the accurate illuminance and color temperature of ambient light. It is ideal for adjusting LCD backlight of TV, mobile phone and tablet PC.", + "Categories": ["color sensor"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "commercial"], + "Manufacturers": ["ROHM"], + "Examples": { + "C++": ["bh1749.cxx"], + "C": ["bh1749.c"], + "Java": ["BH1749_Example.java"], + "Python": ["bh1749.py"], + "Node.js": ["bh1749.js"] + }, + "Specifications": { + "Supply Voltage (VDD)": { + "unit": "V", + "min": 2.3, + "max": 3.6 + }, + "Supply Current": { + "unit": "uA", + "min": 0.8, + "max": 190 + }, + "Operating Temperature": { + "unit": "°C", + "min": -40, + "max": 85 + }, "Illumination Detection": { + "unit" : "klx", + "value": 80 + } + }, + "Urls": { + "Product Pages": [ + "https://www.rohm.com/products/sensors-mems/color-sensor-ics/bh1745nuc-product" + ], + "Datasheets": [ + "https://www.rohm.com/datasheet/BH1749NUC/bh1749nuc-e" + ] + } + } + } +} diff -Nru upm-1.6.0/src/bh1749/bh1749_registers.h upm-1.7.1/src/bh1749/bh1749_registers.h --- upm-1.6.0/src/bh1749/bh1749_registers.h 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1749/bh1749_registers.h 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,160 @@ +/* +The MIT License (MIT) +Copyright (c) 2017 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. +*/ + +#ifndef __BH1749_REGISTERS_H__ +#define __BH1749_REGISTERS_H__ +/* registers */ +#define BH1749_REGISTER_DUMP_START 0x40 +#define BH1749_SYSTEM_CONTROL 0x40 +#define BH1749_MODE_CONTROL1 0x41 +#define BH1749_MODE_CONTROL2 0x42 +// Least significant byte of uint16 RED measurement value +#define BH1749_RED_DATA_LSBS 0x50 +// Most significant byte of uint16 RED measurement value +#define BH1749_RED_DATA_MSBS 0x51 +// Least significant byte of uint16 GREEN measurement value +#define BH1749_GREEN_DATA_LSBS 0x52 +// Most significant byte of uint16 GREEN measurement value +#define BH1749_GREEN_DATA_MSBS 0x53 +// Least significant byte of uint16 BLUE measurement value +#define BH1749_BLUE_DATA_LSBS 0x54 +// Most significant byte of uint16 BLUE measurement value +#define BH1749_BLUE_DATA_MSBS 0x55 +// Least significant byte of uint16 IR measurement value +#define BH1749_IR_DATA_LSBS 0x58 +// Most significant byte of uint16 IR measurement value +#define BH1749_IR_DATA_MSBS 0x59 +// Least significant byte of uint16 GREEN2 measurement value +#define BH1749_GREEN2_DATA_LSBS 0x5A +// Most significant byte of uint16 GREEN2 measurement value +#define BH1749_GREEN2_DATA_MSBS 0x5B +// Interrupt control register +#define BH1749_INTERRUPT 0x60 +// Interrupt status update control register +#define BH1749_PERSISTENCE 0x61 +// Least significant byte of interrupt threshold high level +#define BH1749_TH_LSBS 0x62 +// Most significant byte of interrupt threshold high level +#define BH1749_TH_MSBS 0x63 +// Least significant byte of interrupt threshold low level +#define BH1749_TL_LSBS 0x64 +// Most significant byte of interrupt threshold low level +#define BH1749_TL_MSBS 0x65 +#define BH1749_ID_REG 0x92 +#define BH1749_REGISTER_DUMP_END 0x92 +/* registers bits */ +// Software reset is not done +#define BH1749_SYSTEM_CONTROL_SW_RESET_NOT_DONE (0x00 << 7) +// Software reset is done +#define BH1749_SYSTEM_CONTROL_SW_RESET_DONE (0x01 << 7) +// INT pin status is not changed +#define BH1749_SYSTEM_CONTROL_INT_NO_ACTION (0x00 << 6) +// INT pin becomes inactive (high impedance) +#define BH1749_SYSTEM_CONTROL_INT_RESET (0x01 << 6) +#define BH1749_SYSTEM_CONTROL_PART_ID (0x0D << 0) +#define BH1749_MODE_CONTROL1_RESERVED7_WRITE0 (0x00 << 7) +#define BH1749_MODE_CONTROL1_IR_GAIN_RESERVED0 (0x00 << 5) +#define BH1749_MODE_CONTROL1_IR_GAIN_1X (0x01 << 5) +#define BH1749_MODE_CONTROL1_IR_GAIN_RESERVED1 (0x02 << 5) +#define BH1749_MODE_CONTROL1_IR_GAIN_32X (0x03 << 5) +#define BH1749_MODE_CONTROL1_RGB_GAIN_RESERVED0 (0x00 << 3) +#define BH1749_MODE_CONTROL1_RGB_GAIN_1X (0x01 << 3) +#define BH1749_MODE_CONTROL1_RGB_GAIN_RESERVED1 (0x02 << 3) +#define BH1749_MODE_CONTROL1_RGB_GAIN_32X (0x03 << 3) +// Reserved value +#define BH1749_MODE_CONTROL1_ODR_RESERVED0 (0x00 << 0) +// Reserved value +#define BH1749_MODE_CONTROL1_ODR_RESERVED1 (0x01 << 0) +// 120ms measurement time +#define BH1749_MODE_CONTROL1_ODR_8P333 (0x02 << 0) +// 240ms measurement time +#define BH1749_MODE_CONTROL1_ODR_4P167 (0x03 << 0) +// Reserved value +#define BH1749_MODE_CONTROL1_ODR_RESERVED2 (0x04 << 0) +// 35ms measurement time +#define BH1749_MODE_CONTROL1_ODR_28P6 (0x05 << 0) +// Reserved value +#define BH1749_MODE_CONTROL1_ODR_RESERVED3 (0x06 << 0) +// Reserved value +#define BH1749_MODE_CONTROL1_ODR_RESERVED4 (0x07 << 0) +#define BH1749_MODE_CONTROL2_VALID_NO (0x00 << 7) +#define BH1749_MODE_CONTROL2_VALID_YES (0x01 << 7) +#define BH1749_MODE_CONTROL2_RESERVED65_WRITE00 (0x00 << 5) +#define BH1749_MODE_CONTROL2_RGB_MEASUREMENT_INACTIVE (0x00 << 4) +#define BH1749_MODE_CONTROL2_RGB_MEASUREMENT_ACTIVE (0x01 << 4) +#define BH1749_MODE_CONTROL2_RESERVED30_WRITE0000 (0x00 << 0) +#define BH1749_INTERRUPT_STATUS_INACTIVE (0x00 << 7) +#define BH1749_INTERRUPT_STATUS_ACTIVE (0x01 << 7) +#define BH1749_INTERRUPT_RESERVED64_WRITE000 (0x00 << 4) +// red channel +#define BH1749_INTERRUPT_SOURCE_SELECT_RED (0x00 << 2) +// green channel +#define BH1749_INTERRUPT_SOURCE_SELECT_GREEN (0x01 << 2) +// blue channel +#define BH1749_INTERRUPT_SOURCE_SELECT_BLUE (0x02 << 2) +// Reserved value +#define BH1749_INTERRUPT_SOURCE_RESERVED0 (0x03 << 2) +#define BH1749_INTERRUPT_RESERVED1_WRITE0 (0x00 << 1) +#define BH1749_INTERRUPT_EN_DISABLE (0x00 << 0) +#define BH1749_INTERRUPT_EN_ENABLE (0x01 << 0) +#define BH1749_PERSISTENCE_RESERVED72_WRITE000000 (0x00 << 2) +// Interrupt status becomes active at each measurement end. +#define BH1749_PERSISTENCE_MODE_STATUS_ACTIVE_AFTER_MEASUREMENT (0x00 << 0) +// Interrupt status is updated at each measurement end. +#define BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_MEASUREMENT (0x01 << 0) +// Interrupt status is updated if 4 consecutive threshold judgements are the same +#define BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_4_SAME (0x02 << 0) +// Interrupt status is updated if 8 consecutive threshold judgements are the same +#define BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_8_SAME (0x03 << 0) +// Manufacturer ID +#define BH1749_ID_REG_MANUFACTURER_ID (0xE0 << 0) + /*registers bit masks */ +#define BH1749_SYSTEM_CONTROL_SW_RESET_MASK 0x80 + +#define BH1749_SYSTEM_CONTROL_INT_MASK 0x40 + +#define BH1749_SYSTEM_CONTROL_PART_MASK 0x3F +#define BH1749_MODE_CONTROL1_RESERVED7_MASK 0x80 +#define BH1749_MODE_CONTROL1_IR_GAIN_MASK 0x60 +#define BH1749_MODE_CONTROL1_RGB_GAIN_MASK 0x18 +#define BH1749_MODE_CONTROL1_ODR_MASK 0x07 +// Measurement data update flag. Sets to 0 if MODE_CONTROL1/2 reg, +// MODE_CONTROL2, INTERRUPT, T(H/L)_(LSB/MSB) is written or +// MODE_CONTROL2 read. In specification named as VALID. +#define BH1749_MODE_CONTROL2_VALID_MASK 0x80 +#define BH1749_MODE_CONTROL2_RESERVED65_MASK 0x60 +#define BH1749_MODE_CONTROL2_RGB_MEASUREMENT_MASK 0x10 +#define BH1749_MODE_CONTROL2_RESERVED30_MASK 0x0F +#define BH1749_INTERRUPT_STATUS_MASK 0x80 +#define BH1749_INTERRUPT_RESERVED64_MASK 0x70 +#define BH1749_INTERRUPT_SOURCE_MASK 0x0C +// Write 0 +#define BH1749_INTERRUPT_RESERVED1_MASK 0x02 +#define BH1749_INTERRUPT_EN_MASK 0x01 +#define BH1749_PERSISTENCE_RESERVED72_MASK 0xFC +#define BH1749_PERSISTENCE_MODE_MASK 0x03 + +#define BH1749_ID_REG_MANUFACTURER_MASK 0xFF +#endif + diff -Nru upm-1.6.0/src/bh1749/CMakeLists.txt upm-1.7.1/src/bh1749/CMakeLists.txt --- upm-1.6.0/src/bh1749/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1749/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,8 @@ +upm_mixed_module_init (NAME bh1749 + DESCRIPTION "ROHM Color Sensor" + C_HDR bh1749.h bh1749_registers.h + C_SRC bh1749.c + CPP_HDR bh1749.hpp + CPP_SRC bh1749.cxx + CPP_WRAPS_C + REQUIRES mraa) diff -Nru upm-1.6.0/src/bh1750/bh1750.hpp upm-1.7.1/src/bh1750/bh1750.hpp --- upm-1.6.0/src/bh1750/bh1750.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bh1750/bh1750.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -36,7 +36,7 @@ /** * @brief BH1750 Light Sensor * @defgroup bh1750 libupm-bh1750 - * @ingroup dfrobot i2c + * @ingroup rohm dfrobot i2c */ /** @@ -44,7 +44,7 @@ * @sensor bh1750 * @comname Digital Light Sensor * @type light - * @man dfrobot + * @man rohm dfrobot * @con i2c * @web http://www.dfrobot.com/index.php?route=product/product&product_id=531 * @@ -63,7 +63,7 @@ /** * BH1750 object constructor (Analog mode) * - * @param bus The I2C bus to use + * @param bus The I2C bus to use * @param addr The I2C address of the device * @param mode The mode to start operation under. One of the * BH1750_OPMODES_T values. The default is the highest precision, diff -Nru upm-1.6.0/src/bh1750/bh1750.i upm-1.7.1/src/bh1750/bh1750.i --- upm-1.6.0/src/bh1750/bh1750.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1750/bh1750.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_bh1750) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bh1750_defs.h" +#include "bh1750.hpp" +%} +%include "bh1750_defs.h" +%include "bh1750.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bh1750/javaupm_bh1750.i upm-1.7.1/src/bh1750/javaupm_bh1750.i --- upm-1.6.0/src/bh1750/javaupm_bh1750.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bh1750/javaupm_bh1750.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_bh1750 -%include "../upm.i" -%include "std_string.i" - - -%include "bh1750_defs.h" -%include "bh1750.hpp" -%{ - #include "bh1750.hpp" -%} - - -JAVA_JNI_LOADLIBRARY(javaupm_bh1750) diff -Nru upm-1.6.0/src/bh1750/jsupm_bh1750.i upm-1.7.1/src/bh1750/jsupm_bh1750.i --- upm-1.6.0/src/bh1750/jsupm_bh1750.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bh1750/jsupm_bh1750.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_bh1750 -%include "../upm.i" -%include "std_string.i" - -%include "bh1750_defs.h" -%include "bh1750.hpp" -%{ - #include "bh1750.hpp" -%} - diff -Nru upm-1.6.0/src/bh1750/pyupm_bh1750.i upm-1.7.1/src/bh1750/pyupm_bh1750.i --- upm-1.6.0/src/bh1750/pyupm_bh1750.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bh1750/pyupm_bh1750.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bh1750 -%include "../upm.i" -%include "std_string.i" - -%include "bh1750_defs.h" -%include "bh1750.hpp" -%{ - #include "bh1750.hpp" -%} - diff -Nru upm-1.6.0/src/bh1792/bh1792.c upm-1.7.1/src/bh1792/bh1792.c --- upm-1.6.0/src/bh1792/bh1792.c 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1792/bh1792.c 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,889 @@ +/* +* 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 +#include "bh1792.h" + +/** + * @brief Reads the value of a register + * + * @param dev The sensor context + * @param reg Register address + * @param data Pointer of uint8_t to save register value + * @return UPM result + */ +static upm_result_t bh1792_read_register(bh1792_context dev, uint8_t reg, + uint8_t *data); + +/** + * @brief Reads the values of a set of registers + * + * @param dev The sensor context + * @param reg Register address + * @param data Pointer of uint8_t to save registers values + * @return UPM result + */ +static upm_result_t bh1792_read_registers(bh1792_context dev, uint8_t reg, + uint8_t *data, uint8_t len); + +/** + * @brief Writes a value to a register + * + * @param dev The sensor context + * @param value Value to write + * @param reg Register address + * @return UPM result + */ +static upm_result_t bh1792_write_register(bh1792_context dev, uint8_t value, + uint8_t reg); + +/** + * @brief Sets a bit on in a register with a bit mask + * + * @param dev The sensor context + * @param reg Register address + * @param bit_mask Mask to use + * @return UPM result + */ +static upm_result_t bh1792_set_bit_on(bh1792_context dev, uint8_t reg, + uint8_t bit_mask); + +/** + * @brief Sets a bit off in a register with a bit mask + * + * @param dev The sensor context + * @param reg Register address + * @param bit_mask Mask to use + * @return UPM result + */ +static upm_result_t bh1792_set_bit_off(bh1792_context dev, uint8_t reg, + uint8_t bit_mask); + +/** + * @brief Sets the value of a register as a given pattern with a bit mask + * + * @param dev The sensor context + * @param reg Register address + * @param value Value to write + * @param bit_mask Mask to use + * @return UPM result + */ +static upm_result_t bh1792_set_bits_with_mask(bh1792_context dev, uint8_t reg, + uint8_t value, uint8_t bit_mask); + +/** + * @brief Writes sync bit each 1 second. This function is used in a thread. + * + * @param dev The sensor context + */ +static void *bh1792_sync_measurement(void *args); + +/** + * @brief Sets the measurement time for synchronized mode + * + * @param dev The sensor context + * @param meas_mode Measurement mode choice, take a value of MEAS_MODES + * @return UPM result + */ +static upm_result_t bh1792_set_sync_meas_mode(bh1792_context dev, uint16_t meas_freq); + +/** + * @brief Selects the LED light type to use for measurement + * + * @param dev The sensor context + * @param led_type Can take a value of GREEN or IR + * @return UPM result + */ +static upm_result_t bh1792_select_led_type(bh1792_context dev, LED_TYPES led_type); + +/** + * @brief Sets the interrupt mode to be used, this is called when choosing + * operation mode + * + * @param dev The sensor context + * @param int_mode Interrupt mode, one of INTERRUPT_MODES values + * @return UPM result + */ +static upm_result_t bh1792_set_interrupt_mode(bh1792_context dev, INTERRUPT_MODES int_mode); + +/** + * @brief Sets the RDY bit of the sensor + * + * @param dev The sensor context + * @return UPM result + */ +static upm_result_t bh1792_set_rdy_bit(bh1792_context dev); + + +static upm_result_t bh1792_read_register(bh1792_context dev, uint8_t reg, + uint8_t *data) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t value = mraa_i2c_read_byte_data(dev->i2c, reg); + if(value < 0) { + printf("%s: mraa_i2c_read_byte_data() failed\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + *data = value; + return UPM_SUCCESS; +} + +static upm_result_t bh1792_read_registers(bh1792_context dev, uint8_t reg, + uint8_t *data, uint8_t len) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t value; + + for(int i = 0; i < len; i++) { + if(bh1792_read_register(dev, reg + i, &value) != UPM_SUCCESS) { + return UPM_ERROR_OPERATION_FAILED; + } + + *(data + i) = value; + } + + return UPM_SUCCESS; +} + +static upm_result_t bh1792_write_register(bh1792_context dev, uint8_t value, + uint8_t reg) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if (mraa_i2c_write_byte_data(dev->i2c, value, reg) != MRAA_SUCCESS) { + printf("%s: mraa_i2c_write_byte_data() failed\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + return UPM_SUCCESS; +} + +static upm_result_t bh1792_set_bit_on(bh1792_context dev, uint8_t reg, + uint8_t bit_mask) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t reg_value; + int status; + + status = bh1792_read_register(dev, reg, ®_value); + if(status < 0) { + printf("%s: Failed to read register 0x%2X\n", __FUNCTION__, reg); + return UPM_ERROR_OPERATION_FAILED; + } + + reg_value |= bit_mask; + return bh1792_write_register(dev, reg_value, reg); +} + +static upm_result_t bh1792_set_bit_off(bh1792_context dev, uint8_t reg, + uint8_t bit_mask) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t reg_value; + int status; + + status = bh1792_read_register(dev, reg, ®_value); + if(status < 0) { + printf("%s: Failed to read register 0x%2X\n", __FUNCTION__, reg); + return UPM_ERROR_OPERATION_FAILED; + } + + reg_value &= ~bit_mask; + return bh1792_write_register(dev, reg_value, reg); +} + +static upm_result_t bh1792_set_bits_with_mask(bh1792_context dev, uint8_t reg, + uint8_t value, uint8_t bit_mask) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t reg_value; + int status; + + status = bh1792_read_register(dev, reg, ®_value); + if(status < 0) { + printf("%s: Failed to read register 0x%2X\n", __FUNCTION__, reg); + return UPM_ERROR_OPERATION_FAILED; + } + + reg_value &= ~bit_mask; + reg_value |= value; + return bh1792_write_register(dev, reg_value, reg); +} + +bh1792_context bh1792_init(int bus, int addr) +{ + bh1792_context dev = (bh1792_context)malloc(sizeof(struct _bh1792_context)); + if (!dev) + return NULL; + + dev->i2c = NULL; + dev->interrupt = NULL; + + if (mraa_init() != MRAA_SUCCESS) { + printf("%s: mraa_init() failed.\n", __FUNCTION__); + bh1792_close(dev); + return NULL; + } + + if (!(dev->i2c = mraa_i2c_init(bus))) { + printf("%s: mraa_i2c_init() failed.\n", __FUNCTION__); + bh1792_close(dev); + return NULL; + } + + if (mraa_i2c_address(dev->i2c, addr)) { + printf("%s: mraa_i2c_address() failed.\n", __FUNCTION__); + bh1792_close(dev); + return NULL; + } + + if(bh1792_check_who_am_i(dev) != UPM_SUCCESS) + return NULL; + + dev->enabled = false; + dev->isrEnabled = false; + dev->sync_thread_alive = false; + + return dev; +} + +void bh1792_close(bh1792_context dev) +{ + if(dev) { + bh1792_stop_measurement(dev); + if(dev->isrEnabled) + bh1792_remove_isr(dev); + + if (dev->i2c) + mraa_i2c_stop(dev->i2c); + + if(dev->sync_thread_alive) { + dev->sync_thread_alive = false; + pthread_join(dev->sync_thread, NULL); + } + + free(dev); + } +} + +upm_result_t bh1792_check_who_am_i(bh1792_context dev) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t who_am_i; + if(bh1792_read_register(dev, BH1792_MANUFACTURER_REG, &who_am_i) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(who_am_i != BH1792_MANUFACTURER_REG_MANUFACTURER_ID) { + printf("%s: wrong manufacturer ID\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + if(bh1792_read_register(dev, BH1792_PARTID_REG, &who_am_i) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(who_am_i != BH1792_PARTID_REG_PART_ID) { + printf("%s: wrong part ID\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + return UPM_SUCCESS; +} + +static upm_result_t bh1792_set_rdy_bit(bh1792_context dev) +{ + return bh1792_set_bit_on(dev, BH1792_MEAS_CONTROL1, BH1792_MEAS_CONTROL1_RDY); +} + +bool bh1792_is_enabled(bh1792_context dev) +{ + if(!dev) + return false; + + return dev->enabled; +} + +upm_result_t bh1792_soft_reset(bh1792_context dev) +{ + return bh1792_set_bit_on(dev, BH1792_RESET, BH1792_RESET_SWRESET); +} + +static upm_result_t bh1792_select_led_type(bh1792_context dev, LED_TYPES led_type) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t status; + + if(led_type == GREEN) { + status = bh1792_set_bit_off(dev, BH1792_MEAS_CONTROL1, + BH1792_MEAS_CONTROL1_SEL_ADC_MASK); + if(status != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + } else { + if(dev->op_mode == SYNCHRONIZED) { + printf("%s: IR LED only for single & non-sync modes\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + status = bh1792_set_bit_on(dev, BH1792_MEAS_CONTROL1, + BH1792_MEAS_CONTROL1_SEL_ADC_MASK); + if(status != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + } + + dev->led_type = led_type; + + return UPM_SUCCESS; +} + +static upm_result_t bh1792_set_sync_meas_mode(bh1792_context dev, uint16_t meas_freq) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t status; + + MEAS_MODES meas_mode; + switch(meas_freq) { + case 32: + meas_mode = MSR_32Hz; + break; + case 64: + meas_mode = MSR_64Hz; + break; + case 128: + meas_mode = MSR_128Hz; + break; + case 256: + meas_mode = MSR_256Hz; + break; + case 1024: + meas_mode = MSR_1024Hz; + break; + default: + return UPM_ERROR_INVALID_PARAMETER; + } + + status = bh1792_set_bits_with_mask(dev, BH1792_MEAS_CONTROL1, meas_mode, + BH1792_MEAS_CONTROL1_MSR_MASK); + if(status != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + dev->meas_freq = meas_freq; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_get_meas_time_ms(bh1792_context dev, float *meas_time_ms) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t meas_time_reg; + + if(bh1792_read_register(dev, BH1792_MEAS_CONTROL1, &meas_time_reg) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + switch(meas_time_reg & BH1792_MEAS_CONTROL1_MSR_MASK) { + case MSR_32Hz: + *meas_time_ms = 1000 / (float)32; + break; + case MSR_64Hz: + *meas_time_ms = 1000 / (float)64; + break; + case MSR_128Hz: + *meas_time_ms = 1000 / (float)128; + break; + case MSR_256Hz: + *meas_time_ms = 1000 / (float)256; + break; + case MSR_1024Hz: + *meas_time_ms = 1000 / (float)1024; + break; + case MSR_SINGLE: + case MSR_NON_SYNC: + *meas_time_ms = 1000 / (float)4; + break; + default: + return UPM_ERROR_OPERATION_FAILED; + } + + return UPM_SUCCESS; +} + +upm_result_t bh1792_set_green_leds_current(bh1792_context dev, uint8_t current) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(current > LED_CURRENT_MAX) + return UPM_ERROR_OUT_OF_RANGE; + + uint8_t status; + + status = bh1792_set_bits_with_mask(dev, BH1792_MEAS_CONTROL2, + current & BH1792_MEAS_CONTROL2_LED_CURRENT1_MASK, + BH1792_MEAS_CONTROL2_LED_CURRENT1_MASK); + if(status != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + dev->green_current = current; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_get_green_leds_current(bh1792_context dev, uint8_t *current) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t data; + + if(bh1792_read_register(dev, BH1792_MEAS_CONTROL2, &data) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *current = data & BH1792_MEAS_CONTROL2_LED_CURRENT1_MASK; + return UPM_SUCCESS; +} + +upm_result_t bh1792_set_ir_led_current(bh1792_context dev, uint8_t current) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(current > LED_CURRENT_MAX) + return UPM_ERROR_OUT_OF_RANGE; + + uint8_t status; + + status = bh1792_set_bits_with_mask(dev, BH1792_MEAS_CONTROL3, + current & BH1792_MEAS_CONTROL3_LED_CURRENT2_MASK, + BH1792_MEAS_CONTROL3_LED_CURRENT2_MASK); + if(status != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + dev->ir_current = current; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_get_ir_led_current(bh1792_context dev, uint8_t *current) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t data; + + if(bh1792_read_register(dev, BH1792_MEAS_CONTROL3, &data) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *current = data & BH1792_MEAS_CONTROL3_LED_CURRENT2_MASK; + return UPM_SUCCESS; +} + +upm_result_t bh1792_set_ir_threshold(bh1792_context dev, uint16_t threshold) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_write_register(dev, threshold, BH1792_MEAS_CONTROL4_L) != UPM_SUCCESS || + bh1792_write_register(dev, threshold >> 8, BH1792_MEAS_CONTROL4_H) != UPM_SUCCESS) { + printf("%s: Failed to write high threshold\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + dev->threshold = threshold; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_get_ir_threshold(bh1792_context dev, uint16_t *threshold) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t data[2]; + + if(bh1792_read_register(dev, BH1792_MEAS_CONTROL4_H, &data[1]) != UPM_SUCCESS || + bh1792_read_register(dev, BH1792_MEAS_CONTROL4_L, &data[0]) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *threshold = data[1] << 8 | data[0]; + return UPM_SUCCESS; +} + +upm_result_t bh1792_get_fifo_size(bh1792_context dev, uint8_t *count) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t fifo_count; + + if(bh1792_read_register(dev, BH1792_FIFO_LEV, &fifo_count) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *count = fifo_count & BH1792_FIFO_LEV_LEVEL_MASK; + return UPM_SUCCESS; +} + +static upm_result_t bh1792_set_interrupt_mode(bh1792_context dev, INTERRUPT_MODES int_mode) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_set_bits_with_mask(dev, BH1792_MEAS_CONTROL5, int_mode, + BH1792_MEAS_CONTROL5_INT_SEL_MASK) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + dev->interrupt_mode = int_mode; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_disable_interrupt(bh1792_context dev) +{ + return bh1792_set_bits_with_mask(dev, BH1792_MEAS_CONTROL5, 0, + BH1792_MEAS_CONTROL5_INT_SEL_MASK); +} + +upm_result_t bh1792_clear_interrupt(bh1792_context dev) +{ + uint8_t data; + return bh1792_read_register(dev, BH1792_INT_CLEAR, &data); +} + +static void *bh1792_sync_measurement(void *args) +{ + bh1792_context dev = (bh1792_context)args; + + dev->sync_thread_alive = true; + while(dev->sync_thread_alive) { + bh1792_set_bit_on(dev, BH1792_MEAS_SYNC, BH1792_MEAS_SYNC_MEAS_SYNC); + usleep(ONE_SEC_IN_MIRCO_SEC); + } + + return (void *)UPM_SUCCESS; +} + +upm_result_t bh1792_start_measurement(bh1792_context dev) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(dev->op_mode == SYNCHRONIZED) { + if(dev->sync_thread_alive) { + dev->sync_thread_alive = false; + pthread_join(dev->sync_thread, NULL); + } + pthread_create(&dev->sync_thread, NULL, &bh1792_sync_measurement, dev); + } + + if(bh1792_set_bit_on(dev, BH1792_MEAS_START, BH1792_MEAS_START_MEAS_ST) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + dev->enabled = true; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_stop_measurement(bh1792_context dev) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_soft_reset(dev) != UPM_SUCCESS) + return UPM_SUCCESS; + + dev->enabled = false; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_restart_measurement(bh1792_context dev) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t status; + + status = bh1792_stop_measurement(dev); + if(status != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(status != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + switch(dev->op_mode) { + case SYNCHRONIZED: + status = bh1792_enable_sync_mode(dev, dev->meas_freq, dev->green_current); + break; + case NON_SYNCHRONIZED: + status = bh1792_enable_non_sync_mode(dev, dev->ir_current, dev->threshold); + break; + case SINGLE_GREEN: + status = bh1792_enable_single_mode(dev, GREEN, dev->green_current); + break; + case SINGLE_IR: + status = bh1792_enable_single_mode(dev, IR, dev->ir_current); + break; + } + + if(status != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + return bh1792_start_measurement(dev); +} + +upm_result_t bh1792_get_fifo_data(bh1792_context dev, uint16_t fifo_led_off[], + uint16_t fifo_led_on[]) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(dev->op_mode != SYNCHRONIZED) + return UPM_ERROR_NO_DATA; + + uint8_t data[4]; + for(int i = 0; i < FIFO_WATERMARK; i++) { + if(bh1792_read_registers(dev, BH1792_FIFO_DATA0_L, data, 4) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + fifo_led_off[i] = data[1] << 8 | data[0]; + fifo_led_on[i] = data[3] << 8 | data[2]; + } + + return UPM_SUCCESS; +} + +upm_result_t bh1792_discard_fifo_data(bh1792_context dev) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t data[4]; + + for(int i = 0; i < FIFO_WATERMARK; i++) + bh1792_read_registers(dev, BH1792_FIFO_DATA0_L, data, 4); + + return UPM_SUCCESS; +} + +upm_result_t bh1792_get_green_data(bh1792_context dev, uint16_t *green_led_off, + uint16_t *green_led_on) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(dev->op_mode == NON_SYNCHRONIZED || dev->op_mode == SINGLE_IR) + return UPM_ERROR_NO_DATA; + + uint8_t data[4]; + + if(bh1792_read_registers(dev, BH1792_DATAOUT_LEDOFF_L, data, 4) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *green_led_off = data[1] << 8 | data[0]; + *green_led_on = data[3] << 8 | data[2]; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_get_ir_data(bh1792_context dev, uint16_t *ir_led_off, + uint16_t *ir_led_on) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(dev->op_mode != NON_SYNCHRONIZED && dev->op_mode != SINGLE_IR) + return UPM_ERROR_NO_DATA; + + uint8_t data[4]; + + if(bh1792_read_registers(dev, BH1792_IRDATA_LEDOFF_L, data, 4) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *ir_led_off = data[1] << 8 | data[0]; + *ir_led_on = data[3] << 8 | data[2]; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_enable_sync_mode(bh1792_context dev, uint16_t meas_freq, + uint8_t green_current) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t status; + + if(bh1792_set_rdy_bit(dev) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_set_green_leds_current(dev, green_current) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_select_led_type(dev, GREEN) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + status = bh1792_set_sync_meas_mode(dev, meas_freq); + if(status != UPM_SUCCESS) + return status; + + dev->op_mode = SYNCHRONIZED; + return bh1792_set_interrupt_mode(dev, WATER_MARK); +} + +upm_result_t bh1792_enable_non_sync_mode(bh1792_context dev, uint8_t ir_current, + uint16_t threshold) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_set_rdy_bit(dev) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_set_ir_led_current(dev, ir_current) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_select_led_type(dev, IR) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + if(bh1792_set_sync_meas_mode(dev, MSR_NON_SYNC) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + dev->op_mode = NON_SYNCHRONIZED; + return bh1792_set_interrupt_mode(dev, IR_THRESHOLD_JUDGE); +} + +upm_result_t bh1792_enable_single_mode(bh1792_context dev, LED_TYPES led_type, + uint8_t current) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_set_rdy_bit(dev) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(led_type == GREEN) { + if(bh1792_set_green_leds_current(dev, current) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + } else { + if(bh1792_set_ir_led_current(dev, current) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + } + + if(bh1792_select_led_type(dev, led_type) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(bh1792_set_sync_meas_mode(dev, MSR_SINGLE) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if(led_type == GREEN) + dev->op_mode = SINGLE_GREEN; + else + dev->op_mode = SINGLE_IR; + + return bh1792_set_interrupt_mode(dev, ON_COMPLETE); +} + +upm_result_t bh1792_install_isr(bh1792_context dev, mraa_gpio_edge_t edge, + int pin, void (*isr)(void *), void *isr_args) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + if(dev->isrEnabled) + bh1792_remove_isr(dev); + + mraa_gpio_context isr_gpio = NULL; + + if (!(isr_gpio = mraa_gpio_init(pin))) { + printf("%s: mraa_gpio_init() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + mraa_gpio_dir(isr_gpio, MRAA_GPIO_IN); + + if (mraa_gpio_isr(isr_gpio, edge, isr, isr_args) != MRAA_SUCCESS) { + mraa_gpio_close(isr_gpio); + printf("%s: mraa_gpio_isr() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + dev->interrupt = isr_gpio; + dev->isrEnabled = true; + + return UPM_SUCCESS; +} + +upm_result_t bh1792_install_isr_falling_edge(bh1792_context dev, int pin, + void (*isr)(void *), void *isr_args) +{ + return bh1792_install_isr(dev, MRAA_GPIO_EDGE_FALLING, pin, isr, isr_args); +} + +void bh1792_remove_isr(bh1792_context dev) +{ + if(dev) { + mraa_gpio_isr_exit(dev->interrupt); + mraa_gpio_close(dev->interrupt); + dev->interrupt = NULL; + dev->isrEnabled = false; + } +} + +upm_result_t bh1792_registers_dump(bh1792_context dev, char *dump) +{ + if(!dev) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t reg_values[10]; + int count = 0; + int len = 8; + + if(bh1792_read_registers(dev, BH1792_MEAS_CONTROL1, reg_values, len) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + count += snprintf(dump, 6, "0x41 "); + for(int i = 0; i < len; i++) + count += snprintf(dump + count, 4, "%02X ", reg_values[i]); + snprintf(dump + count - 1, 3, "\n"); + + len = 1; + if(bh1792_read_registers(dev, BH1792_FIFO_LEV, reg_values, len) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + count += snprintf(dump + count, 6, "0x4B "); + for(int i = 0; i < len; i++) + count += snprintf(dump + count, 4, "%02X ", reg_values[i]); + + return UPM_SUCCESS; +} diff -Nru upm-1.6.0/src/bh1792/bh1792.cxx upm-1.7.1/src/bh1792/bh1792.cxx --- upm-1.6.0/src/bh1792/bh1792.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1792/bh1792.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,305 @@ +/* +* 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 +#include +#include "bh1792.hpp" + +using namespace upm; + +BH1792::BH1792(int bus, int addr) : m_bh1792(bh1792_init(bus, addr)) +{ + if(!m_bh1792) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_init() failed"); +} + +BH1792::~BH1792() +{ + bh1792_close(m_bh1792); +} + +void BH1792::CheckWhoAmI() +{ + if(bh1792_check_who_am_i(m_bh1792) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_check_who_am_i() failed"); +} + +bool BH1792::IsEnabled() +{ + return bh1792_is_enabled(m_bh1792); +} + +void BH1792::SoftReset() +{ + if(bh1792_soft_reset(m_bh1792) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_soft_reset() failed"); +} + +float BH1792::GetMeasurementTimeMS() +{ + float meas_time; + + if(bh1792_get_meas_time_ms(m_bh1792, &meas_time) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_get_meas_time_ms() failed"); + + return meas_time; +} + +void BH1792::SetGreenLedsCurrent(uint16_t current) +{ + uint8_t status; + + status = bh1792_set_green_leds_current(m_bh1792, current); + if(status == UPM_ERROR_OUT_OF_RANGE) { + throw std::range_error(std::string(__FUNCTION__) + + "bh1792_set_green_leds_current() failed, current not in range"); + } else if(status != UPM_SUCCESS) { + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_set_green_leds_current() failed"); + } +} + +int BH1792::GetGreenLedsCurrent() +{ + uint8_t current; + + if(bh1792_get_green_leds_current(m_bh1792, ¤t) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_get_green_leds_current() failed"); + + return (int)current; +} + +void BH1792::SetIrLedCurrent(uint16_t current) +{ + uint8_t status; + + status = bh1792_set_ir_led_current(m_bh1792, current); + if(status == UPM_ERROR_OUT_OF_RANGE) { + throw std::range_error(std::string(__FUNCTION__) + + "bh1792_set_ir_led_current() failed, current not in range"); + } else if(status != UPM_SUCCESS) { + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_set_ir_led_current() failed"); + } +} + +int BH1792::GetIrLedCurrent() +{ + uint8_t current; + + if(bh1792_get_ir_led_current(m_bh1792, ¤t) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_get_ir_led_current() failed"); + + return (int)current; +} + +void BH1792::SetIrThreshold(uint16_t threshold) +{ + if(bh1792_set_ir_threshold(m_bh1792, threshold) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_set_ir_threshold() failed"); +} + +int BH1792::GetIrThreshold() +{ + uint16_t threshold; + + if(bh1792_get_ir_threshold(m_bh1792, &threshold) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_get_ir_threshold() failed"); + + return (int)threshold; +} + +int BH1792::GetFifoSize() +{ + uint8_t size; + + if(bh1792_get_fifo_size(m_bh1792, &size) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_get_fifo_size() failed"); + + return (int)size; +} + +void BH1792::DisableInterrupt() +{ + if(bh1792_disable_interrupt(m_bh1792) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_disable_interrupt() failed"); +} + +void BH1792::ClearInterrupt() +{ + if(bh1792_clear_interrupt(m_bh1792) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_clear_interrupt() failed"); +} + +void BH1792::StartMeasurement() +{ + if(bh1792_start_measurement(m_bh1792) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_start_measurement() failed"); +} + +void BH1792::StopMeasurement() +{ + if(bh1792_stop_measurement(m_bh1792) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_stop_measurement() failed"); +} + +void BH1792::RestartMeasurement() +{ + if(bh1792_restart_measurement(m_bh1792) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_restart_measurement() failed"); +} + +std::vector> BH1792::GetFifoData() +{ + uint16_t fifo_off[FIFO_WATERMARK], fifo_on[FIFO_WATERMARK]; + + if(bh1792_get_fifo_data(m_bh1792, fifo_off, fifo_on) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_get_fifo_data() failed"); + + std::vector item; + std::vector> result; + item.reserve(2); + result.reserve(FIFO_WATERMARK); + for(int i = 0; i < FIFO_WATERMARK; i++) { + item.clear(); + item.push_back(fifo_off[i]); + item.push_back(fifo_on[i]); + result.push_back(item); + } + + return result; +} + +void BH1792::DiscardFifoData() +{ + if(bh1792_discard_fifo_data(m_bh1792) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_discard_fifo_data() failed"); +} + +std::vector BH1792::GetGreenData() +{ + uint16_t green_off, green_on; + + if(bh1792_get_green_data(m_bh1792, &green_off, &green_on) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_get_green_data() failed"); + + std::vector result; + result.reserve(2); + result.push_back(green_off); + result.push_back(green_on); + + return result; +} + +std::vector BH1792::GetIrData() +{ + uint16_t ir_off, ir_on; + + if(bh1792_get_ir_data(m_bh1792, &ir_off, &ir_on) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_get_ir_data() failed"); + + std::vector result; + result.reserve(2); + result.push_back(ir_off); + result.push_back(ir_on); + + return result; +} + +void BH1792::EnableSyncMode(uint16_t measFreq, uint16_t green_current) +{ + uint8_t status; + + status = bh1792_enable_sync_mode(m_bh1792, measFreq, green_current); + if(status == UPM_ERROR_INVALID_PARAMETER) { + throw std::invalid_argument(std::string(__FUNCTION__) + + "bh1792_enable_sync_mode() failed, invalid measurement frequncy"); + } else if(status != UPM_SUCCESS) { + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_enable_sync_mode() failed"); + } +} + +void BH1792::EnableNonSyncMode(uint16_t ir_current, uint16_t threshold) +{ + if(bh1792_enable_non_sync_mode(m_bh1792, ir_current, threshold) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_enable_non_sync_mode() failed"); +} + +void BH1792::EnableSingleMode(LED_TYPES led_type, uint16_t current) +{ + if(bh1792_enable_single_mode(m_bh1792, led_type, current) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_enable_single_mode() failed"); +} + +void BH1792::InstallISR(mraa_gpio_edge_t edge, int pin, void (*isr)(void *), void *isr_args) +{ + if(bh1792_install_isr(m_bh1792, edge, pin, isr, isr_args) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_install_isr() failed"); +} + +void BH1792::InstallISR(int pin, void (*isr)(void *), void *isr_args) +{ + if(bh1792_install_isr_falling_edge(m_bh1792, pin, isr, isr_args) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_install_isr_falling_edge() failed"); +} + +void BH1792::RemoveISR() +{ + bh1792_remove_isr(m_bh1792); +} + +std::string BH1792::RegistersDump() +{ + char dump[255]; + std::string dumpStr; + + if(bh1792_registers_dump(m_bh1792, dump) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + + "bh1792_registers_dump() failed"); + dumpStr = dump; + return dumpStr; +} diff -Nru upm-1.6.0/src/bh1792/bh1792glc_registers.h upm-1.7.1/src/bh1792/bh1792glc_registers.h --- upm-1.6.0/src/bh1792/bh1792glc_registers.h 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1792/bh1792glc_registers.h 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,129 @@ +/* +The MIT License (MIT) +Copyright (c) 2017 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. +*/ + +#ifndef __BH1792GLC_REGISTERS_H__ +#define __BH1792GLC_REGISTERS_H__ +/* registers */ +#define BH1792_REGISTER_DUMP_START 0x0F +#define BH1792_MANUFACTURER_REG 0x0F +// WHO_AM_I -value +#define BH1792_PARTID_REG 0x10 +// Soft reset +#define BH1792_RESET 0x40 +// System control setting +#define BH1792_MEAS_CONTROL1 0x41 +// LED 1 & 2 control register +#define BH1792_MEAS_CONTROL2 0x42 +// LED 3 control register +#define BH1792_MEAS_CONTROL3 0x43 +// IR Interrupt Threshold Value [7:0] +#define BH1792_MEAS_CONTROL4_L 0x44 +// IR Interrupt Threshold Value [15:8] +#define BH1792_MEAS_CONTROL4_H 0x45 +#define BH1792_MEAS_CONTROL5 0x46 +#define BH1792_MEAS_START 0x47 +#define BH1792_MEAS_SYNC 0x48 +#define BH1792_FIFO_LEV 0x4B +// FIFO Output data 0 [7:0] +#define BH1792_FIFO_DATA0_L 0x4C +// FIFO Output data 0 [15:8] +#define BH1792_FIFO_DATA0_H 0x4D +// FIFO Output data 1 [7:0] +#define BH1792_FIFO_DATA1_L 0x4E +// FIFO Output data 1 [15:8] +#define BH1792_FIFO_DATA1_H 0x4F +// IR Data Count Value during no LED emission [7:0] +#define BH1792_IRDATA_LEDOFF_L 0x50 +// IR Data Count Value during no LED emission [15:8] +#define BH1792_IRDATA_LEDOFF_H 0x51 +// IR Data Count Value during LED emission [7:0] +#define BH1792_IRDATA_LEDON_L 0x52 +// IR Data Count Value during LED emission [15:8] +#define BH1792_IRDATA_LEDON_H 0x53 +// Green Data Count Value during no LED emission [7:0] +#define BH1792_DATAOUT_LEDOFF_L 0x54 +// Green Data Count Value during no LED emission [15:8] +#define BH1792_DATAOUT_LEDOFF_H 0x55 +// Green Data Count Value during LED emission [7:0] +#define BH1792_DATAOUT_LEDON_L 0x56 +// Green Data Count Value during LED emission [15:8] +#define BH1792_DATAOUT_LEDON_H 0x57 +// IR threshold judgement and measurement completion interrupt is cleared when reading this register. +#define BH1792_INT_CLEAR 0x58 +#define BH1792_REGISTER_DUMP_END 0x58 +/* registers bits */ +#define BH1792_MANUFACTURER_REG_MANUFACTURER_ID (0xE0 << 0) +#define BH1792_PARTID_REG_PART_ID (0x0E << 0) +// 1 : Software reset is performed +#define BH1792_RESET_SWRESET (0x01 << 7) +// 1 : OSC block is active, 0: prohibited +#define BH1792_MEAS_CONTROL1_RDY (0x01 << 7) +// Green mode, leds 1 & 2 active +#define BH1792_MEAS_CONTROL1_SEL_ADC_GREEN (0x00 << 4) +// IR mode, led 3 active. Can be used only in single and non synch modes. +#define BH1792_MEAS_CONTROL1_SEL_ADC_IR (0x01 << 4) +// 32 Hz synchronous mode +#define BH1792_MEAS_CONTROL1_MSR_32HZ (0x00 << 0) +// 128 Hz synchronous mode +#define BH1792_MEAS_CONTROL1_MSR_128HZ (0x01 << 0) +// 64 Hz synchronous mode +#define BH1792_MEAS_CONTROL1_MSR_64HZ (0x02 << 0) +// 256 Hz synchronous mode +#define BH1792_MEAS_CONTROL1_MSR_256HZ (0x03 << 0) +#define BH1792_MEAS_CONTROL1_MSR_PROHIBITED (0x04 << 0) +// 1024 Hz synchronous mode +#define BH1792_MEAS_CONTROL1_MSR_1024HZ (0x05 << 0) +// non synchronized measurement mode +#define BH1792_MEAS_CONTROL1_MSR_NON_SYNCH_MODE (0x06 << 0) +// single measurement mode +#define BH1792_MEAS_CONTROL1_MSR_SINGLE_MEAS_MODE (0x07 << 0) +// LED driver mode, for usage see datasheet +#define BH1792_MEAS_CONTROL3_LED_EN2 (0x01 << 7) +// No interrupt output. +#define BH1792_MEAS_CONTROL5_INT_SEL_DISABLE (0x00 << 0) +// Watermark interrupt FIFO, fires when number of stored samples reaches 32. Cleared when number of samples falls below 32. +#define BH1792_MEAS_CONTROL5_INT_SEL_FIFO_WATERMARK (0x01 << 0) +// IR threshold judgement interrupt. Used in non synchroniozed mode. +#define BH1792_MEAS_CONTROL5_INT_SEL_IR_THRESHOLD (0x02 << 0) +// Measurement completion interrupt. In single mode. +#define BH1792_MEAS_CONTROL5_INT_SEL_ON_COMPLETE (0x03 << 0) +// Flag of start measurement. MEAS_ST=1 after RDY=1 starts measurement. In single measurement mode MEAS_ST=1 restarts measurement. +#define BH1792_MEAS_START_MEAS_ST (0x01 << 0) +// Used in synhcronized measurement mode. Write once per second. +#define BH1792_MEAS_SYNC_MEAS_SYNC (0x01 << 0) + /*registers bit masks */ +#define BH1792_MANUFACTURER_REG_MANUFACTURER_MASK 0xFF +#define BH1792_PARTID_REG_PART_MASK 0xFF +// Select LED omitting frequency +#define BH1792_MEAS_CONTROL1_SEL_ADC_MASK 0x10 +// Measurement mode +#define BH1792_MEAS_CONTROL1_MSR_MASK 0x07 +#define BH1792_MEAS_CONTROL2_LED_EN1_MASK 0xC0 +#define BH1792_MEAS_CONTROL2_LED_CURRENT1_MASK 0x3F +#define BH1792_MEAS_CONTROL3_LED_CURRENT2_MASK 0x3F +// Interrupt function select +#define BH1792_MEAS_CONTROL5_INT_SEL_MASK 0x03 +#define BH1792_FIFO_LEV_LEVEL_MASK 0x3F +#endif + diff -Nru upm-1.6.0/src/bh1792/bh1792.h upm-1.7.1/src/bh1792/bh1792.h --- upm-1.6.0/src/bh1792/bh1792.h 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1792/bh1792.h 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,411 @@ +/* +* 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. +*/ + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include +#include +#include +#include +#include "bh1792glc_registers.h" + +/** + * @file bh1792.h + * @library bh1792 + * @brief C API for the bh1792 driver + * + * @include bh1792.c + */ + +#define ONE_SEC_IN_MIRCO_SEC 1000000 +#define FIFO_WATERMARK 32 +#define LED_CURRENT_MAX 63 + +/** + * @brief Measurement modes, for synchronized time modes, non synchronized + * and single modes. + */ +typedef enum { + MSR_64Hz = BH1792_MEAS_CONTROL1_MSR_64HZ, + MSR_32Hz = BH1792_MEAS_CONTROL1_MSR_32HZ, + MSR_128Hz = BH1792_MEAS_CONTROL1_MSR_128HZ, + MSR_256Hz = BH1792_MEAS_CONTROL1_MSR_256HZ, + MSR_1024Hz = BH1792_MEAS_CONTROL1_MSR_1024HZ, + MSR_NON_SYNC = BH1792_MEAS_CONTROL1_MSR_NON_SYNCH_MODE, + MSR_SINGLE = BH1792_MEAS_CONTROL1_MSR_SINGLE_MEAS_MODE +} MEAS_MODES; + +/** + * @brief LED light types + */ +typedef enum { + GREEN, + IR +} LED_TYPES; + +/** + * @brief Interrupt modes of the sensor + */ +typedef enum { + WATER_MARK = BH1792_MEAS_CONTROL5_INT_SEL_FIFO_WATERMARK, + IR_THRESHOLD_JUDGE = BH1792_MEAS_CONTROL5_INT_SEL_IR_THRESHOLD, + ON_COMPLETE = BH1792_MEAS_CONTROL5_INT_SEL_ON_COMPLETE +} INTERRUPT_MODES; + +/** + * @brief Operations modes available with the sensor + */ +typedef enum { + SYNCHRONIZED, + NON_SYNCHRONIZED, + SINGLE_GREEN, + SINGLE_IR +} OP_MODES; + +/** + * @brief bh1792 sensor context + */ +typedef struct _bh1792_context +{ + mraa_i2c_context i2c; + mraa_gpio_context interrupt; + bool enabled; + bool isrEnabled; + OP_MODES op_mode; + pthread_t sync_thread; + bool sync_thread_alive; + LED_TYPES led_type; + INTERRUPT_MODES interrupt_mode; + uint16_t meas_freq; + uint8_t green_current; + uint8_t ir_current; + uint16_t threshold; +} *bh1792_context; + +/** + * @brief Init the sensor with specific bus and address. Before starting + * measurement, one of (bh1792_enable_sync_mode, bh1792_enable_non_sync_mode, + * or bh1792_enable_single_mode) have to be called. + * + * @param bus I2C bus number + * @param addr I2C sensor address + * @return context of initialized sensor + */ +bh1792_context bh1792_init(int bus, int addr); + +/** + * @brief Close and free sensor context + * + * @param dev Sensor context + */ +void bh1792_close(bh1792_context dev); + +/** + * @brief Check "who am I" register value to identify the sensor + * + * @param dev Sensor context + * @return UPM result + */ +upm_result_t bh1792_check_who_am_i(bh1792_context dev); + +/** + * @brief Checks if the measuremnt on sensor is enabled + * + * @param The sensor context + * @return True if measurement is enabled, or false otherwise + */ +bool bh1792_is_enabled(bh1792_context dev); + +/** + * @brief Initiates a software reset to the sensor. All register values will + * be written to their defaults, thus intended operation mode need to be + * enabled. + * + * @param dev Sensor context + * @return UPM result + */ +upm_result_t bh1792_soft_reset(bh1792_context dev); + +/** + * @brief Gets the value of measurement time is milli-seconds + * + * @param dev The sensor context + * @param meas_time_ms Float pointer to store value of measurement time + * @return UPM result + */ +upm_result_t bh1792_get_meas_time_ms(bh1792_context dev, float *meas_time); + +/** + * @brief Sets the green LED Current value + * + * @param dev The sensor context + * @param current The current value, accepted values are between 0-63 + * @return UPM result + */ +upm_result_t bh1792_set_green_leds_current(bh1792_context dev, uint8_t current); + +/** + * @brief Gets the green LED current value + * + * @param dev The sensor context + * @param current Pointer to store the read current value + * @return UPM result + */ +upm_result_t bh1792_get_green_leds_current(bh1792_context dev, uint8_t *current); + +/** + * @brief Sets the IR LED Current value + * + * @param dev The sensor context + * @param current The current value, accepted values are between 0-63 + * @return UPM result + */ +upm_result_t bh1792_set_ir_led_current(bh1792_context dev, uint8_t current); + +/** + * @brief Gets the IR LED current value + * + * @param dev The sensor context + * @param current Pointer to store the read current value + * @return UPM result + */ +upm_result_t bh1792_get_ir_led_current(bh1792_context dev, uint8_t *current); + +/** + * @brief Sets interrupt ir threshold value for non-synchronized mode + * + * @param dev Sensor context + * @param threshold Value to be written, range 0-65536 + * @return UPM result + */ +upm_result_t bh1792_set_ir_threshold(bh1792_context dev, uint16_t threshold); + +/** + * @brief Gets interrupt ir threshold value + * + * @param dev Sensor context + * @param threshold Pointer (uint16_t) to write value + * @return UPM result + */ +upm_result_t bh1792_get_ir_threshold(bh1792_context dev, uint16_t *threshold); + +/** + * @brief Gets the current size of built-in FIFO + * + * @param dev The sensor context + * @param count The pointer to store the size + * @return UPM result + */ +upm_result_t bh1792_get_fifo_size(bh1792_context dev, uint8_t *count); + +/** + * @brief Disables interrupt function. Interrupt is enabled by default on all + * operation modes, so this have to be called after enabling a specific + * operation mode + * + * @param dev The sensor context + * @return UPM result + */ +upm_result_t bh1792_disable_interrupt(bh1792_context dev); + +/** + * @brief Clears the interrupt flag allowing more interrupts to be raised + * + * @param dev The sensor context + * @return UPM result + */ +upm_result_t bh1792_clear_interrupt(bh1792_context dev); + +/** + * @brief Starts the measuremnt on sensor or enable the sensor + * + * @param dev The sensor context + * @return UPM result + */ +upm_result_t bh1792_start_measurement(bh1792_context dev); + +/** + * @breif Stops the measurement by setting the software reset bit. This + * function will reset all config registers. To resume from previous + * configuration call bh1792_restart_measurement(). + * + * @param dev The sensor context + * @return UPM result + */ +upm_result_t bh1792_stop_measurement(bh1792_context dev); + +/** + * @brief Restart the measurement, This function stops measurement, then + * re-writes the configuration registers again and start measurement with same + * configuration. + * + * @param dev The sensor context + * @return UPM result + */ +upm_result_t bh1792_restart_measurement(bh1792_context dev); + +/** + * @brief Gets the fifo data of 32 entries and resets the WATERMARK interrupt + * flag. + * + * @param dev The sensor context + * @param fifo_led_off Array/Pointer to store 32 entries of fifo LED_OFF data + * @param fifo_led_on Array/Pointer to store 32 entries of fifo LED_ON data + * @return UPM result + */ +upm_result_t bh1792_get_fifo_data(bh1792_context dev, uint16_t fifo_led_off[], + uint16_t fifo_led_on[]); + +/** + * @brief Reads and discard the 32 FIFO entries to reset the WATERMARK + * interrupt flag. + * + * @param dev The sensor context + * @return UPM result + */ +upm_result_t bh1792_discard_fifo_data(bh1792_context dev); + +/** + * @brief Gets the values from using green LED light + * + * @param dev The sensor context + * @param green_led_off Pointer to store the reading value of LED_OFF + * @param green_led_on Pointer to store the reading value of LED_ON + * @return UPM result + */ +upm_result_t bh1792_get_green_data(bh1792_context dev, uint16_t *green_led_off, + uint16_t *green_led_on); + +/** + * @brief Gets the values from using IR LED light + * + * @param dev The sensor context + * @param ir_led_off Pointer to store the reading value of LED_OFF + * @param ir_led_on Pointer to store the reading value of LED_ON + * @return UPM result + */ +upm_result_t bh1792_get_ir_data(bh1792_context dev, uint16_t *ir_led_off, + uint16_t *ir_led_on); + +/** + * @brief Enables and configures the sensor to use synchronized mode. This will + * use the built-in FIFO and raises a WATERMARK interrupt when FIFO size + * reaches 32 entries. To clear that interrupt flag FIFO must be read or + * discarded. This mode uses only green LED. + * + * You need to call bh1792_start_measurement() after this. + * + * @param dev The sensor context + * @param meas_freq Measurement frequncy mode, valid values 32, 64, 128, 256, + * 1024 + * @param green_current Green LED current value + * @return UPM result + */ +upm_result_t bh1792_enable_sync_mode(bh1792_context dev, uint16_t meas_freq, + uint8_t green_current); + +/** + * @brief Enabled and configures the sensor to use non-synchronized mode. This + * mode uses IR_THRESHOLD interrupt, it will raise an interrupt if IR LED ON + * value is equal or greater than the threshold value. Interrupt must be + * cleared before receiving new interrupts. This mode uses only IR LED. + * + * You need to call bh1792_start_measurement() after this. + * + * @param dev The sensor context + * @param ir_current The IR LED current value + * @param threshold The IR LED interrupt threshold value + * @return UPM result + */ +upm_result_t bh1792_enable_non_sync_mode(bh1792_context dev, uint8_t ir_current, + uint16_t threshold); + +/** + * @brief Enables and configures the sensor to use single mode. This sets the + * sensor to take only one measurement and raise an interrupt after measurement + * is finished. Interrupt flags has to be cleared to recieved new interrupts. + * This mode uses both green and IR LEDs. + * + * You need to call bh1792_start_measurement() after this. If you need to get + * continuous values, clear interrupt and bh1792_start_measurement() + * continuously. + * + * @param dev The sensor context + * @param led_type LED light type to use, takes GREEN or IR values + * @param current The chosen led_type current value + * @return UPM result + */ +upm_result_t bh1792_enable_single_mode(bh1792_context dev, LED_TYPES led_type, + uint8_t current); + +/** + * @brief Installs the ISR to a given GPIO pin + * + * @param dev Sensor context + * @param edge Edge type to raise ISR with, of type mraa_gpio_edge_t + * @param pin GPIO pin number + * @param isr Pointer to ISR function + * @param isr_args Arguments to pass the ISR function + * @return UPM result + */ +upm_result_t bh1792_install_isr(bh1792_context dev, mraa_gpio_edge_t edge, + int pin, void (*isr)(void *), void *isr_args); + +/** + * @brief Installs the ISR to a given GPIO pin + * + * @param dev Sensor context + * @param pin GPIO pin number + * @param isr Pointer to ISR function + * @param isr_args Arguments to pass the ISR function + * @return UPM result + */ +upm_result_t bh1792_install_isr_falling_edge(bh1792_context dev, int pin, + void (*isr)(void *), void *isr_args); + +/** + * @brief Removes the ISR if it is installed + * + * @param dev Sensor context + */ +void bh1792_remove_isr(bh1792_context dev); + +/** + * @brief Gets a dump of configuration registers as a string + * + * @param dev Sensor context + * @param dump Pointer of char to save dump string + * @return UPM result + */ +upm_result_t bh1792_registers_dump(bh1792_context dev, char *dump); + +#ifdef __cplusplus +} +#endif diff -Nru upm-1.6.0/src/bh1792/bh1792.hpp upm-1.7.1/src/bh1792/bh1792.hpp --- upm-1.6.0/src/bh1792/bh1792.hpp 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1792/bh1792.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,324 @@ +/* +* 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. +*/ + +#pragma once + +#include +#include +#include "bh1792.h" + +/** + * @brief BH1792 Heart Rate Sensor + * @defgroup bh1792 libupm-bh1792 + * @ingroup rohm i2c medical + */ +/** + * @library bh1792 + * @sensor bh1792 + * @comname Heart Rate Sensor + * @type medical + * @man rohm + * @con i2c + * + * @brief C++ API for the bh1792 driver + * + * @snippet bh1792.cxx Interesting + */ + +namespace upm { + class BH1792 { + public: + + /** + * @brief Init the sensor with specific bus and address. Before + * starting measurement, one of (EnableSyncMode, EnableNonSyncMode, + * or EnableSingleMode) has to be called. + * + * @param bus I2C bus number + * @param addr I2C sensor address + * @throws std::runtime_error on initialization failure + */ + BH1792(int bus = 0, int addr = 0x5b); + + /** + * @brief Close and free sensor + */ + virtual ~BH1792(); + + /** + * @brief Check "who am I" register value to identify the sensor + * + * @throws std::runtime_error if this value is incorrect + */ + void CheckWhoAmI(); + + /** + * @brief Checks if the measuremnt on sensor is enabled + * + * @return True if measurement is enabled, or false otherwise + */ + bool IsEnabled(); + + /** + * @brief Initiates a software reset to the sensor. All register values + * will be written to their defaults, thus intended operation mode need + * to be enabled. + * + * @throws std::runtime_error if software reset fails + */ + void SoftReset(); + + /** + * @brief Gets the value of measurement time is milli-seconds + * + * @return measurement time float in milli-seconds + * @throws std::runtime_error if reading measurement time fails + */ + float GetMeasurementTimeMS(); + + /** + * @brief Sets the green LED Current value + * + * @param current The current value, accepted values are between 0-63 + * @throws std::runtime_error if setting current fails + * @throws std::range_error if current value out of range + */ + void SetGreenLedsCurrent(uint16_t current); + + /** + * @brief Gets the green LED current value + * + * @return Green LED used current + * @throws std::runtime_error if reading current fails + */ + int GetGreenLedsCurrent(); + + /** + * @brief Sets the IR LED Current value + * + * @param current The current value, accepted values are between 0-63 + * @throws std::runtime_error if setting current fails + * @throws std::range_error if current value out of range + */ + void SetIrLedCurrent(uint16_t current); + + /** + * @brief Gets the green LED current value + * + * @return Green LED used current + * @throws std::runtime_error if reading current fails + */ + int GetIrLedCurrent(); + + /** + * @brief Sets interrupt IR threshold value for non-synchronized mode + * + * @param threshold Value to be written, range 0-65536 + * @throws std::runtime_error if setting threshold fails + */ + void SetIrThreshold(uint16_t threshold); + + /** + * @brief Gets interrupt IR threshold value + * + * @return Green LED used current + * @throws std::runtime_error if reading current fails + */ + int GetIrThreshold(); + + /** + * @brief Gets the current size of built-in FIFO + * + * @return Number of entries store in FIFO + * @throws std::runtime_error if reading size fails + */ + int GetFifoSize(); + + /** + * @brief Disables interrupt function. Interrupt is enabled by default + * on all operation modes, so this have to be called after enabling a + * specific operation mode + * + * @throws std::runtime_error if setting interrupt disable bits fails + */ + void DisableInterrupt(); + + /** + * @brief Clears the interrupt flag allowing more interrupts to be + * raised + * + * @throws std::runtime_error if clearing interrupt fails + */ + void ClearInterrupt(); + + /** + * @brief Starts the measuremnt on sensor or enable the sensor + * + * @throws std::runtime_error if starting measurement fails + */ + void StartMeasurement(); + + /** + * @breif Stops the measurement by setting the software reset bit. This + * function will reset all config registers. To resume from previous + * configuration call RestartMeasurement(). + * + * @throws std::runtime_error if disabling measurement fails + */ + void StopMeasurement(); + + /** + * @brief Restart the measurement, This function stops measurement, + * then re-writes the configuration registers again and start + * measurement with same configuration. + * + * @throws std::runtime_error if restarting measurement fails + */ + void RestartMeasurement(); + + /** + * @brief Gets the fifo data of 32 entries and resets the WATERMARK + * interrupt flag. + * + * @return vector of values of the retrieved FIFO values, which are + * vectors containing 2 values each (led off, led_on) + * @throws std::runtime_error if reading FIFO data fails + */ + std::vector> GetFifoData(); + + /** + * @brief Reads and discard the 32 FIFO entries to reset the WATERMARK + * interrupt flag. + * + * @throws std::runtime_error if reading FIFO data fails + */ + void DiscardFifoData(); + + /** + * @brief Gets the values from using green LED light + * + * @return vector of values (led off, led on) of green led values + * @throws std::runtime_error if reading green data fails + */ + std::vector GetGreenData(); + + /** + * @brief Gets the values from using IR LED light + * + * @return vector of values (led off, led on) of IR led values + * @throws std::runtime_error if reading IR data fails + */ + std::vector GetIrData(); + + /** + * @brief Enables and configures the sensor to use synchronized mode. + * This will use the built-in FIFO and raises a WATERMARK interrupt + * when FIFO size reaches 32 entries. To clear that interrupt flag FIFO + * must be read or discarded. This mode uses only green LED. + * + * You need to call StartMeasurement() after this. + * + * @param measFreq Measurement frequncy mode, valid values 32, 64, 128, + * 256, 1024 + * @param green_current Green LED current value + * @throws std::runtime_error if enabling synchronized mode fails + * @throws std::invalid_argument if measurement frequency is invalid + */ + void EnableSyncMode(uint16_t measFreq, uint16_t green_current); + + /** + * @brief Enabled and configures the sensor to use non-synchronized + * mode. This mode uses IR_THRESHOLD interrupt, it will raise an + * interrupt if IR LED ON value is equal or greater than the threshold + * value. Interrupt must be cleared before receiving new interrupts. + * This mode uses only IR LED. + * + * You need to call StartMeasurement() after this. + * + * @param ir_current The IR LED current value + * @param threshold The IR LED interrupt threshold value + * + * @throws std::runtime_error if enabling non-synchronized mode fails + */ + void EnableNonSyncMode(uint16_t ir_current, uint16_t threshold); + + /** + * @brief Enables and configures the sensor to use single mode. This + * sets the sensor to take only one measurement and raise an interrupt + * after measurement is finished. Interrupt flags has to be cleared to + * recieved new interrupts. This mode uses both green and IR LEDs. + * + * You need to call StartMeasurement() after this. If you need to get + * continuous values, clear interrupt and StartMeasurement() + * continuously. + * + * @param led_type LED light type to use, takes GREEN or IR (0 or 1) + * @param current The chosen led_type current value + * @throws std::runtime_error if enabling single mode fails + */ + void EnableSingleMode(LED_TYPES led_type, uint16_t current); + + /** + * @brief Installs the ISR to a given GPIO pin + * + * @param edge Edge type to raise ISR with, of type mraa_gpio_edge_t + * @param pin GPIO pin number + * @param isr Pointer to ISR function + * @param isr_args Arguments to pass the ISR function + * @throws std::runtime_error if installing ISR fails + */ + void InstallISR(mraa_gpio_edge_t edge, int pin, void (*isr)(void *), + void *isr_args); + + /** + * @brief Installs the ISR to a given GPIO pin + * + * @param pin GPIO pin number + * @param isr Pointer to ISR function + * @param isr_args Arguments to pass the ISR function + * @throws std::runtime_error if installing ISR fails + */ + void InstallISR(int pin, void (*isr)(void *), void *isr_args); + + /** + * @brief Removes the ISR if it is installed + */ + void RemoveISR(); + + /** + * @brief Gets a dump of configuration registers as a string + * + * @return string of dumped registers + * @throws std::runtime_error if reading one of the registers fails + */ + std::string RegistersDump(); + + private: + bh1792_context m_bh1792; + + /* Disable implicit copy and assignment operators */ + BH1792(const BH1792 &) = delete; + BH1792 &operator=(const BH1792 &) = delete; + }; +} \ No newline at end of file diff -Nru upm-1.6.0/src/bh1792/bh1792.i upm-1.7.1/src/bh1792/bh1792.i --- upm-1.6.0/src/bh1792/bh1792.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1792/bh1792.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,28 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore InstallISR(mraa_gpio_edge_t, int, void *, void *); + +%extend upm::BH1792 { + void InstallISR(int pin, jobject runnable) + { + $self->InstallISR(pin, mraa_java_isr_callback, runnable); + } +} + +JAVA_JNI_LOADLIBRARY(javaupm_bh1792) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "std_vector.i" +%template(intVector) std::vector; +%template(intVector2D) std::vector>; + +%{ +#include "bh1792.hpp" +%} +%include "bh1792.h" +%include "bh1792.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bh1792/bh1792.json upm-1.7.1/src/bh1792/bh1792.json --- upm-1.6.0/src/bh1792/bh1792.json 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1792/bh1792.json 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,62 @@ +{ + "Library": "BH1792", + "Description": "ROHM BH1792 Heart Rate Sensor library", + "Sensor Class": { + "BH1792": { + "Name": "ROHM BH1792 Heart Rate Sensor library", + "Description": "BH1792GLC is optical sensor for heart rate monitor IC in which LED driver, green light and IR detection photodiode are incorporated. This device drives LED and provides the intensity of light reflected from body. LED brightness can be adjusted by LED driver current. The photodiode having the high sensitivity for green light and excellent wavelength selectivity achieves accurate pulse wave detection.", + "Categories": ["medical"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "commercial"], + "Manufacturers": ["ROHM"], + "Examples": { + "C++": ["bh1792.cxx"], + "C": ["bh1792.c"], + "Java": ["BH1792_Example.java"], + "Python": ["bh1792.py"], + "Node.js": ["bh1792.js"] + }, + "Specifications": { + "Supply Voltage (VDD)": { + "unit": "V", + "min": 2.5, + "typical": 3.0, + "max": 3.6 + }, + "Terminal Input Voltage": { + "unit": "V", + "min": 0.7, + "max": 5.5 + }, + "Supply Current": { + "unit": "uA", + "min": 0.8, + "max": 200 + }, + "LED Supply Current": { + "unit": "mA", + "typical": 1.4, + "max": 3.0 + }, + "Standby Mode Current": { + "unit": "uA", + "typical": 0.8, + "max": 1.5 + }, + "Operating Temperature": { + "unit": "°C", + "min": -20, + "max": 85 + } + }, + "Urls": { + "Product Pages": [ + "https://www.rohm.com/sensor-shield-support/heart-rate-sensor2" + ], + "Datasheets": [ + "https://www.rohm.com/datasheet/BH1792GLC/bh1792glc-e" + ] + } + } + } +} diff -Nru upm-1.6.0/src/bh1792/CMakeLists.txt upm-1.7.1/src/bh1792/CMakeLists.txt --- upm-1.6.0/src/bh1792/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bh1792/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,8 @@ +upm_mixed_module_init (NAME bh1792 + DESCRIPTION "ROHM Color Sensor" + C_HDR bh1792.h bh1792glc_registers.h + C_SRC bh1792.c + CPP_HDR bh1792.hpp + CPP_SRC bh1792.cxx + CPP_WRAPS_C + REQUIRES mraa) diff -Nru upm-1.6.0/src/biss0001/biss0001.json upm-1.7.1/src/biss0001/biss0001.json --- upm-1.6.0/src/biss0001/biss0001.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/biss0001/biss0001.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["tsk"], "Image": "biss0001.jpg", "Examples": { - "Java": ["BISS0001Sample.java"], + "Java": ["BISS0001_Example.java"], "Python": ["biss0001.py"], "Node.js": ["biss0001.js"], "C++": ["biss0001.cxx"], diff -Nru upm-1.6.0/src/biss0001/javaupm_biss0001.i upm-1.7.1/src/biss0001/javaupm_biss0001.i --- upm-1.6.0/src/biss0001/javaupm_biss0001.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/biss0001/javaupm_biss0001.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_biss0001 -%include "../upm.i" - -%{ - #include "biss0001.hpp" -%} - -%include "biss0001.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_biss0001) \ No newline at end of file diff -Nru upm-1.6.0/src/biss0001/jsupm_biss0001.i upm-1.7.1/src/biss0001/jsupm_biss0001.i --- upm-1.6.0/src/biss0001/jsupm_biss0001.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/biss0001/jsupm_biss0001.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_biss0001 -%include "../upm.i" - -%{ - #include "biss0001.hpp" -%} - -%include "biss0001.hpp" diff -Nru upm-1.6.0/src/biss0001/pyupm_biss0001.i upm-1.7.1/src/biss0001/pyupm_biss0001.i --- upm-1.6.0/src/biss0001/pyupm_biss0001.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/biss0001/pyupm_biss0001.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_biss0001 -%include "../upm.i" - -%include "biss0001.hpp" -%{ - #include "biss0001.hpp" -%} diff -Nru upm-1.6.0/src/bma220/bma220.i upm-1.7.1/src/bma220/bma220.i --- upm-1.6.0/src/bma220/bma220.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bma220/bma220.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,54 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" + +%apply int {mraa::Edge}; +%apply float *INOUT { float *x, float *y, float *z }; + +%typemap(jni) float* "jfloatArray" +%typemap(jstype) float* "float[]" +%typemap(jtype) float* "float[]" + +%typemap(javaout) float* { + return $jnicall; +} + +%typemap(out) float *getAccelerometer { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); + delete [] $1; +} + +%ignore getAccelerometer(float *, float *, float *); +%ignore installISR(int, mraa::Edge, void *, void *); + +%define GETTER get_gpioIntr(); +%enddef + +JAVA_ADD_INSTALLISR_GPIO(upm::BMA220) +JAVA_JNI_LOADLIBRARY(javaupm_bma220) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bma220.hpp" +%} +%include "bma220.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bma220/javaupm_bma220.i upm-1.7.1/src/bma220/javaupm_bma220.i --- upm-1.6.0/src/bma220/javaupm_bma220.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bma220/javaupm_bma220.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -%module javaupm_bma220 -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%apply int {mraa::Edge}; -%apply float *INOUT { float *x, float *y, float *z }; - -%typemap(jni) float* "jfloatArray" -%typemap(jstype) float* "float[]" -%typemap(jtype) float* "float[]" - -%typemap(javaout) float* { - return $jnicall; -} - -%typemap(out) float *getAccelerometer { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); - delete [] $1; -} - -%ignore getAccelerometer(float *, float *, float *); - -%{ - #include "bma220.hpp" -%} - -%include "bma220.hpp" - -%define GETTER get_gpioIntr(); -%enddef -JAVA_ADD_INSTALLISR_GPIO(upm::BMA220) - -%ignore installISR(int, mraa::Edge, void *, void *); - -JAVA_JNI_LOADLIBRARY(javaupm_bma220) diff -Nru upm-1.6.0/src/bma220/jsupm_bma220.i upm-1.7.1/src/bma220/jsupm_bma220.i --- upm-1.6.0/src/bma220/jsupm_bma220.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bma220/jsupm_bma220.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module jsupm_bma220 -%include "../upm.i" -%include "cpointer.i" - -%pointer_functions(float, floatp); - -%include "bma220.hpp" -%{ - #include "bma220.hpp" -%} - diff -Nru upm-1.6.0/src/bma220/pyupm_bma220.i upm-1.7.1/src/bma220/pyupm_bma220.i --- upm-1.6.0/src/bma220/pyupm_bma220.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bma220/pyupm_bma220.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bma220 -%include "../upm.i" -%include "cpointer.i" - -%include "stdint.i" - -%pointer_functions(float, floatp); - -%include "bma220.hpp" -%{ - #include "bma220.hpp" -%} - diff -Nru upm-1.6.0/src/bma250e/bma250e.i upm-1.7.1/src/bma250e/bma250e.i --- upm-1.6.0/src/bma250e/bma250e.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bma250e/bma250e.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../upm_javastdvector.i" + +%ignore getAccelerometer(float *, float *, float *); +%ignore installISR (BMA250E_INTERRUPT_PINS_T, int, mraa::Edge , void *, void *); + +%typemap(javaimports) SWIGTYPE %{ +import java.util.AbstractList; +import java.lang.Float; +%} + +%typemap(javaout) upm::BMA250E { + return new $&javaclassname($jnicall, true); +} +%typemap(javaout) std::vector { + return (AbstractList)(new $&javaclassname($jnicall, true)); +} +%typemap(jstype) std::vector "AbstractList" + +%template(floatVector) std::vector; + +%define INTERRUPT BMA250E_INTERRUPT_PINS_T +%enddef + +JAVA_ADD_INSTALLISR_INTERRUPT(upm::BMA250E) +JAVA_JNI_LOADLIBRARY(javaupm_bma250e) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bma250e_defs.h" +#include "bma250e.hpp" +%} +%include "bma250e_defs.h" +%include "bma250e.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bma250e/javaupm_bma250e.i upm-1.7.1/src/bma250e/javaupm_bma250e.i --- upm-1.6.0/src/bma250e/javaupm_bma250e.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bma250e/javaupm_bma250e.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -%module javaupm_bma250e -%include "../upm.i" -%include "typemaps.i" -%include "../upm_javastdvector.i" - -%ignore getAccelerometer(float *, float *, float *); - -%typemap(javaimports) SWIGTYPE %{ -import java.util.AbstractList; -import java.lang.Float; -%} - -%typemap(javaout) upm::BMA250E { - return new $&javaclassname($jnicall, true); -} -%typemap(javaout) std::vector { - return (AbstractList)(new $&javaclassname($jnicall, true)); -} -%typemap(jstype) std::vector "AbstractList" - -%template(floatVector) std::vector; - -%{ - #include "bma250e.hpp" - #include "bma250e_defs.h" -%} -%include "bma250e_defs.h" -%include "bma250e.hpp" - - -%ignore installISR (BMA250E_INTERRUPT_PINS_T, int, mraa::Edge , void *, void *); - -%define INTERRUPT BMA250E_INTERRUPT_PINS_T -%enddef -JAVA_ADD_INSTALLISR_INTERRUPT(upm::BMA250E) - - -JAVA_JNI_LOADLIBRARY(javaupm_bma250e) diff -Nru upm-1.6.0/src/bma250e/jsupm_bma250e.i upm-1.7.1/src/bma250e/jsupm_bma250e.i --- upm-1.6.0/src/bma250e/jsupm_bma250e.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bma250e/jsupm_bma250e.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module jsupm_bma250e -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to JavaScript as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "bma250e_defs.h" -%include "bma250e.hpp" -%{ - #include "bma250e.hpp" -%} diff -Nru upm-1.6.0/src/bma250e/pyupm_bma250e.i upm-1.7.1/src/bma250e/pyupm_bma250e.i --- upm-1.6.0/src/bma250e/pyupm_bma250e.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bma250e/pyupm_bma250e.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bma250e -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to python as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "bma250e_defs.h" -%include "bma250e.hpp" -%{ - #include "bma250e.hpp" -%} diff -Nru upm-1.6.0/src/bmg160/bmg160.i upm-1.7.1/src/bmg160/bmg160.i --- upm-1.6.0/src/bmg160/bmg160.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bmg160/bmg160.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../upm_javastdvector.i" + +%ignore installISR (BMG160_INTERRUPT_PINS_T , int mraa::Edge , void *, void *); +%ignore getGyroscope(float *, float *, float *); + +%typemap(javaimports) SWIGTYPE %{ +import java.util.AbstractList; +import java.lang.Float; +%} + +%typemap(javaout) SWIGTYPE { + return new $&javaclassname($jnicall, true); +} +%typemap(javaout) std::vector { + return (AbstractList)(new $&javaclassname($jnicall, true)); +} +%typemap(jstype) std::vector "AbstractList" + +%template(floatVector) std::vector; + +%define INTERRUPT BMG160_INTERRUPT_PINS_T +%enddef + +JAVA_ADD_INSTALLISR_INTERRUPT(upm::BMG160) +JAVA_JNI_LOADLIBRARY(javaupm_bmg160) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bmg160_defs.h" +#include "bmg160.hpp" +%} +%include "bmg160_defs.h" +%include "bmg160.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bmg160/javaupm_bmg160.i upm-1.7.1/src/bmg160/javaupm_bmg160.i --- upm-1.6.0/src/bmg160/javaupm_bmg160.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmg160/javaupm_bmg160.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -%module javaupm_bmg160 -%include "../upm.i" -%include "typemaps.i" -%include "../upm_javastdvector.i" - -%ignore getGyroscope(float *, float *, float *); - -%typemap(javaimports) SWIGTYPE %{ -import java.util.AbstractList; -import java.lang.Float; -%} - -%typemap(javaout) SWIGTYPE { - return new $&javaclassname($jnicall, true); -} -%typemap(javaout) std::vector { - return (AbstractList)(new $&javaclassname($jnicall, true)); -} -%typemap(jstype) std::vector "AbstractList" - -%template(floatVector) std::vector; - -%{ - #include "bmg160.hpp" - #include "bmg160_defs.h" -%} -%include "bmg160_defs.h" -%include "bmg160.hpp" - - -%ignore installISR (BMG160_INTERRUPT_PINS_T , int mraa::Edge , void *, void *); - -%define INTERRUPT BMG160_INTERRUPT_PINS_T -%enddef -JAVA_ADD_INSTALLISR_INTERRUPT(upm::BMG160) - -JAVA_JNI_LOADLIBRARY(javaupm_bmg160) diff -Nru upm-1.6.0/src/bmg160/jsupm_bmg160.i upm-1.7.1/src/bmg160/jsupm_bmg160.i --- upm-1.6.0/src/bmg160/jsupm_bmg160.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmg160/jsupm_bmg160.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module jsupm_bmg160 -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to JavaScript as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "bmg160_defs.h" -%include "bmg160.hpp" -%{ - #include "bmg160.hpp" -%} diff -Nru upm-1.6.0/src/bmg160/pyupm_bmg160.i upm-1.7.1/src/bmg160/pyupm_bmg160.i --- upm-1.6.0/src/bmg160/pyupm_bmg160.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmg160/pyupm_bmg160.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bmg160 -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to python as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "bmg160_defs.h" -%include "bmg160.hpp" -%{ - #include "bmg160.hpp" -%} diff -Nru upm-1.6.0/src/bmi160/bmi160.i upm-1.7.1/src/bmi160/bmi160.i --- upm-1.6.0/src/bmi160/bmi160.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bmi160/bmi160.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,48 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i" +%include "../java_buffer.i" + +%typemap(jni) float * "jfloatArray" +%typemap(jstype) float * "float[]" +%typemap(jtype) float * "float[]" + +%typemap(javaout) float * { + return $jnicall; +} + +%typemap(out) float * { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); +} + +%ignore getAccelerometer(float *, float *, float *); +%ignore getGyroscope(float *, float *, float *); +%ignore getMagnetometer(float *, float *, float *); + +JAVA_JNI_LOADLIBRARY(javaupm_bmi160) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bmi160_defs.h" +#include "bmi160.hpp" +%} +%include "bmi160_defs.h" +%include "bmi160.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bmi160/javaupm_bmi160.i upm-1.7.1/src/bmi160/javaupm_bmi160.i --- upm-1.6.0/src/bmi160/javaupm_bmi160.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmi160/javaupm_bmi160.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -%module javaupm_bmi160 -%include "../upm.i" -%include "typemaps.i" -%include "arrays_java.i" -%include "../java_buffer.i" -%include "std_string.i" - -%include "bmi160_defs.h" -%{ - #include "bmi160.hpp" -%} - - -%typemap(jni) float * "jfloatArray" -%typemap(jstype) float * "float[]" -%typemap(jtype) float * "float[]" - -%typemap(javaout) float * { - return $jnicall; -} - -%typemap(out) float * { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); -} - -%ignore getAccelerometer(float *, float *, float *); -%ignore getGyroscope(float *, float *, float *); -%ignore getMagnetometer(float *, float *, float *); - -%include "bmi160.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_bmi160) diff -Nru upm-1.6.0/src/bmi160/jsupm_bmi160.i upm-1.7.1/src/bmi160/jsupm_bmi160.i --- upm-1.6.0/src/bmi160/jsupm_bmi160.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmi160/jsupm_bmi160.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module jsupm_bmi160 -%include "../upm.i" -%include "cpointer.i" -%include "std_string.i" - -%pointer_functions(float, floatp); - -%include "bmi160_defs.h" -%include "bmi160.hpp" -%{ - #include "bmi160.hpp" -%} diff -Nru upm-1.6.0/src/bmi160/pyupm_bmi160.i upm-1.7.1/src/bmi160/pyupm_bmi160.i --- upm-1.6.0/src/bmi160/pyupm_bmi160.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmi160/pyupm_bmi160.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bmi160 -%include "../upm.i" -%include "cpointer.i" -%include "std_string.i" - -%include "stdint.i" - -%pointer_functions(float, floatp); - -%include "bmi160_defs.h" -%include "bmi160.hpp" -%{ - #include "bmi160.hpp" -%} diff -Nru upm-1.6.0/src/bmm150/bmm150.i upm-1.7.1/src/bmm150/bmm150.i --- upm-1.6.0/src/bmm150/bmm150.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bmm150/bmm150.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,57 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../upm_javastdvector.i" + +%ignore getMagnetometer(float *, float *, float *); + +%typemap(javaimports) SWIGTYPE %{ +import java.util.AbstractList; +import java.lang.Float; +%} + +%typemap(javaout) SWIGTYPE { + return new $&javaclassname($jnicall, true); +} +%typemap(javaout) std::vector { + return (AbstractList)(new $&javaclassname($jnicall, true)); +} +%typemap(jstype) std::vector "AbstractList" + +%template(floatVector) std::vector; + +%ignore installISR (BMM150_INTERRUPT_PINS_T , int , mraa::Edge , void *, void *); + +%define INTERRUPT BMM150_INTERRUPT_PINS_T +%enddef +JAVA_ADD_INSTALLISR_INTERRUPT(upm::BMM150) + +JAVA_JNI_LOADLIBRARY(javaupm_bmm150) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bmm150_defs.h" +#include "bmm150.hpp" +%} +%include "bmm150_defs.h" +%include "bmm150.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bmm150/bmm150.json upm-1.7.1/src/bmm150/bmm150.json --- upm-1.6.0/src/bmm150/bmm150.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmm150/bmm150.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,46 +1,46 @@ -{ - "Library": "bmx050", - "Description": "Bosch 3-axis Magnetometer", - "Sensor Class": - { - "BMM150": - { - "Name": "3-axis Geomagnetic Sensor", - "Description": "The BMM150 is a standalone geomagnetic sensor for consumer market applications. It allows measurements of the magnetic field in three perpendicular axes. Based on Bosch's proprietary FlipCore technology, performance and features of BMM150 are carefully tuned and perfectly match the demanding requirements of all 3-axis mobile applications such as electronic compass, navigation or augmented reality. An evaluation circuitry (ASIC) converts the output of the geomagnetic sensor to digital results which can be read out over the industry standard digital interfaces (SPI and I2C). Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", - "Aliases": ["bme280"], - "Categories": ["pressure", "humidity", "temperature"], - "Connections": ["gpio", "i2c", "spi"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["bosch"], - "Kits": [], - "Examples": - { - "Java": ["BMM150_Example.java"], - "Python": ["bmm150.py"], - "Node.js": ["bmm150.js"], - "C++": ["bmm150.cxx"], - "C": ["bmm150.c"] - }, - "Specifications": - { - "Vdd": {"unit": "v", "low" : 1.62, "high": 3.6}, - "Temperature Range": {"unit": "degC", "low" : -40, "high": 85}, - "Sensing Range": {"unit": "uT (±)", "low": 1300, "high": 2500} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.bosch-sensortec.com/bst/products/all_products/bmm150"], - "Datasheets": ["https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMM150-DS001-01.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "bmx050", + "Description": "Bosch 3-axis Magnetometer", + "Sensor Class": + { + "BMM150": + { + "Name": "3-axis Geomagnetic Sensor", + "Description": "The BMM150 is a standalone geomagnetic sensor for consumer market applications. It allows measurements of the magnetic field in three perpendicular axes. Based on Bosch's proprietary FlipCore technology, performance and features of BMM150 are carefully tuned and perfectly match the demanding requirements of all 3-axis mobile applications such as electronic compass, navigation or augmented reality. An evaluation circuitry (ASIC) converts the output of the geomagnetic sensor to digital results which can be read out over the industry standard digital interfaces (SPI and I2C). Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", + "Aliases": ["bme280"], + "Categories": ["pressure", "humidity", "temperature"], + "Connections": ["gpio", "i2c", "spi"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["bosch"], + "Kits": [], + "Examples": + { + "Java": ["BMM150_Example.java"], + "Python": ["bmm150.py"], + "Node.js": ["bmm150.js"], + "C++": ["bmm150.cxx"], + "C": ["bmm150.c"] + }, + "Specifications": + { + "Vdd": {"unit": "v", "low" : 1.62, "high": 3.6}, + "Temperature Range": {"unit": "degC", "low" : -40, "high": 85}, + "Sensing Range": {"unit": "uT (±)", "low": 1300, "high": 2500} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.bosch-sensortec.com/bst/products/all_products/bmm150"], + "Datasheets": ["https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMM150-DS001-01.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/bmm150/javaupm_bmm150.i upm-1.7.1/src/bmm150/javaupm_bmm150.i --- upm-1.6.0/src/bmm150/javaupm_bmm150.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmm150/javaupm_bmm150.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -%module javaupm_bmm150 -%include "../upm.i" -%include "typemaps.i" -%include "../upm_javastdvector.i" - -%ignore getMagnetometer(float *, float *, float *); - -%typemap(javaimports) SWIGTYPE %{ -import java.util.AbstractList; -import java.lang.Float; -%} - -%typemap(javaout) SWIGTYPE { - return new $&javaclassname($jnicall, true); -} -%typemap(javaout) std::vector { - return (AbstractList)(new $&javaclassname($jnicall, true)); -} -%typemap(jstype) std::vector "AbstractList" - -%template(floatVector) std::vector; - -%{ - #include "bmm150.hpp" - #include "bmm150_defs.h" -%} -%include "bmm150_defs.h" -%include "bmm150.hpp" - -%ignore installISR (BMM150_INTERRUPT_PINS_T , int , mraa::Edge , void *, void *); - -%define INTERRUPT BMM150_INTERRUPT_PINS_T -%enddef -JAVA_ADD_INSTALLISR_INTERRUPT(upm::BMM150) - -JAVA_JNI_LOADLIBRARY(javaupm_bmm150) diff -Nru upm-1.6.0/src/bmm150/jsupm_bmm150.i upm-1.7.1/src/bmm150/jsupm_bmm150.i --- upm-1.6.0/src/bmm150/jsupm_bmm150.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmm150/jsupm_bmm150.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module jsupm_bmm150 -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to JavaScript as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "bmm150_defs.h" -%include "bmm150.hpp" -%{ - #include "bmm150.hpp" -%} diff -Nru upm-1.6.0/src/bmm150/pyupm_bmm150.i upm-1.7.1/src/bmm150/pyupm_bmm150.i --- upm-1.6.0/src/bmm150/pyupm_bmm150.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmm150/pyupm_bmm150.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bmm150 -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to python as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "bmm150_defs.h" -%include "bmm150.hpp" -%{ - #include "bmm150.hpp" -%} diff -Nru upm-1.6.0/src/bmp280/bmp280.i upm-1.7.1/src/bmp280/bmp280.i --- upm-1.6.0/src/bmp280/bmp280.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bmp280/bmp280.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%import "../interfaces/javaupm_iTemperatureSensor.i" +%import "../interfaces/javaupm_iHumiditySensor.i" +%import "../interfaces/javaupm_iPressureSensor.i" + +%include "arrays_java.i"; +%include "../java_buffer.i" + +%typemap(javaimports) SWIGTYPE %{ + import upm_interfaces.*; +%} + +JAVA_JNI_LOADLIBRARY(javaupm_bmp280) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "iModuleStatus.hpp" +%include "iTemperatureSensor.hpp" +%include "iPressureSensor.hpp" +%include "iHumiditySensor.hpp" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "iModuleStatus.hpp" +%include "iTemperatureSensor.hpp" +%include "iPressureSensor.hpp" +%include "iHumiditySensor.hpp" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bmp280_regs.h" +#include "bmp280.hpp" +#include "bme280.hpp" +%} +%include "bmp280_regs.h" +%include "bmp280.hpp" +%include "bme280.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bmp280/javaupm_bmp280.i upm-1.7.1/src/bmp280/javaupm_bmp280.i --- upm-1.6.0/src/bmp280/javaupm_bmp280.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmp280/javaupm_bmp280.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -%module javaupm_bmp280 - -%import "../interfaces/javaupm_iTemperatureSensor.i" -%import "../interfaces/javaupm_iHumiditySensor.i" -%import "../interfaces/javaupm_iPressureSensor.i" - - -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%typemap(javaimports) SWIGTYPE %{ - import upm_interfaces.*; -%} - -%include "bmp280_regs.h" -%include "bmp280.hpp" -%{ - #include "bmp280.hpp" -%} - -%include "bme280.hpp" -%{ - #include "bme280.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_bmp280) diff -Nru upm-1.6.0/src/bmp280/jsupm_bmp280.i upm-1.7.1/src/bmp280/jsupm_bmp280.i --- upm-1.6.0/src/bmp280/jsupm_bmp280.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmp280/jsupm_bmp280.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -%module jsupm_bmp280 -%include "../upm.i" -%include "cpointer.i" - -%include "iModuleStatus.hpp" -%include "iHumiditySensor.hpp" -%include "iPressureSensor.hpp" -%include "iTemperatureSensor.hpp" - -%include "bmp280_regs.h" -%include "bmp280.hpp" -%{ - #include "bmp280.hpp" -%} - -%include "bme280.hpp" -%{ - #include "bme280.hpp" -%} diff -Nru upm-1.6.0/src/bmp280/pyupm_bmp280.i upm-1.7.1/src/bmp280/pyupm_bmp280.i --- upm-1.6.0/src/bmp280/pyupm_bmp280.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmp280/pyupm_bmp280.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bmp280 -%include "../upm.i" -%include "cpointer.i" - -%include "stdint.i" - -%include "iModuleStatus.hpp" -%include "iHumiditySensor.hpp" -%include "iPressureSensor.hpp" -%include "iTemperatureSensor.hpp" - -%include "bmp280_regs.h" -%include "bmp280.hpp" -%{ - #include "bmp280.hpp" -%} - -%include "bme280.hpp" -%{ - #include "bme280.hpp" -%} diff -Nru upm-1.6.0/src/bmpx8x/bmpx8x.i upm-1.7.1/src/bmpx8x/bmpx8x.i --- upm-1.6.0/src/bmpx8x/bmpx8x.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bmpx8x/bmpx8x.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,28 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%import "../interfaces/javaupm_iPressureSensor.i" +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} +%import "../interfaces/javaupm_iTemperatureSensor.i" + +JAVA_JNI_LOADLIBRARY(javaupm_bmpx8x) +#endif +/* END Java syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "iModuleStatus.hpp" +%include "iTemperatureSensor.hpp" +%include "iPressureSensor.hpp" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bmpx8x_defs.h" +#include "bmpx8x.hpp" +%} +%include "bmpx8x_defs.h" +%include "bmpx8x.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bmpx8x/bmpx8x.json upm-1.7.1/src/bmpx8x/bmpx8x.json --- upm-1.6.0/src/bmpx8x/bmpx8x.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmpx8x/bmpx8x.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,49 +1,49 @@ -{ - "Library": "bmpx8x", - "Description": "BMP Atmospheric Pressure Sensor", - "Sensor Class": - { - "BMPX8X": - { - "Name": "BMP Atmospheric Pressure Sensor", - "Description": "The BME280 is as combined digital humidity, pressure and temperature sensor based on proven sensing principles. The sensor module is housed in an extremely compact metal-lid LGA package with a footprint of only 2.5 * 2.5 mm2 with a height of 0.93 mm. Its small dimensions and its low power consumption allow the implementation in battery driven devices such as handsets, GPS modules or watches. The BME280 is register and performance compatible to the Bosch Sensortec BMP280 digital pressure sensor", - "Aliases": ["bmpx8x"], - "Categories": ["pressure"], - "Connections": ["i2c"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["seeed", "adafruit", "sparkfun"], - "Kits": [], - "Examples": - { - "Java": ["BMPX8XSample.java"], - "Python": ["bmpx8x.py"], - "Node.js": ["bmpx8x.js"], - "C++": ["bmpx8x.cxx"], - "C": ["bmpx8x.c"] - }, - "Specifications": - { - "Vdd": {"unit": "v", "low" : 1.8, "high": 3.6}, - "Supply Current": {"unit": "uA", "low": 3, "high": 32}, - "Peak Current": {"unit": "uA", "low": 650, "high": 1000}, - "Standby Current": {"unit": "uA", "low": 0.1, "high": 0.1}, - "Pressure Range": {"unit": "hPa", "low" : 300, "high": 1100}, - "Temperature Range": {"unit": "C", "low" : -40, "high": 85} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.adafruit.com/product/1900"], - "Datasheets": ["https://cdn-shop.adafruit.com/datasheets/1900_BMP183.pdf", "https://www.sparkfun.com/datasheets/Components/General/BST-BMP085-DS000-05.pdf"], - "Schematics": ["https://learn.adafruit.com/adafruit-bmp183-spi-barometric-pressure-and-altitude-sensor/downloads#schematic"] - } - } - } -} +{ + "Library": "bmpx8x", + "Description": "BMP Atmospheric Pressure Sensor", + "Sensor Class": + { + "BMPX8X": + { + "Name": "BMP Atmospheric Pressure Sensor", + "Description": "The BME280 is as combined digital humidity, pressure and temperature sensor based on proven sensing principles. The sensor module is housed in an extremely compact metal-lid LGA package with a footprint of only 2.5 * 2.5 mm2 with a height of 0.93 mm. Its small dimensions and its low power consumption allow the implementation in battery driven devices such as handsets, GPS modules or watches. The BME280 is register and performance compatible to the Bosch Sensortec BMP280 digital pressure sensor", + "Aliases": ["bmpx8x"], + "Categories": ["pressure"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["seeed", "adafruit", "sparkfun"], + "Kits": [], + "Examples": + { + "Java": ["BMPX8X_Example.java"], + "Python": ["bmpx8x.py"], + "Node.js": ["bmpx8x.js"], + "C++": ["bmpx8x.cxx"], + "C": ["bmpx8x.c"] + }, + "Specifications": + { + "Vdd": {"unit": "v", "low" : 1.8, "high": 3.6}, + "Supply Current": {"unit": "uA", "low": 3, "high": 32}, + "Peak Current": {"unit": "uA", "low": 650, "high": 1000}, + "Standby Current": {"unit": "uA", "low": 0.1, "high": 0.1}, + "Pressure Range": {"unit": "hPa", "low" : 300, "high": 1100}, + "Temperature Range": {"unit": "C", "low" : -40, "high": 85} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.adafruit.com/product/1900"], + "Datasheets": ["https://cdn-shop.adafruit.com/datasheets/1900_BMP183.pdf", "https://www.sparkfun.com/datasheets/Components/General/BST-BMP085-DS000-05.pdf"], + "Schematics": ["https://learn.adafruit.com/adafruit-bmp183-spi-barometric-pressure-and-altitude-sensor/downloads#schematic"] + } + } + } +} diff -Nru upm-1.6.0/src/bmpx8x/javaupm_bmpx8x.i upm-1.7.1/src/bmpx8x/javaupm_bmpx8x.i --- upm-1.6.0/src/bmpx8x/javaupm_bmpx8x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmpx8x/javaupm_bmpx8x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -%module javaupm_bmpx8x -%include "../upm.i" - -%import "../interfaces/javaupm_iTemperatureSensor.i" -%import "../interfaces/javaupm_iPressureSensor.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%{ - #include "bmpx8x.hpp" -%} - -%include "bmpx8x_defs.h" -%include "bmpx8x.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_bmpx8x) diff -Nru upm-1.6.0/src/bmpx8x/jsupm_bmpx8x.i upm-1.7.1/src/bmpx8x/jsupm_bmpx8x.i --- upm-1.6.0/src/bmpx8x/jsupm_bmpx8x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmpx8x/jsupm_bmpx8x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_bmpx8x -%include "../upm.i" - -%{ - #include "bmpx8x.hpp" -%} - -%include "bmpx8x_defs.h" -%include "bmpx8x.hpp" diff -Nru upm-1.6.0/src/bmpx8x/pyupm_bmpx8x.i upm-1.7.1/src/bmpx8x/pyupm_bmpx8x.i --- upm-1.6.0/src/bmpx8x/pyupm_bmpx8x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmpx8x/pyupm_bmpx8x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bmpx8x -%include "../upm.i" - -%include "stdint.i" - -%include "bmpx8x_defs.h" -%include "bmpx8x.hpp" -%{ - #include "bmpx8x.hpp" -%} - diff -Nru upm-1.6.0/src/bmx055/bmx055.i upm-1.7.1/src/bmx055/bmx055.i --- upm-1.6.0/src/bmx055/bmx055.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bmx055/bmx055.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,65 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../upm_javastdvector.i" + +%apply int {mraa::Edge}; + +%ignore getAccelerometer(float *, float *, float *); +%ignore getMagnetometer(float *, float *, float *); +%ignore getGyroscope(float *, float *, float *); + +%typemap(javaimports) SWIGTYPE %{ +import java.util.AbstractList; +import java.lang.Float; +%} + +%typemap(javaout) SWIGTYPE { + return new $&javaclassname($jnicall, true); +} +%typemap(javaout) std::vector { + return (AbstractList)(new $&javaclassname($jnicall, true)); +} +%typemap(jstype) std::vector "AbstractList" + +%template(floatVector) std::vector; + +JAVA_JNI_LOADLIBRARY(javaupm_bmx055) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bmm150_defs.h" +#include "bmg160_defs.h" +#include "bma250e_defs.h" +#include "bmm150.hpp" +#include "bmc150.hpp" +#include "bmx055.hpp" +#include "bmi055.hpp" +%} +%include "bmm150_defs.h" +%include "bmg160_defs.h" +%include "bma250e_defs.h" +%include "bmm150.hpp" +%include "bmx055.hpp" +%include "bmi055.hpp" +%include "bmc150.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bmx055/bmx055.json upm-1.7.1/src/bmx055/bmx055.json --- upm-1.6.0/src/bmx055/bmx055.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmx055/bmx055.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,49 +1,49 @@ -{ - "Library": "bmx055", - "Description": "BMX055 9-axis Sensor Module", - "Sensor Class": - { - "BMX055": - { - "Name": "BMX055 9-axis Sensor Module", - "Description": "The BMX055 is an integrated 9-axis sensor for the detection of movements and rotations and magnetic heading. It comprises the full functionality of a triaxial, low-g acceleration sensor, a triaxial angular rate sensor and a triaxial geomagnetic sensor. The BMX055 senses orientation, tilt, motion, acceleration, rotation, shock, vibration and heading in cell phones, handhelds, computer peripherals, man-machine interfaces, virtual reality features and game controllers. The BMX055 is essentially 3 separate devices in one: the BMA250E Accelerometer, the BMG160 Gyroscope, and the BMM150 Magnetometer. They are completely independant of each other. This driver provides a very simple interface to these 3 devices. If finer control is desired, you should just use the separate BMA25E, BMG160, and BMM150 device classes directly. This driver simply initializes all three devices, and provides a mechanism to read accelerometer, gyroscope and magnetometer data from them.", - "Aliases": ["bmx055"], - "Categories": ["imu", "accelerometer", "gyroscope", "magnetometer"], - "Connections": ["gpio", "i2c", "spi"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["bosch"], - "Kits": [], - "Examples": - { - "Java": ["BMX055_Example.java"], - "Python": ["bmx055.py"], - "Node.js": ["bmx055.js"], - "C++": ["bmx055.cxx"], - "C": [] - }, - "Specifications": - { - "Vdd": {"unit": "v", "low" : 2.4, "high": 3.6}, - "Measurement Range (Accelerometer)": {"unit": "g", "low": 2, "high": 16}, - "Measurement Range (Gyroscope)": {"unit": "deg/s", "low": 125, "high": 2000}, - "Measurement Range (Magnetometer)": {"unit": "LSB/uT", "typ": 3.3}, - "Iavg": {"unit": "uA", "low" : 130, "high": 5000}, - "Temperature Range": {"unit": "C", "low" : -40, "high": 85} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.bosch-sensortec.com/bst/products/all_products/bmx055"], - "Datasheets": ["https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMX055-DS000-02.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "bmx055", + "Description": "BMX055 9-axis Sensor Module", + "Sensor Class": + { + "BMX055": + { + "Name": "BMX055 9-axis Sensor Module", + "Description": "The BMX055 is an integrated 9-axis sensor for the detection of movements and rotations and magnetic heading. It comprises the full functionality of a triaxial, low-g acceleration sensor, a triaxial angular rate sensor and a triaxial geomagnetic sensor. The BMX055 senses orientation, tilt, motion, acceleration, rotation, shock, vibration and heading in cell phones, handhelds, computer peripherals, man-machine interfaces, virtual reality features and game controllers. The BMX055 is essentially 3 separate devices in one: the BMA250E Accelerometer, the BMG160 Gyroscope, and the BMM150 Magnetometer. They are completely independant of each other. This driver provides a very simple interface to these 3 devices. If finer control is desired, you should just use the separate BMA25E, BMG160, and BMM150 device classes directly. This driver simply initializes all three devices, and provides a mechanism to read accelerometer, gyroscope and magnetometer data from them.", + "Aliases": ["bmx055"], + "Categories": ["imu", "accelerometer", "gyroscope", "magnetometer"], + "Connections": ["gpio", "i2c", "spi"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["bosch"], + "Kits": [], + "Examples": + { + "Java": ["BMX055_Example.java"], + "Python": ["bmx055.py"], + "Node.js": ["bmx055.js"], + "C++": ["bmx055.cxx"], + "C": [] + }, + "Specifications": + { + "Vdd": {"unit": "v", "low" : 2.4, "high": 3.6}, + "Measurement Range (Accelerometer)": {"unit": "g", "low": 2, "high": 16}, + "Measurement Range (Gyroscope)": {"unit": "deg/s", "low": 125, "high": 2000}, + "Measurement Range (Magnetometer)": {"unit": "LSB/uT", "typ": 3.3}, + "Iavg": {"unit": "uA", "low" : 130, "high": 5000}, + "Temperature Range": {"unit": "C", "low" : -40, "high": 85} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.bosch-sensortec.com/bst/products/all_products/bmx055"], + "Datasheets": ["https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMX055-DS000-02.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/bmx055/CMakeLists.txt upm-1.7.1/src/bmx055/CMakeLists.txt --- upm-1.6.0/src/bmx055/CMakeLists.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmx055/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -1,5 +1,5 @@ upm_mixed_module_init (NAME bmx055 DESCRIPTION "Bosch IMU Sensor Library" - CPP_HDR bmx055.hpp bmc150.cxx bmi055.hpp + CPP_HDR bmx055.hpp bmc150.hpp bmi055.hpp CPP_SRC bmx055.cxx bmc150.cxx bmi055.cxx REQUIRES mraa bmg160 bma250e bmm150) diff -Nru upm-1.6.0/src/bmx055/javaupm_bmx055.i upm-1.7.1/src/bmx055/javaupm_bmx055.i --- upm-1.6.0/src/bmx055/javaupm_bmx055.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmx055/javaupm_bmx055.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -%module javaupm_bmx055 -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "../upm_javastdvector.i" - -%apply int {mraa::Edge}; - -%ignore getAccelerometer(float *, float *, float *); -%ignore getMagnetometer(float *, float *, float *); -%ignore getGyroscope(float *, float *, float *); - -%typemap(javaimports) SWIGTYPE %{ -import java.util.AbstractList; -import java.lang.Float; -%} - -%typemap(javaout) SWIGTYPE { - return new $&javaclassname($jnicall, true); -} -%typemap(javaout) std::vector { - return (AbstractList)(new $&javaclassname($jnicall, true)); -} -%typemap(jstype) std::vector "AbstractList" - -%template(floatVector) std::vector; - -%include "bmg160_defs.h" -%include "bma250e_defs.h" -%include "bmm150_defs.h" - -%include "bmx055.hpp" -%{ - #include "bmx055.hpp" -%} - -%include "bmc150.hpp" -%{ - #include "bmc150.hpp" -%} - -%include "bmi055.hpp" -%{ - #include "bmi055.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_bmx055) diff -Nru upm-1.6.0/src/bmx055/jsupm_bmx055.i upm-1.7.1/src/bmx055/jsupm_bmx055.i --- upm-1.6.0/src/bmx055/jsupm_bmx055.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmx055/jsupm_bmx055.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -%module jsupm_bmx055 -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to JavaScript as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "bmg160_defs.h" -%include "bma250e_defs.h" -%include "bmm150_defs.h" - -%include "bmx055.hpp" -%{ - #include "bmx055.hpp" -%} - -%include "bmc150.hpp" -%{ - #include "bmc150.hpp" -%} - -%include "bmi055.hpp" -%{ - #include "bmi055.hpp" -%} diff -Nru upm-1.6.0/src/bmx055/pyupm_bmx055.i upm-1.7.1/src/bmx055/pyupm_bmx055.i --- upm-1.6.0/src/bmx055/pyupm_bmx055.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bmx055/pyupm_bmx055.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bmx055 -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to python as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "bmg160_defs.h" -%include "bma250e_defs.h" -%include "bmm150_defs.h" - -%include "bmm150.hpp" -%{ - #include "bmm150.hpp" -%} - -%include "bmx055.hpp" -%{ - #include "bmx055.hpp" -%} - -%include "bmc150.hpp" -%{ - #include "bmc150.hpp" -%} - -%include "bmi055.hpp" -%{ - #include "bmi055.hpp" -%} diff -Nru upm-1.6.0/src/bno055/bno055.i upm-1.7.1/src/bno055/bno055.i --- upm-1.6.0/src/bno055/bno055.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/bno055/bno055.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "std_vector.i" +%ignore getCalibrationStatus(int *, int *, int *, int *); +%ignore getAccelerometer(float *, float *, float *); +%ignore getMagnetometer(float *, float *, float *); +%ignore getGyroscope(float *, float *, float *); +%ignore getEulerAngles(float *, float *, float *); +%ignore getQuaternions(float *, float *, float *, float *); +%ignore getLinearAcceleration(float *, float *, float *); +%ignore getGravityVectors(float *, float *, float *); +%ignore installISR(int , mraa::Edge , void *, void *); + +%template(floatVector) std::vector; +%template(byteVector) std::vector; +%template(intVector) std::vector; + +%extend upm::BNO055 { + void installISR(int gpio, mraa_gpio_edge_t level, jobject runnable) + { + $self->installISR(gpio, level, mraa_java_isr_callback, runnable); + } +} + +JAVA_JNI_LOADLIBRARY(javaupm_bno055) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bno055.hpp" +%} +%include "bno055_regs.h" +%include "bno055.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/bno055/bno055.json upm-1.7.1/src/bno055/bno055.json --- upm-1.6.0/src/bno055/bno055.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bno055/bno055.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,48 +1,48 @@ -{ - "Library": "bno055", - "Description": "API for the BNO055 Absolute Orientation 9DOF Fusion Hub", - "Sensor Class": - { - "BNO055": - { - "Name": "Intelligent 9-axis Absolute Orientation Sensor", - "Description": "The BNO055 is a System in Package (SiP), integrating a triaxial 14-bit accelerometer, a triaxial 16-bit gyroscope with a range of +/- 2000 degrees per second, a triaxial geomagnetic sensor and a 32-bit cortex M0+ microcontroller running Bosch Sensortec sensor fusion software, in a single package. This sensor handles the hard problem of combining various sensor information into a reliable measurement of sensor orientation (refered to as 'sensor fusion'). The onboard MCU runs this software and can provide fusion output in the form of Euler Angles, Quaternions, Linear Acceleration, and Gravity Vectors in 3 axes. The focus on this driver has been on supporting the fusion components. Less support is available for use of this device as a generic accelerometer, gyroscope and magnetometer, however enough infrastructure is available to add any missing functionality. This device requires calibration in order to operate accurately. Methods are provided to retrieve calibration data (once calibrated) to be stored somewhere else, like in a file. A method is provided to load this data as well. Calibration data is lost on a power cycle. See one of the examples for a description of how to calibrate the device, but in essence: There is a calibration status register available (getCalibrationStatus()) that returns the calibration status of the accelerometer (ACC), magnetometer (MAG), gyroscope (GYR), and overall system (SYS). Each of these values range from 0 (uncalibrated) to 3 (fully calibrated). Calibration involves certain motions to get all 4 values at 3. The motions are as follows (though see the datasheet for more information): GYR: Simply let the sensor sit flat for a few seconds. ACC: Move the sensor in various positions. Start flat, then rotate slowly by 45 degrees, hold for a few seconds, then continue rotating another 45 degrees and hold, etc. 6 or more movements of this type may be required. You can move through any axis you desire, but make sure that the device is lying at least once perpendicular to the x, y, and z axis. MAG: Move slowly in a figure 8 pattern in the air, until the calibration values reaches 3. SYS: This will usually reach 3 when the other items have also reached 3. If not, continue slowly moving the device though various axes until it does.", - "Aliases": ["bno055"], - "Categories": ["accelerometer", "compass"], - "Connections": ["gpio", "i2c"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["adafruit"], - "Kits": [], - "Examples": - { - "Java": ["BNO055_Example.java"], - "Python": ["bno055.py"], - "Node.js": ["bno055.js"], - "C++": ["bno055.cxx"], - "C": ["bno055.c"] - }, - "Specifications": - { - "Vsource": {"unit": "v", "low" : 2.4, "high": 3.6}, - "Supply Current": {"unit": "mA", "low": 0.33, "high": 12.3}, - "Supply Current (Suspended)": {"unit": "uA", "typ": 40}, - "Gyroscope Ranges": {"unit": "deg/s", "low": 125, "high": 2000}, - "Magnetometer Ranges": {} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.adafruit.com/products/2472"], - "Datasheets": ["https://cdn-learn.adafruit.com/assets/assets/000/036/832/original/BST_BNO055_DS000_14.pdf"], - "Schematics": ["https://cdn-learn.adafruit.com/assets/assets/000/024/546/medium800/sensors_BNO055_REV-C.png?1429569060"] - } - } - } -} +{ + "Library": "bno055", + "Description": "API for the BNO055 Absolute Orientation 9DOF Fusion Hub", + "Sensor Class": + { + "BNO055": + { + "Name": "Intelligent 9-axis Absolute Orientation Sensor", + "Description": "The BNO055 is a System in Package (SiP), integrating a triaxial 14-bit accelerometer, a triaxial 16-bit gyroscope with a range of +/- 2000 degrees per second, a triaxial geomagnetic sensor and a 32-bit cortex M0+ microcontroller running Bosch Sensortec sensor fusion software, in a single package. This sensor handles the hard problem of combining various sensor information into a reliable measurement of sensor orientation (refered to as 'sensor fusion'). The onboard MCU runs this software and can provide fusion output in the form of Euler Angles, Quaternions, Linear Acceleration, and Gravity Vectors in 3 axes. The focus on this driver has been on supporting the fusion components. Less support is available for use of this device as a generic accelerometer, gyroscope and magnetometer, however enough infrastructure is available to add any missing functionality. This device requires calibration in order to operate accurately. Methods are provided to retrieve calibration data (once calibrated) to be stored somewhere else, like in a file. A method is provided to load this data as well. Calibration data is lost on a power cycle. See one of the examples for a description of how to calibrate the device, but in essence: There is a calibration status register available (getCalibrationStatus()) that returns the calibration status of the accelerometer (ACC), magnetometer (MAG), gyroscope (GYR), and overall system (SYS). Each of these values range from 0 (uncalibrated) to 3 (fully calibrated). Calibration involves certain motions to get all 4 values at 3. The motions are as follows (though see the datasheet for more information): GYR: Simply let the sensor sit flat for a few seconds. ACC: Move the sensor in various positions. Start flat, then rotate slowly by 45 degrees, hold for a few seconds, then continue rotating another 45 degrees and hold, etc. 6 or more movements of this type may be required. You can move through any axis you desire, but make sure that the device is lying at least once perpendicular to the x, y, and z axis. MAG: Move slowly in a figure 8 pattern in the air, until the calibration values reaches 3. SYS: This will usually reach 3 when the other items have also reached 3. If not, continue slowly moving the device though various axes until it does.", + "Aliases": ["bno055"], + "Categories": ["accelerometer", "compass"], + "Connections": ["gpio", "i2c"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["adafruit"], + "Kits": [], + "Examples": + { + "Java": ["BNO055_Example.java"], + "Python": ["bno055.py"], + "Node.js": ["bno055.js"], + "C++": ["bno055.cxx"], + "C": ["bno055.c"] + }, + "Specifications": + { + "Vsource": {"unit": "v", "low" : 2.4, "high": 3.6}, + "Supply Current": {"unit": "mA", "low": 0.33, "high": 12.3}, + "Supply Current (Suspended)": {"unit": "uA", "typ": 40}, + "Gyroscope Ranges": {"unit": "deg/s", "low": 125, "high": 2000}, + "Magnetometer Ranges": {} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.adafruit.com/products/2472"], + "Datasheets": ["https://cdn-learn.adafruit.com/assets/assets/000/036/832/original/BST_BNO055_DS000_14.pdf"], + "Schematics": ["https://cdn-learn.adafruit.com/assets/assets/000/024/546/medium800/sensors_BNO055_REV-C.png?1429569060"] + } + } + } +} diff -Nru upm-1.6.0/src/bno055/javaupm_bno055.i upm-1.7.1/src/bno055/javaupm_bno055.i --- upm-1.6.0/src/bno055/javaupm_bno055.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bno055/javaupm_bno055.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -%module javaupm_bno055 -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "std_vector.i" -%include "stdint.i" - -%ignore getCalibrationStatus(int *, int *, int *, int *); -%ignore getAccelerometer(float *, float *, float *); -%ignore getMagnetometer(float *, float *, float *); -%ignore getGyroscope(float *, float *, float *); -%ignore getEulerAngles(float *, float *, float *); -%ignore getQuaternions(float *, float *, float *, float *); -%ignore getLinearAcceleration(float *, float *, float *); -%ignore getGravityVectors(float *, float *, float *); - -%template(floatVector) std::vector; -%template(byteVector) std::vector; -%template(intVector) std::vector; - -%{ - #include "bno055.hpp" - #include "bno055_regs.h" -%} -%include "bno055_regs.h" -%include "bno055.hpp" - -%ignore installISR(int , mraa::Edge , void *, void *); - -%extend upm::BNO055 { - void installISR(int gpio, mraa_gpio_edge_t level, jobject runnable) - { - $self->installISR(gpio, level, mraa_java_isr_callback, runnable); - } -} - -JAVA_JNI_LOADLIBRARY(javaupm_bno055) diff -Nru upm-1.6.0/src/bno055/jsupm_bno055.i upm-1.7.1/src/bno055/jsupm_bno055.i --- upm-1.6.0/src/bno055/jsupm_bno055.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bno055/jsupm_bno055.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -%module jsupm_bno055 -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to JS as intp and floatp, though - * using the vector return (upm_vectortypes.i) functions instead of - * the pointer argument functions is preferable. - */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "bno055_regs.h" -%include "bno055.hpp" -%{ - #include "bno055.hpp" -%} diff -Nru upm-1.6.0/src/bno055/pyupm_bno055.i upm-1.7.1/src/bno055/pyupm_bno055.i --- upm-1.6.0/src/bno055/pyupm_bno055.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/bno055/pyupm_bno055.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_bno055 -%include "../upm.i" -%include "cpointer.i" -%include "../upm_vectortypes.i" - -/* Send "int *" and "float *" to python as intp and floatp, though - * using the vector return (upm_vectortypes.i) functions instead of - * the pointer argument functions is preferable. - */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - - -%include "bno055_regs.h" -%include "bno055.hpp" -%{ - #include "bno055.hpp" -%} diff -Nru upm-1.6.0/src/button/button.c upm-1.7.1/src/button/button.c --- upm-1.6.0/src/button/button.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/button/button.c 2018-10-12 04:47:41.000000000 +0000 @@ -42,9 +42,7 @@ return NULL; } - dev->gpio_pin = pin; - - dev->gpio = mraa_gpio_init(dev->gpio_pin); + dev->gpio = mraa_gpio_init(pin); mraa_gpio_dir(dev->gpio, MRAA_GPIO_IN); dev->isr_installed = false; diff -Nru upm-1.6.0/src/button/button.h upm-1.7.1/src/button/button.h --- upm-1.6.0/src/button/button.h 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/button/button.h 2018-10-12 04:47:41.000000000 +0000 @@ -61,7 +61,6 @@ typedef struct _button_context { mraa_gpio_context gpio; - uint8_t gpio_pin; bool isr_installed; } *button_context; diff -Nru upm-1.6.0/src/button/button.i upm-1.7.1/src/button/button.i --- upm-1.6.0/src/button/button.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/button/button.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%apply int {mraa::Edge} + +JAVA_ADD_INSTALLISR_EDGE(upm::Button) + +JAVA_JNI_LOADLIBRARY(javaupm_button) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "button.hpp" +%} +%include "button.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/button/button.json upm-1.7.1/src/button/button.json --- upm-1.6.0/src/button/button.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/button/button.json 2018-10-12 04:47:41.000000000 +0000 @@ -16,7 +16,7 @@ "Image": "button.jpg", "Examples": { - "Java": ["ButtonSample.java", "Button_intrSample.java"], + "Java": ["Button_Example.java", "Button_intr_Example.java"], "Python": ["button.py"], "Node.js": ["button.js"], "C++": ["button.cxx"], diff -Nru upm-1.6.0/src/button/javaupm_button.i upm-1.7.1/src/button/javaupm_button.i --- upm-1.6.0/src/button/javaupm_button.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/button/javaupm_button.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -%module javaupm_button -%include "../upm.i" - -%apply int {mraa::Edge} - -%{ - #include "button.hpp" -%} - -%include "button.hpp" - -#%ignore - -JAVA_ADD_INSTALLISR_EDGE(upm::Button) - -JAVA_JNI_LOADLIBRARY(javaupm_button) diff -Nru upm-1.6.0/src/button/jsupm_button.i upm-1.7.1/src/button/jsupm_button.i --- upm-1.6.0/src/button/jsupm_button.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/button/jsupm_button.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_button -%include "../upm.i" - -%{ - #include "button.hpp" -%} - -%include "button.hpp" diff -Nru upm-1.6.0/src/button/pyupm_button.i upm-1.7.1/src/button/pyupm_button.i --- upm-1.6.0/src/button/pyupm_button.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/button/pyupm_button.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_button -%include "../upm.i" - -%include "button.hpp" -%{ - #include "button.hpp" -%} diff -Nru upm-1.6.0/src/buzzer/buzzer.i upm-1.7.1/src/buzzer/buzzer.i --- upm-1.6.0/src/buzzer/buzzer.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/buzzer/buzzer.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,15 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_buzzer) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "buzzer.hpp" +%} +%include "buzzer_tones.h" +%include "buzzer.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/buzzer/buzzer.json upm-1.7.1/src/buzzer/buzzer.json --- upm-1.6.0/src/buzzer/buzzer.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/buzzer/buzzer.json 2018-10-12 04:47:41.000000000 +0000 @@ -16,7 +16,7 @@ "Image": "buzzer.jpg", "Examples": { - "Java": ["BuzzerSample.java"], + "Java": ["Buzzer_Example.java"], "Python": ["buzzer.py"], "Node.js": ["buzzer.js"], "C++": ["buzzer.cxx"], diff -Nru upm-1.6.0/src/buzzer/javaupm_buzzer.i upm-1.7.1/src/buzzer/javaupm_buzzer.i --- upm-1.6.0/src/buzzer/javaupm_buzzer.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/buzzer/javaupm_buzzer.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_buzzer -%include "../upm.i" - - -%include "buzzer_tones.h" -%include "buzzer.hpp" -%{ - #include "buzzer.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_buzzer) diff -Nru upm-1.6.0/src/buzzer/jsupm_buzzer.i upm-1.7.1/src/buzzer/jsupm_buzzer.i --- upm-1.6.0/src/buzzer/jsupm_buzzer.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/buzzer/jsupm_buzzer.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_buzzer -%include "../upm.i" - -%include "buzzer_tones.h" -%include "buzzer.hpp" -%{ - #include "buzzer.hpp" -%} - diff -Nru upm-1.6.0/src/buzzer/pyupm_buzzer.i upm-1.7.1/src/buzzer/pyupm_buzzer.i --- upm-1.6.0/src/buzzer/pyupm_buzzer.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/buzzer/pyupm_buzzer.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_buzzer -%include "../upm.i" - -%include "buzzer_tones.h" -%include "buzzer.hpp" -%{ - #include "buzzer.hpp" -%} diff -Nru upm-1.6.0/src/cjq4435/cjq4435.json upm-1.7.1/src/cjq4435/cjq4435.json --- upm-1.6.0/src/cjq4435/cjq4435.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/cjq4435/cjq4435.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,46 +1,46 @@ -{ - "Library": "cjq4435", - "Description": "API for the CJQ4435 MOSFET", - "Sensor Class": - { - "CJQ4435": - { - "Name": "CJQ4435 MOSFET", - "Description": "UPM module for the CJQ4435 MOSFET. It was developed using the Grove MOSFET module, but could be used with any MOSFET. A MOSFET is like a switch, but it can switch much faster than a mechanical relay. Here, we implement support via MRAA pulse width modulation (PWM) functions. Note: available periods vary depending on the capabilities of your platform.", - "Aliases": ["cjq4435"], - "Categories": ["electric"], - "Connections": ["gpio", "pwm"], - "Project Type": ["prototyping", "robotics"], - "Manufacturers": ["seeed"], - "Kits": ["robok"], - "Image": "cjq4435.jpg", - "Examples": - { - "Java": ["CJQ4435Sample.java"], - "Python": ["cjq4435.py"], - "Node.js": ["cjq4435.js"], - "C++": ["cjq4435.cxx"], - "C": ["cjq4435.c"] - }, - "Specifications": - { - "Trigger Voltage": {"unit": "V", "typ" : 5}, - "Working Voltage" : {"unit": "V", "low" : 5, "high": 15} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-MOSFET-p-1594.html", "http://wiki.seeed.cc/Grove-MOSFET/"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-MOSFET/master/res/CJQ4435.pdf"], - "Schematics": ["https://github.com/SeeedDocument/Grove-MOSFET/raw/master/res/Grove%20-%20MOSFET%20.pdf"] - } - } - } -} +{ + "Library": "cjq4435", + "Description": "API for the CJQ4435 MOSFET", + "Sensor Class": + { + "CJQ4435": + { + "Name": "CJQ4435 MOSFET", + "Description": "UPM module for the CJQ4435 MOSFET. It was developed using the Grove MOSFET module, but could be used with any MOSFET. A MOSFET is like a switch, but it can switch much faster than a mechanical relay. Here, we implement support via MRAA pulse width modulation (PWM) functions. Note: available periods vary depending on the capabilities of your platform.", + "Aliases": ["cjq4435"], + "Categories": ["electric"], + "Connections": ["gpio", "pwm"], + "Project Type": ["prototyping", "robotics"], + "Manufacturers": ["seeed"], + "Kits": ["robok"], + "Image": "cjq4435.jpg", + "Examples": + { + "Java": ["CJQ4435_Example.java"], + "Python": ["cjq4435.py"], + "Node.js": ["cjq4435.js"], + "C++": ["cjq4435.cxx"], + "C": ["cjq4435.c"] + }, + "Specifications": + { + "Trigger Voltage": {"unit": "V", "typ" : 5}, + "Working Voltage" : {"unit": "V", "low" : 5, "high": 15} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-MOSFET-p-1594.html", "http://wiki.seeed.cc/Grove-MOSFET/"], + "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-MOSFET/master/res/CJQ4435.pdf"], + "Schematics": ["https://github.com/SeeedDocument/Grove-MOSFET/raw/master/res/Grove%20-%20MOSFET%20.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/cjq4435/javaupm_cjq4435.i upm-1.7.1/src/cjq4435/javaupm_cjq4435.i --- upm-1.6.0/src/cjq4435/javaupm_cjq4435.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/cjq4435/javaupm_cjq4435.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_cjq4435 -%include "../upm.i" - -%{ - #include "cjq4435.hpp" -%} - -%include "cjq4435.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_cjq4435) \ No newline at end of file diff -Nru upm-1.6.0/src/cjq4435/jsupm_cjq4435.i upm-1.7.1/src/cjq4435/jsupm_cjq4435.i --- upm-1.6.0/src/cjq4435/jsupm_cjq4435.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/cjq4435/jsupm_cjq4435.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_cjq4435 -%include "../upm.i" - -%{ - #include "cjq4435.hpp" -%} - -%include "cjq4435.hpp" diff -Nru upm-1.6.0/src/cjq4435/pyupm_cjq4435.i upm-1.7.1/src/cjq4435/pyupm_cjq4435.i --- upm-1.6.0/src/cjq4435/pyupm_cjq4435.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/cjq4435/pyupm_cjq4435.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_cjq4435 -%include "../upm.i" - -%include "cjq4435.hpp" -%{ - #include "cjq4435.hpp" -%} diff -Nru upm-1.6.0/src/CMakeLists.txt upm-1.7.1/src/CMakeLists.txt --- upm-1.6.0/src/CMakeLists.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -53,8 +53,8 @@ # Get the LINK_LIBRARIES property of the target get_target_property(_dep_libs ${target} LINK_LIBRARIES) - # Remove this libname from the _dep_libs (if it exists) - list(REMOVE_ITEM _dep_libs ${libname}) + # Remove this target from the _dep_libs (if it exists) + list(REMOVE_ITEM _dep_libs ${target}) # Check if any of the LINK_LIBRARIES are targets in this project, # if so, add them to ${return_variable} @@ -228,18 +228,62 @@ set(${varIncludeDirs} "${${varIncludeDirs}}" PARENT_SCOPE) endfunction (_get_target_dependency_interface_include_dirs target varIncludeDirs) +# This function decides which swig interface file to use for the +# CMAKE_CURRENT_SOURCE_DIR. If no .i file exists, create one. +# +# if ${filePrefix}_${libname}.i exists +# return its full path +# elif ${libname}.i exists +# return its full path +# else +# create ${libname}.i via template and return its full path +# +function (_get_current_dot_i_file filePrefix varDotIFile) + set(${varDotIFile} "${CMAKE_CURRENT_SOURCE_DIR}/${libname}.i") + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${filePrefix}_${libname}.i") + set(${varDotIFile} "${CMAKE_CURRENT_SOURCE_DIR}/${filePrefix}_${libname}.i") + endif() + # If a SWIG .i file DOES NOT exist, make a simple one from the template + if (NOT EXISTS "${${varDotIFile}}") + # This file will exist OUTSIDE the source tree + set(${varDotIFile} "${CMAKE_CURRENT_BINARY_DIR}/${libname}.i") + + # Create preprocessor include string for importing + string(REGEX REPLACE ";" "\"\n#include \"" SWIG_HASH_INCLUDES "${module_h_hpp}") + set(SWIG_HASH_INCLUDES "#include \"${SWIG_HASH_INCLUDES}\"") + # And the SWIG import string + string(REPLACE "#" "%" SWIG_PERCENT_INCLUDES "${SWIG_HASH_INCLUDES}") + + # Write the interface file + configure_file (${PROJECT_SOURCE_DIR}/src/swigme.i.in "${${varDotIFile}}" @ONLY) + endif() + + set(${varDotIFile} "${${varDotIFile}}" PARENT_SCOPE) +endfunction() + # Create a single swig target for python +# This is a macro since the function which calls it (upm_swig_python) depends +# on values set inside this macro macro(_upm_swig_python) # Transitive headers don't appear to get picked up by swig_add_module call for # wrapper generation. Get them manually and add them here. _get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS) - include_directories (${CMAKE_CURRENT_SOURCE_DIR}/.. + include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. ${DEPEND_DIRS}) - set_source_files_properties (pyupm_${libname}.i PROPERTIES CPLUSPLUS ON) - set_source_files_properties (pyupm_${libname}.i PROPERTIES SWIG_FLAGS "-I${CMAKE_CURRENT_BINARY_DIR}/..") + # Decide between ${libname}.i or a language-specific .i + _get_current_dot_i_file(pyupm SWIG_CURRENT_DOT_I_FILE) + # If this module is using ${libname}.i, provide a module name for UseSWIG AND SWIG_FLAGS + if (${SWIG_CURRENT_DOT_I_FILE} MATCHES ${libname}.i) + set_source_files_properties(${SWIG_CURRENT_DOT_I_FILE} PROPERTIES + SWIG_MODULE_NAME pyupm_${libname} + SWIG_FLAGS ";-module;pyupm_${libname};") + endif() + + # Tell UseSWIG that this is CXX + set_property(SOURCE ${SWIG_CURRENT_DOT_I_FILE} PROPERTY CPLUSPLUS ON) # Set current python binary dir set (CMAKE_CURRENT_PYTHON_BINARY_DIR @@ -255,15 +299,15 @@ # Swig module name (example: pyupm_a110x-python2) set (python_wrapper_name pyupm_${libname}-python${PYTHON_VERSION_MAJOR}) if (CMAKE_VERSION VERSION_LESS "3.8") - swig_add_module (${python_wrapper_name} python pyupm_${libname}.i) + swig_add_module (${python_wrapper_name} python ${SWIG_CURRENT_DOT_I_FILE}) else () - swig_add_library (${python_wrapper_name} LANGUAGE python SOURCES pyupm_${libname}.i) + swig_add_library (${python_wrapper_name} LANGUAGE python SOURCES ${SWIG_CURRENT_DOT_I_FILE}) endif () # Get target library name (example _pyupm_a110x-python2) set (python_wrapper_target ${SWIG_MODULE_${python_wrapper_name}_REAL_NAME}) add_dependencies(${python_wrapper_target} ${libname}) - swig_link_libraries (${python_wrapper_name} ${PYTHON_LIBRARIES} ${libname}) + swig_link_libraries (${python_wrapper_name} ${PYTHON_LIBRARIES} ${libname} -Wl,--unresolved-symbols=report-all) target_include_directories (${python_wrapper_target} PUBLIC "${PYTHON_INCLUDE_PATH}" @@ -281,11 +325,11 @@ # Add C++ comments to ALL python modules (requires doc build) if (BUILDDOC) - # Python module depends on doxy2swig .i file generated from the monolithic doxygen xml file - add_dependencies(${python_wrapper_target} pyupm_doxy2swig ) - - # The pydoc target depends on EACH python module - add_dependencies(pydoc ${python_wrapper_target}) + # The python documentation generated with Sphinx only uses python2 + if (PYTHON_VERSION_MAJOR VERSION_EQUAL 2) + # Python module depends on doxy2swig .i file generated from the monolithic doxygen xml file + add_dependencies(${python_wrapper_target} pyupm_doxy2swig) + endif() endif (BUILDDOC) # Python collateral names will be the same for python2/3 w/different library dirs @@ -361,16 +405,29 @@ # wrapper generation. Get them manually and add them here. _get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS) - include_directories (${CMAKE_CURRENT_SOURCE_DIR}/.. + include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. ${DEPEND_DIRS}) - set_property (SOURCE jsupm_${libname}.i PROPERTY SWIG_FLAGS "-node" "-DV8_VERSION=${V8_VERSION_HEX}") - set_source_files_properties (jsupm_${libname}.i PROPERTIES CPLUSPLUS ON) + # Decide between ${libname}.i or a language-specific .i + _get_current_dot_i_file(jsupm SWIG_CURRENT_DOT_I_FILE) + # If this module is using ${libname}.i, provide a module name for UseSWIG AND SWIG_FLAGS + if (${SWIG_CURRENT_DOT_I_FILE} MATCHES ${libname}.i) + set_source_files_properties(${SWIG_CURRENT_DOT_I_FILE} PROPERTIES + SWIG_MODULE_NAME jsupm_${libname} + SWIG_FLAGS ";-module;jsupm_${libname};") + endif() + + # Tell UseSWIG that this is CXX + set_property(SOURCE ${SWIG_CURRENT_DOT_I_FILE} PROPERTY CPLUSPLUS ON) + # Append additional flags for NodeJS + set_property(SOURCE ${SWIG_CURRENT_DOT_I_FILE} APPEND PROPERTY + SWIG_FLAGS ";-node;-DV8_VERSION=${V8_VERSION_HEX}") + if (CMAKE_VERSION VERSION_LESS "3.8") - swig_add_module (jsupm_${libname} javascript jsupm_${libname}.i) + swig_add_module (jsupm_${libname} javascript ${SWIG_CURRENT_DOT_I_FILE}) else () - swig_add_library (jsupm_${libname} LANGUAGE javascript SOURCES jsupm_${libname}.i) + swig_add_library (jsupm_${libname} LANGUAGE javascript SOURCES ${SWIG_CURRENT_DOT_I_FILE}) endif () add_dependencies(jsupm_${libname} ${libname}) swig_link_libraries (jsupm_${libname} ${NODE_LIBRARIES} ${libname}) @@ -427,20 +484,33 @@ # wrapper generation. Get them manually and add them here. _get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS) - include_directories ( - ${JAVA_INCLUDE_PATH} - ${JAVA_INCLUDE_PATH2} - ${CMAKE_CURRENT_BINARY_DIR}/.. - ${CMAKE_CURRENT_BINARY_DIR}/.. - ${DEPEND_DIRS} - ) + include_directories (${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH2} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/.. + ${DEPEND_DIRS}) + + # Decide between ${libname}.i or a language-specific .i + _get_current_dot_i_file(javaupm SWIG_CURRENT_DOT_I_FILE) + # If this module is using ${libname}.i, provide a module name for UseSWIG AND SWIG_FLAGS + if (${SWIG_CURRENT_DOT_I_FILE} MATCHES ${libname}.i) + set_source_files_properties(${SWIG_CURRENT_DOT_I_FILE} PROPERTIES + SWIG_MODULE_NAME javaupm_${libname} + SWIG_FLAGS ";-module;javaupm_${libname};") + endif() + + # Tell UseSWIG that this is CXX + set_property(SOURCE ${SWIG_CURRENT_DOT_I_FILE} PROPERTY CPLUSPLUS ON) + + # Set a -package as well (which is slightly different than the module name, + # module: javaupm_a110x vs package: upm_a110x + set_property(SOURCE ${SWIG_CURRENT_DOT_I_FILE} APPEND PROPERTY + SWIG_FLAGS ";-package;upm_${libname}") - set_source_files_properties (javaupm_${libname}.i PROPERTIES CPLUSPLUS ON) - set_source_files_properties (javaupm_${libname}.i PROPERTIES SWIG_FLAGS ";-package;upm_${libname};-I${CMAKE_BINARY_DIR}/src") if (CMAKE_VERSION VERSION_LESS "3.8") - swig_add_module (javaupm_${libname} java javaupm_${libname}.i) + swig_add_module (javaupm_${libname} java ${SWIG_CURRENT_DOT_I_FILE}) else () - swig_add_library (javaupm_${libname} LANGUAGE java SOURCES javaupm_${libname}.i) + swig_add_library (javaupm_${libname} LANGUAGE java SOURCES ${SWIG_CURRENT_DOT_I_FILE}) endif () # If the C++ target depends on C++ interfaces, make the JAVA target @@ -505,6 +575,10 @@ COMMAND ${JAR} cf upm_${libname}.jar upm_${libname} ) + # Save the absolute path of the jar file as a property of this java target + set_target_properties (javaupm_${libname} PROPERTIES + JAR_FILE_ABSOLUTE ${CMAKE_CURRENT_BINARY_DIR}/upm_${libname}.jar) + # Keep track of all JAVA targets set(UPM_TARGETS_JAVA ${UPM_TARGETS_JAVA} javaupm_${libname} CACHE INTERNAL "List of JAVA target names") endif (NOT ";${JAVASWIG_BLACKLIST};" MATCHES ";${libname};") @@ -593,6 +667,17 @@ endmacro(createpackagejson) endif(BUILDSWIGNODE) +# Cordova binding +if (BUILDCORDOVA) + add_custom_target(cordova_binding ALL + COMMAND upm-cordova-binding ${CMAKE_BINARY_DIR}/src ${CMAKE_BINARY_DIR}/cordova ${VERSION} + COMMENT "Building cordova bindings based on swig java modules") + + install(DIRECTORY ${CMAKE_BINARY_DIR}/cordova + DESTINATION ${CMAKE_INSTALL_PREFIX} + COMPONENT ${CMAKE_PROJECT_NAME}-cordova) +endif (BUILDCORDOVA) + # Process C/C++ sensor modules # This function pre-processes sensor library input and hands off the # necessary global variables to upm_module_init for library creation, @@ -735,6 +820,16 @@ # Don't SWIG C if (NOT IS_C_LIBRARY) + # When auto-generating a SWIG .i file, first include any C headers which + # end in *_regs.h. Then, include the C++ headers. + if (UPM_MIXED_MODULE_INIT_C_HDR AND UPM_MIXED_MODULE_INIT_CPP_WRAPS_C) + string(REGEX MATCHALL "[^;]*_regs.h" _regs "${UPM_MIXED_MODULE_INIT_C_HDR}") + if(_regs) + list(APPEND module_h_hpp "${_regs}") + endif() + endif () + list(APPEND module_h_hpp "${module_hpp}") + separate_arguments (module_h_hpp) if (BUILDSWIGPYTHON) upm_swig_python() endif (BUILDSWIGPYTHON) @@ -746,6 +841,13 @@ endif (BUILDSWIGJAVA) endif (NOT IS_C_LIBRARY) + # Skip if the libname is in the blacklist + if (BUILDCORDOVA) + if (NOT IS_C_LIBRARY AND NOT ";${JAVASWIG_BLACKLIST};" MATCHES ";${libname};") + add_dependencies(cordova_binding javaupm_${libname}) + endif() + endif (BUILDCORDOVA) + # Add additional properties to this target (used later for .pc/pom file creation) set_target_properties(${libname} PROPERTIES PKG_CONFIG_NAME "${libprefix}${basename}") set_target_properties(${libname} PROPERTIES PKG_CONFIG_DESCRIPTION "${libdescription}") @@ -790,21 +892,6 @@ endif(PYTHON3LIBS_FOUND) endif (BUILDSWIGPYTHON) -# Generate python module documentation from doxygen collateral -if (BUILDDOC AND BUILDSWIGPYTHON) - # doxy2swig the doxygen output - add_custom_target (pyupm_doxy2swig ALL - COMMAND ${PYTHON2_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py - ${CMAKE_BINARY_DIR}/xml/index.xml --quiet - ${CMAKE_CURRENT_BINARY_DIR}/pyupm_doxy2swig.i - DEPENDS doc) -# BUILDDOC not set but still building python modules, generate an empty -# pyupm_doxy2swig.i file (overwriting if necessary) -elseif (BUILDSWIGPYTHON) - message (STATUS "BUILDDOC=${BUILDDOC}, python modules will not contain cxx documentation") - file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/pyupm_doxy2swig.i "// Empty doxy2swig stub") -endif (BUILDDOC AND BUILDSWIGPYTHON) - # Provide a cached variable to groups of targets set(UPM_TARGETS_C "" CACHE INTERNAL "List of C target names") set(UPM_TARGETS_CXX "" CACHE INTERNAL "List of CXX target names") @@ -854,3 +941,7 @@ if (BUILDSWIGJAVA) _gen_pom_per_target(${UPM_TARGETS_CXX}) endif (BUILDSWIGJAVA) + +# Available to the top-level CMakeLists.txt +set (UPM_TARGETS_CXX ${UPM_TARGETS_CXX} PARENT_SCOPE) +set (UPM_TARGETS_PYTHON2 ${UPM_TARGETS_PYTHON2} PARENT_SCOPE) diff -Nru upm-1.6.0/src/collision/collision.c upm-1.7.1/src/collision/collision.c --- upm-1.6.0/src/collision/collision.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/collision/collision.c 2018-10-12 04:47:41.000000000 +0000 @@ -39,8 +39,7 @@ if (!dev) return NULL; - dev->gpio_pin = pin; - dev->gpio = mraa_gpio_init(dev->gpio_pin); + dev->gpio = mraa_gpio_init(pin); if(mraa_gpio_dir(dev->gpio, MRAA_GPIO_IN) != MRAA_SUCCESS) { diff -Nru upm-1.6.0/src/collision/collision.h upm-1.7.1/src/collision/collision.h --- upm-1.6.0/src/collision/collision.h 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/collision/collision.h 2018-10-12 04:47:41.000000000 +0000 @@ -45,7 +45,6 @@ */ typedef struct _collision_context { mraa_gpio_context gpio; - uint8_t gpio_pin; } *collision_context; /** diff -Nru upm-1.6.0/src/collision/collision.json upm-1.7.1/src/collision/collision.json --- upm-1.6.0/src/collision/collision.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/collision/collision.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,45 +1,45 @@ -{ - "Library": "collision", - "Description": "API for the Collision Sensor", - "Sensor Class": - { - "Collision": - { - "Name": "Grove Collision Sensor", - "Description": "The Collision Sensor can detect whether any collision movement or vibration happens. It outputs a low pulse signal when vibration is detected.", - "Aliases": ["collision"], - "Categories": ["collision", "accelerometer"], - "Connections": ["gpio"], - "Project Type": ["prototyping", "robotics"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "collision.jpg", - "Examples": - { - "Java": ["Collision.java"], - "Python": ["collision.py"], - "Node.js": ["collision.js"], - "C++": ["collision.cxx"], - "C": ["collision.c"] - }, - "Specifications": - { - "Vsource": {"unit": "V", "low" : 3.3, "high": 5} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Collision-Sensor-p-1132.html", "http://wiki.seeed.cc/Grove-Collision_Sensor/"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Collision_Sensor/master/res/DataSheet-MVS0608_02-v2_1.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "collision", + "Description": "API for the Collision Sensor", + "Sensor Class": + { + "Collision": + { + "Name": "Grove Collision Sensor", + "Description": "The Collision Sensor can detect whether any collision movement or vibration happens. It outputs a low pulse signal when vibration is detected.", + "Aliases": ["collision"], + "Categories": ["collision", "accelerometer"], + "Connections": ["gpio"], + "Project Type": ["prototyping", "robotics"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "collision.jpg", + "Examples": + { + "Java": ["Collision_Example.java"], + "Python": ["collision.py"], + "Node.js": ["collision.js"], + "C++": ["collision.cxx"], + "C": ["collision.c"] + }, + "Specifications": + { + "Vsource": {"unit": "V", "low" : 3.3, "high": 5} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Collision-Sensor-p-1132.html", "http://wiki.seeed.cc/Grove-Collision_Sensor/"], + "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Collision_Sensor/master/res/DataSheet-MVS0608_02-v2_1.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/collision/javaupm_collision.i upm-1.7.1/src/collision/javaupm_collision.i --- upm-1.6.0/src/collision/javaupm_collision.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/collision/javaupm_collision.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_collision -%include "../upm.i" - -%{ - #include "collision.hpp" -%} - -%include "collision.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_collision) \ No newline at end of file diff -Nru upm-1.6.0/src/collision/jsupm_collision.i upm-1.7.1/src/collision/jsupm_collision.i --- upm-1.6.0/src/collision/jsupm_collision.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/collision/jsupm_collision.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_collision -%include "../upm.i" - -%{ - #include "collision.hpp" -%} - -%include "collision.hpp" diff -Nru upm-1.6.0/src/collision/pyupm_collision.i upm-1.7.1/src/collision/pyupm_collision.i --- upm-1.6.0/src/collision/pyupm_collision.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/collision/pyupm_collision.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_collision -%include "../upm.i" - -%include "collision.hpp" -%{ - #include "collision.hpp" -%} diff -Nru upm-1.6.0/src/common_top.i upm-1.7.1/src/common_top.i --- upm-1.6.0/src/common_top.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/common_top.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,60 @@ +%include "std_string.i" +%include "cpointer.i" +%include "stdint.i" +%include "typemaps.i" +%include "upm_exception.i" + +/* Import additional SWIG helps (not exposed in wrapper) */ +%import _upm.i + +%{ +#include "version.hpp" +%} +%include "version.hpp" + +%apply int { speed_t }; +%apply int { mraa_result_t }; +%apply int { mraa::Result }; +%apply int { upm_result_t }; + +#if (SWIG_JAVASCRIPT_V8) +%{ +/* Because there's no guarantee that v8 will ever call garbage collection, + * we're adding a function that will allow a user to call it manually + */ +void cleanUp() +{ + /* Call the v8 garbage collector as long as there is memory to clean up + * See https://codereview.chromium.org/412163003 for this API change + */ +#if (SWIG_V8_VERSION < 0x032838) + while (!v8::V8::IdleNotificationDeadline()) +#else + while (!v8::Isolate::GetCurrent()->IdleNotificationDeadline(1000)) +#endif + {;} +} +%} +void cleanUp(); +#endif + +#if (SWIGJAVA) +%typemap(jtype) jobject runnable "java.lang.Runnable" +%typemap(jstype) jobject runnable "java.lang.Runnable" +#endif + +// Disable nested struct warnings +#pragma SWIG nowarn=312,325 + +#if SWIGPYTHON +/* Apply all uints as 'unsigned int' for python */ +%apply unsigned int {uint}; +#endif + +/* The pyupm_doxy2swig.i file is created via doxy2swig.py from doxygen xml + * output during doc build. This file is used by swig to provide native + * python module documentation. + */ +#if defined(SWIGPYTHON) && defined(BUILDDOC) +%include "pyupm_doxy2swig.i" +#endif diff -Nru upm-1.6.0/src/curieimu/curieimu.i upm-1.7.1/src/curieimu/curieimu.i --- upm-1.6.0/src/curieimu/curieimu.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/curieimu/curieimu.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,58 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%typemap(jni) int16_t* "jshortArray" +%typemap(jstype) int16_t* "short[]" +%typemap(jtype) int16_t* "short[]" + +%typemap(javaout) int16_t* { + return $jnicall; +} + +%typemap(out) int16_t *getAccel { + $result = JCALL1(NewShortArray, jenv, 3); + JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); +} + +%typemap(out) int16_t *getGyro { + $result = JCALL1(NewShortArray, jenv, 3); + JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); +} + +%typemap(out) int16_t *getMotion { + $result = JCALL1(NewShortArray, jenv, 6); + JCALL4(SetShortArrayRegion, jenv, $result, 0, 6, (jshort*)$1); +} + +JAVA_JNI_LOADLIBRARY(javaupm_curieimu) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_int16_t.i" + +// Adding this typemap because SWIG is converting int16 into a short by default +// This forces SWIG to convert it correctly +%typemap(out) int16_t* { + jsresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_int16_t.i" +%typemap(out) int16_t* { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "curieimu.hpp" +%} +%include "curieimu.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/curieimu/curieimu.json upm-1.7.1/src/curieimu/curieimu.json --- upm-1.6.0/src/curieimu/curieimu.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/curieimu/curieimu.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "curieimu", - "Description": "Bosch Atmospheric Sensor Library", - "Sensor Class": - { - "CurieImu": - { - "Name": "Digital Humidity, Pressure, and Temperature Sensor", - "Description": "Curie IMU is a 6-axis accelerometer.", - "Aliases": ["curieimu"], - "Categories": ["IMU", "accelerometer", "compass"], - "Connections": ["firmata"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["bosch"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": ["curieimu.py"], - "Node.js": ["curieimu.js"], - "C++": ["curieimu.cxx"], - "C": [] - }, - "Specifications": - { - - }, - "Platforms": - {}, - "Urls" : - { - "Product Pages": [], - "Datasheets": [], - "Schematics": [] - } - } - } -} +{ + "Library": "curieimu", + "Description": "Bosch Atmospheric Sensor Library", + "Sensor Class": + { + "CurieImu": + { + "Name": "Digital Humidity, Pressure, and Temperature Sensor", + "Description": "Curie IMU is a 6-axis accelerometer.", + "Aliases": ["curieimu"], + "Categories": ["IMU", "accelerometer", "compass"], + "Connections": ["firmata"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["bosch"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": ["curieimu.py"], + "Node.js": ["curieimu.js"], + "C++": ["curieimu.cxx"], + "C": [] + }, + "Specifications": + { + + }, + "Platforms": + {}, + "Urls" : + { + "Product Pages": [], + "Datasheets": [], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/curieimu/javaupm_curieimu.i upm-1.7.1/src/curieimu/javaupm_curieimu.i --- upm-1.6.0/src/curieimu/javaupm_curieimu.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/curieimu/javaupm_curieimu.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -%module javaupm_curieimu -%include "../upm.i" - -%{ - #include "curieimu.hpp" -%} - -%typemap(jni) int16_t* "jshortArray" -%typemap(jstype) int16_t* "short[]" -%typemap(jtype) int16_t* "short[]" - -%typemap(javaout) int16_t* { - return $jnicall; -} - -%typemap(out) int16_t *getAccel { - $result = JCALL1(NewShortArray, jenv, 3); - JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); -} - -%typemap(out) int16_t *getGyro { - $result = JCALL1(NewShortArray, jenv, 3); - JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); -} - -%typemap(out) int16_t *getMotion { - $result = JCALL1(NewShortArray, jenv, 6); - JCALL4(SetShortArrayRegion, jenv, $result, 0, 6, (jshort*)$1); -} - -%include "curieimu.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_curieimu) diff -Nru upm-1.6.0/src/curieimu/jsupm_curieimu.i upm-1.7.1/src/curieimu/jsupm_curieimu.i --- upm-1.6.0/src/curieimu/jsupm_curieimu.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/curieimu/jsupm_curieimu.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -%module jsupm_curieimu -%include "../upm.i" -%include "../carrays_int16_t.i" - -// Adding this typemap because SWIG is converting int16 into a short by default -// This forces SWIG to convert it correctly -%typemap(out) int16_t* { - jsresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%{ - #include "curieimu.hpp" -%} - -%include "curieimu.hpp" diff -Nru upm-1.6.0/src/curieimu/pyupm_curieimu.i upm-1.7.1/src/curieimu/pyupm_curieimu.i --- upm-1.6.0/src/curieimu/pyupm_curieimu.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/curieimu/pyupm_curieimu.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_curieimu -%include "../upm.i" -%include "../carrays_int16_t.i" -%include "stdint.i" - -%typemap(out) int16_t* { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%include "curieimu.hpp" -%{ - #include "curieimu.hpp" -%} diff -Nru upm-1.6.0/src/cwlsxxa/cwlsxxa.i upm-1.7.1/src/cwlsxxa/cwlsxxa.i --- upm-1.6.0/src/cwlsxxa/cwlsxxa.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/cwlsxxa/cwlsxxa.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_cwlsxxa) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "cwlsxxa.hpp" +%} +%include "cwlsxxa.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/cwlsxxa/cwlsxxa.json upm-1.7.1/src/cwlsxxa/cwlsxxa.json --- upm-1.6.0/src/cwlsxxa/cwlsxxa.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/cwlsxxa/cwlsxxa.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,59 +1,59 @@ -{ - "Library": "cwlsxxa", - "Description": "API for the Veris CWLSXXA CO2 Sensor Family", - "Sensor Class": - { - "CWLXSSA": - { - "Name": "Veris CWLSXXA CO2 Sensor", - "Description": "The driver was developed using the CWLSHTA CO2 Gas sensor. The 'T' variant supports a temperature transmitter, and the 'H' variant supports a humidity sensor. All 3 signals are provided by the device as analog 0-5Vdc, 0-10Vdc, or 4-20ma loop current outputs. For devices supporting temperature, the valid temperature range is 10C to 50C. The humidity ranges from 0% to 100% (non-condensing). The CO2 sensor ranges from 0 to 2000 ppm. This driver was developed using the 5Vdc outputs and the 4-20ma outputs. For voltage outputs, your MCU must be configured for 5V operation. In addition, you must configure the sensor (via it's configuration switches) to output 0-5VDC only. Using any other analog reference voltage will require the appropriate external circuitry (such as a voltage divider) in order to interface safely with your MCU. In addition, the sensor can be configured for 4-20ma usage, by specifying the correct receiver resistance (in ohms) in the constructor. This sensor was tested with a Cooking Hacks (Libelium) 4-channel 4-20ma Arduino interface shield. For this interface, the receiver resistance was specified as 165.0 ohms. For devices which do not support temperature, use '-1' as the temperature pin number in the object constructor. If temperature measurement is disabled, getTemperature() will always return 0C/32F. For devices which do not support humidity, use '-1' as the temperature pin number in the object constructor. If humidity measurement is disabled, getHumidity() will always return 0.", - "Aliases": ["cwlsxxa"], - "Categories": ["temp", "gaseous"], - "Connections": ["analog"], - "Project Type": ["industrial"], - "Manufacturers": ["veris"], - "Kits": [], - "Examples": - { - "Java": ["CWLSXXA_Example.java"], - "Python": ["cwlsxxa.py"], - "Node.js": ["cwlsxxa.js"], - "C++": ["cwlsxxa.cxx"], - "C": [] - }, - "Specifications": - { - "Vsource (DC)": {"unit": "VDC", "low": 20, "high": 30}, - "Vsource (AC)": {"unit": "VAC", "typ": 24}, - - "CO2 Measurement Range": {"unit": "ppm", "low": 0, "high": 5000}, - "CO2 Accuracy": {"unit": "ppm ±", "typ": 30}, - "CO2 Repeatability": {"unit": "ppm ±", "typ": 20}, - "CO2 Response Time": {"unit": "s", "max": 60}, - - "RH Measurement Range": {"unit": "%", "low": 0, "high": 100}, - "RH Operating Temperature Range": {"unit": "degC", "low": 10, "high": 35}, - "RH Accuracy": {"unit": "%", "typ": 2}, - "RH Stability": {"unit": "%", "typ": 1}, - - "Temperature Accuracy": {"unit": "degC", "typ": 0.5}, - "Temperature Resolution": {"unit": "degC", "typ": 0.1}, - "Temperature Range": {"unit": "degC", "low": 10, "high": 35} - }, - "Platforms": - { - "Intel Joule Module": - { - "Notes": ["Requires pull-up resistors with carrier board"], - "Images": [""] - } - }, - "Urls" : - { - "Product Pages": ["http://www.veris.com/Item/CWLSHTA.aspx"], - "Datasheets": ["http://www.veris.com/docs/Datasheets/CDL_CDW_d0117.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "cwlsxxa", + "Description": "API for the Veris CWLSXXA CO2 Sensor Family", + "Sensor Class": + { + "CWLXSSA": + { + "Name": "Veris CWLSXXA CO2 Sensor", + "Description": "The driver was developed using the CWLSHTA CO2 Gas sensor. The 'T' variant supports a temperature transmitter, and the 'H' variant supports a humidity sensor. All 3 signals are provided by the device as analog 0-5Vdc, 0-10Vdc, or 4-20ma loop current outputs. For devices supporting temperature, the valid temperature range is 10C to 50C. The humidity ranges from 0% to 100% (non-condensing). The CO2 sensor ranges from 0 to 2000 ppm. This driver was developed using the 5Vdc outputs and the 4-20ma outputs. For voltage outputs, your MCU must be configured for 5V operation. In addition, you must configure the sensor (via it's configuration switches) to output 0-5VDC only. Using any other analog reference voltage will require the appropriate external circuitry (such as a voltage divider) in order to interface safely with your MCU. In addition, the sensor can be configured for 4-20ma usage, by specifying the correct receiver resistance (in ohms) in the constructor. This sensor was tested with a Cooking Hacks (Libelium) 4-channel 4-20ma Arduino interface shield. For this interface, the receiver resistance was specified as 165.0 ohms. For devices which do not support temperature, use '-1' as the temperature pin number in the object constructor. If temperature measurement is disabled, getTemperature() will always return 0C/32F. For devices which do not support humidity, use '-1' as the temperature pin number in the object constructor. If humidity measurement is disabled, getHumidity() will always return 0.", + "Aliases": ["cwlsxxa"], + "Categories": ["temp", "gaseous"], + "Connections": ["analog"], + "Project Type": ["industrial"], + "Manufacturers": ["veris"], + "Kits": [], + "Examples": + { + "Java": ["CWLSXXA_Example.java"], + "Python": ["cwlsxxa.py"], + "Node.js": ["cwlsxxa.js"], + "C++": ["cwlsxxa.cxx"], + "C": [] + }, + "Specifications": + { + "Vsource (DC)": {"unit": "VDC", "low": 20, "high": 30}, + "Vsource (AC)": {"unit": "VAC", "typ": 24}, + + "CO2 Measurement Range": {"unit": "ppm", "low": 0, "high": 5000}, + "CO2 Accuracy": {"unit": "ppm ±", "typ": 30}, + "CO2 Repeatability": {"unit": "ppm ±", "typ": 20}, + "CO2 Response Time": {"unit": "s", "max": 60}, + + "RH Measurement Range": {"unit": "%", "low": 0, "high": 100}, + "RH Operating Temperature Range": {"unit": "degC", "low": 10, "high": 35}, + "RH Accuracy": {"unit": "%", "typ": 2}, + "RH Stability": {"unit": "%", "typ": 1}, + + "Temperature Accuracy": {"unit": "degC", "typ": 0.5}, + "Temperature Resolution": {"unit": "degC", "typ": 0.1}, + "Temperature Range": {"unit": "degC", "low": 10, "high": 35} + }, + "Platforms": + { + "Intel Joule Module": + { + "Notes": ["Requires pull-up resistors with carrier board"], + "Images": [""] + } + }, + "Urls" : + { + "Product Pages": ["http://www.veris.com/Item/CWLSHTA.aspx"], + "Datasheets": ["http://www.veris.com/docs/Datasheets/CDL_CDW_d0117.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/cwlsxxa/javaupm_cwlsxxa.i upm-1.7.1/src/cwlsxxa/javaupm_cwlsxxa.i --- upm-1.6.0/src/cwlsxxa/javaupm_cwlsxxa.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/cwlsxxa/javaupm_cwlsxxa.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_cwlsxxa -%include "../upm.i" -%include "std_string.i" - -%include "cwlsxxa.hpp" -%{ - #include "cwlsxxa.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_cwlsxxa) diff -Nru upm-1.6.0/src/cwlsxxa/jsupm_cwlsxxa.i upm-1.7.1/src/cwlsxxa/jsupm_cwlsxxa.i --- upm-1.6.0/src/cwlsxxa/jsupm_cwlsxxa.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/cwlsxxa/jsupm_cwlsxxa.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_cwlsxxa -%include "../upm.i" -%include "std_string.i" - -%{ - #include "cwlsxxa.hpp" -%} - -%include "cwlsxxa.hpp" - diff -Nru upm-1.6.0/src/cwlsxxa/pyupm_cwlsxxa.i upm-1.7.1/src/cwlsxxa/pyupm_cwlsxxa.i --- upm-1.6.0/src/cwlsxxa/pyupm_cwlsxxa.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/cwlsxxa/pyupm_cwlsxxa.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_cwlsxxa -%include "../upm.i" -%include "std_string.i" - -%{ - #include "cwlsxxa.hpp" -%} -%include "cwlsxxa.hpp" - diff -Nru upm-1.6.0/src/dfrec/dfrec.i upm-1.7.1/src/dfrec/dfrec.i --- upm-1.6.0/src/dfrec/dfrec.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/dfrec/dfrec.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,17 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_dfrec) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(int, intp); +%pointer_functions(float, floatp); + +%{ +#include "dfrec.hpp" +%} +%include "dfrec.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/dfrec/dfrec.json upm-1.7.1/src/dfrec/dfrec.json --- upm-1.6.0/src/dfrec/dfrec.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrec/dfrec.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "dfrec", - "Description": "DFRobot EC Meter Library", - "Sensor Class": - { - "DFREC": - { - "Name": "Analog Electrical Conductivity (EC) Sensor", - "Description": "The driver was tested with the DFRobot EC Analog Sensor. This device measure the electrical conductivity of an aqueous solution. The included probe is a K=1 model. Calibration is somewhat complicated - see the DFRobot wiki for instructions on calibration. Functions are provided to supply the appropriate values. By default, the values used in the DFRobot arduino example are used.", - "Aliases": ["dfrec"], - "Categories": ["ec", "conductivity"], - "Connections": ["analog", "uart"], - "Project Type": ["industrial"], - "Manufacturers": ["dfrobot"], - "Kits": [], - "Examples": - { - "Java": ["DFREC_Example.java"], - "Python": ["dfrec.py"], - "Node.js": ["dfrec.js"], - "C++": ["dfrec.cxx"], - "C": ["dfrec.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "Typ": 5}, - "Measurement Range": {"unit": "mS/cm", "low": 1, "high": 20}, - "Operating Temperature": {"unit": "degC", "low": 5, "high": 40} - - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/product-1123.html"], - "Datasheets": [""], - "Schematics": ["http://image.dfrobot.com/image/data/DFR0300/DFR0300_v1.0_schematic.pdf"] - } - } - } -} +{ + "Library": "dfrec", + "Description": "DFRobot EC Meter Library", + "Sensor Class": + { + "DFREC": + { + "Name": "Analog Electrical Conductivity (EC) Sensor", + "Description": "The driver was tested with the DFRobot EC Analog Sensor. This device measure the electrical conductivity of an aqueous solution. The included probe is a K=1 model. Calibration is somewhat complicated - see the DFRobot wiki for instructions on calibration. Functions are provided to supply the appropriate values. By default, the values used in the DFRobot arduino example are used.", + "Aliases": ["dfrec"], + "Categories": ["ec", "conductivity"], + "Connections": ["analog", "uart"], + "Project Type": ["industrial"], + "Manufacturers": ["dfrobot"], + "Kits": [], + "Examples": + { + "Java": ["DFREC_Example.java"], + "Python": ["dfrec.py"], + "Node.js": ["dfrec.js"], + "C++": ["dfrec.cxx"], + "C": ["dfrec.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "Typ": 5}, + "Measurement Range": {"unit": "mS/cm", "low": 1, "high": 20}, + "Operating Temperature": {"unit": "degC", "low": 5, "high": 40} + + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/product-1123.html"], + "Datasheets": [""], + "Schematics": ["http://image.dfrobot.com/image/data/DFR0300/DFR0300_v1.0_schematic.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/dfrec/javaupm_dfrec.i upm-1.7.1/src/dfrec/javaupm_dfrec.i --- upm-1.6.0/src/dfrec/javaupm_dfrec.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrec/javaupm_dfrec.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_dfrec -%include "../upm.i" -%include "std_string.i" -%include "cpointer.i" -%include "typemaps.i" - -%include "dfrec.hpp" -%{ - #include "dfrec.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_dfrec) diff -Nru upm-1.6.0/src/dfrec/jsupm_dfrec.i upm-1.7.1/src/dfrec/jsupm_dfrec.i --- upm-1.6.0/src/dfrec/jsupm_dfrec.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrec/jsupm_dfrec.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module jsupm_dfrec -%include "../upm.i" -%include "std_string.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to JavaScript as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "dfrec.hpp" -%{ - #include "dfrec.hpp" -%} diff -Nru upm-1.6.0/src/dfrec/pyupm_dfrec.i upm-1.7.1/src/dfrec/pyupm_dfrec.i --- upm-1.6.0/src/dfrec/pyupm_dfrec.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrec/pyupm_dfrec.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_dfrec -%include "../upm.i" -%include "std_string.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to python as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "dfrec.hpp" -%{ - #include "dfrec.hpp" -%} diff -Nru upm-1.6.0/src/dfrorp/dfrorp.i upm-1.7.1/src/dfrorp/dfrorp.i --- upm-1.6.0/src/dfrorp/dfrorp.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/dfrorp/dfrorp.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,17 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_dfrorp) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(int, intp); +%pointer_functions(float, floatp); + +%{ +#include "dfrorp.hpp" +%} +%include "dfrorp.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/dfrorp/dfrorp.json upm-1.7.1/src/dfrorp/dfrorp.json --- upm-1.6.0/src/dfrorp/dfrorp.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrorp/dfrorp.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "dfrorp", - "Description": "UPM C++ API for the DFRobot ORP (Oxidation/Reduction Potential)", - "Sensor Class": - { - "DFRORP": - { - "Name": "Analog Oxidation Reduction Potential (ORP) Sensor", - "Description": "This library was tested with the DFRobot ORP (Oxidation/Reduction Potential) Sensor. To calibrate: Disconnect the sensor probe (but leave the sensor interface board connected). Then run one of the examples while holding down the 'calibrate' button on the device. Read the ORP value reported (it should be fairly small). This value is what you should supply to setCalibrationOffset(). Then reconnect the probe to the interface board and you should be ready to go. DO NOT press the calibrate button on the interface board while the probe is attached or you can permanently damage the probe.", - "Aliases": ["dfrorp"], - "Categories": ["orp", "liquid"], - "Connections": ["analog"], - "Project Type": ["industrial"], - "Manufacturers": ["dfrobot"], - "Kits": [], - "Examples": - { - "Java": ["DFRORP_Example.java"], - "Python": ["dfrorp.py"], - "Node.js": ["dfrorp.js"], - "C++": ["dfrorp.cxx"], - "C": ["dfrorp.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "Typ": 5}, - "Measurement Range": {"unit": "V", "low": -2, "high": 2}, - "Operating Temperature": {"unit": "degC", "low": 5, "high": 70} - - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/product-1071.html"], - "Datasheets": ["https://www.dfrobot.com/wiki/index.php/Analog_ORP_Meter(SKU:SEN0165)"], - "Schematics": ["http://image.dfrobot.com/image/data/SEN0165/OPR%20meter%20V1.0%20Schematic.pdf"] - } - } - } -} +{ + "Library": "dfrorp", + "Description": "UPM C++ API for the DFRobot ORP (Oxidation/Reduction Potential)", + "Sensor Class": + { + "DFRORP": + { + "Name": "Analog Oxidation Reduction Potential (ORP) Sensor", + "Description": "This library was tested with the DFRobot ORP (Oxidation/Reduction Potential) Sensor. To calibrate: Disconnect the sensor probe (but leave the sensor interface board connected). Then run one of the examples while holding down the 'calibrate' button on the device. Read the ORP value reported (it should be fairly small). This value is what you should supply to setCalibrationOffset(). Then reconnect the probe to the interface board and you should be ready to go. DO NOT press the calibrate button on the interface board while the probe is attached or you can permanently damage the probe.", + "Aliases": ["dfrorp"], + "Categories": ["orp", "liquid"], + "Connections": ["analog"], + "Project Type": ["industrial"], + "Manufacturers": ["dfrobot"], + "Kits": [], + "Examples": + { + "Java": ["DFRORP_Example.java"], + "Python": ["dfrorp.py"], + "Node.js": ["dfrorp.js"], + "C++": ["dfrorp.cxx"], + "C": ["dfrorp.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "Typ": 5}, + "Measurement Range": {"unit": "V", "low": -2, "high": 2}, + "Operating Temperature": {"unit": "degC", "low": 5, "high": 70} + + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/product-1071.html"], + "Datasheets": ["https://www.dfrobot.com/wiki/index.php/Analog_ORP_Meter(SKU:SEN0165)"], + "Schematics": ["http://image.dfrobot.com/image/data/SEN0165/OPR%20meter%20V1.0%20Schematic.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/dfrorp/javaupm_dfrorp.i upm-1.7.1/src/dfrorp/javaupm_dfrorp.i --- upm-1.6.0/src/dfrorp/javaupm_dfrorp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrorp/javaupm_dfrorp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_dfrorp -%include "../upm.i" -%include "std_string.i" -%include "cpointer.i" -%include "typemaps.i" - -%include "dfrorp.hpp" -%{ - #include "dfrorp.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_dfrorp) diff -Nru upm-1.6.0/src/dfrorp/jsupm_dfrorp.i upm-1.7.1/src/dfrorp/jsupm_dfrorp.i --- upm-1.6.0/src/dfrorp/jsupm_dfrorp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrorp/jsupm_dfrorp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module jsupm_dfrorp -%include "../upm.i" -%include "std_string.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to JavaScript as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "dfrorp.hpp" -%{ - #include "dfrorp.hpp" -%} diff -Nru upm-1.6.0/src/dfrorp/pyupm_dfrorp.i upm-1.7.1/src/dfrorp/pyupm_dfrorp.i --- upm-1.6.0/src/dfrorp/pyupm_dfrorp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrorp/pyupm_dfrorp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_dfrorp -%include "../upm.i" -%include "std_string.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to python as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "dfrorp.hpp" -%{ - #include "dfrorp.hpp" -%} diff -Nru upm-1.6.0/src/dfrph/dfrph.json upm-1.7.1/src/dfrph/dfrph.json --- upm-1.6.0/src/dfrph/dfrph.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrph/dfrph.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "dfrph", - "Description": "API for the DFRobot pH Sensors", - "Sensor Class": - { - "DFRPH": - { - "Name": "Analog pH Sensor", - "Description": "TThis sensor family returns an analog voltage proportional to the acidity or alkalinity of a liquid -- it's pH value. This driver was developed using the DFRobot Analog pH meter and the DFRobot Analog pH Meter Pro. Calibration instructions, taken and slightly reworded from the DFRobot wiki at: http://dfrobot.com/wiki/index.php/PH_meter%28SKU:_SEN0161%29 1) Connect equipment: the pH electrode is connected to the BNC connector on the pH meter board, and then the pH meter board is connected to the analog port 0 of the controller. When the controller gets power, you will see the blue LED on board is on. 2) Put the pH electrode into the standard solution whose pH value is 7.00. Run the dfrph example and note the pH output value. Compare the value with 7.00, and calculate the difference. This is the value you should supply to the setOffset() method. 3) Put the pH electrode into the pH standard solution whose value is 4.00. Then wait about one minute, and adjust the potentiometer on the interface board. Let the value stabilise at around 4.00. At this time,the acidic calibration has been completed and you can measure the pH value of an acidic solution. 4) According to the linear characteristics of pH electrode itself, after the above calibration,you can directly measure the pH value of the alkaline solution. If you want to get better accuracy, you can recalibrate it. Alkaline calibration use the standard solution whose pH value is 9.18. Also adjust the potentiometer and let the value stabilise at around 9.18. After this calibration, you can measure the pH value of an alkaline solution.", - "Aliases": ["dfrph"], - "Categories": ["pH", "liquid"], - "Connections": ["analog"], - "Project Type": ["industrial"], - "Manufacturers": ["dfrobot"], - "Kits": [], - "Image": "dfrph.jpg", - "Examples": - { - "Java": [], - "Python": ["dfrph.py"], - "Node.js": ["dfrph.js"], - "C++": ["dfrph.cxx"], - "C": ["dfrph.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "Typ": 5}, - "Measurement Range": {"unit": "pH", "low": 0, "high": 14}, - "Operating Temperature": {"unit": "degC", "low": 0, "high": 60} - - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/product-1110.html"], - "Datasheets": ["https://www.dfrobot.com/wiki/index.php/PH_meter(SKU:_SEN0161)"], - "Schematics": ["http://image.dfrobot.com/image/data/SEN0161/pH%20meter%20V1.0%20SCH.pdf"] - } - } - } -} +{ + "Library": "dfrph", + "Description": "API for the DFRobot pH Sensors", + "Sensor Class": + { + "DFRPH": + { + "Name": "Analog pH Sensor", + "Description": "TThis sensor family returns an analog voltage proportional to the acidity or alkalinity of a liquid -- it's pH value. This driver was developed using the DFRobot Analog pH meter and the DFRobot Analog pH Meter Pro. Calibration instructions, taken and slightly reworded from the DFRobot wiki at: http://dfrobot.com/wiki/index.php/PH_meter%28SKU:_SEN0161%29 1) Connect equipment: the pH electrode is connected to the BNC connector on the pH meter board, and then the pH meter board is connected to the analog port 0 of the controller. When the controller gets power, you will see the blue LED on board is on. 2) Put the pH electrode into the standard solution whose pH value is 7.00. Run the dfrph example and note the pH output value. Compare the value with 7.00, and calculate the difference. This is the value you should supply to the setOffset() method. 3) Put the pH electrode into the pH standard solution whose value is 4.00. Then wait about one minute, and adjust the potentiometer on the interface board. Let the value stabilise at around 4.00. At this time,the acidic calibration has been completed and you can measure the pH value of an acidic solution. 4) According to the linear characteristics of pH electrode itself, after the above calibration,you can directly measure the pH value of the alkaline solution. If you want to get better accuracy, you can recalibrate it. Alkaline calibration use the standard solution whose pH value is 9.18. Also adjust the potentiometer and let the value stabilise at around 9.18. After this calibration, you can measure the pH value of an alkaline solution.", + "Aliases": ["dfrph"], + "Categories": ["pH", "liquid"], + "Connections": ["analog"], + "Project Type": ["industrial"], + "Manufacturers": ["dfrobot"], + "Kits": [], + "Image": "dfrph.jpg", + "Examples": + { + "Java": [], + "Python": ["dfrph.py"], + "Node.js": ["dfrph.js"], + "C++": ["dfrph.cxx"], + "C": ["dfrph.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "Typ": 5}, + "Measurement Range": {"unit": "pH", "low": 0, "high": 14}, + "Operating Temperature": {"unit": "degC", "low": 0, "high": 60} + + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/product-1110.html"], + "Datasheets": ["https://www.dfrobot.com/wiki/index.php/PH_meter(SKU:_SEN0161)"], + "Schematics": ["http://image.dfrobot.com/image/data/SEN0161/pH%20meter%20V1.0%20SCH.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/dfrph/javaupm_dfrph.i upm-1.7.1/src/dfrph/javaupm_dfrph.i --- upm-1.6.0/src/dfrph/javaupm_dfrph.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrph/javaupm_dfrph.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_dfrph -%include "../upm.i" - -%{ - #include "dfrph.hpp" -%} - -%include "dfrph.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_dfrph) \ No newline at end of file diff -Nru upm-1.6.0/src/dfrph/jsupm_dfrph.i upm-1.7.1/src/dfrph/jsupm_dfrph.i --- upm-1.6.0/src/dfrph/jsupm_dfrph.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrph/jsupm_dfrph.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_dfrph -%include "../upm.i" - -%{ - #include "dfrph.hpp" -%} - -%include "dfrph.hpp" diff -Nru upm-1.6.0/src/dfrph/pyupm_dfrph.i upm-1.7.1/src/dfrph/pyupm_dfrph.i --- upm-1.6.0/src/dfrph/pyupm_dfrph.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/dfrph/pyupm_dfrph.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_dfrph -%include "../upm.i" - -%include "dfrph.hpp" -%{ - #include "dfrph.hpp" -%} diff -Nru upm-1.6.0/src/ds1307/ds1307.i upm-1.7.1/src/ds1307/ds1307.i --- upm-1.6.0/src/ds1307/ds1307.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ds1307/ds1307.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,17 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" + +JAVA_JNI_LOADLIBRARY(javaupm_ds1307) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ds1307.hpp" +%} +%include "ds1307.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ds1307/ds1307.json upm-1.7.1/src/ds1307/ds1307.json --- upm-1.6.0/src/ds1307/ds1307.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds1307/ds1307.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,41 +1,41 @@ -{ - "Library": "ds1307", - "Description": "DS1307 Real-Time Clock library", - "Sensor Class": - { - "DS1307": - { - "Name": "DS1307 Real Time Clock (RTC) Module", - "Description": "UPM module for the DS1307-based real-time clock. The clock can provide information about seconds, minutes, hours, day of the week, day of the month, month, and year. It can operate in either a 24-hour or a 12-hour format. This device can also output a square wave at 1Khz, 4Khz, 8Khz, and 32Khz. However, this capability is not implemented in this module.", - "Aliases": ["ds1307"], - "Categories": ["RTC", "timekeeping"], - "Connections": ["i2c"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["seeed", "maxim"], - "Kits": [], - "Image": "ds1307.jpg", - "Examples": - { - "Java": ["DS1307Sample.java"], - "Python": ["ds1307.py"], - "Node.js": ["ds1307.js"], - "C++": ["ds1307.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 4.5, "high": 5.5}, - "Active Current": {"unit": "mA", "Typ": 1.5}, - "Standby Current (Oscillator On)": {"unit": "nA", "low": 480, "high": 800}, - "Operating Temperature": {"unit": "degC", "low": 0, "high": 70} - - }, - "Urls" : - { - "Product Pages": ["https://www.maximintegrated.com/en/products/digital/real-time-clocks/DS1307.html/tb_tab0"], - "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/DS1307.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "ds1307", + "Description": "DS1307 Real-Time Clock library", + "Sensor Class": + { + "DS1307": + { + "Name": "DS1307 Real Time Clock (RTC) Module", + "Description": "UPM module for the DS1307-based real-time clock. The clock can provide information about seconds, minutes, hours, day of the week, day of the month, month, and year. It can operate in either a 24-hour or a 12-hour format. This device can also output a square wave at 1Khz, 4Khz, 8Khz, and 32Khz. However, this capability is not implemented in this module.", + "Aliases": ["ds1307"], + "Categories": ["RTC", "timekeeping"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["seeed", "maxim"], + "Kits": [], + "Image": "ds1307.jpg", + "Examples": + { + "Java": ["DS1307_Example.java"], + "Python": ["ds1307.py"], + "Node.js": ["ds1307.js"], + "C++": ["ds1307.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 4.5, "high": 5.5}, + "Active Current": {"unit": "mA", "Typ": 1.5}, + "Standby Current (Oscillator On)": {"unit": "nA", "low": 480, "high": 800}, + "Operating Temperature": {"unit": "degC", "low": 0, "high": 70} + + }, + "Urls" : + { + "Product Pages": ["https://www.maximintegrated.com/en/products/digital/real-time-clocks/DS1307.html/tb_tab0"], + "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/DS1307.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/ds1307/javaupm_ds1307.i upm-1.7.1/src/ds1307/javaupm_ds1307.i --- upm-1.6.0/src/ds1307/javaupm_ds1307.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds1307/javaupm_ds1307.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_ds1307 -%include "../upm.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%{ - #include "ds1307.hpp" -%} - -%include "ds1307.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ds1307) \ No newline at end of file diff -Nru upm-1.6.0/src/ds1307/jsupm_ds1307.i upm-1.7.1/src/ds1307/jsupm_ds1307.i --- upm-1.6.0/src/ds1307/jsupm_ds1307.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds1307/jsupm_ds1307.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ds1307 -%include "../upm.i" - -%{ - #include "ds1307.hpp" -%} - -%include "ds1307.hpp" diff -Nru upm-1.6.0/src/ds1307/pyupm_ds1307.i upm-1.7.1/src/ds1307/pyupm_ds1307.i --- upm-1.6.0/src/ds1307/pyupm_ds1307.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds1307/pyupm_ds1307.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ds1307 -%include "../upm.i" - -%include "ds1307.hpp" -%{ - #include "ds1307.hpp" -%} diff -Nru upm-1.6.0/src/ds1808lc/ds1808lc.i upm-1.7.1/src/ds1808lc/ds1808lc.i --- upm-1.6.0/src/ds1808lc/ds1808lc.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ds1808lc/ds1808lc.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,33 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} +%import "../interfaces/javaupm_iLightController.i" + +JAVA_JNI_LOADLIBRARY(javaupm_ds1808lc) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "iModuleStatus.hpp" +%include "iLightController.hpp" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "iModuleStatus.hpp" +%include "iLightController.hpp" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ds1808lc.hpp" +%} +%include "ds1808lc.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ds1808lc/ds1808lc.json upm-1.7.1/src/ds1808lc/ds1808lc.json --- upm-1.6.0/src/ds1808lc/ds1808lc.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds1808lc/ds1808lc.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "ds1808lc", - "Description": "API for DS1808 Dual Log Digital Potentiometer as a Light Controller", - "Sensor Class": - { - "DS1808LC": - { - "Name": "DS1808LC Lighting Controller", - "Description": "The Maxim Integrated [DS1808](http://www.maximintegrated.com/en/products/analog/data-converters/digital-potentiometers/DS1808.html) Dual Log Digital Potentiometer", - "Aliases": ["ds1808lc"], - "Categories": ["lighting"], - "Connections": ["i2c"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["maxim"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["ds1808lc.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "+-V", "Typ": 12}, - "Voltage Range": {"unit": "+-%", "Typ": 10}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - - }, - "Urls" : - { - "Product Pages": ["https://www.maximintegrated.com/en/products/analog/data-converters/digital-potentiometers/DS1808.html"], - "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/DS1808.pdf"], - "Schematics": [""] - } - } - } -} +{ + "Library": "ds1808lc", + "Description": "API for DS1808 Dual Log Digital Potentiometer as a Light Controller", + "Sensor Class": + { + "DS1808LC": + { + "Name": "DS1808LC Lighting Controller", + "Description": "The Maxim Integrated [DS1808](http://www.maximintegrated.com/en/products/analog/data-converters/digital-potentiometers/DS1808.html) Dual Log Digital Potentiometer", + "Aliases": ["ds1808lc"], + "Categories": ["lighting"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["maxim"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["ds1808lc.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "+-V", "Typ": 12}, + "Voltage Range": {"unit": "+-%", "Typ": 10}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + + }, + "Urls" : + { + "Product Pages": ["https://www.maximintegrated.com/en/products/analog/data-converters/digital-potentiometers/DS1808.html"], + "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/DS1808.pdf"], + "Schematics": [""] + } + } + } +} diff -Nru upm-1.6.0/src/ds1808lc/javaupm_ds1808lc.i upm-1.7.1/src/ds1808lc/javaupm_ds1808lc.i --- upm-1.6.0/src/ds1808lc/javaupm_ds1808lc.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds1808lc/javaupm_ds1808lc.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -%module javaupm_ds1808lc -%include "../upm.i" - -%import "../interfaces/javaupm_iLightController.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%include "arrays_java.i"; -%include "../java_buffer.i" -%include "cpointer.i" -%include "typemaps.i" - -%{ - #include "ds1808lc.hpp" -%} - -%include "ds1808lc.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ds1808lc) diff -Nru upm-1.6.0/src/ds1808lc/jsupm_ds1808lc.i upm-1.7.1/src/ds1808lc/jsupm_ds1808lc.i --- upm-1.6.0/src/ds1808lc/jsupm_ds1808lc.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds1808lc/jsupm_ds1808lc.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_ds1808lc -%include "../upm.i" - -%{ - #include "ds1808lc.hpp" -%} - -%include "iModuleStatus.hpp" -%include "iLightController.hpp" -%include "ds1808lc.hpp" diff -Nru upm-1.6.0/src/ds1808lc/pyupm_ds1808lc.i upm-1.7.1/src/ds1808lc/pyupm_ds1808lc.i --- upm-1.6.0/src/ds1808lc/pyupm_ds1808lc.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds1808lc/pyupm_ds1808lc.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module pyupm_ds1808lc -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - - -%include "iModuleStatus.hpp" -%include "iLightController.hpp" -%include "ds1808lc.hpp" -%{ - #include "ds1808lc.hpp" -%} diff -Nru upm-1.6.0/src/ds18b20/ds18b20.i upm-1.7.1/src/ds18b20/ds18b20.i --- upm-1.6.0/src/ds18b20/ds18b20.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ds18b20/ds18b20.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_ds18b20) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "carrays.i" +%{ +#include "ds18b20_defs.h" +#include "ds18b20.hpp" +%} +%include "ds18b20_defs.h" +%include "ds18b20.hpp" +%array_class(char, charArray); +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ds18b20/ds18b20.json upm-1.7.1/src/ds18b20/ds18b20.json --- upm-1.6.0/src/ds18b20/ds18b20.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds18b20/ds18b20.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "ds18b20", - "Description": "API for the DS18B20 1-Wire Temperature Sensor", - "Sensor Class": - { - "DS18B20": - { - "Name": "DS18B20 1-Wire Temperature Sensor", - "Description": "The driver was tested with the DFRobot EC Analog Sensor. This device measure the electrical conductivity of an aqueous solution. The included probe is a K=1 model. Calibration is somewhat complicated - see the DFRobot wiki for instructions on calibration. Functions are provided to supply the appropriate values. By default, the values used in the DFRobot arduino example are used.", - "Aliases": ["ds18b20"], - "Categories": ["ec", "conductivity"], - "Connections": ["uart"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["dallas"], - "Kits": [], - "Examples": - { - "Java": [""], - "Python": ["ds18b20.py"], - "Node.js": ["ds18b20.js"], - "C++": ["ds18b20.cxx"], - "C": ["ds18b20.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.0, "high": 5.5}, - "Measurement Range": {"unit": "degC", "low": -55, "high": 125}, - "+-.5degC Accuracy Range": {"unit": "degC", "low": -10, "high": 85} - - }, - "Urls" : - { - "Product Pages": ["https://www.sparkfun.com/products/11050"], - "Datasheets": ["http://cdn.sparkfun.com/datasheets/Sensors/Temp/DS18B20.pdf"], - "Schematics": [""] - } - } - } -} +{ + "Library": "ds18b20", + "Description": "API for the DS18B20 1-Wire Temperature Sensor", + "Sensor Class": + { + "DS18B20": + { + "Name": "DS18B20 1-Wire Temperature Sensor", + "Description": "The driver was tested with the DFRobot EC Analog Sensor. This device measure the electrical conductivity of an aqueous solution. The included probe is a K=1 model. Calibration is somewhat complicated - see the DFRobot wiki for instructions on calibration. Functions are provided to supply the appropriate values. By default, the values used in the DFRobot arduino example are used.", + "Aliases": ["ds18b20"], + "Categories": ["ec", "conductivity"], + "Connections": ["uart"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["dallas"], + "Kits": [], + "Examples": + { + "Java": [""], + "Python": ["ds18b20.py"], + "Node.js": ["ds18b20.js"], + "C++": ["ds18b20.cxx"], + "C": ["ds18b20.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.0, "high": 5.5}, + "Measurement Range": {"unit": "degC", "low": -55, "high": 125}, + "+-.5degC Accuracy Range": {"unit": "degC", "low": -10, "high": 85} + + }, + "Urls" : + { + "Product Pages": ["https://www.sparkfun.com/products/11050"], + "Datasheets": ["http://cdn.sparkfun.com/datasheets/Sensors/Temp/DS18B20.pdf"], + "Schematics": [""] + } + } + } +} diff -Nru upm-1.6.0/src/ds18b20/javaupm_ds18b20.i upm-1.7.1/src/ds18b20/javaupm_ds18b20.i --- upm-1.6.0/src/ds18b20/javaupm_ds18b20.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds18b20/javaupm_ds18b20.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module javaupm_ds18b20 -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%include "ds18b20_defs.h" -%include "ds18b20.hpp" -%{ - #include "ds18b20.hpp" -%} - -%array_class(char, charArray); - -JAVA_JNI_LOADLIBRARY(javaupm_ds18b20) diff -Nru upm-1.6.0/src/ds18b20/jsupm_ds18b20.i upm-1.7.1/src/ds18b20/jsupm_ds18b20.i --- upm-1.6.0/src/ds18b20/jsupm_ds18b20.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds18b20/jsupm_ds18b20.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module jsupm_ds18b20 -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%include "ds18b20_defs.h" -%include "ds18b20.hpp" -%{ - #include "ds18b20.hpp" -%} - -%array_class(char, charArray); diff -Nru upm-1.6.0/src/ds18b20/pyupm_ds18b20.i upm-1.7.1/src/ds18b20/pyupm_ds18b20.i --- upm-1.6.0/src/ds18b20/pyupm_ds18b20.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds18b20/pyupm_ds18b20.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -%module pyupm_ds18b20 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%include "carrays.i" -%include "std_string.i" - -%include "ds18b20_defs.h" -%include "ds18b20.hpp" -%{ - #include "ds18b20.hpp" -%} -%include "ds18b20.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/ds2413/ds2413.i upm-1.7.1/src/ds2413/ds2413.i --- upm-1.6.0/src/ds2413/ds2413.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ds2413/ds2413.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_ds2413) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "carrays.i" +%{ +#include "ds2413.hpp" +%} +%include "ds2413.hpp" +%array_class(char, charArray); +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ds2413/ds2413.json upm-1.7.1/src/ds2413/ds2413.json --- upm-1.6.0/src/ds2413/ds2413.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds2413/ds2413.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "ds2413", - "Description": "1-Wire Dual Channel Addressable Switch Library", - "Sensor Class": - { - "DS2413": - { - "Name": "1-Wire Dual Channel Addressable Switch", - "Description": "The DS2413 is a dual-channel programmable I/O 1-Wire(r) chip. The PIO outputs are configured as open-drain and provide up to 20mA continuous sink capability and off-state operating voltage up to 28V. Control and sensing of the PIO pins is performed with a dedicated device-level command protocol. This device requires the use of a UART to provide access to a Dallas 1-wire bus, via a new facility supported by MRAA (once the relevant PR is accepted), using the UartOW access class. It is important to realize that the UART is only being used to access and control a Dallas 1-wire compliant bus, it is not actually a UART device. Multiple DS2413 devices can be connected to this bus. This module will identify all such devices connected, and allow you to access them using an index starting at 0.", - "Aliases": ["ds2413"], - "Categories": ["switch"], - "Connections": ["uart"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["maxim", "adafruit"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": ["ds2413.py"], - "Node.js": ["ds2413.js"], - "C++": ["ds2413.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.8, "high": 5.5}, - "Input Load Current": {"unit": "uA", "low": 3.5, "high": 950}, - "Operating Temperature": {"unit": "degC", "low": 0, "high": 70} - - }, - "Urls" : - { - "Product Pages": ["http://www.maximintegrated.com/datasheet/index.mvp/id/4588", "https://learn.adafruit.com/adafruit-1-wire-gpio-breakout-ds2413/overview"], - "Datasheets": ["http://www.adafruit.com/datasheets/DS2413.pdf"], - "Schematics": ["https://learn.adafruit.com/assets/15639"] - } - } - } -} +{ + "Library": "ds2413", + "Description": "1-Wire Dual Channel Addressable Switch Library", + "Sensor Class": + { + "DS2413": + { + "Name": "1-Wire Dual Channel Addressable Switch", + "Description": "The DS2413 is a dual-channel programmable I/O 1-Wire(r) chip. The PIO outputs are configured as open-drain and provide up to 20mA continuous sink capability and off-state operating voltage up to 28V. Control and sensing of the PIO pins is performed with a dedicated device-level command protocol. This device requires the use of a UART to provide access to a Dallas 1-wire bus, via a new facility supported by MRAA (once the relevant PR is accepted), using the UartOW access class. It is important to realize that the UART is only being used to access and control a Dallas 1-wire compliant bus, it is not actually a UART device. Multiple DS2413 devices can be connected to this bus. This module will identify all such devices connected, and allow you to access them using an index starting at 0.", + "Aliases": ["ds2413"], + "Categories": ["switch"], + "Connections": ["uart"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["maxim", "adafruit"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": ["ds2413.py"], + "Node.js": ["ds2413.js"], + "C++": ["ds2413.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.8, "high": 5.5}, + "Input Load Current": {"unit": "uA", "low": 3.5, "high": 950}, + "Operating Temperature": {"unit": "degC", "low": 0, "high": 70} + + }, + "Urls" : + { + "Product Pages": ["http://www.maximintegrated.com/datasheet/index.mvp/id/4588", "https://learn.adafruit.com/adafruit-1-wire-gpio-breakout-ds2413/overview"], + "Datasheets": ["http://www.adafruit.com/datasheets/DS2413.pdf"], + "Schematics": ["https://learn.adafruit.com/assets/15639"] + } + } + } +} diff -Nru upm-1.6.0/src/ds2413/javaupm_ds2413.i upm-1.7.1/src/ds2413/javaupm_ds2413.i --- upm-1.6.0/src/ds2413/javaupm_ds2413.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds2413/javaupm_ds2413.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_ds2413 -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "ds2413.hpp" -%} - -%include "ds2413.hpp" -%array_class(char, charArray); - -JAVA_JNI_LOADLIBRARY(javaupm_ds2413) diff -Nru upm-1.6.0/src/ds2413/jsupm_ds2413.i upm-1.7.1/src/ds2413/jsupm_ds2413.i --- upm-1.6.0/src/ds2413/jsupm_ds2413.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds2413/jsupm_ds2413.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module jsupm_ds2413 -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "ds2413.hpp" -%} - -%include "ds2413.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/ds2413/pyupm_ds2413.i upm-1.7.1/src/ds2413/pyupm_ds2413.i --- upm-1.6.0/src/ds2413/pyupm_ds2413.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ds2413/pyupm_ds2413.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module pyupm_ds2413 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%include "carrays.i" -%include "std_string.i" - -%{ - #include "ds2413.hpp" -%} -%include "ds2413.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/e50hx/e50hx.i upm-1.7.1/src/e50hx/e50hx.i --- upm-1.6.0/src/e50hx/e50hx.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/e50hx/e50hx.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,30 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../carrays_uint32_t.i" + +// We need to use this method for enum wrapping since the enum typedefs used +// by the derived classes (like ANALOG_VALUES_T) are passed to methods +// in the base class which expect a uint32_t. This is fine, and +// works everywhere except Java. Its type safety is a little too +// stringent in these cases. %javaconst(1) is generally recommended +// as it avoids JNI calls to determine the enumerant values at +// runtime. +%include "enumtypeunsafe.swg" +%javaconst(1); + +JAVA_JNI_LOADLIBRARY(javaupm_e50hx) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bacnetmstp.hpp" +#include "bacnetutil.hpp" +#include "e50hx.hpp" +%} +%include "bacnetmstp.hpp" +%include "bacnetutil.hpp" +%include "e50hx.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/e50hx/e50hx.json upm-1.7.1/src/e50hx/e50hx.json --- upm-1.6.0/src/e50hx/e50hx.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/e50hx/e50hx.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,41 +1,41 @@ -{ - "Library": "e50hx", - "Description": "UPM API for the Veris E50HX Energy Meter", - "Sensor Class": - { - "E50HX": - { - "Name": "Veris E50HX (E50H2/E50H5) Energy Meter Module", - "Description": "This module implements support for the Veris E50H2 and E50H5 BACnet Energy Meters. From the datasheet: The E50H5 BACnet MS/TP DIN Rail Meter with Data Logging combines exceptional performance and easy installation to deliver a cost-effective solution for power monitoring applications. Native serial communication via BACnet MS/TP provides complete accessibility of all measurements to your Building Automation System The data logging capability protects data in the event of a power failure. The E50H5 can be easily installed on standard DIN rail, surface mounted or contained in an optional NEMA 4 enclosure, as needed. The front-panel LCD display makes device installation and setup easy and provides local access to the full set of detailed measurements. This module was developed using the upm::BACNETMSTP module, based on libbacnet-stack 0.8.3. Both libbacnet 0.8.3 and the upm::BACNETMSTP libraries must be present in order to build this module. This driver was developed on the E50H5. The Trend Log functionality is not currently supported. The Binary Input Objects are also not supported as these are only used for the Alarm bits which are already available from Analog Input Object 52 as an alarm bitfield incorporating all of the supported alarm indicators. It was connected using an RS232->RS485 interface. You cannot use the built in MCU TTL UART pins for accessing this device -- you must use a full Serial RS232->RS485 or USB-RS485 interface connected via USB.", - "Aliases": ["e50hx"], - "Categories": ["energy"], - "Connections": ["rs485"], - "Project Type": ["industrial"], - "Manufacturers": ["veris"], - "Kits": [], - "Examples": - { - "Java": ["E50HX_Example.java"], - "Python": ["e50hx.py"], - "Node.js": ["e50hx.js"], - "C++": ["e50hx.cxx"], - "C": [] - }, - "Specifications": - { - "AC Operating Voltage": {"unit": "VAC", "low": 90, "high": 600}, - "AC Power Usage": {"unit": "VA", "Max": 5}, - "DC Operating Voltage": {"unit": "VDC", "low": 125, "high": 300}, - "DC Power Usage": {"unit": "W", "Max": 3}, - "Operating Temperature": {"unit": "degC", "low": -30, "high": 70} - - }, - "Urls" : - { - "Product Pages": ["http://www.veris.com/Item/E50H5.aspx"], - "Datasheets": ["http://www.veris.com/docs/Datasheets/E5x_d0117.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "e50hx", + "Description": "UPM API for the Veris E50HX Energy Meter", + "Sensor Class": + { + "E50HX": + { + "Name": "Veris E50HX (E50H2/E50H5) Energy Meter Module", + "Description": "This module implements support for the Veris E50H2 and E50H5 BACnet Energy Meters. From the datasheet: The E50H5 BACnet MS/TP DIN Rail Meter with Data Logging combines exceptional performance and easy installation to deliver a cost-effective solution for power monitoring applications. Native serial communication via BACnet MS/TP provides complete accessibility of all measurements to your Building Automation System The data logging capability protects data in the event of a power failure. The E50H5 can be easily installed on standard DIN rail, surface mounted or contained in an optional NEMA 4 enclosure, as needed. The front-panel LCD display makes device installation and setup easy and provides local access to the full set of detailed measurements. This module was developed using the upm::BACNETMSTP module, based on libbacnet-stack 0.8.3. Both libbacnet 0.8.3 and the upm::BACNETMSTP libraries must be present in order to build this module. This driver was developed on the E50H5. The Trend Log functionality is not currently supported. The Binary Input Objects are also not supported as these are only used for the Alarm bits which are already available from Analog Input Object 52 as an alarm bitfield incorporating all of the supported alarm indicators. It was connected using an RS232->RS485 interface. You cannot use the built in MCU TTL UART pins for accessing this device -- you must use a full Serial RS232->RS485 or USB-RS485 interface connected via USB.", + "Aliases": ["e50hx"], + "Categories": ["energy"], + "Connections": ["rs485"], + "Project Type": ["industrial"], + "Manufacturers": ["veris"], + "Kits": [], + "Examples": + { + "Java": ["E50HX_Example.java"], + "Python": ["e50hx.py"], + "Node.js": ["e50hx.js"], + "C++": ["e50hx.cxx"], + "C": [] + }, + "Specifications": + { + "AC Operating Voltage": {"unit": "VAC", "low": 90, "high": 600}, + "AC Power Usage": {"unit": "VA", "Max": 5}, + "DC Operating Voltage": {"unit": "VDC", "low": 125, "high": 300}, + "DC Power Usage": {"unit": "W", "Max": 3}, + "Operating Temperature": {"unit": "degC", "low": -30, "high": 70} + + }, + "Urls" : + { + "Product Pages": ["http://www.veris.com/Item/E50H5.aspx"], + "Datasheets": ["http://www.veris.com/docs/Datasheets/E5x_d0117.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/e50hx/javaupm_e50hx.i upm-1.7.1/src/e50hx/javaupm_e50hx.i --- upm-1.6.0/src/e50hx/javaupm_e50hx.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/e50hx/javaupm_e50hx.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -%module javaupm_e50hx -%include "../upm.i" -%include "typemaps.i" -%include "../carrays_uint32_t.i" - -// We need to use this method for enum wrapping since the enum typedefs used -// by the derived classes (like ANALOG_VALUES_T) are passed to methods -// in the base class which expect a uint32_t. This is fine, and -// works everywhere except Java. Its type safety is a little too -// stringent in these cases. %javaconst(1) is generally recommended -// as it avoids JNI calls to determine the enumerant values at -// runtime. -%include "enumtypeunsafe.swg" -%javaconst(1); - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" -%include "e50hx.hpp" -%{ - #include "bacnetutil.hpp" - #include "e50hx.hpp" -%} - - -JAVA_JNI_LOADLIBRARY(javaupm_e50hx) diff -Nru upm-1.6.0/src/e50hx/jsupm_e50hx.i upm-1.7.1/src/e50hx/jsupm_e50hx.i --- upm-1.6.0/src/e50hx/jsupm_e50hx.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/e50hx/jsupm_e50hx.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_e50hx -%include "../upm.i" -%include "stdint.i" - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" -%include "e50hx.hpp" -%{ - #include "e50hx.hpp" -%} diff -Nru upm-1.6.0/src/e50hx/pyupm_e50hx.i upm-1.7.1/src/e50hx/pyupm_e50hx.i --- upm-1.6.0/src/e50hx/pyupm_e50hx.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/e50hx/pyupm_e50hx.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_e50hx -%include "../upm.i" -%include "stdint.i" - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" -%include "e50hx.hpp" -%{ - #include "e50hx.hpp" -%} diff -Nru upm-1.6.0/src/ecezo/ecezo.c upm-1.7.1/src/ecezo/ecezo.c --- upm-1.6.0/src/ecezo/ecezo.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecezo/ecezo.c 2018-10-12 04:47:41.000000000 +0000 @@ -488,7 +488,7 @@ // our write buffer char writeBuffer[ECEZO_MAX_BUFFER_LEN]; - strncpy(writeBuffer, cmd, ECEZO_MAX_BUFFER_LEN); + memcpy(writeBuffer, cmd, ECEZO_MAX_BUFFER_LEN - 1); writeBuffer[ECEZO_MAX_BUFFER_LEN - 1] = 0; int writelen = strlen(writeBuffer); diff -Nru upm-1.6.0/src/ecezo/ecezo.i upm-1.7.1/src/ecezo/ecezo.i --- upm-1.6.0/src/ecezo/ecezo.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ecezo/ecezo.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_ecezo) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ecezo_defs.h" +#include "ecezo.hpp" +%} +%include "ecezo_defs.h" +%include "ecezo.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ecezo/ecezo.json upm-1.7.1/src/ecezo/ecezo.json --- upm-1.6.0/src/ecezo/ecezo.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecezo/ecezo.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,43 +1,43 @@ -{ - "Library": "ecezo", - "Description": "API for the EC-EZO EC Sensor", - "Sensor Class": - { - "ECEZO": - { - "Name": "Electrical Conductivity (EC) Circuit", - "Description": "This driver was tested with the Atlas Scientific Electrical Conductivity kit. This device can operate in either UART or I2C modes.", - "Aliases": ["ecezo"], - "Categories": ["ec", "conductivity", "liquid"], - "Connections": ["i2c", "uart"], - "Project Type": ["industrial"], - "Manufacturers": ["atlas", "sparkfun"], - "Kits": [], - "Examples": - { - "Java": ["ECEZO_Example.java"], - "Python": ["ecezo.py"], - "Node.js": ["ecezo.js"], - "C++": ["ecezo.cxx"], - "C": ["ecezo.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "low": 19, "high": 50}, - "Conductivity Probe Range": {"unit": "K", "low": 0.1, "high": 10}, - "Accurate Reading Range (K=0.1)": {"unit": "uS", "low": 0.5, "high": 50000}, - "Accurate Reading Range (K=1.0)": {"unit": "uS", "low": 5, "high": 200000}, - "Accurate Reading Range (K=10.0)": {"unit": "uS", "low": 10, "high": 1000000}, - "Operating Temperature": {"unit": "degC", "low": 1, "high": 35} - - }, - "Urls" : - { - "Product Pages": ["https://www.atlas-scientific.com/product_pages/kits/ec_k1_0_kit.html", "https://www.sparkfun.com/products/12908"], - "Datasheets": ["https://cdn.sparkfun.com/datasheets/Sensors/Biometric/EC_EZO_Datasheet.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "ecezo", + "Description": "API for the EC-EZO EC Sensor", + "Sensor Class": + { + "ECEZO": + { + "Name": "Electrical Conductivity (EC) Circuit", + "Description": "This driver was tested with the Atlas Scientific Electrical Conductivity kit. This device can operate in either UART or I2C modes.", + "Aliases": ["ecezo"], + "Categories": ["ec", "conductivity", "liquid"], + "Connections": ["i2c", "uart"], + "Project Type": ["industrial"], + "Manufacturers": ["atlas", "sparkfun"], + "Kits": [], + "Examples": + { + "Java": ["ECEZO_Example.java"], + "Python": ["ecezo.py"], + "Node.js": ["ecezo.js"], + "C++": ["ecezo.cxx"], + "C": ["ecezo.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "mA", "low": 19, "high": 50}, + "Conductivity Probe Range": {"unit": "K", "low": 0.1, "high": 10}, + "Accurate Reading Range (K=0.1)": {"unit": "uS", "low": 0.5, "high": 50000}, + "Accurate Reading Range (K=1.0)": {"unit": "uS", "low": 5, "high": 200000}, + "Accurate Reading Range (K=10.0)": {"unit": "uS", "low": 10, "high": 1000000}, + "Operating Temperature": {"unit": "degC", "low": 1, "high": 35} + + }, + "Urls" : + { + "Product Pages": ["https://www.atlas-scientific.com/product_pages/kits/ec_k1_0_kit.html", "https://www.sparkfun.com/products/12908"], + "Datasheets": ["https://cdn.sparkfun.com/datasheets/Sensors/Biometric/EC_EZO_Datasheet.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/ecezo/javaupm_ecezo.i upm-1.7.1/src/ecezo/javaupm_ecezo.i --- upm-1.6.0/src/ecezo/javaupm_ecezo.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecezo/javaupm_ecezo.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_ecezo -%include "../upm.i" -%include "std_string.i" -%include "stdint.i" -%include "typemaps.i" - -%include "ecezo_defs.h" -%include "ecezo.hpp" -%{ - #include "ecezo.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_ecezo) diff -Nru upm-1.6.0/src/ecezo/jsupm_ecezo.i upm-1.7.1/src/ecezo/jsupm_ecezo.i --- upm-1.6.0/src/ecezo/jsupm_ecezo.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecezo/jsupm_ecezo.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_ecezo -%include "../upm.i" -%include "std_string.i" - -%include "ecezo_defs.h" -%include "ecezo.hpp" -%{ - #include "ecezo.hpp" -%} diff -Nru upm-1.6.0/src/ecezo/pyupm_ecezo.i upm-1.7.1/src/ecezo/pyupm_ecezo.i --- upm-1.6.0/src/ecezo/pyupm_ecezo.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecezo/pyupm_ecezo.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ecezo -%include "../upm.i" -%include "std_string.i" - -%include "ecezo_defs.h" -%include "ecezo.hpp" -%{ - #include "ecezo.hpp" -%} diff -Nru upm-1.6.0/src/ecs1030/ecs1030.hpp upm-1.7.1/src/ecs1030/ecs1030.hpp --- upm-1.6.0/src/ecs1030/ecs1030.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecs1030/ecs1030.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -67,8 +67,8 @@ * * @image html ecs1030.jpg *
ECS1030 Sensor image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet ecs1030.cxx Interesting */ diff -Nru upm-1.6.0/src/ecs1030/ecs1030.i upm-1.7.1/src/ecs1030/ecs1030.i --- upm-1.6.0/src/ecs1030/ecs1030.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ecs1030/ecs1030.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_ecs1030) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ecs1030.hpp" +%} +%include "ecs1030.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ecs1030/ecs1030.json upm-1.7.1/src/ecs1030/ecs1030.json --- upm-1.6.0/src/ecs1030/ecs1030.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecs1030/ecs1030.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "ecs1030", - "Description": "ECS1030 Electricity Sensor Library", - "Sensor Class": - { - "ECS1030": - { - "Name": "Non-Invasive Current Sensor", - "Description": "This non-invasive current sensor can be clamped around the supply line of an electrical load to tell you how much current is passing through it. It does this by acting as an inductor and responding to the magnetic field around a current-carrying conductor. This particular current sensor measures a load up to 30 A, which makes it great for building your own energy monitors.", - "Aliases": ["ecs1030"], - "Categories": ["meter", "electric"], - "Connections": ["analog"], - "Project Type": ["industrial"], - "Manufacturers": ["sparkfun"], - "Kits": [], - "Image": "ecs1030.jpg", - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["ecs1030.cxx"], - "C": [] - }, - "Specifications": - { - "Measurable Current": {"unit": "V", "low": 1, "nominal": 30, "maximum": 60}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 65} - - }, - "Urls" : - { - "Product Pages": ["https://www.sparkfun.com/products/11005"], - "Datasheets": ["https://cdn.sparkfun.com/datasheets/Sensors/Current/ECS1030-L72-SPEC.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "ecs1030", + "Description": "ECS1030 Electricity Sensor Library", + "Sensor Class": + { + "ECS1030": + { + "Name": "Non-Invasive Current Sensor", + "Description": "This non-invasive current sensor can be clamped around the supply line of an electrical load to tell you how much current is passing through it. It does this by acting as an inductor and responding to the magnetic field around a current-carrying conductor. This particular current sensor measures a load up to 30 A, which makes it great for building your own energy monitors.", + "Aliases": ["ecs1030"], + "Categories": ["meter", "electric"], + "Connections": ["analog"], + "Project Type": ["industrial"], + "Manufacturers": ["sparkfun"], + "Kits": [], + "Image": "ecs1030.jpg", + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["ecs1030.cxx"], + "C": [] + }, + "Specifications": + { + "Measurable Current": {"unit": "V", "low": 1, "nominal": 30, "maximum": 60}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 65} + + }, + "Urls" : + { + "Product Pages": ["https://www.sparkfun.com/products/11005"], + "Datasheets": ["https://cdn.sparkfun.com/datasheets/Sensors/Current/ECS1030-L72-SPEC.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/ecs1030/javaupm_ecs1030.i upm-1.7.1/src/ecs1030/javaupm_ecs1030.i --- upm-1.6.0/src/ecs1030/javaupm_ecs1030.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecs1030/javaupm_ecs1030.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_ecs1030 -%include "../upm.i" - -%{ - #include "ecs1030.hpp" -%} - -%include "ecs1030.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ecs1030) \ No newline at end of file diff -Nru upm-1.6.0/src/ecs1030/jsupm_ecs1030.i upm-1.7.1/src/ecs1030/jsupm_ecs1030.i --- upm-1.6.0/src/ecs1030/jsupm_ecs1030.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecs1030/jsupm_ecs1030.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ecs1030 -%include "../upm.i" - -%{ - #include "ecs1030.hpp" -%} - -%include "ecs1030.hpp" diff -Nru upm-1.6.0/src/ecs1030/pyupm_ecs1030.i upm-1.7.1/src/ecs1030/pyupm_ecs1030.i --- upm-1.6.0/src/ecs1030/pyupm_ecs1030.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ecs1030/pyupm_ecs1030.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ecs1030 -%include "../upm.i" - -%include "stdint.i" - -%include "ecs1030.hpp" -%{ - #include "ecs1030.hpp" -%} diff -Nru upm-1.6.0/src/ehr/ehr.i upm-1.7.1/src/ehr/ehr.i --- upm-1.6.0/src/ehr/ehr.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ehr/ehr.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore beatISR; + +JAVA_JNI_LOADLIBRARY(javaupm_ehr) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ehr.hpp" +%} +%include "ehr.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ehr/ehr.json upm-1.7.1/src/ehr/ehr.json --- upm-1.6.0/src/ehr/ehr.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ehr/ehr.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "ehr", - "Description": "API for the Ear-clip Heart Rate Sensor", - "Sensor Class": - { - "EHR": - { - "Name": "Ear-clip Heart Rate Sensor", - "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", - "Aliases": ["ehr"], - "Categories": ["heartrate"], - "Connections": ["gpio"], - "Project Type": ["medical", "wearables", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "ehr.jpg", - "Examples": - { - "Java": ["EHRSample.java"], - "Python": ["ehr.py"], - "Node.js": ["ehr.js"], - "C++": ["ehr.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3, "high": 5}, - "Operating Current": {"unit": "mA", "typ": 6.5}, - "Measurement Range": {"unit": "bpm", "min": 30} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Ear-clip-Heart-Rate-Sensor-p-1116.html"], - "Datasheets": ["http://wiki.seeedstudio.com/wiki/Grove_-_Heart_rate_ear_clip_kit"], - "Schematics": [] - } - } - } -} +{ + "Library": "ehr", + "Description": "API for the Ear-clip Heart Rate Sensor", + "Sensor Class": + { + "EHR": + { + "Name": "Ear-clip Heart Rate Sensor", + "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", + "Aliases": ["ehr"], + "Categories": ["heartrate"], + "Connections": ["gpio"], + "Project Type": ["medical", "wearables", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "ehr.jpg", + "Examples": + { + "Java": ["EHR_Example.java"], + "Python": ["ehr.py"], + "Node.js": ["ehr.js"], + "C++": ["ehr.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3, "high": 5}, + "Operating Current": {"unit": "mA", "typ": 6.5}, + "Measurement Range": {"unit": "bpm", "min": 30} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Ear-clip-Heart-Rate-Sensor-p-1116.html"], + "Datasheets": ["http://wiki.seeedstudio.com/wiki/Grove_-_Heart_rate_ear_clip_kit"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/ehr/javaupm_ehr.i upm-1.7.1/src/ehr/javaupm_ehr.i --- upm-1.6.0/src/ehr/javaupm_ehr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ehr/javaupm_ehr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_ehr -%include "../upm.i" - -%ignore beatISR; - -%{ - #include "ehr.hpp" -%} - -%include "ehr.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ehr) \ No newline at end of file diff -Nru upm-1.6.0/src/ehr/jsupm_ehr.i upm-1.7.1/src/ehr/jsupm_ehr.i --- upm-1.6.0/src/ehr/jsupm_ehr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ehr/jsupm_ehr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ehr -%include "../upm.i" - -%{ - #include "ehr.hpp" -%} - -%include "ehr.hpp" diff -Nru upm-1.6.0/src/ehr/pyupm_ehr.i upm-1.7.1/src/ehr/pyupm_ehr.i --- upm-1.6.0/src/ehr/pyupm_ehr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ehr/pyupm_ehr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ehr -%include "../upm.i" - -%include "ehr.hpp" -%{ - #include "ehr.hpp" -%} diff -Nru upm-1.6.0/src/eldriver/eldriver.json upm-1.7.1/src/eldriver/eldriver.json --- upm-1.6.0/src/eldriver/eldriver.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/eldriver/eldriver.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "eldriver", - "Description": "API for the EL Driver Module", - "Sensor Class": - { - "ElDriver": - { - "Name": "Electroluminescent Wire (EL) Driver", - "Description": "The EL Driver allows you to easily light up an EL wire with just one single cable.", - "Aliases": ["eldriver"], - "Categories": ["lighting"], - "Connections": ["gpio"], - "Project Type": ["prototyping", "commercial", "wearables"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "eldriver.jpg", - "Examples": - { - "Java": [], - "Python": ["eldriver.py"], - "Node.js": ["eldriver.js"], - "C++": ["eldriver.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "max": 300}, - "Supported EL Capacitance": {"unit": "nF", "max": 15} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-EL-Driver-p-2269.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-EL_Driver/"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EL_Driver/master/res/Grove-EL_Driver_v1.0.pdf"] - } - } - } -} +{ + "Library": "eldriver", + "Description": "API for the EL Driver Module", + "Sensor Class": + { + "ElDriver": + { + "Name": "Electroluminescent Wire (EL) Driver", + "Description": "The EL Driver allows you to easily light up an EL wire with just one single cable.", + "Aliases": ["eldriver"], + "Categories": ["lighting"], + "Connections": ["gpio"], + "Project Type": ["prototyping", "commercial", "wearables"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "eldriver.jpg", + "Examples": + { + "Java": [], + "Python": ["eldriver.py"], + "Node.js": ["eldriver.js"], + "C++": ["eldriver.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "mA", "max": 300}, + "Supported EL Capacitance": {"unit": "nF", "max": 15} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-EL-Driver-p-2269.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-EL_Driver/"], + "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EL_Driver/master/res/Grove-EL_Driver_v1.0.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/eldriver/javaupm_eldriver.i upm-1.7.1/src/eldriver/javaupm_eldriver.i --- upm-1.6.0/src/eldriver/javaupm_eldriver.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/eldriver/javaupm_eldriver.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_eldriver -%include "../upm.i" - -%{ - #include "eldriver.hpp" -%} - -%include "eldriver.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_eldriver) \ No newline at end of file diff -Nru upm-1.6.0/src/eldriver/jsupm_eldriver.i upm-1.7.1/src/eldriver/jsupm_eldriver.i --- upm-1.6.0/src/eldriver/jsupm_eldriver.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/eldriver/jsupm_eldriver.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_eldriver -%include "../upm.i" - -%{ - #include "eldriver.hpp" -%} - -%include "eldriver.hpp" diff -Nru upm-1.6.0/src/eldriver/pyupm_eldriver.i upm-1.7.1/src/eldriver/pyupm_eldriver.i --- upm-1.6.0/src/eldriver/pyupm_eldriver.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/eldriver/pyupm_eldriver.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_eldriver -%include "../upm.i" - -%include "eldriver.hpp" -%{ - #include "eldriver.hpp" -%} diff -Nru upm-1.6.0/src/electromagnet/electromagnet.json upm-1.7.1/src/electromagnet/electromagnet.json --- upm-1.6.0/src/electromagnet/electromagnet.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/electromagnet/electromagnet.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,41 +1,41 @@ -{ - "Library": "electromagnet", - "Description": "Electromagnet Library", - "Sensor Class": - { - "Electromagnet": - { - "Name": "API for the Electromagnet", - "Description": "The Electromagnet can hold up to 1 kg (approximately 2.2 lbs)", - "Aliases": ["electromagnet"], - "Categories": ["electric", "magnetic"], - "Connections": ["gpio"], - "Project Type": ["prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "electromagnet.jpg", - "Examples": - { - "Java": [], - "Python": ["electromagnet.py"], - "Node.js": ["electromagnet.js"], - "C++": ["electromagnet.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "typ": 400}, - "Standby Current": {"unit": "uA", "typ": 200}, - "Max Load Weight": {"unit": "kgs", "typ": 1} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Electromagnet-p-1820.html"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Electromagnet/master/res/ZYE1-P20-15.pdf", "http://wiki.seeed.cc/Grove-Electromagnet/"], - "Schematics": [] - } - } - } -} +{ + "Library": "electromagnet", + "Description": "Electromagnet Library", + "Sensor Class": + { + "Electromagnet": + { + "Name": "API for the Electromagnet", + "Description": "The Electromagnet can hold up to 1 kg (approximately 2.2 lbs)", + "Aliases": ["electromagnet"], + "Categories": ["electric", "magnetic"], + "Connections": ["gpio"], + "Project Type": ["prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "electromagnet.jpg", + "Examples": + { + "Java": [], + "Python": ["electromagnet.py"], + "Node.js": ["electromagnet.js"], + "C++": ["electromagnet.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "typ": 400}, + "Standby Current": {"unit": "uA", "typ": 200}, + "Max Load Weight": {"unit": "kgs", "typ": 1} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Electromagnet-p-1820.html"], + "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Electromagnet/master/res/ZYE1-P20-15.pdf", "http://wiki.seeed.cc/Grove-Electromagnet/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/electromagnet/javaupm_electromagnet.i upm-1.7.1/src/electromagnet/javaupm_electromagnet.i --- upm-1.6.0/src/electromagnet/javaupm_electromagnet.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/electromagnet/javaupm_electromagnet.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_electromagnet -%include "../upm.i" - -%{ - #include "electromagnet.hpp" -%} - -%include "electromagnet.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_electromagnet) \ No newline at end of file diff -Nru upm-1.6.0/src/electromagnet/jsupm_electromagnet.i upm-1.7.1/src/electromagnet/jsupm_electromagnet.i --- upm-1.6.0/src/electromagnet/jsupm_electromagnet.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/electromagnet/jsupm_electromagnet.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_electromagnet -%include "../upm.i" - -%{ - #include "electromagnet.hpp" -%} - -%include "electromagnet.hpp" diff -Nru upm-1.6.0/src/electromagnet/pyupm_electromagnet.i upm-1.7.1/src/electromagnet/pyupm_electromagnet.i --- upm-1.6.0/src/electromagnet/pyupm_electromagnet.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/electromagnet/pyupm_electromagnet.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_electromagnet -%include "../upm.i" - -%include "electromagnet.hpp" -%{ - #include "electromagnet.hpp" -%} diff -Nru upm-1.6.0/src/emg/emg.json upm-1.7.1/src/emg/emg.json --- upm-1.6.0/src/emg/emg.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/emg/emg.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "emg", - "Description": "Grove EMG Muscle Signal Reader Library", - "Sensor Class": - { - "EMG": - { - "Name": "Electromyography (EMG) Sensor", - "Description": "Grove EMG muscle signal reader gathers small muscle signals, then processes them, and returns the result.", - "Aliases": ["emg"], - "Categories": ["electromyography", "medical"], - "Connections": ["analog"], - "Project Type": ["wearables", "computer interfacing", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "emg.jpg", - "Examples": - { - "Java": ["Emg.java"], - "Python": ["emg.py"], - "Node.js": ["emg.js"], - "C++": ["emg.cxx"], - "C": ["emg.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-EMG-Detector-p-1737.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-EMG_Detector/"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EMG_Detector/master/res/Grove-EMG_Sensor_v1.1_SCH.pdf"] - } - } - } -} +{ + "Library": "emg", + "Description": "Grove EMG Muscle Signal Reader Library", + "Sensor Class": + { + "EMG": + { + "Name": "Electromyography (EMG) Sensor", + "Description": "Grove EMG muscle signal reader gathers small muscle signals, then processes them, and returns the result.", + "Aliases": ["emg"], + "Categories": ["electromyography", "medical"], + "Connections": ["analog"], + "Project Type": ["wearables", "computer interfacing", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "emg.jpg", + "Examples": + { + "Java": ["Emg_Example.java"], + "Python": ["emg.py"], + "Node.js": ["emg.js"], + "C++": ["emg.cxx"], + "C": ["emg.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-EMG-Detector-p-1737.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-EMG_Detector/"], + "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EMG_Detector/master/res/Grove-EMG_Sensor_v1.1_SCH.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/emg/javaupm_emg.i upm-1.7.1/src/emg/javaupm_emg.i --- upm-1.6.0/src/emg/javaupm_emg.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/emg/javaupm_emg.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_emg -%include "../upm.i" - -%{ - #include "emg.hpp" -%} - -%include "emg.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_emg) \ No newline at end of file diff -Nru upm-1.6.0/src/emg/jsupm_emg.i upm-1.7.1/src/emg/jsupm_emg.i --- upm-1.6.0/src/emg/jsupm_emg.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/emg/jsupm_emg.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_emg -%include "../upm.i" - -%{ - #include "emg.hpp" -%} - -%include "emg.hpp" diff -Nru upm-1.6.0/src/emg/pyupm_emg.i upm-1.7.1/src/emg/pyupm_emg.i --- upm-1.6.0/src/emg/pyupm_emg.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/emg/pyupm_emg.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_emg -%include "../upm.i" - -%include "emg.hpp" -%{ - #include "emg.hpp" -%} diff -Nru upm-1.6.0/src/enc03r/enc03r.json upm-1.7.1/src/enc03r/enc03r.json --- upm-1.6.0/src/enc03r/enc03r.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/enc03r/enc03r.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "enc03r", - "Description": "ENC03R Single Axis Gyro Library", - "Sensor Class": - { - "ENC03R": - { - "Name": "Single-axis Analog Gyro Module", - "Description": "UPM module for the ENC03R single axis analog gyro. This gyroscope measures x-axis angular velocity, that is how fast the sensor is rotating around the x-axis. Calibration of the sensor is necessary for accurate readings.", - "Aliases": ["enc03r"], - "Categories": ["gyroscope", "IMU", "Discontinued"], - "Connections": ["analog"], - "Project Type": ["prototyping"], - "Manufacturers": ["murata", "seeed"], - "Kits": ["robok"], - "Image": "enc03r.jpg", - "Examples": - { - "Java": ["ENC03RSample.java"], - "Python": ["enc03r.py"], - "Node.js": ["enc03r.js"], - "C++": ["enc03r.cxx"], - "C": ["enc03r.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.25}, - "Response Time": {"unit": "Hz", "typ": 50}, - "Operating Temperature": {"unit": "decC", "low": -5, "high": 75} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Single-Axis-Analog-Gyro-p-1451.html"], - "Datasheets": ["http://www.seeedstudio.com/wiki/File:Analog_Gyro_datasheet.pdf", "http://wiki.seeedstudio.com/wiki/Grove_-_Single_Axis_Analog_Gyro"], - "Schematics": [] - } - } - } -} +{ + "Library": "enc03r", + "Description": "ENC03R Single Axis Gyro Library", + "Sensor Class": + { + "ENC03R": + { + "Name": "Single-axis Analog Gyro Module", + "Description": "UPM module for the ENC03R single axis analog gyro. This gyroscope measures x-axis angular velocity, that is how fast the sensor is rotating around the x-axis. Calibration of the sensor is necessary for accurate readings.", + "Aliases": ["enc03r"], + "Categories": ["gyroscope", "IMU", "Discontinued"], + "Connections": ["analog"], + "Project Type": ["prototyping"], + "Manufacturers": ["murata", "seeed"], + "Kits": ["robok"], + "Image": "enc03r.jpg", + "Examples": + { + "Java": ["ENC03R_Example.java"], + "Python": ["enc03r.py"], + "Node.js": ["enc03r.js"], + "C++": ["enc03r.cxx"], + "C": ["enc03r.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.25}, + "Response Time": {"unit": "Hz", "typ": 50}, + "Operating Temperature": {"unit": "decC", "low": -5, "high": 75} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Single-Axis-Analog-Gyro-p-1451.html"], + "Datasheets": ["http://www.seeedstudio.com/wiki/File:Analog_Gyro_datasheet.pdf", "http://wiki.seeedstudio.com/wiki/Grove_-_Single_Axis_Analog_Gyro"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/enc03r/javaupm_enc03r.i upm-1.7.1/src/enc03r/javaupm_enc03r.i --- upm-1.6.0/src/enc03r/javaupm_enc03r.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/enc03r/javaupm_enc03r.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_enc03r -%include "../upm.i" - -%{ - #include "enc03r.hpp" -%} - -%include "enc03r.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_enc03r) \ No newline at end of file diff -Nru upm-1.6.0/src/enc03r/jsupm_enc03r.i upm-1.7.1/src/enc03r/jsupm_enc03r.i --- upm-1.6.0/src/enc03r/jsupm_enc03r.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/enc03r/jsupm_enc03r.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_enc03r -%include "../upm.i" - -%{ - #include "enc03r.hpp" -%} - -%include "enc03r.hpp" diff -Nru upm-1.6.0/src/enc03r/pyupm_enc03r.i upm-1.7.1/src/enc03r/pyupm_enc03r.i --- upm-1.6.0/src/enc03r/pyupm_enc03r.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/enc03r/pyupm_enc03r.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_enc03r -%include "../upm.i" - -%include "enc03r.hpp" -%{ - #include "enc03r.hpp" -%} diff -Nru upm-1.6.0/src/flex/flex.hpp upm-1.7.1/src/flex/flex.hpp --- upm-1.6.0/src/flex/flex.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/flex/flex.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -51,8 +51,8 @@ * * @image html flex.jpg *
Flex Sensor image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet flex.cxx Interesting */ diff -Nru upm-1.6.0/src/flex/flex.json upm-1.7.1/src/flex/flex.json --- upm-1.6.0/src/flex/flex.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/flex/flex.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "flex", - "Description": "API for the Spectra Symbol Flex Sensor", - "Sensor Class": - { - "Flex": - { - "Name": "Resistive Flex Sensor", - "Description": "A simple flex sensor. The resistance across the sensor increases when flexed. Patented technology by Spectra Symbol, these sensors were used in the original Nintendo* Power Glove.", - "Aliases": ["flex"], - "Categories": ["flex sensors"], - "Connections": ["analog"], - "Project Type": ["prototyping", "industrial"], - "Manufacturers": ["sparkfun"], - "Kits": [], - "Image": "flex.jpg", - "Examples": - { - "Java": ["FlexSensorExample.java"], - "Python": [], - "Node.js": ["flex.js"], - "C++": ["flex.cxx"], - "C": [] - }, - "Specifications": - { - "Flat Resistance": {"unit": "KOhms", "typ": 10}, - "Bend Resistance": {"unit": "KOhms", "low": 60, "high": 110}, - "Temperature Range": {"unit": "degC", "low": -35, "high": 80} - }, - "Urls" : - { - "Product Pages": ["https://www.sparkfun.com/products/8606"], - "Datasheets": ["https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/FLEXSENSORREVA1.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "flex", + "Description": "API for the Spectra Symbol Flex Sensor", + "Sensor Class": + { + "Flex": + { + "Name": "Resistive Flex Sensor", + "Description": "A simple flex sensor. The resistance across the sensor increases when flexed. Patented technology by Spectra Symbol, these sensors were used in the original Nintendo* Power Glove.", + "Aliases": ["flex"], + "Categories": ["flex sensors"], + "Connections": ["analog"], + "Project Type": ["prototyping", "industrial"], + "Manufacturers": ["sparkfun"], + "Kits": [], + "Image": "flex.jpg", + "Examples": + { + "Java": ["FlexSensor_Example.java"], + "Python": [], + "Node.js": ["flex.js"], + "C++": ["flex.cxx"], + "C": [] + }, + "Specifications": + { + "Flat Resistance": {"unit": "KOhms", "typ": 10}, + "Bend Resistance": {"unit": "KOhms", "low": 60, "high": 110}, + "Temperature Range": {"unit": "degC", "low": -35, "high": 80} + }, + "Urls" : + { + "Product Pages": ["https://www.sparkfun.com/products/8606"], + "Datasheets": ["https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/FLEXSENSORREVA1.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/flex/javaupm_flex.i upm-1.7.1/src/flex/javaupm_flex.i --- upm-1.6.0/src/flex/javaupm_flex.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/flex/javaupm_flex.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_flex -%include "../upm.i" - -%{ - #include "flex.hpp" -%} - -%include "flex.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_flex) \ No newline at end of file diff -Nru upm-1.6.0/src/flex/jsupm_flex.i upm-1.7.1/src/flex/jsupm_flex.i --- upm-1.6.0/src/flex/jsupm_flex.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/flex/jsupm_flex.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_flex -%include "../upm.i" - -%{ - #include "flex.hpp" -%} - -%include "flex.hpp" diff -Nru upm-1.6.0/src/flex/pyupm_flex.i upm-1.7.1/src/flex/pyupm_flex.i --- upm-1.6.0/src/flex/pyupm_flex.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/flex/pyupm_flex.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_flex -%include "../upm.i" - -%include "flex.hpp" -%{ - #include "flex.hpp" -%} diff -Nru upm-1.6.0/src/gas/gas.i upm-1.7.1/src/gas/gas.i --- upm-1.6.0/src/gas/gas.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/gas/gas.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,75 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%typemap(jni) (uint16_t *buffer, int len) "jshortArray"; +%typemap(jtype) (uint16_t *buffer, int len) "short[]"; +%typemap(jstype) (uint16_t *buffer, int len) "short[]"; + +%typemap(javain) (uint16_t *buffer, int len) "$javainput"; + +%typemap(in) (uint16_t *buffer, int len) { + $1 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL); + $2 = JCALL1(GetArrayLength, jenv, $input); +} + +%typemap(freearg) (uint16_t *buffer, int len) { + JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$1, 0); +} + +%typemap(jni) (int numberOfSamples, uint16_t *buffer) "jshortArray"; +%typemap(jtype) (int numberOfSamples, uint16_t *buffer) "short[]"; +%typemap(jstype) (int numberOfSamples, uint16_t *buffer) "short[]"; + +%typemap(javain) (int numberOfSamples, uint16_t *buffer) "$javainput"; + +%typemap(in) (int numberOfSamples, uint16_t *buffer) { + $2 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL); + $1 = JCALL1(GetArrayLength, jenv, $input); +} + +%typemap(freearg) (int numberOfSamples, uint16_t *buffer) { + JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$2, 0); +} + +JAVA_JNI_LOADLIBRARY(javaupm_gas) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint16_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_uint16_t.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "gas.hpp" +#include "mq2.hpp" +#include "mq3.hpp" +#include "mq4.hpp" +#include "mq5.hpp" +#include "mq6.hpp" +#include "mq7.hpp" +#include "mq8.hpp" +#include "mq9.hpp" +#include "tp401.hpp" +%} + +%include "gas.hpp" +%include "mq2.hpp" +%include "mq3.hpp" +%include "mq4.hpp" +%include "mq5.hpp" +%include "mq6.hpp" +%include "mq7.hpp" +%include "mq8.hpp" +%include "mq9.hpp" +%include "tp401.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/gas/gas.json upm-1.7.1/src/gas/gas.json --- upm-1.6.0/src/gas/gas.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gas/gas.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,275 +1,275 @@ -{ - "Library": "gas", - "Description": "Gas Sensor Library", - "Sensor Class": - { - "MQ2": - { - "Name": "MQ2 Methane, Butane, Liquefied Petroleum Gas (LPG), and Smoke Sensor", - "Description": "The MQ2 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect LPG, i-butane, methane, alcohol, hydrogen, smoke, and other combustible gases. It's a medium-sensitivity sensor with a detection range of 300-10,000 ppm.", - "Aliases": ["mq2"], - "Categories": ["gas"], - "Connections": ["analog"], - "Project Type": ["prototyping", "safety", "industrial"], - "Manufacturers": ["seeed"], - "Kits": ["hak"], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["gas-mq2.cxx"], - "C": ["gas-mqx.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "low": 0.1, "high": 160}, - "Heater Resistance": {"unit": "Ohms", "typ": 33}, - "Sensor Resistance": {"unit": "KOhms", "low": 3, "high": 30} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Gas-Sensor(MQ2)-p-937.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-MQ2/"], - "Schematics": [] - } - }, - - "MQ3": - { - "Name": "MQ3 Alcohol, Ethanol, Smoke Sensor", - "Description": "The MQ3 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect alcohol vapors and benzine. It's highly sensitive but has a long warm-up time of about 1 minute. It's detection range is 0.04-4 mg/L Alcohol.", - "Aliases": ["mq3"], - "Categories": ["gas"], - "Connections": ["analog"], - "Project Type": ["prototyping", "safety", "industrial"], - "Manufacturers": ["seeed"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["gas-mq3.cxx"], - "C": ["gas-mqx.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "low": 0.1, "high": 150}, - "Heater Resistance": {"unit": "Ohms", "typ": 33}, - "Sensor Resistance": {"unit": "MOhms", "low": 1, "high": 8}, - "Detectable Concentration": {"unit": "mg/L", "low": 0.05, "high": 10} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Gas-Sensor%28MQ3%29-p-1418.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-MQ3/"], - "Schematics": [] - } - }, - - "MQ4": - { - "Name": "MQ4 Methane and Connecticut Natural Gas (CNG) Sensor", - "Description": "The MQ4 Gas Sensor module is useful for detecting CH4 (Methane), and natural gas concentrations in the air. It has a detection range of 100-10000 ppm. For optimum use, it requires calibration after a pre-heat time of at least 24 hours. See the datasheet for details.", - "Aliases": ["mq4"], - "Categories": ["gas"], - "Connections": ["analog"], - "Project Type": ["prototyping", "safety", "industrial"], - "Manufacturers": ["dfrobot"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["gas-mq4.cxx"], - "C": ["gas-mqx.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "low": 0.1, "high": 150}, - "Heater Resistance": {"unit": "Ohms", "typ": 33}, - "Sensor Resistance": {"unit": "KOhms", "low": 10, "high": 60} - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/product-683.html"], - "Datasheets": ["http://image.dfrobot.com/image/data/SEN0129/MQ-4.pdf", "https://www.dfrobot.com/wiki/index.php/Analog_Gas_Sensor(MQ4)_(SKU:SEN0129)"], - "Schematics": [] - } - }, - - "MQ5": - { - "Name": "MQ5 Natural Gas and Liquefied Petroleum Gas (LPG) Sensor", - "Description": "The MQ5 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect LPG, natural gas, town gas, and so on. It is highly sensitive and has a detection range of 300-10,000 ppm.", - "Aliases": ["mq5"], - "Categories": ["gas"], - "Connections": ["analog"], - "Project Type": ["prototyping", "safety", "industrial"], - "Manufacturers": ["seeed"], - "Kits": ["eak"], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["gas-mq5.cxx"], - "C": ["gas-mqx.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "low": 0.1, "high": 160}, - "Heater Resistance": {"unit": "Ohms", "typ": 31}, - "Sensor Resistance": {"unit": "KOhms", "low": 10, "high": 60}, - "Detectable Concentration": {"unit": "ppm", "low": 200, "high": 10000} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Gas-Sensor%28MQ5%29-p-938.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-MQ5/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Gas_Sensor-MQ5/master/res/MQ-5.pdf"], - "Schematics": [] - } - }, - - "MQ6": - { - "Name": "MQ6 Liquefied Petroleum Gas (LPG) and Butane Sensor", - "Description": "The MQ6 Gas Sensor module is useful for detecting LPG, iso-butane, propane, and LNG concentrations in the air. It has a detection range of 200-10000 ppm. For optimum use, it requires calibration after a pre-heat time of at least 24 hours. See the datasheet for details.", - "Aliases": ["mq6"], - "Categories": ["gas"], - "Connections": ["analog"], - "Project Type": ["prototyping", "safety", "industrial"], - "Manufacturers": ["dfrobot"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["gas-mq6.cxx"], - "C": ["gas-mqx.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "low": 0.1, "high": 150}, - "Heater Resistance": {"unit": "Ohms", "typ": 33}, - "Sensor Resistance": {"unit": "KOhms", "low": 10, "high": 60}, - "Detectable Concentration": {"unit": "ppm", "low": 200, "high": 10000} - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/product-685.html"], - "Datasheets": ["https://www.dfrobot.com/wiki/index.php/LPG_Gas_Sensor(MQ6)_(SKU:SEN0131)", "http://image.dfrobot.com/image/data/SEN0131/MQ-6.pdf"], - "Schematics": ["http://image.dfrobot.com/image/data/SEN0131/MQ-X%20Schematic.pdf"] - } - }, - - "MQ7": - { - "Name": "MQ7 Carbon Monoxide Sensor", - "Description": "The Grove MQ7 Gas Sensor module is useful for detecting Carbon Monoxide (CO) concentrations in the air. It has a detection range of 20-2000 ppm. For optimum use, it requires calibration after a pre-heat time of 48 hours. See the datasheet for details.", - "Aliases": ["mq7"], - "Categories": ["gas"], - "Connections": ["analog"], - "Project Type": ["prototyping", "safety", "industrial"], - "Manufacturers": ["dfrobot"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["gas-mq7.cxx"], - "C": ["gas-mqx.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "typ": 70}, - "Heater Resistance": {"unit": "Ohms", "typ": 33}, - "Detectable Concentration": {"unit": "ppm", "low": 20, "high": 2000} - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/product-686.html"], - "Datasheets": ["https://www.dfrobot.com/wiki/index.php/Carbon_Monoxide_Gas_Sensor(MQ7)_(SKU:SEN0132)", "http://image.dfrobot.com/image/data/SEN0132/MQ-7.pdf"], - "Schematics": ["http://image.dfrobot.com/image/data/SEN0132/MQ-X%20Schematic.pdf"] - } - }, - - "MQ8": - { - "Name": "MQ8 Flammable (Hydrogen) Gas Sensor", - "Description": "The MQ8 Gas Sensor module is useful for detecting Hydrogen gas concentrations in the air. It has a detection range of 100-10000 ppm. For optimum use, it requires calibration after a pre-heat time of at least 24 hours. See the datasheet for details.", - "Aliases": ["mq8"], - "Categories": ["gas"], - "Connections": ["analog"], - "Project Type": ["prototyping", "safety", "industrial"], - "Manufacturers": ["dfrobot"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["gas-mq8.cxx"], - "C": ["gas-mqx.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "max": 160}, - "Heater Resistance": {"unit": "Ohms", "typ": 31}, - "Sensor Resistance": {"unit": "KOhms", "low": 10, "high": 60}, - "Detectable Concentration": {"unit": "ppm", "low": 100, "high": 10000} - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/product-687.html"], - "Datasheets": ["https://www.dfrobot.com/wiki/index.php/Hydrogen_Gas_Sensor(MQ8)_(SKU:SEN0133)", "http://image.dfrobot.com/image/data/SEN0133/MQ-8.pdf"], - "Schematics": ["http://image.dfrobot.com/image/data/SEN0133/MQ-X%20Schematic.pdf"] - } - }, - - "MQ9": - { - "Name": "MQ9 Carbon Monoxide (CO) and Flammable Gas Sensor", - "Description": "The Grove MQ9 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect carbon monoxide, coal gas, and liquefied gas. Its sensitivity is 10-1,000 ppm CO, and 100-10,000 ppm Gas.", - "Aliases": ["mq9"], - "Categories": ["gas"], - "Connections": ["analog"], - "Project Type": ["prototyping", "safety", "industrial"], - "Manufacturers": ["seeed"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["gas-mq9.cxx"], - "C": ["gas-mqx.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "low": 0.1, "high": 68}, - "Heater Resistance": {"unit": "Ohms", "typ": 33}, - "Sensor Resistance": {"unit": "Ohms", "low": 2, "high": 20000}, - "Detectable Concentration": {"unit": "ppm", "low": 200, "high": 10000} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Gas-Sensor%28MQ9%29-p-1419.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-MQ9/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Gas_Sensor-MQ9/master/res/MQ-9.pdf"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Gas_Sensor-MQ9/master/res/Gas_Sensor_Schematic.pdf"] - } - } - } -} +{ + "Library": "gas", + "Description": "Gas Sensor Library", + "Sensor Class": + { + "MQ2": + { + "Name": "MQ2 Methane, Butane, Liquefied Petroleum Gas (LPG), and Smoke Sensor", + "Description": "The MQ2 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect LPG, i-butane, methane, alcohol, hydrogen, smoke, and other combustible gases. It's a medium-sensitivity sensor with a detection range of 300-10,000 ppm.", + "Aliases": ["mq2"], + "Categories": ["gas"], + "Connections": ["analog"], + "Project Type": ["prototyping", "safety", "industrial"], + "Manufacturers": ["seeed"], + "Kits": ["hak"], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["gas-mq2.cxx"], + "C": ["gas-mqx.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "low": 0.1, "high": 160}, + "Heater Resistance": {"unit": "Ohms", "typ": 33}, + "Sensor Resistance": {"unit": "KOhms", "low": 3, "high": 30} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Gas-Sensor(MQ2)-p-937.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-MQ2/"], + "Schematics": [] + } + }, + + "MQ3": + { + "Name": "MQ3 Alcohol, Ethanol, Smoke Sensor", + "Description": "The MQ3 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect alcohol vapors and benzine. It's highly sensitive but has a long warm-up time of about 1 minute. It's detection range is 0.04-4 mg/L Alcohol.", + "Aliases": ["mq3"], + "Categories": ["gas"], + "Connections": ["analog"], + "Project Type": ["prototyping", "safety", "industrial"], + "Manufacturers": ["seeed"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["gas-mq3.cxx"], + "C": ["gas-mqx.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "low": 0.1, "high": 150}, + "Heater Resistance": {"unit": "Ohms", "typ": 33}, + "Sensor Resistance": {"unit": "MOhms", "low": 1, "high": 8}, + "Detectable Concentration": {"unit": "mg/L", "low": 0.05, "high": 10} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Gas-Sensor%28MQ3%29-p-1418.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-MQ3/"], + "Schematics": [] + } + }, + + "MQ4": + { + "Name": "MQ4 Methane and Connecticut Natural Gas (CNG) Sensor", + "Description": "The MQ4 Gas Sensor module is useful for detecting CH4 (Methane), and natural gas concentrations in the air. It has a detection range of 100-10000 ppm. For optimum use, it requires calibration after a pre-heat time of at least 24 hours. See the datasheet for details.", + "Aliases": ["mq4"], + "Categories": ["gas"], + "Connections": ["analog"], + "Project Type": ["prototyping", "safety", "industrial"], + "Manufacturers": ["dfrobot"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["gas-mq4.cxx"], + "C": ["gas-mqx.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "low": 0.1, "high": 150}, + "Heater Resistance": {"unit": "Ohms", "typ": 33}, + "Sensor Resistance": {"unit": "KOhms", "low": 10, "high": 60} + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/product-683.html"], + "Datasheets": ["http://image.dfrobot.com/image/data/SEN0129/MQ-4.pdf", "https://www.dfrobot.com/wiki/index.php/Analog_Gas_Sensor(MQ4)_(SKU:SEN0129)"], + "Schematics": [] + } + }, + + "MQ5": + { + "Name": "MQ5 Natural Gas and Liquefied Petroleum Gas (LPG) Sensor", + "Description": "The MQ5 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect LPG, natural gas, town gas, and so on. It is highly sensitive and has a detection range of 300-10,000 ppm.", + "Aliases": ["mq5"], + "Categories": ["gas"], + "Connections": ["analog"], + "Project Type": ["prototyping", "safety", "industrial"], + "Manufacturers": ["seeed"], + "Kits": ["eak"], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["gas-mq5.cxx"], + "C": ["gas-mqx.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "low": 0.1, "high": 160}, + "Heater Resistance": {"unit": "Ohms", "typ": 31}, + "Sensor Resistance": {"unit": "KOhms", "low": 10, "high": 60}, + "Detectable Concentration": {"unit": "ppm", "low": 200, "high": 10000} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Gas-Sensor%28MQ5%29-p-938.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-MQ5/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Gas_Sensor-MQ5/master/res/MQ-5.pdf"], + "Schematics": [] + } + }, + + "MQ6": + { + "Name": "MQ6 Liquefied Petroleum Gas (LPG) and Butane Sensor", + "Description": "The MQ6 Gas Sensor module is useful for detecting LPG, iso-butane, propane, and LNG concentrations in the air. It has a detection range of 200-10000 ppm. For optimum use, it requires calibration after a pre-heat time of at least 24 hours. See the datasheet for details.", + "Aliases": ["mq6"], + "Categories": ["gas"], + "Connections": ["analog"], + "Project Type": ["prototyping", "safety", "industrial"], + "Manufacturers": ["dfrobot"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["gas-mq6.cxx"], + "C": ["gas-mqx.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "low": 0.1, "high": 150}, + "Heater Resistance": {"unit": "Ohms", "typ": 33}, + "Sensor Resistance": {"unit": "KOhms", "low": 10, "high": 60}, + "Detectable Concentration": {"unit": "ppm", "low": 200, "high": 10000} + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/product-685.html"], + "Datasheets": ["https://www.dfrobot.com/wiki/index.php/LPG_Gas_Sensor(MQ6)_(SKU:SEN0131)", "http://image.dfrobot.com/image/data/SEN0131/MQ-6.pdf"], + "Schematics": ["http://image.dfrobot.com/image/data/SEN0131/MQ-X%20Schematic.pdf"] + } + }, + + "MQ7": + { + "Name": "MQ7 Carbon Monoxide Sensor", + "Description": "The Grove MQ7 Gas Sensor module is useful for detecting Carbon Monoxide (CO) concentrations in the air. It has a detection range of 20-2000 ppm. For optimum use, it requires calibration after a pre-heat time of 48 hours. See the datasheet for details.", + "Aliases": ["mq7"], + "Categories": ["gas"], + "Connections": ["analog"], + "Project Type": ["prototyping", "safety", "industrial"], + "Manufacturers": ["dfrobot"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["gas-mq7.cxx"], + "C": ["gas-mqx.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "typ": 70}, + "Heater Resistance": {"unit": "Ohms", "typ": 33}, + "Detectable Concentration": {"unit": "ppm", "low": 20, "high": 2000} + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/product-686.html"], + "Datasheets": ["https://www.dfrobot.com/wiki/index.php/Carbon_Monoxide_Gas_Sensor(MQ7)_(SKU:SEN0132)", "http://image.dfrobot.com/image/data/SEN0132/MQ-7.pdf"], + "Schematics": ["http://image.dfrobot.com/image/data/SEN0132/MQ-X%20Schematic.pdf"] + } + }, + + "MQ8": + { + "Name": "MQ8 Flammable (Hydrogen) Gas Sensor", + "Description": "The MQ8 Gas Sensor module is useful for detecting Hydrogen gas concentrations in the air. It has a detection range of 100-10000 ppm. For optimum use, it requires calibration after a pre-heat time of at least 24 hours. See the datasheet for details.", + "Aliases": ["mq8"], + "Categories": ["gas"], + "Connections": ["analog"], + "Project Type": ["prototyping", "safety", "industrial"], + "Manufacturers": ["dfrobot"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["gas-mq8.cxx"], + "C": ["gas-mqx.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "max": 160}, + "Heater Resistance": {"unit": "Ohms", "typ": 31}, + "Sensor Resistance": {"unit": "KOhms", "low": 10, "high": 60}, + "Detectable Concentration": {"unit": "ppm", "low": 100, "high": 10000} + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/product-687.html"], + "Datasheets": ["https://www.dfrobot.com/wiki/index.php/Hydrogen_Gas_Sensor(MQ8)_(SKU:SEN0133)", "http://image.dfrobot.com/image/data/SEN0133/MQ-8.pdf"], + "Schematics": ["http://image.dfrobot.com/image/data/SEN0133/MQ-X%20Schematic.pdf"] + } + }, + + "MQ9": + { + "Name": "MQ9 Carbon Monoxide (CO) and Flammable Gas Sensor", + "Description": "The Grove MQ9 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect carbon monoxide, coal gas, and liquefied gas. Its sensitivity is 10-1,000 ppm CO, and 100-10,000 ppm Gas.", + "Aliases": ["mq9"], + "Categories": ["gas"], + "Connections": ["analog"], + "Project Type": ["prototyping", "safety", "industrial"], + "Manufacturers": ["seeed"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["gas-mq9.cxx"], + "C": ["gas-mqx.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "low": 0.1, "high": 68}, + "Heater Resistance": {"unit": "Ohms", "typ": 33}, + "Sensor Resistance": {"unit": "Ohms", "low": 2, "high": 20000}, + "Detectable Concentration": {"unit": "ppm", "low": 200, "high": 10000} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Gas-Sensor%28MQ9%29-p-1419.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-MQ9/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Gas_Sensor-MQ9/master/res/MQ-9.pdf"], + "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Gas_Sensor-MQ9/master/res/Gas_Sensor_Schematic.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/gas/javaupm_gas.i upm-1.7.1/src/gas/javaupm_gas.i --- upm-1.6.0/src/gas/javaupm_gas.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gas/javaupm_gas.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -%module javaupm_gas -%include "../upm.i" -%include "typemaps.i" - -%{ - #include "gas.hpp" - #include "mq2.hpp" - #include "mq3.hpp" - #include "mq4.hpp" - #include "mq5.hpp" - #include "mq6.hpp" - #include "mq7.hpp" - #include "mq8.hpp" - #include "mq9.hpp" - #include "tp401.hpp" -%} - -%typemap(jni) (uint16_t *buffer, int len) "jshortArray"; -%typemap(jtype) (uint16_t *buffer, int len) "short[]"; -%typemap(jstype) (uint16_t *buffer, int len) "short[]"; - -%typemap(javain) (uint16_t *buffer, int len) "$javainput"; - -%typemap(in) (uint16_t *buffer, int len) { - $1 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL); - $2 = JCALL1(GetArrayLength, jenv, $input); -} - -%typemap(freearg) (uint16_t *buffer, int len) { - JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$1, 0); -} - -%typemap(jni) (int numberOfSamples, uint16_t *buffer) "jshortArray"; -%typemap(jtype) (int numberOfSamples, uint16_t *buffer) "short[]"; -%typemap(jstype) (int numberOfSamples, uint16_t *buffer) "short[]"; - -%typemap(javain) (int numberOfSamples, uint16_t *buffer) "$javainput"; - -%typemap(in) (int numberOfSamples, uint16_t *buffer) { - $2 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL); - $1 = JCALL1(GetArrayLength, jenv, $input); -} - -%typemap(freearg) (int numberOfSamples, uint16_t *buffer) { - JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$2, 0); -} - -%include "gas.hpp" -%include "mq2.hpp" -%include "mq3.hpp" -%include "mq4.hpp" -%include "mq5.hpp" -%include "mq6.hpp" -%include "mq7.hpp" -%include "mq8.hpp" -%include "mq9.hpp" -%include "tp401.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_gas) \ No newline at end of file diff -Nru upm-1.6.0/src/gas/jsupm_gas.i upm-1.7.1/src/gas/jsupm_gas.i --- upm-1.6.0/src/gas/jsupm_gas.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gas/jsupm_gas.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -%module jsupm_gas -%include "../upm.i" -%include "../carrays_uint16_t.i" - -%include "gas.hpp" -%{ - #include "gas.hpp" -%} - -%include "mq2.hpp" -%{ - #include "mq2.hpp" -%} - -%include "mq3.hpp" -%{ - #include "mq3.hpp" -%} - -%include "mq4.hpp" -%{ - #include "mq4.hpp" -%} - -%include "mq5.hpp" -%{ - #include "mq5.hpp" -%} - -%include "mq6.hpp" -%{ - #include "mq6.hpp" -%} - -%include "mq7.hpp" -%{ - #include "mq7.hpp" -%} - -%include "mq8.hpp" -%{ - #include "mq8.hpp" -%} - -%include "mq9.hpp" -%{ - #include "mq9.hpp" -%} - -%include "tp401.hpp" -%{ - #include "tp401.hpp" -%} diff -Nru upm-1.6.0/src/gas/pyupm_gas.i upm-1.7.1/src/gas/pyupm_gas.i --- upm-1.6.0/src/gas/pyupm_gas.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gas/pyupm_gas.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_gas -%include "../upm.i" -%include "../carrays_uint16_t.i" - -%include "gas.hpp" -%{ - #include "gas.hpp" -%} - -%include "mq2.hpp" -%{ - #include "mq2.hpp" -%} - -%include "mq3.hpp" -%{ - #include "mq3.hpp" -%} - -%include "mq4.hpp" -%{ - #include "mq4.hpp" -%} - -%include "mq5.hpp" -%{ - #include "mq5.hpp" -%} - -%include "mq6.hpp" -%{ - #include "mq6.hpp" -%} - -%include "mq7.hpp" -%{ - #include "mq7.hpp" -%} - -%include "mq8.hpp" -%{ - #include "mq8.hpp" -%} - -%include "mq9.hpp" -%{ - #include "mq9.hpp" -%} - -%include "tp401.hpp" -%{ - #include "tp401.hpp" -%} diff -Nru upm-1.6.0/src/gp2y0a/gp2y0a.json upm-1.7.1/src/gp2y0a/gp2y0a.json --- upm-1.6.0/src/gp2y0a/gp2y0a.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gp2y0a/gp2y0a.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "gp2y0a", - "Description": "API for the GP2Y0A family of IR Proximity Sensors", - "Sensor Class": - { - "GP2Y0A": - { - "Name": "Analog Infrared (IR) Based Distance Sensor", - "Description": "Sensors of this family return an analog voltage corresponding to the distance of an object from the sensor. The voltage is lower when objects are far away; the voltage increases as objects get closer to the sensor.", - "Aliases": ["gp2y0a"], - "Categories": ["proximity", "light"], - "Connections": ["analog"], - "Project Type": ["prototyping", "robotics"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "gp2y0a.jpg", - "Examples": - { - "Java": ["Gp2y0aExample.java"], - "Python": ["gp2y0a.py"], - "Node.js": ["gp2y0a.js"], - "C++": ["gp2y0a.cxx"], - "C": ["gp2y0a.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.5, "typ": 5, "high": 7}, - "Operating Current": {"unit": "mA", "typ": 33, "max": 50}, - "Measurement Range": {"unit": "cm", "low": 10, "high": 80} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-80cm-Infrared-Proximity-Sensor-p-788.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-80cm_Infrared_Proximity_Sensor/"], - "Schematics": [] - } - } - } -} +{ + "Library": "gp2y0a", + "Description": "API for the GP2Y0A family of IR Proximity Sensors", + "Sensor Class": + { + "GP2Y0A": + { + "Name": "Analog Infrared (IR) Based Distance Sensor", + "Description": "Sensors of this family return an analog voltage corresponding to the distance of an object from the sensor. The voltage is lower when objects are far away; the voltage increases as objects get closer to the sensor.", + "Aliases": ["gp2y0a"], + "Categories": ["proximity", "light"], + "Connections": ["analog"], + "Project Type": ["prototyping", "robotics"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "gp2y0a.jpg", + "Examples": + { + "Java": ["Gp2y0a_Example.java"], + "Python": ["gp2y0a.py"], + "Node.js": ["gp2y0a.js"], + "C++": ["gp2y0a.cxx"], + "C": ["gp2y0a.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.5, "typ": 5, "high": 7}, + "Operating Current": {"unit": "mA", "typ": 33, "max": 50}, + "Measurement Range": {"unit": "cm", "low": 10, "high": 80} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-80cm-Infrared-Proximity-Sensor-p-788.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-80cm_Infrared_Proximity_Sensor/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/gp2y0a/javaupm_gp2y0a.i upm-1.7.1/src/gp2y0a/javaupm_gp2y0a.i --- upm-1.6.0/src/gp2y0a/javaupm_gp2y0a.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gp2y0a/javaupm_gp2y0a.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_gp2y0a -%include "../upm.i" - -%{ - #include "gp2y0a.hpp" -%} - -%include "gp2y0a.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_gp2y0a) \ No newline at end of file diff -Nru upm-1.6.0/src/gp2y0a/jsupm_gp2y0a.i upm-1.7.1/src/gp2y0a/jsupm_gp2y0a.i --- upm-1.6.0/src/gp2y0a/jsupm_gp2y0a.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gp2y0a/jsupm_gp2y0a.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_gp2y0a -%include "../upm.i" - -%{ - #include "gp2y0a.hpp" -%} - -%include "gp2y0a.hpp" diff -Nru upm-1.6.0/src/gp2y0a/pyupm_gp2y0a.i upm-1.7.1/src/gp2y0a/pyupm_gp2y0a.i --- upm-1.6.0/src/gp2y0a/pyupm_gp2y0a.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gp2y0a/pyupm_gp2y0a.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_gp2y0a -%include "../upm.i" - -%include "gp2y0a.hpp" -%{ - #include "gp2y0a.hpp" -%} diff -Nru upm-1.6.0/src/gprs/gprs.i upm-1.7.1/src/gprs/gprs.i --- upm-1.6.0/src/gprs/gprs.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/gprs/gprs.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_gprs) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "carrays.i" +%{ +#include "gprs.hpp" +%} +%include "gprs.hpp" +%array_class(char, charArray); +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/gprs/gprs.json upm-1.7.1/src/gprs/gprs.json --- upm-1.6.0/src/gprs/gprs.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gprs/gprs.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "gprs", - "Description": "API for the GPRS Module", - "Sensor Class": - { - "GPRS": - { - "Name": "General Packet Radio Service (GPRS) Module", - "Description": "The driver was tested with the GPRS Module, V2. It's a GSM GPRS module based on the SIM900. This module uses a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses.", - "Aliases": ["gprs"], - "Categories": ["wireless"], - "Connections": ["uart"], - "Project Type": ["prototyping", "wireless"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "gprs.jpg", - "Examples": - { - "Java": [], - "Python": ["gprs.py"], - "Node.js": ["gprs.js"], - "C++": ["gprs.cxx"], - "C": [] - }, - "Specifications": - { - "Input Voltage (5v Pin)": {"unit": "V", "Typ": 5}, - "Input Voltage (Vin Pin)": {"unit": "V", "low": 6.5, "high": 12}, - "Power Consumption": {"unit": "mA", "low": 1.5}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/GPRS-Shield-V3.0-p-2333.html"], - "Datasheets": ["http://www.seeedstudio.com/document/SIM900datasheeet.zip", "http://wiki.seeedstudio.com/wiki/GPRS_Shield_V3.0", "http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf", "http://garden.seeedstudio.com/images/a/a8/SIM900_AT_Command_Manual_V1.03.pdf", "http://garden.seeedstudio.com/images/a/a0/SIM900_ATC_V1_00.pdf"], - "Schematics": ["http://www.seeedstudio.com/wiki/File:GPRS_Shield_v3.0.pdf"] - } - } - } -} +{ + "Library": "gprs", + "Description": "API for the GPRS Module", + "Sensor Class": + { + "GPRS": + { + "Name": "General Packet Radio Service (GPRS) Module", + "Description": "The driver was tested with the GPRS Module, V2. It's a GSM GPRS module based on the SIM900. This module uses a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses.", + "Aliases": ["gprs"], + "Categories": ["wireless"], + "Connections": ["uart"], + "Project Type": ["prototyping", "wireless"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "gprs.jpg", + "Examples": + { + "Java": [], + "Python": ["gprs.py"], + "Node.js": ["gprs.js"], + "C++": ["gprs.cxx"], + "C": [] + }, + "Specifications": + { + "Input Voltage (5v Pin)": {"unit": "V", "Typ": 5}, + "Input Voltage (Vin Pin)": {"unit": "V", "low": 6.5, "high": 12}, + "Power Consumption": {"unit": "mA", "low": 1.5}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/GPRS-Shield-V3.0-p-2333.html"], + "Datasheets": ["http://www.seeedstudio.com/document/SIM900datasheeet.zip", "http://wiki.seeedstudio.com/wiki/GPRS_Shield_V3.0", "http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf", "http://garden.seeedstudio.com/images/a/a8/SIM900_AT_Command_Manual_V1.03.pdf", "http://garden.seeedstudio.com/images/a/a0/SIM900_ATC_V1_00.pdf"], + "Schematics": ["http://www.seeedstudio.com/wiki/File:GPRS_Shield_v3.0.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/gprs/javaupm_gprs.i upm-1.7.1/src/gprs/javaupm_gprs.i --- upm-1.6.0/src/gprs/javaupm_gprs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gprs/javaupm_gprs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_gprs -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "gprs.hpp" -%} - -%include "gprs.hpp" -%array_class(char, charArray); - -JAVA_JNI_LOADLIBRARY(javaupm_gprs) \ No newline at end of file diff -Nru upm-1.6.0/src/gprs/jsupm_gprs.i upm-1.7.1/src/gprs/jsupm_gprs.i --- upm-1.6.0/src/gprs/jsupm_gprs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gprs/jsupm_gprs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module jsupm_gprs -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "gprs.hpp" -%} - -%include "gprs.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/gprs/pyupm_gprs.i upm-1.7.1/src/gprs/pyupm_gprs.i --- upm-1.6.0/src/gprs/pyupm_gprs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gprs/pyupm_gprs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_gprs -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "gprs.hpp" -%} -%include "gprs.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/groups.md upm-1.7.1/src/groups.md --- upm-1.6.0/src/groups.md 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groups.md 2018-10-12 04:47:41.000000000 +0000 @@ -422,6 +422,10 @@ @ingroup byman @brief Semtech Corporation +@defgroup rohm ROHM Semiconductor +@ingroup byman +@brief ROHM Semiconductor + ### Groups for the various Starter Kits ### diff -Nru upm-1.6.0/src/grove/grove.i upm-1.7.1/src/grove/grove.i --- upm-1.6.0/src/grove/grove.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/grove/grove.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,33 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%apply int {mraa::Edge} + +JAVA_ADD_INSTALLISR_EDGE(upm::GroveButton) +JAVA_JNI_LOADLIBRARY(javaupm_grove) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "grovebase.hpp" +#include "grove.hpp" +#include "grovebutton.hpp" +#include "groveled.hpp" +#include "grovelight.hpp" +#include "groverelay.hpp" +#include "groverotary.hpp" +#include "groveslide.hpp" +#include "grovetemp.hpp" +%} +%include "grovebase.hpp" +%include "grove.hpp" +%include "grovebutton.hpp" +%include "groveled.hpp" +%include "grovelight.hpp" +%include "groverelay.hpp" +%include "groverotary.hpp" +%include "groveslide.hpp" +%include "grovetemp.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/grove/grove.json upm-1.7.1/src/grove/grove.json --- upm-1.6.0/src/grove/grove.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grove/grove.json 2018-10-12 04:47:41.000000000 +0000 @@ -29,7 +29,7 @@ "Kits": ["gsk"], "Image": "grovebutton.jpg", "Examples": { - "Java": ["GroveButtonSample.java", "GroveButton_intrSample.java"], + "Java": ["GroveButton_Example.java", "GroveButton_intr_Example.java"], "Python": ["grovebutton.py"], "Node.js": ["grovebutton.js"], "C++": ["grove-grovebutton.cxx"] @@ -75,7 +75,7 @@ "Kits": ["gsk"], "Image": "groveled.jpg", "Examples": { - "Java": ["GroveLEDSample.java", "GroveLed_multiSample.java"], + "Java": ["GroveLED_Example.java", "GroveLed_multi_Example.java"], "Python": ["groveled.py"], "Node.js": ["groveled.js"], "C++": ["grove-groveled.cxx", "grove-groveled-multi.cxx"] @@ -122,7 +122,7 @@ "Kits": ["gsk"], "Image": "grovelight.jpg", "Examples": { - "Java": ["GroveLightSample.java"], + "Java": ["GroveLight_Example.java"], "Python": ["grovelight.py"], "Node.js": ["grovelight.js"], "C++": ["grove-grovelight.cxx"] @@ -174,7 +174,7 @@ "Kits": ["gsk", "eak", "hak"], "Image": "groverelay.jpg", "Examples": { - "Java": ["GroveRelaySample.java"], + "Java": ["GroveRelay_Example.java"], "Python": ["groverelay.py"], "Node.js": ["groverelay.js"], "C++": ["grove-groverelay.cxx"] @@ -238,7 +238,7 @@ "Kits": ["gsk"], "Image": "groverotary.jpg", "Examples": { - "Java": ["GroveRotarySample.java"], + "Java": ["GroveRotary_Example.java"], "Python": ["groverotary.py"], "Node.js": ["groverotary.js"], "C++": ["grove-groverotary.cxx"] @@ -287,7 +287,7 @@ "Manufacturers": ["Seeed"], "Images": "slide.jpg", "Examples": { - "Java": ["GroveSlideSample.java"], + "Java": ["GroveSlide_Example.java"], "Python": ["groveslide.py"], "Node.js": ["groveslide.js"], "C++": ["grove-groveslide.cxx"] @@ -338,7 +338,7 @@ "Kits": ["gsk"], "Image": "grovetemp.jpg", "Examples": { - "Java": ["GroveTempSample.java"], + "Java": ["GroveTemp_Example.java"], "Python": ["grovetemp.py"], "Node.js": ["grovetemp.js"], "C++": ["grove-grovetemp.cxx"] diff -Nru upm-1.6.0/src/grove/javaupm_grove.i upm-1.7.1/src/grove/javaupm_grove.i --- upm-1.6.0/src/grove/javaupm_grove.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grove/javaupm_grove.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -%module (docstring="Basic Grove sensors") javaupm_grove - -%include "../upm.i" - -%apply int {mraa::Edge} - -%include "grove.hpp" -%{ - #include "grove.hpp" -%} - -%include "grovebase.hpp" -%{ - #include "grovebase.hpp" -%} - -%include "grovebutton.hpp" -%{ - #include "grovebutton.hpp" -%} - -%include "groveled.hpp" -%{ - #include "groveled.hpp" -%} - -%include "grovelight.hpp" -%{ - #include "grovelight.hpp" -%} - -%include "groverelay.hpp" -%{ - #include "groverelay.hpp" -%} - -%include "groverotary.hpp" -%{ - #include "groverotary.hpp" -%} - -%include "groveslide.hpp" -%{ - #include "groveslide.hpp" -%} - -%include "grovetemp.hpp" -%{ - #include "grovetemp.hpp" -%} - -JAVA_ADD_INSTALLISR_EDGE(upm::GroveButton) - - - -JAVA_JNI_LOADLIBRARY(javaupm_grove) diff -Nru upm-1.6.0/src/grove/jsupm_grove.i upm-1.7.1/src/grove/jsupm_grove.i --- upm-1.6.0/src/grove/jsupm_grove.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grove/jsupm_grove.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -%module jsupm_grove -%include "../upm.i" - -%include "grove.hpp" -%{ - #include "grove.hpp" -%} - -%include "grovebase.hpp" -%{ - #include "grovebase.hpp" -%} - -%include "grovebutton.hpp" -%{ - #include "grovebutton.hpp" -%} - -%include "groveled.hpp" -%{ - #include "groveled.hpp" -%} - -%include "grovelight.hpp" -%{ - #include "grovelight.hpp" -%} - -%include "groverelay.hpp" -%{ - #include "groverelay.hpp" -%} - -%include "groverotary.hpp" -%{ - #include "groverotary.hpp" -%} - -%include "groveslide.hpp" -%{ - #include "groveslide.hpp" -%} - -%include "grovetemp.hpp" -%{ - #include "grovetemp.hpp" -%} diff -Nru upm-1.6.0/src/grove/pyupm_grove.i upm-1.7.1/src/grove/pyupm_grove.i --- upm-1.6.0/src/grove/pyupm_grove.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grove/pyupm_grove.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grove -%include "../upm.i" - -%include "grove.hpp" -%{ - #include "grove.hpp" -%} - -%include "grovebase.hpp" -%{ - #include "grovebase.hpp" -%} - -%include "grovebutton.hpp" -%{ - #include "grovebutton.hpp" -%} - -%include "groveled.hpp" -%{ - #include "groveled.hpp" -%} - -%include "grovelight.hpp" -%{ - #include "grovelight.hpp" -%} - -%include "groverelay.hpp" -%{ - #include "groverelay.hpp" -%} - -%include "groverotary.hpp" -%{ - #include "groverotary.hpp" -%} - -%include "groveslide.hpp" -%{ - #include "groveslide.hpp" -%} - -%include "grovetemp.hpp" -%{ - #include "grovetemp.hpp" -%} diff -Nru upm-1.6.0/src/grovecollision/grovecollision.json upm-1.7.1/src/grovecollision/grovecollision.json --- upm-1.6.0/src/grovecollision/grovecollision.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovecollision/grovecollision.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,41 +1,41 @@ -{ - "Library": "grovecollision", - "Description": "API for the Grove Collision Sensor", - "Sensor Class": - { - "GroveCollision": - { - "Name": "Grove Collision Sensor", - "Description": "The Grove Collision Sensor can detect whether any collision movement or vibration happens. It outputs a low pulse signal when vibration is detected.", - "Aliases": ["grovecollision"], - "Categories": ["collision", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["prototyping", "robotics"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "grovecollision.jpg", - "Examples": - { - "Java": ["GroveCollision.java"], - "Python": ["grovecollision.py"], - "Node.js": ["grovecollision.js"], - "C++": ["grovecollision.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "max": 2}, - "Reaction Point": {"unit": "mg", "typ": 50}, - "Off Resistance": {"unit": "MOhms", "min": 30}, - "On Resistance": {"unit": "Ohms", "max": 100} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Collision-Sensor-p-1132.html"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Collision_Sensor/master/res/DataSheet-MVS0608_02-v2_1.pdf", "http://wiki.seeed.cc/Grove-Collision_Sensor/"], - "Schematics": [] - } - } - } -} +{ + "Library": "grovecollision", + "Description": "API for the Grove Collision Sensor", + "Sensor Class": + { + "GroveCollision": + { + "Name": "Grove Collision Sensor", + "Description": "The Grove Collision Sensor can detect whether any collision movement or vibration happens. It outputs a low pulse signal when vibration is detected.", + "Aliases": ["grovecollision"], + "Categories": ["collision", "deprecated"], + "Connections": ["gpio"], + "Project Type": ["prototyping", "robotics"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "grovecollision.jpg", + "Examples": + { + "Java": ["GroveCollision_Example.java"], + "Python": ["grovecollision.py"], + "Node.js": ["grovecollision.js"], + "C++": ["grovecollision.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "mA", "max": 2}, + "Reaction Point": {"unit": "mg", "typ": 50}, + "Off Resistance": {"unit": "MOhms", "min": 30}, + "On Resistance": {"unit": "Ohms", "max": 100} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Collision-Sensor-p-1132.html"], + "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Collision_Sensor/master/res/DataSheet-MVS0608_02-v2_1.pdf", "http://wiki.seeed.cc/Grove-Collision_Sensor/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/grovecollision/javaupm_grovecollision.i upm-1.7.1/src/grovecollision/javaupm_grovecollision.i --- upm-1.6.0/src/grovecollision/javaupm_grovecollision.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovecollision/javaupm_grovecollision.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_grovecollision -%include "../upm.i" - -%{ - #include "grovecollision.hpp" -%} - -%include "grovecollision.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovecollision) \ No newline at end of file diff -Nru upm-1.6.0/src/grovecollision/jsupm_grovecollision.i upm-1.7.1/src/grovecollision/jsupm_grovecollision.i --- upm-1.6.0/src/grovecollision/jsupm_grovecollision.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovecollision/jsupm_grovecollision.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovecollision -%include "../upm.i" - -%{ - #include "grovecollision.hpp" -%} - -%include "grovecollision.hpp" diff -Nru upm-1.6.0/src/grovecollision/pyupm_grovecollision.i upm-1.7.1/src/grovecollision/pyupm_grovecollision.i --- upm-1.6.0/src/grovecollision/pyupm_grovecollision.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovecollision/pyupm_grovecollision.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovecollision -%include "../upm.i" - -%include "grovecollision.hpp" -%{ - #include "grovecollision.hpp" -%} diff -Nru upm-1.6.0/src/groveehr/groveehr.i upm-1.7.1/src/groveehr/groveehr.i --- upm-1.6.0/src/groveehr/groveehr.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/groveehr/groveehr.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore beatISR; + +JAVA_JNI_LOADLIBRARY(javaupm_groveehr) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "groveehr.hpp" +%} +%include "groveehr.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/groveehr/groveehr.json upm-1.7.1/src/groveehr/groveehr.json --- upm-1.6.0/src/groveehr/groveehr.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveehr/groveehr.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "groveehr", - "Description": "API for the Ear-clip Heart Rate Sensor", - "Sensor Class": - { - "GroveEHR": - { - "Name": "Ear-clip Heart Rate Sensor", - "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", - "Aliases": ["groveehr"], - "Categories": ["heartrate", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["medical", "wearables", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveehr.jpg", - "Examples": - { - "Java": ["GroveEHRSample.java"], - "Python": ["groveehr.py"], - "Node.js": ["groveehr.js"], - "C++": ["groveehr.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3, "high": 5}, - "Operating Current": {"unit": "mA", "typ": 6.5}, - "Measurement Range": {"unit": "bpm", "min": 30} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Ear-clip-Heart-Rate-Sensor-p-1116.html"], - "Datasheets": ["http://wiki.seeedstudio.com/wiki/Grove_-_Heart_rate_ear_clip_kit"], - "Schematics": [] - } - } - } -} +{ + "Library": "groveehr", + "Description": "API for the Ear-clip Heart Rate Sensor", + "Sensor Class": + { + "GroveEHR": + { + "Name": "Ear-clip Heart Rate Sensor", + "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", + "Aliases": ["groveehr"], + "Categories": ["heartrate", "deprecated"], + "Connections": ["gpio"], + "Project Type": ["medical", "wearables", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "groveehr.jpg", + "Examples": + { + "Java": ["GroveEHR_Example.java"], + "Python": ["groveehr.py"], + "Node.js": ["groveehr.js"], + "C++": ["groveehr.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3, "high": 5}, + "Operating Current": {"unit": "mA", "typ": 6.5}, + "Measurement Range": {"unit": "bpm", "min": 30} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Ear-clip-Heart-Rate-Sensor-p-1116.html"], + "Datasheets": ["http://wiki.seeedstudio.com/wiki/Grove_-_Heart_rate_ear_clip_kit"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/groveehr/javaupm_groveehr.i upm-1.7.1/src/groveehr/javaupm_groveehr.i --- upm-1.6.0/src/groveehr/javaupm_groveehr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveehr/javaupm_groveehr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_groveehr -%include "../upm.i" - -%ignore beatISR; - -%{ - #include "groveehr.hpp" -%} - -%include "groveehr.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_groveehr) \ No newline at end of file diff -Nru upm-1.6.0/src/groveehr/jsupm_groveehr.i upm-1.7.1/src/groveehr/jsupm_groveehr.i --- upm-1.6.0/src/groveehr/jsupm_groveehr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveehr/jsupm_groveehr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_groveehr -%include "../upm.i" - -%{ - #include "groveehr.hpp" -%} - -%include "groveehr.hpp" diff -Nru upm-1.6.0/src/groveehr/pyupm_groveehr.i upm-1.7.1/src/groveehr/pyupm_groveehr.i --- upm-1.6.0/src/groveehr/pyupm_groveehr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveehr/pyupm_groveehr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_groveehr -%include "../upm.i" - -%include "groveehr.hpp" -%{ - #include "groveehr.hpp" -%} diff -Nru upm-1.6.0/src/groveeldriver/groveeldriver.json upm-1.7.1/src/groveeldriver/groveeldriver.json --- upm-1.6.0/src/groveeldriver/groveeldriver.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveeldriver/groveeldriver.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "groveeldriver", - "Description": "API for the Grove EL Driver Module", - "Sensor Class": - { - "GroveElDriver": - { - "Name": "Grove Electroluminescent Wire (EL) Driver", - "Description": "The Grove EL Driver allows you to easily light up an EL wire with just one single cable.", - "Aliases": ["groveeldriver"], - "Categories": ["lighting", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["prototyping", "commercial", "wearables"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveeldriver.jpg", - "Examples": - { - "Java": [], - "Python": ["groveeldriver.py"], - "Node.js": ["groveeldriver.js"], - "C++": ["groveeldriver.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "max": 300}, - "Supported EL Capacitance": {"unit": "nF", "max": 15} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-EL-Driver-p-2269.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-EL_Driver/"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EL_Driver/master/res/Grove-EL_Driver_v1.0.pdf"] - } - } - } -} +{ + "Library": "groveeldriver", + "Description": "API for the Grove EL Driver Module", + "Sensor Class": + { + "GroveElDriver": + { + "Name": "Grove Electroluminescent Wire (EL) Driver", + "Description": "The Grove EL Driver allows you to easily light up an EL wire with just one single cable.", + "Aliases": ["groveeldriver"], + "Categories": ["lighting", "deprecated"], + "Connections": ["gpio"], + "Project Type": ["prototyping", "commercial", "wearables"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "groveeldriver.jpg", + "Examples": + { + "Java": [], + "Python": ["groveeldriver.py"], + "Node.js": ["groveeldriver.js"], + "C++": ["groveeldriver.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "mA", "max": 300}, + "Supported EL Capacitance": {"unit": "nF", "max": 15} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-EL-Driver-p-2269.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-EL_Driver/"], + "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EL_Driver/master/res/Grove-EL_Driver_v1.0.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/groveeldriver/javaupm_groveeldriver.i upm-1.7.1/src/groveeldriver/javaupm_groveeldriver.i --- upm-1.6.0/src/groveeldriver/javaupm_groveeldriver.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveeldriver/javaupm_groveeldriver.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_groveeldriver -%include "../upm.i" - -%{ - #include "groveeldriver.hpp" -%} - -%include "groveeldriver.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_groveeldriver) \ No newline at end of file diff -Nru upm-1.6.0/src/groveeldriver/jsupm_groveeldriver.i upm-1.7.1/src/groveeldriver/jsupm_groveeldriver.i --- upm-1.6.0/src/groveeldriver/jsupm_groveeldriver.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveeldriver/jsupm_groveeldriver.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_groveeldriver -%include "../upm.i" - -%{ - #include "groveeldriver.hpp" -%} - -%include "groveeldriver.hpp" diff -Nru upm-1.6.0/src/groveeldriver/pyupm_groveeldriver.i upm-1.7.1/src/groveeldriver/pyupm_groveeldriver.i --- upm-1.6.0/src/groveeldriver/pyupm_groveeldriver.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveeldriver/pyupm_groveeldriver.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_groveeldriver -%include "../upm.i" - -%include "groveeldriver.hpp" -%{ - #include "groveeldriver.hpp" -%} diff -Nru upm-1.6.0/src/groveelectromagnet/groveelectromagnet.json upm-1.7.1/src/groveelectromagnet/groveelectromagnet.json --- upm-1.6.0/src/groveelectromagnet/groveelectromagnet.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveelectromagnet/groveelectromagnet.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,41 +1,41 @@ -{ - "Library": "groveelectromagnet", - "Description": "Grove Electromagnet Library", - "Sensor Class": - { - "GroveElectromagnet": - { - "Name": "API for the Grove Electromagnet", - "Description": "The Grove Electromagnet can hold up to 1 kg (approximately 2.2 lbs)", - "Aliases": ["groveelectromagnet"], - "Categories": ["electric", "magnetic", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveelectromagnet.jpg", - "Examples": - { - "Java": [], - "Python": ["groveelectromagnet.py"], - "Node.js": ["groveelectromagnet.js"], - "C++": ["groveelectromagnet.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "typ": 400}, - "Standby Current": {"unit": "uA", "typ": 200}, - "Max Load Weight": {"unit": "kgs", "typ": 1} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Electromagnet-p-1820.html"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Electromagnet/master/res/ZYE1-P20-15.pdf", "http://wiki.seeed.cc/Grove-Electromagnet/"], - "Schematics": [] - } - } - } -} +{ + "Library": "groveelectromagnet", + "Description": "Grove Electromagnet Library", + "Sensor Class": + { + "GroveElectromagnet": + { + "Name": "API for the Grove Electromagnet", + "Description": "The Grove Electromagnet can hold up to 1 kg (approximately 2.2 lbs)", + "Aliases": ["groveelectromagnet"], + "Categories": ["electric", "magnetic", "deprecated"], + "Connections": ["gpio"], + "Project Type": ["prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "groveelectromagnet.jpg", + "Examples": + { + "Java": [], + "Python": ["groveelectromagnet.py"], + "Node.js": ["groveelectromagnet.js"], + "C++": ["groveelectromagnet.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "typ": 400}, + "Standby Current": {"unit": "uA", "typ": 200}, + "Max Load Weight": {"unit": "kgs", "typ": 1} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Electromagnet-p-1820.html"], + "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Electromagnet/master/res/ZYE1-P20-15.pdf", "http://wiki.seeed.cc/Grove-Electromagnet/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/groveelectromagnet/javaupm_groveelectromagnet.i upm-1.7.1/src/groveelectromagnet/javaupm_groveelectromagnet.i --- upm-1.6.0/src/groveelectromagnet/javaupm_groveelectromagnet.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveelectromagnet/javaupm_groveelectromagnet.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_groveelectromagnet -%include "../upm.i" - -%{ - #include "groveelectromagnet.hpp" -%} - -%include "groveelectromagnet.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_groveelectromagnet) \ No newline at end of file diff -Nru upm-1.6.0/src/groveelectromagnet/jsupm_groveelectromagnet.i upm-1.7.1/src/groveelectromagnet/jsupm_groveelectromagnet.i --- upm-1.6.0/src/groveelectromagnet/jsupm_groveelectromagnet.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveelectromagnet/jsupm_groveelectromagnet.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_groveelectromagnet -%include "../upm.i" - -%{ - #include "groveelectromagnet.hpp" -%} - -%include "groveelectromagnet.hpp" diff -Nru upm-1.6.0/src/groveelectromagnet/pyupm_groveelectromagnet.i upm-1.7.1/src/groveelectromagnet/pyupm_groveelectromagnet.i --- upm-1.6.0/src/groveelectromagnet/pyupm_groveelectromagnet.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveelectromagnet/pyupm_groveelectromagnet.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_groveelectromagnet -%include "../upm.i" - -%include "groveelectromagnet.hpp" -%{ - #include "groveelectromagnet.hpp" -%} diff -Nru upm-1.6.0/src/groveemg/groveemg.json upm-1.7.1/src/groveemg/groveemg.json --- upm-1.6.0/src/groveemg/groveemg.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveemg/groveemg.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "groveemg", - "Description": "Grove EMG Muscle Signal Reader Library", - "Sensor Class": - { - "GroveEMG": - { - "Name": "Grove Electromyography (EMG) Sensor", - "Description": "Grove EMG muscle signal reader gathers small muscle signals, then processes them, and returns the result.", - "Aliases": ["groveemg"], - "Categories": ["electromyography", "medical", "deprecated"], - "Connections": ["analog"], - "Project Type": ["wearables", "computer interfacing", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Examples": - { - "Java": ["GroveEmg.java"], - "Python": ["groveemg.py"], - "Node.js": ["groveemg.js"], - "C++": ["groveemg.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-EMG-Detector-p-1737.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-EMG_Detector/"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EMG_Detector/master/res/Grove-EMG_Sensor_v1.1_SCH.pdf"] - } - } - } -} +{ + "Library": "groveemg", + "Description": "Grove EMG Muscle Signal Reader Library", + "Sensor Class": + { + "GroveEMG": + { + "Name": "Grove Electromyography (EMG) Sensor", + "Description": "Grove EMG muscle signal reader gathers small muscle signals, then processes them, and returns the result.", + "Aliases": ["groveemg"], + "Categories": ["electromyography", "medical", "deprecated"], + "Connections": ["analog"], + "Project Type": ["wearables", "computer interfacing", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Examples": + { + "Java": ["GroveEmg_Example.java"], + "Python": ["groveemg.py"], + "Node.js": ["groveemg.js"], + "C++": ["groveemg.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-EMG-Detector-p-1737.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-EMG_Detector/"], + "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EMG_Detector/master/res/Grove-EMG_Sensor_v1.1_SCH.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/groveemg/javaupm_groveemg.i upm-1.7.1/src/groveemg/javaupm_groveemg.i --- upm-1.6.0/src/groveemg/javaupm_groveemg.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveemg/javaupm_groveemg.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_groveemg -%include "../upm.i" - -%{ - #include "groveemg.hpp" -%} - -%include "groveemg.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_groveemg) \ No newline at end of file diff -Nru upm-1.6.0/src/groveemg/jsupm_groveemg.i upm-1.7.1/src/groveemg/jsupm_groveemg.i --- upm-1.6.0/src/groveemg/jsupm_groveemg.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveemg/jsupm_groveemg.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_groveemg -%include "../upm.i" - -%{ - #include "groveemg.hpp" -%} - -%include "groveemg.hpp" diff -Nru upm-1.6.0/src/groveemg/pyupm_groveemg.i upm-1.7.1/src/groveemg/pyupm_groveemg.i --- upm-1.6.0/src/groveemg/pyupm_groveemg.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveemg/pyupm_groveemg.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_groveemg -%include "../upm.i" - -%include "groveemg.hpp" -%{ - #include "groveemg.hpp" -%} diff -Nru upm-1.6.0/src/grovegprs/grovegprs.i upm-1.7.1/src/grovegprs/grovegprs.i --- upm-1.6.0/src/grovegprs/grovegprs.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/grovegprs/grovegprs.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_grovegprs) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "carrays.i" +%{ +#include "grovegprs.hpp" +%} +%include "grovegprs.hpp" +%array_class(char, charArray); +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/grovegprs/grovegprs.json upm-1.7.1/src/grovegprs/grovegprs.json --- upm-1.6.0/src/grovegprs/grovegprs.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovegprs/grovegprs.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "grovegprs", - "Description": "API for the Grove GPRS Module", - "Sensor Class": - { - "GroveGPRS": - { - "Name": "Grove General Packet Radio Service (GPRS) Module", - "Description": "The driver was tested with the Grove GPRS Module, V2. It's a GSM GPRS module based on the SIM900. This module uses a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses.", - "Aliases": ["grovegprs"], - "Categories": ["wireless"], - "Connections": ["uart"], - "Project Type": ["prototyping", "wireless"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "grovegprs.jpg", - "Examples": - { - "Java": [], - "Python": ["grovegprs.py"], - "Node.js": ["grovegprs.js"], - "C++": ["grovegprs.cxx"], - "C": [] - }, - "Specifications": - { - "Input Voltage (5v Pin)": {"unit": "V", "Typ": 5}, - "Input Voltage (Vin Pin)": {"unit": "V", "low": 6.5, "high": 12}, - "Power Consumption": {"unit": "mA", "low": 1.5}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/GPRS-Shield-V3.0-p-2333.html"], - "Datasheets": ["http://www.seeedstudio.com/document/SIM900datasheeet.zip", "http://wiki.seeedstudio.com/wiki/GPRS_Shield_V3.0", "http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf", "http://garden.seeedstudio.com/images/a/a8/SIM900_AT_Command_Manual_V1.03.pdf", "http://garden.seeedstudio.com/images/a/a0/SIM900_ATC_V1_00.pdf"], - "Schematics": ["http://www.seeedstudio.com/wiki/File:GPRS_Shield_v3.0.pdf"] - } - } - } -} +{ + "Library": "grovegprs", + "Description": "API for the Grove GPRS Module", + "Sensor Class": + { + "GroveGPRS": + { + "Name": "Grove General Packet Radio Service (GPRS) Module", + "Description": "The driver was tested with the Grove GPRS Module, V2. It's a GSM GPRS module based on the SIM900. This module uses a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses.", + "Aliases": ["grovegprs"], + "Categories": ["wireless"], + "Connections": ["uart"], + "Project Type": ["prototyping", "wireless"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "grovegprs.jpg", + "Examples": + { + "Java": [], + "Python": ["grovegprs.py"], + "Node.js": ["grovegprs.js"], + "C++": ["grovegprs.cxx"], + "C": [] + }, + "Specifications": + { + "Input Voltage (5v Pin)": {"unit": "V", "Typ": 5}, + "Input Voltage (Vin Pin)": {"unit": "V", "low": 6.5, "high": 12}, + "Power Consumption": {"unit": "mA", "low": 1.5}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/GPRS-Shield-V3.0-p-2333.html"], + "Datasheets": ["http://www.seeedstudio.com/document/SIM900datasheeet.zip", "http://wiki.seeedstudio.com/wiki/GPRS_Shield_V3.0", "http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf", "http://garden.seeedstudio.com/images/a/a8/SIM900_AT_Command_Manual_V1.03.pdf", "http://garden.seeedstudio.com/images/a/a0/SIM900_ATC_V1_00.pdf"], + "Schematics": ["http://www.seeedstudio.com/wiki/File:GPRS_Shield_v3.0.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/grovegprs/javaupm_grovegprs.i upm-1.7.1/src/grovegprs/javaupm_grovegprs.i --- upm-1.6.0/src/grovegprs/javaupm_grovegprs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovegprs/javaupm_grovegprs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_grovegprs -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "grovegprs.hpp" -%} - -%include "grovegprs.hpp" -%array_class(char, charArray); - -JAVA_JNI_LOADLIBRARY(javaupm_grovegprs) \ No newline at end of file diff -Nru upm-1.6.0/src/grovegprs/jsupm_grovegprs.i upm-1.7.1/src/grovegprs/jsupm_grovegprs.i --- upm-1.6.0/src/grovegprs/jsupm_grovegprs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovegprs/jsupm_grovegprs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module jsupm_grovegprs -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "grovegprs.hpp" -%} - -%include "grovegprs.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/grovegprs/pyupm_grovegprs.i upm-1.7.1/src/grovegprs/pyupm_grovegprs.i --- upm-1.6.0/src/grovegprs/pyupm_grovegprs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovegprs/pyupm_grovegprs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovegprs -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "grovegprs.hpp" -%} -%include "grovegprs.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/grovegsr/grovegsr.json upm-1.7.1/src/grovegsr/grovegsr.json --- upm-1.6.0/src/grovegsr/grovegsr.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovegsr/grovegsr.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "grovegsr", - "Description": "API for the Grove GSR Galvanic Skin Response Sensor", - "Sensor Class": - { - "GroveGSR": - { - "Name": "Galvanic Skin Response (GSR) Sensor", - "Description": "Measures the electrical conductance of skin to measure strong emotional reactions. In other words, it measures sweat on your fingers as an indicator of strong emotional reactions.", - "Aliases": ["grovegsr"], - "Categories": ["skinresponse"], - "Connections": ["analog"], - "Project Type": ["medical", "interface", "wearables", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Examples": - { - "Java": ["GroveGsr.java"], - "Python": ["grovegsr.py"], - "Node.js": ["grovegsr.js"], - "C++": ["grovegsr.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "low": 0.7, "high": 3}, - "Operating Temperature": {"unit": "degC", "min": 0, "max": 70} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-GSR-sensor-p-1614.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-GSR_Sensor/", "file:///C:/Users/Malachai/Downloads/Lm324.pdf"], - "Schematics": ["https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR_v1.2_SCH.pdf", "https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR%20v1.0%20SCH.pdf"] - } - } - } -} +{ + "Library": "grovegsr", + "Description": "API for the Grove GSR Galvanic Skin Response Sensor", + "Sensor Class": + { + "GroveGSR": + { + "Name": "Galvanic Skin Response (GSR) Sensor", + "Description": "Measures the electrical conductance of skin to measure strong emotional reactions. In other words, it measures sweat on your fingers as an indicator of strong emotional reactions.", + "Aliases": ["grovegsr"], + "Categories": ["skinresponse"], + "Connections": ["analog"], + "Project Type": ["medical", "interface", "wearables", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Examples": + { + "Java": ["GroveGsr_Example.java"], + "Python": ["grovegsr.py"], + "Node.js": ["grovegsr.js"], + "C++": ["grovegsr.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "mA", "low": 0.7, "high": 3}, + "Operating Temperature": {"unit": "degC", "min": 0, "max": 70} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-GSR-sensor-p-1614.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-GSR_Sensor/", "file:///C:/Users/Malachai/Downloads/Lm324.pdf"], + "Schematics": ["https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR_v1.2_SCH.pdf", "https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR%20v1.0%20SCH.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/grovegsr/javaupm_grovegsr.i upm-1.7.1/src/grovegsr/javaupm_grovegsr.i --- upm-1.6.0/src/grovegsr/javaupm_grovegsr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovegsr/javaupm_grovegsr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_grovegsr -%include "../upm.i" - -%{ - #include "grovegsr.hpp" -%} - -%include "grovegsr.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovegsr) \ No newline at end of file diff -Nru upm-1.6.0/src/grovegsr/jsupm_grovegsr.i upm-1.7.1/src/grovegsr/jsupm_grovegsr.i --- upm-1.6.0/src/grovegsr/jsupm_grovegsr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovegsr/jsupm_grovegsr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovegsr -%include "../upm.i" - -%{ - #include "grovegsr.hpp" -%} - -%include "grovegsr.hpp" diff -Nru upm-1.6.0/src/grovegsr/pyupm_grovegsr.i upm-1.7.1/src/grovegsr/pyupm_grovegsr.i --- upm-1.6.0/src/grovegsr/pyupm_grovegsr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovegsr/pyupm_grovegsr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovegsr -%include "../upm.i" - -%include "grovegsr.hpp" -%{ - #include "grovegsr.hpp" -%} diff -Nru upm-1.6.0/src/grovelinefinder/grovelinefinder.json upm-1.7.1/src/grovelinefinder/grovelinefinder.json --- upm-1.6.0/src/grovelinefinder/grovelinefinder.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovelinefinder/grovelinefinder.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "grovelinefinder", - "Description": "Grove Line Finder Sensor Library", - "Sensor Class": - { - "GroveLineFinder": - { - "Name": "Infrared (IR) Based Line Finder", - "Description": "UPM module for the Line Finder sensor. It outputs a digital signal indicating whether it is detecting black on a white background, or white on a black background.", - "Aliases": ["grovelinefinder"], - "Categories": ["grovelinefinder"], - "Connections": ["gpio"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["seeed", "dfrobot"], - "Kits": ["robok"], - "Image": "grovelinefinder.jpg", - "Examples": - { - "Java": ["GroveLineFinderSample.java"], - "Python": ["grovelinefinder.py"], - "Node.js": ["grovelinefinder.js"], - "C++": ["grovelinefinder.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5}, - "Operating Current": {"unit": "uA", "typ": 210}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 125} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Line-Finder-v1.1-p-2712.html"], - "Datasheets": ["file:///C:/Users/Malachai/Downloads/Lmv358.pdf", "http://wiki.seeed.cc/Grove-Line_Finder/"], - "Schematics": ["https://easyeda.com/Seeed/Grove_Line_Finder_v1_1-dfc99c72325e41ff93a451882fd2e143"] - } - } - } -} +{ + "Library": "grovelinefinder", + "Description": "Grove Line Finder Sensor Library", + "Sensor Class": + { + "GroveLineFinder": + { + "Name": "Infrared (IR) Based Line Finder", + "Description": "UPM module for the Line Finder sensor. It outputs a digital signal indicating whether it is detecting black on a white background, or white on a black background.", + "Aliases": ["grovelinefinder"], + "Categories": ["grovelinefinder"], + "Connections": ["gpio"], + "Project Type": ["robotics", "prototyping"], + "Manufacturers": ["seeed", "dfrobot"], + "Kits": ["robok"], + "Image": "grovelinefinder.jpg", + "Examples": + { + "Java": ["GroveLineFinder_Example.java"], + "Python": ["grovelinefinder.py"], + "Node.js": ["grovelinefinder.js"], + "C++": ["grovelinefinder.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5}, + "Operating Current": {"unit": "uA", "typ": 210}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 125} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Line-Finder-v1.1-p-2712.html"], + "Datasheets": ["file:///C:/Users/Malachai/Downloads/Lmv358.pdf", "http://wiki.seeed.cc/Grove-Line_Finder/"], + "Schematics": ["https://easyeda.com/Seeed/Grove_Line_Finder_v1_1-dfc99c72325e41ff93a451882fd2e143"] + } + } + } +} diff -Nru upm-1.6.0/src/grovelinefinder/javaupm_grovelinefinder.i upm-1.7.1/src/grovelinefinder/javaupm_grovelinefinder.i --- upm-1.6.0/src/grovelinefinder/javaupm_grovelinefinder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovelinefinder/javaupm_grovelinefinder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_grovelinefinder -%include "../upm.i" - -%{ - #include "grovelinefinder.hpp" -%} - -%include "grovelinefinder.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovelinefinder) \ No newline at end of file diff -Nru upm-1.6.0/src/grovelinefinder/jsupm_grovelinefinder.i upm-1.7.1/src/grovelinefinder/jsupm_grovelinefinder.i --- upm-1.6.0/src/grovelinefinder/jsupm_grovelinefinder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovelinefinder/jsupm_grovelinefinder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovelinefinder -%include "../upm.i" - -%{ - #include "grovelinefinder.hpp" -%} - -%include "grovelinefinder.hpp" diff -Nru upm-1.6.0/src/grovelinefinder/pyupm_grovelinefinder.i upm-1.7.1/src/grovelinefinder/pyupm_grovelinefinder.i --- upm-1.6.0/src/grovelinefinder/pyupm_grovelinefinder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovelinefinder/pyupm_grovelinefinder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovelinefinder -%include "../upm.i" - -%include "grovelinefinder.hpp" -%{ - #include "grovelinefinder.hpp" -%} diff -Nru upm-1.6.0/src/grovemd/javaupm_grovemd.i upm-1.7.1/src/grovemd/javaupm_grovemd.i --- upm-1.6.0/src/grovemd/javaupm_grovemd.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovemd/javaupm_grovemd.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_grovemd -%include "../upm.i" - -%{ - #include "grovemd.hpp" -%} - -%include "grovemd.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovemd) \ No newline at end of file diff -Nru upm-1.6.0/src/grovemd/jsupm_grovemd.i upm-1.7.1/src/grovemd/jsupm_grovemd.i --- upm-1.6.0/src/grovemd/jsupm_grovemd.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovemd/jsupm_grovemd.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovemd -%include "../upm.i" - -%{ - #include "grovemd.hpp" -%} - -%include "grovemd.hpp" diff -Nru upm-1.6.0/src/grovemd/pyupm_grovemd.i upm-1.7.1/src/grovemd/pyupm_grovemd.i --- upm-1.6.0/src/grovemd/pyupm_grovemd.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovemd/pyupm_grovemd.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovemd -%include "../upm.i" - -%include "grovemd.hpp" -%{ - #include "grovemd.hpp" -%} diff -Nru upm-1.6.0/src/grovemoisture/grovemoisture.json upm-1.7.1/src/grovemoisture/grovemoisture.json --- upm-1.6.0/src/grovemoisture/grovemoisture.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovemoisture/grovemoisture.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "grovemoisture", - "Description": "API for the Grove Moisture Sensor", - "Sensor Class": - { - "GroveMoisture": - { - "Name": "Grove Moisture Sensor", - "Description": "UPM module for the Grove Moisture Sensor. This sensor can be used to detect the moisture content of soil or whether there is water around the sensor. As the moisture content increases, so does the value that is read. Note: this sensor is not designed to be left in soil nor to be used outdoors.", - "Aliases": ["grovemoisture"], - "Categories": ["moisture"], - "Connections": ["analog"], - "Project Type": ["liquid", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["eak", "hak"], - "Image": "grovemoisture.jpg", - "Examples": - { - "Java": ["GroveMoistureSample.java"], - "Python": ["grovemoisture.py"], - "Node.js": ["grovemoisture.js"], - "C++": ["grovemoisture.cxx"], - "C": [] - }, - "Specifications": { - "Vsource": {"unit": "V", "min": 3.3, "max": 5 }, - "Operating Temperature": {"unit": "°C", "min": -40, "max": 85 }, - "Supply Current": {"unit": "mA", "min" : 0, "max" : 35 } - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Moisture-Sensor-p-955.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Moisture_Sensor/"], - "Schematics": [] - } - } - } -} +{ + "Library": "grovemoisture", + "Description": "API for the Grove Moisture Sensor", + "Sensor Class": + { + "GroveMoisture": + { + "Name": "Grove Moisture Sensor", + "Description": "UPM module for the Grove Moisture Sensor. This sensor can be used to detect the moisture content of soil or whether there is water around the sensor. As the moisture content increases, so does the value that is read. Note: this sensor is not designed to be left in soil nor to be used outdoors.", + "Aliases": ["grovemoisture"], + "Categories": ["moisture"], + "Connections": ["analog"], + "Project Type": ["liquid", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": ["eak", "hak"], + "Image": "grovemoisture.jpg", + "Examples": + { + "Java": ["GroveMoisture_Example.java"], + "Python": ["grovemoisture.py"], + "Node.js": ["grovemoisture.js"], + "C++": ["grovemoisture.cxx"], + "C": [] + }, + "Specifications": { + "Vsource": {"unit": "V", "min": 3.3, "max": 5 }, + "Operating Temperature": {"unit": "°C", "min": -40, "max": 85 }, + "Supply Current": {"unit": "mA", "min" : 0, "max" : 35 } + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Moisture-Sensor-p-955.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Moisture_Sensor/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/grovemoisture/javaupm_grovemoisture.i upm-1.7.1/src/grovemoisture/javaupm_grovemoisture.i --- upm-1.6.0/src/grovemoisture/javaupm_grovemoisture.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovemoisture/javaupm_grovemoisture.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_grovemoisture -%include "../upm.i" - -%{ - #include "grovemoisture.hpp" -%} - -%include "grovemoisture.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovemoisture) \ No newline at end of file diff -Nru upm-1.6.0/src/grovemoisture/jsupm_grovemoisture.i upm-1.7.1/src/grovemoisture/jsupm_grovemoisture.i --- upm-1.6.0/src/grovemoisture/jsupm_grovemoisture.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovemoisture/jsupm_grovemoisture.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovemoisture -%include "../upm.i" - -%{ - #include "grovemoisture.hpp" -%} - -%include "grovemoisture.hpp" diff -Nru upm-1.6.0/src/grovemoisture/pyupm_grovemoisture.i upm-1.7.1/src/grovemoisture/pyupm_grovemoisture.i --- upm-1.6.0/src/grovemoisture/pyupm_grovemoisture.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovemoisture/pyupm_grovemoisture.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovemoisture -%include "../upm.i" - -%include "grovemoisture.hpp" -%{ - #include "grovemoisture.hpp" -%} diff -Nru upm-1.6.0/src/groveo2/groveo2.json upm-1.7.1/src/groveo2/groveo2.json --- upm-1.6.0/src/groveo2/groveo2.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveo2/groveo2.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "groveo2", - "Description": "Grove O2 Oxygen Gas Sensor Library", - "Sensor Class": - { - "GroveO2": - { - "Name": "Grove Oxygen (O2) Concentration Sensor", - "Description": "The Grove O2 Oxygen Gas sensor measures the oxygen concentration in the air.", - "Aliases": ["groveo2"], - "Categories": ["gas", "oxygen", "deprecated"], - "Connections": ["analog"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveo2.jpg", - "Examples": - { - "Java": ["GroveO2Example.java"], - "Python": ["groveo2.py"], - "Node.js": ["groveo2.js"], - "C++": ["groveo2.cxx"], - "C": [] - }, - "Specifications": - { - "Measurement Range": {"unit": "% Vol", "low": 0, "high": 25}, - "Sensitivity": {"unit": "mA (in air)", "low": 0.1, "high": 0.3}, - "Operating Temperature": {"unit": "degC", "low": -20, "high": 50} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/grove-gas-sensoro2-p-1541.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-O2/"], - "Schematics": ["https://github.com/SeeedDocument/Grove_Gas_Sensor_O2/raw/master/resources/Schematics_O2.zip"] - } - } - } -} +{ + "Library": "groveo2", + "Description": "Grove O2 Oxygen Gas Sensor Library", + "Sensor Class": + { + "GroveO2": + { + "Name": "Grove Oxygen (O2) Concentration Sensor", + "Description": "The Grove O2 Oxygen Gas sensor measures the oxygen concentration in the air.", + "Aliases": ["groveo2"], + "Categories": ["gas", "oxygen", "deprecated"], + "Connections": ["analog"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "groveo2.jpg", + "Examples": + { + "Java": ["GroveO2_Example.java"], + "Python": ["groveo2.py"], + "Node.js": ["groveo2.js"], + "C++": ["groveo2.cxx"], + "C": [] + }, + "Specifications": + { + "Measurement Range": {"unit": "% Vol", "low": 0, "high": 25}, + "Sensitivity": {"unit": "mA (in air)", "low": 0.1, "high": 0.3}, + "Operating Temperature": {"unit": "degC", "low": -20, "high": 50} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/grove-gas-sensoro2-p-1541.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-O2/"], + "Schematics": ["https://github.com/SeeedDocument/Grove_Gas_Sensor_O2/raw/master/resources/Schematics_O2.zip"] + } + } + } +} diff -Nru upm-1.6.0/src/groveo2/javaupm_groveo2.i upm-1.7.1/src/groveo2/javaupm_groveo2.i --- upm-1.6.0/src/groveo2/javaupm_groveo2.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveo2/javaupm_groveo2.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_groveo2 -%include "../upm.i" - -%{ - #include "groveo2.hpp" -%} - -%include "groveo2.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_groveo2) \ No newline at end of file diff -Nru upm-1.6.0/src/groveo2/jsupm_groveo2.i upm-1.7.1/src/groveo2/jsupm_groveo2.i --- upm-1.6.0/src/groveo2/jsupm_groveo2.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveo2/jsupm_groveo2.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_groveo2 -%include "../upm.i" - -%{ - #include "groveo2.hpp" -%} - -%include "groveo2.hpp" diff -Nru upm-1.6.0/src/groveo2/pyupm_groveo2.i upm-1.7.1/src/groveo2/pyupm_groveo2.i --- upm-1.6.0/src/groveo2/pyupm_groveo2.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveo2/pyupm_groveo2.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_groveo2 -%include "../upm.i" - -%include "groveo2.hpp" -%{ - #include "groveo2.hpp" -%} diff -Nru upm-1.6.0/src/grovescam/grovescam.i upm-1.7.1/src/grovescam/grovescam.i --- upm-1.6.0/src/grovescam/grovescam.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/grovescam/grovescam.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../java_buffer.i" + +JAVA_JNI_LOADLIBRARY(javaupm_grovescam) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "grovescam.hpp" +%} +%include "grovescam.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/grovescam/grovescam.json upm-1.7.1/src/grovescam/grovescam.json --- upm-1.6.0/src/grovescam/grovescam.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovescam/grovescam.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "grovescam", - "Description": "Grove Serial Camera Library", - "Sensor Class": - { - "GROVESCAM": - { - "Name": "Serial Camera Module", - "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", - "Aliases": ["grovescam"], - "Categories": ["imaging", "deprecated"], - "Connections": ["uart"], - "Project Type": ["prototyping", "access control", "security"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "grovescam.jpg", - "Examples": - { - "Java": ["GROVESCAMSample.java"], - "Python": ["grovescam.py"], - "Node.js": ["grovescam.js"], - "C++": ["grovescam.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Resolution": {"unit": "", "max": "640x480"} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Serial-Camera-Kit-p-1608.html"], - "Datasheets": ["http://www.seeedstudio.com/wiki/Grove_-_Serial_Camera_Kit"], - "Schematics": [] - } - } - } -} +{ + "Library": "grovescam", + "Description": "Grove Serial Camera Library", + "Sensor Class": + { + "GROVESCAM": + { + "Name": "Serial Camera Module", + "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", + "Aliases": ["grovescam"], + "Categories": ["imaging", "deprecated"], + "Connections": ["uart"], + "Project Type": ["prototyping", "access control", "security"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "grovescam.jpg", + "Examples": + { + "Java": ["GROVESCAM_Example.java"], + "Python": ["grovescam.py"], + "Node.js": ["grovescam.js"], + "C++": ["grovescam.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Resolution": {"unit": "", "max": "640x480"} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Serial-Camera-Kit-p-1608.html"], + "Datasheets": ["http://www.seeedstudio.com/wiki/Grove_-_Serial_Camera_Kit"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/grovescam/javaupm_grovescam.i upm-1.7.1/src/grovescam/javaupm_grovescam.i --- upm-1.6.0/src/grovescam/javaupm_grovescam.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovescam/javaupm_grovescam.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_grovescam -%include "../upm.i" -%include "../java_buffer.i" - -%{ - #include "grovescam.hpp" -%} - -%include "grovescam.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovescam) \ No newline at end of file diff -Nru upm-1.6.0/src/grovescam/jsupm_grovescam.i upm-1.7.1/src/grovescam/jsupm_grovescam.i --- upm-1.6.0/src/grovescam/jsupm_grovescam.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovescam/jsupm_grovescam.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovescam -%include "../upm.i" - -%{ - #include "grovescam.hpp" -%} - -%include "grovescam.hpp" diff -Nru upm-1.6.0/src/grovescam/pyupm_grovescam.i upm-1.7.1/src/grovescam/pyupm_grovescam.i --- upm-1.6.0/src/grovescam/pyupm_grovescam.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovescam/pyupm_grovescam.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovescam -%include "../upm.i" - -%{ - #include "grovescam.hpp" -%} -%include "grovescam.hpp" diff -Nru upm-1.6.0/src/grovespeaker/grovespeaker.json upm-1.7.1/src/grovespeaker/grovespeaker.json --- upm-1.6.0/src/grovespeaker/grovespeaker.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovespeaker/grovespeaker.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "grovespeaker", - "Description": "API for the Grove Speaker", - "Sensor Class": - { - "GroveSpeaker": - { - "Name": "Grove Speaker Module", - "Description": "UPM module for the Grove Speaker. This sensor can generate different tones and sounds depending on the frequency of the input signal.", - "Aliases": ["grovespeaker"], - "Categories": ["sound", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["sound", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["hak"], - "Image": "grovespeaker.jpg", - "Examples": - { - "Java": ["GroveSpeakerSample.java"], - "Python": ["grovespeaker.py"], - "Node.js": ["grovespeaker.js"], - "C++": ["grovespeaker.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 4, "high": 5.5}, - "Voltage Gain": {"unit": "dB", "typ": 46}, - "Bandwidth": {"unit": "KHz", "min": 20} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Speaker-p-1445.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Speaker/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Speaker/master/res/LM386_Low_Voltage_Audio_Power_Amplifier_Datasheet.pdf"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Speaker/master/res/Grove-Speaker_v1.0_sch.pdf"] - } - } - } -} +{ + "Library": "grovespeaker", + "Description": "API for the Grove Speaker", + "Sensor Class": + { + "GroveSpeaker": + { + "Name": "Grove Speaker Module", + "Description": "UPM module for the Grove Speaker. This sensor can generate different tones and sounds depending on the frequency of the input signal.", + "Aliases": ["grovespeaker"], + "Categories": ["sound", "deprecated"], + "Connections": ["gpio"], + "Project Type": ["sound", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": ["hak"], + "Image": "grovespeaker.jpg", + "Examples": + { + "Java": ["GroveSpeaker_Example.java"], + "Python": ["grovespeaker.py"], + "Node.js": ["grovespeaker.js"], + "C++": ["grovespeaker.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 4, "high": 5.5}, + "Voltage Gain": {"unit": "dB", "typ": 46}, + "Bandwidth": {"unit": "KHz", "min": 20} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Speaker-p-1445.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Speaker/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Speaker/master/res/LM386_Low_Voltage_Audio_Power_Amplifier_Datasheet.pdf"], + "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Speaker/master/res/Grove-Speaker_v1.0_sch.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/grovespeaker/javaupm_grovespeaker.i upm-1.7.1/src/grovespeaker/javaupm_grovespeaker.i --- upm-1.6.0/src/grovespeaker/javaupm_grovespeaker.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovespeaker/javaupm_grovespeaker.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_grovespeaker -%include "../upm.i" - -%{ - #include "grovespeaker.hpp" -%} - -%include "grovespeaker.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovespeaker) \ No newline at end of file diff -Nru upm-1.6.0/src/grovespeaker/jsupm_grovespeaker.i upm-1.7.1/src/grovespeaker/jsupm_grovespeaker.i --- upm-1.6.0/src/grovespeaker/jsupm_grovespeaker.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovespeaker/jsupm_grovespeaker.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovespeaker -%include "../upm.i" - -%{ - #include "grovespeaker.hpp" -%} - -%include "grovespeaker.hpp" diff -Nru upm-1.6.0/src/grovespeaker/pyupm_grovespeaker.i upm-1.7.1/src/grovespeaker/pyupm_grovespeaker.i --- upm-1.6.0/src/grovespeaker/pyupm_grovespeaker.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovespeaker/pyupm_grovespeaker.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovespeaker -%include "../upm.i" - -%include "grovespeaker.hpp" -%{ - #include "grovespeaker.hpp" -%} diff -Nru upm-1.6.0/src/groveultrasonic/groveultrasonic.cxx upm-1.7.1/src/groveultrasonic/groveultrasonic.cxx --- upm-1.6.0/src/groveultrasonic/groveultrasonic.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveultrasonic/groveultrasonic.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -44,7 +44,6 @@ fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", pin); exit (1); } - mraa_gpio_use_mmaped(m_pinCtx, 1); mraa_gpio_isr (m_pinCtx, MRAA_GPIO_EDGE_BOTH, &signalISR, this); } diff -Nru upm-1.6.0/src/groveultrasonic/groveultrasonic.i upm-1.7.1/src/groveultrasonic/groveultrasonic.i --- upm-1.6.0/src/groveultrasonic/groveultrasonic.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/groveultrasonic/groveultrasonic.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore signalISR; + +JAVA_JNI_LOADLIBRARY(javaupm_groveultrasonic) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "groveultrasonic.hpp" +%} +%include "groveultrasonic.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/groveultrasonic/groveultrasonic.json upm-1.7.1/src/groveultrasonic/groveultrasonic.json --- upm-1.6.0/src/groveultrasonic/groveultrasonic.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveultrasonic/groveultrasonic.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "groveultrasonic", - "Description": "Grove Ultrasonic Sensor Library", - "Sensor Class": - { - "GroveUltraSonic": - { - "Name": "Ultrasonic Proximity Sensor", - "Description": "This Grove Ultrasonic sensor is a non-contact distance measurement module which is compatible with the Grove system. It is designed for easy modular project usage with industrial performance. Detection ranges from 3 cm (1.2\") to 4 m (13'1.5\") and works best when the object is within a 30 degree angle relative to the sensor.", - "Aliases": ["groveultrasonic"], - "Categories": ["proximity", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveultrasonic.jpg", - "Examples": - { - "Java": [], - "Python": [], - "Node.js": ["groveultrasonic.js"], - "C++": ["groveultrasonic.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.2, "high": 5.2}, - "Operating Current": {"unit": "mA", "typ": 8}, - "Measurement Range": {"unit": "cm", "low": 2, "high": 350} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Ultrasonic-Ranger-p-960.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Ultrasonic_Ranger/"], - "Schematics": [] - } - } - } -} +{ + "Library": "groveultrasonic", + "Description": "Grove Ultrasonic Sensor Library", + "Sensor Class": + { + "GroveUltraSonic": + { + "Name": "Ultrasonic Proximity Sensor", + "Description": "This Grove Ultrasonic sensor is a non-contact distance measurement module which is compatible with the Grove system. It is designed for easy modular project usage with industrial performance. Detection ranges from 3 cm (1.2\") to 4 m (13'1.5\") and works best when the object is within a 30 degree angle relative to the sensor.", + "Aliases": ["groveultrasonic"], + "Categories": ["proximity", "deprecated"], + "Connections": ["gpio"], + "Project Type": ["robotics", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "groveultrasonic.jpg", + "Examples": + { + "Java": [], + "Python": [], + "Node.js": ["groveultrasonic.js"], + "C++": ["groveultrasonic.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.2, "high": 5.2}, + "Operating Current": {"unit": "mA", "typ": 8}, + "Measurement Range": {"unit": "cm", "low": 2, "high": 350} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Ultrasonic-Ranger-p-960.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Ultrasonic_Ranger/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/groveultrasonic/javaupm_groveultrasonic.i upm-1.7.1/src/groveultrasonic/javaupm_groveultrasonic.i --- upm-1.6.0/src/groveultrasonic/javaupm_groveultrasonic.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveultrasonic/javaupm_groveultrasonic.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_groveultrasonic -%include "../upm.i" - -%ignore signalISR; - -%{ - #include "groveultrasonic.hpp" -%} - -%include "groveultrasonic.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_groveultrasonic) diff -Nru upm-1.6.0/src/groveultrasonic/jsupm_groveultrasonic.i upm-1.7.1/src/groveultrasonic/jsupm_groveultrasonic.i --- upm-1.6.0/src/groveultrasonic/jsupm_groveultrasonic.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveultrasonic/jsupm_groveultrasonic.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_groveultrasonic -%include "../upm.i" - -%{ - #include "groveultrasonic.hpp" -%} - -%include "groveultrasonic.hpp" diff -Nru upm-1.6.0/src/groveultrasonic/pyupm_groveultrasonic.i upm-1.7.1/src/groveultrasonic/pyupm_groveultrasonic.i --- upm-1.6.0/src/groveultrasonic/pyupm_groveultrasonic.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/groveultrasonic/pyupm_groveultrasonic.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_groveultrasonic -%include "../upm.i" - -%include "groveultrasonic.hpp" -%{ - #include "groveultrasonic.hpp" -%} diff -Nru upm-1.6.0/src/grovevdiv/grovevdiv.json upm-1.7.1/src/grovevdiv/grovevdiv.json --- upm-1.6.0/src/grovevdiv/grovevdiv.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovevdiv/grovevdiv.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "grovevdiv", - "Description": "API for the Grove Voltage Divider Sensor", - "Sensor Class": - { - "GroveVDiv": - { - "Name": "Grove Voltage Divider Sensor", - "Description": "UPM module for the Grove Voltage Divider sensor.", - "Aliases": ["grovevdiv"], - "Categories": ["electric", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["robok"], - "Image": "grovevdiv.jpg", - "Examples": - { - "Java": ["GroveVDivSample.java"], - "Python": ["grovevdiv.py"], - "Node.js": ["grovevdiv.js"], - "C++": ["grovevdiv.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Voltage-Divider-p-1472.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Voltage_Divider/"], - "Schematics": ["https://github.com/SeeedDocument/Grove-Voltage_Divider/raw/master/res/LMV358ID_Datasheet.pdf"] - } - } - } -} +{ + "Library": "grovevdiv", + "Description": "API for the Grove Voltage Divider Sensor", + "Sensor Class": + { + "GroveVDiv": + { + "Name": "Grove Voltage Divider Sensor", + "Description": "UPM module for the Grove Voltage Divider sensor.", + "Aliases": ["grovevdiv"], + "Categories": ["electric", "deprecated"], + "Connections": ["gpio"], + "Project Type": ["robotics", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": ["robok"], + "Image": "grovevdiv.jpg", + "Examples": + { + "Java": ["GroveVDiv_Example.java"], + "Python": ["grovevdiv.py"], + "Node.js": ["grovevdiv.js"], + "C++": ["grovevdiv.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Voltage-Divider-p-1472.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Voltage_Divider/"], + "Schematics": ["https://github.com/SeeedDocument/Grove-Voltage_Divider/raw/master/res/LMV358ID_Datasheet.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/grovevdiv/javaupm_grovevdiv.i upm-1.7.1/src/grovevdiv/javaupm_grovevdiv.i --- upm-1.6.0/src/grovevdiv/javaupm_grovevdiv.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovevdiv/javaupm_grovevdiv.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_grovevdiv -%include "../upm.i" - -%{ - #include "grovevdiv.hpp" -%} - -%include "grovevdiv.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovevdiv) \ No newline at end of file diff -Nru upm-1.6.0/src/grovevdiv/jsupm_grovevdiv.i upm-1.7.1/src/grovevdiv/jsupm_grovevdiv.i --- upm-1.6.0/src/grovevdiv/jsupm_grovevdiv.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovevdiv/jsupm_grovevdiv.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovevdiv -%include "../upm.i" - -%{ - #include "grovevdiv.hpp" -%} - -%include "grovevdiv.hpp" diff -Nru upm-1.6.0/src/grovevdiv/pyupm_grovevdiv.i upm-1.7.1/src/grovevdiv/pyupm_grovevdiv.i --- upm-1.6.0/src/grovevdiv/pyupm_grovevdiv.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovevdiv/pyupm_grovevdiv.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovevdiv -%include "../upm.i" - -%include "grovevdiv.hpp" -%{ - #include "grovevdiv.hpp" -%} diff -Nru upm-1.6.0/src/grovewater/grovewater.json upm-1.7.1/src/grovewater/grovewater.json --- upm-1.6.0/src/grovewater/grovewater.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovewater/grovewater.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "grovewater", - "Description": "Grove Water Sensor Library", - "Sensor Class": - { - "GroveWater": - { - "Name": "Grove Water Sensor", - "Description": "UPM module for the Grove Water sensor.", - "Aliases": ["grovewater"], - "Categories": ["liquid", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["agriculture", "environmental", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["eak"], - "Examples": - { - "Java": ["GroveWaterSample.java"], - "Python": ["grovewater.py"], - "Node.js": ["grovewater.js"], - "C++": ["grovewater.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 4.7, "high": 5.25}, - "Operating Current": {"unit": "mA", "max": 20}, - "Working Temperature": {"unit": "degC", "low": 10, "high": 30} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Water-Sensor-p-748.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Water_Sensor/"], - "Schematics": [] - } - } - } -} +{ + "Library": "grovewater", + "Description": "Grove Water Sensor Library", + "Sensor Class": + { + "GroveWater": + { + "Name": "Grove Water Sensor", + "Description": "UPM module for the Grove Water sensor.", + "Aliases": ["grovewater"], + "Categories": ["liquid", "deprecated"], + "Connections": ["gpio"], + "Project Type": ["agriculture", "environmental", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": ["eak"], + "Examples": + { + "Java": ["GroveWater_Example.java"], + "Python": ["grovewater.py"], + "Node.js": ["grovewater.js"], + "C++": ["grovewater.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 4.7, "high": 5.25}, + "Operating Current": {"unit": "mA", "max": 20}, + "Working Temperature": {"unit": "degC", "low": 10, "high": 30} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Water-Sensor-p-748.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Water_Sensor/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/grovewater/javaupm_grovewater.i upm-1.7.1/src/grovewater/javaupm_grovewater.i --- upm-1.6.0/src/grovewater/javaupm_grovewater.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovewater/javaupm_grovewater.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_grovewater -%include "../upm.i" - -%{ - #include "grovewater.hpp" -%} - -%include "grovewater.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovewater) \ No newline at end of file diff -Nru upm-1.6.0/src/grovewater/jsupm_grovewater.i upm-1.7.1/src/grovewater/jsupm_grovewater.i --- upm-1.6.0/src/grovewater/jsupm_grovewater.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovewater/jsupm_grovewater.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovewater -%include "../upm.i" - -%{ - #include "grovewater.hpp" -%} - -%include "grovewater.hpp" diff -Nru upm-1.6.0/src/grovewater/pyupm_grovewater.i upm-1.7.1/src/grovewater/pyupm_grovewater.i --- upm-1.6.0/src/grovewater/pyupm_grovewater.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovewater/pyupm_grovewater.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovewater -%include "../upm.i" - -%include "grovewater.hpp" -%{ - #include "grovewater.hpp" -%} diff -Nru upm-1.6.0/src/grovewfs/grovewfs.i upm-1.7.1/src/grovewfs/grovewfs.i --- upm-1.6.0/src/grovewfs/grovewfs.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/grovewfs/grovewfs.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore flowISR; + +JAVA_JNI_LOADLIBRARY(javaupm_grovewfs) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "grovewfs.hpp" +%} +%include "grovewfs.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/grovewfs/grovewfs.json upm-1.7.1/src/grovewfs/grovewfs.json --- upm-1.6.0/src/grovewfs/grovewfs.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovewfs/grovewfs.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "grovewfs", - "Description": "API for the Grove Water Flow Sensor", - "Sensor Class": - { - "GroveWFS": - { - "Name": "Water Flow Sensor", - "Description": "This sensor is used to measure water flow in liters per minute (LPM). It incorporates a Hall Effect sensor. The UPM module defines an interrupt routine to be triggered on each low pulse, keeping count. This device requires a 10K pull-up resistor for the signal line (yellow wire). There is a schematic diagram on the SeeedStudio site (3/2015): http://www.seeedstudio.com/wiki/index.php?title=G1/2_Water_Flow_sensor However, be careful when wiring this up - the schematic appears to have a bug in it: the lower left connection of the signal line (yellow) to Vcc (red) should not be there. The sensor can work with this connection, but probably not for very long.", - "Aliases": ["grovewfs"], - "Categories": ["liquid", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["agriculture", "monitoring", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["eak"], - "Image": "grovewfs.jpg", - "Examples": - { - "Java": ["GroveWFSSample.java"], - "Python": ["grovewfs.py"], - "Node.js": ["grovewfs.js"], - "C++": ["grovewfs.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 5, "high": 24}, - "Operating Current": {"unit": "mA", "typ": 15}, - "Water Pressure": {"unit": "MPa", "max": 2}, - "Water Temperature": {"unit": "degC", "max": 120} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/G1%26amp%3B2%26quot%3B-Water-Flow-Sensor-p-635.html"], - "Datasheets": ["http://wiki.seeedstudio.com/wiki/G1/2_Water_Flow_sensor", "http://www.seeedstudio.com/wiki/images/b/b7/Water_flow_sensor_datasheet.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "grovewfs", + "Description": "API for the Grove Water Flow Sensor", + "Sensor Class": + { + "GroveWFS": + { + "Name": "Water Flow Sensor", + "Description": "This sensor is used to measure water flow in liters per minute (LPM). It incorporates a Hall Effect sensor. The UPM module defines an interrupt routine to be triggered on each low pulse, keeping count. This device requires a 10K pull-up resistor for the signal line (yellow wire). There is a schematic diagram on the SeeedStudio site (3/2015): http://www.seeedstudio.com/wiki/index.php?title=G1/2_Water_Flow_sensor However, be careful when wiring this up - the schematic appears to have a bug in it: the lower left connection of the signal line (yellow) to Vcc (red) should not be there. The sensor can work with this connection, but probably not for very long.", + "Aliases": ["grovewfs"], + "Categories": ["liquid", "deprecated"], + "Connections": ["gpio"], + "Project Type": ["agriculture", "monitoring", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": ["eak"], + "Image": "grovewfs.jpg", + "Examples": + { + "Java": ["GroveWFS_Example.java"], + "Python": ["grovewfs.py"], + "Node.js": ["grovewfs.js"], + "C++": ["grovewfs.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 5, "high": 24}, + "Operating Current": {"unit": "mA", "typ": 15}, + "Water Pressure": {"unit": "MPa", "max": 2}, + "Water Temperature": {"unit": "degC", "max": 120} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/G1%26amp%3B2%26quot%3B-Water-Flow-Sensor-p-635.html"], + "Datasheets": ["http://wiki.seeedstudio.com/wiki/G1/2_Water_Flow_sensor", "http://www.seeedstudio.com/wiki/images/b/b7/Water_flow_sensor_datasheet.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/grovewfs/javaupm_grovewfs.i upm-1.7.1/src/grovewfs/javaupm_grovewfs.i --- upm-1.6.0/src/grovewfs/javaupm_grovewfs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovewfs/javaupm_grovewfs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_grovewfs -%include "../upm.i" - -%ignore flowISR; - -%{ - #include "grovewfs.hpp" -%} - -%include "grovewfs.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_grovewfs) \ No newline at end of file diff -Nru upm-1.6.0/src/grovewfs/jsupm_grovewfs.i upm-1.7.1/src/grovewfs/jsupm_grovewfs.i --- upm-1.6.0/src/grovewfs/jsupm_grovewfs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovewfs/jsupm_grovewfs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_grovewfs -%include "../upm.i" - -%{ - #include "grovewfs.hpp" -%} - -%include "grovewfs.hpp" diff -Nru upm-1.6.0/src/grovewfs/pyupm_grovewfs.i upm-1.7.1/src/grovewfs/pyupm_grovewfs.i --- upm-1.6.0/src/grovewfs/pyupm_grovewfs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/grovewfs/pyupm_grovewfs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_grovewfs -%include "../upm.i" - -%include "grovewfs.hpp" -%{ - #include "grovewfs.hpp" -%} diff -Nru upm-1.6.0/src/gsr/gsr.json upm-1.7.1/src/gsr/gsr.json --- upm-1.6.0/src/gsr/gsr.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gsr/gsr.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "gsr", - "Description": "API for the Grove GSR Galvanic Skin Response Sensor", - "Sensor Class": - { - "GSR": - { - "Name": "Galvanic Skin Response (GSR) Sensor", - "Description": "Measures the electrical conductance of skin to measure strong emotional reactions. In other words, it measures sweat on your fingers as an indicator of strong emotional reactions.", - "Aliases": ["gsr"], - "Categories": ["skinresponse"], - "Connections": ["analog"], - "Project Type": ["medical", "interface", "wearables", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "gsr.jpg", - "Examples": - { - "Java": ["Gsr.java"], - "Python": ["gsr.py"], - "Node.js": ["gsr.js"], - "C++": ["gsr.cxx"], - "C": ["gsr.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "low": 0.7, "high": 3}, - "Operating Temperature": {"unit": "degC", "min": 0, "max": 70} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-GSR-sensor-p-1614.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-GSR_Sensor/", "file:///C:/Users/Malachai/Downloads/Lm324.pdf"], - "Schematics": ["https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR_v1.2_SCH.pdf", "https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR%20v1.0%20SCH.pdf"] - } - } - } -} +{ + "Library": "gsr", + "Description": "API for the Grove GSR Galvanic Skin Response Sensor", + "Sensor Class": + { + "GSR": + { + "Name": "Galvanic Skin Response (GSR) Sensor", + "Description": "Measures the electrical conductance of skin to measure strong emotional reactions. In other words, it measures sweat on your fingers as an indicator of strong emotional reactions.", + "Aliases": ["gsr"], + "Categories": ["skinresponse"], + "Connections": ["analog"], + "Project Type": ["medical", "interface", "wearables", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "gsr.jpg", + "Examples": + { + "Java": ["Gsr_Example.java"], + "Python": ["gsr.py"], + "Node.js": ["gsr.js"], + "C++": ["gsr.cxx"], + "C": ["gsr.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "mA", "low": 0.7, "high": 3}, + "Operating Temperature": {"unit": "degC", "min": 0, "max": 70} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-GSR-sensor-p-1614.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-GSR_Sensor/", "file:///C:/Users/Malachai/Downloads/Lm324.pdf"], + "Schematics": ["https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR_v1.2_SCH.pdf", "https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR%20v1.0%20SCH.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/gsr/javaupm_gsr.i upm-1.7.1/src/gsr/javaupm_gsr.i --- upm-1.6.0/src/gsr/javaupm_gsr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gsr/javaupm_gsr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_gsr -%include "../upm.i" - -%{ - #include "gsr.hpp" -%} - -%include "gsr.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_gsr) \ No newline at end of file diff -Nru upm-1.6.0/src/gsr/jsupm_gsr.i upm-1.7.1/src/gsr/jsupm_gsr.i --- upm-1.6.0/src/gsr/jsupm_gsr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gsr/jsupm_gsr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_gsr -%include "../upm.i" - -%{ - #include "gsr.hpp" -%} - -%include "gsr.hpp" diff -Nru upm-1.6.0/src/gsr/pyupm_gsr.i upm-1.7.1/src/gsr/pyupm_gsr.i --- upm-1.6.0/src/gsr/pyupm_gsr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/gsr/pyupm_gsr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_gsr -%include "../upm.i" - -%include "gsr.hpp" -%{ - #include "gsr.hpp" -%} diff -Nru upm-1.6.0/src/guvas12d/guvas12d.json upm-1.7.1/src/guvas12d/guvas12d.json --- upm-1.6.0/src/guvas12d/guvas12d.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/guvas12d/guvas12d.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "guvas12d", - "Description": "API for the GUVA-S12D UV Sensor", - "Sensor Class": - { - "GUVAS12D": - { - "Name": "Grove Analog UV Sensor", - "Description": "UPM module for the GUVA-S12D UV sensor", - "Aliases": ["guvas12d"], - "Categories": ["ultraviolet"], - "Connections": ["gpio"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["eak"], - "Image": "guvas12d.jpg", - "Examples": - { - "Java": ["GUVAS12DSample.java"], - "Python": ["guvas12d.py"], - "Node.js": ["guvas12d.js"], - "C++": ["guvas12d.cxx"], - "C": ["guvas12d.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3, "high": 5.1}, - "Operating Current": {"unit": "mA", "typ": 0.31}, - "Response Wavelength": {"unit": "nm", "low": 240, "high": 370}, - "Working Temperature": {"unit": "degC", "low": -30, "high": 85} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-UV-Sensor-p-1540.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-UV_Sensor/", "https://raw.githubusercontent.com/SeeedDocument/Grove-UV_Sensor/master/res/Grove-UV_Sensor_v1.1_Datasheets.zip"], - "Schematics": ["https://github.com/SeeedDocument/Grove-UV_Sensor/raw/master/res/Grove%20-%20UV%20Sensor%20v1.1sch.pdf"] - } - } - } -} +{ + "Library": "guvas12d", + "Description": "API for the GUVA-S12D UV Sensor", + "Sensor Class": + { + "GUVAS12D": + { + "Name": "Grove Analog UV Sensor", + "Description": "UPM module for the GUVA-S12D UV sensor", + "Aliases": ["guvas12d"], + "Categories": ["ultraviolet"], + "Connections": ["gpio"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": ["eak"], + "Image": "guvas12d.jpg", + "Examples": + { + "Java": ["GUVAS12D_Example.java"], + "Python": ["guvas12d.py"], + "Node.js": ["guvas12d.js"], + "C++": ["guvas12d.cxx"], + "C": ["guvas12d.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3, "high": 5.1}, + "Operating Current": {"unit": "mA", "typ": 0.31}, + "Response Wavelength": {"unit": "nm", "low": 240, "high": 370}, + "Working Temperature": {"unit": "degC", "low": -30, "high": 85} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-UV-Sensor-p-1540.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-UV_Sensor/", "https://raw.githubusercontent.com/SeeedDocument/Grove-UV_Sensor/master/res/Grove-UV_Sensor_v1.1_Datasheets.zip"], + "Schematics": ["https://github.com/SeeedDocument/Grove-UV_Sensor/raw/master/res/Grove%20-%20UV%20Sensor%20v1.1sch.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/guvas12d/javaupm_guvas12d.i upm-1.7.1/src/guvas12d/javaupm_guvas12d.i --- upm-1.6.0/src/guvas12d/javaupm_guvas12d.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/guvas12d/javaupm_guvas12d.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_guvas12d -%include "../upm.i" - -%{ - #include "guvas12d.hpp" -%} - -%include "guvas12d.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_guvas12d) \ No newline at end of file diff -Nru upm-1.6.0/src/guvas12d/jsupm_guvas12d.i upm-1.7.1/src/guvas12d/jsupm_guvas12d.i --- upm-1.6.0/src/guvas12d/jsupm_guvas12d.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/guvas12d/jsupm_guvas12d.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_guvas12d -%include "../upm.i" - -%{ - #include "guvas12d.hpp" -%} - -%include "guvas12d.hpp" diff -Nru upm-1.6.0/src/guvas12d/pyupm_guvas12d.i upm-1.7.1/src/guvas12d/pyupm_guvas12d.i --- upm-1.6.0/src/guvas12d/pyupm_guvas12d.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/guvas12d/pyupm_guvas12d.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_guvas12d -%include "../upm.i" - -%include "guvas12d.hpp" -%{ - #include "guvas12d.hpp" -%} diff -Nru upm-1.6.0/src/h3lis331dl/h3lis331dl.i upm-1.7.1/src/h3lis331dl/h3lis331dl.i --- upm-1.6.0/src/h3lis331dl/h3lis331dl.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/h3lis331dl/h3lis331dl.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,27 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "std_vector.i" + +%apply float *OUTPUT { float *aX, float *aY, float *aZ }; +%apply int *OUTPUT { int *x, int *y, int*z }; + +%ignore i2cContext; + +%template(IntVector) std::vector; +%template(FloatVector) std::vector; + +JAVA_JNI_LOADLIBRARY(javaupm_h3lis331dl) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(int, intp); +%pointer_functions(float, floatp); + +%{ +#include "h3lis331dl.hpp" +%} +%include "h3lis331dl.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/h3lis331dl/h3lis331dl.json upm-1.7.1/src/h3lis331dl/h3lis331dl.json --- upm-1.6.0/src/h3lis331dl/h3lis331dl.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/h3lis331dl/h3lis331dl.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "h3lis331dl", - "Description": "H3LIS331DL I2C Accelerometer (400g) Library", - "Sensor Class": - { - "H3LIS331DL": - { - "Name": "I2C 3-axis Digital Accelerometer (400g)", - "Description": "This is a high-performance, high-range accelerometer for extreme applications.", - "Aliases": ["h3lis331dl"], - "Categories": ["accelerometer"], - "Connections": ["i2c"], - "Project Type": ["IMU", "prototyping"], - "Manufacturers": ["seeed", "stmicro"], - "Kits": [], - "Image": "h3lis331dl.jpg", - "Examples": - { - "Java": ["H3LIS331DLSample.java"], - "Python": ["h3lis331dl.py"], - "Node.js": ["h3lis331dl.js"], - "C++": ["h3lis331dl.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "uA", "typ": 300}, - "Measurement Range": {"unit": "+-g", "low": 100, "high": 400} - }, - "Urls" : - { - "Product Pages": ["httpshttps://www.seeedstudio.com/Grove-3Axis-Digital-Accelerometer400g-p-1897.html"], - "Datasheets": ["http://www.st.com/web/en/resource/technical/document/datasheet/DM00053090.pdf", "http://wiki.seeed.cc/Grove-3-Axis_Digital_Accelerometer-400g/"], - "Schematics": [] - } - } - } -} +{ + "Library": "h3lis331dl", + "Description": "H3LIS331DL I2C Accelerometer (400g) Library", + "Sensor Class": + { + "H3LIS331DL": + { + "Name": "I2C 3-axis Digital Accelerometer (400g)", + "Description": "This is a high-performance, high-range accelerometer for extreme applications.", + "Aliases": ["h3lis331dl"], + "Categories": ["accelerometer"], + "Connections": ["i2c"], + "Project Type": ["IMU", "prototyping"], + "Manufacturers": ["seeed", "stmicro"], + "Kits": [], + "Image": "h3lis331dl.jpg", + "Examples": + { + "Java": ["H3LIS331DL_Example.java"], + "Python": ["h3lis331dl.py"], + "Node.js": ["h3lis331dl.js"], + "C++": ["h3lis331dl.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "uA", "typ": 300}, + "Measurement Range": {"unit": "+-g", "low": 100, "high": 400} + }, + "Urls" : + { + "Product Pages": ["httpshttps://www.seeedstudio.com/Grove-3Axis-Digital-Accelerometer400g-p-1897.html"], + "Datasheets": ["http://www.st.com/web/en/resource/technical/document/datasheet/DM00053090.pdf", "http://wiki.seeed.cc/Grove-3-Axis_Digital_Accelerometer-400g/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/h3lis331dl/javaupm_h3lis331dl.i upm-1.7.1/src/h3lis331dl/javaupm_h3lis331dl.i --- upm-1.6.0/src/h3lis331dl/javaupm_h3lis331dl.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/h3lis331dl/javaupm_h3lis331dl.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -%module javaupm_h3lis331dl -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "std_vector.i" - -%template(IntVector) std::vector; -%template(FloatVector) std::vector; - -%apply int *OUTPUT { int *x, int *y, int*z }; -%apply float *OUTPUT { float *aX, float *aY, float *aZ }; - -%ignore i2cContext; - -%{ -#include "h3lis331dl.hpp" -%} -%include "h3lis331dl.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_h3lis331dl) diff -Nru upm-1.6.0/src/h3lis331dl/jsupm_h3lis331dl.i upm-1.7.1/src/h3lis331dl/jsupm_h3lis331dl.i --- upm-1.6.0/src/h3lis331dl/jsupm_h3lis331dl.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/h3lis331dl/jsupm_h3lis331dl.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module jsupm_h3lis331dl -%include "../upm.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to JavaScript as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%{ - #include "h3lis331dl.hpp" -%} - -%include "h3lis331dl.hpp" diff -Nru upm-1.6.0/src/h3lis331dl/pyupm_h3lis331dl.i upm-1.7.1/src/h3lis331dl/pyupm_h3lis331dl.i --- upm-1.6.0/src/h3lis331dl/pyupm_h3lis331dl.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/h3lis331dl/pyupm_h3lis331dl.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_h3lis331dl -%include "../upm.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to python as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "h3lis331dl.hpp" -%{ - #include "h3lis331dl.hpp" -%} diff -Nru upm-1.6.0/src/h803x/h803x.i upm-1.7.1/src/h803x/h803x.i --- upm-1.6.0/src/h803x/h803x.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/h803x/h803x.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_h803x) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "h803x.hpp" +%} +%include "h803x.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/h803x/h803x.json upm-1.7.1/src/h803x/h803x.json --- upm-1.6.0/src/h803x/h803x.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/h803x/h803x.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "h803x", - "Description": "UPM API for the Veris H803X Energy Meter", - "Sensor Class": - { - "H803X": - { - "Name": "Veris H803X Energy Meter Module", - "Description": "The H8036 is similar to the H8035, but provides much more data. The Enercept H8035/H8036 is an innovative three-phase networked (Modbus RTU) power transducer that combines electronics and high accuracy industrial grade CTs in a single package. The need for external electrical enclosures is eliminated, greatly reducing installation time and cost. Color-coordination between voltage leads and CTs makes phase matching easy. Additionally, these transducers automatically detect and compensate for phase reversal, eliminating the concern of CT load orientation. Up to 63 Transducers can be daisy-chained on a single RS-485 network. This module was developed using libmodbus 3.1.2, and the H8035. The H8036 has not been tested. libmodbus 3.1.2 must be present for this module to build. It was developed using an RS232->RS485 interface. You cannot use the built in MCU TTL UART pins for accessing this device -- you must use a full Serial RS232->RS485 or USB-RS485 interface connected via USB.", - "Aliases": ["h803x"], - "Categories": ["energy", "electric"], - "Connections": ["uart"], - "Project Type": ["prototyping"], - "Manufacturers": ["veris"], - "Kits": [], - "Examples": - { - "Java": ["H803X_Example.java"], - "Python": ["h803x.py"], - "Node.js": ["h803x.js"], - "C++": ["h803x.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "VAC", "low": 208, "high": 480}, - "Operating Current": {"unit": "A", "max": 2400}, - "Operating Temperature": {"unit": "degC", "low": 0, "high": 60} - }, - "Urls" : - { - "Product Pages": ["http://www.veris.com/Item/H8035-0100-2.aspx"], - "Datasheets": ["http://www.veris.com/docs/Datasheets/H803x_d0117.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "h803x", + "Description": "UPM API for the Veris H803X Energy Meter", + "Sensor Class": + { + "H803X": + { + "Name": "Veris H803X Energy Meter Module", + "Description": "The H8036 is similar to the H8035, but provides much more data. The Enercept H8035/H8036 is an innovative three-phase networked (Modbus RTU) power transducer that combines electronics and high accuracy industrial grade CTs in a single package. The need for external electrical enclosures is eliminated, greatly reducing installation time and cost. Color-coordination between voltage leads and CTs makes phase matching easy. Additionally, these transducers automatically detect and compensate for phase reversal, eliminating the concern of CT load orientation. Up to 63 Transducers can be daisy-chained on a single RS-485 network. This module was developed using libmodbus 3.1.2, and the H8035. The H8036 has not been tested. libmodbus 3.1.2 must be present for this module to build. It was developed using an RS232->RS485 interface. You cannot use the built in MCU TTL UART pins for accessing this device -- you must use a full Serial RS232->RS485 or USB-RS485 interface connected via USB.", + "Aliases": ["h803x"], + "Categories": ["energy", "electric"], + "Connections": ["uart"], + "Project Type": ["prototyping"], + "Manufacturers": ["veris"], + "Kits": [], + "Examples": + { + "Java": ["H803X_Example.java"], + "Python": ["h803x.py"], + "Node.js": ["h803x.js"], + "C++": ["h803x.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "VAC", "low": 208, "high": 480}, + "Operating Current": {"unit": "A", "max": 2400}, + "Operating Temperature": {"unit": "degC", "low": 0, "high": 60} + }, + "Urls" : + { + "Product Pages": ["http://www.veris.com/Item/H8035-0100-2.aspx"], + "Datasheets": ["http://www.veris.com/docs/Datasheets/H803x_d0117.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/h803x/javaupm_h803x.i upm-1.7.1/src/h803x/javaupm_h803x.i --- upm-1.6.0/src/h803x/javaupm_h803x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/h803x/javaupm_h803x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_h803x -%include "../upm.i" -%include "typemaps.i" - -%{ - #include "h803x.hpp" -%} - -%include "h803x.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_h803x) diff -Nru upm-1.6.0/src/h803x/jsupm_h803x.i upm-1.7.1/src/h803x/jsupm_h803x.i --- upm-1.6.0/src/h803x/jsupm_h803x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/h803x/jsupm_h803x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_h803x -%include "../upm.i" -%include "stdint.i" - -%include "h803x.hpp" -%{ - #include "h803x.hpp" -%} diff -Nru upm-1.6.0/src/h803x/pyupm_h803x.i upm-1.7.1/src/h803x/pyupm_h803x.i --- upm-1.6.0/src/h803x/pyupm_h803x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/h803x/pyupm_h803x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_h803x -%include "../upm.i" -%include "stdint.i" - -%include "h803x.hpp" -%{ - #include "h803x.hpp" -%} diff -Nru upm-1.6.0/src/hcsr04/hcsr04.i upm-1.7.1/src/hcsr04/hcsr04.i --- upm-1.6.0/src/hcsr04/hcsr04.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/hcsr04/hcsr04.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,15 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_hcsr04) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "hcsr04.hpp" +%} +%include "hcsr04.h" +%include "hcsr04.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/hcsr04/hcsr04.json upm-1.7.1/src/hcsr04/hcsr04.json --- upm-1.6.0/src/hcsr04/hcsr04.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hcsr04/hcsr04.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "hcsr04", - "Description": "HC-SR04 Ultrasonic Sensor Library", - "Sensor Class": - { - "HCSR04": - { - "Name": "HC-SR04 Ultrasonic Distance Measuring Sensor", - "Description": "This module defines the HC-SR04 interface for libhcsr04.", - "Aliases": ["hcsr04"], - "Categories": ["ultrasonic", "distance"], - "Connections": ["gpio"], - "Project Type": ["robotics", "safety", "prototyping"], - "Manufacturers": ["sparkfun"], - "Kits": [], - "Examples": - { - "Java": ["HCSR04Sample.java"], - "Python": ["hcsr04.py"], - "Node.js": ["hcsr04.js"], - "C++": ["hcsr04.cxx"], - "C": ["hcsr04.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "typ": 15}, - "Measurement Range": {"unit": "cm", "low": 2, "high": 400} - }, - "Urls" : - { - "Product Pages": ["https://www.sparkfun.com/products/13959"], - "Datasheets": ["https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "hcsr04", + "Description": "HC-SR04 Ultrasonic Sensor Library", + "Sensor Class": + { + "HCSR04": + { + "Name": "HC-SR04 Ultrasonic Distance Measuring Sensor", + "Description": "This module defines the HC-SR04 interface for libhcsr04.", + "Aliases": ["hcsr04"], + "Categories": ["ultrasonic", "distance"], + "Connections": ["gpio"], + "Project Type": ["robotics", "safety", "prototyping"], + "Manufacturers": ["sparkfun"], + "Kits": [], + "Examples": + { + "Java": ["HCSR04_Example.java"], + "Python": ["hcsr04.py"], + "Node.js": ["hcsr04.js"], + "C++": ["hcsr04.cxx"], + "C": ["hcsr04.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "typ": 15}, + "Measurement Range": {"unit": "cm", "low": 2, "high": 400} + }, + "Urls" : + { + "Product Pages": ["https://www.sparkfun.com/products/13959"], + "Datasheets": ["https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hcsr04/javaupm_hcsr04.i upm-1.7.1/src/hcsr04/javaupm_hcsr04.i --- upm-1.6.0/src/hcsr04/javaupm_hcsr04.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hcsr04/javaupm_hcsr04.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_hcsr04 -%include "../upm.i" - -%{ - #include "hcsr04.hpp" -%} - -%include "hcsr04.h" -%include "hcsr04.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_hcsr04) - diff -Nru upm-1.6.0/src/hcsr04/jsupm_hcsr04.i upm-1.7.1/src/hcsr04/jsupm_hcsr04.i --- upm-1.6.0/src/hcsr04/jsupm_hcsr04.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hcsr04/jsupm_hcsr04.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_hcsr04 -%include "../upm.i" - -%{ - #include "hcsr04.hpp" -%} - -%include "hcsr04.h" -%include "hcsr04.hpp" diff -Nru upm-1.6.0/src/hcsr04/pyupm_hcsr04.i upm-1.7.1/src/hcsr04/pyupm_hcsr04.i --- upm-1.6.0/src/hcsr04/pyupm_hcsr04.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hcsr04/pyupm_hcsr04.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hcsr04 -%include "../upm.i" - -%include "hcsr04.h" -%include "hcsr04.hpp" -%{ - #include "hcsr04.hpp" -%} diff -Nru upm-1.6.0/src/hdc1000/hdc1000.json upm-1.7.1/src/hdc1000/hdc1000.json --- upm-1.6.0/src/hdc1000/hdc1000.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hdc1000/hdc1000.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "hdc1000", - "Description": "API for the HDC1000 Temperature & Humidity Sensor", - "Sensor Class": - { - "HDC1000": - { - "Name": "HDC1000 Temperature and Humidity Sensor", - "Description": "The HDC1000 is a digital humidity sensor with integrated temperature sensor that provides excellent measurement accuracy at very low power. The device measures humidity based on a novel capacitive sensor. The humidity and temperature sensors are factory calibrated. The innovative WLCSP (Wafer Level Chip Scale Package) simplifies board design with the use of an ultra-compact package. The sensing element of the HDC1000 is placed on the bottom part of the device, which makes the HDC1000 more robust against dirt, dust, and other environmental contaminants. The HDC1000 is functional within the full -40 to +125 [degC] temperature range.", - "Aliases": ["hdc1000"], - "Categories": ["temperature", "humidity"], - "Connections": ["i2c"], - "Project Type": ["environmental", "", "prototyping"], - "Manufacturers": ["ti"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": ["hdc1000.py"], - "Node.js": [], - "C++": ["hdc1000.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3, "high": 5}, - "Operating Current": {"unit": "uA", "low": 0.82, "high": 1.2}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 125} - }, - "Urls" : - { - "Product Pages": ["http://www.ti.com/product/HDC1000/description"], - "Datasheets": ["http://www.ti.com/lit/ds/symlink/hdc1000.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "hdc1000", + "Description": "API for the HDC1000 Temperature & Humidity Sensor", + "Sensor Class": + { + "HDC1000": + { + "Name": "HDC1000 Temperature and Humidity Sensor", + "Description": "The HDC1000 is a digital humidity sensor with integrated temperature sensor that provides excellent measurement accuracy at very low power. The device measures humidity based on a novel capacitive sensor. The humidity and temperature sensors are factory calibrated. The innovative WLCSP (Wafer Level Chip Scale Package) simplifies board design with the use of an ultra-compact package. The sensing element of the HDC1000 is placed on the bottom part of the device, which makes the HDC1000 more robust against dirt, dust, and other environmental contaminants. The HDC1000 is functional within the full -40 to +125 [degC] temperature range.", + "Aliases": ["hdc1000"], + "Categories": ["temperature", "humidity"], + "Connections": ["i2c"], + "Project Type": ["environmental", "", "prototyping"], + "Manufacturers": ["ti"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": ["hdc1000.py"], + "Node.js": [], + "C++": ["hdc1000.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3, "high": 5}, + "Operating Current": {"unit": "uA", "low": 0.82, "high": 1.2}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 125} + }, + "Urls" : + { + "Product Pages": ["http://www.ti.com/product/HDC1000/description"], + "Datasheets": ["http://www.ti.com/lit/ds/symlink/hdc1000.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hdc1000/javaupm_hdc1000.i upm-1.7.1/src/hdc1000/javaupm_hdc1000.i --- upm-1.6.0/src/hdc1000/javaupm_hdc1000.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hdc1000/javaupm_hdc1000.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_hdc1000 -%include "../upm.i" - -%{ - #include "hdc1000.hpp" -%} - -%include "hdc1000.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_hdc1000) \ No newline at end of file diff -Nru upm-1.6.0/src/hdc1000/jsupm_hdc1000.i upm-1.7.1/src/hdc1000/jsupm_hdc1000.i --- upm-1.6.0/src/hdc1000/jsupm_hdc1000.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hdc1000/jsupm_hdc1000.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_hdc1000 -%include "../upm.i" - -%{ - #include "hdc1000.hpp" -%} - -%include "hdc1000.hpp" diff -Nru upm-1.6.0/src/hdc1000/pyupm_hdc1000.i upm-1.7.1/src/hdc1000/pyupm_hdc1000.i --- upm-1.6.0/src/hdc1000/pyupm_hdc1000.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hdc1000/pyupm_hdc1000.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hdc1000 -%include "../upm.i" - -%include "hdc1000.hpp" -%{ - #include "hdc1000.hpp" -%} diff -Nru upm-1.6.0/src/hdxxvxta/hdxxvxta.i upm-1.7.1/src/hdxxvxta/hdxxvxta.i --- upm-1.6.0/src/hdxxvxta/hdxxvxta.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/hdxxvxta/hdxxvxta.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_hdxxvxta) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "hdxxvxta.hpp" +%} +%include "hdxxvxta.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/hdxxvxta/hdxxvxta.json upm-1.7.1/src/hdxxvxta/hdxxvxta.json --- upm-1.6.0/src/hdxxvxta/hdxxvxta.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hdxxvxta/hdxxvxta.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,35 +1,35 @@ -{ - "Library": "hdxxvxta", - "Description": "API for the Veris HDXXVXTA Humidity Transmitter", - "Sensor Class": - { - "HDXXVXTA": - { - "Name": "Veris HDXXVXTA Humidity Transmitter", - "Description": "The driver was developed using the HD2NVSTA1 humidity transmitter. The 'T' variant supports a temperature transmitter as well. Both signals are provided by the device as analog 0-5Vdc or 0-10Vdc outputs. The A1 variant supports a temperature range of -40C-50C, while the A2 variant supports a range of 0C-50C. Humidity ranges for all devices in this device family range from 0% to 100% (non-condensing). This driver used the 5Vdc outputs for obvious reasons. Your MCU must be configured for 5V operation. Using any other analog reference voltage will require the appropriate external circuitry (such as a voltage divider) in order to interface safely with your MCU. For devices which do not support temperature, use '-1' as the temperature pin number in the object constructor. If temperature measurement is disabled, getTemperature() will always return 0C/32F.", - "Aliases": ["hdxxvxta"], - "Categories": ["humidity"], - "Connections": ["analog"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["veris"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": ["hdxxvxta.py"], - "Node.js": ["hdxxvxta.js"], - "C++": ["hdxxvxta.cxx"], - "C": [] - }, - "Specifications": - { - }, - "Urls" : - { - "Product Pages": [], - "Datasheets": [], - "Schematics": [] - } - } - } -} +{ + "Library": "hdxxvxta", + "Description": "API for the Veris HDXXVXTA Humidity Transmitter", + "Sensor Class": + { + "HDXXVXTA": + { + "Name": "Veris HDXXVXTA Humidity Transmitter", + "Description": "The driver was developed using the HD2NVSTA1 humidity transmitter. The 'T' variant supports a temperature transmitter as well. Both signals are provided by the device as analog 0-5Vdc or 0-10Vdc outputs. The A1 variant supports a temperature range of -40C-50C, while the A2 variant supports a range of 0C-50C. Humidity ranges for all devices in this device family range from 0% to 100% (non-condensing). This driver used the 5Vdc outputs for obvious reasons. Your MCU must be configured for 5V operation. Using any other analog reference voltage will require the appropriate external circuitry (such as a voltage divider) in order to interface safely with your MCU. For devices which do not support temperature, use '-1' as the temperature pin number in the object constructor. If temperature measurement is disabled, getTemperature() will always return 0C/32F.", + "Aliases": ["hdxxvxta"], + "Categories": ["humidity"], + "Connections": ["analog"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["veris"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": ["hdxxvxta.py"], + "Node.js": ["hdxxvxta.js"], + "C++": ["hdxxvxta.cxx"], + "C": [] + }, + "Specifications": + { + }, + "Urls" : + { + "Product Pages": [], + "Datasheets": [], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hdxxvxta/javaupm_hdxxvxta.i upm-1.7.1/src/hdxxvxta/javaupm_hdxxvxta.i --- upm-1.6.0/src/hdxxvxta/javaupm_hdxxvxta.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hdxxvxta/javaupm_hdxxvxta.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_hdxxvxta -%include "../upm.i" -%include "std_string.i" - -%{ - #include "hdxxvxta.hpp" -%} - -%include "hdxxvxta.hpp" - - -JAVA_JNI_LOADLIBRARY(javaupm_hdxxvxta) diff -Nru upm-1.6.0/src/hdxxvxta/jsupm_hdxxvxta.i upm-1.7.1/src/hdxxvxta/jsupm_hdxxvxta.i --- upm-1.6.0/src/hdxxvxta/jsupm_hdxxvxta.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hdxxvxta/jsupm_hdxxvxta.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_hdxxvxta -%include "../upm.i" -%include "std_string.i" - -%{ - #include "hdxxvxta.hpp" -%} - -%include "hdxxvxta.hpp" - diff -Nru upm-1.6.0/src/hdxxvxta/pyupm_hdxxvxta.i upm-1.7.1/src/hdxxvxta/pyupm_hdxxvxta.i --- upm-1.6.0/src/hdxxvxta/pyupm_hdxxvxta.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hdxxvxta/pyupm_hdxxvxta.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hdxxvxta -%include "../upm.i" -%include "std_string.i" - -%{ - #include "hdxxvxta.hpp" -%} -%include "hdxxvxta.hpp" - diff -Nru upm-1.6.0/src/hka5/hka5.i upm-1.7.1/src/hka5/hka5.i --- upm-1.6.0/src/hka5/hka5.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/hka5/hka5.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_hka5) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "hka5.hpp" +%} +%include "hka5.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/hka5/hka5.json upm-1.7.1/src/hka5/hka5.json --- upm-1.6.0/src/hka5/hka5.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hka5/hka5.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "hka5", - "Description": "API for the DFRobot Laser Particulate Matter (PM) Sensor", - "Sensor Class": - { - "HKA5": - { - "Name": "DFRobot Laser Particulate Matter (PM) Sensor", - "Description": "This driver was tested with a DFRobot Laser PM2.5 Sensor. It connects to a UART at 9600 baud. This is the only baud rate supported. It optionally supports Reset and Set/Sleep gpios as well.", - "Aliases": ["hka5"], - "Categories": ["gaseous"], - "Connections": ["gpio", "uart"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["dfrobot"], - "Kits": [], - "Examples": - { - "Java": ["HKA5_Example.java"], - "Python": ["hka5.py"], - "Node.js": ["hka5.js"], - "C++": ["hka5.cxx"], - "C": ["hka5.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "typ": 10} - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/wiki/index.php/DFRobot_LM35_Linear_Temperature_Sensor_(SKU:DFR0023)"], - "Datasheets": ["http://image.dfrobot.com/image/data/DFR0023/DFR0023_Datasheet.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "hka5", + "Description": "API for the DFRobot Laser Particulate Matter (PM) Sensor", + "Sensor Class": + { + "HKA5": + { + "Name": "DFRobot Laser Particulate Matter (PM) Sensor", + "Description": "This driver was tested with a DFRobot Laser PM2.5 Sensor. It connects to a UART at 9600 baud. This is the only baud rate supported. It optionally supports Reset and Set/Sleep gpios as well.", + "Aliases": ["hka5"], + "Categories": ["gaseous"], + "Connections": ["gpio", "uart"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["dfrobot"], + "Kits": [], + "Examples": + { + "Java": ["HKA5_Example.java"], + "Python": ["hka5.py"], + "Node.js": ["hka5.js"], + "C++": ["hka5.cxx"], + "C": ["hka5.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "mA", "typ": 10} + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/wiki/index.php/DFRobot_LM35_Linear_Temperature_Sensor_(SKU:DFR0023)"], + "Datasheets": ["http://image.dfrobot.com/image/data/DFR0023/DFR0023_Datasheet.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hka5/javaupm_hka5.i upm-1.7.1/src/hka5/javaupm_hka5.i --- upm-1.6.0/src/hka5/javaupm_hka5.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hka5/javaupm_hka5.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_hka5 -%include "../upm.i" -%include "std_string.i" -%include "stdint.i" -%include "typemaps.i" - -%include "hka5.hpp" -%{ - #include "hka5.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_hka5) diff -Nru upm-1.6.0/src/hka5/jsupm_hka5.i upm-1.7.1/src/hka5/jsupm_hka5.i --- upm-1.6.0/src/hka5/jsupm_hka5.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hka5/jsupm_hka5.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_hka5 -%include "../upm.i" -%include "std_string.i" - -%include "hka5.hpp" -%{ - #include "hka5.hpp" -%} diff -Nru upm-1.6.0/src/hka5/pyupm_hka5.i upm-1.7.1/src/hka5/pyupm_hka5.i --- upm-1.6.0/src/hka5/pyupm_hka5.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hka5/pyupm_hka5.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hka5 -%include "../upm.i" -%include "std_string.i" - -%include "hka5.hpp" -%{ - #include "hka5.hpp" -%} diff -Nru upm-1.6.0/src/hlg150h/hlg150h.i upm-1.7.1/src/hlg150h/hlg150h.i --- upm-1.6.0/src/hlg150h/hlg150h.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/hlg150h/hlg150h.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,19 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} +%import "../interfaces/javaupm_iLightController.i" + +JAVA_JNI_LOADLIBRARY(javaupm_hlg150h) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "hlg150h.hpp" +%} +%include "hlg150h.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/hlg150h/javaupm_hlg150h.i upm-1.7.1/src/hlg150h/javaupm_hlg150h.i --- upm-1.6.0/src/hlg150h/javaupm_hlg150h.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hlg150h/javaupm_hlg150h.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -%module javaupm_hlg150h - -%include "../upm.i" -%include "arrays_java.i"; -%include "../java_buffer.i" -%include "cpointer.i" -%include "typemaps.i" - -%import "../interfaces/javaupm_iLightController.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%{ - #include "hlg150h.hpp" -%} - -%include "hlg150h.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_hlg150h) diff -Nru upm-1.6.0/src/hlg150h/jsupm_hlg150h.i upm-1.7.1/src/hlg150h/jsupm_hlg150h.i --- upm-1.6.0/src/hlg150h/jsupm_hlg150h.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hlg150h/jsupm_hlg150h.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_hlg150h -%include "../upm.i" - -%{ - #include "hlg150h.hpp" -%} - -%include "hlg150h.hpp" diff -Nru upm-1.6.0/src/hlg150h/pyupm_hlg150h.i upm-1.7.1/src/hlg150h/pyupm_hlg150h.i --- upm-1.6.0/src/hlg150h/pyupm_hlg150h.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hlg150h/pyupm_hlg150h.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module pyupm_hlg150h -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%include "hlg150h.hpp" -%{ - #include "hlg150h.hpp" -%} diff -Nru upm-1.6.0/src/hm11/hm11.i upm-1.7.1/src/hm11/hm11.i --- upm-1.6.0/src/hm11/hm11.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/hm11/hm11.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,23 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../java_buffer.i" + +JAVA_JNI_LOADLIBRARY(javaupm_hm11) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "carrays.i" + +%{ +#include "hm11.hpp" +speed_t int_B9600 = B9600; +%} +%include "hm11.hpp" + +%array_class(char, charArray); + +speed_t int_B9600 = B9600; +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/hm11/hm11.json upm-1.7.1/src/hm11/hm11.json --- upm-1.6.0/src/hm11/hm11.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hm11/hm11.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "hm11", - "Description": "HM-11 Bluetooth 4.0 Low Energy Module Library", - "Sensor Class": - { - "HM11": - { - "Name": "Bluetooth Low Energy Module", - "Description": "The driver was tested with the Grove BLE module. It's an HM-11 BLE 4.0 module based on a TI CC2541 chip. It operates using a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses: http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf It is connected via a UART at 9,600 baud.", - "Aliases": ["hm11"], - "Categories": ["bluetooth"], - "Connections": ["uart"], - "Project Type": ["wireless", "wearables", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "hm11.jpg", - "Examples": - { - "Java": ["HM11Sample.java"], - "Python": ["hm11.py"], - "Node.js": ["hm11.js"], - "C++": ["hm11.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.0, "typ": 3.3, "high": 3.6}, - "Peak Operating Current": {"unit": "mA", "typ": 15}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 65} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Bluetooth-V4.0-HM-11-BLE-Module-p-1803.html"], - "Datasheets": ["http://wiki.seeed.cc/Bluetooth_V4.0_HM_11_BLE_Module/"], - "Schematics": [] - } - } - } -} +{ + "Library": "hm11", + "Description": "HM-11 Bluetooth 4.0 Low Energy Module Library", + "Sensor Class": + { + "HM11": + { + "Name": "Bluetooth Low Energy Module", + "Description": "The driver was tested with the Grove BLE module. It's an HM-11 BLE 4.0 module based on a TI CC2541 chip. It operates using a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses: http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf It is connected via a UART at 9,600 baud.", + "Aliases": ["hm11"], + "Categories": ["bluetooth"], + "Connections": ["uart"], + "Project Type": ["wireless", "wearables", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "hm11.jpg", + "Examples": + { + "Java": ["HM11_Example.java"], + "Python": ["hm11.py"], + "Node.js": ["hm11.js"], + "C++": ["hm11.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.0, "typ": 3.3, "high": 3.6}, + "Peak Operating Current": {"unit": "mA", "typ": 15}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 65} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Bluetooth-V4.0-HM-11-BLE-Module-p-1803.html"], + "Datasheets": ["http://wiki.seeed.cc/Bluetooth_V4.0_HM_11_BLE_Module/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hm11/javaupm_hm11.i upm-1.7.1/src/hm11/javaupm_hm11.i --- upm-1.6.0/src/hm11/javaupm_hm11.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hm11/javaupm_hm11.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -%module javaupm_hm11 -%include "../upm.i" -%include "carrays.i" -%include "../java_buffer.i" - -%{ - #include "hm11.hpp" - speed_t int_B9600 = B9600; -%} - -%include "hm11.hpp" -speed_t int_B9600 = B9600; -%array_class(char, charArray); - -JAVA_JNI_LOADLIBRARY(javaupm_hm11) \ No newline at end of file diff -Nru upm-1.6.0/src/hm11/jsupm_hm11.i upm-1.7.1/src/hm11/jsupm_hm11.i --- upm-1.6.0/src/hm11/jsupm_hm11.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hm11/jsupm_hm11.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module jsupm_hm11 -%include "../upm.i" -%include "carrays.i" - -%{ - #include "hm11.hpp" - speed_t int_B9600 = B9600; -%} - -%include "hm11.hpp" -speed_t int_B9600 = B9600; -%array_class(char, charArray); diff -Nru upm-1.6.0/src/hm11/pyupm_hm11.i upm-1.7.1/src/hm11/pyupm_hm11.i --- upm-1.6.0/src/hm11/pyupm_hm11.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hm11/pyupm_hm11.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hm11 -%include "../upm.i" -%include "carrays.i" - -%{ - #include "hm11.hpp" - speed_t int_B9600 = B9600; -%} -%include "hm11.hpp" -speed_t int_B9600 = B9600; -%array_class(char, charArray); diff -Nru upm-1.6.0/src/hmc5883l/hmc5883l.i upm-1.7.1/src/hmc5883l/hmc5883l.i --- upm-1.6.0/src/hmc5883l/hmc5883l.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/hmc5883l/hmc5883l.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,49 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%typemap(jni) int16_t* "jshortArray" +%typemap(jstype) int16_t* "short[]" +%typemap(jtype) int16_t* "short[]" + +%typemap(javaout) int16_t* { + return $jnicall; +} + +%typemap(out) int16_t *coordinates { + $result = JCALL1(NewShortArray, jenv, 3); + JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); +} + +JAVA_JNI_LOADLIBRARY(javaupm_hmc5883l) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_int16_t.i" + +// Adding this typemap because SWIG is converting int16 into a short by default +// This forces SWIG to convert it correctly +%typemap(out) int16_t* { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_int16_t.i" + +%typemap(out) int16_t* { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "hmc5883l.hpp" +%} +%include "hmc5883l.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/hmc5883l/hmc5883l.json upm-1.7.1/src/hmc5883l/hmc5883l.json --- upm-1.6.0/src/hmc5883l/hmc5883l.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hmc5883l/hmc5883l.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "hmc5883l", - "Description": "HMC5883L Magnetometer Library", - "Sensor Class": - { - "Hmc5883l": - { - "Name": "Grove 3-Axis Digital Compass", - "Description": "Honeywell [HMC5883L] (http://www.adafruit.com/datasheets/HMC5883L_3-Axis_Digital_Compass_IC.pdf) is a 3-axis digital compass. Communication with HMC5883L is simple and all done through an I2C interface. Different breakout boards are available. Typically, a 3V supply is all that is needed to power the sensor.", - "Aliases": ["hmc5883l"], - "Categories": ["compass", "magnetometer"], - "Connections": ["i2c"], - "Project Type": ["IMU", "prototyping"], - "Manufacturers": ["seeed", "honeywell"], - "Kits": ["robok"], - "Examples": - { - "Java": ["Hmc5883lSample.java"], - "Python": ["hmc5883l.py"], - "Node.js": ["hmc5883l.js"], - "C++": ["hmc5883l.cxx"], - "C": ["hmc5883l.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "uA", "low": 2.5, "high": 640}, - "Output Rate": {"unit": "Hz", "max": 116} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-3-Axis-Digital-Compass-p-759.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-3-Axis_Compass_V1.0/", "https://raw.githubusercontent.com/SeeedDocument/Grove-3-Axis_Compass_V1.0/master/res/HMC5883.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "hmc5883l", + "Description": "HMC5883L Magnetometer Library", + "Sensor Class": + { + "Hmc5883l": + { + "Name": "Grove 3-Axis Digital Compass", + "Description": "Honeywell [HMC5883L] (http://www.adafruit.com/datasheets/HMC5883L_3-Axis_Digital_Compass_IC.pdf) is a 3-axis digital compass. Communication with HMC5883L is simple and all done through an I2C interface. Different breakout boards are available. Typically, a 3V supply is all that is needed to power the sensor.", + "Aliases": ["hmc5883l"], + "Categories": ["compass", "magnetometer"], + "Connections": ["i2c"], + "Project Type": ["IMU", "prototyping"], + "Manufacturers": ["seeed", "honeywell"], + "Kits": ["robok"], + "Examples": + { + "Java": ["Hmc5883l_Example.java"], + "Python": ["hmc5883l.py"], + "Node.js": ["hmc5883l.js"], + "C++": ["hmc5883l.cxx"], + "C": ["hmc5883l.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "uA", "low": 2.5, "high": 640}, + "Output Rate": {"unit": "Hz", "max": 116} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-3-Axis-Digital-Compass-p-759.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-3-Axis_Compass_V1.0/", "https://raw.githubusercontent.com/SeeedDocument/Grove-3-Axis_Compass_V1.0/master/res/HMC5883.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hmc5883l/javaupm_hmc5883l.i upm-1.7.1/src/hmc5883l/javaupm_hmc5883l.i --- upm-1.6.0/src/hmc5883l/javaupm_hmc5883l.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hmc5883l/javaupm_hmc5883l.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -%module javaupm_hmc5883l -%include "../upm.i" - -%{ - #include "hmc5883l.hpp" -%} - -%typemap(jni) int16_t* "jshortArray" -%typemap(jstype) int16_t* "short[]" -%typemap(jtype) int16_t* "short[]" - -%typemap(javaout) int16_t* { - return $jnicall; -} - -%typemap(out) int16_t *coordinates { - $result = JCALL1(NewShortArray, jenv, 3); - JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); -} - -%include "hmc5883l.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_hmc5883l) \ No newline at end of file diff -Nru upm-1.6.0/src/hmc5883l/jsupm_hmc5883l.i upm-1.7.1/src/hmc5883l/jsupm_hmc5883l.i --- upm-1.6.0/src/hmc5883l/jsupm_hmc5883l.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hmc5883l/jsupm_hmc5883l.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module jsupm_hmc5883l -%include "../upm.i" -%include "../carrays_int16_t.i" -%{ - #include "hmc5883l.hpp" -%} - -// Adding this typemap because SWIG is converting int16 into a short by default -// This forces SWIG to convert it correctly -%typemap(out) int16_t* { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%include "hmc5883l.hpp" diff -Nru upm-1.6.0/src/hmc5883l/pyupm_hmc5883l.i upm-1.7.1/src/hmc5883l/pyupm_hmc5883l.i --- upm-1.6.0/src/hmc5883l/pyupm_hmc5883l.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hmc5883l/pyupm_hmc5883l.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hmc5883l -%include "../upm.i" -%include "../carrays_int16_t.i" - -%typemap(out) int16_t* { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%include "hmc5883l.hpp" -%{ - #include "hmc5883l.hpp" -%} diff -Nru upm-1.6.0/src/hmtrp/hmtrp.i upm-1.7.1/src/hmtrp/hmtrp.i --- upm-1.6.0/src/hmtrp/hmtrp.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/hmtrp/hmtrp.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,55 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../java_buffer.i" +%include "../java_exceptions.i" + +%apply uint32_t *OUTPUT { uint32_t *freq, uint32_t *dataRate }; +%apply uint16_t *OUTPUT { uint16_t *rxBandwidth }; +%apply uint8_t *OUTPUT { uint8_t *modulation, uint8_t *txPower }; +%apply uint32_t *OUTPUT { uint32_t *uartBaud }; +%apply uint8_t *OUTPUT { uint8_t *strength }; + +%ignore getRFSignalStrength(uint8_t *strength); +READDATA_EXCEPTION(getRFSignalStrength()) + +%ignore getModSignalStrength(uint8_t *strength); +READDATA_EXCEPTION(getModSignalStrength()) + +JAVA_JNI_LOADLIBRARY(javaupm_hmtrp) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint8_t.i" +%include "../carrays_uint16_t.i" +%include "../carrays_uint32_t.i" + +%array_class(char, charArray); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_uint8_t.i" +%include "../carrays_uint16_t.i" +%include "../carrays_uint32_t.i" + +%rename("getModSignalStrengthNoParam") getModSignalStrength(); +%rename("getRFSignalStrengthNoParam") getRFSignalStrength(); + +%array_class(char, charArray); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "hmtrp.hpp" +speed_t int_B9600 = B9600; +%} +%include "hmtrp.hpp" + +speed_t int_B9600 = B9600; +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/hmtrp/hmtrp.json upm-1.7.1/src/hmtrp/hmtrp.json --- upm-1.6.0/src/hmtrp/hmtrp.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hmtrp/hmtrp.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "hmtrp", - "Description": "API for the HM-TRP Serial RF Pro Transceiver", - "Sensor Class": - { - "HMTRP": - { - "Name": "Serial RF Pro Module", - "Description": "UPM support for the HM-TRP Serial RF Pro transceiver. This was tested specifically with the Grove Serial RF Pro transceiver. In theory, this class should work with the following devices: HM-TRP-433: 414000000-454000000Hz HM-TRP-470: 450000000-490000000Hz HM-TRP-868: 849000000-889000000Hz HM-TRP-915: 895000000-935000000Hz The only difference is the transmit and receive frequencies supported. By default, the device simply sends and receives any data presented on its UART interface. It can be put into a configuration mode by grounding the CONFIG pin on the transceiver.", - "Aliases": ["hmtrp"], - "Categories": ["wireless"], - "Connections": ["uart"], - "Project Type": ["wireless", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "hmtrp.jpg", - "Examples": - { - "Java": ["HMTRPSample.java"], - "Python": ["hmtrp.py"], - "Node.js": ["hmtrp.js"], - "C++": ["hmtrp.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 4.75, "typ": 5.0, "high": 5.25}, - "Sleep Current": {"unit": "uA", "typ": 1}, - "Transmission Distance": {"unit": "Km", "max": 1}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Serial-RF-Pro-p-794.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Serial_RF_Pro/", "https://github.com/SeeedDocument/Grove-Serial_RF_Pro/raw/master/res/HM-TRP-RS232_enV1.0_20120604.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "hmtrp", + "Description": "API for the HM-TRP Serial RF Pro Transceiver", + "Sensor Class": + { + "HMTRP": + { + "Name": "Serial RF Pro Module", + "Description": "UPM support for the HM-TRP Serial RF Pro transceiver. This was tested specifically with the Grove Serial RF Pro transceiver. In theory, this class should work with the following devices: HM-TRP-433: 414000000-454000000Hz HM-TRP-470: 450000000-490000000Hz HM-TRP-868: 849000000-889000000Hz HM-TRP-915: 895000000-935000000Hz The only difference is the transmit and receive frequencies supported. By default, the device simply sends and receives any data presented on its UART interface. It can be put into a configuration mode by grounding the CONFIG pin on the transceiver.", + "Aliases": ["hmtrp"], + "Categories": ["wireless"], + "Connections": ["uart"], + "Project Type": ["wireless", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "hmtrp.jpg", + "Examples": + { + "Java": ["HMTRP_Example.java"], + "Python": ["hmtrp.py"], + "Node.js": ["hmtrp.js"], + "C++": ["hmtrp.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 4.75, "typ": 5.0, "high": 5.25}, + "Sleep Current": {"unit": "uA", "typ": 1}, + "Transmission Distance": {"unit": "Km", "max": 1}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Serial-RF-Pro-p-794.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Serial_RF_Pro/", "https://github.com/SeeedDocument/Grove-Serial_RF_Pro/raw/master/res/HM-TRP-RS232_enV1.0_20120604.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hmtrp/javaupm_hmtrp.i upm-1.7.1/src/hmtrp/javaupm_hmtrp.i --- upm-1.6.0/src/hmtrp/javaupm_hmtrp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hmtrp/javaupm_hmtrp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -%module javaupm_hmtrp -%include "../upm.i" -%include "stdint.i" -%include "typemaps.i" -%include "../java_buffer.i" -%include "../java_exceptions.i" - -%apply uint32_t *OUTPUT { uint32_t *freq, uint32_t *dataRate }; -%apply uint16_t *OUTPUT { uint16_t *rxBandwidth }; -%apply uint8_t *OUTPUT { uint8_t *modulation, uint8_t *txPower }; -%apply uint32_t *OUTPUT { uint32_t *uartBaud }; -%apply uint8_t *OUTPUT { uint8_t *strength }; - -%{ - #include "hmtrp.hpp" - speed_t int_B9600 = B9600; -%} - -%ignore getRFSignalStrength(uint8_t *strength); -READDATA_EXCEPTION(getRFSignalStrength()) - -%ignore getModSignalStrength(uint8_t *strength); -READDATA_EXCEPTION(getModSignalStrength()) - -%include "hmtrp.hpp" -speed_t int_B9600 = B9600; - -JAVA_JNI_LOADLIBRARY(javaupm_hmtrp) diff -Nru upm-1.6.0/src/hmtrp/jsupm_hmtrp.i upm-1.7.1/src/hmtrp/jsupm_hmtrp.i --- upm-1.6.0/src/hmtrp/jsupm_hmtrp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hmtrp/jsupm_hmtrp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module jsupm_hmtrp -%include "../upm.i" -%include "../carrays_uint8_t.i" -%include "../carrays_uint16_t.i" -%include "../carrays_uint32_t.i" - -%{ - #include "hmtrp.hpp" - speed_t int_B9600 = B9600; -%} - -%include "hmtrp.hpp" -speed_t int_B9600 = B9600; -%array_class(char, charArray); diff -Nru upm-1.6.0/src/hmtrp/pyupm_hmtrp.i upm-1.7.1/src/hmtrp/pyupm_hmtrp.i --- upm-1.6.0/src/hmtrp/pyupm_hmtrp.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hmtrp/pyupm_hmtrp.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hmtrp -%include "../upm.i" -%include "../carrays_uint8_t.i" -%include "../carrays_uint16_t.i" -%include "../carrays_uint32_t.i" - -%rename("getModSignalStrengthNoParam") getModSignalStrength(); -%rename("getRFSignalStrengthNoParam") getRFSignalStrength(); - -%include "hmtrp.hpp" -%{ - #include "hmtrp.hpp" - speed_t int_B9600 = B9600; -%} -speed_t int_B9600 = B9600; -%array_class(char, charArray); diff -Nru upm-1.6.0/src/hp20x/hp20x.json upm-1.7.1/src/hp20x/hp20x.json --- upm-1.6.0/src/hp20x/hp20x.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hp20x/hp20x.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "hp20x", - "Description": "API for the HP20X-based Grove Barometer (High-Accuracy)", - "Sensor Class": - { - "HP20X": - { - "Name": "HP20X Barometer (High-Accuracy)", - "Description": "This is a high-accuracy barometer providing pressure, altitude, and temperature data. It can be calibrated for a given altitude offset, and a wide range of interrupt generating capabilities are supported. As usual, see the HP20X datasheet for more details. This module was developed using a Grove Barometer (High-Accuracy) based on an HP206C chip.", - "Aliases": ["hp20x"], - "Categories": ["pressure"], - "Connections": ["i2c"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "hp20x.jpg", - "Examples": - { - "Java": ["HP20xExample.java"], - "Python": ["hp20x.py"], - "Node.js": ["hp20x.js"], - "C++": ["hp20x.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5.5}, - "Operating Current": {"unit": "mA", "low": 0.635, "high": 1.1}, - "Measurement Range": {"unit": "hPa", "low": 300, "high": 1200} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Barometer-HighAccuracy-p-1865.html"], - "Datasheets": ["http://www.seeedstudio.com/wiki/File:HP206C_Datasheet.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "hp20x", + "Description": "API for the HP20X-based Grove Barometer (High-Accuracy)", + "Sensor Class": + { + "HP20X": + { + "Name": "HP20X Barometer (High-Accuracy)", + "Description": "This is a high-accuracy barometer providing pressure, altitude, and temperature data. It can be calibrated for a given altitude offset, and a wide range of interrupt generating capabilities are supported. As usual, see the HP20X datasheet for more details. This module was developed using a Grove Barometer (High-Accuracy) based on an HP206C chip.", + "Aliases": ["hp20x"], + "Categories": ["pressure"], + "Connections": ["i2c"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "hp20x.jpg", + "Examples": + { + "Java": ["HP20x_Example.java"], + "Python": ["hp20x.py"], + "Node.js": ["hp20x.js"], + "C++": ["hp20x.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5.5}, + "Operating Current": {"unit": "mA", "low": 0.635, "high": 1.1}, + "Measurement Range": {"unit": "hPa", "low": 300, "high": 1200} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Barometer-HighAccuracy-p-1865.html"], + "Datasheets": ["http://www.seeedstudio.com/wiki/File:HP206C_Datasheet.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hp20x/javaupm_hp20x.i upm-1.7.1/src/hp20x/javaupm_hp20x.i --- upm-1.6.0/src/hp20x/javaupm_hp20x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hp20x/javaupm_hp20x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_hp20x -%include "../upm.i" - -%{ - #include "hp20x.hpp" -%} - -%include "hp20x.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_hp20x) \ No newline at end of file diff -Nru upm-1.6.0/src/hp20x/jsupm_hp20x.i upm-1.7.1/src/hp20x/jsupm_hp20x.i --- upm-1.6.0/src/hp20x/jsupm_hp20x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hp20x/jsupm_hp20x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_hp20x -%include "../upm.i" - -%{ - #include "hp20x.hpp" -%} - -%include "hp20x.hpp" diff -Nru upm-1.6.0/src/hp20x/pyupm_hp20x.i upm-1.7.1/src/hp20x/pyupm_hp20x.i --- upm-1.6.0/src/hp20x/pyupm_hp20x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hp20x/pyupm_hp20x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hp20x -%include "../upm.i" - -%include "hp20x.hpp" -%{ - #include "hp20x.hpp" -%} diff -Nru upm-1.6.0/src/ht9170/ht9170.json upm-1.7.1/src/ht9170/ht9170.json --- upm-1.6.0/src/ht9170/ht9170.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ht9170/ht9170.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "ht9170", - "Description": "API for the HT9170 DTMF Decoder", - "Sensor Class": - { - "HT9170": - { - "Name": "Dual Tone Multi Frequency (DTMF) Decoder", - "Description": "This driver was developed using the DTMF (Dual-Tone Multi-Frequency) Shield by Seeed Studio*. It can decode DTMF signals presented at its audio input. It does not generate DTMF signals.", - "Aliases": ["ht9170"], - "Categories": ["telephony"], - "Connections": ["gpio"], - "Project Type": ["telephone", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "ht9170.jpg", - "Examples": - { - "Java": [], - "Python": ["ht9170.py"], - "Node.js": ["ht9170.js"], - "C++": ["ht9170.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "typ": 3} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/DTMFDual-Tone-Multi-Frequency-Shield-p-1839.html"], - "Datasheets": ["http://www.holtek.com/pdf/comm/9170v111.pdf"], - "Schematics": ["http://www.dossant.com/projects/wp-content/uploads/2013/01/dtmf_mod3_schematic.pdf"] - } - } - } -} +{ + "Library": "ht9170", + "Description": "API for the HT9170 DTMF Decoder", + "Sensor Class": + { + "HT9170": + { + "Name": "Dual Tone Multi Frequency (DTMF) Decoder", + "Description": "This driver was developed using the DTMF (Dual-Tone Multi-Frequency) Shield by Seeed Studio*. It can decode DTMF signals presented at its audio input. It does not generate DTMF signals.", + "Aliases": ["ht9170"], + "Categories": ["telephony"], + "Connections": ["gpio"], + "Project Type": ["telephone", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "ht9170.jpg", + "Examples": + { + "Java": [], + "Python": ["ht9170.py"], + "Node.js": ["ht9170.js"], + "C++": ["ht9170.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "typ": 3} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/DTMFDual-Tone-Multi-Frequency-Shield-p-1839.html"], + "Datasheets": ["http://www.holtek.com/pdf/comm/9170v111.pdf"], + "Schematics": ["http://www.dossant.com/projects/wp-content/uploads/2013/01/dtmf_mod3_schematic.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/ht9170/javaupm_ht9170.i upm-1.7.1/src/ht9170/javaupm_ht9170.i --- upm-1.6.0/src/ht9170/javaupm_ht9170.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ht9170/javaupm_ht9170.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_ht9170 -%include "../upm.i" - -%{ - #include "ht9170.hpp" -%} - -%include "ht9170.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ht9170) \ No newline at end of file diff -Nru upm-1.6.0/src/ht9170/jsupm_ht9170.i upm-1.7.1/src/ht9170/jsupm_ht9170.i --- upm-1.6.0/src/ht9170/jsupm_ht9170.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ht9170/jsupm_ht9170.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ht9170 -%include "../upm.i" - -%{ - #include "ht9170.hpp" -%} - -%include "ht9170.hpp" diff -Nru upm-1.6.0/src/ht9170/pyupm_ht9170.i upm-1.7.1/src/ht9170/pyupm_ht9170.i --- upm-1.6.0/src/ht9170/pyupm_ht9170.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ht9170/pyupm_ht9170.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ht9170 -%include "../upm.i" - -%include "ht9170.hpp" -%{ - #include "ht9170.hpp" -%} diff -Nru upm-1.6.0/src/htu21d/htu21d.i upm-1.7.1/src/htu21d/htu21d.i --- upm-1.6.0/src/htu21d/htu21d.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/htu21d/htu21d.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore getHumidityData(float*, float*, float*); + +JAVA_JNI_LOADLIBRARY(javaupm_htu21d) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "htu21d.hpp" +%} +%include "htu21d.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/htu21d/htu21d.json upm-1.7.1/src/htu21d/htu21d.json --- upm-1.6.0/src/htu21d/htu21d.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/htu21d/htu21d.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,32 +1,32 @@ -{ - "Library": "htu21d", - "Description": "API for the HTU21D Temperature & Humidity Sensor", - "Sensor Class": - { - "HTU21D": - { - "Name": "Digital Relative Humidity Sensor with Temperature", - "Description": "HTU21D by Measurement Specialties is a digital humidity sensor with temperature output. RH reports between 0 and 100%, and the temperature range is -40 to +125 degC. Note: getCompRH is the preferred function below (passing true to cause a measurement cycle). If actual values used for the compensated ready are necessary, use the getHumidity(false) and getTemperature(false) functions following the getCompRH call. Also note the sensor should not perform more than a couple of measurements per second to limit the heating of the sensor.", - "Aliases": ["htu21d"], - "Categories": ["temperature", "humidity"], - "Connections": ["i2c"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["seeed", "adafruit", "sparkfun"], - "Kits": [], - "Examples": - { - "Java": ["HTU21DSample.java"], - "Python": ["htu21d.py"], - "Node.js": ["htu21d.js"], - "C++": ["htu21d.cxx"], - "C": [] - }, - "Urls" : - { - "Product Pages": [], - "Datasheets": [], - "Schematics": [] - } - } - } -} +{ + "Library": "htu21d", + "Description": "API for the HTU21D Temperature & Humidity Sensor", + "Sensor Class": + { + "HTU21D": + { + "Name": "Digital Relative Humidity Sensor with Temperature", + "Description": "HTU21D by Measurement Specialties is a digital humidity sensor with temperature output. RH reports between 0 and 100%, and the temperature range is -40 to +125 degC. Note: getCompRH is the preferred function below (passing true to cause a measurement cycle). If actual values used for the compensated ready are necessary, use the getHumidity(false) and getTemperature(false) functions following the getCompRH call. Also note the sensor should not perform more than a couple of measurements per second to limit the heating of the sensor.", + "Aliases": ["htu21d"], + "Categories": ["temperature", "humidity"], + "Connections": ["i2c"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["seeed", "adafruit", "sparkfun"], + "Kits": [], + "Examples": + { + "Java": ["HTU21D_Example.java"], + "Python": ["htu21d.py"], + "Node.js": ["htu21d.js"], + "C++": ["htu21d.cxx"], + "C": [] + }, + "Urls" : + { + "Product Pages": [], + "Datasheets": [], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/htu21d/javaupm_htu21d.i upm-1.7.1/src/htu21d/javaupm_htu21d.i --- upm-1.6.0/src/htu21d/javaupm_htu21d.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/htu21d/javaupm_htu21d.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_htu21d -%include "../upm.i" -%include "typemaps.i" - -%ignore getHumidityData(float*, float*, float*); - -%{ - #include "htu21d.hpp" -%} -%include "htu21d.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_htu21d) diff -Nru upm-1.6.0/src/htu21d/jsupm_htu21d.i upm-1.7.1/src/htu21d/jsupm_htu21d.i --- upm-1.6.0/src/htu21d/jsupm_htu21d.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/htu21d/jsupm_htu21d.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_htu21d -%include "../upm.i" - -%{ - #include "htu21d.hpp" -%} - -%include "htu21d.hpp" diff -Nru upm-1.6.0/src/htu21d/pyupm_htu21d.i upm-1.7.1/src/htu21d/pyupm_htu21d.i --- upm-1.6.0/src/htu21d/pyupm_htu21d.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/htu21d/pyupm_htu21d.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_htu21d -%include "../upm.i" - -%include "htu21d.hpp" -%{ - #include "htu21d.hpp" -%} diff -Nru upm-1.6.0/src/hwxpxx/hwxpxx.i upm-1.7.1/src/hwxpxx/hwxpxx.i --- upm-1.6.0/src/hwxpxx/hwxpxx.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/hwxpxx/hwxpxx.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_hwxpxx) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "hwxpxx.hpp" +%} +%include "hwxpxx.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/hwxpxx/hwxpxx.json upm-1.7.1/src/hwxpxx/hwxpxx.json --- upm-1.6.0/src/hwxpxx/hwxpxx.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hwxpxx/hwxpxx.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "hwxpxx", - "Description": "UPM API for the Veris HWXPXX Hardware Protocol Humidity and Temperature Sensor", - "Sensor Class": - { - "HWXPXX": - { - "Name": "Veris HWXPXX Hardware Protocol Humidity and Temperature Sensor", - "Description": "This module implements support for the Veris HWXPHTX Hardware Protocol Humidity and Temperature Sensor family. It uses MODBUS over an RS485 interface. You must have libmodbus v3.1.2 (or greater) installed to compile and use this driver. This module was developed using libmodbus 3.1.2, and the HWXPHTX. This sensor supports humidity, and optionally, temperature, slider switch, and override switch reporting. The HWXPHTX used to develop this driver did not include the optional slider or override switches, however support for them is provided. It was developed using an RS232->RS485 inteface. You cannot use the built in MCU TTL UART pins for accessing this device -- you must use a full serial RS232->RS485 interface connected via USB.", - "Aliases": ["hwxpxx"], - "Categories": ["temperature"], - "Connections": ["uart"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["veris"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": ["hwxpxx.py"], - "Node.js": ["hwxpxx.js"], - "C++": ["hwxpxx.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage (DC)": {"unit": "V", "low": 12, "high": 30}, - "Operating Voltage (AC)": {"unit": "VAC", "typ": 24}, - "Operating Current": {"unit": "mA", "max": 100}, - "Operating Range (RH)": {"unit": "%RH", "low": 0, "high": 100}, - "Operating Range (Temp)": {"unit": "degC", "low": 10, "high": 35} - }, - "Urls" : - { - "Product Pages": ["http://www.veris.com/Item/HWXPHTX.aspx"], - "Datasheets": ["http://www.veris.com/docs/Datasheets/HWProtocol_d0117.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "hwxpxx", + "Description": "UPM API for the Veris HWXPXX Hardware Protocol Humidity and Temperature Sensor", + "Sensor Class": + { + "HWXPXX": + { + "Name": "Veris HWXPXX Hardware Protocol Humidity and Temperature Sensor", + "Description": "This module implements support for the Veris HWXPHTX Hardware Protocol Humidity and Temperature Sensor family. It uses MODBUS over an RS485 interface. You must have libmodbus v3.1.2 (or greater) installed to compile and use this driver. This module was developed using libmodbus 3.1.2, and the HWXPHTX. This sensor supports humidity, and optionally, temperature, slider switch, and override switch reporting. The HWXPHTX used to develop this driver did not include the optional slider or override switches, however support for them is provided. It was developed using an RS232->RS485 inteface. You cannot use the built in MCU TTL UART pins for accessing this device -- you must use a full serial RS232->RS485 interface connected via USB.", + "Aliases": ["hwxpxx"], + "Categories": ["temperature"], + "Connections": ["uart"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["veris"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": ["hwxpxx.py"], + "Node.js": ["hwxpxx.js"], + "C++": ["hwxpxx.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage (DC)": {"unit": "V", "low": 12, "high": 30}, + "Operating Voltage (AC)": {"unit": "VAC", "typ": 24}, + "Operating Current": {"unit": "mA", "max": 100}, + "Operating Range (RH)": {"unit": "%RH", "low": 0, "high": 100}, + "Operating Range (Temp)": {"unit": "degC", "low": 10, "high": 35} + }, + "Urls" : + { + "Product Pages": ["http://www.veris.com/Item/HWXPHTX.aspx"], + "Datasheets": ["http://www.veris.com/docs/Datasheets/HWProtocol_d0117.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hwxpxx/javaupm_hwxpxx.i upm-1.7.1/src/hwxpxx/javaupm_hwxpxx.i --- upm-1.6.0/src/hwxpxx/javaupm_hwxpxx.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hwxpxx/javaupm_hwxpxx.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_hwxpxx -%include "../upm.i" -%include "typemaps.i" - -%{ - #include "hwxpxx.hpp" -%} - -%include "hwxpxx.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_hwxpxx) diff -Nru upm-1.6.0/src/hwxpxx/jsupm_hwxpxx.i upm-1.7.1/src/hwxpxx/jsupm_hwxpxx.i --- upm-1.6.0/src/hwxpxx/jsupm_hwxpxx.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hwxpxx/jsupm_hwxpxx.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_hwxpxx -%include "../upm.i" -%include "stdint.i" - -%include "hwxpxx.hpp" -%{ - #include "hwxpxx.hpp" -%} diff -Nru upm-1.6.0/src/hwxpxx/pyupm_hwxpxx.i upm-1.7.1/src/hwxpxx/pyupm_hwxpxx.i --- upm-1.6.0/src/hwxpxx/pyupm_hwxpxx.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hwxpxx/pyupm_hwxpxx.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hwxpxx -%include "../upm.i" -%include "stdint.i" - -%include "hwxpxx.hpp" -%{ - #include "hwxpxx.hpp" -%} diff -Nru upm-1.6.0/src/hx711/hx711.i upm-1.7.1/src/hx711/hx711.i --- upm-1.6.0/src/hx711/hx711.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/hx711/hx711.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_hx711) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "hx711.hpp" +%} +%include "hx711.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/hx711/hx711.json upm-1.7.1/src/hx711/hx711.json --- upm-1.6.0/src/hx711/hx711.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hx711/hx711.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "hx711", - "Description": "API for the HX711 Analog-to-Digital Converter", - "Sensor Class": - { - "HX711": - { - "Name": "24-bit Analog-to-digital Converter", - "Description": "HX711 is a precision 24-bit analog-to-digital converter (ADC) designed for weight scales and industrial control applications to interface directly with a bridge sensor. This module was tested on the Intel(R) Galileo Gen 2 board.", - "Aliases": ["hx711"], - "Categories": ["adc"], - "Connections": ["gpio"], - "Project Type": ["prototyping"], - "Manufacturers": ["generic"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": ["hx711.js"], - "C++": ["hx711.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5}, - "Operating Current": {"unit": "mA", "max": 1.4} - }, - "Urls" : - { - "Product Pages": [], - "Datasheets": ["http://image.dfrobot.com/image/data/SEN0160/hx711_english.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "hx711", + "Description": "API for the HX711 Analog-to-Digital Converter", + "Sensor Class": + { + "HX711": + { + "Name": "24-bit Analog-to-digital Converter", + "Description": "HX711 is a precision 24-bit analog-to-digital converter (ADC) designed for weight scales and industrial control applications to interface directly with a bridge sensor. This module was tested on the Intel(R) Galileo Gen 2 board.", + "Aliases": ["hx711"], + "Categories": ["adc"], + "Connections": ["gpio"], + "Project Type": ["prototyping"], + "Manufacturers": ["generic"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": ["hx711.js"], + "C++": ["hx711.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5}, + "Operating Current": {"unit": "mA", "max": 1.4} + }, + "Urls" : + { + "Product Pages": [], + "Datasheets": ["http://image.dfrobot.com/image/data/SEN0160/hx711_english.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/hx711/javaupm_hx711.i upm-1.7.1/src/hx711/javaupm_hx711.i --- upm-1.6.0/src/hx711/javaupm_hx711.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hx711/javaupm_hx711.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_hx711 -%include "../upm.i" - -%{ - #include "hx711.hpp" -%} - -%include "hx711.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_hx711) \ No newline at end of file diff -Nru upm-1.6.0/src/hx711/jsupm_hx711.i upm-1.7.1/src/hx711/jsupm_hx711.i --- upm-1.6.0/src/hx711/jsupm_hx711.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hx711/jsupm_hx711.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_hx711 -%include "../upm.i" - -%{ - #include "hx711.hpp" -%} - -%include "hx711.hpp" diff -Nru upm-1.6.0/src/hx711/pyupm_hx711.i upm-1.7.1/src/hx711/pyupm_hx711.i --- upm-1.6.0/src/hx711/pyupm_hx711.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/hx711/pyupm_hx711.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_hx711 -%include "../upm.i" -%include "stdint.i" - -%include "hx711.hpp" -%{ - #include "hx711.hpp" -%} diff -Nru upm-1.6.0/src/ili9341/ili9341.i upm-1.7.1/src/ili9341/ili9341.i --- upm-1.6.0/src/ili9341/ili9341.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ili9341/ili9341.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%apply uint8_t *INPUT { uint8_t *addr } + +JAVA_JNI_LOADLIBRARY(javaupm_ili9341) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ili9341_gfx.hpp" +#include "ili9341.hpp" +%} +%include "ili9341_gfx.hpp" +%include "ili9341.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ili9341/ili9341.json upm-1.7.1/src/ili9341/ili9341.json --- upm-1.6.0/src/ili9341/ili9341.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ili9341/ili9341.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "ili9341", - "Description": "API for the ILI9342 LCD", - "Sensor Class": - { - "ILI9341": - { - "Name": "SPI Based LCD", - "Description": "This module defines the interface for the ILI9341 display library.", - "Aliases": ["ili9341"], - "Categories": ["display"], - "Connections": ["spi"], - "Project Type": ["graphics", "prototyping"], - "Manufacturers": ["adafruit"], - "Kits": [], - "Image": "ili9341.jpg", - "Examples": - { - "Java": [], - "Python": ["ili9341.py"], - "Node.js": ["ili9341.js"], - "C++": ["ili9341.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3, "high": 5} - - }, - "Urls" : - { - "Product Pages": ["https://www.adafruit.com/product/2090"], - "Datasheets": ["http://www.adafruit.com/datasheets/ILI9341.pdf"], - "Schematics": ["https://cdn-learn.adafruit.com/assets/assets/000/015/463/medium800/adafruit_products_schem.png?1395173896"] - } - } - } -} +{ + "Library": "ili9341", + "Description": "API for the ILI9342 LCD", + "Sensor Class": + { + "ILI9341": + { + "Name": "SPI Based LCD", + "Description": "This module defines the interface for the ILI9341 display library.", + "Aliases": ["ili9341"], + "Categories": ["display"], + "Connections": ["spi"], + "Project Type": ["graphics", "prototyping"], + "Manufacturers": ["adafruit"], + "Kits": [], + "Image": "ili9341.jpg", + "Examples": + { + "Java": [], + "Python": ["ili9341.py"], + "Node.js": ["ili9341.js"], + "C++": ["ili9341.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3, "high": 5} + + }, + "Urls" : + { + "Product Pages": ["https://www.adafruit.com/product/2090"], + "Datasheets": ["http://www.adafruit.com/datasheets/ILI9341.pdf"], + "Schematics": ["https://cdn-learn.adafruit.com/assets/assets/000/015/463/medium800/adafruit_products_schem.png?1395173896"] + } + } + } +} diff -Nru upm-1.6.0/src/ili9341/javaupm_ili9341.i upm-1.7.1/src/ili9341/javaupm_ili9341.i --- upm-1.6.0/src/ili9341/javaupm_ili9341.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ili9341/javaupm_ili9341.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -%module javaupm_ili9341 -%include "../upm.i" -%include "stdint.i" -%include "typemaps.i" - -%apply uint8_t *INPUT { uint8_t *addr } - -%include "ili9341_gfx.hpp" -%{ - #include "ili9341_gfx.hpp" -%} - -%{ - #include "ili9341.hpp" -%} - -%include "ili9341.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ili9341) \ No newline at end of file diff -Nru upm-1.6.0/src/ili9341/jsupm_ili9341.i upm-1.7.1/src/ili9341/jsupm_ili9341.i --- upm-1.6.0/src/ili9341/jsupm_ili9341.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ili9341/jsupm_ili9341.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module jsupm_ili9341 -%include "../upm.i" - -%include "ili9341_gfx.hpp" -%{ - #include "ili9341_gfx.hpp" -%} - -%include "ili9341.hpp" -%{ - #include "ili9341.hpp" -%} diff -Nru upm-1.6.0/src/ili9341/pyupm_ili9341.i upm-1.7.1/src/ili9341/pyupm_ili9341.i --- upm-1.6.0/src/ili9341/pyupm_ili9341.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ili9341/pyupm_ili9341.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ili9341 -%include "../upm.i" - -%include "ili9341_gfx.hpp" -%{ - #include "ili9341_gfx.hpp" -%} - -%include "ili9341.hpp" -%{ - #include "ili9341.hpp" -%} diff -Nru upm-1.6.0/src/ims/ims.i upm-1.7.1/src/ims/ims.i --- upm-1.6.0/src/ims/ims.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ims/ims.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_ims) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ims_defs.h" +#include "ims.hpp" +%} +%include "ims_defs.h" +%include "ims.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ims/ims.json upm-1.7.1/src/ims/ims.json --- upm-1.6.0/src/ims/ims.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ims/ims.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "ims", - "Description": "API for the Catnip Electronics I2C Moisture Sensor", - "Sensor Class": - { - "IMS": - { - "Name": "I2C Moisture Sensor", - "Description": "I2C Sensor which can be used to read moisture, light, and temperature which must run at 100kHz.", - "Aliases": ["ims"], - "Categories": ["moisture"], - "Connections": ["i2c"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["catnip"], - "Kits": [], - "Examples": - { - "Java": ["IMS_Example.java"], - "Python": ["ims.py"], - "Node.js": ["ims.js"], - "C++": ["ims.cxx"], - "C": ["ims.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "low": 0.7, "high": 14}, - "Operating Temperature": {"unit": "degC", "low": 0, "high": 85} - - }, - "Urls" : - { - "Product Pages": ["https://www.tindie.com/products/miceuz/i2c-soil-moisture-sensor/"], - "Datasheets": [], - "Schematics": [] - } - } - } -} +{ + "Library": "ims", + "Description": "API for the Catnip Electronics I2C Moisture Sensor", + "Sensor Class": + { + "IMS": + { + "Name": "I2C Moisture Sensor", + "Description": "I2C Sensor which can be used to read moisture, light, and temperature which must run at 100kHz.", + "Aliases": ["ims"], + "Categories": ["moisture"], + "Connections": ["i2c"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["catnip"], + "Kits": [], + "Examples": + { + "Java": ["IMS_Example.java"], + "Python": ["ims.py"], + "Node.js": ["ims.js"], + "C++": ["ims.cxx"], + "C": ["ims.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "mA", "low": 0.7, "high": 14}, + "Operating Temperature": {"unit": "degC", "low": 0, "high": 85} + + }, + "Urls" : + { + "Product Pages": ["https://www.tindie.com/products/miceuz/i2c-soil-moisture-sensor/"], + "Datasheets": [], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/ims/javaupm_ims.i upm-1.7.1/src/ims/javaupm_ims.i --- upm-1.6.0/src/ims/javaupm_ims.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ims/javaupm_ims.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_ims -%include "../upm.i" - -%{ - #include "ims.hpp" -%} - -%include "ims_defs.h" -%include "ims.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ims) diff -Nru upm-1.6.0/src/ims/jsupm_ims.i upm-1.7.1/src/ims/jsupm_ims.i --- upm-1.6.0/src/ims/jsupm_ims.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ims/jsupm_ims.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_ims -%include "../upm.i" - -%{ - #include "ims.hpp" -%} - -%include "ims_defs.h" -%include "ims.hpp" diff -Nru upm-1.6.0/src/ims/pyupm_ims.i upm-1.7.1/src/ims/pyupm_ims.i --- upm-1.6.0/src/ims/pyupm_ims.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ims/pyupm_ims.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ims -%include "../upm.i" - -%{ - #include "ims.hpp" -%} - -%include "ims_defs.h" -%include "ims.hpp" diff -Nru upm-1.6.0/src/ina132/ina132.json upm-1.7.1/src/ina132/ina132.json --- upm-1.6.0/src/ina132/ina132.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ina132/ina132.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "ina132", - "Description": "API for the INA132 Differential Amplifier Sensor", - "Sensor Class": - { - "INA132": - { - "Name": "Grove Differential Amplifier", - "Description": "The INA132 Differential Amplifier Sensor is designed for precise differential-input amplification. This sensor was tested amplifying the signal from a Weight Sensor (Load Cell) 0-500g", - "Aliases": ["ina132"], - "Categories": ["electric"], - "Connections": ["analog"], - "Project Type": ["prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "ina132.jpg", - "Examples": - { - "Java": [], - "Python": ["ina132.py"], - "Node.js": ["ina132.js"], - "C++": ["ina132.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Differential-Amplifier-p-1284.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Differential_Amplifier_v1.2", "https://raw.githubusercontent.com/SeeedDocument/Grove-Differential_Amplifier_v1.2/master/res/Ina132.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "ina132", + "Description": "API for the INA132 Differential Amplifier Sensor", + "Sensor Class": + { + "INA132": + { + "Name": "Grove Differential Amplifier", + "Description": "The INA132 Differential Amplifier Sensor is designed for precise differential-input amplification. This sensor was tested amplifying the signal from a Weight Sensor (Load Cell) 0-500g", + "Aliases": ["ina132"], + "Categories": ["electric"], + "Connections": ["analog"], + "Project Type": ["prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "ina132.jpg", + "Examples": + { + "Java": [], + "Python": ["ina132.py"], + "Node.js": ["ina132.js"], + "C++": ["ina132.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Differential-Amplifier-p-1284.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Differential_Amplifier_v1.2", "https://raw.githubusercontent.com/SeeedDocument/Grove-Differential_Amplifier_v1.2/master/res/Ina132.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/ina132/javaupm_ina132.i upm-1.7.1/src/ina132/javaupm_ina132.i --- upm-1.6.0/src/ina132/javaupm_ina132.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ina132/javaupm_ina132.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_ina132 -%include "../upm.i" - -%{ - #include "ina132.hpp" -%} - -%include "ina132.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ina132) \ No newline at end of file diff -Nru upm-1.6.0/src/ina132/jsupm_ina132.i upm-1.7.1/src/ina132/jsupm_ina132.i --- upm-1.6.0/src/ina132/jsupm_ina132.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ina132/jsupm_ina132.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ina132 -%include "../upm.i" - -%{ - #include "ina132.hpp" -%} - -%include "ina132.hpp" diff -Nru upm-1.6.0/src/ina132/pyupm_ina132.i upm-1.7.1/src/ina132/pyupm_ina132.i --- upm-1.6.0/src/ina132/pyupm_ina132.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ina132/pyupm_ina132.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ina132 -%include "../upm.i" - -%include "ina132.hpp" -%{ - #include "ina132.hpp" -%} diff -Nru upm-1.6.0/src/interfaces/interfaces.i upm-1.7.1/src/interfaces/interfaces.i --- upm-1.6.0/src/interfaces/interfaces.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/interfaces/interfaces.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%import "../_upm.i" + +%include javaupm_iModuleStatus.i +%include javaupm_iADC.i +%include javaupm_iCO2Sensor.i +%include javaupm_iHumiditySensor.i +%include javaupm_iLightController.i +%include javaupm_iLightSensor.i +%include javaupm_iPressureSensor.i +%include javaupm_iTemperatureSensor.i + +JAVA_JNI_LOADLIBRARY(javaupm_interfaces) +#endif +/* END Java syntax */ diff -Nru upm-1.6.0/src/interfaces/javaupm_iADC.i upm-1.7.1/src/interfaces/javaupm_iADC.i --- upm-1.6.0/src/interfaces/javaupm_iADC.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/javaupm_iADC.i 2018-10-12 04:47:41.000000000 +0000 @@ -2,11 +2,10 @@ %include %interface_impl(upm::IADC); #endif - -%include "javaupm_interfaces.i" +%include "interfaces.i" %include "javaupm_iModuleStatus.i" %include "iADC.hpp" %{ #include "iADC.hpp" -%} \ No newline at end of file +%} diff -Nru upm-1.6.0/src/interfaces/javaupm_iCO2Sensor.i upm-1.7.1/src/interfaces/javaupm_iCO2Sensor.i --- upm-1.6.0/src/interfaces/javaupm_iCO2Sensor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/javaupm_iCO2Sensor.i 2018-10-12 04:47:41.000000000 +0000 @@ -2,12 +2,11 @@ %include %interface_impl(upm::ICO2Sensor); #endif - %include "stdint.i" -%include "javaupm_interfaces.i" +%include "interfaces.i" %include "javaupm_iModuleStatus.i" %include "iCO2Sensor.hpp" %{ #include "iCO2Sensor.hpp" -%} \ No newline at end of file +%} diff -Nru upm-1.6.0/src/interfaces/javaupm_iHumiditySensor.i upm-1.7.1/src/interfaces/javaupm_iHumiditySensor.i --- upm-1.6.0/src/interfaces/javaupm_iHumiditySensor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/javaupm_iHumiditySensor.i 2018-10-12 04:47:41.000000000 +0000 @@ -2,11 +2,10 @@ %include %interface_impl(upm::IHumiditySensor); #endif - -%include "javaupm_interfaces.i" +%include "interfaces.i" %include "javaupm_iModuleStatus.i" %include "iHumiditySensor.hpp" %{ #include "iHumiditySensor.hpp" -%} \ No newline at end of file +%} diff -Nru upm-1.6.0/src/interfaces/javaupm_iLightController.i upm-1.7.1/src/interfaces/javaupm_iLightController.i --- upm-1.6.0/src/interfaces/javaupm_iLightController.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/javaupm_iLightController.i 2018-10-12 04:47:41.000000000 +0000 @@ -2,11 +2,10 @@ %include %interface_impl(upm::ILightController); #endif - -%include "javaupm_interfaces.i" +%include "interfaces.i" %include "javaupm_iModuleStatus.i" -%include "iLightController.hpp" %{ - #include "iLightController.hpp" -%} \ No newline at end of file +#include "iLightController.hpp" +%} +%include "iLightController.hpp" diff -Nru upm-1.6.0/src/interfaces/javaupm_iLightSensor.i upm-1.7.1/src/interfaces/javaupm_iLightSensor.i --- upm-1.6.0/src/interfaces/javaupm_iLightSensor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/javaupm_iLightSensor.i 2018-10-12 04:47:41.000000000 +0000 @@ -2,11 +2,10 @@ %include %interface_impl(upm::ILightSensor); #endif - -%include "javaupm_interfaces.i" +%include "interfaces.i" %include "javaupm_iModuleStatus.i" %include "iLightSensor.hpp" %{ #include "iLightSensor.hpp" -%} \ No newline at end of file +%} diff -Nru upm-1.6.0/src/interfaces/javaupm_iModuleStatus.i upm-1.7.1/src/interfaces/javaupm_iModuleStatus.i --- upm-1.6.0/src/interfaces/javaupm_iModuleStatus.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/javaupm_iModuleStatus.i 2018-10-12 04:47:41.000000000 +0000 @@ -2,7 +2,6 @@ %include %interface_impl(upm::IModuleStatus); #endif - %include "iModuleStatus.hpp" %{ #include "iModuleStatus.hpp" diff -Nru upm-1.6.0/src/interfaces/javaupm_interfaces.i upm-1.7.1/src/interfaces/javaupm_interfaces.i --- upm-1.6.0/src/interfaces/javaupm_interfaces.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/javaupm_interfaces.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module javaupm_interfaces - -%import "../_upm.i" - -%include javaupm_iModuleStatus.i -%include javaupm_iADC.i -%include javaupm_iCO2Sensor.i -%include javaupm_iHumiditySensor.i -%include javaupm_iLightController.i -%include javaupm_iLightSensor.i -%include javaupm_iPressureSensor.i -%include javaupm_iTemperatureSensor.i - -JAVA_JNI_LOADLIBRARY(javaupm_interfaces) diff -Nru upm-1.6.0/src/interfaces/javaupm_iPressureSensor.i upm-1.7.1/src/interfaces/javaupm_iPressureSensor.i --- upm-1.6.0/src/interfaces/javaupm_iPressureSensor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/javaupm_iPressureSensor.i 2018-10-12 04:47:41.000000000 +0000 @@ -2,11 +2,10 @@ %include %interface_impl(upm::IPressureSensor); #endif - -%include "javaupm_interfaces.i" +%include "interfaces.i" %include "javaupm_iModuleStatus.i" %include "iPressureSensor.hpp" %{ #include "iPressureSensor.hpp" -%} \ No newline at end of file +%} diff -Nru upm-1.6.0/src/interfaces/javaupm_iTemperatureSensor.i upm-1.7.1/src/interfaces/javaupm_iTemperatureSensor.i --- upm-1.6.0/src/interfaces/javaupm_iTemperatureSensor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/javaupm_iTemperatureSensor.i 2018-10-12 04:47:41.000000000 +0000 @@ -2,11 +2,10 @@ %include %interface_impl(upm::ITemperatureSensor); #endif - -%include "javaupm_interfaces.i" +%include "interfaces.i" %include "javaupm_iModuleStatus.i" %include "iTemperatureSensor.hpp" %{ #include "iTemperatureSensor.hpp" -%} \ No newline at end of file +%} diff -Nru upm-1.6.0/src/interfaces/jsupm_interfaces.i upm-1.7.1/src/interfaces/jsupm_interfaces.i --- upm-1.6.0/src/interfaces/jsupm_interfaces.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/jsupm_interfaces.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module jsupm_interfaces -/* -%include "../upm.i" - -%{ - #include "iLightSensor.hpp" - #include "iLightController.hpp" -%} - -%include "iModuleStatus.hpp" -%include "iLightSensor.hpp" -%include "iLightController.hpp" -*/ diff -Nru upm-1.6.0/src/interfaces/pyupm_interfaces.i upm-1.7.1/src/interfaces/pyupm_interfaces.i --- upm-1.6.0/src/interfaces/pyupm_interfaces.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/interfaces/pyupm_interfaces.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -%module pyupm_interfaces -/* -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%{ - #include "iLightSensor.hpp" - #include "iLightController.hpp" -%} - -%include "iModuleStatus.hpp" -%include "iLightSensor.hpp" -%include "iLightController.hpp" -*/ diff -Nru upm-1.6.0/src/isd1820/isd1820.json upm-1.7.1/src/isd1820/isd1820.json --- upm-1.6.0/src/isd1820/isd1820.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/isd1820/isd1820.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,33 +1,33 @@ -{ - "Library": "isd1820", - "Description": "API support for the ISD1820-based Grove Voice Recorder", - "Sensor Class": - { - "ISD1820": - { - "Name": "Grove Voice Recording and Playback Module", - "Description": "This class implements support for the Grove Voice Recorder. There are two digital pins: one that enables recording, and the other that plays back what was previously recorded.", - "Aliases": ["isd1820"], - "Categories": ["audio"], - "Connections": ["gpio"], - "Project Type": ["audio", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "isd1820.jpg", - "Examples": - { - "Java": [], - "Python": ["isd1820.py"], - "Node.js": ["isd1820.js"], - "C++": ["isd1820.cxx"], - "C": [] - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Recorder-p-1825.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove_Recorder/", "https://github.com/SeeedDocument/Grove_Recorder/raw/master/res/ISD1820P.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "isd1820", + "Description": "API support for the ISD1820-based Grove Voice Recorder", + "Sensor Class": + { + "ISD1820": + { + "Name": "Grove Voice Recording and Playback Module", + "Description": "This class implements support for the Grove Voice Recorder. There are two digital pins: one that enables recording, and the other that plays back what was previously recorded.", + "Aliases": ["isd1820"], + "Categories": ["audio"], + "Connections": ["gpio"], + "Project Type": ["audio", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "isd1820.jpg", + "Examples": + { + "Java": [], + "Python": ["isd1820.py"], + "Node.js": ["isd1820.js"], + "C++": ["isd1820.cxx"], + "C": [] + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Recorder-p-1825.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove_Recorder/", "https://github.com/SeeedDocument/Grove_Recorder/raw/master/res/ISD1820P.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/isd1820/javaupm_isd1820.i upm-1.7.1/src/isd1820/javaupm_isd1820.i --- upm-1.6.0/src/isd1820/javaupm_isd1820.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/isd1820/javaupm_isd1820.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_isd1820 -%include "../upm.i" - -%{ - #include "isd1820.hpp" -%} - -%include "isd1820.hpp" - - -JAVA_JNI_LOADLIBRARY(javaupm_isd1820) \ No newline at end of file diff -Nru upm-1.6.0/src/isd1820/jsupm_isd1820.i upm-1.7.1/src/isd1820/jsupm_isd1820.i --- upm-1.6.0/src/isd1820/jsupm_isd1820.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/isd1820/jsupm_isd1820.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_isd1820 -%include "../upm.i" - -%{ - #include "isd1820.hpp" -%} - -%include "isd1820.hpp" - diff -Nru upm-1.6.0/src/isd1820/pyupm_isd1820.i upm-1.7.1/src/isd1820/pyupm_isd1820.i --- upm-1.6.0/src/isd1820/pyupm_isd1820.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/isd1820/pyupm_isd1820.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_isd1820 -%include "../upm.i" - -%{ - #include "isd1820.hpp" -%} - -%include "isd1820.hpp" - diff -Nru upm-1.6.0/src/itg3200/itg3200.i upm-1.7.1/src/itg3200/itg3200.i --- upm-1.6.0/src/itg3200/itg3200.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/itg3200/itg3200.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,72 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%typemap(jni) float* "jfloatArray" +%typemap(jstype) float* "float[]" +%typemap(jtype) float* "float[]" + +%typemap(javaout) float* { + return $jnicall; +} + +%typemap(out) float *getRotation { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); +} + +%typemap(jni) int16_t* "jshortArray" +%typemap(jstype) int16_t* "short[]" +%typemap(jtype) int16_t* "short[]" + +%typemap(javaout) int16_t* { + return $jnicall; +} + +%typemap(out) int16_t *getRawValues { + $result = JCALL1(NewShortArray, jenv, 3); + JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); +} + +JAVA_JNI_LOADLIBRARY(javaupm_itg3200) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_int16_t.i" +%include "../carrays_float.i" + +%typemap(out) int16_t * { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} + +%typemap(out) float * { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 ); +} + +%include +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_int16_t.i" +%include "../carrays_float.i" + +%typemap(out) int16_t * { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} + +%typemap(out) float * { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 ); +} +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "itg3200.hpp" +%} +%include "itg3200.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/itg3200/itg3200.json upm-1.7.1/src/itg3200/itg3200.json --- upm-1.6.0/src/itg3200/itg3200.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/itg3200/itg3200.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "itg3200", - "Description": "API for the ITG-3200 3-Axis Digital Gyroscope", - "Sensor Class": - { - "Itg3200": - { - "Name": "Grove 3-Axis Digital Gyroscope", - "Description": "InvenSense* ITG-3200 is a 3-axis digital gyroscope. (https://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf) This sensor has been tested and can run at either 3.3V or 5V on Intel(R) Galileo.
However, it is incompatible with and not detected on the I2C bus by Intel(R) Edison using the Arduino* breakout board.", - "Aliases": ["itg3200"], - "Categories": ["gyroscope"], - "Connections": ["i2c"], - "Project Type": ["IMU", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Examples": - { - "Java": ["Itg3200Sample.java"], - "Python": ["itg3200.py"], - "Node.js": ["itg3200.js"], - "C++": ["itg3200.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "typ": 6.5}, - "Standby Current": {"unit": "uA", "typ": 5} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-3-Axis-Digital-Gyro-p-750.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-3-Axis_Digital_Gyro/", "https://raw.githubusercontent.com/SeeedDocument/Grove-3-Axis_Digital_Gyro/master/res/ITG-3200.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "itg3200", + "Description": "API for the ITG-3200 3-Axis Digital Gyroscope", + "Sensor Class": + { + "Itg3200": + { + "Name": "Grove 3-Axis Digital Gyroscope", + "Description": "InvenSense* ITG-3200 is a 3-axis digital gyroscope. (https://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf) This sensor has been tested and can run at either 3.3V or 5V on Intel(R) Galileo.
However, it is incompatible with and not detected on the I2C bus by Intel(R) Edison using the Arduino* breakout board.", + "Aliases": ["itg3200"], + "Categories": ["gyroscope"], + "Connections": ["i2c"], + "Project Type": ["IMU", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Examples": + { + "Java": ["Itg3200_Example.java"], + "Python": ["itg3200.py"], + "Node.js": ["itg3200.js"], + "C++": ["itg3200.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Operating Current": {"unit": "mA", "typ": 6.5}, + "Standby Current": {"unit": "uA", "typ": 5} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-3-Axis-Digital-Gyro-p-750.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-3-Axis_Digital_Gyro/", "https://raw.githubusercontent.com/SeeedDocument/Grove-3-Axis_Digital_Gyro/master/res/ITG-3200.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/itg3200/javaupm_itg3200.i upm-1.7.1/src/itg3200/javaupm_itg3200.i --- upm-1.6.0/src/itg3200/javaupm_itg3200.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/itg3200/javaupm_itg3200.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -%module javaupm_itg3200 -%include "../upm.i" - -%{ - #include "itg3200.hpp" -%} - -%typemap(jni) float* "jfloatArray" -%typemap(jstype) float* "float[]" -%typemap(jtype) float* "float[]" - -%typemap(javaout) float* { - return $jnicall; -} - -%typemap(out) float *getRotation { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); -} - - -%typemap(jni) int16_t* "jshortArray" -%typemap(jstype) int16_t* "short[]" -%typemap(jtype) int16_t* "short[]" - -%typemap(javaout) int16_t* { - return $jnicall; -} - -%typemap(out) int16_t *getRawValues { - $result = JCALL1(NewShortArray, jenv, 3); - JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); -} - -%include "itg3200.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_itg3200) \ No newline at end of file diff -Nru upm-1.6.0/src/itg3200/jsupm_itg3200.i upm-1.7.1/src/itg3200/jsupm_itg3200.i --- upm-1.6.0/src/itg3200/jsupm_itg3200.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/itg3200/jsupm_itg3200.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -%module jsupm_itg3200 -%include "../upm.i" -%include "../carrays_int16_t.i" -%include "../carrays_float.i" - -%{ - #include "itg3200.hpp" -%} - -%typemap(out) int16_t * { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%typemap(out) float * { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 ); -} - -%include "itg3200.hpp" - -%include diff -Nru upm-1.6.0/src/itg3200/pyupm_itg3200.i upm-1.7.1/src/itg3200/pyupm_itg3200.i --- upm-1.6.0/src/itg3200/pyupm_itg3200.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/itg3200/pyupm_itg3200.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_itg3200 -%include "../upm.i" -%include "../carrays_int16_t.i" -%include "../carrays_float.i" - -%typemap(out) int16_t * { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%typemap(out) float * { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 ); -} - -%include "itg3200.hpp" -%{ - #include "itg3200.hpp" -%} diff -Nru upm-1.6.0/src/jhd1313m1/javaupm_jhd1313m1.i upm-1.7.1/src/jhd1313m1/javaupm_jhd1313m1.i --- upm-1.6.0/src/jhd1313m1/javaupm_jhd1313m1.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/jhd1313m1/javaupm_jhd1313m1.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module javaupm_jhd1313m1 -%include "../upm.i" -%include "typemaps.i" -%include "std_vector.i" -%include "stdint.i" - -%template(byteVector) std::vector; - -%include "jhd1313m1.hpp" -%{ - #include "jhd1313m1.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_jhd1313m1) diff -Nru upm-1.6.0/src/jhd1313m1/jhd1313m1.i upm-1.7.1/src/jhd1313m1/jhd1313m1.i --- upm-1.6.0/src/jhd1313m1/jhd1313m1.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/jhd1313m1/jhd1313m1.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,29 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "std_vector.i" +%template(byteVector) std::vector; + +JAVA_JNI_LOADLIBRARY(javaupm_jhd1313m1) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "jhd1313m1.hpp" +%} +%include "jhd1313m1.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/jhd1313m1/jhd1313m1.json upm-1.7.1/src/jhd1313m1/jhd1313m1.json --- upm-1.6.0/src/jhd1313m1/jhd1313m1.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/jhd1313m1/jhd1313m1.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "jhd1313m1", - "Description": "API for the JHD1313M1 I2C LCD Controller", - "Sensor Class": - { - "Jhd1313m1": - { - "Name": "LCD Display Driver for the JHD1313M1 Controller for HD44780-based Displays", - "Description": "JHD1313M1 has two I2C addreses: one belongs to a controller, very similar to the upm::Lcm1602 LCD driver, that controls the HD44780-based display, and the other controls only the backlight. This module was tested with the Seeed Grove LCD RGB Backlight v2.0 display that requires 5V to operate.", - "Aliases": ["jhd1313m1"], - "Categories": ["display"], - "Connections": ["i2c"], - "Project Type": ["display", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["gsk"], - "Examples": - { - "Java": ["Jhd1313m1Sample.java", "Jhd1313m1_lcdSample.java"], - "Python": ["jhd1313m1-lcd.py"], - "Node.js": ["jhd1313m1-lcd.js"], - "C++": ["jhd1313m1-lcd.cxx"], - "C": ["jhd1313m1.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "max": 60} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-LCD-RGB-Backlight-p-1643.html?cPath=34_36"], - "Datasheets": ["http://wiki.seeed.cc/Grove-LCD_RGB_Backlight/"], - "Schematics": [] - } - } - } -} +{ + "Library": "jhd1313m1", + "Description": "API for the JHD1313M1 I2C LCD Controller", + "Sensor Class": + { + "Jhd1313m1": + { + "Name": "LCD Display Driver for the JHD1313M1 Controller for HD44780-based Displays", + "Description": "JHD1313M1 has two I2C addreses: one belongs to a controller, very similar to the upm::Lcm1602 LCD driver, that controls the HD44780-based display, and the other controls only the backlight. This module was tested with the Seeed Grove LCD RGB Backlight v2.0 display that requires 5V to operate.", + "Aliases": ["jhd1313m1"], + "Categories": ["display"], + "Connections": ["i2c"], + "Project Type": ["display", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": ["gsk"], + "Examples": + { + "Java": ["Jhd1313m1_Example.java", "Jhd1313m1_lcd_Example.java"], + "Python": ["jhd1313m1-lcd.py"], + "Node.js": ["jhd1313m1-lcd.js"], + "C++": ["jhd1313m1-lcd.cxx"], + "C": ["jhd1313m1.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "max": 60} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-LCD-RGB-Backlight-p-1643.html?cPath=34_36"], + "Datasheets": ["http://wiki.seeed.cc/Grove-LCD_RGB_Backlight/"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/jhd1313m1/jsupm_jhd1313m1.i upm-1.7.1/src/jhd1313m1/jsupm_jhd1313m1.i --- upm-1.6.0/src/jhd1313m1/jsupm_jhd1313m1.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/jhd1313m1/jsupm_jhd1313m1.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_jhd1313m1 -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "jhd1313m1.hpp" -%{ - #include "jhd1313m1.hpp" -%} diff -Nru upm-1.6.0/src/jhd1313m1/pyupm_jhd1313m1.i upm-1.7.1/src/jhd1313m1/pyupm_jhd1313m1.i --- upm-1.6.0/src/jhd1313m1/pyupm_jhd1313m1.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/jhd1313m1/pyupm_jhd1313m1.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_jhd1313m1 -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "jhd1313m1.hpp" -%{ - #include "jhd1313m1.hpp" -%} diff -Nru upm-1.6.0/src/joystick12/javaupm_joystick12.i upm-1.7.1/src/joystick12/javaupm_joystick12.i --- upm-1.6.0/src/joystick12/javaupm_joystick12.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/joystick12/javaupm_joystick12.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_joystick12 -%include "../upm.i" - -%{ - #include "joystick12.hpp" -%} - -%include "joystick12.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_joystick12) \ No newline at end of file diff -Nru upm-1.6.0/src/joystick12/joystick12.i upm-1.7.1/src/joystick12/joystick12.i --- upm-1.6.0/src/joystick12/joystick12.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/joystick12/joystick12.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_joystick12) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "joystick12.hpp" +%} +%include "joystick12.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/joystick12/joystick12.json upm-1.7.1/src/joystick12/joystick12.json --- upm-1.6.0/src/joystick12/joystick12.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/joystick12/joystick12.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,33 +1,33 @@ -{ - "Library": "joystick12", - "Description": "API for the ElecFreaks* Joystick v 1.2-1.4 Breakout", - "Sensor Class": - { - "Joystick12": - { - "Name": "2-axis Analog Joystick", - "Description": "This module defines the Joystick API, and implementation for the X and Y buttons could be treated as normal GPIO - this enables easier interrupt support. This driver should be compatible with any 2-axis analog joystick.", - "Aliases": ["joystick12"], - "Categories": ["input"], - "Connections": ["analog"], - "Project Type": ["prototyping"], - "Manufacturers": ["generic"], - "Kits": ["robok"], - "Image": "joystick12.jpg", - "Examples": - { - "Java": ["Joystick12Sample.java", "Joystick12_exampleSample.java"], - "Python": ["joystick12.py"], - "Node.js": ["joystick12.js"], - "C++": ["joystick12.cxx"], - "C": ["joystick12.c"] - }, - "Urls" : - { - "Product Pages": ["http://www.elecfreaks.com/estore/joystick-breakout-module-bkout-md01.html"], - "Datasheets": ["https://www.elecfreaks.com/wiki/index.php?title=Joystick_breakout_module"], - "Schematics": ["http://elecfreaks.com/store/download/schematic-red.pdf"] - } - } - } -} +{ + "Library": "joystick12", + "Description": "API for the ElecFreaks* Joystick v 1.2-1.4 Breakout", + "Sensor Class": + { + "Joystick12": + { + "Name": "2-axis Analog Joystick", + "Description": "This module defines the Joystick API, and implementation for the X and Y buttons could be treated as normal GPIO - this enables easier interrupt support. This driver should be compatible with any 2-axis analog joystick.", + "Aliases": ["joystick12"], + "Categories": ["input"], + "Connections": ["analog"], + "Project Type": ["prototyping"], + "Manufacturers": ["generic"], + "Kits": ["robok"], + "Image": "joystick12.jpg", + "Examples": + { + "Java": ["Joystick12_Example.java", "Joystick12_example_Example.java"], + "Python": ["joystick12.py"], + "Node.js": ["joystick12.js"], + "C++": ["joystick12.cxx"], + "C": ["joystick12.c"] + }, + "Urls" : + { + "Product Pages": ["http://www.elecfreaks.com/estore/joystick-breakout-module-bkout-md01.html"], + "Datasheets": ["https://www.elecfreaks.com/wiki/index.php?title=Joystick_breakout_module"], + "Schematics": ["http://elecfreaks.com/store/download/schematic-red.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/joystick12/jsupm_joystick12.i upm-1.7.1/src/joystick12/jsupm_joystick12.i --- upm-1.6.0/src/joystick12/jsupm_joystick12.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/joystick12/jsupm_joystick12.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_joystick12 -%include "../upm.i" - -%{ - #include "joystick12.hpp" -%} - -%include "joystick12.hpp" diff -Nru upm-1.6.0/src/joystick12/pyupm_joystick12.i upm-1.7.1/src/joystick12/pyupm_joystick12.i --- upm-1.6.0/src/joystick12/pyupm_joystick12.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/joystick12/pyupm_joystick12.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_joystick12 -%include "../upm.i" - -%include "stdint.i" - -%include "joystick12.hpp" -%{ - #include "joystick12.hpp" -%} diff -Nru upm-1.6.0/src/kx122/CMakeLists.txt upm-1.7.1/src/kx122/CMakeLists.txt --- upm-1.6.0/src/kx122/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kx122/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,8 @@ +upm_mixed_module_init (NAME kx122 + DESCRIPTION "3-Axis Digital Accelerometer" + C_HDR kx122.h kx122_registers.h + C_SRC kx122.c + CPP_HDR kx122.hpp + CPP_SRC kx122.cxx + CPP_WRAPS_C + REQUIRES mraa m) diff -Nru upm-1.6.0/src/kx122/kx122.c upm-1.7.1/src/kx122/kx122.c --- upm-1.6.0/src/kx122/kx122.c 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kx122/kx122.c 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,1093 @@ +/* +* The MIT License (MIT) +* +* Author: Samuli Rissanen +* 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 "kx122.h" + +//Used to set the bit required for SPI reading +#define SPI_READ 0x80 + +//Used to mask the read bit required for SPI writing +#define SPI_WRITE 0x7F + +//Used to determine amount of samples in the buffer. +#define LOW_RES_SAMPLE_MODIFIER 3 +#define HIGH_RES_SAMPLE_MODIFIER 6 + +//Mask for software reset +#define KX122_CNTL2_SRST_MASK 0x80 + +//Masks for interrupt control registers +#define KX122_INC1_MASK 0xFB +#define KX122_INC4_MASK 0xF7 +#define KX122_INC5_MASK 0xFB +#define KX122_INC6_MASK 0xF7 + +//Acceleration data buffer length +#define BUFFER_LEN 6 + +//Acceleration per decimal value for each acceleration ranges +#define RANGE_2G_G 0.00006f +#define RANGE_4G_G 0.00012f +#define RANGE_8G_G 0.00024f + +//Acceleration scaling between high and low resolution modes +#define RANGE_RES_SCALE 260 + +//Maximum loop iterations, used in software reset and self testing +#define MAX_LOOP_COUNT 100 + +//Sensor self-test defines +#define SELF_TEST_LOOP_WAIT_TIME 10000 +#define SELF_TEST_MAX_DIFFERENCE 0.75f +#define SELF_TEST_MIN_XY_DIFFERENCE 0.25f +#define SELF_TEST_MIN_Z_DIFFERENCE 0.20f + +//Maximum amount of samples in the buffer for high and low resolutions +#define MAX_BUFFER_SAMPLES_LOW_RES 681 +#define MAX_BUFFER_SAMPLES_HIGH_RES 340 + +//Earth gravity constant (m/s^2) +#define GRAVITY 9.81f +/** +Enables the chip select on the chip_select GPIO pin. +Chip select is active low. + +@param dev The device context. +*/ +static void kx122_chip_select_on(const kx122_context dev); + +/** +Disables the chip select on the chip_select GPIO pin. + +@param dev The device context. +*/ +static void kx122_chip_select_off(const kx122_context dev); + +/** +Reads a register. + +@param dev The device context. +@param reg The register to read. +@param data Pointer to a uint8_t variable to store the value. +@return UPM result +*/ +static upm_result_t kx122_read_register(const kx122_context dev, uint8_t reg, uint8_t *data); + +/** +Reads multiple continous registers. + +@param dev The device context. +@param reg The start register. +@param buffer Pointer to a uint8_t buffer to store the values. +@param len Amount of bytes to read. +@return UPM result +*/ +static upm_result_t kx122_read_registers(const kx122_context dev, uint8_t reg, uint8_t *buffer, uint len); + +/** +Writes to a register. + +@param dev The device context. +@param reg The register to write to. +@param val The value to write to the register. +@return UPM result +*/ +static upm_result_t kx122_write_register(const kx122_context dev, uint8_t reg, uint8_t val); + +/** +Writes to a register using a bitmask. + +@param dev The device context. +@param reg The register to write to. +@param val The value to write to the register. +@param bit_mask The bitmask to be used. +@return UPM result. +*/ +static upm_result_t kx122_set_bit_pattern(const kx122_context dev, uint8_t reg, uint8_t val, uint8_t bit_mask); + +/** +Sets a specific bit on (1) in a register. + +@param dev The device context. +@param reg The register to write to. +@param val The value to write to the register. +@return UPM result. +*/ +static upm_result_t kx122_set_bit_on(const kx122_context dev, uint8_t reg, uint8_t val); + +/** +Sets a specific bit off (0) in a register. + +@param dev The device context. +@param reg The register to write to. +@param val The value to write to the register. +@return UPM result. +*/ +static upm_result_t kx122_set_bit_off(const kx122_context dev, uint8_t reg, uint8_t val); + +/** +Sets the default internal variable values. + +@param dev The device context. +*/ +static void kx122_set_default_values(const kx122_context dev); + +/** +Sets acceleration scale of sensor and the buffer. + +@param dev The device context. +@param grange One of the KX122_RANGE_T values. +*/ +static void kx122_map_grange(const kx122_context dev, KX122_RANGE_T grange); + +kx122_context kx122_init(int bus, int addr, int chip_select_pin, int spi_bus_frequency) +{ + kx122_context dev = (kx122_context)malloc(sizeof(struct _kx122_context)); + + if(!dev){ + return NULL; + } + + dev->using_spi = false; + + dev->i2c = NULL; + dev->spi = NULL; + dev->chip_select = NULL; + + dev->gpio1 = NULL; + dev->gpio2 = NULL; + + if(mraa_init() != MRAA_SUCCESS){ + printf("%s: mraa_init() failed.\n", __FUNCTION__); + kx122_close(dev); + return NULL; + } + + if(addr == -1){ + dev->using_spi = true; + } + + if(dev->using_spi){ + + if (spi_bus_frequency > 10000000){ // KX122 has a maximum SPI bus speed of 10MHz + printf("%s: bus frequency too high - KX122 has a maximum SPI bus speed of 10MHz.\n", __FUNCTION__); + kx122_close(dev); + return NULL; + } + + if (!(dev->spi = mraa_spi_init(bus))){ + printf("%s: mraa_spi_init() failed.\n", __FUNCTION__); + kx122_close(dev); + return NULL; + } + + if (!(dev->chip_select = mraa_gpio_init(chip_select_pin))){ + printf("%s: mraa_gpio_init() failed.\n", __FUNCTION__); + kx122_close(dev); + return NULL; + } + + mraa_gpio_dir(dev->chip_select,MRAA_GPIO_OUT); + mraa_spi_mode(dev->spi,MRAA_SPI_MODE0); + + if (mraa_spi_frequency(dev->spi, spi_bus_frequency)){ + printf("%s: mraa_spi_frequency() failed.\n", __FUNCTION__); + kx122_close(dev); + return NULL; + } + } + else{ //Using I2C + if (!(dev->i2c = mraa_i2c_init(bus))){ + printf("%s: mraa_i2c_init() failed, used bus: %d\n", __FUNCTION__,bus); + kx122_close(dev); + return NULL; + } + + if (mraa_i2c_address(dev->i2c, addr)){ + printf("%s: mraa_i2c_address() failed.\n", __FUNCTION__); + kx122_close(dev); + return NULL; + } + } + + uint8_t who_am_i; + kx122_get_who_am_i(dev,&who_am_i); + + if(who_am_i != KX122_WHO_AM_I_WIA_ID){ + printf("%s: Wrong WHO AM I received, expected: 0x%x | got: 0x%x\n", __FUNCTION__,KX122_WHO_AM_I_WIA_ID,who_am_i); + kx122_close(dev); + return NULL; + } + + kx122_set_default_values(dev); + + kx122_device_init(dev,KX122_ODR_50,HIGH_RES,KX122_RANGE_2G); + return dev; +} + +void kx122_close(kx122_context dev) +{ + assert(dev != NULL); + kx122_uninstall_isr(dev,INT1); + kx122_uninstall_isr(dev,INT2); + + if(dev->i2c){ + mraa_i2c_stop(dev->i2c); + } + if(dev->spi){ + mraa_spi_stop(dev->spi); + } + if(dev->chip_select){ + mraa_gpio_close(dev->chip_select); + } + free(dev); +} + +static void kx122_chip_select_on(const kx122_context dev) +{ + if(dev->chip_select){ + mraa_gpio_write(dev->chip_select,0); + } +} + +static void kx122_chip_select_off(const kx122_context dev) +{ + if(dev->chip_select){ + mraa_gpio_write(dev->chip_select,1); + } +} + +//Register operations +static upm_result_t kx122_read_register(const kx122_context dev, uint8_t reg, uint8_t *data) +{ + if(dev->using_spi){ + reg |= SPI_READ; + + uint8_t spi_data[2] = {reg,0}; + + kx122_chip_select_on(dev); + + if(mraa_spi_transfer_buf(dev->spi,spi_data,spi_data,(sizeof(spi_data) / sizeof(uint8_t))) != MRAA_SUCCESS){ + printf("%s: mraa_spi_transfer_buf() failed.\n", __FUNCTION__); + + kx122_chip_select_off(dev); + return UPM_ERROR_OPERATION_FAILED; + } + *data = spi_data[1]; + + kx122_chip_select_off(dev); + return UPM_SUCCESS; + } + else{ + int value = mraa_i2c_read_byte_data(dev->i2c,reg); + + if(value != -1){ + *data = (uint8_t) value; + return UPM_SUCCESS; + } + + printf("%s: mraa_i2c_read_byte_data() failed, reading from register 0x%x\n",__FUNCTION__, reg); + return UPM_ERROR_OPERATION_FAILED; + } +} + +static upm_result_t kx122_read_registers(const kx122_context dev, uint8_t reg, uint8_t *buffer, uint len) +{ + if(dev->using_spi){ + reg |= SPI_READ; + + uint8_t spi_data_buffer[len + 1]; + spi_data_buffer[0] = reg; + + kx122_chip_select_on(dev); + + if(mraa_spi_transfer_buf(dev->spi,spi_data_buffer,spi_data_buffer, + (sizeof(spi_data_buffer) / sizeof(uint8_t))) != MRAA_SUCCESS){ + printf("%s: mraa_spi_transfer_buf() failed.\n", __FUNCTION__); + + kx122_chip_select_off(dev); + return UPM_ERROR_OPERATION_FAILED; + } + + for (size_t i = 0; i < len; i++) { + buffer[i] = spi_data_buffer[i + 1]; + } + + kx122_chip_select_off(dev); + return UPM_SUCCESS; + } + else{ + uint8_t data_buffer[len]; + if(mraa_i2c_read_bytes_data(dev->i2c,reg,data_buffer,len) != (int)len){ + return UPM_ERROR_OPERATION_FAILED; + } + else{ + for(size_t i = 0; i < len; i++){ + buffer[i] = data_buffer[i]; + } + return UPM_SUCCESS; + } + } +} + +static upm_result_t kx122_write_register(const kx122_context dev, uint8_t reg, uint8_t val) +{ + if(dev->using_spi){ + reg &= SPI_WRITE; + uint8_t spi_data[2] = {reg,val}; + + kx122_chip_select_on(dev); + if(mraa_spi_transfer_buf(dev->spi,spi_data,NULL,(sizeof(spi_data) / sizeof(uint8_t))) != MRAA_SUCCESS){ + printf("%s: mraa_spi_transfer_buf() failed.\n", __FUNCTION__); + + kx122_chip_select_off(dev); + return UPM_ERROR_OPERATION_FAILED; + } + + kx122_chip_select_off(dev); + return UPM_SUCCESS; + } + else{ + if(mraa_i2c_write_byte_data(dev->i2c,val,reg) != MRAA_SUCCESS){ + printf("%s: mraa_i2c_write_byte_data() failed.\n",__FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + return UPM_SUCCESS; + } +} + +static upm_result_t kx122_set_bit_pattern(const kx122_context dev, uint8_t reg, uint8_t val, uint8_t bit_mask) +{ + uint8_t reg_val; + + if(kx122_read_register(dev,reg,®_val) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + reg_val &= ~bit_mask; + reg_val |= val; + return kx122_write_register(dev,reg,reg_val); +} + +static upm_result_t kx122_set_bit_on(const kx122_context dev, uint8_t reg, uint8_t val) +{ + uint8_t reg_val; + + if(kx122_read_register(dev,reg,®_val) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + reg_val |= val; + return kx122_write_register(dev,reg,reg_val); +} + +static upm_result_t kx122_set_bit_off(const kx122_context dev, uint8_t reg, uint8_t val) +{ + uint8_t reg_val; + + if(kx122_read_register(dev,reg,®_val) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + reg_val &= ~val; + return kx122_write_register(dev,reg,reg_val); +} + +static void kx122_set_default_values(const kx122_context dev) +{ + dev->accel_scale = RANGE_2G_G; + dev->grange_mode = KX122_RANGE_2G; + dev->res_mode = HIGH_RES; + + dev->buffer_accel_scale = RANGE_2G_G; + dev->buffer_res = LOW_RES; + dev->buffer_mode = KX122_FIFO_MODE; +} + +static void kx122_map_grange(const kx122_context dev, KX122_RANGE_T grange) +{ + switch (grange) { + case KX122_RANGE_2G: + dev->accel_scale = RANGE_2G_G; + dev->buffer_accel_scale = RANGE_2G_G; + break; + case KX122_RANGE_4G: + dev->accel_scale = RANGE_4G_G; + dev->buffer_accel_scale = RANGE_4G_G; + break; + case KX122_RANGE_8G: + dev->accel_scale = RANGE_8G_G; + dev->buffer_accel_scale = RANGE_8G_G; + break; + } + + if(dev->res_mode == LOW_RES){ + dev->accel_scale *= RANGE_RES_SCALE; + } + if(dev->buffer_res == LOW_RES){ + dev->buffer_accel_scale *= RANGE_RES_SCALE; + } + + dev->grange_mode = grange; +} + +float kx122_get_sample_period(const kx122_context dev) +{ + assert(dev != NULL); + + odr_item odr_map[16] = { + {KX122_ODR_0P781,0.781f},{KX122_ODR_1P563,1.563f},{KX122_ODR_3P125,3.125f},{KX122_ODR_6P25,6.25f}, + {KX122_ODR_12P5,12.5f},{KX122_ODR_25,25},{KX122_ODR_50,50},{KX122_ODR_100,100},{KX122_ODR_200,200}, + {KX122_ODR_400,400},{KX122_ODR_800,800},{KX122_ODR_1600,1600},{KX122_ODR_3200,3200},{KX122_ODR_6400,6400}, + {KX122_ODR_12800,128000},{KX122_ODR_25600,25600} + }; + + uint8_t reg_val = 0; + + kx122_read_register(dev,KX122_ODCNTL, ®_val); + reg_val = reg_val & KX122_ODCNTL_OSA_MASK; + + for (size_t i = 0; i < (sizeof(odr_map) / sizeof(odr_item)); i++) { + if(reg_val == odr_map[i].odr_value){ + return (1 / odr_map[i].odr_decimal); + } + } + return -1; //Return -1 if failed +} +//Driver functions +upm_result_t kx122_device_init(const kx122_context dev, KX122_ODR_T odr, KX122_RES_T res, KX122_RANGE_T grange) +{ + assert(dev != NULL); + kx122_set_sensor_standby(dev); + + if(kx122_set_odr(dev,odr) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + if(kx122_set_resolution(dev,res) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + if(kx122_set_grange(dev,grange) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + kx122_set_sensor_active(dev); + return UPM_SUCCESS; +} + +upm_result_t kx122_get_who_am_i(const kx122_context dev, uint8_t *data) +{ + assert(dev != NULL); + return kx122_read_register(dev,KX112_WHO_AM_I,data); +} + +upm_result_t kx122_set_sensor_standby(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_off(dev,KX122_CNTL1,KX122_CNTL1_PC1); +} + +upm_result_t kx122_set_sensor_active(const kx122_context dev) +{ + assert(dev != NULL); + upm_result_t result = kx122_set_bit_on(dev,KX122_CNTL1,KX122_CNTL1_PC1); + + usleep((kx122_get_sample_period(dev) * 1.5f) * MICRO_S); //Sleep 1.5/ODR + + return result; +} + +upm_result_t kx122_get_acceleration_data_raw(const kx122_context dev, float *x, float *y, float *z) +{ + assert(dev != NULL); + + uint8_t buffer[BUFFER_LEN]; + + if(kx122_read_registers(dev,KX122_XOUT_L,buffer,BUFFER_LEN) != UPM_SUCCESS){ + printf("%s: kx122_read_registers() failed to read %d bytes\n",__FUNCTION__, BUFFER_LEN); + return UPM_ERROR_OPERATION_FAILED; + } + + if(dev->res_mode == HIGH_RES){ + if(x){ + *x = (float)((int16_t)(buffer[1] << 8) | buffer[0]); + } + if(y){ + *y = (float)((int16_t)(buffer[3] << 8) | buffer[2]); + } + if(z){ + *z = (float)((int16_t)(buffer[5] << 8) | buffer[4]); + } + } + else{ + if(x){ + *x = (float)(int8_t)buffer[1]; + } + if(y){ + *y = (float)(int8_t)buffer[3]; + } + if(z){ + *z = (float)(int8_t)buffer[5]; + } + } + + return UPM_SUCCESS; +} + +upm_result_t kx122_get_acceleration_data(const kx122_context dev, float *x, float *y, float *z) +{ + float x_raw,y_raw,z_raw; + + if(kx122_get_acceleration_data_raw(dev,&x_raw,&y_raw,&z_raw) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + if(x){ + *x = (x_raw * dev->accel_scale) * GRAVITY; + } + if(y){ + *y = (y_raw * dev->accel_scale) * GRAVITY; + } + if(z){ + *z = (z_raw * dev->accel_scale) * GRAVITY; + } + + return UPM_SUCCESS; +} + +upm_result_t kx122_sensor_software_reset(const kx122_context dev) +{ + assert(dev != NULL); + if(kx122_set_bit_on(dev,KX122_CNTL2,KX122_CNTL2_SRST) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + int counter = 0; + uint8_t reg_val; + + kx122_read_register(dev,KX122_CNTL2, ®_val); + + while((reg_val & KX122_CNTL2_SRST_MASK) != 0x00 && counter < MAX_LOOP_COUNT){ + if(kx122_read_register(dev,KX122_CNTL2, ®_val) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + usleep(100000); + counter++; + } + + if(counter == MAX_LOOP_COUNT){ + return UPM_ERROR_OPERATION_FAILED; + } + + kx122_set_default_values(dev); + + return UPM_SUCCESS; +} + +upm_result_t kx122_enable_iir(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_off(dev,KX122_ODCNTL,KX122_ODCNTL_IIR_BYPASS_BYPASS); +} + +upm_result_t kx122_disable_iir(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_on(dev,KX122_ODCNTL,KX122_ODCNTL_IIR_BYPASS_BYPASS); +} + +upm_result_t kx122_self_test(const kx122_context dev) +{ + assert(dev != NULL); + float x,y,z; + + float x_before_test_avg = 0, x_during_test_avg = 0; + float y_before_test_avg = 0, y_during_test_avg = 0; + float z_before_test_avg = 0, z_during_test_avg = 0; + + for (size_t i = 0; i < MAX_LOOP_COUNT; i++) { + kx122_get_acceleration_data(dev,&x,&y,&z); + x_before_test_avg += fabs((x / GRAVITY)); + y_before_test_avg += fabs((y / GRAVITY)); + z_before_test_avg += fabs((z / GRAVITY)); + usleep(SELF_TEST_LOOP_WAIT_TIME); + } + + kx122_write_register(dev,KX122_SELF_TEST,KX122_SELF_TEST_MEMS_TEST_ON); + + for (size_t i = 0; i < MAX_LOOP_COUNT; i++) { + kx122_get_acceleration_data(dev,&x,&y,&z); + x_during_test_avg += fabs((x / GRAVITY)); + y_during_test_avg += fabs((y / GRAVITY)); + z_during_test_avg += fabs((z / GRAVITY)); + usleep(SELF_TEST_LOOP_WAIT_TIME); + } + + kx122_write_register(dev,KX122_SELF_TEST,KX122_SELF_TEST_MEMS_TEST_OFF); + + x_before_test_avg /= MAX_LOOP_COUNT; + x_during_test_avg /= MAX_LOOP_COUNT; + + y_before_test_avg /= MAX_LOOP_COUNT; + y_during_test_avg /= MAX_LOOP_COUNT; + + z_before_test_avg /= MAX_LOOP_COUNT; + z_during_test_avg /= MAX_LOOP_COUNT; + + bool success = true; + float difference; + //X-AXIS + difference = fabs(x_during_test_avg - x_before_test_avg); + difference = ceilf(difference * 100) / 100; + + if(difference >= SELF_TEST_MIN_XY_DIFFERENCE && difference <= SELF_TEST_MAX_DIFFERENCE){ + printf("X-AXIS OK DIFFERENCE %.02f\n",difference); + } + else{ + printf("X-AXIS FAILED, DIFFERENCE %.02f\n", difference); + success = false; + } + //Y-AXIS + difference = fabs(y_during_test_avg - y_before_test_avg); + difference = ceilf(difference * 100) / 100; + if(difference >= SELF_TEST_MIN_XY_DIFFERENCE && difference <= SELF_TEST_MAX_DIFFERENCE){ + printf("Y-AXIS OK DIFFERENCE %.02f\n",difference); + } + else{ + printf("Y-AXIS FAILED, DIFFERENCE %.02f\n", difference); + success = false; + } + //Z-AXIS + difference = fabs(z_during_test_avg - z_before_test_avg); + difference = ceilf(difference * 100) / 100; + if(difference >= SELF_TEST_MIN_Z_DIFFERENCE && difference <= SELF_TEST_MAX_DIFFERENCE){ + printf("Z-AXIS OK DIFFERENCE %.02f\n",difference); + } + else{ + printf("Z-AXIS FAILED, DIFFERENCE %.02f\n", difference); + success = false; + } + + if(success){ + return UPM_SUCCESS; + } + + return UPM_ERROR_OPERATION_FAILED; +} + +upm_result_t kx122_set_odr(const kx122_context dev, KX122_ODR_T odr) +{ + assert(dev != NULL); + return kx122_set_bit_pattern(dev,KX122_ODCNTL,odr,KX122_ODCNTL_OSA_MASK); +} + +upm_result_t kx122_set_grange(const kx122_context dev, KX122_RANGE_T grange) +{ + assert(dev != NULL); + kx122_map_grange(dev,grange); + + return kx122_set_bit_pattern(dev,KX122_CNTL1,grange,KX122_CNTL1_GSEL_MASK); +} + +upm_result_t kx122_set_resolution(const kx122_context dev, KX122_RES_T res) +{ + assert(dev != NULL); + + dev->res_mode = res; + kx122_map_grange(dev,dev->grange_mode); + + if(res == HIGH_RES){ + return kx122_set_bit_on(dev,KX122_CNTL1,KX122_CNTL1_RES); + } + else{ + return kx122_set_bit_off(dev,KX122_CNTL1,KX122_CNTL1_RES); + } +} + +upm_result_t kx122_set_bw(const kx122_context dev, LPRO_STATE_T lpro) +{ + assert(dev != NULL); + if(lpro == ODR_9){ + return kx122_set_bit_off(dev, KX122_ODCNTL, KX122_ODCNTL_LPRO_ODR_2); + } + else{ + return kx122_set_bit_on(dev, KX122_ODCNTL, KX122_ODCNTL_LPRO_ODR_2); + } +} + +upm_result_t kx122_set_average(const kx122_context dev, KX122_AVG_T avg) +{ + assert(dev != NULL); + return kx122_set_bit_pattern(dev,KX122_LP_CNTL,avg,KX122_LP_CNTL_AVC_MASK); +} + +upm_result_t kx122_install_isr(const kx122_context dev, mraa_gpio_edge_t edge,KX122_INTERRUPT_PIN_T intp, int pin, void (*isr)(void *), void *arg) +{ + assert(dev != NULL); + mraa_gpio_context isr_gpio = NULL; + + if (!(isr_gpio = mraa_gpio_init(pin))){ + printf("%s: mraa_gpio_init() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + mraa_gpio_dir(isr_gpio, MRAA_GPIO_IN); + + if (mraa_gpio_isr(isr_gpio, edge, isr, arg)){ + mraa_gpio_close(isr_gpio); + printf("%s: mraa_gpio_isr() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + if(intp == INT1){ + dev->gpio1 = isr_gpio; + } + else{ + dev->gpio2 = isr_gpio; + } + + return UPM_SUCCESS; +} + +void kx122_uninstall_isr(const kx122_context dev, KX122_INTERRUPT_PIN_T intp) +{ + assert(dev != NULL); + if(intp == INT1 && dev->gpio1){ + mraa_gpio_isr_exit(dev->gpio1); + mraa_gpio_close(dev->gpio1); + dev->gpio1 = NULL; + } + else if(intp == INT2 && dev->gpio2){ + mraa_gpio_isr_exit(dev->gpio2); + mraa_gpio_close(dev->gpio2); + dev->gpio2 = NULL; + } +} + +upm_result_t kx122_enable_interrupt1(const kx122_context dev, KX122_INTERRUPT_POLARITY_T polarity) +{ + assert(dev != NULL); + + uint8_t bits = KX122_INC1_PWSEL1_50US_10US | KX122_INC1_IEL1 | KX122_INC1_IEN1; + if(polarity == ACTIVE_HIGH){ + bits |= KX122_INC1_IEA1; + } + + return kx122_set_bit_pattern(dev,KX122_INC1,bits,KX122_INC1_MASK); +} + +upm_result_t kx122_enable_interrupt2(const kx122_context dev, KX122_INTERRUPT_POLARITY_T polarity) +{ + assert(dev != NULL); + + uint8_t bits = KX122_INC5_PWSEL2_50US_10US | KX122_INC5_IEL2 | KX122_INC5_IEN2; + if(polarity == ACTIVE_HIGH){ + bits |= KX122_INC5_IEA2; + } + + return kx122_set_bit_pattern(dev,KX122_INC5,bits,KX122_INC5_MASK); +} + +upm_result_t kx122_disable_interrupt1(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_off(dev,KX122_INC1,KX122_INC1_IEN1); +} + +upm_result_t kx122_disable_interrupt2(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_off(dev,KX122_INC5,KX122_INC5_IEN2); +} + +upm_result_t kx122_route_interrupt1(const kx122_context dev, uint8_t bits) +{ + assert(dev != NULL); + return kx122_set_bit_pattern(dev,KX122_INC4,bits,KX122_INC4_MASK); +} + +upm_result_t kx122_route_interrupt2(const kx122_context dev, uint8_t bits) +{ + assert(dev != NULL); + return kx122_set_bit_pattern(dev,KX122_INC6,bits,KX122_INC6_MASK); +} + +upm_result_t kx122_enable_data_ready_interrupt(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_on(dev,KX122_CNTL1,KX122_CNTL1_DRDYE); +} + +upm_result_t kx122_disable_data_ready_interrupt(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_off(dev,KX122_CNTL1,KX122_CNTL1_DRDYE); +} + +upm_result_t kx122_enable_buffer_full_interrupt(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_on(dev,KX122_BUF_CNTL2,KX122_BUF_CNTL2_BFIE); +} + +upm_result_t kx122_disable_buffer_full_interrupt(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_off(dev,KX122_BUF_CNTL2,KX122_BUF_CNTL2_BFIE); +} + +upm_result_t kx122_get_interrupt_source(const kx122_context dev, uint8_t *data) +{ + assert(dev != NULL); + return kx122_read_register(dev,KX122_INS2,data); +} + +upm_result_t kx122_clear_interrupt(const kx122_context dev) +{ + assert(dev != NULL); + uint8_t reg_val; + + return kx122_read_register(dev,KX122_INT_REL,®_val); +} + +bool kx122_get_interrupt_status(const kx122_context dev) +{ + assert(dev != NULL); + uint8_t reg_val; + + if(kx122_read_register(dev,KX122_STATUS_REG,®_val) != UPM_SUCCESS){ + printf("%s: kx122_read_register() failed.\n", __FUNCTION__); + return false; + } + + if(reg_val != 0x00){ + return true; + } + return false; +} + +upm_result_t kx122_enable_buffer(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_on(dev,KX122_BUF_CNTL2,KX122_BUF_CNTL2_BUFE); +} + +upm_result_t kx122_disable_buffer(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_set_bit_off(dev,KX122_BUF_CNTL2,KX122_BUF_CNTL2_BUFE); +} + +upm_result_t kx122_buffer_init(const kx122_context dev, uint samples, KX122_RES_T res, KX122_BUFFER_MODE_T mode) +{ + assert(dev != NULL); + kx122_set_sensor_standby(dev); + + if(kx122_set_buffer_threshold(dev,samples) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + if(kx122_set_buffer_resolution(dev,res) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + if(kx122_set_buffer_mode(dev,mode) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + kx122_enable_buffer(dev); + kx122_set_sensor_active(dev); + + return UPM_SUCCESS; +} + +upm_result_t kx122_set_buffer_resolution(const kx122_context dev, KX122_RES_T res) +{ + assert(dev != NULL); + dev->buffer_res = res; + kx122_map_grange(dev,dev->grange_mode); + + if(res == HIGH_RES){ + return kx122_set_bit_on(dev,KX122_BUF_CNTL2,KX122_BUF_CNTL2_BRES); + } + return kx122_set_bit_off(dev, KX122_BUF_CNTL2, KX122_BUF_CNTL2_BRES); +} + +upm_result_t kx122_set_buffer_threshold(const kx122_context dev, uint samples) +{ + assert(dev != NULL); + if(dev->buffer_res == LOW_RES && samples > MAX_BUFFER_SAMPLES_LOW_RES){ + samples = MAX_BUFFER_SAMPLES_LOW_RES; + } + else if(dev->buffer_res == HIGH_RES && samples > MAX_BUFFER_SAMPLES_HIGH_RES){ + samples = MAX_BUFFER_SAMPLES_HIGH_RES; + } + + uint16_t bits = (uint16_t)samples; + + uint8_t temp = (uint8_t) (bits & 0x00FF);//Get first 8 bits and set them to BUF_CNTL1 + + if(kx122_write_register(dev,KX122_BUF_CNTL1,temp) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + temp = (uint8_t)((bits & 0x0300) >> 6); //Get last 2 bits and set them to BUF_CNTL2 + + return kx122_set_bit_pattern(dev,KX122_BUF_CNTL2,temp,KX122_BUF_CNTL2_SMP_TH8_9_MASK); +} + +upm_result_t kx122_set_buffer_mode(const kx122_context dev, KX122_BUFFER_MODE_T mode) +{ + assert(dev != NULL); + dev->buffer_mode = mode; + + return kx122_set_bit_pattern(dev,KX122_BUF_CNTL2,mode,KX122_BUF_CNTL2_BUF_M_MASK); +} + +upm_result_t kx122_clear_buffer(const kx122_context dev) +{ + assert(dev != NULL); + return kx122_write_register(dev,KX122_BUF_CLEAR,0xFF); //Writing anything to the register clears the buffer +} + +upm_result_t kx122_get_buffer_status(const kx122_context dev, uint *samples) +{ + uint8_t reg_val; + uint16_t temp; //Using only 10 bits + + if(kx122_read_register(dev,KX122_BUF_STATUS_2,®_val) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + temp = (reg_val & 0x0007) << 8; //Get 3 MSb from BUF_STATUS 2 + + if(kx122_read_register(dev,KX122_BUF_STATUS_1, ®_val) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + temp = (temp + (reg_val & 0x00FF)); //Get rest of the bits from BUF_STATUS 1 + + //Get the amount of samples + if(dev->buffer_res == LOW_RES){ + //3 axis / sample + *samples = ((uint)(int16_t)temp) / 3; + } + else{ + //3 axis * MSB/LSB / sample + *samples = ((uint)(int16_t)temp) / 6; + } + + return UPM_SUCCESS; +} + +upm_result_t kx122_read_buffer_samples_raw(const kx122_context dev, uint len, float *x_array, float *y_array, float *z_array) +{ + assert(dev != NULL); + if(dev->buffer_res == LOW_RES){ + len *= LOW_RES_SAMPLE_MODIFIER; //3 axis / sample + } + else{ + len *= HIGH_RES_SAMPLE_MODIFIER; //3 axis * 2 bytes / sample + } + + uint8_t buffer[len]; + + if(kx122_read_registers(dev,KX122_BUF_READ,buffer,len) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + if(dev->buffer_res == HIGH_RES){ + for (size_t i = 0; i < len; i+= HIGH_RES_SAMPLE_MODIFIER) { + if(dev->buffer_mode != KX122_FILO_MODE){ + if(x_array){ + x_array[i / HIGH_RES_SAMPLE_MODIFIER] = (float)((int16_t) (buffer[i + 1] << 8) | buffer[i]); + } + if(y_array){ + y_array[i / HIGH_RES_SAMPLE_MODIFIER] = (float)((int16_t) (buffer[i + 3] << 8) | buffer[i + 2]); + } + if(z_array){ + z_array[i / HIGH_RES_SAMPLE_MODIFIER] = (float)((int16_t) (buffer[i + 5] << 8) | buffer[i + 4]); + } + } + else{ + if(x_array){ + x_array[i / HIGH_RES_SAMPLE_MODIFIER] = (float)((int16_t) (buffer[i + 4] << 8) | buffer[i + 5]); + } + if(y_array){ + y_array[i / HIGH_RES_SAMPLE_MODIFIER] = (float)((int16_t) (buffer[i + 2] << 8) | buffer[i + 3]); + } + if(z_array){ + z_array[i / HIGH_RES_SAMPLE_MODIFIER] = (float)((int16_t) (buffer[i] << 8) | buffer[i + 1]); + } + } + } + } + else{ //Low resolution + for (size_t i = 0; i < len; i+= LOW_RES_SAMPLE_MODIFIER) { + if(dev->buffer_mode != KX122_FILO_MODE){ + if(x_array){ + x_array[i / LOW_RES_SAMPLE_MODIFIER] = (float)(int8_t)buffer[i]; + } + if(y_array){ + y_array[i / LOW_RES_SAMPLE_MODIFIER] = (float)(int8_t)buffer[i + 1]; + } + if(z_array){ + z_array[i / LOW_RES_SAMPLE_MODIFIER] = (float)(int8_t)buffer[i + 2]; + } + } + else{ + if(x_array){ + x_array[i / LOW_RES_SAMPLE_MODIFIER] = (float)(int8_t)buffer[i + 2]; + } + if(y_array){ + y_array[i / LOW_RES_SAMPLE_MODIFIER] = (float)(int8_t)buffer[i + 1]; + } + if(z_array){ + z_array[i / LOW_RES_SAMPLE_MODIFIER] = (float)(int8_t)buffer[i]; + } + } + } + } + + return UPM_SUCCESS; +} + +upm_result_t kx122_read_buffer_samples(const kx122_context dev, uint len, float *x_array, float *y_array, float *z_array) +{ + assert(dev != NULL); + if(kx122_read_buffer_samples_raw(dev,len,x_array,y_array,z_array) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + for (size_t i = 0; i < len; i++) { + if(x_array){ + x_array[i] = (x_array[i] * dev->buffer_accel_scale) * GRAVITY; + } + if(y_array){ + y_array[i] = (y_array[i] * dev->buffer_accel_scale) * GRAVITY; + } + if(z_array){ + z_array[i] = (z_array[i] * dev->buffer_accel_scale) * GRAVITY; + } + } + + return UPM_SUCCESS; +} diff -Nru upm-1.6.0/src/kx122/kx122.cxx upm-1.7.1/src/kx122/kx122.cxx --- upm-1.6.0/src/kx122/kx122.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kx122/kx122.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,369 @@ +/* +* The MIT License (MIT) +* +* Author: Samuli Rissanen +* 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 +#include +#include + +#include + +#include "kx122.hpp" + +using namespace upm; + +KX122::KX122(int bus, int addr, int chip_select, int spi_bus_frequency) + : m_kx122(kx122_init(bus, addr, chip_select, spi_bus_frequency)) +{ + if(!m_kx122){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_init() failed"); + } +} + +KX122::~KX122() +{ + kx122_close(m_kx122); +} + +void KX122::deviceInit(KX122_ODR_T odr, KX122_RES_T res, KX122_RANGE_T grange) +{ + if(kx122_device_init(m_kx122,odr,res,grange)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_device_init() failed"); + } +} + +float KX122::getSamplePeriod() +{ + return kx122_get_sample_period(m_kx122); +} + +uint8_t KX122::getWhoAmI() +{ + uint8_t data; + + if(kx122_get_who_am_i(m_kx122, &data)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_get_who_am_i failed"); + } + + return data; +} +void KX122::getRawAccelerationData(float *x, float *y, float *z) +{ + if(kx122_get_acceleration_data_raw(m_kx122,x,y,z)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_get_accleration_data_raw failed"); + } +} + +void KX122::getAccelerationData(float *x, float *y, float *z) +{ + if(kx122_get_acceleration_data(m_kx122,x,y,z)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_get_acceleration_data failed"); + } +} + +std::vector KX122::getAccelerationDataVector() +{ + std::vector xyz(3); + getAccelerationData(&xyz[0], &xyz[1], &xyz[2]); + + return xyz; +} + +void KX122::softwareReset() +{ + if(kx122_sensor_software_reset(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_sensor_software_reset failed"); + } +} + +void KX122::enableIIR() +{ + if(kx122_enable_iir(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_enable_iir failed"); + } +} + +void KX122::disableIIR() +{ + if(kx122_disable_iir(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_disable_iir failed"); + } +} + +void KX122::selfTest() +{ + if(kx122_self_test(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_self_test failed"); + } +} + +void KX122::setSensorStandby() +{ + if(kx122_set_sensor_standby(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_sensor_standby failed"); + } +} + +void KX122::setSensorActive() +{ + if(kx122_set_sensor_active(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_sensor_active failed"); + } +} + +void KX122::setODR(KX122_ODR_T odr) +{ + if(kx122_set_odr(m_kx122,odr)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_odr failed"); + } +} + +void KX122::setGrange(KX122_RANGE_T grange) +{ + if(kx122_set_grange(m_kx122,grange)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_grange failed"); + } +} + +void KX122::setResolution(KX122_RES_T res) +{ + if(kx122_set_resolution(m_kx122,res)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_resolution failed"); + } +} + +void KX122::setBW(LPRO_STATE_T lpro) +{ + if(kx122_set_bw(m_kx122,lpro)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_bw failed"); + } +} + +void KX122::setAverage(KX122_AVG_T avg) +{ + if(kx122_set_average(m_kx122,avg)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_average failed"); + } +} + +void KX122::installISR(mraa::Edge edge, KX122_INTERRUPT_PIN_T intp, int pin, void(*isr)(void*),void *arg) +{ + if(kx122_install_isr(m_kx122,(mraa_gpio_edge_t)edge,intp,pin,isr,arg)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_install_isr failed"); + } +} + +void KX122::uninstallISR(KX122_INTERRUPT_PIN_T intp) +{ + kx122_uninstall_isr(m_kx122,intp); +} + +void KX122::enableInterrupt1(KX122_INTERRUPT_POLARITY_T polarity) +{ + if(kx122_enable_interrupt1(m_kx122,polarity)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_enable_interrupt1 failed"); + } +} + +void KX122::enableInterrupt2(KX122_INTERRUPT_POLARITY_T polarity) +{ + if(kx122_enable_interrupt2(m_kx122,polarity)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_enable_interrupt2 failed"); + } +} + +void KX122::disableInterrupt1() +{ + if(kx122_disable_interrupt1(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_disable_interrupt1 failed"); + } +} + +void KX122::disableInterrupt2() +{ + if(kx122_disable_interrupt2(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_disable_interrupt2 failed"); + } +} + +void KX122::routeInterrupt1(uint8_t bits) +{ + if(kx122_route_interrupt1(m_kx122,bits)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_route_interrupt1 failed"); + } +} + +void KX122::routeInterrupt2(uint8_t bits) +{ + if(kx122_route_interrupt2(m_kx122,bits)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_route_interrupt2 failed"); + } +} + +bool KX122::getInterruptStatus() +{ + return kx122_get_interrupt_status(m_kx122); +} + +uint8_t KX122::getInterruptSource() +{ + uint8_t data; + if(kx122_get_interrupt_source(m_kx122, &data)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_get_interrupt_source failed"); + } + + return data; +} + +void KX122::clearInterrupt() +{ + if(kx122_clear_interrupt(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_clear_interrupt failed"); + } +} + +void KX122::enableDataReadyInterrupt() +{ + if(kx122_enable_data_ready_interrupt(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_enable_data_ready_interrupt failed"); + } +} + +void KX122::disableDataReadyInterrupt() +{ + if(kx122_disable_data_ready_interrupt(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_disable_data_ready_interrupt failed"); + } +} + +void KX122::enableBufferFullInterrupt() +{ + if(kx122_enable_buffer_full_interrupt(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_enable_buffer_full_interrupt failed"); + } +} + +void KX122::disableBufferFullInterrupt() +{ + if(kx122_disable_buffer_full_interrupt(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_disable_buffer_full_interrupt failed"); + } +} + +void KX122::enableBuffer() +{ + if(kx122_enable_buffer(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_enable_buffer failed"); + } +} + +void KX122::disableBuffer() +{ + if(kx122_disable_buffer(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_disable_buffer failed"); + } +} + +void KX122::bufferInit(uint samples, KX122_RES_T res, KX122_BUFFER_MODE_T mode) +{ + if(kx122_buffer_init(m_kx122,samples,res,mode)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_buffer_init failed"); + } +} + +void KX122::setBufferResolution(KX122_RES_T res) +{ + if(kx122_set_buffer_resolution(m_kx122,res)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_buffer_resolution failed"); + } +} + +void KX122::setBufferThreshold(uint samples) +{ + if(kx122_set_buffer_threshold(m_kx122,samples)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_buffer_threshold failed"); + } +} + +void KX122::setBufferMode(KX122_BUFFER_MODE_T mode) +{ + if(kx122_set_buffer_mode(m_kx122,mode)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_set_buffer_mode failed"); + } +} + +uint KX122::getBufferStatus() +{ + uint nb_samples = 0; + if(kx122_get_buffer_status(m_kx122, &nb_samples)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_get_buffer_status failed"); + } + + return nb_samples; +} + +//Maximum number of samples that can be stored in the buffer of the KX122 +#define MAX_SAMPLES_IN_BUFFER 681 + +std::vector KX122::getRawBufferSamples(uint len) +{ + float bufferx[MAX_SAMPLES_IN_BUFFER], buffery[MAX_SAMPLES_IN_BUFFER], bufferz[MAX_SAMPLES_IN_BUFFER]; + if(kx122_read_buffer_samples_raw(m_kx122,len,bufferx,buffery,bufferz)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_read_buffer_samples_raw failed"); + } + + std::vector xyz_array(len * 3); + for (uint i = 0; i < len; i++) + { + xyz_array[i * 3 + 0] = bufferx[i]; + xyz_array[i * 3 + 1] = buffery[i]; + xyz_array[i * 3 + 2] = bufferz[i]; + } + + return xyz_array; +} + +std::vector KX122::getBufferSamples(uint len) +{ + float bufferx[MAX_SAMPLES_IN_BUFFER], buffery[MAX_SAMPLES_IN_BUFFER], bufferz[MAX_SAMPLES_IN_BUFFER]; + if(kx122_read_buffer_samples(m_kx122,len,bufferx,buffery,bufferz)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_read_buffer_samples failed"); + } + + std::vector xyz_array(len * 3); + for (uint i = 0; i < len; i++) + { + xyz_array[i * 3 + 0] = bufferx[i]; + xyz_array[i * 3 + 1] = buffery[i]; + xyz_array[i * 3 + 2] = bufferz[i]; + } + + return xyz_array; +} + +void KX122::clearBuffer() +{ + if(kx122_clear_buffer(m_kx122)){ + throw std::runtime_error(std::string(__FUNCTION__) + "kx122_clear_buffer failed"); + } +} diff -Nru upm-1.6.0/src/kx122/kx122.h upm-1.7.1/src/kx122/kx122.h --- upm-1.6.0/src/kx122/kx122.h 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kx122/kx122.h 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,675 @@ +/* +* The MIT License (MIT) +* +* Author: Samuli Rissanen +* 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. +*/ + +#pragma once + +#ifdef __cplusplus +extern "C"{ +#endif + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "kx122_registers.h" + +/** + * @file kx122.h + * @library kx122 + * @brief C API for the kx122 driver + * + * @include kx122.c + */ + +//Frequency of the SPI connection +#define DEFAULT_SPI_FREQUENCY 10000 + +//Default slave addresses for the sensor +#define KX122_DEFAULT_SLAVE_ADDR_1 0x1F +#define KX122_DEFAULT_SLAVE_ADDR_2 0x1E + +//Microseconds in a second +#define MICRO_S 1000000 + +//Sensor ODR values +typedef enum{ + KX122_ODR_12P5 = KX122_ODCNTL_OSA_12P5, + KX122_ODR_25 = KX122_ODCNTL_OSA_25, + KX122_ODR_50 = KX122_ODCNTL_OSA_50, + KX122_ODR_100 = KX122_ODCNTL_OSA_100, + KX122_ODR_200 = KX122_ODCNTL_OSA_200, + KX122_ODR_400 = KX122_ODCNTL_OSA_400, + KX122_ODR_800 = KX122_ODCNTL_OSA_800, + KX122_ODR_1600 = KX122_ODCNTL_OSA_1600, + KX122_ODR_0P781 = KX122_ODCNTL_OSA_0P781, + KX122_ODR_1P563 = KX122_ODCNTL_OSA_1P563, + KX122_ODR_3P125 = KX122_ODCNTL_OSA_3P125, + KX122_ODR_6P25 = KX122_ODCNTL_OSA_6P25, + KX122_ODR_3200 = KX122_ODCNTL_OSA_3200, + KX122_ODR_6400 = KX122_ODCNTL_OSA_6400, + KX122_ODR_12800 = KX122_ODCNTL_OSA_12800, + KX122_ODR_25600 = KX122_ODCNTL_OSA_25600 +} KX122_ODR_T; + +//Sensor average values +typedef enum{ + KX122_NO_AVG = KX122_LP_CNTL_AVC_NO_AVG, + KX122_2_SAMPLE_AVG = KX122_LP_CNTL_AVC_2_SAMPLE_AVG, + KX122_4_SAMPLE_AVG = KX122_LP_CNTL_AVC_4_SAMPLE_AVG, + KX122_8_SAMPLE_AVG = KX122_LP_CNTL_AVC_8_SAMPLE_AVG, + KX122_16_SAMPLE_AVG = KX122_LP_CNTL_AVC_16_SAMPLE_AVG, + KX122_32_SAMPLE_AVG = KX122_LP_CNTL_AVC_32_SAMPLE_AVG, + KX122_64_SAMPLE_AVG = KX122_LP_CNTL_AVC_64_SAMPLE_AVG, + KX122_128_SAMPLE_AVG = KX122_LP_CNTL_AVC_128_SAMPLE_AVG +} KX122_AVG_T; + +//Sensor range values +typedef enum{ + KX122_RANGE_2G = KX122_CNTL1_GSEL_2G, + KX122_RANGE_4G = KX122_CNTL1_GSEL_4G, + KX122_RANGE_8G = KX122_CNTL1_GSEL_8G +} KX122_RANGE_T; + +//Sensor buffer modes +typedef enum{ + KX122_FIFO_MODE = KX122_BUF_CNTL2_BUF_M_FIFO, + KX122_FILO_MODE = KX122_BUF_CNTL2_BUF_M_FILO, + KX122_STREAM_MODE = KX122_BUF_CNTL2_BUF_M_STREAM, +} KX122_BUFFER_MODE_T; + +//Sensor interrupt types +typedef enum{ + KX122_BUF_FULL_INT = KX122_INC4_BFI1, + KX122_WATERMARK_INT = KX122_INC4_WMI1, + KX122_DATA_READY_INT = KX122_INC4_DRDYI1 +} KX122_INTERRUPT_T; + +//High and low resolution modes +typedef enum{ + HIGH_RES, + LOW_RES +} KX122_RES_T; + +//Sensor low-pass filter roll of values +typedef enum{ + ODR_9, + ODR_2 +} LPRO_STATE_T; + +//Interrupt pins +typedef enum{ + INT1, + INT2 +}KX122_INTERRUPT_PIN_T; + +//Interrupt polarity +typedef enum{ + ACTIVE_LOW, + ACTIVE_HIGH +} KX122_INTERRUPT_POLARITY_T; + +//Device context +typedef struct _kx122_context { + mraa_i2c_context i2c; + mraa_spi_context spi; + mraa_gpio_context gpio1; //Interrupt pin 1 + mraa_gpio_context gpio2; //Interrupt pin 2 + mraa_gpio_context chip_select; //Chip select pin (SPI) + + float accel_scale; //Acceleration scaling + KX122_RES_T res_mode; //Sensor resolution + KX122_RANGE_T grange_mode; //Sensor range + + float buffer_accel_scale; //Buffer acceleration scaling + KX122_BUFFER_MODE_T buffer_mode; //Buffer mode + KX122_RES_T buffer_res; //Buffer resolution + + bool using_spi; + +} *kx122_context; + +//Struct for ODR values and their decimal counterparts. +typedef struct _odr_item{ + uint8_t odr_value; + float odr_decimal; +} odr_item; + +/** +KX122 initialization + +Set addr to -1 if using SPI. +When using I2C, set chip_select_pin to -1; + +If no errors occur, the device gets initialized with default values and gets set to active state. + +@param bus I2C or SPI bus to use. +@param addr I2C address of the sensor. +@param chip_select Chip select pin for SPI. +@param spi_bus_frequency Speed of the SPI communication bus in Hz (ignored when using I2C). +@return The device context, or NULL if an error occurs. +*/ +kx122_context kx122_init(int bus, int addr, int chip_select_pin, int spi_bus_frequency); + +/** +KX122 destructor +Closes the I2C or SPI context, and removes interrupts. +Frees memory of the kx122_context. + +@param dev The device context. +*/ +void kx122_close(kx122_context dev); + + +/** +Intilializes the sensor with the given sampling rate, resolution and acceleration range. + +This gets called during the kx122_init(), so it will not need to be called unless the device is reset. + +Sensor is automatically set into standby mode during the initialization. +Sensor is set to active mode after initialization. + +@param dev The device context. +@param odr One of the KX122_ODR_T values. +@param res One of the KX122_RES_T values. +@param grange One of the KX122_RANGE_T values. +@return UPM result. +*/ +upm_result_t kx122_device_init(const kx122_context dev, KX122_ODR_T odr, KX122_RES_T res, KX122_RANGE_T grange); + +/** +Gets the length of one sample period depending on the sampling rate of the sensor. + +@param dev The device context. +@return Floating point value of the sampling period, or if an error occurs returns -1. +*/ +float kx122_get_sample_period(const kx122_context dev); + +/** +Gets who am i value of the sensor. + +@param dev The device context. +@param data Pointer to a uint8_t variable to store the value. +@return UPM result. +*/ +upm_result_t kx122_get_who_am_i(const kx122_context dev, uint8_t *data); + +/** +Gets raw accelerometer data from the sensor. + +@param dev The device context. +@param x Pointer to a floating point variable to store the x-axis value. Can be set to NULL if not wanted. +@param y Pointer to a floating point variable to store the y-axis value. Can be set to NULL if not wanted. +@param z Pointer to a floating point variable to store the z-axis value. Can be set to NULL if not wanted. +@return UPM result. +*/ +upm_result_t kx122_get_acceleration_data_raw(const kx122_context dev, float *x, float *y, float *z); + +/** +Gets converted (m/s^2) accelerometer data from the sensor. + +@param dev The device context. +@param x Pointer to a floating point variable to store the x-axis value. Can be set to NULL if not wanted. +@param y Pointer to a floating point variable to store the y-axis value. Can be set to NULL if not wanted. +@param z Pointer to a floating point variable to store the z-axis value. Can be set to NULL if not wanted. +*/ +upm_result_t kx122_get_acceleration_data(const kx122_context dev, float *x, float *y, float *z); + +/** +Performs a sensor software reset. The software reset clears the RAM of the sensor and resets all registers +to pre-defined values. + +You should call kx122_device_init() after the software reset. + +See the datasheet for more details. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_sensor_software_reset(const kx122_context dev); + +/** +Enables sensor filter bypass. + +Sensor needs to be in standby mode when enabling the filter bypass. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_enable_iir(const kx122_context dev); + +/** +Disables sensor filter bypass. + +Sensor needs to be in standby mode when disabling the filter bypass. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_disable_iir(const kx122_context dev); + +/** +Performs a self-test of the sensor. The test applies an electrostatic force to the sensor, +simulating input acceleration. The test compares samples from all axis before and after +applying the electrostatic force to the sensor. If the amount of acceleration increases according +to the values defined in TABLE 1 of the datasheet, the test passes. + +The function prints out the minimum, maximum and values calculated during the test +for each axis, and the result of the test for each axis. + +See the datasheet for more information. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_self_test(const kx122_context dev); + +/** +Sets the sensor to the standby mode. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_set_sensor_standby(const kx122_context dev); + +/** +Sets the sensor to active mode. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_set_sensor_active(const kx122_context dev); + +/** +Sets the ODR of the sensor. + +Sensor needs to be in standby mode when setting the ODR. + +@param dev The device context. +@param odr One of the KX122_ODR_T values. +@return UPM result. +*/ +upm_result_t kx122_set_odr(const kx122_context dev, KX122_ODR_T odr); + +/** +Sets the acceleration range of the sensor. + +Sensor needs to be in standby mode when setting the acceleration range value. + +@param dev The device context. +@param grange One of the KX122_RANGE_T values. +@return UPM result. +*/ +upm_result_t kx122_set_grange(const kx122_context dev, KX122_RANGE_T grange); + +/** +Sets the resolution of the sensor. High resolution (16 bits) or low resolution (8 bits). + +Sensor needs to be in standby mode when setting the sensor resolution. + +When sensor is set to low resolution mode, the sensor runs in low power mode, which in turn +enables features such as averaging.(kx122_set_average()). + +@param dev The device context. +@param res One of the KX122_RES_T values. +@return UPM result. +*/ +upm_result_t kx122_set_resolution(const kx122_context dev, KX122_RES_T res); + +/** +Sets the low pass filter roll off + +Sensor needs to be in standby mode when setting the filter roll off value. + +@param dev The device context. +@param lpro One of the LPRO_STATE_T values. +@return UPM result. +*/ +upm_result_t kx122_set_bw(const kx122_context dev, LPRO_STATE_T lpro); + +/** +Set the amount of samples to be averaged in low power mode. + +Sensor needs to be in standby mode when setting the average value. + +@param dev The device context. +@param avg One of the KX122_AVG_T values. +@return UPM result. +*/ +upm_result_t kx122_set_average(const kx122_context dev, KX122_AVG_T avg); + +/** +Installs an interrupt handler to be executed when an interrupt is detected on the interrupt pin. + +@param dev The device context. +@param edge One of the mraa_gpio_edge_t values. Interrupt trigger edge. +@param intp One of the KX122_INTERRUPT_PIN_T values. Specifies which interrupt pin you are setting. +@param pin The GPIO pin to use as the interrupt pin. +@param isr Pointer to the function to be called, when the interrupt occurs. +@param arg The arguments to be passed to the function. +@return UPM result. +*/ +upm_result_t kx122_install_isr(const kx122_context dev, mraa_gpio_edge_t edge,KX122_INTERRUPT_PIN_T intp, int pin,void (*isr)(void *), void *arg); + +/** +Uninstalls a previously installed interrupt handler. + +@param dev The device context. +@param intp One of the KX122_INTERRUPT_PIN_T values. Specifies which interrupt pin handler is uninstalled. +*/ +void kx122_uninstall_isr(const kx122_context dev, KX122_INTERRUPT_PIN_T intp); + +/** +Enables interrupts on the interrupt pin 1 of the sensor. + +Pulse width = 50us (10us if data sampling rate > 1600Hz). +Using pulse mode. + +Sensor needs to be in standby mode when enabling the interrupt. + +See datasheet for more details. + +@param dev The device context. +@param polarity One of the KX122_INTERRUPT_POLARITY_T values. Select the polarity of the interrupt. +@return UPM result. +*/ +upm_result_t kx122_enable_interrupt1(const kx122_context dev, KX122_INTERRUPT_POLARITY_T polarity); + +/** +Enables interrupts on the interrupt pin 2 of the sensor. + +Pulse width = 50us (10us if data sampling rate > 1600Hz). +Using pulse mode. + +Sensor needs to be in standby mode when enabling the interrupt. + +See datasheet for more details. + +@param dev The device context. +@param polarity One of the KX122_INTERRUPT_POLARITY_T values. Select the polarity of the interrupt. +@return UPM result. +*/ +upm_result_t kx122_enable_interrupt2(const kx122_context dev, KX122_INTERRUPT_POLARITY_T polarity); + +/** +Disables interrupts on the interrupt pin 1 of the sensor. + +Sensor needs to be in standby mode when disabling the interrupt pin 1. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_disable_interrupt1(const kx122_context dev); + +/** +Disables interrupts on the interrupt pin 2 of the sensor. + +Sensor needs to be in standby mode when disabling the interrupt pin 2. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_disable_interrupt2(const kx122_context dev); + +/** +Routes the interrupts to the interrupt pin 1 of the sensor. + +Sensor needs to be in standby mode when routing the interrupts. + +See datasheet for more details. + +@param dev The device context. +@param bits One or more of the KX122_INTERRUPT_T values. Combine with bitwise OR (|) +@return UPM result. +*/ +upm_result_t kx122_route_interrupt1(const kx122_context dev, uint8_t bits); + +/** +Routes the interrupts to the interrupt pin 2 of the sensor. + +Sensor needs to be in standby mode when routing the interrupts. + +See datasheet for more details. + +@param dev The device context. +@param bits One or more of the KX122_INTERRUPT_T values. Combine with bitwise OR (|) +@return UPM result. +*/ +upm_result_t kx122_route_interrupt2(const kx122_context dev, uint8_t bits); + +/** +Gets the status of the interrupts. (Has an interrupt occured) + +See datasheet for more details. + +@param dev The device context. +@return Return true if an interrupt event has occured, returns false if no interrupts have occured. +*/ +bool kx122_get_interrupt_status(const kx122_context dev); + +/** +Gets the source of the interrupt. +The value stored is one or more of the KX122_INTERRUPT_T values, depending on the interrupts +that have occured. + +If multiple interrupts have occured, and you need to determine a specific interrupt, +you can use masking to get the state of the specific interrupt: +(int_source & KX122_DATA_READY_INT) == KX122_DATA_READY_INT) + +See datasheet for more details. + +@param dev The device context. +@param data Pointer to a uint8_t variable to store the value. +@return UPM result. +*/ +upm_result_t kx122_get_interrupt_source(const kx122_context dev, uint8_t *data); + +/** +Clears latching interrupts (Wakeup, Data Ready). + +See datasheet for more details. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_clear_interrupt(const kx122_context dev); + +/** +Enables the data ready interrupt. Availability of new acceleration data is +reflected as an interrupt. + +Sensor needs to be in standby mode when enabling the interrupt. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_enable_data_ready_interrupt(const kx122_context dev); + +/** +Disables the data ready interrupt. + +Sensor needs to be in standby mode when disabling the interrupt. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_disable_data_ready_interrupt(const kx122_context dev); + +/** +Enables the buffer full interrupt. +Buffer can hold 681 sets of values (8 bit, low resolution mode) or +340 sets of values (16 bit, high resolution mode). + +Sensor needs to be in standby mode when enabling the interrupt. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_enable_buffer_full_interrupt(const kx122_context dev); + +/** +Disables the buffer full interrupt. + +Sensor needs to be in standby mode when disabling the interrupt. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_disable_buffer_full_interrupt(const kx122_context dev); + +/** +Enables the buffer. + +Sensor needs to be in standby mode when enabling the buffer. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_enable_buffer(const kx122_context dev); + +/** +Disables the buffer. + +Sensor needs to be in standby mode when disabling the buffer. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_disable_buffer(const kx122_context dev); + +/** +Initializes the buffer with the given sample watermark level, buffer resolution and buffer operating mode. +Buffer is enabled after the initialization. + +Sensor is automatically set into standby mode during the buffer initialization. +Sensor is set to active mode after initialization. + +See the other buffer functions for details about the different parameter values. + +@param dev The device context. +@param samples Amount of samples to trigger the watermark interrupt. +@param res One of the KX122_RES_T values. +@param mode One of the KX122_BUFFER_MODE_T values. +@return UPM result. +*/ +upm_result_t kx122_buffer_init(const kx122_context dev, uint samples, KX122_RES_T res, KX122_BUFFER_MODE_T mode); + +/** +Sets the buffer resolution. +Buffer resolution is indepedent of the sensor resolution. + +Sensor needs to be in standby mode when setting the buffer resolution. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_set_buffer_resolution(const kx122_context dev, KX122_RES_T res); + +/** +Sets the buffer watermark interrupt threshold. +When the buffer sample count reaches the watermark, watermark interrupt will be given. + +In low resolution mode, maxiumum number of samples is 681. In high resolution, the maximum +number is 340. + +See datasheet for more details. + +Sensor needs to be in standby mode when setting the buffer threshold. + +@param dev The device context. +@param samples Amount of samples to trigger the watermark interrupt. +@return UPM result. +*/ +upm_result_t kx122_set_buffer_threshold(const kx122_context dev, uint samples); + +/** +Sets the buffer operating mode. +The buffer can operate in FIFO,FILO or Stream mode. +The buffer gathers data, reports data and interracts with the status indicators +in a slightly different way depending on the operating mode. + +See datasheet for more details. + +Sensor needs to be in standby mode when setting the buffer mode. + +@param dev The device context. +@param mode One of the KX122_BUFFER_MODE_T values. +@return UPM result. +*/ +upm_result_t kx122_set_buffer_mode(const kx122_context dev, KX122_BUFFER_MODE_T mode); + +/** +Gets the current amount of samples in the buffer. + +@param dev The device context. +@param samples Pointer to an uint variable to store the data. +@return UPM result. +*/ +upm_result_t kx122_get_buffer_status(const kx122_context dev, uint *samples); + +/** +Gets the specified amount of raw acceleration samples from the buffer. + +Make sure the array size is atleast the amount of samples to be read. + +@param dev The device context. +@param len The amount of samples to read from the buffer. +@param x_array Pointer to an floating point array to store the x-axis data. Can be set to NULL if not wanted. +@param y_array Pointer to an floating point array to store the y-axis data. Can be set to NULL if not wanted. +@param z_array Pointer to an floating point array to store the z-axis data. Can be set to NULL if not wanted. +@return UPM result. +*/ +upm_result_t kx122_read_buffer_samples_raw(const kx122_context dev, uint len, float *x_array, float *y_array, float *z_array); + +/** +Gets the specified amount of converted (m/s^2) acceleration samples from the buffer. + +Make sure the array size is atleast the amount of samples to be read. + +@param dev The device context. +@param len The amount of samples to read from the buffer. +@param x_array Pointer to an floating point array to store the x-axis data. Can be set to NULL if not wanted. +@param y_array Pointer to an floating point array to store the y-axis data. Can be set to NULL if not wanted. +@param z_array Pointer to an floating point array to store the z-axis data. Can be set to NULL if not wanted. +@return UPM result. +*/ +upm_result_t kx122_read_buffer_samples(const kx122_context dev, uint len, float *x_array, float *y_array, float *z_array); + +/** +Clears the buffer, removing all existing samples from the buffer. + +@param dev The device context. +@return UPM result. +*/ +upm_result_t kx122_clear_buffer(const kx122_context dev); + +#ifdef __cplusplus +} +#endif diff -Nru upm-1.6.0/src/kx122/kx122.hpp upm-1.7.1/src/kx122/kx122.hpp --- upm-1.6.0/src/kx122/kx122.hpp 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kx122/kx122.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,513 @@ +/* +* The MIT License (MIT) +* +* Author: Samuli Rissanen +* 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. +*/ + +#pragma once + +#include +#include + +#include "kx122.h" + +/** + * @file kx122.hpp + * @library kx122 + * @brief C++ API for the kx122 driver + * + * @include kx122.cxx + */ + +namespace upm{ + + class KX122{ + public: + + /** + KX122 constructor + Set addr to -1 if using SPI. + When using I2C, set chip_select_pin to -1 + + If no errors occur, the device gets initialized with default values and gets set to active state. + + @param bus I2C or SPI bus to use. + @param addr I2C address of the sensor. + @param chip_select Chip select pin for SPI. + @param spi_bus_frequency Speed of the SPI communication bus in Hz. + @throws std::runtime_error on initialization failure. + */ + KX122(int bus, int addr, int chip_select, int spi_bus_frequency = DEFAULT_SPI_FREQUENCY); + + /** + KX122 destructor + */ + ~KX122(); + + /** + Initializes the sensor with given sampling rate, resolution and acceleration range. + This gets called in the constructor, so it will not need to be called unless the device is reset. + + Sensor is automatically set into standby mode during the initialization. + Sensor is set to active mode after initialization. + + @param odr One of the KX122_ODR_T values. + @param res One of the KX122_RES_T values. + @param grange One of the KX122_RANGE_T values. + @throws std::runtime_error on failure. + */ + void deviceInit(KX122_ODR_T odr, KX122_RES_T res, KX122_RANGE_T grange); + + /** + Gets the length of one sample period depending on the sampling rate of the sensor. + @return Floating point value of the sampling period, or if error occurs returns -1. + */ + float getSamplePeriod(); + + /** + Gets who am i value of the sensor. + + @return Who am I value of the sensor. + @throws std::runtime_error on failure. + */ + uint8_t getWhoAmI(); + + /** + Gets raw accelerometer data from the sensor. + @param x Pointer to a floating point variable to store the x-axis value. Can be set to NULL if not wanted. + @param y Pointer to a floating point variable to store the y-axis value. Can be set to NULL if not wanted. + @param z Pointer to a floating point variable to store the z-axis value. Can be set to NULL if not wanted. + @throws std::runtime_error on failure. + */ + void getRawAccelerationData(float *x, float *y, float *z); + + /** + Gets converted (m/s^2) accelerometer data from the sensor. + + @param x Pointer to a floating point variable to store the x-axis value. Can be set to NULL if not wanted. + @param y Pointer to a floating point variable to store the y-axis value. Can be set to NULL if not wanted. + @param z Pointer to a floating point variable to store the z-axis value. Can be set to NULL if not wanted. + @throws std::runtime_error on failure. + */ + void getAccelerationData(float *x, float *y, float *z); + + /** + Gets converted (m/s^2) accelerometer data from the sensor. + + @return Acceleration vector [X, Y, Z] + @throws std::runtime_error on failure. + */ + std::vector getAccelerationDataVector(); + + /** + Performs a sensor software reset. The software reset clears the RAM of the sensor and resets all registers + to pre-defined values. + + You should call deviceInit() after the software reset. + + See the datasheet for more details. + + @throws std::runtime_error on failure. + */ + void softwareReset(); + + /** + Enables sensor filter bypass. + + Sensor needs to be in standby mode when enabling the filter bypass. + + @throws std::runtime_error on failure. + */ + void enableIIR(); + + /** + Disables sensor filter bypass. + + Sensor needs to be in standby mode when enabling the filter bypass. + + @throws std::runtime_error on failure. + */ + void disableIIR(); + + /** + Performs a self-test of the sensor. The test applies an electrostatic force to the sensor, + simulating input acceleration. The test compares samples from all axis before and after + applying the electrostatic force to the sensor. If the amount of acceleration increases according + to the values defined in TABLE 1 of the datasheet, the test passes. + + The function prints out the minimum, maximum and values calculated during the test + for each axis, and the result of the test for each axis. + + See the datasheet for more information. + + @throws std::runtime_error on failure. + */ + void selfTest(); + + /** + Sets the sensor to the standby mode. + + @throws std::runtime_error on failure. + */ + void setSensorStandby(); + + /** + Sets the sensor to the active mode. + + @throws std::runtime_error on failure. + */ + void setSensorActive(); + + /** + Sets the ODR of the sensor. + + Sensor needs to be in standby mode when setting the ODR. + + @param odr One of the KX122_ODR_T values. + @throws std::runtime_error on failure. + */ + void setODR(KX122_ODR_T odr); + + /** + Sets the acceleration range of the sensor. + + Sensor needs to be in standby mode when setting the acceleration range value. + + @param grange One of the KX122_RANGE_T values. + @throws std::runtime_error on failure. + */ + void setGrange(KX122_RANGE_T grange); + + /** + Sets the resolution of the sensor. High resolution (16 bits) or low resolution (8 bits). + + Sensor needs to be in standby mode when setting the sensor resolution. + + When sensor is set to low resolution mode, the sensor runs in low power mode, which in turn + enables features such as averaging.(setAverage()). + + @param res One of the KX122_RES_T values. + @throws std::runtime_error on failure. + */ + void setResolution(KX122_RES_T res); + + /** + Sets the low pass filter roll off + + Sensor needs to be in standby mode when setting the filter roll off value. + + @param lpro One of the LPRO_STATE_T values. + @throws std::runtime_error on failure. + */ + void setBW(LPRO_STATE_T lpro); + + /** + Set the amount of samples to be averaged in low power mode. + + Sensor needs to be in standby mode when setting the average value. + + @param avg One of the KX122_AVG_T values. + @throws std::runtime_error on failure. + */ + void setAverage(KX122_AVG_T avg); + + /** + Installs an interrupt handler to be executed when an interrupt is detected on the interrupt pin. + + @param edge One of the mraa::Edge values. Interrupt trigger edge. + @param intp One of the KX122_INTERRUPT_PIN_T values. Specifies which interrupt pin you are setting. + @param pin The GPIO pin to use as the interrupt pin. + @param isr Pointer to the function to be called, when the interrupt occurs. + @param arg The arguments to be passed to the function. + @throws std::runtime_error on failure. + */ + void installISR(mraa::Edge edge, KX122_INTERRUPT_PIN_T intp, int pin, void (*isr)(void*), void *arg); + + /** + Uninstalls a previously installed interrupt handler. + + @param intp One of the KX122_INTERRUPT_PIN_T values. Specifies which interrupt pin handler is uninstalled. + @throws std::runtime_error on failure. + */ + void uninstallISR(KX122_INTERRUPT_PIN_T intp); + + /** + Enables interrupts on the interrupt pin 1 of the sensor. + + Pulse width = 50us (10us if data sampling rate > 1600Hz). + Using pulse mode. + + Sensor needs to be in standby mode when enabling the interrupt. + + See datasheet for more details. + + @param polarity One of the KX122_INTERRUPT_POLARITY_T values. Select the polarity of the interrupt. + @throws std::runtime_error on failure. + */ + void enableInterrupt1(KX122_INTERRUPT_POLARITY_T polarity); + + /** + Enables interrupts on the interrupt pin 2 of the sensor. + + Pulse width = 50us (10us if data sampling rate > 1600Hz). + Using pulse mode. + + Sensor needs to be in standby mode when enabling the interrupt. + + See datasheet for more details. + + @param polarity One of the KX122_INTERRUPT_POLARITY_T values. Select the polarity of the interrupt. + @throws std::runtime_error on failure. + */ + void enableInterrupt2(KX122_INTERRUPT_POLARITY_T polarity); + + /** + Disables interrupts on the interrupt pin 1 of the sensor. + + Sensor needs to be in standby mode when disabling the interrupt pin 1. + + @throws std::runtime_error on failure. + */ + void disableInterrupt1(); + + /** + Disables interrupts on the interrupt pin 2 of the sensor. + + Sensor needs to be in standby mode when disabling the interrupt pin 2. + + @throws std::runtime_error on failure. + */ + void disableInterrupt2(); + + /** + Routes the interrupts to the interrupt pin 1 of the sensor. + + Sensor needs to be in standby mode when routing the interrupts. + + See datasheet for more details. + + @param bits One or more of the KX122_INTERRUPT_T values. Combine with bitwise OR (|) + @throws std::runtime_error on failure. + */ + void routeInterrupt1(uint8_t bits); + + /** + Routes the interrupts to the interrupt pin 2 of the sensor. + + Sensor needs to be in standby mode when routing the interrupts. + + See datasheet for more details. + + @param bits One or more of the KX122_INTERRUPT_T values. Combine with bitwise OR (|) + @throws std::runtime_error on failure. + */ + void routeInterrupt2(uint8_t bits); + + /** + Gets the status of the interrupts. (Has an interrupt occurred) + + See datasheet for more details. + + @return Return true if an interrupt event has occurred, returns false if no interrupts have occurred. + */ + bool getInterruptStatus(); + + /** + Gets the source of the interrupt. + + The value stored is one or more of the KX122_INTERRUPT_T values, depending on the interrupts + that have occurred. + + If multiple interrupts have occurred, and you need to determine a specific interrupt, + you can use masking to get the state of the specific interrupt: + (int_source & KX122_DATA_READY_INT) == KX122_DATA_READY_INT) + + See datasheet for more details. + + @return Interrupt source value. + @throws std::runtime_error on failure. + */ + uint8_t getInterruptSource(); + + /** + Clears latching interrupts (Wakeup, Data Ready). + + See datasheet for more details. + + @throws std::runtime_error on failure. + */ + void clearInterrupt(); + + /** + Enables the data ready interrupt. Availability of new acceleration data is + reflected as an interrupt. + + Sensor needs to be in standby mode when enabling the interrupt. + + @throws std::runtime_error on failure. + */ + void enableDataReadyInterrupt(); + + /** + Disables the data ready interrupt. + + Sensor needs to be in standby mode when disabling the interrupt. + + @throws std::runtime_error on failure. + */ + void disableDataReadyInterrupt(); + + /** + Enables the buffer full interrupt. + Buffer can hold 681 sets of values (8 bit, low resolution mode) or + 340 sets of values (16 bit, high resolution mode). + + Sensor needs to be in standby mode when enabling the interrupt. + + @throws std::runtime_error on failure. + */ + void enableBufferFullInterrupt(); + + /** + Disables the buffer full interrupt. + + Sensor needs to be in standby mode when disabling the interrupt. + + @throws std::runtime_error on failure. + */ + void disableBufferFullInterrupt(); + + /** + Enables the buffer. + + Sensor needs to be in standby mode when enabling the buffer. + + @throws std::runtime_error on failure. + */ + void enableBuffer(); + + /** + Disables the buffer. + + Sensor needs to be in standby mode when disabling the buffer. + + @throws std::runtime_error on failure. + */ + void disableBuffer(); + + /** + Initializes the buffer with the given sample watermark level, buffer resolution and buffer operating mode. + Buffer is enabled after the initialization. + + Sensor is automatically set into standby mode during the buffer initialization. + Sensor is set to active mode after initialization. + + See the other buffer functions for details about the different parameter values. + + @param samples Amount of samples to trigger the watermark interrupt. + @param res One of the KX122_RES_T values. + @param mode One of the KX122_BUFFER_MODE_T values. + @throws std::runtime_error on failure. + */ + void bufferInit(uint samples, KX122_RES_T res, KX122_BUFFER_MODE_T mode); + + /** + Sets the buffer resolution. + Buffer resolution is independent of the sensor resolution. + + Sensor needs to be in standby mode when setting the buffer resolution. + + @throws std::runtime_error on failure. + */ + void setBufferResolution(KX122_RES_T res); + + /** + Sets the buffer watermark interrupt threshold. + When the buffer sample count reaches the watermark, watermark interrupt will be given. + + In low resolution mode, maximum number of samples is 681. In high resolution, the maximum + number is 340. + + See datasheet for more details. + + Sensor needs to be in standby mode when setting the buffer threshold. + + @param samples Amount of samples to trigger the watermark interrupt. + @throws std::runtime_error on failure. + */ + void setBufferThreshold(uint samples); + + /** + Sets the buffer operating mode. + The buffer can operate in FIFO,FILO or Stream mode. + The buffer gathers data, reports data and interacts with the status indicators + in a slightly different way depending on the operating mode. + + See datasheet for more details. + + Sensor needs to be in standby mode when setting the buffer mode. + + @param mode One of the KX122_BUFFER_MODE_T values. + @throws std::runtime_error on failure. + */ + void setBufferMode(KX122_BUFFER_MODE_T mode); + + /** + Gets the current amount of samples in the buffer. + + @return number of samples in the buffer. + @throws std::runtime_error on failure. + */ + uint getBufferStatus(); + + /** + Gets the specified amount of raw acceleration samples from the buffer. + + @param len The amount of samples to read from the buffer. + @return vector containing x, y & z-axis data + @throws std::runtime_error on failure. + */ + std::vector getRawBufferSamples(uint len); + + /** + Gets the specified amount of converted (m/s^2) acceleration samples from the buffer. + + @param len The amount of samples to read from the buffer. + @return vector containing x, y & z-axis data + @throws std::runtime_error on failure. + */ + std::vector getBufferSamples(uint len); + + /** + Clears the buffer, removing all existing samples from the buffer. + + @throws std::runtime_error on failure. + */ + void clearBuffer(); + private: + //Device context + kx122_context m_kx122; + + /* Disable implicit copy and assignment operators */ + KX122(const KX122&) = delete; + KX122 &operator=(const KX122&) = delete; + }; +} diff -Nru upm-1.6.0/src/kx122/kx122.i upm-1.7.1/src/kx122/kx122.i --- upm-1.6.0/src/kx122/kx122.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kx122/kx122.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,20 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_kx122) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "std_vector.i" +%template(floatVector) std::vector; + +%apply float *OUTPUT {float *x, float *y, float *z}; + +%{ +#include "kx122.hpp" +%} +%include "kx122.h" +%include "kx122.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/kx122/kx122.json upm-1.7.1/src/kx122/kx122.json --- upm-1.6.0/src/kx122/kx122.json 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kx122/kx122.json 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +{ + "Library": "KX122", + "Description": "Kionix KX122 accelerometer sensor library", + "Sensor Class": { + "KX122": { + "Name": "Kionix KX122 tri-axis accelerometer sensor", + "Description": "This is the UPM Module for the Kionix KX122 accelerometer sensor. + The Kionix KX122 sensor is a multifunctional sensor that provides a multitude if different functionality + in addition to the basic accelerometer functionality. The sensor has 2 interrupt pins, + that can be used to detect various interrupts. The Sensor has an additional sample buffer that can be configured.", + "Categories": ["acceleration"], + "Connections": ["i2c,spi"], + "Project Type": ["prototyping", "commercial"], + "Manufacturers": ["Kionix"], + "Examples": { + "C++":["kx122.cxx"], + "C": ["kx122.c"] + }, + "Specifications": { + "Supply Voltage (VDD)": { + "unit": "V", + "min": 1.71, + "max": 3.6 + }, + "I/O Pads Supply Voltage (IO_VDD)": { + "unit": "V", + "min": 1.7, + "max": 3.6 + }, + "Supply Current": { + "unit": "uA", + "min" : 0.9, + "max" : 146 + }, + "Operating Temperature": { + "unit": "°C", + "min": -40, + "max": 85 + } + }, + "Urls": { + "Product Pages": ["http://www.kionix.com/product/KX122-1037"], + "Datasheets": ["http://kionixfs.kionix.com/en/datasheet/KX122-1037%20Specifications%20Rev%205.0.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/kx122/kx122_registers.h upm-1.7.1/src/kx122/kx122_registers.h --- upm-1.6.0/src/kx122/kx122_registers.h 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kx122/kx122_registers.h 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,539 @@ +/* +The MIT License (MIT) +Copyright (c) 2017 Kionix Inc. + +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. +*/ + +#ifndef __KX122_REGISTERS_H__ +#define __KX122_REGISTERS_H__ +/* registers */ +// x- hp filter output +#define KX122_XHP_L 0x00 +#define KX122_XHP_H 0x01 +// y- hp filter output +#define KX122_YHP_L 0x02 +#define KX122_YHP_H 0x03 +// z- hpfilteroutput +#define KX122_ZHP_L 0x04 +#define KX122_ZHP_H 0x05 +// output register x +#define KX122_XOUT_L 0x06 +#define KX122_XOUT_H 0x07 +// output register y +#define KX122_YOUT_L 0x08 +#define KX122_YOUT_H 0x09 +// output register z +#define KX122_ZOUT_L 0x0A +#define KX122_ZOUT_H 0x0B +// communication selftest +#define KX122_COTR 0x0C +// WHO_AM_I +#define KX122_WHO_AM_I 0x0F +// current sixfacet posititions +#define KX122_TSCP 0x10 +// previous six facet positions +#define KX122_TSPP 0x11 +// This register indicates the triggering axis when a tap/double tap interrupt occurs. +#define KX122_INS1 0x12 +// This register tells witch function caused an interrupt. +#define KX122_INS2 0x13 +// This register reports the axis and direction of detected motion. +#define KX122_INS3 0x14 +// This register reports the status of the interrupt. +#define KX122_STATUS_REG 0x15 +#define KX122_INT_REL 0x17 +// Read/write control register that controls the main feature set. +#define KX122_CNTL1 0x18 +// 2' control register +#define KX122_CNTL2 0x19 +// 3' controlregister +#define KX122_CNTL3 0x1A +// This register is responsible for configuring ODR (output data rate) and filter settings +#define KX122_ODCNTL 0x1B +// This register controls the settings for the physical interrupt pin INT1 +#define KX122_INC1 0x1C +// This register controls which axis and direction of detected motion can cause an interrupt. +#define KX122_INC2 0x1D +// This register controls which axis and direction of tap/double tap can cause an interrup +#define KX122_INC3 0x1E +// This register controls routing of an interrupt reporting to physical interrupt pin INT1 +#define KX122_INC4 0x1F +// This register controls the settings for the physical interrupt pin INT2. +#define KX122_INC5 0x20 +// This register controls routing of interrupt reporting to physical interrupt pin INT2 +#define KX122_INC6 0x21 +#define KX122_TILT_TIMER 0x22 +#define KX122_WUFC 0x23 +// This register is responsible for enableing/disabling reporting of Tap/Double Tap. +#define KX122_TDTRC 0x24 +#define KX122_TDTC 0x25 +#define KX122_TTH 0x26 +#define KX122_TTL 0x27 +#define KX122_FTD 0x28 +#define KX122_STD 0x29 +#define KX122_TLT 0x2A +#define KX122_TWS 0x2B +#define KX122_FFTH 0x2C +#define KX122_FFC 0x2D +// Free Fall Control: This register contains the counter setting of the Free fall detection. +#define KX122_FFCNTL 0x2E +#define KX122_ATH 0x30 +#define KX122_TILT_ANGLE_LL 0x32 +#define KX122_TILT_ANGLE_HL 0x33 +// This register sets the Hysteresis that is placed in between the Screen Rotation states +#define KX122_HYST_SET 0x34 +// Low Power Control sets the number of samples of accelerometer output to be average +#define KX122_LP_CNTL 0x35 +// Read/write control register that controls the buffer sample threshold +#define KX122_BUF_CNTL1 0x3A +// Read/write control register that controls sample buffer operation +#define KX122_BUF_CNTL2 0x3B +// This register reports the status of the sample buffer +#define KX122_BUF_STATUS_1 0x3C +// This register reports the status of the sample buffer trigger function +#define KX122_BUF_STATUS_2 0x3D +#define KX122_BUF_CLEAR 0x3E +#define KX122_BUF_READ 0x3F +// When 0xCA is written to this register, the MEMS self-test function is enabled. Electrostatic-actuation of the accelerometer, results in a DC shift of the X, Y and Z axis outputs. Writing 0x00 to this register will return the accelerometer to normal operation +#define KX122_SELF_TEST 0x60 +// WHO_AM_I +#define KX112_WHO_AM_I 0x0F +// WHO_AM_I +#define KX123_WHO_AM_I 0x0F +// WHO_AM_I +#define KX124_WHO_AM_I 0x0F +/* registers bits */ +// before set +#define KX122_COTR_DCSTR_BEFORE (0x55 << 0) +// after set +#define KX122_COTR_DCSTR_AFTER (0xAA << 0) +// WHO_AM_I -value for KX122 +#define KX122_WHO_AM_I_WIA_ID (0x1B << 0) +// x-left +#define KX122_TSCP_LE (0x01 << 5) +// x+right +#define KX122_TSCP_RI (0x01 << 4) +// y-down +#define KX122_TSCP_DO (0x01 << 3) +// y+up +#define KX122_TSCP_UP (0x01 << 2) +// z-facedown +#define KX122_TSCP_FD (0x01 << 1) +// z+faceup +#define KX122_TSCP_FU (0x01 << 0) +// x-left +#define KX122_TSPP_LE (0x01 << 5) +// x+right +#define KX122_TSPP_RI (0x01 << 4) +// y-down +#define KX122_TSPP_DO (0x01 << 3) +// y+up +#define KX122_TSPP_UP (0x01 << 2) +// z-facedown +#define KX122_TSPP_FD (0x01 << 1) +// z+faceup +#define KX122_TSPP_FU (0x01 << 0) +// x- +#define KX122_INS1_TLE (0x01 << 5) +// x+ +#define KX122_INS1_TRI (0x01 << 4) +// y- +#define KX122_INS1_TDO (0x01 << 3) +// y+ +#define KX122_INS1_TUP (0x01 << 2) +// z- +#define KX122_INS1_TFD (0x01 << 1) +// z+ +#define KX122_INS1_TFU (0x01 << 0) +// Free fall. This bit is cleared when the interrupt latch release register (INL) is read.. +#define KX122_INS2_FFS (0x01 << 7) +// indicates buffer full interrupt. Automatically cleared when buffer is read. +#define KX122_INS2_BFI (0x01 << 6) +// Watermark interrupt, bit is set to one when FIFO has filled up to the value stored in the sample bits.This bit is automatically cleared when FIFO/FILO is read and the content returns to a value below the value stored in the sample bits. +#define KX122_INS2_WMI (0x01 << 5) +// indicates that new acceleration data (0x06h to 0x0Bh) is available. This bit is cleared when acceleration data is read or the interrupt release register INT_REL is read. +#define KX122_INS2_DRDY (0x01 << 4) +// no tap +#define KX122_INS2_TDTS_NOTAP (0x00 << 2) +// single tap event +#define KX122_INS2_TDTS_SINGLE (0x01 << 2) +// double tap event +#define KX122_INS2_TDTS_DOUBLE (0x02 << 2) +// do not exist +#define KX122_INS2_TDTS_NA (0x03 << 2) +// Status of Wake up. This bit is cleared when the interrupt release register INT_REL is read. +#define KX122_INS2_WUFS (0x01 << 1) +// Tilt Position status. This bit is cleared when the interrupt release register INT_REL is read. +#define KX122_INS2_TPS (0x01 << 0) +// x- +#define KX122_INS3_XNWU (0x01 << 5) +// x+ +#define KX122_INS3_XPWU (0x01 << 4) +// y- +#define KX122_INS3_YNWU (0x01 << 3) +// y+ +#define KX122_INS3_YPWU (0x01 << 2) +// z- +#define KX122_INS3_ZNWU (0x01 << 1) +// z+ +#define KX122_INS3_ZPWU (0x01 << 0) +// INT reports the combined (OR) interrupt information of all features. +#define KX122_STATUS_REG_INT (0x01 << 4) +// controls the operating mode of the KX122. +#define KX122_CNTL1_PC1 (0x01 << 7) +// determines the performance mode of the KX122. The noise varies with ODR, RES and different LP_CNTL settings possibly reducing the effective resolution. +#define KX122_CNTL1_RES (0x01 << 6) +// enables the reporting of the availability of new acceleration data as an interrupt +#define KX122_CNTL1_DRDYE (0x01 << 5) +// 2g range +#define KX122_CNTL1_GSEL_2G (0x00 << 3) +// 4g range +#define KX122_CNTL1_GSEL_4G (0x01 << 3) +// 8g range +#define KX122_CNTL1_GSEL_8G (0x02 << 3) +// not valid settings +#define KX122_CNTL1_GSEL_NA (0x03 << 3) +// enables the Directional Tap function that will detect single and double tap events. +#define KX122_CNTL1_TDTE (0x01 << 2) +// enables the Wake Up (motion detect) function +#define KX122_CNTL1_WUFE (0x01 << 1) +// enables the Tilt Position function that will detect changes in device orientation. +#define KX122_CNTL1_TPE (0x01 << 0) +// initiates software reset, which performs the RAM reboot routine +#define KX122_CNTL2_SRST (0x01 << 7) +// command test control +#define KX122_CNTL2_COTC (0x01 << 6) +// x- +#define KX122_CNTL2_LEM (0x01 << 5) +// x+ +#define KX122_CNTL2_RIM (0x01 << 4) +// y- +#define KX122_CNTL2_DOM (0x01 << 3) +// y+ +#define KX122_CNTL2_UPM (0x01 << 2) +// z- +#define KX122_CNTL2_FDM (0x01 << 1) +// z+ +#define KX122_CNTL2_FUM (0x01 << 0) +// 1.5Hz +#define KX122_CNTL3_OTP_1P563 (0x00 << 6) +// 6.25Hz +#define KX122_CNTL3_OTP_6P25 (0x01 << 6) +// 12.5Hz +#define KX122_CNTL3_OTP_12P5 (0x02 << 6) +// 50Hz +#define KX122_CNTL3_OTP_50 (0x03 << 6) +// 50Hz +#define KX122_CNTL3_OTDT_50 (0x00 << 3) +// 100Hz +#define KX122_CNTL3_OTDT_100 (0x01 << 3) +// 200Hz +#define KX122_CNTL3_OTDT_200 (0x02 << 3) +// 400Hz +#define KX122_CNTL3_OTDT_400 (0x03 << 3) +// 12.5Hz +#define KX122_CNTL3_OTDT_12P5 (0x04 << 3) +// 25Hz +#define KX122_CNTL3_OTDT_25 (0x05 << 3) +// 800Hz +#define KX122_CNTL3_OTDT_800 (0x06 << 3) +// 1600Hz +#define KX122_CNTL3_OTDT_1600 (0x07 << 3) +// 0.78Hz +#define KX122_CNTL3_OWUF_0P781 (0x00 << 0) +// 1.563Hz +#define KX122_CNTL3_OWUF_1P563 (0x01 << 0) +// 3.125Hz +#define KX122_CNTL3_OWUF_3P125 (0x02 << 0) +// 6.25Hz +#define KX122_CNTL3_OWUF_6P25 (0x03 << 0) +// 12.5Hz +#define KX122_CNTL3_OWUF_12P5 (0x04 << 0) +// 25Hz +#define KX122_CNTL3_OWUF_25 (0x05 << 0) +// 50Hz +#define KX122_CNTL3_OWUF_50 (0x06 << 0) +// 100Hz +#define KX122_CNTL3_OWUF_100 (0x07 << 0) +// filtering applied +#define KX122_ODCNTL_IIR_BYPASS_APPLY (0x00 << 7) +// filter bypassed +#define KX122_ODCNTL_IIR_BYPASS_BYPASS (0x01 << 7) +// filter corner frequency set to ODR/9 +#define KX122_ODCNTL_LPRO_ODR_9 (0x00 << 6) +// filter corner frequency set to ODR/2 +#define KX122_ODCNTL_LPRO_ODR_2 (0x01 << 6) +// 12.5Hz +#define KX122_ODCNTL_OSA_12P5 (0x00 << 0) +// 25Hz +#define KX122_ODCNTL_OSA_25 (0x01 << 0) +// 50Hz +#define KX122_ODCNTL_OSA_50 (0x02 << 0) +// 100Hz +#define KX122_ODCNTL_OSA_100 (0x03 << 0) +// 200Hz +#define KX122_ODCNTL_OSA_200 (0x04 << 0) +// 400Hz +#define KX122_ODCNTL_OSA_400 (0x05 << 0) +// 800Hz +#define KX122_ODCNTL_OSA_800 (0x06 << 0) +// 1600Hz +#define KX122_ODCNTL_OSA_1600 (0x07 << 0) +// 0.78Hz +#define KX122_ODCNTL_OSA_0P781 (0x08 << 0) +// 1.563Hz +#define KX122_ODCNTL_OSA_1P563 (0x09 << 0) +// 3.125Hz +#define KX122_ODCNTL_OSA_3P125 (0x0A << 0) +// 6.25Hz +#define KX122_ODCNTL_OSA_6P25 (0x0B << 0) +// 3200Hz +#define KX122_ODCNTL_OSA_3200 (0x0C << 0) +// 6400Hz +#define KX122_ODCNTL_OSA_6400 (0x0D << 0) +// 12800Hz +#define KX122_ODCNTL_OSA_12800 (0x0E << 0) +// 25600Hz +#define KX122_ODCNTL_OSA_25600 (0x0F << 0) +// pulse 50us, 10us 1600ODR and over +#define KX122_INC1_PWSEL1_50US_10US (0x00 << 6) +// 1*OSA period +#define KX122_INC1_PWSEL1_1XOSA (0x01 << 6) +// 2*OSA period +#define KX122_INC1_PWSEL1_2XOSA (0x02 << 6) +// 4*OSA period +#define KX122_INC1_PWSEL1_4XOSA (0x03 << 6) +// enables/disables the physical interrupt +#define KX122_INC1_IEN1 (0x01 << 5) +// sets the polarity of the physical interrupt pin +#define KX122_INC1_IEA1 (0x01 << 4) +// sets the response of the physical interrupt pin +#define KX122_INC1_IEL1 (0x01 << 3) +// sets the polarity of Self Test +#define KX122_INC1_STPOL (0x01 << 1) +// sets the 3-wire SPI interface +#define KX122_INC1_SPI3E (0x01 << 0) +// OR combination between selected directions +#define KX122_INC2_AOI_OR (0x00 << 6) +// AND combination between selected axes +#define KX122_INC2_AOI_AND (0x01 << 6) +// x negative (x-): 0 = disabled, 1 = enabled +#define KX122_INC2_XNWUE (0x01 << 5) +// x positive (x+): 0 = disabled, 1 = enabled +#define KX122_INC2_XPWUE (0x01 << 4) +// y negative (y-): 0 = disabled, 1 = enabled +#define KX122_INC2_YNWUE (0x01 << 3) +// y positive (y+): 0 = disabled, 1 = enabled +#define KX122_INC2_YPWUE (0x01 << 2) +// z negative (z-): 0 = disabled, 1 = enabled +#define KX122_INC2_ZNWUE (0x01 << 1) +// z positive (z+): 0 = disabled, 1 = enabled +#define KX122_INC2_ZPWUE (0x01 << 0) +// x negative (x-): 0 = disabled, 1 = enabled +#define KX122_INC3_TLEM (0x01 << 5) +// x positive (x+): 0 = disabled, 1 = enabled +#define KX122_INC3_TRIM (0x01 << 4) +// y negative (y-): 0 = disabled, 1 = enabled +#define KX122_INC3_TDOM (0x01 << 3) +// y positive (y+): 0 = disabled, 1 = enabled +#define KX122_INC3_TUPM (0x01 << 2) +// z negative (z-): 0 = disabled, 1 = enabled +#define KX122_INC3_TFDM (0x01 << 1) +// z positive (z+): 0 = disabled, 1 = enabled +#define KX122_INC3_TFUM (0x01 << 0) +// Free fall interrupt reported on physical interrupt INT1 +#define KX122_INC4_FFI1 (0x01 << 7) +// Buffer full interrupt reported on physical interrupt pin INT1 +#define KX122_INC4_BFI1 (0x01 << 6) +// Watermark interrupt reported on physical interrupt pin INT1 +#define KX122_INC4_WMI1 (0x01 << 5) +// Data ready interrupt reported on physical interrupt pin INT1 +#define KX122_INC4_DRDYI1 (0x01 << 4) +// Tap/Double Tap interrupt reported on physical interrupt pin INT1 +#define KX122_INC4_TDTI1 (0x01 << 2) +// Wake-Up (motion detect) interrupt reported on physical interrupt pin INT1 +#define KX122_INC4_WUFI1 (0x01 << 1) +// Tilt position interrupt reported on physical interrupt pin INT1 +#define KX122_INC4_TPI1 (0x01 << 0) +// pulse 50us, 10us 1600ODR and over +#define KX122_INC5_PWSEL2_50US_10US (0x00 << 6) +// 1*OSA period +#define KX122_INC5_PWSEL2_1XOSA (0x01 << 6) +// 2*OSA period +#define KX122_INC5_PWSEL2_2XOSA (0x02 << 6) +// 4*OSA period +#define KX122_INC5_PWSEL2_4XOSA (0x03 << 6) +// enables/disables the physical interrupt +#define KX122_INC5_IEN2 (0x01 << 5) +// sets the polarity of the physical interrupt pin +#define KX122_INC5_IEA2 (0x01 << 4) +// sets the response of the physical interrupt pin +#define KX122_INC5_IEL2 (0x01 << 3) +// Interrupt source automatic clear at interup 2 trailing edge +#define KX122_INC5_ACLR2 (0x01 << 1) +// Interrupt source automatic clear at interup 1 trailing edge +#define KX122_INC5_ACLR1 (0x01 << 0) +// FFI2 Free fall interrupt reported on physical interrupt INT2 +#define KX122_INC6_FFI2 (0x01 << 7) +// BFI2 Buffer full interrupt reported on physical interrupt pin INT2 +#define KX122_INC6_BFI2 (0x01 << 6) +// WMI2 - Watermark interrupt reported on physical interrupt pin INT2 +#define KX122_INC6_WMI2 (0x01 << 5) +// DRDYI2 Data ready interrupt reported on physical interrupt pin INT2 +#define KX122_INC6_DRDYI2 (0x01 << 4) +// TDTI2 - Tap/Double Tap interrupt reported on physical interrupt pin INT2 +#define KX122_INC6_TDTI2 (0x01 << 2) +// WUFI2 Wake-Up (motion detect) interrupt reported on physical interrupt pin INT2 +#define KX122_INC6_WUFI2 (0x01 << 1) +// TPI2 Tilt position interrupt reported on physical interrupt pin INT2 +#define KX122_INC6_TPI2 (0x01 << 0) +// enables/disables the double tap interrupt +#define KX122_TDTRC_DTRE (0x01 << 1) +// enables/disables single tap interrupt +#define KX122_TDTRC_STRE (0x01 << 0) +// Free fall engine enable +#define KX122_FFCNTL_FFIE (0x01 << 7) +// Free fall interrupt latch/un-latch control +#define KX122_FFCNTL_ULMODE (0x01 << 6) +// Debounce methodology control +#define KX122_FFCNTL_DCRM (0x01 << 3) +// 12.5Hz +#define KX122_FFCNTL_OFFI_12P5 (0x00 << 0) +// 25Hz +#define KX122_FFCNTL_OFFI_25 (0x01 << 0) +// 50Hz +#define KX122_FFCNTL_OFFI_50 (0x02 << 0) +// 100Hz +#define KX122_FFCNTL_OFFI_100 (0x03 << 0) +// 200Hz +#define KX122_FFCNTL_OFFI_200 (0x04 << 0) +// 400Hz +#define KX122_FFCNTL_OFFI_400 (0x05 << 0) +// 800Hz +#define KX122_FFCNTL_OFFI_800 (0x06 << 0) +// 1600Hz +#define KX122_FFCNTL_OFFI_1600 (0x07 << 0) +// No Averaging +#define KX122_LP_CNTL_AVC_NO_AVG (0x00 << 4) +// 2 Samples Averaged +#define KX122_LP_CNTL_AVC_2_SAMPLE_AVG (0x01 << 4) +// 4 Samples Averaged +#define KX122_LP_CNTL_AVC_4_SAMPLE_AVG (0x02 << 4) +// 8 Samples Averaged +#define KX122_LP_CNTL_AVC_8_SAMPLE_AVG (0x03 << 4) +// 16 Samples Averaged (default) +#define KX122_LP_CNTL_AVC_16_SAMPLE_AVG (0x04 << 4) +// 32 Samples Averaged +#define KX122_LP_CNTL_AVC_32_SAMPLE_AVG (0x05 << 4) +// 64 Samples Averaged +#define KX122_LP_CNTL_AVC_64_SAMPLE_AVG (0x06 << 4) +// 128 Samples Averaged +#define KX122_LP_CNTL_AVC_128_SAMPLE_AVG (0x07 << 4) +#define KX122_BUF_CNTL1_SMP_TH0_7 (0xFF << 0) +// controls activation of the sample buffer +#define KX122_BUF_CNTL2_BUFE (0x01 << 7) +// determines the resolution of the acceleration data samples collected by the sample +#define KX122_BUF_CNTL2_BRES (0x01 << 6) +// buffer full interrupt enable bit +#define KX122_BUF_CNTL2_BFIE (0x01 << 5) +// watermark level bits 8 and 9 +#define KX122_BUF_CNTL2_SMP_TH8_9 (0x0C << 2) +// The buffer collects 681 sets of 8-bit low resolution values or 339 sets of 16-bit high resolution values and then stops collecting data, collecting new data only when the buffer is not full +#define KX122_BUF_CNTL2_BUF_M_FIFO (0x00 << 0) +// The buffer holds the last 681 sets of 8-bit low resolution values or 339 sets of 16-bit high resolution values. Once the buffer is full, the oldest data is discarded to make room for newer data. +#define KX122_BUF_CNTL2_BUF_M_STREAM (0x01 << 0) +// When a trigger event occurs, the buffer holds the last data set of SMP[9:0] samples before the trigger event and then continues to collect data until full. New data is collected only when the buffer is not full. +#define KX122_BUF_CNTL2_BUF_M_TRIGGER (0x02 << 0) +// The buffer holds the last 681 sets of 8-bit low resolution values or 339 sets of 16-bit high resolution values. Once the buffer is full, the oldest data is discarded to make room for newer data. Reading from the buffer in this mode will return the most recent data first. +#define KX122_BUF_CNTL2_BUF_M_FILO (0x03 << 0) +#define KX122_BUF_STATUS_1_SMP_LEV0_7 (0xFF << 0) +// reports the status of the buffers trigger function if this mode has been selected +#define KX122_BUF_STATUS_2_BUF_TRIG (0x01 << 7) +// level High mask +#define KX122_BUF_STATUS_2_SMP_LEV8_10 (0x07 << 0) +// MEMS Test OFF +#define KX122_SELF_TEST_MEMS_TEST_OFF (0x00 << 0) +// MEMS Test ON +#define KX122_SELF_TEST_MEMS_TEST_ON (0xCA << 0) +// WHO_AM_I -value for KX112 +#define KX112_WHO_AM_I_WIA_ID (0x22 << 0) +// WHO_AM_I -value for KX123 +#define KX123_WHO_AM_I_WIA_ID (0x20 << 0) +// WHO_AM_I -value for KX124 +#define KX124_WHO_AM_I_WIA_ID (0x28 << 0) + /*registers bit masks */ + +#define KX122_COTR_DCSTR_MASK 0xFF + +#define KX122_WHO_AM_I_WIA_MASK 0xFF +// status of tap/double tap, bit is released when interrupt release register INT_REL is read. +#define KX122_INS2_TDTS_MASK 0x0C +// selects the acceleration range of the accelerometer outputs +#define KX122_CNTL1_GSEL_MASK 0x18 +// sets the output data rate for the Tilt Position function +#define KX122_CNTL3_OTP_MASK 0xC0 +// sets the output data rate for the Directional TapTM function +#define KX122_CNTL3_OTDT_MASK 0x38 +// sets the output data rate for the general motion detection function and the high-pass filtered outputs +#define KX122_CNTL3_OWUF_MASK 0x07 +// filter bypass mode +#define KX122_ODCNTL_IIR_BYPASS_MASK 0x80 +// low-pass filter roll off control +#define KX122_ODCNTL_LPRO_MASK 0x40 +// acceleration output data rate. +#define KX122_ODCNTL_OSA_MASK 0x0F +// Pulse interrupt 1 width configuration +#define KX122_INC1_PWSEL1_MASK 0xC0 +// AND OR configuration for motion detection +#define KX122_INC2_AOI_MASK 0x40 +#define KX122_INC2_WUE_MASK 0x3F +#define KX122_INC3_TM_MASK 0x3F +// Pulse interrupt 2 width configuration +#define KX122_INC5_PWSEL2_MASK 0xC0 +// Output Data Rate at which the Free fall engine performs its function. +#define KX122_FFCNTL_OFFI_MASK 0x07 +#define KX122_HYST_SET_HYST_MASK 0x3F +// Averaging Filter Control +#define KX122_LP_CNTL_AVC_MASK 0x70 + +#define KX122_BUF_CNTL1_SMP_TH0_MASK 0xFF +#define KX122_BUF_CNTL1_SMP_TH0_7_MASK 0xFF + +#define KX122_BUF_CNTL2_SMP_TH8_MASK 0x0C +#define KX122_BUF_CNTL2_SMP_TH8_9_MASK 0x0C +// selects the operating mode of the sample buffer +#define KX122_BUF_CNTL2_BUF_M_MASK 0x03 + +#define KX122_BUF_STATUS_1_SMP_LEV0_MASK 0xFF +#define KX122_BUF_STATUS_1_SMP_LEV0_7_MASK 0xFF + +#define KX122_BUF_STATUS_2_SMP_LEV8_MASK 0x07 +#define KX122_BUF_STATUS_2_SMP_LEV8_10_MASK 0x07 + +#define KX122_SELF_TEST_MEMS_TEST_MASK 0xFF + +#define KX112_WHO_AM_I_WIA_MASK 0xFF + +#define KX123_WHO_AM_I_WIA_MASK 0xFF + +#define KX124_WHO_AM_I_WIA_MASK 0xFF +#endif + diff -Nru upm-1.6.0/src/kxcjk1013/javaupm_kxcjk1013.i upm-1.7.1/src/kxcjk1013/javaupm_kxcjk1013.i --- upm-1.6.0/src/kxcjk1013/javaupm_kxcjk1013.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/kxcjk1013/javaupm_kxcjk1013.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_kxcjk1013 -%include "../upm.i" - -%{ - #include "kxcjk1013.hpp" -%} - -%include "kxcjk1013.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_kxcjk1013) diff -Nru upm-1.6.0/src/kxcjk1013/jsupm_kxcjk1013.i upm-1.7.1/src/kxcjk1013/jsupm_kxcjk1013.i --- upm-1.6.0/src/kxcjk1013/jsupm_kxcjk1013.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/kxcjk1013/jsupm_kxcjk1013.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_kxcjk1013 -%include "../upm.i" - -%{ - #include "kxcjk1013.hpp" -%} - -%include "kxcjk1013.hpp" diff -Nru upm-1.6.0/src/kxcjk1013/kxcjk1013.json upm-1.7.1/src/kxcjk1013/kxcjk1013.json --- upm-1.6.0/src/kxcjk1013/kxcjk1013.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/kxcjk1013/kxcjk1013.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "kxcjk1013", - "Description": "KXCJK1013 Tri-axis Digital Accelerometer API", - "Sensor Class": - { - "KXCJK1013": - { - "Name": "Tri-axis Digital Accelerometer", - "Description": "he KXCJK is a tri-axis +/-2g, +/-4g or +/-8g silicon micromachined accelerometer.", - "Aliases": ["kxcjk1013"], - "Categories": ["accelerometer"], - "Connections": ["iio", "i2c"], - "Project Type": ["imu", "prototyping"], - "Manufacturers": ["kionix"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["kxcjk1013.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.71, "typ": 2.6, "high": 3.6}, - "Operating Current": {"unit": "uA", "low": 0.9, "high": 135}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - - }, - "Urls" : - { - "Product Pages": [], - "Datasheets": ["http://kionixfs.kionix.com/en/datasheet/KXCJK-1013%20Specifications%20Rev%202.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "kxcjk1013", + "Description": "KXCJK1013 Tri-axis Digital Accelerometer API", + "Sensor Class": + { + "KXCJK1013": + { + "Name": "Tri-axis Digital Accelerometer", + "Description": "he KXCJK is a tri-axis +/-2g, +/-4g or +/-8g silicon micromachined accelerometer.", + "Aliases": ["kxcjk1013"], + "Categories": ["accelerometer"], + "Connections": ["iio", "i2c"], + "Project Type": ["imu", "prototyping"], + "Manufacturers": ["kionix"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["kxcjk1013.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.71, "typ": 2.6, "high": 3.6}, + "Operating Current": {"unit": "uA", "low": 0.9, "high": 135}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + + }, + "Urls" : + { + "Product Pages": [], + "Datasheets": ["http://kionixfs.kionix.com/en/datasheet/KXCJK-1013%20Specifications%20Rev%202.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/kxcjk1013/pyupm_kxcjk1013.i upm-1.7.1/src/kxcjk1013/pyupm_kxcjk1013.i --- upm-1.6.0/src/kxcjk1013/pyupm_kxcjk1013.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/kxcjk1013/pyupm_kxcjk1013.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module pyupm_kxcjk1013 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - - -%include "kxcjk1013.hpp" -%{ - #include "kxcjk1013.hpp" -%} diff -Nru upm-1.6.0/src/kxtj3/CMakeLists.txt upm-1.7.1/src/kxtj3/CMakeLists.txt --- upm-1.6.0/src/kxtj3/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kxtj3/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,8 @@ +upm_mixed_module_init (NAME kxtj3 + DESCRIPTION "Tri-Axis Accelerometer" + C_HDR kxtj3.h kxtj3_registers.h + C_SRC kxtj3.c + CPP_HDR kxtj3.hpp + CPP_SRC kxtj3.cxx + CPP_WRAPS_C + REQUIRES mraa utilities-c) diff -Nru upm-1.6.0/src/kxtj3/kxtj3.c upm-1.7.1/src/kxtj3/kxtj3.c --- upm-1.6.0/src/kxtj3/kxtj3.c 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kxtj3/kxtj3.c 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,1095 @@ +/* +* 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 +#include +#include "kxtj3.h" +#include "upm_utilities.h" + +#define SW_RESET_MAX_LOOP_COUNT 10 +#define SW_RESET_READ_WAIT_MICRO_S 50000 + +#define SELF_TEST_SAMPLE_COUNT 10 +#define SELF_TEST_DIFFERENCE_THRESHOLD 0.5f + +#define DATA_BUFFER_LENGTH 6 + +/** + * @brief Acceleration steps in (g) for each range setting. + * Used to calculate acceleration_scale to convert + * raw data to readable acceleration data. + */ +#define RANGE_2G_8BIT_STEP 0.016f +#define RANGE_4G_8BIT_STEP 0.031f +#define RANGE_8G_8BIT_STEP 0.0625f +#define RANGE_16G_8BIT_STEP 0.125f + +#define RANGE_2G_12BIT_STEP 0.001f +#define RANGE_4G_12BIT_STEP 0.002f +#define RANGE_8G_12BIT_STEP 0.0039f +#define RANGE_16G_12BIT_STEP 0.0078f + +#define RANGE_8G_14BIT_STEP 0.00098f +#define RANGE_16G_14BIT_STEP 0.00195f +#define EARTH_GRAVITY 9.81f + +/** + * @brief Map of ODR register values to ODR in Hz + * used to calculate sampling time in seconds + */ +struct odr_map_t +{ + uint8_t odr_reg_bit; + float odr_in_Hz; +}; + +/** + * @brief ODR register values maping with ODR in Hz + */ +const struct odr_map_t odr_map_in_Hz[] = { + {KXTJ3_ODR_0P781, 0.781f}, + {KXTJ3_ODR_1P563, 1.563f}, + {KXTJ3_ODR_3P125, 3.125f}, + {KXTJ3_ODR_6P25, 6.25f}, + {KXTJ3_ODR_12P5, 12.5f}, + {KXTJ3_ODR_25, 25.0f}, + {KXTJ3_ODR_50, 50.0f}, + {KXTJ3_ODR_100, 100.0f}, + {KXTJ3_ODR_200, 200.0f}, + {KXTJ3_ODR_400, 400.0f}, + {KXTJ3_ODR_800, 800.0f}, + {KXTJ3_ODR_1600, 1600.0f}}; +/** + * @brief ODR register values maping with ODR in Hz for + * wake-up function + */ +const struct odr_map_t odr_map_in_Hz_wakeup[] = { + {KXTJ3_ODR_WAKEUP_0P781, 0.781f}, + {KXTJ3_ODR_WAKEUP_1P563, 1.563f}, + {KXTJ3_ODR_WAKEUP_3P125, 3.125f}, + {KXTJ3_ODR_WAKEUP_6P25, 6.25f}, + {KXTJ3_ODR_WAKEUP_12P5, 12.5f}, + {KXTJ3_ODR_WAKEUP_25, 25.0f}, + {KXTJ3_ODR_WAKEUP_50, 50.0f}, + {KXTJ3_ODR_WAKEUP_100, 100.0f}}; + +/** + * @brief Coordinates structure + */ +struct Coordinates +{ + float x, y, z; +}; + +/** +@brief Inits the I2C connections and returns status of initialization + +@param dev The sensor context +@param bus I2C bus number +@param addr I2C addr of the sensor +@return true if initialization successful or false for failure +*/ +static bool kxtj3_check_mraa_i2c_connection(kxtj3_context dev, int bus, uint8_t addr); + +/** +@brief Checks if the sensor WHO_AM_I value is correct + +@param dev The sensor context +@return true if value correct, or false if mismatch +*/ +static bool kxtj3_check_who_am_i(kxtj3_context dev); + +/** +@brief Calculates the ODR sample time from an ODR register value + +@param odr One of KXTJ3_ODR_T values of ODR register configurations +@return the float time value +*/ +static float kxtj3_odr_val_to_sec(KXTJ3_ODR_T odr); + +/** +@brief Calculates the ODR sample time from an ODR register value for wake-up function + +@param odr One of KXTJ3_ODR_WAKEUP_T values of ODR register configurations for wake-up +@return the float time value +*/ +static float kxtj3_odr_val_to_sec_wakeup(KXTJ3_ODR_WAKEUP_T odr); + +/** +@brief Sets the sensor default values for ODR, resolution (with its scale), +G range (both normal and wake-up modes) + +@param dev The sensor context +*/ +static void kxtj3_set_default_values(const kxtj3_context dev); + +/** +@brief Read the value of a provided register + +@param dev The sensor context +@param reg The register address to read from +@param data A pointer to variable for storing the value read +@return A UPM result +*/ +static upm_result_t kxtj3_read_register(const kxtj3_context dev, uint8_t reg, uint8_t *data); + +/** +@brief Read the values starting from a provided register, of specific length + +@param dev The sensor context +@param reg The register address to start reading from +@param data A pointer to variable for storing the value read +@param len The number of bytes to read +@return A UPM result +*/ +static upm_result_t kxtj3_read_registers(const kxtj3_context dev, uint8_t reg, uint8_t *data, int len); + +/** +@brief Writes a value to a provided register + +@param dev The sensor context +@param reg The register address to write to +@param val byte of data to write +@return A UPM result +*/ +static upm_result_t kxtj3_write_register(const kxtj3_context dev, uint8_t reg, uint8_t val); + +/** +@brief Sets a specific bit on in a provided register + +@param dev The sensor context +@param reg register to write into +@param bit_mask The bit to set, as a register mask +@return A UPM result +*/ +static upm_result_t kxtj3_set_bit_on(const kxtj3_context dev, uint8_t reg, uint8_t bit_mask); + +/** +@brief Clear a specific bit (set off) in a provided register + +@param dev The sensor context +@param reg register address to write into +@param bit_mask The bit to set, as a register mask +@return A UPM result +*/ +static upm_result_t kxtj3_set_bit_off(const kxtj3_context dev, uint8_t reg, uint8_t bit_mask); + +/** +@brief Sets a register value or its bits according to a provided mask + +@param dev The sensor context +@param reg The register address to write to +@param val byte data to write +@param bit_mask The bits or register mask +@return A UPM result +*/ +static upm_result_t kxtj3_set_bits_with_mask(const kxtj3_context dev, uint8_t reg, uint8_t val, uint8_t bit_mask); + +/** +@brief Checks whether a given G range setting uses 14-bit mode + +@param g_range One of KXTJ3_G_RANGE_T value for available acceleration settings +@return true if range is 14-bit based, false otherwise +*/ +static bool kxtj3_is_14_bit_range(KXTJ3_G_RANGE_T g_range_mode); + +/** +@brief Maps the acceleration_scale (that is used to calculate the acceleration data in g unit) +with the G range and resolution mode. Changes the acceleration_scale value in sensor context. + +@param dev The sensor context +@param g_range The G range setting, one of KXTJ3_G_RANGE_T values +*/ +static void kxtj3_map_g_range_to_resolution(kxtj3_context dev, KXTJ3_G_RANGE_T g_range); +/** +@brief Calculates the average of coordinates for a sample of data (SELF_TEST_SAMPLE_COUNT). +This is used by the self-test functionality. + +@param dev The sensor context +@return Coordinates struct that contains value of x, y and z +*/ +static struct Coordinates kxtj3_get_sample_averaged_data(kxtj3_context dev); + +/** +@brief Check whether the self-test acceleration data difference is within the permitted threshold (0.5g) + +@param before The Coordinates struct before the self-test +@param during The Coordinates struct of the self-test +@return true if difference is below threshold, false otherwise +*/ +static bool kxtj3_check_self_test_difference(struct Coordinates before, struct Coordinates during); + +/** +@brief Checks the digital communication register (DCST_RESP) register value with an expected value + +@param dev The sensor context +@param expected_val The expected byte value of the register +@return true if values match, false otherwise. +*/ +static bool kxtj3_check_digital_communication_reg_value(kxtj3_context dev, uint8_t expected_val); + +/** +@brief Gets the count value from a given time (in seconds) for the wake-up function. +Used by the wake-up motion counter and non-activity counter before another wake-up functions. + +@param dev The sensor context +@param time_sec Time in seconds to be converted +@return the count value as a uint8_t +*/ +static uint8_t kxtj3_get_wakeup_count_from_time_sec(kxtj3_context dev, float time_sec); + +/** +@brief Gets the count value from a given acceleration threshold (in g) for the wake-up function. +Used by wake-up threshold counter functionality. + +@param dev The sensor context +@param g_threshold acceleration value in g to be converted +@return the count value as a uint16_t (expected range up to 4096) +*/ +static uint16_t kxtj3_get_wakeup_threshold_count_from_g(kxtj3_context dev, float g_threshold); + +// Register Read/Write helper functions +static upm_result_t kxtj3_read_register(const kxtj3_context dev, uint8_t reg, uint8_t *data) +{ + int value = mraa_i2c_read_byte_data(dev->i2c, reg); + if (value == -1) + { + printf("%s: mraa_i2c_read_byte_data() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + *data = (uint8_t)value; + return UPM_SUCCESS; +} + +static upm_result_t kxtj3_read_registers(const kxtj3_context dev, uint8_t reg, uint8_t *data, int len) +{ + if (mraa_i2c_read_bytes_data(dev->i2c, reg, data, len) != (int)len) + return UPM_ERROR_OPERATION_FAILED; + + return UPM_SUCCESS; +} + +static upm_result_t kxtj3_write_register(const kxtj3_context dev, uint8_t reg, uint8_t val) +{ + if (mraa_i2c_write_byte_data(dev->i2c, val, reg) != MRAA_SUCCESS) + { + printf("%s: mraa_i2c_write_byte_data() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + return UPM_SUCCESS; +} + +static upm_result_t kxtj3_set_bit_on(const kxtj3_context dev, uint8_t reg, uint8_t bit_mask) +{ + uint8_t reg_value = 0; + if (kxtj3_read_register(dev, reg, ®_value) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + reg_value |= bit_mask; + return kxtj3_write_register(dev, reg, reg_value); +} + +static upm_result_t kxtj3_set_bit_off(const kxtj3_context dev, uint8_t reg, uint8_t bit_mask) +{ + uint8_t reg_value = 0; + if (kxtj3_read_register(dev, reg, ®_value) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + reg_value &= ~bit_mask; + return kxtj3_write_register(dev, reg, reg_value); +} + +static upm_result_t kxtj3_set_bits_with_mask(const kxtj3_context dev, uint8_t reg, uint8_t val, uint8_t bit_mask) +{ + uint8_t reg_val = 0; + if (kxtj3_read_register(dev, reg, ®_val) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + reg_val &= ~bit_mask; + reg_val |= val; + return kxtj3_write_register(dev, reg, reg_val); +} +// End of register Read/Write helper functions + +static bool kxtj3_check_mraa_i2c_connection(kxtj3_context dev, int bus, uint8_t addr) +{ + if (mraa_init() != MRAA_SUCCESS) + { + printf("%s: mraa_init() failed.\n", __FUNCTION__); + kxtj3_close(dev); + return false; + } + + if (!(dev->i2c = mraa_i2c_init(bus))) + { + printf("%s: mraa_i2c_init() failed.\n", __FUNCTION__); + kxtj3_close(dev); + return false; + } + + if (mraa_i2c_address(dev->i2c, addr)) + { + printf("%s: mraa_i2c_address() failed.\n", __FUNCTION__); + kxtj3_close(dev); + return false; + } + + return true; +} + +static bool kxtj3_check_who_am_i(kxtj3_context dev) +{ + uint8_t who_am_i; + kxtj3_get_who_am_i(dev, &who_am_i); + if (who_am_i != KXTJ3_WHO_AM_I_WIA_ID) + { + printf("%s: Wrong WHO AM I received, expected: 0x%x | got: 0x%x\n", __FUNCTION__, + KXTJ3_WHO_AM_I_WIA_ID, who_am_i); + kxtj3_close(dev); + return false; + } + return true; +} + +static float kxtj3_odr_val_to_sec(KXTJ3_ODR_T odr) +{ + for (size_t i = 0; i < (sizeof(odr_map_in_Hz) / sizeof(struct odr_map_t)); i++) + if (odr == odr_map_in_Hz[i].odr_reg_bit) + return (1 / odr_map_in_Hz[i].odr_in_Hz); + + return -1; +} + +static float kxtj3_odr_val_to_sec_wakeup(KXTJ3_ODR_WAKEUP_T odr) +{ + for (size_t i = 0; i < (sizeof(odr_map_in_Hz_wakeup) / sizeof(struct odr_map_t)); i++) + if (odr == odr_map_in_Hz_wakeup[i].odr_reg_bit) + return (1 / odr_map_in_Hz_wakeup[i].odr_in_Hz); + + return -1; +} + +static void kxtj3_set_default_values(const kxtj3_context dev) +{ + dev->g_range_mode = KXTJ3_RANGE_2G; + dev->acceleration_scale = RANGE_2G_8BIT_STEP; + dev->res_mode = LOW_RES; + dev->odr = KXTJ3_ODR_50; + dev->odr_in_sec = kxtj3_odr_val_to_sec(dev->odr); + dev->odr_wakeup = KXTJ3_ODR_WAKEUP_0P781; + dev->odr_in_sec_wakeup = kxtj3_odr_val_to_sec_wakeup(dev->odr_wakeup); +} + +kxtj3_context kxtj3_init(int bus, uint8_t addr) +{ + kxtj3_context dev = (kxtj3_context)malloc(sizeof(struct _kxtj3_context)); + if (!dev) + return NULL; + + dev->i2c = NULL; + dev->interrupt_pin = NULL; + + if (!kxtj3_check_mraa_i2c_connection(dev, bus, addr)) + return NULL; + + if (!kxtj3_check_who_am_i(dev)) + return NULL; + + kxtj3_set_default_values(dev); + + kxtj3_set_odr_wakeup_function(dev, dev->odr_wakeup); + kxtj3_sensor_init(dev, dev->odr, dev->res_mode, dev->g_range_mode); + + return dev; +} + +upm_result_t kxtj3_sensor_init(const kxtj3_context dev, KXTJ3_ODR_T odr, KXTJ3_RESOLUTION_T res, KXTJ3_G_RANGE_T g_range) +{ + assert(dev != NULL); + if (kxtj3_set_sensor_standby(dev) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if (kxtj3_set_odr(dev, odr) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t g_range_with_res = 0; + if (res) + g_range_with_res |= KXTJ3_CTRL_REG1_RES; + + g_range_with_res |= (g_range & KXTJ3_CTRL_REG1_GSEL_MASK); + if (kxtj3_set_bits_with_mask(dev, KXTJ3_CTRL_REG1, g_range_with_res, + KXTJ3_CTRL_REG1_RES | KXTJ3_CTRL_REG1_GSEL_MASK) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + dev->g_range_mode = g_range; + dev->res_mode = res; + kxtj3_map_g_range_to_resolution(dev, dev->g_range_mode); + + if (kxtj3_set_sensor_active(dev) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + return UPM_SUCCESS; +} + +upm_result_t kxtj3_get_who_am_i(const kxtj3_context dev, uint8_t *data) +{ + assert(dev != NULL); + return kxtj3_read_register(dev, KXTJ3_WHO_AM_I, data); +} + +void kxtj3_close(kxtj3_context dev) +{ + assert(dev != NULL); + + if (dev->i2c) + { + mraa_i2c_stop(dev->i2c); + } + + if (dev->interrupt_pin) + kxtj3_uninstall_isr(dev); + + free(dev); +} + +upm_result_t kxtj3_set_sensor_active(const kxtj3_context dev) +{ + assert(dev != NULL); + return kxtj3_set_bit_on(dev, KXTJ3_CTRL_REG1, KXTJ3_CTRL_REG1_PC); +} + +upm_result_t kxtj3_set_sensor_standby(const kxtj3_context dev) +{ + assert(dev != NULL); + return kxtj3_set_bit_off(dev, KXTJ3_CTRL_REG1, KXTJ3_CTRL_REG1_PC); +} + +static void kxtj3_map_g_range_to_resolution(kxtj3_context dev, KXTJ3_G_RANGE_T g_range) +{ + if (dev->res_mode == LOW_RES) + switch (g_range) + { + case KXTJ3_RANGE_2G: + dev->acceleration_scale = RANGE_2G_8BIT_STEP; + break; + case KXTJ3_RANGE_4G: + dev->acceleration_scale = RANGE_4G_8BIT_STEP; + break; + case KXTJ3_RANGE_8G: + dev->acceleration_scale = RANGE_8G_8BIT_STEP; + break; + case KXTJ3_RANGE_16G: + case KXTJ3_RANGE_16G_2: + case KXTJ3_RANGE_16G_3: + dev->acceleration_scale = RANGE_16G_8BIT_STEP; + break; + + case KXTJ3_RANGE_8G_14: + kxtj3_set_resolution(dev, HIGH_RES); + dev->acceleration_scale = RANGE_8G_14BIT_STEP; + break; + case KXTJ3_RANGE_16G_14: + kxtj3_set_resolution(dev, HIGH_RES); + dev->acceleration_scale = RANGE_16G_14BIT_STEP; + break; + } + else + switch (g_range) + { + case KXTJ3_RANGE_2G: + dev->acceleration_scale = RANGE_2G_12BIT_STEP; + break; + case KXTJ3_RANGE_4G: + dev->acceleration_scale = RANGE_4G_12BIT_STEP; + break; + case KXTJ3_RANGE_8G: + dev->acceleration_scale = RANGE_8G_12BIT_STEP; + break; + case KXTJ3_RANGE_16G: + case KXTJ3_RANGE_16G_2: + case KXTJ3_RANGE_16G_3: + dev->acceleration_scale = RANGE_16G_12BIT_STEP; + break; + + case KXTJ3_RANGE_8G_14: + dev->acceleration_scale = RANGE_8G_14BIT_STEP; + break; + case KXTJ3_RANGE_16G_14: + dev->acceleration_scale = RANGE_16G_14BIT_STEP; + break; + } +} + +upm_result_t kxtj3_set_g_range(const kxtj3_context dev, KXTJ3_G_RANGE_T g_range) +{ + assert(dev != NULL); + + if (kxtj3_set_bits_with_mask(dev, KXTJ3_CTRL_REG1, g_range, KXTJ3_CTRL_REG1_GSEL_MASK) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + dev->g_range_mode = g_range; + kxtj3_map_g_range_to_resolution(dev, g_range); + return UPM_SUCCESS; +} + +upm_result_t kxtj3_set_resolution(const kxtj3_context dev, KXTJ3_RESOLUTION_T resolution) +{ + assert(dev != NULL); + + if (resolution == HIGH_RES) + { + if (kxtj3_set_bit_on(dev, KXTJ3_CTRL_REG1, KXTJ3_CTRL_REG1_RES) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + } + else + { + if (kxtj3_set_bit_off(dev, KXTJ3_CTRL_REG1, KXTJ3_CTRL_REG1_RES != UPM_SUCCESS)) + return UPM_ERROR_OPERATION_FAILED; + } + + dev->res_mode = resolution; + kxtj3_map_g_range_to_resolution(dev, dev->g_range_mode); + return UPM_SUCCESS; +} + +upm_result_t kxtj3_set_odr(const kxtj3_context dev, KXTJ3_ODR_T odr) +{ + assert(dev != NULL); + if (kxtj3_set_bits_with_mask(dev, KXTJ3_DATA_CTRL_REG, odr, KXTJ3_DATA_CTRL_REG_OSA_MASK) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + dev->odr = odr; + dev->odr_in_sec = kxtj3_odr_val_to_sec(odr); + + return UPM_SUCCESS; +} + +upm_result_t kxtj3_set_odr_wakeup_function(const kxtj3_context dev, KXTJ3_ODR_WAKEUP_T odr) +{ + assert(dev != NULL); + if (kxtj3_set_bits_with_mask(dev, KXTJ3_CTRL_REG2, odr, KXTJ3_CTRL_REG2_OWUF_MASK) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + dev->odr_wakeup = odr; + dev->odr_in_sec_wakeup = kxtj3_odr_val_to_sec_wakeup(odr); + + return UPM_SUCCESS; +} + +static bool kxtj3_check_digital_communication_reg_value(kxtj3_context dev, uint8_t expected_val) +{ + uint8_t dcst_reg = 0; + if (kxtj3_read_register(dev, KXTJ3_DCST_RESP, &dcst_reg) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if (dcst_reg != expected_val) + return false; + + return true; +} + +upm_result_t kxtj3_self_test_digital_communication(kxtj3_context dev) +{ + assert(dev != NULL); + if (!kxtj3_check_digital_communication_reg_value(dev, KXTJ3_DCST_RESP_DCSTR_BEFORE)) + return UPM_ERROR_OPERATION_FAILED; + + if (kxtj3_set_bit_on(dev, KXTJ3_CTRL_REG2, KXTJ3_CTRL_REG2_DCST) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if (!kxtj3_check_digital_communication_reg_value(dev, KXTJ3_DCST_RESP_DCSTR_AFTER)) + return UPM_ERROR_OPERATION_FAILED; + + if (!kxtj3_check_digital_communication_reg_value(dev, KXTJ3_DCST_RESP_DCSTR_BEFORE)) + return UPM_ERROR_OPERATION_FAILED; + + return UPM_SUCCESS; +} + +static struct Coordinates kxtj3_get_sample_averaged_data(kxtj3_context dev) +{ + struct Coordinates coordinates_averaged_sample; + coordinates_averaged_sample.x = 0.0f; + coordinates_averaged_sample.y = 0.0f; + coordinates_averaged_sample.z = 0.0f; + + float wait_time = kxtj3_get_acceleration_sampling_period(dev) * SECOND_IN_MICRO_S; + float x, y, z; + for (size_t i = 0; i < SELF_TEST_SAMPLE_COUNT; i++) + { + kxtj3_get_acceleration_data(dev, &x, &y, &z); + coordinates_averaged_sample.x += fabs((x / EARTH_GRAVITY)); + coordinates_averaged_sample.y += fabs((y / EARTH_GRAVITY)); + coordinates_averaged_sample.z += fabs((z / EARTH_GRAVITY)); + upm_delay_us(wait_time); + } + + coordinates_averaged_sample.x /= SELF_TEST_SAMPLE_COUNT; + coordinates_averaged_sample.y /= SELF_TEST_SAMPLE_COUNT; + coordinates_averaged_sample.z /= SELF_TEST_SAMPLE_COUNT; + + return coordinates_averaged_sample; +} + +static bool kxtj3_check_self_test_difference(struct Coordinates before, struct Coordinates during) +{ + struct Coordinates difference; + difference.x = fabs(before.x - during.x); + difference.y = fabs(before.y - during.y); + difference.z = fabs(before.z - during.z); + + if (difference.x > SELF_TEST_DIFFERENCE_THRESHOLD) + { + printf("%s: X-asix FAILED, change on X difference: %.2f\n", __FUNCTION__, difference.x); + return false; + } + + if (difference.y > SELF_TEST_DIFFERENCE_THRESHOLD) + { + printf("%s: Y-asix FAILED, change on Y difference: %.2f\n", __FUNCTION__, difference.y); + return false; + } + + if (difference.z > SELF_TEST_DIFFERENCE_THRESHOLD) + { + printf("%s: Z-asix FAILED, change on Z difference: %.2f\n", __FUNCTION__, difference.z); + return false; + } + + return true; +} + +upm_result_t kxtj3_sensor_self_test(kxtj3_context dev) +{ + assert(dev != NULL); + + struct Coordinates coordinates_before_test, coordinates_during_test; + coordinates_before_test = kxtj3_get_sample_averaged_data(dev); + + uint8_t stpol_val; + kxtj3_read_register(dev, KXTJ3_INT_CTRL_REG1, &stpol_val); + + kxtj3_set_sensor_standby(dev); + kxtj3_set_bit_on(dev, KXTJ3_INT_CTRL_REG1, KXTJ3_INT_CTRL_REG1_STPOL); + kxtj3_write_register(dev, KXTJ3_SELF_TEST, KXTJ3_SELF_TEST_MEMS_TEST_ENABLE); + kxtj3_set_bit_off(dev, KXTJ3_INT_CTRL_REG1, KXTJ3_INT_CTRL_REG1_STPOL); + kxtj3_set_sensor_active(dev); + + coordinates_during_test = kxtj3_get_sample_averaged_data(dev); + kxtj3_write_register(dev, KXTJ3_SELF_TEST, KXTJ3_SELF_TEST_MEMS_TEST_DISABLE); + + if (!kxtj3_check_self_test_difference(coordinates_before_test, coordinates_during_test)) + return UPM_ERROR_OPERATION_FAILED; + + kxtj3_set_sensor_standby(dev); + if (kxtj3_self_test_digital_communication(dev) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + return kxtj3_set_sensor_active(dev); +} + +upm_result_t kxtj3_sensor_software_reset(const kxtj3_context dev) +{ + assert(dev != NULL); + if (kxtj3_set_bit_on(dev, KXTJ3_CTRL_REG2, KXTJ3_CTRL_REG2_SRST) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + uint8_t ctrl_reg2_data; + kxtj3_read_register(dev, KXTJ3_CTRL_REG2, &ctrl_reg2_data); + + uint8_t srst_counter = 0; + while ((ctrl_reg2_data & KXTJ3_CTRL_REG2_SRST) != 0x00 && srst_counter < SW_RESET_MAX_LOOP_COUNT) + { + upm_delay_us(SW_RESET_READ_WAIT_MICRO_S); + kxtj3_read_register(dev, KXTJ3_CTRL_REG2, &ctrl_reg2_data); + srst_counter++; + } + + if (srst_counter == SW_RESET_MAX_LOOP_COUNT) + return UPM_ERROR_OPERATION_FAILED; + + return UPM_SUCCESS; +} + +static bool kxtj3_is_14_bit_range(KXTJ3_G_RANGE_T g_range_mode) +{ + return g_range_mode == KXTJ3_RANGE_8G_14 || g_range_mode == KXTJ3_RANGE_16G_14; +} + +upm_result_t kxtj3_get_acceleration_data_raw(const kxtj3_context dev, float *x, float *y, float *z) +{ + uint8_t buffer[DATA_BUFFER_LENGTH]; + if (kxtj3_read_registers(dev, KXTJ3_XOUT_L, buffer, DATA_BUFFER_LENGTH) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if (dev->res_mode == HIGH_RES) + { + uint8_t shift_amount = 4; + if (kxtj3_is_14_bit_range(dev->g_range_mode)) + shift_amount = 2; + + if (x) + *x = (float)((int16_t)((buffer[1] << 8) | buffer[0]) >> shift_amount); + if (y) + *y = (float)((int16_t)((buffer[3] << 8) | buffer[2]) >> shift_amount); + if (z) + *z = (float)((int16_t)((buffer[5] << 8) | buffer[4]) >> shift_amount); + } + else + { + if (x) + *x = (float)(int8_t)buffer[1]; + if (y) + *y = (float)(int8_t)buffer[3]; + if (z) + *z = (float)(int8_t)buffer[5]; + } + + return UPM_SUCCESS; +} + +upm_result_t kxtj3_get_acceleration_data(const kxtj3_context dev, float *x, float *y, float *z) +{ + float x_raw, y_raw, z_raw; + + if (kxtj3_get_acceleration_data_raw(dev, &x_raw, &y_raw, &z_raw) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if (x) + *x = (x_raw * dev->acceleration_scale) * EARTH_GRAVITY; + if (y) + *y = (y_raw * dev->acceleration_scale) * EARTH_GRAVITY; + if (z) + *z = (z_raw * dev->acceleration_scale) * EARTH_GRAVITY; + + return UPM_SUCCESS; +} + +float kxtj3_get_acceleration_sampling_period(kxtj3_context dev) +{ + return dev->odr_in_sec; +} + +float kxtj3_get_wakeup_sampling_period(kxtj3_context dev) +{ + return dev->odr_in_sec_wakeup; +} + +upm_result_t kxtj3_enable_data_ready_interrupt(const kxtj3_context dev) +{ + assert(dev != NULL); + return kxtj3_set_bit_on(dev, KXTJ3_CTRL_REG1, KXTJ3_CTRL_REG1_DRDYE); +} + +upm_result_t kxtj3_disable_data_ready_interrupt(const kxtj3_context dev) +{ + assert(dev != NULL); + return kxtj3_set_bit_off(dev, KXTJ3_CTRL_REG1, KXTJ3_CTRL_REG1_DRDYE); +} + +upm_result_t kxtj3_enable_wakeup_interrupt(const kxtj3_context dev) +{ + assert(dev != NULL); + return kxtj3_set_bit_on(dev, KXTJ3_CTRL_REG1, KXTJ3_CTRL_REG1_WUFE); +} + +upm_result_t kxtj3_disable_wakeup_interrupt(const kxtj3_context dev) +{ + assert(dev != NULL); + return kxtj3_set_bit_off(dev, KXTJ3_CTRL_REG1, KXTJ3_CTRL_REG1_WUFE); +} + +upm_result_t kxtj3_enable_interrupt_pin(const kxtj3_context dev, KXTJ3_INTERRUPT_POLARITY_T polarity, + KXTJ3_INTERRUPT_RESPONSE_T response_type) +{ + assert(dev != NULL); + uint8_t int_reg_value; + kxtj3_read_register(dev, KXTJ3_INT_CTRL_REG1, &int_reg_value); + + if (polarity) + polarity = KXTJ3_INT_CTRL_REG1_IEA; + if (response_type) + response_type = KXTJ3_INT_CTRL_REG1_IEL; + + int_reg_value &= ~(KXTJ3_INT_CTRL_REG1_IEA | KXTJ3_INT_CTRL_REG1_IEL); + int_reg_value |= (KXTJ3_INT_CTRL_REG1_IEN | polarity | response_type); + + return kxtj3_write_register(dev, KXTJ3_INT_CTRL_REG1, int_reg_value); +} + +upm_result_t kxtj3_disable_interrupt_pin(const kxtj3_context dev) +{ + assert(dev != NULL); + return kxtj3_set_bit_off(dev, KXTJ3_INT_CTRL_REG1, KXTJ3_INT_CTRL_REG1_IEN); +} + +upm_result_t kxtj3_set_interrupt_polarity(const kxtj3_context dev, KXTJ3_INTERRUPT_POLARITY_T polarity) +{ + assert(dev != NULL); + if (polarity == ACTIVE_HIGH) + return kxtj3_set_bit_on(dev, KXTJ3_INT_CTRL_REG1, KXTJ3_INT_CTRL_REG1_IEA); + + return kxtj3_set_bit_off(dev, KXTJ3_INT_CTRL_REG1, KXTJ3_INT_CTRL_REG1_IEA); +} + +upm_result_t kxtj3_set_interrupt_response(const kxtj3_context dev, KXTJ3_INTERRUPT_RESPONSE_T response_type) +{ + assert(dev != NULL); + if (response_type == LATCH_UNTIL_CLEARED) + return kxtj3_set_bit_on(dev, KXTJ3_INT_CTRL_REG1, KXTJ3_INT_CTRL_REG1_IEL); + + return kxtj3_set_bit_off(dev, KXTJ3_INT_CTRL_REG1, KXTJ3_INT_CTRL_REG1_IEL); +} + +bool kxtj3_get_interrupt_status(const kxtj3_context dev) +{ + assert(dev != NULL); + uint8_t status_reg_value; + kxtj3_read_register(dev, KXTJ3_STATUS_REG, &status_reg_value); + if (!(status_reg_value & KXTJ3_STATUS_REG_INT)) + return false; + + return true; +} + +upm_result_t kxtj3_read_interrupt_source1_reg(const kxtj3_context dev, uint8_t *reg_value) +{ + assert(dev != NULL); + return kxtj3_read_register(dev, KXTJ3_INT_SOURCE1, reg_value); +} + +KXTJ3_INTERRUPT_SOURCE_T kxtj3_get_interrupt_source(const kxtj3_context dev) +{ + assert(dev != NULL); + if (kxtj3_get_interrupt_status(dev)) + { + uint8_t int_source_reg; + kxtj3_read_interrupt_source1_reg(dev, &int_source_reg); + + int_source_reg &= (KXTJ3_INT_SOURCE1_DRDY | KXTJ3_INT_SOURCE1_WUFS); + switch (int_source_reg) + { + case KXTJ3_INT_SOURCE1_DRDY: + return KXTJ3_DATA_READY_INTERRUPT; + case KXTJ3_INT_SOURCE1_WUFS: + return KXTJ3_WAKEUP_INTERRUPT; + case KXTJ3_INT_SOURCE1_DRDY | KXTJ3_INT_SOURCE1_WUFS: + return KXTJ3_DATA_READY_AND_WAKEUP_INT; + } + } + return NO_INTERRUPT; +} + +upm_result_t kxtj3_install_isr(const kxtj3_context dev, mraa_gpio_edge_t edge, int pin, void (*isr)(void *), void *isr_args) +{ + assert(dev != NULL); + mraa_gpio_context isr_gpio = NULL; + if (!(isr_gpio = mraa_gpio_init(pin))) + { + printf("%s: mraa_gpio_init() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + mraa_gpio_dir(isr_gpio, MRAA_GPIO_IN); + + if (mraa_gpio_isr(isr_gpio, edge, isr, isr_args) != MRAA_SUCCESS) + { + mraa_gpio_close(isr_gpio); + printf("%s: mraa_gpio_isr() failed.\n", __FUNCTION__); + return UPM_ERROR_OPERATION_FAILED; + } + + dev->interrupt_pin = isr_gpio; + return UPM_SUCCESS; +} + +void kxtj3_uninstall_isr(const kxtj3_context dev) +{ + assert(dev != NULL); + mraa_gpio_isr_exit(dev->interrupt_pin); + mraa_gpio_close(dev->interrupt_pin); + dev->interrupt_pin = NULL; +} + +upm_result_t kxtj3_clear_interrupt_information(kxtj3_context dev) +{ + assert(dev != NULL); + uint8_t int_rel_value; + return kxtj3_read_register(dev, KXTJ3_INT_REL, &int_rel_value); +} + +upm_result_t kxtj3_enable_wakeup_single_axis_direction(kxtj3_context dev, KXTJ3_WAKEUP_SOURCE_T axis) +{ + assert(dev != NULL); + return kxtj3_set_bit_on(dev, KXTJ3_INT_CTRL_REG2, axis); +} + +upm_result_t kxtj3_disable_wakeup_single_axis_direction(kxtj3_context dev, KXTJ3_WAKEUP_SOURCE_T axis) +{ + assert(dev != NULL); + return kxtj3_set_bit_off(dev, KXTJ3_INT_CTRL_REG2, axis); +} + +kxtj3_wakeup_axes kxtj3_get_wakeup_axis_and_direction(kxtj3_context dev) +{ + assert(dev != NULL); + + uint8_t int_source2_value; + kxtj3_read_register(dev, KXTJ3_INT_SOURCE2, &int_source2_value); + + kxtj3_wakeup_axes wakeup_axis; + wakeup_axis.X_NEGATIVE = false; + wakeup_axis.X_POSITIVE = false; + wakeup_axis.Y_POSITIVE = false; + wakeup_axis.Y_NEGATIVE = false; + wakeup_axis.Z_POSITIVE = false; + wakeup_axis.Z_NEGATIVE = false; + + if (int_source2_value & KXTJ3_INT_SOURCE2_XPWU) + wakeup_axis.X_POSITIVE = true; + else if (int_source2_value & KXTJ3_INT_SOURCE2_XNWU) + wakeup_axis.X_NEGATIVE = true; + if (int_source2_value & KXTJ3_INT_SOURCE2_YPWU) + wakeup_axis.Y_POSITIVE = true; + else if (int_source2_value & KXTJ3_INT_SOURCE2_YNWU) + wakeup_axis.Y_NEGATIVE = true; + if (int_source2_value & KXTJ3_INT_SOURCE2_ZPWU) + wakeup_axis.Z_POSITIVE = true; + else if (int_source2_value & KXTJ3_INT_SOURCE2_ZNWU) + wakeup_axis.Z_NEGATIVE = true; + + return wakeup_axis; +} + +upm_result_t kxtj3_enable_wakeup_latch(kxtj3_context dev) +{ + assert(dev != NULL); + return kxtj3_set_bit_off(dev, KXTJ3_INT_CTRL_REG2, KXTJ3_INT_CTRL_REG2_ULMODE); +} + +upm_result_t kxtj3_disable_wakeup_latch(kxtj3_context dev) +{ + assert(dev != NULL); + return kxtj3_set_bit_on(dev, KXTJ3_INT_CTRL_REG2, KXTJ3_INT_CTRL_REG2_ULMODE); +} + +upm_result_t kxtj3_set_wakeup_motion_counter(kxtj3_context dev, uint8_t count) +{ + assert(dev != NULL); + if (count == 0) + return UPM_ERROR_OPERATION_FAILED; + return kxtj3_write_register(dev, KXTJ3_WAKEUP_COUNTER, count); +} + +static uint8_t kxtj3_get_wakeup_count_from_time_sec(kxtj3_context dev, float time_sec) +{ + return time_sec / dev->odr_in_sec_wakeup; +} + +upm_result_t kxtj3_set_wakeup_motion_time(kxtj3_context dev, float desired_time) +{ + assert(dev != NULL); + uint8_t count = kxtj3_get_wakeup_count_from_time_sec(dev, desired_time); + return kxtj3_set_wakeup_motion_counter(dev, count); +} + +upm_result_t kxtj3_get_wakeup_motion_time(kxtj3_context dev, float *out_time) +{ + assert(dev != NULL); + uint8_t motion_count = 0; + if (kxtj3_read_register(dev, KXTJ3_WAKEUP_COUNTER, &motion_count) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *out_time = (float)motion_count * dev->odr_in_sec_wakeup; + + return UPM_SUCCESS; +} + +upm_result_t kxtj3_set_wakeup_non_activity_counter(kxtj3_context dev, uint8_t count) +{ + assert(dev != NULL); + if (count == 0) + return UPM_ERROR_OPERATION_FAILED; + return kxtj3_write_register(dev, KXTJ3_NA_COUNTER, count); +} + +upm_result_t kxtj3_set_wakeup_non_activity_time(kxtj3_context dev, float desired_time) +{ + assert(dev != NULL); + uint8_t count = kxtj3_get_wakeup_count_from_time_sec(dev, desired_time); + return kxtj3_set_wakeup_non_activity_counter(dev, count); +} + +upm_result_t kxtj3_get_wakeup_non_activity_time(kxtj3_context dev, float *out_time) +{ + assert(dev != NULL); + uint8_t non_activity_reg_count = 0; + if (kxtj3_read_register(dev, KXTJ3_NA_COUNTER, &non_activity_reg_count) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *out_time = (float)non_activity_reg_count * dev->odr_in_sec_wakeup; + + return UPM_SUCCESS; +} + +upm_result_t kxtj3_set_wakeup_threshold_counter(kxtj3_context dev, uint16_t count) +{ + assert(dev != NULL); + if (count == 0) + return UPM_ERROR_OPERATION_FAILED; + if (kxtj3_write_register(dev, KXTJ3_WAKEUP_THRESHOLD_H, (uint8_t)(count >> 4)) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if (kxtj3_write_register(dev, KXTJ3_WAKEUP_THRESHOLD_L, (uint8_t)(count << 4)) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + return UPM_SUCCESS; +} + +static uint16_t kxtj3_get_wakeup_threshold_count_from_g(kxtj3_context dev, float g_threshold) +{ + return g_threshold * 256; +} + +upm_result_t kxtj3_set_wakeup_threshold_g_value(kxtj3_context dev, float g_threshold) +{ + assert(dev != NULL); + uint16_t count = kxtj3_get_wakeup_threshold_count_from_g(dev, g_threshold); + return kxtj3_set_wakeup_threshold_counter(dev, count); +} + +upm_result_t kxtj3_get_wakeup_threshold(kxtj3_context dev, float *out_threshold) +{ + assert(dev != NULL); + uint8_t reg_value_h = 0, reg_value_l = 0; + if (kxtj3_read_register(dev, KXTJ3_WAKEUP_THRESHOLD_H, ®_value_h) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + if (kxtj3_read_register(dev, KXTJ3_WAKEUP_THRESHOLD_L, ®_value_l) != UPM_SUCCESS) + return UPM_ERROR_OPERATION_FAILED; + + *out_threshold = (float)((uint16_t)((reg_value_h << 8) | reg_value_l) >> 4) / 256; + + return UPM_SUCCESS; +} diff -Nru upm-1.6.0/src/kxtj3/kxtj3.cxx upm-1.7.1/src/kxtj3/kxtj3.cxx --- upm-1.6.0/src/kxtj3/kxtj3.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kxtj3/kxtj3.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,315 @@ +/* +* 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 +#include +#include + +#include "kxtj3.hpp" + +using namespace upm; + +KXTJ3::KXTJ3(int bus, uint8_t addr) : m_kxtj3(kxtj3_init(bus, addr)) +{ + if (!m_kxtj3) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_init() failed"); +} + +KXTJ3::~KXTJ3() +{ + kxtj3_close(m_kxtj3); +} + +void KXTJ3::SensorInit(KXTJ3_ODR_T odr, KXTJ3_RESOLUTION_T resolution, KXTJ3_G_RANGE_T g_range) +{ + if (kxtj3_sensor_init(m_kxtj3, odr, resolution, g_range) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_sensor_init() failed"); +} + +uint8_t KXTJ3::GetWhoAmI() +{ + uint8_t who_am_i; + if (kxtj3_get_who_am_i(m_kxtj3, &who_am_i) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_get_who_am_i() failed"); + + return who_am_i; +} + +void KXTJ3::SensorActive() +{ + if (kxtj3_set_sensor_active(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_sensor_active() failed"); +} + +void KXTJ3::SensorStandby() +{ + if (kxtj3_set_sensor_standby(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_sensor_standby() failed"); +} + +void KXTJ3::SetGRange(KXTJ3_G_RANGE_T g_range) +{ + if (kxtj3_set_g_range(m_kxtj3, g_range) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_g_range() failed"); +} + +void KXTJ3::SetResolution(KXTJ3_RESOLUTION_T resolution) +{ + if (kxtj3_set_resolution(m_kxtj3, resolution) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_resolution() failed"); +} + +void KXTJ3::SetOdr(KXTJ3_ODR_T odr) +{ + if (kxtj3_set_odr(m_kxtj3, odr) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_odr() failed"); +} + +void KXTJ3::SetOdrForWakeup(KXTJ3_ODR_WAKEUP_T odr) +{ + if (kxtj3_set_odr_wakeup_function(m_kxtj3, odr) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_odr_wakeup_function() failed"); +} + +void KXTJ3::SelfTestDigitalCommunication() +{ + if (kxtj3_self_test_digital_communication(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_self_test_digital_communication() failed"); +} + +void KXTJ3::SensorSelfTest() +{ + if (kxtj3_sensor_self_test(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_sensor_self_test() failed"); +} + +void KXTJ3::SensorSoftwareReset() +{ + if (kxtj3_sensor_software_reset(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_sensor_software_reset() failed"); +} + +std::vector KXTJ3::GetAccelerationRawVector() +{ + std::vector xyz(3); + if (kxtj3_get_acceleration_data_raw(m_kxtj3, &xyz[0], &xyz[1], &xyz[2]) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_get_acceleration_data_raw() failed"); + + return xyz; +} + +std::vector KXTJ3::GetAccelerationVector() +{ + std::vector xyz(3); + if (kxtj3_get_acceleration_data(m_kxtj3, &xyz[0], &xyz[1], &xyz[2]) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_get_acceleration_data() failed"); + + return xyz; +} + +float KXTJ3::GetAccelerationSamplePeriod() +{ + return kxtj3_get_acceleration_sampling_period(m_kxtj3); +} + +float KXTJ3::GetWakeUpSamplePeriod() +{ + return kxtj3_get_wakeup_sampling_period(m_kxtj3); +} + +void KXTJ3::EnableDataReadyInterrupt() +{ + if (kxtj3_enable_data_ready_interrupt(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_enable_data_ready_interrupt() failed"); +} + +void KXTJ3::DisableDataReadyInterrupt() +{ + if (kxtj3_disable_data_ready_interrupt(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_disable_data_ready_interrupt() failed"); +} + +void KXTJ3::EnableWakeUpInterrupt() +{ + if (kxtj3_enable_wakeup_interrupt(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_enable_wakeup_interrupt() failed"); +} + +void KXTJ3::DisableWakeUpInterrupt() +{ + if (kxtj3_disable_wakeup_interrupt(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_disable_wakeup_interrupt() failed"); +} + +void KXTJ3::EnableInterruptPin(KXTJ3_INTERRUPT_POLARITY_T polarity, KXTJ3_INTERRUPT_RESPONSE_T response_type) +{ + if (kxtj3_enable_interrupt_pin(m_kxtj3, polarity, response_type) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_enable_interrupt_pin() failed"); +} + +void KXTJ3::DisableInterruptPin() +{ + if (kxtj3_disable_interrupt_pin(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_disable_interrupt_pin() failed"); +} + +void KXTJ3::SetInterruptPolarity(KXTJ3_INTERRUPT_POLARITY_T polarity) +{ + if (kxtj3_set_interrupt_polarity(m_kxtj3, polarity) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_interrupt_polarity() failed"); +} + +void KXTJ3::SetInerruptResponse(KXTJ3_INTERRUPT_RESPONSE_T response_type) +{ + if (kxtj3_set_interrupt_response(m_kxtj3, response_type) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_interrupt_response() failed"); +} + +bool KXTJ3::GetInterruptStatus() +{ + return kxtj3_get_interrupt_status(m_kxtj3); +} + +uint8_t KXTJ3::ReadInterruptSource1() +{ + uint8_t reg_value; + if (kxtj3_read_interrupt_source1_reg(m_kxtj3, ®_value) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_read_interrupt_source1_reg() failed"); + + return reg_value; +} + +KXTJ3_INTERRUPT_SOURCE_T KXTJ3::GetInterruptSource() +{ + return kxtj3_get_interrupt_source(m_kxtj3); +} + +void KXTJ3::InstallIsr(mraa_gpio_edge_t edge, int pin, void (*isr)(void *), void *isr_args) +{ + if (kxtj3_install_isr(m_kxtj3, edge, pin, isr, isr_args) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_install_isr() failed"); +} + +void KXTJ3::UninstallIsr() +{ + kxtj3_uninstall_isr(m_kxtj3); +} + +void KXTJ3::ClearInterrupt() +{ + if (kxtj3_clear_interrupt_information(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_clear_interrupt_information() failed"); +} + +void KXTJ3::EnableWakeUpSingleAxisDirection(KXTJ3_WAKEUP_SOURCE_T axis) +{ + if (kxtj3_enable_wakeup_single_axis_direction(m_kxtj3, axis) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_enable_wakeup_single_axis_direction() failed"); +} + +void KXTJ3::DisableWakeUpSingleAxisDirection(KXTJ3_WAKEUP_SOURCE_T axis) +{ + if (kxtj3_disable_wakeup_single_axis_direction(m_kxtj3, axis) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_disable_wakeup_single_axis_direction() failed"); +} + +kxtj3_wakeup_axes KXTJ3::GetWakeUpAxisDirection() +{ + return kxtj3_get_wakeup_axis_and_direction(m_kxtj3); +} + +void KXTJ3::EnableWakeUpLatch() +{ + if (kxtj3_enable_wakeup_latch(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_enable_wakeup_latch() failed"); +} + +void KXTJ3::DisableWakeUpLatch() +{ + if (kxtj3_disable_wakeup_latch(m_kxtj3) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_disable_wakeup_latch() failed"); +} + +void KXTJ3::SetWakeUpMotionCounter(uint8_t count) +{ + if (kxtj3_set_wakeup_motion_counter(m_kxtj3, count) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_wakeup_motion_counter() failed"); +} + +void KXTJ3::SetWakeUpMotionTime(float desired_time) +{ + if (kxtj3_set_wakeup_motion_time(m_kxtj3, desired_time) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_wakeup_motion_time() failed"); +} + +float KXTJ3::GetWakeUpMotionTime() +{ + float out_time; + if (kxtj3_get_wakeup_motion_time(m_kxtj3, &out_time) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_get_wakeup_motion_time() failed"); + + return out_time; +} + +void KXTJ3::SetWakeUpNonActivityCounter(uint8_t count) +{ + if (kxtj3_set_wakeup_non_activity_counter(m_kxtj3, count) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_wakeup_non_activity_counter() failed"); +} + +void KXTJ3::SetWakeUpNonActivityTime(float desired_time) +{ + if (kxtj3_set_wakeup_non_activity_time(m_kxtj3, desired_time) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_wakeup_non_activity_time() failed"); +} + +float KXTJ3::GetWakeUpNonActivityTime() +{ + float out_time; + if (kxtj3_get_wakeup_non_activity_time(m_kxtj3, &out_time) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_get_wakeup_non_activity_time() failed"); + + return out_time; +} + +void KXTJ3::SetWakeUpThresholdCounter(uint16_t count) +{ + if (kxtj3_set_wakeup_threshold_counter(m_kxtj3, count) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_wakeup_threshold_counter() failed"); +} + +void KXTJ3::SetWakeUpThresholdGRange(float g_threshold) +{ + if (kxtj3_set_wakeup_threshold_g_value(m_kxtj3, g_threshold) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_set_wakeup_threshold_g_value() failed"); +} + +float KXTJ3::GetWakeUpThresholdGRange() +{ + float out_threshold; + if (kxtj3_get_wakeup_threshold(m_kxtj3, &out_threshold) != UPM_SUCCESS) + throw std::runtime_error(std::string(__FUNCTION__) + "kxtj3_get_wakeup_threshold() failed"); + + return out_threshold; +} \ No newline at end of file diff -Nru upm-1.6.0/src/kxtj3/kxtj3.h upm-1.7.1/src/kxtj3/kxtj3.h --- upm-1.6.0/src/kxtj3/kxtj3.h 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kxtj3/kxtj3.h 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,746 @@ +/* +* 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. +*/ + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +#include +#include +#include + +#include "kxtj3_registers.h" + + /** + * @brief C API for the kxtj3 driver + * @defgroup kxtj3 libupm-kxtj3 + * @ingroup Kionix i2c accelerometer + * + * @include kxtj3.c + */ + + /** + * @library kxtj3 + * @sensor kxtj3 + * @comname tri-axis accelerometer + * @type accelerometer + * @man Kionix + * @con i2c + * + * @brief C API for the kxtj3 driver + * + * @image html kxtj3.png + */ + +#define SECOND_IN_MICRO_S 1000000 + + /** + * @brief Resolution types + */ + typedef enum + { + LOW_RES, + HIGH_RES + } KXTJ3_RESOLUTION_T; + + /** + * @brief Interrupt polarity types + */ + typedef enum + { + ACTIVE_LOW, + ACTIVE_HIGH + + } KXTJ3_INTERRUPT_POLARITY_T; + + /** + * @brief Interrupt response types + */ + typedef enum + { + LATCH_UNTIL_CLEARED, + TRANSMIT_ONE_PULSE + } KXTJ3_INTERRUPT_RESPONSE_T; + + /** + * @brief Interrupt sources + */ + typedef enum + { + NO_INTERRUPT, + KXTJ3_DATA_READY_INTERRUPT = KXTJ3_INT_SOURCE1_DRDY, + KXTJ3_WAKEUP_INTERRUPT = KXTJ3_INT_SOURCE1_WUFS, + KXTJ3_DATA_READY_AND_WAKEUP_INT = KXTJ3_INT_SOURCE1_DRDY | KXTJ3_INT_SOURCE1_WUFS + } KXTJ3_INTERRUPT_SOURCE_T; + + /** + * @brief Acceleration ranges + */ + typedef enum + { + KXTJ3_RANGE_2G = KXTJ3_CTRL_REG1_GSEL_2G, + KXTJ3_RANGE_4G = KXTJ3_CTRL_REG1_GSEL_4G, + KXTJ3_RANGE_8G = KXTJ3_CTRL_REG1_GSEL_8G, + KXTJ3_RANGE_8G_14 = KXTJ3_CTRL_REG1_GSEL_8G_14, + KXTJ3_RANGE_16G = KXTJ3_CTRL_REG1_GSEL_16G, + KXTJ3_RANGE_16G_2 = KXTJ3_CTRL_REG1_GSEL_16G2, + KXTJ3_RANGE_16G_3 = KXTJ3_CTRL_REG1_GSEL_16G3, + KXTJ3_RANGE_16G_14 = KXTJ3_CTRL_REG1_GSEL_16G_14 + } KXTJ3_G_RANGE_T; + + /** + * @brief Output Data Rates for normal mode + */ + typedef enum + { + KXTJ3_ODR_0P781 = KXTJ3_DATA_CTRL_REG_OSA_0P781, + KXTJ3_ODR_1P563 = KXTJ3_DATA_CTRL_REG_OSA_1P563, + KXTJ3_ODR_3P125 = KXTJ3_DATA_CTRL_REG_OSA_3P125, + KXTJ3_ODR_6P25 = KXTJ3_DATA_CTRL_REG_OSA_6P25, + KXTJ3_ODR_12P5 = KXTJ3_DATA_CTRL_REG_OSA_12P5, + KXTJ3_ODR_25 = KXTJ3_DATA_CTRL_REG_OSA_25, + KXTJ3_ODR_50 = KXTJ3_DATA_CTRL_REG_OSA_50, + KXTJ3_ODR_100 = KXTJ3_DATA_CTRL_REG_OSA_100, + KXTJ3_ODR_200 = KXTJ3_DATA_CTRL_REG_OSA_200, + KXTJ3_ODR_400 = KXTJ3_DATA_CTRL_REG_OSA_400, + KXTJ3_ODR_800 = KXTJ3_DATA_CTRL_REG_OSA_800, + KXTJ3_ODR_1600 = KXTJ3_DATA_CTRL_REG_OSA_1600 + } KXTJ3_ODR_T; + + /** + * @brief Output Data Rates for wake-up function + */ + typedef enum + { + KXTJ3_ODR_WAKEUP_0P781 = KXTJ3_CTRL_REG2_OWUF_0P781, + KXTJ3_ODR_WAKEUP_1P563 = KXTJ3_CTRL_REG2_OWUF_1P563, + KXTJ3_ODR_WAKEUP_3P125 = KXTJ3_CTRL_REG2_OWUF_3P125, + KXTJ3_ODR_WAKEUP_6P25 = KXTJ3_CTRL_REG2_OWUF_6P25, + KXTJ3_ODR_WAKEUP_12P5 = KXTJ3_CTRL_REG2_OWUF_12P5, + KXTJ3_ODR_WAKEUP_25 = KXTJ3_CTRL_REG2_OWUF_25, + KXTJ3_ODR_WAKEUP_50 = KXTJ3_CTRL_REG2_OWUF_50, + KXTJ3_ODR_WAKEUP_100 = KXTJ3_CTRL_REG2_OWUF_100 + } KXTJ3_ODR_WAKEUP_T; + + /** + * @brief Wake-up source axis and direction + */ + typedef enum + { + X_NEGATIVE = KXTJ3_INT_CTRL_REG2_XNWU, + X_POSITIVE = KXTJ3_INT_CTRL_REG2_XPWU, + Y_NEGATIVE = KXTJ3_INT_CTRL_REG2_YNWU, + Y_POSITIVE = KXTJ3_INT_CTRL_REG2_YPWU, + Z_NEGATIVE = KXTJ3_INT_CTRL_REG2_ZNWU, + Z_POSITIVE = KXTJ3_INT_CTRL_REG2_ZPWU + } KXTJ3_WAKEUP_SOURCE_T; + + /** + * @brief Use it to get axis and direction for wake-up function + */ + typedef struct + { + bool X_NEGATIVE, + X_POSITIVE, + Y_NEGATIVE, + Y_POSITIVE, + Z_NEGATIVE, + Z_POSITIVE; + } kxtj3_wakeup_axes; + + /** + * @brief Sensor context + */ + typedef struct _kxtj3_context + { + mraa_i2c_context i2c; + KXTJ3_RESOLUTION_T res_mode; + KXTJ3_G_RANGE_T g_range_mode; + float acceleration_scale; + KXTJ3_ODR_T odr; + float odr_in_sec; + KXTJ3_ODR_WAKEUP_T odr_wakeup; + float odr_in_sec_wakeup; + mraa_gpio_context interrupt_pin; + } * kxtj3_context; + + /** +@brief KXTJ3 initialization. Sets sensor default values and put it to active state. + +@param bus I2C bus to use +@param addr I2C address of the sensor +@return The sensor context, or NULL if an error occurs +*/ + kxtj3_context kxtj3_init(int bus, uint8_t addr); + + /** +@brief Initializes the sensor with the given resolution and acceleration range + +This gets called during the kxtj3_init(), so it will not need to be called unless the sensor is reset + +Sensor is automatically set into standby mode during the initialization +Sensor is set to active mode after initialization + +Be cautious not to set resolution to LOW_RES along with g_range as 14-bits modes + +@param dev The sensor context +@param odr Output Data Rate, One of the KXTJ3_ODR_T values +@param res Resolution mode, One of the KXTJ3_RESOLUTION_T values. LOW_RES valid only for ODR <= 200 Hz. +@param g_range Acceleration range, One of the KXTJ3_G_RANGE_T values +@return UPM result +*/ + upm_result_t kxtj3_sensor_init(const kxtj3_context dev, KXTJ3_ODR_T odr, KXTJ3_RESOLUTION_T res, KXTJ3_G_RANGE_T g_range); + + /** +@brief Gets "who am I" value of the sensor + +@param dev The sensor context +@param data Pointer to a uint8_t variable to store the value +@return UPM result +*/ + upm_result_t kxtj3_get_who_am_i(const kxtj3_context dev, uint8_t *data); + + /** +@brief KXTJ3 destructor +Closes the I2C context, and removes interrupts +Frees memory of the kxtj3_context + +@param dev The sensor context +*/ + void kxtj3_close(kxtj3_context dev); + + /** +@brief Sets the sensor to active mode + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_set_sensor_active(const kxtj3_context dev); + + /** +@brief Sets the sensor to the standby mode + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_set_sensor_standby(const kxtj3_context dev); + + /** +@brief Sets the acceleration range of the sensor + +Sensor needs to be in standby mode when setting the acceleration range value + +Be cautious not to set g_range to 14-bits modes with the resolution being on LOW_RES. +If the acceleration range is not compatible with resolution mode, the resolution is set automatically +to the compatible value. + +@param dev The sensor context +@param g_range One of the KXTJ3_G_RANGE_T values +@return UPM result +*/ + upm_result_t kxtj3_set_g_range(const kxtj3_context dev, KXTJ3_G_RANGE_T g_range); + + /** +@brief Sets the resolution of the sensor. High resolution (14 bits and 12 bits) or low resolution (8 bits). + +LOW_RES valid only for ODR <= 200 Hz + +Be cautious not to set resolution to LOW_RES with the G_RANG being on 14-bits modes. +If the resolution mode is not compatible with acceleration range, the resolution is set automatically +to the compatible value. + +Sensor needs to be in standby mode when setting the sensor resolution + +@param dev The sensor context +@param resolution One of the KXTJ3_RESOLUTION_T values +@return UPM result +*/ + upm_result_t kxtj3_set_resolution(const kxtj3_context dev, KXTJ3_RESOLUTION_T resolution); + + /** +@brief Sets the ODR of the sensor + +Sensor needs to be in standby mode when setting the ODR + +@param dev The sensor context +@param odr One of the KXTJ3_ODR_T values +@return UPM result +*/ + upm_result_t kxtj3_set_odr(const kxtj3_context dev, KXTJ3_ODR_T odr); + + /** +@brief Sets the ODR of the wakeup function of the sensor + +Sensor needs to be in standby mode when setting the ODR + +@param dev The sensor context +@param odr One of the KXTJ3_ODR_WAKEUP_T values +@return UPM result +*/ + upm_result_t kxtj3_set_odr_wakeup_function(const kxtj3_context dev, KXTJ3_ODR_WAKEUP_T odr); + + /** +@brief Performs a self-test for digital communication of the sensor. The test sets DCST bit in +CTRL_REG2, then checks the DCST_RESP register for a 0xAA, after the register is read, its +value is 0x55 and DCST bit is cleared. + +This function is called by kxtj3_sensor_self_test also + +Sensor must be in standby mode before performing this action + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_self_test_digital_communication(kxtj3_context dev); + + /** +@brief Performs a self-test of the sensor. The test applies an electrostatic force to the sensor, +simulating input acceleration. The test compares samples from all axis before and after +applying the electrostatic force to the sensor. If the amount of acceleration increases according +to the values defined in TABLE 1 of the datasheet (0.5 g), the test passes. + +The function prints out the values before and during test and the average difference for each axis + +See the datasheet for more information + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_sensor_self_test(const kxtj3_context dev); + + /** +@brief Performs a sensor software reset. The software reset clears the RAM of the sensor and resets all registers +to pre-defined values. + +You should call kxtj3_sensor_init() after the software reset + +See the datasheet for more details + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_sensor_software_reset(const kxtj3_context dev); + + /** +@brief Gets raw accelerometer data from the sensor + +@param dev The sensor context +@param x Pointer to a floating point variable to store the x-axis value. Set to NULL if not wanted. +@param y Pointer to a floating point variable to store the y-axis value. Set to NULL if not wanted. +@param z Pointer to a floating point variable to store the z-axis value. Set to NULL if not wanted. +@return UPM result +*/ + upm_result_t kxtj3_get_acceleration_data_raw(const kxtj3_context dev, float *x, float *y, float *z); + + /** +@brief Gets converted (m/s^2) accelerometer data from the sensor + +@param dev The sensor context +@param x Pointer to a floating point variable to store the x-axis value. Set to NULL if not wanted. +@param y Pointer to a floating point variable to store the y-axis value. Set to NULL if not wanted. +@param z Pointer to a floating point variable to store the z-axis value. Set to NULL if not wanted. +*/ + upm_result_t kxtj3_get_acceleration_data(const kxtj3_context dev, float *x, float *y, float *z); + + /** +@brief Gets the duration of one sample period (in seconds) for getting the acceleration data depending on +the sampling rate of the sensor + +@param dev The sensor context +@return Floating point value of the sampling period +*/ + float kxtj3_get_acceleration_sampling_period(kxtj3_context dev); + + /** +Gets the duration of one sample period (in seconds) for the wakeup function depending on +the sampling rate of the sensor wakeup function + +@param dev The sensor context +@return Floating point value of the sampling period +*/ + float kxtj3_get_wakeup_sampling_period(kxtj3_context dev); + + /** +@brief Enables the data ready interrupt. Availability of new acceleration data is +reflected as an interrupt. + +Sensor must be in standby mode before performing this action + +@param dev The sensor context +@return UPM result + */ + upm_result_t kxtj3_enable_data_ready_interrupt(const kxtj3_context dev); + + /** +@brief Disables the data ready interrupt + +Sensor must be in standby mode before performing this action + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_disable_data_ready_interrupt(const kxtj3_context dev); + + /** +@brief Enables the wakeup function (motion detection) + +Sensor must be in standby mode before performing this action + +@param dev The sensor context +@return UPM result + */ + upm_result_t kxtj3_enable_wakeup_interrupt(const kxtj3_context dev); + + /** +@brief Disables the wakeup function (motion detection) + +Sensor must be in standby mode before performing this action + +@param dev The sensor context +@return UPM result + */ + upm_result_t kxtj3_disable_wakeup_interrupt(const kxtj3_context dev); + + /** +@brief Enables interrupts on the interrupt pin, sets polarity and response types + +Polarity ACTIVE_HIGH or ACTIVE_LOW + +Response either latch until cleared by reading INT_REL register, or transmit one pulse +Pulse width of 0.03-0.05ms + +For Wakeup function, the response type is always latched unless set wakeup latch off + +Sensor needs to be in standby mode when enabling the interrupt + +See datasheet for more details + +@param dev The sensor context +@param polarity Select the polarity of the interrupt. One of the KXTJ3_INTERRUPT_POLARITY_T values. +@param response_type Select the response type of the interrupt. One of the KXTJ3_INTERRUPT_RESPONSE_T values. +@return UPM result +*/ + upm_result_t kxtj3_enable_interrupt_pin(const kxtj3_context dev, KXTJ3_INTERRUPT_POLARITY_T polarity, KXTJ3_INTERRUPT_RESPONSE_T response_type); + + /** +@brief Disables interrupts on the interrupt pin of the sensor + +Sensor needs to be in standby mode when disabling the interrupt pin + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_disable_interrupt_pin(const kxtj3_context dev); + + /** +@brief Sets the polarity of the interrupt pin + +Polarity ACTIVE_HIGH or ACTIVE_LOW + +Sensor must be in standby mode before performing this action + +@param dev The sensor context +@param polarity Select the polarity of the interrupt. One of the KXTJ3_INTERRUPT_POLARITY_T values. +@return UPM result +*/ + upm_result_t kxtj3_set_interrupt_polarity(const kxtj3_context dev, KXTJ3_INTERRUPT_POLARITY_T polarity); + + /** +@brief Sets the response type of the interrupt pin + +Response either latch until cleared by reading INT_REL register, or transmit one pulse +Pulse width of 0.03-0.05ms + +For Wakeup function, the response type is always latched unless set wakeup latch off + +Sensor must be in standby mode before performing this action + +See datasheet for more details + +@param dev The sensor context +@param response_type Select the response type of the interrupt. One of the KXTJ3_INTERRUPT_RESPONSE_T values. +@return UPM result +*/ + upm_result_t kxtj3_set_interrupt_response(const kxtj3_context dev, KXTJ3_INTERRUPT_RESPONSE_T response_type); + + /** +@brief Gets the status of the interrupts. (Has an interrupt occurred). + +See datasheet for more details + +@param dev The sensor context +@return Return true if an interrupt event has occurred (DRDY or WUFS is 1), returns false if no interrupts have occurred +*/ + bool kxtj3_get_interrupt_status(const kxtj3_context dev); + + /** +@brief Gets the source of the interrupt +The value stored is one or more of the KXTJ3_INTERRUPT_SOURCE_T values + +See datasheet for more details + +@param dev The sensor context +@param reg_value Pointer to a uint8_t variable to store the value +@return UPM result +*/ + upm_result_t kxtj3_read_interrupt_source1_reg(const kxtj3_context dev, uint8_t *reg_value); + + /** +@brief Gets the source of the interrupt + +See datasheet for more details + +@param dev The sensor context +@return One of the KXTJ3_INTERRUPT_SOURCE_T values/types +*/ + KXTJ3_INTERRUPT_SOURCE_T kxtj3_get_interrupt_source(const kxtj3_context dev); + + /** +@brief Installs an interrupt handler to be executed when an interrupt is detected on the interrupt pin + +@param dev The sensor context +@param edge One of the mraa_gpio_edge_t values, Interrupt trigger edge +@param pin The GPIO pin to use as the interrupt pin +@param isr Pointer to the function to be called, when the interrupt occurs +@param isr_args The arguments to be passed to the function +@return UPM result +*/ + upm_result_t kxtj3_install_isr(const kxtj3_context dev, mraa_gpio_edge_t edge, int pin, void (*isr)(void *), void *isr_args); + + /** +@brief Uninstalls a previously installed interrupt handler for interrupt pin + +@param dev The sensor context +@return UPM result +*/ + void kxtj3_uninstall_isr(const kxtj3_context dev); + + /** +@brief Clears latching interrupts information of Wakeup (with axis and direction information) and Data Ready + +See datasheet for more details + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_clear_interrupt_information(kxtj3_context dev); + + /** +@brief Enables wakeup interrupt for the given axis (axis with direction) + +Sensor must be in standby mode before performing this action + +@param dev The sensor context +@param axis The axis to enable, takes one of KXTJ3_WAKEUP_SOURCE_T value +@return UPM result + */ + upm_result_t kxtj3_enable_wakeup_single_axis_direction(kxtj3_context dev, KXTJ3_WAKEUP_SOURCE_T axis); + + /** +@brief Disables wakeup interrupt for the given axis (axis with direction) + +Sensor must be in standby mode before performing this action + +@param dev The sensor context +@param axis The axis to enable, takes one of KXTJ3_WAKEUP_SOURCE_T value +@return UPM result + */ + upm_result_t kxtj3_disable_wakeup_single_axis_direction(kxtj3_context dev, KXTJ3_WAKEUP_SOURCE_T axis); + + /** +@brief Gets the source axis and direction of motion detection of the wakeup function interrupt + +See datasheet for more details + +@param dev The sensor context +@return A kxtj3_wakeup_axes struct with values of true/false for a wakeup for each axis and its direction +*/ + kxtj3_wakeup_axes kxtj3_get_wakeup_axis_and_direction(kxtj3_context dev); + + /** +@brief Enables the Unlatched mode motion interrupt (ULMODE). This mode is always by default enabled. + +When this bit is set, the wakeup interrupt has to be cleared manually +(cannot use interrupt response with pulse) + +Sensor must be in standby mode before performing this action + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_enable_wakeup_latch(kxtj3_context dev); + + /** +@brief Disables the Unlatched mode motion interrupt (ULMODE). This mode is always by default enabled +(cannot use interrupt response with pulse). + +The wakeup threshold is advised to not be very low to avoid interrupt being triggered in +an almost continuous manner + +Sensor must be in standby mode before performing this action + +When this bit is cleared, and the interrupt response type is set to Pulse, then upon a wakeup event +the wakeup interrupt signal will pulse and return low, but only once. Then, the interrupt +output will not reset until data is read or interrupt cleared. + +@param dev The sensor context +@return UPM result +*/ + upm_result_t kxtj3_disable_wakeup_latch(kxtj3_context dev); + + /** +@brief Sets the timer counter of motion before sending a wakeup interrupt + +The count is limited to values from 1 to 255 + +Every count is calculated as (1 / Wakeup_ODR_FREQUENCY) where Wakeup_ODR_FREQUENCY +is the current odr_in_Hz value from odr_map_in_Hz_wakeup value + +Sensor must be in standby mode before performing this action + +See datasheet for more details + +@param dev The sensor context +@param count The timer count from 1 to 255 +@return UPM result + */ + upm_result_t kxtj3_set_wakeup_motion_counter(kxtj3_context dev, uint8_t count); + + /** +@brief Sets the timer of motion before sending a wakeup interrupt + +the desired time should be such that (0 < desired_time * wakeup_odr_frequency <= 255) + +Sensor must be in standby mode before performing this action + +See datasheet for more details + +@param dev The sensor context +@param desired_time The desired time in seconds +@return UPM result + */ + upm_result_t kxtj3_set_wakeup_motion_time(kxtj3_context dev, float desired_time); + + /** +@brief Gets the current count value of the timer of motion before sending a wakeup interrupt + +@param dev The sensor context +@param out_time Pointer to a float variable to store the time value in seconds +@return UPM result + */ + upm_result_t kxtj3_get_wakeup_motion_time(kxtj3_context dev, float *out_time); + + /** +@brief Sets the timer counter of non-activity before sending another wakeup interrupt + +The count is limited to values from 1 to 255 + +Every count is calculated as (1 / Wakeup_ODR_FREQUENCY) where Wakeup_ODR_FREQUENCY +is the current odr_in_Hz value from odr_map_in_Hz_wakeup value + +Sensor must be in standby mode before performing this action + +See datasheet for more details + +@param dev The sensor context +@param count The timer count from 1 to 255 +@return UPM result + */ + upm_result_t kxtj3_set_wakeup_non_activity_counter(kxtj3_context dev, uint8_t count); + + /** +@brief Sets the timer of non-activity before sending another wakeup interrupt + +the desired time should be such that (0 < desired_time * wakeup_odr_frequency <= 255) + +Sensor must be in standby mode before performing this action + +See datasheet for more details + +@param dev The sensor context +@param desired_time The desired time in seconds +@return UPM result + */ + upm_result_t kxtj3_set_wakeup_non_activity_time(kxtj3_context dev, float desired_time); + + /** +@brief Gets the current count value of the timer of non-activity before sending another wakeup interrupt + +@param dev The sensor context +@param out_time Pointer to a float variable to store the time value in seconds +@return UPM result + */ + upm_result_t kxtj3_get_wakeup_non_activity_time(kxtj3_context dev, float *out_time); + + /** +@brief Sets the threshold counter for acceleration difference before sending a wakeup interrupt + +The count is limited to values from 1 to 4096, that it is 16g threshold with (3.9mg/count) +It is advised to not set the threshold to a very low value which may cause bad behaviour +in the wakeup interrupt + +Sensor must be in standby mode before performing this action + +See datasheet for more details + +@param dev The sensor context +@param count The timer count from 1 to 4096, that it is 16g threshold with (3.9mg/count) +@return UPM result + */ + upm_result_t kxtj3_set_wakeup_threshold_counter(kxtj3_context dev, uint16_t count); + + /** +@brief Sets the threshold g value for acceleration difference before sending a wakeup interrupt + +The count is limited to values up to 16g, with steps of 3.9mg. It is advised to not set +the threshold to a very low value which may cause bad behaviour in the wakeup interrupt + +Sensor must be in standby mode before performing this action + +See datasheet for more details + +@param dev The sensor context +@param g_threshold The acceleration threshold (in g) in g, from 3.9mg to 16g, steps of 3.9mg/count +@return UPM result + */ + upm_result_t kxtj3_set_wakeup_threshold_g_value(kxtj3_context dev, float g_threshold); + + /** +@brief Gets the current threshold difference value before sending wakeup interrupt + +@param dev The sensor context +@param out_threshold Pointer to a float variable to store the threshold value in g +@return UPM result + */ + upm_result_t kxtj3_get_wakeup_threshold(kxtj3_context dev, float *out_threshold); + +#ifdef __cplusplus +} +#endif diff -Nru upm-1.6.0/src/kxtj3/kxtj3.hpp upm-1.7.1/src/kxtj3/kxtj3.hpp --- upm-1.6.0/src/kxtj3/kxtj3.hpp 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kxtj3/kxtj3.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,565 @@ +/* +* 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. +*/ + +#pragma once + +#include +#include + +#include "kxtj3.h" + +/** + * @brief C API for the kxtj3 driver + * @defgroup kxtj3 libupm-kxtj3 + * @ingroup Kionix i2c accelerometer + * + * @include kxtj3.cxx + */ + +/** + * @library kxtj3 + * @sensor kxtj3 + * @comname tri-axis accelerometer + * @type accelerometer + * @man Kionix + * @con i2c + * + * @brief C++ API for the kxtj3 driver + * + * @image html kxtj3.png + */ + +namespace upm +{ +class KXTJ3 +{ +public: + /** + * @brief KXTJ3 constructor + * + * If no errors occur, the device is initialized with default values and set to active state + * + * @param bus I2C bus + * @param addr I2C address of the sensor + * @throws std::runtime_error on initialization failure + */ + KXTJ3(int bus, uint8_t addr = 0x0f); + + /** + * @brief KXTJ3 destructor + * + * Closes the I2C context, and removes interrupts + * Frees memory of the kxtj3_context + * + * @throws std::runtime_error on initialization failure + */ + virtual ~KXTJ3(); + + /** + * @brief Initializes the sensor with given sampling rate, resolution and acceleration range. + * This gets called in the constructor, so it will not need to be called unless the device is reset. + * + * Sensor is set to standby mode during the initialization and back to active after initialization. + * + * @param odr One of the KXTJ3_ODR_T values + * @param resolution One of the KXTJ3_RESOLUTION_T values + * @param g_range One of the KXTJ3_G_RANGE_T values + * @throws std::runtime_error on failure + */ + void SensorInit(KXTJ3_ODR_T odr, KXTJ3_RESOLUTION_T resolution, KXTJ3_G_RANGE_T g_range); + + /** + * @brief Gets "who am I" value of the sensor + * + * @return Who am I value of the sensor + * @throws std::runtime_error on failure + */ + uint8_t GetWhoAmI(); + + /** + * @brief Sets the sensor to active mode + * + * @throws std::runtime_error on failure + */ + void SensorActive(); + + /** + * @brief Sets the sensor to standby mode + + * @throws std::runtime_error on failure + */ + void SensorStandby(); + + /** + * @brief Sets the acceleration range of the sensor + * + * Sensor needs to be in standby mode when setting the acceleration range value + * + * Be cautious not to set g_range to 14-bits modes with the resolution being on LOW_RES + * + * @param g_range One of the KXTJ3_G_RANGE_T values + * @throws std::runtime_error on failure + */ + void SetGRange(KXTJ3_G_RANGE_T g_range); + + /** + * @brief Sets the resolution of the sensor. High resolution (14 bits and 12 bits) or low resolution (8 bits). + * + * LOW_RES valid only for ODR <= 200 Hz + * + * Be cautious not to set resolution to LOW_RES with the G_RANG being on 14-bits modes + * + * Sensor needs to be in standby mode when setting the sensor resolution + * + * @param resolution One of the KXTJ3_RESOLUTION_T values + * @throws std::runtime_error on failure + */ + void SetResolution(KXTJ3_RESOLUTION_T resolution); + + /** + * @brief Sets the ODR of the sensor + * + * Sensor needs to be in standby mode when setting the ODR + * + * @param odr One of the KXTJ3_ODR_T values + * @throws std::runtime_error on failure + */ + void SetOdr(KXTJ3_ODR_T odr); + + /** + * @brief Sets the ODR of the wakeup function of the sensor + * + * Sensor needs to be in standby mode when setting the ODR + * + * @param odr One of the KXTJ3_ODR_WAKEUP_T values + * @throws std::runtime_error on failure + */ + void SetOdrForWakeup(KXTJ3_ODR_WAKEUP_T odr); + + /** + * @brief Performs a self-test for digital communication of the sensor. The test sets DCST bit in + * CTRL_REG2, then checks the DCST_RESP register for a 0xAA, after the register is read, its + * value is 0x55 and DCST bit is cleared. + * + * This method is called by SensorSelfTest also + * + * Sensor must be in standby mode before performing this action + * + * @throws std::runtime_error on failure + */ + void SelfTestDigitalCommunication(); + + /** + * @brief Performs a self-test of the sensor. The test applies an electrostatic force to the sensor, + * simulating input acceleration. The test compares samples from all axis before and after + * applying the electrostatic force to the sensor. If the amount of acceleration increases according + * to the values defined in TABLE 1 of the datasheet (0.5 g), the test passes. + * + * The method prints out the values before and during test and the average difference for each axis + * + * See the datasheet for more information + * + * @throws std::runtime_error on failure + */ + void SensorSelfTest(); + + /** + * @brief Performs a sensor software reset. The software reset clears the RAM of the sensor and resets all registers + * to pre-defined values. + * + * You should call kxtj3_sensor_init() after the software reset + * + * See the datasheet for more details + * + * @throws std::runtime_error on failure + */ + void SensorSoftwareReset(); + + /** + * Gets raw acceleration data from the sensor. + * + * @return Acceleration vector [x, y, z] + * @throws std::runtime_error on failure. + */ + std::vector GetAccelerationRawVector(); + + /** + * Gets acceleration data in (m/s^2) from the sensor. + * + * @return Acceleration vector [x, y, z] + * @throws std::runtime_error on failure. + */ + std::vector GetAccelerationVector(); + + /** + * @brief Gets the duration of one sample period (in seconds) for getting the acceleration data depending on + * the sampling rate of the sensor + * + * @return Floating point value of the sampling period + * @throws std::runtime_error on failure + */ + float GetAccelerationSamplePeriod(); + + /** + * @brief Gets the duration of one sample period (in seconds) for the wakeup function depending on + * the sampling rate of the sensor wakeup function + * + * @return Floating point value of the sampling period + * @throws std::runtime_error on failure + */ + float GetWakeUpSamplePeriod(); + + /** + * @brief Enables the data ready interrupt. Availability of new acceleration data is + * reflected as an interrupt. + * + * Sensor must be in standby mode before performing this action + * + * @throws std::runtime_error on failure + */ + void EnableDataReadyInterrupt(); + + /** + * @brief Disables the data ready interrupt + * + * Sensor must be in standby mode before performing this action + * + * @throws std::runtime_error on failure + */ + void DisableDataReadyInterrupt(); + + /** + * @brief Enables the wakeup function (motion detection) + * + * Sensor must be in standby mode before performing this action + * + * @throws std::runtime_error on failure + */ + void EnableWakeUpInterrupt(); + + /** + * @brief Disables the wakeup function (motion detection) + * + * Sensor must be in standby mode before performing this action + * + * @throws std::runtime_error on failure + */ + void DisableWakeUpInterrupt(); + + /** + * @brief Enables interrupts on the interrupt pin, sets polarity and response types. + * Polarity ACTIVE_HIGH or ACTIVE_LOW. + * Response either latch until cleared by reading INT_REL register, or transmit one pulse + * Pulse width of 0.03-0.05ms. + * + * For Wakeup function, the response type is always latched unless set wakeup latch off + * Sensor needs to be in standby mode when enabling the interrupt + * + * See datasheet for more details + * + * @param polarity Select the polarity of the interrupt. One of the KXTJ3_INTERRUPT_POLARITY_T values. + * @param response_type Select the response type of the interrupt. One of the KXTJ3_INTERRUPT_RESPONSE_T values. + * @throws std::runtime_error on failure + */ + void EnableInterruptPin(KXTJ3_INTERRUPT_POLARITY_T polarity, KXTJ3_INTERRUPT_RESPONSE_T response_type); + + /** + * @brief Disables interrupts on the interrupt pin of the sensor + * + * Sensor needs to be in standby mode when disabling the interrupt pin + * + * @throws std::runtime_error on failure + */ + void DisableInterruptPin(); + + /** + * @brief Sets the polarity of the interrupt pin + * + * Polarity ACTIVE_HIGH or ACTIVE_LOW + * + * Sensor must be in standby mode before performing this action + * + * @param polarity Select the polarity of the interrupt. One of the KXTJ3_INTERRUPT_POLARITY_T values. + * @throws std::runtime_error on failure + */ + void SetInterruptPolarity(KXTJ3_INTERRUPT_POLARITY_T polarity); + + /** + * @brief Sets the response type of the interrupt pin + * + * Response either latch until cleared by reading INT_REL register, or transmit one pulse + * Pulse width of 0.03-0.05ms + * + * For Wakeup function, the response type is always latched unless set wakeup latch off + * + * Sensor must be in standby mode before performing this action + * + * See datasheet for more details + * + * @param response_type Select the response type of the interrupt. One of the KXTJ3_INTERRUPT_RESPONSE_T values + * @throws std::runtime_error on failure + */ + void SetInerruptResponse(KXTJ3_INTERRUPT_RESPONSE_T response_type); + + /** + * @brief Gets the status of the interrupts. (Has an interrupt occurred) + * + * See datasheet for more details + * + * @return Return true if an interrupt event has occurred (DRDY or WUFS is 1), + * returns false if no interrupts have occurred + */ + bool GetInterruptStatus(); + + /** + * @brief Gets the source of the interrupt + * The value stored is one or more of the KXTJ3_INTERRUPT_SOURCE_T values + * + * See datasheet for more details + * + * @return Value of the interrupt source register + * @throws std::runtime_error on failure + */ + uint8_t ReadInterruptSource1(); + + /** + * @brief Gets the source of the interrupt + * + * See datasheet for more details + * + * @return One of the KXTJ3_INTERRUPT_SOURCE_T values/types + */ + KXTJ3_INTERRUPT_SOURCE_T GetInterruptSource(); + + /** + * @brief Installs an interrupt handler to be executed when an interrupt is detected on the interrupt pin + + * @param edge One of the mraa_gpio_edge_t values. Interrupt trigger edge. + * @param pin The GPIO pin to use as the interrupt pin + * @param isr Pointer to the method to be called, when the interrupt occurs + * @param isr_args The arguments to be passed to the method + * @return std::runtime_error on failure + */ + void InstallIsr(mraa_gpio_edge_t edge, int pin, void (*isr)(void *), void *isr_args); + + /** + * @brief Uninstalls a previously installed interrupt handler for interrupt pin + * + * @throws std::runtime_error on failure + */ + void UninstallIsr(); + + /** + * @brief Clears latching interrupts information of Wakeup (with axis and direction information) and Data Ready + * + * See datasheet for more details + * + * @throws std::runtime_error on failure + */ + void ClearInterrupt(); + + /** + * @brief Enables wakeup interrupt for the given axis (axis with direction) + * + * Sensor must be in standby mode before performing this action + * + * @param axis The axis to enable, takes one of KXTJ3_WAKEUP_SOURCE_T value + * @throws std::runtime_error on failure + */ + void EnableWakeUpSingleAxisDirection(KXTJ3_WAKEUP_SOURCE_T axis); + + /** + * @brief Disables wakeup interrupt for the given axis (axis with direction) + * + * Sensor must be in standby mode before performing this action + * + * @param axis The axis to enable, takes one of KXTJ3_WAKEUP_SOURCE_T value + * @throws std::runtime_error on failure + */ + void DisableWakeUpSingleAxisDirection(KXTJ3_WAKEUP_SOURCE_T axis); + + /** + * @brief Gets the source axis and direction of motion detection of the wakeup function interrupt + * + * See datasheet for more details + * + * @return A kxtj3_wakeup_axes struct with values of true/false + * for a wakeup for each axis and its direction + */ + kxtj3_wakeup_axes GetWakeUpAxisDirection(); + + /** + * @brief Enables the Unlatched mode motion interrupt (ULMODE). This mode is always by default enabled. + * + * When this bit is set, the wakeup interrupt has to be cleared manually + * (cannot use interrupt response with pulse) + * + * Sensor must be in standby mode before performing this action + * + * @throws std::runtime_error on failure + */ + void EnableWakeUpLatch(); + + /** + * @brief Disables the Unlatched mode motion interrupt (ULMODE). This mode is always by default enabled. + * (cannot use interrupt response with pulse) + * + * The wakeup threshold is advised to not be very low to avoid interrupt being triggered in + * an almost continuous manner + * + * Sensor must be in standby mode before performing this action + * + * When this bit is cleared, and the interrupt response type is set to Pulse, then upon a wakeup event + * the wakeup interrupt signal will pulse and return low, but only once. Then, the interrupt + * output will not reset until data is read or interrupt cleared. + + * @throws std::runtime_error on failure + */ + void DisableWakeUpLatch(); + + /** + * @brief Sets the timer counter of motion before sending a wakeup interrupt + * + * The count is limited to values from 1 to 255 + * + * Every count is calculated as (1 / Wakeup_ODR_FREQUENCY) where Wakeup_ODR_FREQUENCY + * is the current odr_in_Hz value from odr_map_in_Hz_wakeup value + * + * Sensor must be in standby mode before performing this action + * + * See datasheet for more details + * + * @param count The timer count from 1 to 255 + * @throws std::runtime_error on failure + */ + void SetWakeUpMotionCounter(uint8_t count); + + /** + * @brief Sets the timer of motion before sending a wakeup interrupt + * + * the desired time should be such that (0 < desired_time * wakeup_odr_frequency <= 255) + * + * Sensor must be in standby mode before performing this action + * + * See datasheet for more details + * + * @param desired_time The desired time in seconds + * @throws std::runtime_error on failure + */ + void SetWakeUpMotionTime(float desired_time); + + /** + * @brief Get the current count value of the timer of motion before sending a wakeup interrupt + * + * @return Time value in seconds + * @throws std::runtime_error on failure + */ + float GetWakeUpMotionTime(); + + /** + * @brief Sets the timer counter of non-activity before sending another wakeup interrupt + * + * The count is limited to values from 1 to 255 + * + * Every count is calculated as (1 / Wakeup_ODR_FREQUENCY) where Wakeup_ODR_FREQUENCY + * is the current odr_in_Hz value from odr_map_in_Hz_wakeup value + * + * Sensor must be in standby mode before performing this action + * + * See datasheet for more details + * + * @param count The timer count from 1 to 255 + * @throws std::runtime_error on failure + */ + void SetWakeUpNonActivityCounter(uint8_t count); + + /** + * @brief Sets the timer of non-activity before sending another wakeup interrupt + * + * the desired time should be such that (0 < desired_time * wakeup_odr_frequency <= 255) + * + * Sensor must be in standby mode before performing this action + * + * See datasheet for more details + * + * @param desired_time The desired time in seconds + * @throws std::runtime_error on failure + */ + void SetWakeUpNonActivityTime(float desired_time); + + /** + * @brief Get the current count value of the timer of non-activity before sending another wakeup interrupt + * + * @return Time value in seconds + * @throws std::runtime_error on failure + */ + float GetWakeUpNonActivityTime(); + + /** + * @brief Sets the threshold counter for acceleration difference before sending a wakeup interrupt + * + * The count is limited to values from 1 to 4096, that it is 16g threshold with (3.9mg/count) + * It is advised to not set the threshold to a very low value which may cause bad behaviour + * in the wakeup interrupt + * + * Sensor must be in standby mode before performing this action + * + * See datasheet for more details + * + * @param count The timer count from 1 to 4096, that it is 16g threshold with (3.9mg/count) + * @throws std::runtime_error on failure + */ + void SetWakeUpThresholdCounter(uint16_t count); + + /** + * @brief Sets the threshold g value for acceleration difference before sending a wakeup interrupt + * + * The count is limited to values up to 16g, with steps of 3.9mg. It is advised to not set + * the threshold to a very low value which may cause bad behaviour in the wakeup interrupt + * + * Sensor must be in standby mode before performing this action + * + * See datasheet for more details + * + * @param g_threshold The acceleration threshold (in g) in g, from 3.9mg to 16g, steps of 3.9mg/count. + * @throws std::runtime_error on failure + */ + void SetWakeUpThresholdGRange(float g_threshold); + + /** + * @brief Get the current threshold difference value before sending wakeup interrupt + * + * @return Threshold value in g + * @throws std::runtime_error on failure + */ + float GetWakeUpThresholdGRange(); + +private: + kxtj3_context m_kxtj3; + + /* Disable implicit copy and assignment operators */ + KXTJ3(const KXTJ3 &) = delete; + KXTJ3 &operator=(const KXTJ3 &) = delete; +}; +} // namespace upm diff -Nru upm-1.6.0/src/kxtj3/kxtj3.i upm-1.7.1/src/kxtj3/kxtj3.i --- upm-1.6.0/src/kxtj3/kxtj3.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kxtj3/kxtj3.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,20 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_kxtj3) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "std_vector.i" +%template(floatVector) std::vector; + +%apply float *OUTPUT {float *x, float *y, float *z}; + +%{ +#include "kxtj3.hpp" +%} +%include "kxtj3.h" +%include "kxtj3.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/kxtj3/kxtj3.json upm-1.7.1/src/kxtj3/kxtj3.json --- upm-1.6.0/src/kxtj3/kxtj3.json 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kxtj3/kxtj3.json 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,72 @@ +{ + "Library": "KXTJ3", + "Description": "Kionix KXTJ3 tri-axis accelerometer sensor library", + "Sensor Class": { + "KXTJ3": { + "Name": "Kionix KXTJ3 tri-axis accelerometer sensor", + "Description": "This is the UPM Module for the Kionix KXTJ3 accelerometer sensor. The Kionix KXTJ3 sensor is a multifunctional sensor that provides multiple functionalities. The sensor provides an extended g-range up to +/- 16g, higher resolution embedded wake-up function down to 3.9mg, and a flexible interrupt circuitry. The KXTJ3 sense element offers lower noise performance, exceptional shock resiliency, stable performance over temperature, and virtually eliminates offset and sensitivity shifts from reflow.", + "Categories": [ + "acceleration" + ], + "Connections": [ + "i2c" + ], + "Project Type": [ + "prototyping", + "commercial" + ], + "Manufacturers": [ + "Kionix" + ], + "Image": "kxtj3.png", + "Examples": { + "C++": [ + "kxtj3.cxx" + ], + "C": [ + "kxtj3.c" + ], + "Java": [ + "KXTJ3_Example.java" + ], + "Python": [ + "kxtj3.py" + ], + "Node.js": [ + "kxtj3.js" + ] + }, + "Specifications": { + "Supply Voltage (VDD)": { + "unit": "V", + "min": 1.71, + "typical": 2.5, + "max": 3.6 + }, + "I/O Pads Supply Voltage (IO_VDD)": { + "unit": "V", + "min": 1.7, + "max": 3.6 + }, + "Supply Current": { + "unit": "uA", + "min": 0.9, + "max": 155 + }, + "Operating Temperature": { + "unit": "°C", + "min": -40, + "max": 85 + } + }, + "Urls": { + "Product Pages": [ + "http://www.kionix.com/product/KXTJ3-1057" + ], + "Datasheets": [ + "http://kionixfs.kionix.com/en/datasheet/KXTJ3-1057-Specifications-Rev-3.0.pdf" + ] + } + } + } +} diff -Nru upm-1.6.0/src/kxtj3/kxtj3_registers.h upm-1.7.1/src/kxtj3/kxtj3_registers.h --- upm-1.6.0/src/kxtj3/kxtj3_registers.h 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/kxtj3/kxtj3_registers.h 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,204 @@ +/* +The MIT License (MIT) +Copyright (c) 2017 Kionix Inc. + +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. +*/ + +#ifndef __KXTJ3_REGISTERS_H__ +#define __KXTJ3_REGISTERS_H__ +/* registers */ +// output register x +#define KXTJ3_XOUT_L 0x06 +#define KXTJ3_XOUT_H 0x07 +// output register y +#define KXTJ3_YOUT_L 0x08 +#define KXTJ3_YOUT_H 0x09 +// output register z +#define KXTJ3_ZOUT_L 0x0A +#define KXTJ3_ZOUT_H 0x0B +// This register can be used to verify proper integrated circuit functionality +#define KXTJ3_DCST_RESP 0x0C +// This register can be used for supplier recognition, as it can be factory written to a known byte value. +#define KXTJ3_WHO_AM_I 0x0F +// This register reports which function caused an interrupt. +#define KXTJ3_INT_SOURCE1 0x16 +// This register reports the axis and direction of detected motion +#define KXTJ3_INT_SOURCE2 0x17 +// This register reports the status of the interrupt +#define KXTJ3_STATUS_REG 0x18 +#define KXTJ3_INT_REL 0x1A +// Read/write control register that controls the main feature set +#define KXTJ3_CTRL_REG1 0x1B +// Read/write control register that provides more feature set control +#define KXTJ3_CTRL_REG2 0x1D +// This register controls the settings for the physical interrupt pin +#define KXTJ3_INT_CTRL_REG1 0x1E +// This register controls which axis and direction of detected motion can cause an interrupt +#define KXTJ3_INT_CTRL_REG2 0x1F +// Read/write control register that configures the acceleration outputs +#define KXTJ3_DATA_CTRL_REG 0x21 +#define KXTJ3_WAKEUP_COUNTER 0x29 +#define KXTJ3_NA_COUNTER 0x2A +// When 0xCA is written to this register, the MEMS self-test function is enabled +#define KXTJ3_SELF_TEST 0x3A +#define KXTJ3_WAKEUP_THRESHOLD_H 0x6A +#define KXTJ3_WAKEUP_THRESHOLD_L 0x6B +// This register can be used for supplier recognition, as it can be factory written to a known byte value. +#define KXCJC_WHO_AM_I 0x0F +/* registers bits */ +// before set +#define KXTJ3_DCST_RESP_DCSTR_BEFORE (0x55 << 0) +// after set +#define KXTJ3_DCST_RESP_DCSTR_AFTER (0xAA << 0) +// WHO_AM_I -value for KXTJ3 +#define KXTJ3_WHO_AM_I_WIA_ID (0x35 << 0) +// indicates that new acceleration data +#define KXTJ3_INT_SOURCE1_DRDY (0x01 << 4) +// Wake up +#define KXTJ3_INT_SOURCE1_WUFS (0x01 << 1) +// x- +#define KXTJ3_INT_SOURCE2_XNWU (0x01 << 5) +// x+ +#define KXTJ3_INT_SOURCE2_XPWU (0x01 << 4) +// y- +#define KXTJ3_INT_SOURCE2_YNWU (0x01 << 3) +// y+ +#define KXTJ3_INT_SOURCE2_YPWU (0x01 << 2) +// z- +#define KXTJ3_INT_SOURCE2_ZNWU (0x01 << 1) +// z+ +#define KXTJ3_INT_SOURCE2_ZPWU (0x01 << 0) +// reports the combined (OR) interrupt information of DRDY and WUFS in the interrupt source register +#define KXTJ3_STATUS_REG_INT (0x01 << 4) +// controls the operating mode of the KXTJ3 +#define KXTJ3_CTRL_REG1_PC (0x01 << 7) +// determines the performance mode of the KXTJ3 +#define KXTJ3_CTRL_REG1_RES (0x01 << 6) +// enables the reporting of the availability of new acceleration data as an interrupt +#define KXTJ3_CTRL_REG1_DRDYE (0x01 << 5) +// 2g range +#define KXTJ3_CTRL_REG1_GSEL_2G (0x00 << 2) +// 16g range +#define KXTJ3_CTRL_REG1_GSEL_16G (0x01 << 2) +// 4g range +#define KXTJ3_CTRL_REG1_GSEL_4G (0x02 << 2) +// 16g range +#define KXTJ3_CTRL_REG1_GSEL_16G2 (0x03 << 2) +// 8g range +#define KXTJ3_CTRL_REG1_GSEL_8G (0x04 << 2) +// 16g range +#define KXTJ3_CTRL_REG1_GSEL_16G3 (0x05 << 2) +// 8g range with 14b resolution +#define KXTJ3_CTRL_REG1_GSEL_8G_14 (0x06 << 2) +// 16g range with 14b resolution +#define KXTJ3_CTRL_REG1_GSEL_16G_14 (0x07 << 2) +// enables 14-bit mode if GSEL = '11' +#define KXTJ3_CTRL_REG1_EN16G (0x01 << 2) +// enables the Wake Up (motion detect) function. +#define KXTJ3_CTRL_REG1_WUFE (0x01 << 1) +// initiates software reset +#define KXTJ3_CTRL_REG2_SRST (0x01 << 7) +// initiates the digital communication self-test function. +#define KXTJ3_CTRL_REG2_DCST (0x01 << 4) +// 0.78Hz +#define KXTJ3_CTRL_REG2_OWUF_0P781 (0x00 << 0) +// 1.563Hz +#define KXTJ3_CTRL_REG2_OWUF_1P563 (0x01 << 0) +// 3.125Hz +#define KXTJ3_CTRL_REG2_OWUF_3P125 (0x02 << 0) +// 6.25Hz +#define KXTJ3_CTRL_REG2_OWUF_6P25 (0x03 << 0) +// 12.5Hz +#define KXTJ3_CTRL_REG2_OWUF_12P5 (0x04 << 0) +// 25Hz +#define KXTJ3_CTRL_REG2_OWUF_25 (0x05 << 0) +// 50Hz +#define KXTJ3_CTRL_REG2_OWUF_50 (0x06 << 0) +// 100Hz +#define KXTJ3_CTRL_REG2_OWUF_100 (0x07 << 0) +// enables/disables the physical interrupt pin +#define KXTJ3_INT_CTRL_REG1_IEN (0x01 << 5) +// sets the polarity of the physical interrupt pin +#define KXTJ3_INT_CTRL_REG1_IEA (0x01 << 4) +// sets the response of the physical interrupt pin +#define KXTJ3_INT_CTRL_REG1_IEL (0x01 << 3) +// selftest polarity +#define KXTJ3_INT_CTRL_REG1_STPOL (0x01 << 1) +// Unlatched mode motion interrupt; 0=disabled,1=enabled +#define KXTJ3_INT_CTRL_REG2_ULMODE (0x01 << 7) +// x- +#define KXTJ3_INT_CTRL_REG2_XNWU (0x01 << 5) +// x+ +#define KXTJ3_INT_CTRL_REG2_XPWU (0x01 << 4) +// y- +#define KXTJ3_INT_CTRL_REG2_YNWU (0x01 << 3) +// y+ +#define KXTJ3_INT_CTRL_REG2_YPWU (0x01 << 2) +// z- +#define KXTJ3_INT_CTRL_REG2_ZNWU (0x01 << 1) +// z+ +#define KXTJ3_INT_CTRL_REG2_ZPWU (0x01 << 0) +// 12.5Hz +#define KXTJ3_DATA_CTRL_REG_OSA_12P5 (0x00 << 0) +// 25Hz +#define KXTJ3_DATA_CTRL_REG_OSA_25 (0x01 << 0) +// 50Hz +#define KXTJ3_DATA_CTRL_REG_OSA_50 (0x02 << 0) +// 100Hz +#define KXTJ3_DATA_CTRL_REG_OSA_100 (0x03 << 0) +// 200Hz +#define KXTJ3_DATA_CTRL_REG_OSA_200 (0x04 << 0) +// 400Hz +#define KXTJ3_DATA_CTRL_REG_OSA_400 (0x05 << 0) +// 800Hz +#define KXTJ3_DATA_CTRL_REG_OSA_800 (0x06 << 0) +// 1600Hz +#define KXTJ3_DATA_CTRL_REG_OSA_1600 (0x07 << 0) +// 0.78Hz +#define KXTJ3_DATA_CTRL_REG_OSA_0P781 (0x08 << 0) +// 1.563Hz +#define KXTJ3_DATA_CTRL_REG_OSA_1P563 (0x09 << 0) +// 3.125Hz +#define KXTJ3_DATA_CTRL_REG_OSA_3P125 (0x0A << 0) +// 6.25Hz +#define KXTJ3_DATA_CTRL_REG_OSA_6P25 (0x0B << 0) +// charge on +#define KXTJ3_SELF_TEST_MEMS_TEST_ENABLE (0xCA << 0) +// charge off +#define KXTJ3_SELF_TEST_MEMS_TEST_DISABLE (0x00 << 0) +// WHO_AM_I -value for KXCJC +#define KXCJC_WHO_AM_I_WIA_ID (0x36 << 0) +/*registers bit masks */ + +#define KXTJ3_DCST_RESP_DCSTR_MASK 0xFF + +#define KXTJ3_WHO_AM_I_WIA_MASK 0xFF +// selects the acceleration range of the accelerometer outputs +#define KXTJ3_CTRL_REG1_GSEL_MASK 0x1C +// sets the Output Data Rate for the Wake Up function +#define KXTJ3_CTRL_REG2_OWUF_MASK 0x07 +// sets the output data rate (ODR) +#define KXTJ3_DATA_CTRL_REG_OSA_MASK 0x0F + +#define KXTJ3_SELF_TEST_MEMS_TEST_MASK 0xFF + +#define KXCJC_WHO_AM_I_WIA_MASK 0xFF +#endif diff -Nru upm-1.6.0/src/l298/javaupm_l298.i upm-1.7.1/src/l298/javaupm_l298.i --- upm-1.6.0/src/l298/javaupm_l298.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/l298/javaupm_l298.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_l298 -%include "../upm.i" - -%{ - #include "l298.hpp" -%} - -%include "l298.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_l298) \ No newline at end of file diff -Nru upm-1.6.0/src/l298/jsupm_l298.i upm-1.7.1/src/l298/jsupm_l298.i --- upm-1.6.0/src/l298/jsupm_l298.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/l298/jsupm_l298.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_l298 -%include "../upm.i" - -%{ - #include "l298.hpp" -%} - -%include "l298.hpp" diff -Nru upm-1.6.0/src/l298/l298.hpp upm-1.7.1/src/l298/l298.hpp --- upm-1.6.0/src/l298/l298.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/l298/l298.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -58,8 +58,8 @@ * * @image html l298.jpg *
L298 Dual H-Bridge Motor Driver image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * Example driving a DC motor * @snippet l298.cxx Interesting diff -Nru upm-1.6.0/src/l298/l298.json upm-1.7.1/src/l298/l298.json --- upm-1.6.0/src/l298/l298.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/l298/l298.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "l298", - "Description": "API for the L298 Dual H-Bridge Motor Driver", - "Sensor Class": - { - "L298": - { - "Name": "Dual H-bridge Motor Driver", - "Description": "It was developed using the RobotBase Dual H-Bridge module. This module can support 2 DC motors, or one 2-phase stepper motor. It requires 3 pins per DC motor (or H-bridge), or 4 pins for the stepper motor (uses both H-bridges).", - "Aliases": ["l298"], - "Categories": ["motors"], - "Connections": ["gpio", "pwm"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["seeed", "sparkfun"], - "Kits": [], - "Image": "l298.jpg", - "Examples": - { - "Java": [], - "Python": ["l298.py", "l298-stepper.py"], - "Node.js": ["l298.js", "l298-stepper.js"], - "C++": ["l298.cxx", "l298-stepper.cxx"], - "C": [] - }, - "Specifications": - { - "Motor Supply Voltage": {"unit": "V", "low": 6, "high": 35}, - "Motor Supply Current": {"unit": "A", "typ": 2} - }, - "Urls" : - { - "Product Pages": ["https://www.sparkfun.com/products/9670"], - "Datasheets": [], - "Schematics": [] - } - } - } -} +{ + "Library": "l298", + "Description": "API for the L298 Dual H-Bridge Motor Driver", + "Sensor Class": + { + "L298": + { + "Name": "Dual H-bridge Motor Driver", + "Description": "It was developed using the RobotBase Dual H-Bridge module. This module can support 2 DC motors, or one 2-phase stepper motor. It requires 3 pins per DC motor (or H-bridge), or 4 pins for the stepper motor (uses both H-bridges).", + "Aliases": ["l298"], + "Categories": ["motors"], + "Connections": ["gpio", "pwm"], + "Project Type": ["robotics", "prototyping"], + "Manufacturers": ["seeed", "sparkfun"], + "Kits": [], + "Image": "l298.jpg", + "Examples": + { + "Java": [], + "Python": ["l298.py", "l298-stepper.py"], + "Node.js": ["l298.js", "l298-stepper.js"], + "C++": ["l298.cxx", "l298-stepper.cxx"], + "C": [] + }, + "Specifications": + { + "Motor Supply Voltage": {"unit": "V", "low": 6, "high": 35}, + "Motor Supply Current": {"unit": "A", "typ": 2} + }, + "Urls" : + { + "Product Pages": ["https://www.sparkfun.com/products/9670"], + "Datasheets": [], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/l298/pyupm_l298.i upm-1.7.1/src/l298/pyupm_l298.i --- upm-1.6.0/src/l298/pyupm_l298.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/l298/pyupm_l298.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_l298 -%include "../upm.i" - -%include "l298.hpp" -%{ - #include "l298.hpp" -%} diff -Nru upm-1.6.0/src/l3gd20/javaupm_l3gd20.i upm-1.7.1/src/l3gd20/javaupm_l3gd20.i --- upm-1.6.0/src/l3gd20/javaupm_l3gd20.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/l3gd20/javaupm_l3gd20.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_l3gd20 -%include "../upm.i" - -%{ - #include "l3gd20.hpp" -%} - -%include "l3gd20.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_l3gd20) diff -Nru upm-1.6.0/src/l3gd20/jsupm_l3gd20.i upm-1.7.1/src/l3gd20/jsupm_l3gd20.i --- upm-1.6.0/src/l3gd20/jsupm_l3gd20.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/l3gd20/jsupm_l3gd20.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_l3gd20 -%include "../upm.i" - -%{ - #include "l3gd20.hpp" -%} - -%include "l3gd20.hpp" diff -Nru upm-1.6.0/src/l3gd20/l3gd20.json upm-1.7.1/src/l3gd20/l3gd20.json --- upm-1.6.0/src/l3gd20/l3gd20.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/l3gd20/l3gd20.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "l3gd20", - "Description": "L3GD20 Tri-axis Digital Gyroscope API", - "Sensor Class": - { - "L3GD20": - { - "Name": "L3GD20 Tri-axis Digital Gyroscope", - "Description": "The L3GD20 The L3GD20 is a low-power three-axis angular rate sensor. This driver supports IIO and I2C modes. Some methods will only work in one mode or the other. See the documentation on the methods to determine whether a given method is operation in a given mode. Both the I2C and IIO mechanisms make use of the calibration and denoise algorithms. For I2C mode, not all capabilities of the device are supported, but a complete register map and low level read/write methods are provided to add any missing functionality.", - "Aliases": ["l3gd20"], - "Categories": ["gyroscope"], - "Connections": ["iio", "i2c"], - "Project Type": ["IMU", "prototyping"], - "Manufacturers": ["stmicro"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["l3gd20.cxx", "l3gd20-i2c.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.4, "high": 3.6}, - "Operating Current": {"unit": "mA", "typ": 6.1}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - - }, - "Urls" : - { - "Product Pages": ["http://www.st.com/en/mems-and-sensors/l3gd20.html"], - "Datasheets": ["http://www.st.com/resource/en/datasheet/l3gd20.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "l3gd20", + "Description": "L3GD20 Tri-axis Digital Gyroscope API", + "Sensor Class": + { + "L3GD20": + { + "Name": "L3GD20 Tri-axis Digital Gyroscope", + "Description": "The L3GD20 The L3GD20 is a low-power three-axis angular rate sensor. This driver supports IIO and I2C modes. Some methods will only work in one mode or the other. See the documentation on the methods to determine whether a given method is operation in a given mode. Both the I2C and IIO mechanisms make use of the calibration and denoise algorithms. For I2C mode, not all capabilities of the device are supported, but a complete register map and low level read/write methods are provided to add any missing functionality.", + "Aliases": ["l3gd20"], + "Categories": ["gyroscope"], + "Connections": ["iio", "i2c"], + "Project Type": ["IMU", "prototyping"], + "Manufacturers": ["stmicro"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["l3gd20.cxx", "l3gd20-i2c.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.4, "high": 3.6}, + "Operating Current": {"unit": "mA", "typ": 6.1}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + + }, + "Urls" : + { + "Product Pages": ["http://www.st.com/en/mems-and-sensors/l3gd20.html"], + "Datasheets": ["http://www.st.com/resource/en/datasheet/l3gd20.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/l3gd20/pyupm_l3gd20.i upm-1.7.1/src/l3gd20/pyupm_l3gd20.i --- upm-1.6.0/src/l3gd20/pyupm_l3gd20.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/l3gd20/pyupm_l3gd20.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module pyupm_l3gd20 -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%include "../upm.i" - -%include "l3gd20.hpp" -%{ - #include "l3gd20.hpp" -%} diff -Nru upm-1.6.0/src/lcd/eboled.hpp upm-1.7.1/src/lcd/eboled.hpp --- upm-1.6.0/src/lcd/eboled.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcd/eboled.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -76,8 +76,8 @@ * * @image html eboled.jpg *
OLED Sensor image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet lcd-eboled.cxx Interesting */ diff -Nru upm-1.6.0/src/lcd/javaupm_lcd.i upm-1.7.1/src/lcd/javaupm_lcd.i --- upm-1.6.0/src/lcd/javaupm_lcd.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcd/javaupm_lcd.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -%module javaupm_lcd -%include "../upm.i" -%include "stdint.i" -%include "typemaps.i" -%include "arrays_java.i"; - -%apply signed char[] {uint8_t []}; -%ignore BasicFont; - -%typemap(jni) (uint8_t *data, int bytes) "jbyteArray"; -%typemap(jtype) (uint8_t *data, int bytes) "byte[]"; -%typemap(jstype) (uint8_t *data, int bytes) "byte[]"; - -%typemap(javain) (uint8_t *data, int bytes) "$javainput"; - -%typemap(in) (uint8_t *data, int bytes) { - $1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL); - $2 = JCALL1(GetArrayLength, jenv, $input); -} - -%typemap(freearg) (uint8_t *data, int bytes) { - JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); -} - -%{ - #include "lcd.hpp" - #include "ssd.hpp" - #include "ssd1327.hpp" - #include "ssd1308.hpp" - #include "ssd1306.hpp" - #include "eboled.hpp" -%} - -%include "lcd.hpp" -%include "ssd.hpp" -%include "ssd1327.hpp" -%include "ssd1308.hpp" -%include "ssd1306.hpp" -%include "eboled.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_i2clcd) diff -Nru upm-1.6.0/src/lcd/jsupm_lcd.i upm-1.7.1/src/lcd/jsupm_lcd.i --- upm-1.6.0/src/lcd/jsupm_lcd.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcd/jsupm_lcd.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -%module jsupm_lcd -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%include "ssd.hpp" -%include "lcd.hpp" -%{ - #include "lcd.hpp" -%} - -%include "ssd1327.hpp" -%{ - #include "ssd1327.hpp" -%} - -%include "ssd1308.hpp" -%{ - #include "ssd1308.hpp" -%} - -%include "eboled.hpp" -%{ - #include "eboled.hpp" -%} - -%include "ssd1306.hpp" -%{ - #include "ssd1306.hpp" -%} diff -Nru upm-1.6.0/src/lcd/lcd.i upm-1.7.1/src/lcd/lcd.i --- upm-1.6.0/src/lcd/lcd.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lcd/lcd.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,56 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; + +%apply signed char[] {uint8_t []}; +%ignore BasicFont; + +%typemap(jni) (uint8_t *data, int bytes) "jbyteArray"; +%typemap(jtype) (uint8_t *data, int bytes) "byte[]"; +%typemap(jstype) (uint8_t *data, int bytes) "byte[]"; + +%typemap(javain) (uint8_t *data, int bytes) "$javainput"; + +%typemap(in) (uint8_t *data, int bytes) { + $1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL); + $2 = JCALL1(GetArrayLength, jenv, $input); +} + +%typemap(freearg) (uint8_t *data, int bytes) { + JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); +} + +JAVA_JNI_LOADLIBRARY(javaupm_i2clcd) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint8_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_uint8_t.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lcd.hpp" +#include "eboled.hpp" +#include "ssd1306.hpp" +#include "ssd1308.hpp" +#include "ssd1327.hpp" +%} + +%include "lcd.hpp" +%include "eboled.hpp" +%include "ssd1306.hpp" +%include "ssd1308.hpp" +%include "ssd1327.hpp" +%include "ssd.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lcd/pyupm_lcd.i upm-1.7.1/src/lcd/pyupm_lcd.i --- upm-1.6.0/src/lcd/pyupm_lcd.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcd/pyupm_lcd.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lcd -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%include "ssd.hpp" -%include "lcd.hpp" -%{ - #include "lcd.hpp" -%} - -%include "ssd1327.hpp" -%{ - #include "ssd1327.hpp" -%} - -%include "ssd1308.hpp" -%{ - #include "ssd1308.hpp" -%} - -%include "eboled.hpp" -%{ - #include "eboled.hpp" -%} - -%include "ssd1306.hpp" -%{ - #include "ssd1306.hpp" -%} diff -Nru upm-1.6.0/src/lcdks/javaupm_lcdks.i upm-1.7.1/src/lcdks/javaupm_lcdks.i --- upm-1.6.0/src/lcdks/javaupm_lcdks.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcdks/javaupm_lcdks.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module javaupm_lcdks -%include "../upm.i" -%include "typemaps.i" -%include "std_vector.i" -%include "stdint.i" - -%template(byteVector) std::vector; - -%include "lcdks.hpp" -%{ - #include "lcdks.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_lcdks) diff -Nru upm-1.6.0/src/lcdks/jsupm_lcdks.i upm-1.7.1/src/lcdks/jsupm_lcdks.i --- upm-1.6.0/src/lcdks/jsupm_lcdks.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcdks/jsupm_lcdks.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_lcdks -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lcdks.hpp" -%{ - #include "lcdks.hpp" -%} diff -Nru upm-1.6.0/src/lcdks/lcdks.i upm-1.7.1/src/lcdks/lcdks.i --- upm-1.6.0/src/lcdks/lcdks.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lcdks/lcdks.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,29 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "std_vector.i" +%template(byteVector) std::vector; + +JAVA_JNI_LOADLIBRARY(javaupm_lcdks) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lcdks.hpp" +%} +%include "lcdks.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lcdks/lcdks.json upm-1.7.1/src/lcdks/lcdks.json --- upm-1.6.0/src/lcdks/lcdks.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcdks/lcdks.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,36 +1,36 @@ -{ - "Library": "lcdks", - "Description": "API for the generic LCD Keypad Shield", - "Sensor Class": - { - "LCDKS": - { - "Name": "LCD Keypad Shield", - "Description": "The LCD Keypad Shield uses 7 digital outputs and 1 analog input (for the keypad). The outputs are used to drive an attached LCM1602 LCD controller. This driver should be compatible with the similar LCD keypad shields from Sainsmart, DFRobot and Sparkfun.", - "Aliases": ["lcdks"], - "Categories": ["userinput"], - "Connections": ["gpio", "analog"], - "Project Type": ["control", "prototyping"], - "Manufacturers": ["sainsmart", "dfrobot", "sparkfun"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": ["lcdks.py"], - "Node.js": ["lcdks.js"], - "C++": ["lcdks.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5} - }, - "Urls" : - { - "Product Pages": ["https://www.sparkfun.com/products/13293", "http://www.sainsmart.com/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html", "http://www.dfrobot.com/index.php?route=product/product&product_id=51"], - "Datasheets": ["http://linksprite.com/wiki/index.php5?title=16_X_2_LCD_Keypad_Shield_for_Arduino_V2"], - "Schematics": ["https://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/16X2_LCD_shield.pdf"] - } - } - } -} +{ + "Library": "lcdks", + "Description": "API for the generic LCD Keypad Shield", + "Sensor Class": + { + "LCDKS": + { + "Name": "LCD Keypad Shield", + "Description": "The LCD Keypad Shield uses 7 digital outputs and 1 analog input (for the keypad). The outputs are used to drive an attached LCM1602 LCD controller. This driver should be compatible with the similar LCD keypad shields from Sainsmart, DFRobot and Sparkfun.", + "Aliases": ["lcdks"], + "Categories": ["userinput"], + "Connections": ["gpio", "analog"], + "Project Type": ["control", "prototyping"], + "Manufacturers": ["sainsmart", "dfrobot", "sparkfun"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": ["lcdks.py"], + "Node.js": ["lcdks.js"], + "C++": ["lcdks.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5} + }, + "Urls" : + { + "Product Pages": ["https://www.sparkfun.com/products/13293", "http://www.sainsmart.com/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html", "http://www.dfrobot.com/index.php?route=product/product&product_id=51"], + "Datasheets": ["http://linksprite.com/wiki/index.php5?title=16_X_2_LCD_Keypad_Shield_for_Arduino_V2"], + "Schematics": ["https://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/16X2_LCD_shield.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/lcdks/pyupm_lcdks.i upm-1.7.1/src/lcdks/pyupm_lcdks.i --- upm-1.6.0/src/lcdks/pyupm_lcdks.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcdks/pyupm_lcdks.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lcdks -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lcdks.hpp" -%{ - #include "lcdks.hpp" -%} diff -Nru upm-1.6.0/src/lcm1602/javaupm_lcm1602.i upm-1.7.1/src/lcm1602/javaupm_lcm1602.i --- upm-1.6.0/src/lcm1602/javaupm_lcm1602.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcm1602/javaupm_lcm1602.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module javaupm_lcm1602 -%include "../upm.i" -%include "typemaps.i" -%include "std_vector.i" -%include "stdint.i" - -%template(byteVector) std::vector; - -%include "lcm1602.hpp" -%{ - #include "lcm1602.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_lcm1602) diff -Nru upm-1.6.0/src/lcm1602/jsupm_lcm1602.i upm-1.7.1/src/lcm1602/jsupm_lcm1602.i --- upm-1.6.0/src/lcm1602/jsupm_lcm1602.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcm1602/jsupm_lcm1602.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_lcm1602 -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lcm1602.hpp" -%{ - #include "lcm1602.hpp" -%} diff -Nru upm-1.6.0/src/lcm1602/lcm1602.i upm-1.7.1/src/lcm1602/lcm1602.i --- upm-1.6.0/src/lcm1602/lcm1602.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lcm1602/lcm1602.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,29 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "std_vector.i" +%template(byteVector) std::vector; + +JAVA_JNI_LOADLIBRARY(javaupm_lcm1602) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lcm1602.hpp" +%} +%include "lcm1602.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lcm1602/lcm1602.json upm-1.7.1/src/lcm1602/lcm1602.json --- upm-1.6.0/src/lcm1602/lcm1602.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcm1602/lcm1602.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "lcm1602", - "Description": "API for the LCM1602 I2C controller for HD44780-based displays", - "Sensor Class": - { - "Lcm1602": - { - "Name": "LCD Display Driver for the LCM1602 Controller for HD44780-based Displays", - "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", - "Aliases": ["lcm1602"], - "Categories": ["display"], - "Connections": ["gpio"], - "Project Type": ["display", "prototyping"], - "Manufacturers": ["adafruit", "sparkfun", "seeed"], - "Kits": [], - "Examples": - { - "Java": ["Lcm1602_i2cSample.java", "Lcm1602_parallelSample.java"], - "Python": [], - "Node.js": [], - "C++": ["lcm1602-i2c.cxx", "lcm1602-parallel.cxx"], - "C": ["lcm1602-i2c.c", "lcm1602-parallel.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 4.8, "typ": 5, "high": 5.2}, - "Operating Current": {"unit": "mA", "max": 150} - }, - "Urls" : - { - "Product Pages": [], - "Datasheets": ["https://www.adafruit.com/datasheets/TC1602A-01T.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "lcm1602", + "Description": "API for the LCM1602 I2C controller for HD44780-based displays", + "Sensor Class": + { + "Lcm1602": + { + "Name": "LCD Display Driver for the LCM1602 Controller for HD44780-based Displays", + "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", + "Aliases": ["lcm1602"], + "Categories": ["display"], + "Connections": ["gpio"], + "Project Type": ["display", "prototyping"], + "Manufacturers": ["adafruit", "sparkfun", "seeed"], + "Kits": [], + "Examples": + { + "Java": ["Lcm1602_i2c_Example.java", "Lcm1602_parallel_Example.java"], + "Python": [], + "Node.js": [], + "C++": ["lcm1602-i2c.cxx", "lcm1602-parallel.cxx"], + "C": ["lcm1602-i2c.c", "lcm1602-parallel.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 4.8, "typ": 5, "high": 5.2}, + "Operating Current": {"unit": "mA", "max": 150} + }, + "Urls" : + { + "Product Pages": [], + "Datasheets": ["https://www.adafruit.com/datasheets/TC1602A-01T.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lcm1602/pyupm_lcm1602.i upm-1.7.1/src/lcm1602/pyupm_lcm1602.i --- upm-1.6.0/src/lcm1602/pyupm_lcm1602.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lcm1602/pyupm_lcm1602.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lcm1602 -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lcm1602.hpp" -%{ - #include "lcm1602.hpp" -%} diff -Nru upm-1.6.0/src/ldt0028/javaupm_ldt0028.i upm-1.7.1/src/ldt0028/javaupm_ldt0028.i --- upm-1.6.0/src/ldt0028/javaupm_ldt0028.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ldt0028/javaupm_ldt0028.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_ldt0028 -%include "../upm.i" - -%{ - #include "ldt0028.hpp" -%} - -%include "ldt0028.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ldt0028) \ No newline at end of file diff -Nru upm-1.6.0/src/ldt0028/jsupm_ldt0028.i upm-1.7.1/src/ldt0028/jsupm_ldt0028.i --- upm-1.6.0/src/ldt0028/jsupm_ldt0028.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ldt0028/jsupm_ldt0028.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ldt0028 -%include "../upm.i" - -%{ - #include "ldt0028.hpp" -%} - -%include "ldt0028.hpp" diff -Nru upm-1.6.0/src/ldt0028/ldt0028.json upm-1.7.1/src/ldt0028/ldt0028.json --- upm-1.6.0/src/ldt0028/ldt0028.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ldt0028/ldt0028.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "ldt0028", - "Description": "API for LDT0-028 PZT Film-Based Sensors", - "Sensor Class": - { - "LDT0028": - { - "Name": "Piezo Vibration Sensor", - "Description": "This module defines the LDT0-028 interface for libupm-ldt0028", - "Aliases": ["ldt0028"], - "Categories": ["vibration"], - "Connections": ["analog"], - "Project Type": ["industrial", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "ldt0028.jpg", - "Examples": - { - "Java": ["LDT0028Sample.java"], - "Python": ["ldt0028.py"], - "Node.js": ["ldt0028.js"], - "C++": ["ldt0028.cxx"], - "C": ["ldt0028.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Piezo-Vibration-Sensor-p-1411.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Piezo_Vibration_Sensor/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Piezo_Vibration_Sensor/master/res/Piezo_Vibration_Sensor.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "ldt0028", + "Description": "API for LDT0-028 PZT Film-Based Sensors", + "Sensor Class": + { + "LDT0028": + { + "Name": "Piezo Vibration Sensor", + "Description": "This module defines the LDT0-028 interface for libupm-ldt0028", + "Aliases": ["ldt0028"], + "Categories": ["vibration"], + "Connections": ["analog"], + "Project Type": ["industrial", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "ldt0028.jpg", + "Examples": + { + "Java": ["LDT0028_Example.java"], + "Python": ["ldt0028.py"], + "Node.js": ["ldt0028.js"], + "C++": ["ldt0028.cxx"], + "C": ["ldt0028.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Piezo-Vibration-Sensor-p-1411.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Piezo_Vibration_Sensor/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Piezo_Vibration_Sensor/master/res/Piezo_Vibration_Sensor.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/ldt0028/pyupm_ldt0028.i upm-1.7.1/src/ldt0028/pyupm_ldt0028.i --- upm-1.6.0/src/ldt0028/pyupm_ldt0028.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ldt0028/pyupm_ldt0028.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ldt0028 -%include "../upm.i" - -%include "ldt0028.hpp" -%{ - #include "ldt0028.hpp" -%} - diff -Nru upm-1.6.0/src/led/javaupm_led.i upm-1.7.1/src/led/javaupm_led.i --- upm-1.6.0/src/led/javaupm_led.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/led/javaupm_led.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_led -%include "../upm.i" - -%apply int {mraa::Edge} - -%include "led.hpp" -%{ - #include "led.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_led) diff -Nru upm-1.6.0/src/led/jsupm_led.i upm-1.7.1/src/led/jsupm_led.i --- upm-1.6.0/src/led/jsupm_led.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/led/jsupm_led.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -%module jsupm_led -%include "../upm.i" - -%include "led.hpp" -%{ - #include "led.hpp" -%} diff -Nru upm-1.6.0/src/led/led.c upm-1.7.1/src/led/led.c --- upm-1.6.0/src/led/led.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/led/led.c 2018-10-12 04:47:41.000000000 +0000 @@ -76,7 +76,7 @@ dev->gpio = NULL; dev->name = name; - dev->gpioled = mraa_led_init(name); + dev->gpioled = mraa_led_init_raw(name); if (!dev->gpioled) { printf("%s: Unable to initialize gpioled device (%s).\n", __FUNCTION__, dev->name); diff -Nru upm-1.6.0/src/led/led.i upm-1.7.1/src/led/led.i --- upm-1.6.0/src/led/led.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/led/led.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%apply int {mraa::Edge} + +JAVA_JNI_LOADLIBRARY(javaupm_led) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "led.hpp" +%} +%include "led.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/led/led.json upm-1.7.1/src/led/led.json --- upm-1.6.0/src/led/led.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/led/led.json 2018-10-12 04:47:41.000000000 +0000 @@ -16,7 +16,7 @@ "Image": "led.jpg", "Examples": { - "Java": ["LEDSample.java"], + "Java": ["LED_Example.java"], "Python": ["led.py"], "Node.js": ["led.js"], "C++": ["led.cxx"], diff -Nru upm-1.6.0/src/led/pyupm_led.i upm-1.7.1/src/led/pyupm_led.i --- upm-1.6.0/src/led/pyupm_led.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/led/pyupm_led.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_led -%include "../upm.i" - -%include "led.hpp" -%{ - #include "led.hpp" -%} diff -Nru upm-1.6.0/src/lidarlitev3/javaupm_lidarlitev3.i upm-1.7.1/src/lidarlitev3/javaupm_lidarlitev3.i --- upm-1.6.0/src/lidarlitev3/javaupm_lidarlitev3.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lidarlitev3/javaupm_lidarlitev3.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_lidarlitev3 -%include "../upm.i" - -%{ - #include "lidarlitev3.hpp" -%} - -%include "lidarlitev3.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_lidarlitev3) diff -Nru upm-1.6.0/src/lidarlitev3/jsupm_lidarlitev3.i upm-1.7.1/src/lidarlitev3/jsupm_lidarlitev3.i --- upm-1.6.0/src/lidarlitev3/jsupm_lidarlitev3.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lidarlitev3/jsupm_lidarlitev3.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_lidarlitev3 -%include "../upm.i" - -%{ - #include "lidarlitev3.hpp" -%} - -%include "lidarlitev3.hpp" diff -Nru upm-1.6.0/src/lidarlitev3/lidarlitev3.i upm-1.7.1/src/lidarlitev3/lidarlitev3.i --- upm-1.6.0/src/lidarlitev3/lidarlitev3.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lidarlitev3/lidarlitev3.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_lidarlitev3) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lidarlitev3.hpp" +%} +%include "lidarlitev3.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lidarlitev3/lidarlitev3.json upm-1.7.1/src/lidarlitev3/lidarlitev3.json --- upm-1.6.0/src/lidarlitev3/lidarlitev3.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lidarlitev3/lidarlitev3.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "lidarlitev3", - "Description": "API for the LIDARLITEV3 Optical Distance Measurement Sensor", - "Sensor Class": - { - "LIDARLITEV3": - { - "Name": "Optical Distance Measurement Sensor", - "Description": "It is a compact, high-performance optical distance measurement sensor from Garmin.", - "Aliases": ["lidarlitev3"], - "Categories": ["distance"], - "Connections": ["i2c", "pwm"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["garmin"], - "Kits": [], - "Image": "lidarlitev3.jpg", - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["lidarlitev3.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "low": 105, "high": 130} - }, - "Urls" : - { - "Product Pages": ["https://www.sparkfun.com/products/14032"], - "Datasheets": ["http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "lidarlitev3", + "Description": "API for the LIDARLITEV3 Optical Distance Measurement Sensor", + "Sensor Class": + { + "LIDARLITEV3": + { + "Name": "Optical Distance Measurement Sensor", + "Description": "It is a compact, high-performance optical distance measurement sensor from Garmin.", + "Aliases": ["lidarlitev3"], + "Categories": ["distance"], + "Connections": ["i2c", "pwm"], + "Project Type": ["robotics", "prototyping"], + "Manufacturers": ["garmin"], + "Kits": [], + "Image": "lidarlitev3.jpg", + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["lidarlitev3.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 5}, + "Operating Current": {"unit": "mA", "low": 105, "high": 130} + }, + "Urls" : + { + "Product Pages": ["https://www.sparkfun.com/products/14032"], + "Datasheets": ["http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lidarlitev3/pyupm_lidarlitev3.i upm-1.7.1/src/lidarlitev3/pyupm_lidarlitev3.i --- upm-1.6.0/src/lidarlitev3/pyupm_lidarlitev3.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lidarlitev3/pyupm_lidarlitev3.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lidarlitev3 -%include "../upm.i" - -%include "stdint.i" - -%include "lidarlitev3.hpp" -%{ - #include "lidarlitev3.hpp" -%} diff -Nru upm-1.6.0/src/light/javaupm_light.i upm-1.7.1/src/light/javaupm_light.i --- upm-1.6.0/src/light/javaupm_light.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/light/javaupm_light.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_light -%include "../upm.i" - -%{ - #include "light.hpp" -%} - -%include "light.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_light) \ No newline at end of file diff -Nru upm-1.6.0/src/light/jsupm_light.i upm-1.7.1/src/light/jsupm_light.i --- upm-1.6.0/src/light/jsupm_light.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/light/jsupm_light.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_light -%include "../upm.i" - -%{ - #include "light.hpp" -%} - -%include "light.hpp" diff -Nru upm-1.6.0/src/light/light.json upm-1.7.1/src/light/light.json --- upm-1.6.0/src/light/light.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/light/light.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "light", - "Description": "API for the Light Sensor", - "Sensor Class": - { - "Light": - { - "Name": "Analog Light Sensor", - "Description": "The light sensor detects the intensity of the ambient light. As the light intensity of the environment increases, the resistance of the sensor decreases. This means the raw value from the analog pin is larger in bright light and smaller in the dark. A very approximate lux value can also be returned.", - "Aliases": ["light"], - "Categories": ["light"], - "Connections": ["analog"], - "Project Type": ["environmental", "security", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["gsk"], - "Image": "light.jpg", - "Examples": - { - "Java": ["LightSample.java"], - "Python": ["light.py"], - "Node.js": ["light.js"], - "C++": ["light.cxx"], - "C": ["light.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3, "high": 5}, - "Operating Current": {"unit": "mA", "low": 0.5, "high": 3}, - "Response Time": {"unit": "ms", "low": 20, "high": 30} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Light-Sensor-p-746.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Light_Sensor/", "https://github.com/SeeedDocument/Grove_Light_Sensor/raw/master/res/LS06-M%CE%A65_datasheet.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "light", + "Description": "API for the Light Sensor", + "Sensor Class": + { + "Light": + { + "Name": "Analog Light Sensor", + "Description": "The light sensor detects the intensity of the ambient light. As the light intensity of the environment increases, the resistance of the sensor decreases. This means the raw value from the analog pin is larger in bright light and smaller in the dark. A very approximate lux value can also be returned.", + "Aliases": ["light"], + "Categories": ["light"], + "Connections": ["analog"], + "Project Type": ["environmental", "security", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": ["gsk"], + "Image": "light.jpg", + "Examples": + { + "Java": ["Light_Example.java"], + "Python": ["light.py"], + "Node.js": ["light.js"], + "C++": ["light.cxx"], + "C": ["light.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3, "high": 5}, + "Operating Current": {"unit": "mA", "low": 0.5, "high": 3}, + "Response Time": {"unit": "ms", "low": 20, "high": 30} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Light-Sensor-p-746.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Light_Sensor/", "https://github.com/SeeedDocument/Grove_Light_Sensor/raw/master/res/LS06-M%CE%A65_datasheet.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/light/pyupm_light.i upm-1.7.1/src/light/pyupm_light.i --- upm-1.6.0/src/light/pyupm_light.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/light/pyupm_light.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_light -%include "../upm.i" - -%include "light.hpp" -%{ - #include "light.hpp" -%} diff -Nru upm-1.6.0/src/linefinder/javaupm_linefinder.i upm-1.7.1/src/linefinder/javaupm_linefinder.i --- upm-1.6.0/src/linefinder/javaupm_linefinder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/linefinder/javaupm_linefinder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_linefinder -%include "../upm.i" - -%{ - #include "linefinder.hpp" -%} - -%include "linefinder.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_linefinder) \ No newline at end of file diff -Nru upm-1.6.0/src/linefinder/jsupm_linefinder.i upm-1.7.1/src/linefinder/jsupm_linefinder.i --- upm-1.6.0/src/linefinder/jsupm_linefinder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/linefinder/jsupm_linefinder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_linefinder -%include "../upm.i" - -%{ - #include "linefinder.hpp" -%} - -%include "linefinder.hpp" diff -Nru upm-1.6.0/src/linefinder/linefinder.json upm-1.7.1/src/linefinder/linefinder.json --- upm-1.6.0/src/linefinder/linefinder.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/linefinder/linefinder.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,40 +1,40 @@ -{ - "Library": "linefinder", - "Description": "Grove Line Finder Sensor Library", - "Sensor Class": - { - "LineFinder": - { - "Name": "Infrared (IR) Based Line Finder", - "Description": "UPM module for the Line Finder sensor. It outputs a digital signal indicating whether it is detecting black on a white background, or white on a black background.", - "Aliases": ["linefinder"], - "Categories": ["linefinder"], - "Connections": ["gpio"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["seeed", "dfrobot"], - "Kits": ["robok"], - "Image": "linefinder.jpg", - "Examples": - { - "Java": ["LineFinderSample.java"], - "Python": ["linefinder.py"], - "Node.js": ["linefinder.js"], - "C++": ["linefinder.cxx"], - "C": ["linefinder.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5}, - "Operating Current": {"unit": "uA", "typ": 210}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 125} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Line-Finder-v1.1-p-2712.html"], - "Datasheets": ["file:///C:/Users/Malachai/Downloads/Lmv358.pdf", "http://wiki.seeed.cc/Grove-Line_Finder/"], - "Schematics": ["https://easyeda.com/Seeed/Grove_Line_Finder_v1_1-dfc99c72325e41ff93a451882fd2e143"] - } - } - } -} +{ + "Library": "linefinder", + "Description": "Grove Line Finder Sensor Library", + "Sensor Class": + { + "LineFinder": + { + "Name": "Infrared (IR) Based Line Finder", + "Description": "UPM module for the Line Finder sensor. It outputs a digital signal indicating whether it is detecting black on a white background, or white on a black background.", + "Aliases": ["linefinder"], + "Categories": ["linefinder"], + "Connections": ["gpio"], + "Project Type": ["robotics", "prototyping"], + "Manufacturers": ["seeed", "dfrobot"], + "Kits": ["robok"], + "Image": "linefinder.jpg", + "Examples": + { + "Java": ["LineFinder_Example.java"], + "Python": ["linefinder.py"], + "Node.js": ["linefinder.js"], + "C++": ["linefinder.cxx"], + "C": ["linefinder.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5}, + "Operating Current": {"unit": "uA", "typ": 210}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 125} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Line-Finder-v1.1-p-2712.html"], + "Datasheets": ["file:///C:/Users/Malachai/Downloads/Lmv358.pdf", "http://wiki.seeed.cc/Grove-Line_Finder/"], + "Schematics": ["https://easyeda.com/Seeed/Grove_Line_Finder_v1_1-dfc99c72325e41ff93a451882fd2e143"] + } + } + } +} diff -Nru upm-1.6.0/src/linefinder/pyupm_linefinder.i upm-1.7.1/src/linefinder/pyupm_linefinder.i --- upm-1.6.0/src/linefinder/pyupm_linefinder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/linefinder/pyupm_linefinder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_linefinder -%include "../upm.i" - -%include "linefinder.hpp" -%{ - #include "linefinder.hpp" -%} diff -Nru upm-1.6.0/src/lis2ds12/javaupm_lis2ds12.i upm-1.7.1/src/lis2ds12/javaupm_lis2ds12.i --- upm-1.6.0/src/lis2ds12/javaupm_lis2ds12.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lis2ds12/javaupm_lis2ds12.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -%module javaupm_lis2ds12 -%include "../upm.i" -%include "typemaps.i" -%include "../upm_vectortypes.i" - -%ignore getAccelerometer(float *, float *, float *); - -%{ - #include "lis2ds12.hpp" - #include "lis2ds12_defs.h" -%} -%include "lis2ds12_defs.h" -%include "lis2ds12.hpp" - - -#%ignore installISR(LIS2DS12_INTERRUPT_PINS_T , int , mraa::Edge, void *, void *); - -%define INTERRUPT LIS2DS12_INTERRUPT_PINS_T -%enddef -JAVA_ADD_INSTALLISR_INTERRUPT(upm::LIS2DS12) - -JAVA_JNI_LOADLIBRARY(javaupm_lis2ds12) diff -Nru upm-1.6.0/src/lis2ds12/jsupm_lis2ds12.i upm-1.7.1/src/lis2ds12/jsupm_lis2ds12.i --- upm-1.6.0/src/lis2ds12/jsupm_lis2ds12.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lis2ds12/jsupm_lis2ds12.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_lis2ds12 -%include "../upm.i" -%include "../upm_vectortypes.i" - - -%include "lis2ds12_defs.h" -%include "lis2ds12.hpp" -%{ - #include "lis2ds12.hpp" -%} diff -Nru upm-1.6.0/src/lis2ds12/lis2ds12.i upm-1.7.1/src/lis2ds12/lis2ds12.i --- upm-1.6.0/src/lis2ds12/lis2ds12.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lis2ds12/lis2ds12.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,23 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore getAccelerometer(float *, float *, float *); +#%ignore installISR(LIS2DS12_INTERRUPT_PINS_T , int , mraa::Edge, void *, void *); + +%define INTERRUPT LIS2DS12_INTERRUPT_PINS_T +%enddef +JAVA_ADD_INSTALLISR_INTERRUPT(upm::LIS2DS12) + +JAVA_JNI_LOADLIBRARY(javaupm_lis2ds12) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "../upm_vectortypes.i" +%{ +#include "lis2ds12.hpp" +%} +%include "lis2ds12_defs.h" +%include "lis2ds12.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lis2ds12/lis2ds12.json upm-1.7.1/src/lis2ds12/lis2ds12.json --- upm-1.6.0/src/lis2ds12/lis2ds12.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lis2ds12/lis2ds12.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "lis2ds12", - "Description": "API for the LIS2DS12 3-axis Accelerometer", - "Sensor Class": - { - "LIS2DS12": - { - "Name": "Digital 3-axis Accelerometer", - "Description": "The LIS2DS12 is an ultra-low-power high performance three-axis linear accelerometer belonging to the \"pico\" family which leverages on the robust and mature manufacturing processes already used for the production of micromachined accelerometers. The LIS2DS12 has user-selectable full scales of 2g/4g/8g/16g and is capable of measuring accelerations with output data rates from 1 Hz to 6400 Hz. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", - "Aliases": ["lis2ds12"], - "Categories": ["accelerometer"], - "Connections": ["i2c", "spi", "gpio"], - "Project Type": ["imu", "prototyping"], - "Manufacturers": ["stmicro"], - "Kits": [], - "Examples": - { - "Java": ["LIS2DS12_Example.java"], - "Python": ["lis2ds12.py"], - "Node.js": ["lis2ds12.js"], - "C++": ["lis2ds12.cxx"], - "C": ["lis2ds12.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.62, "high": 1.98}, - "Operating Current": {"unit": "uA", "low": 0.7, "high": 150}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - }, - "Urls" : - { - "Product Pages": ["http://www.st.com/en/mems-and-sensors/lis2ds12.html"], - "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/ce/32/55/ac/e1/87/46/84/DM00177048.pdf/files/DM00177048.pdf/jcr:content/translations/en.DM00177048.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "lis2ds12", + "Description": "API for the LIS2DS12 3-axis Accelerometer", + "Sensor Class": + { + "LIS2DS12": + { + "Name": "Digital 3-axis Accelerometer", + "Description": "The LIS2DS12 is an ultra-low-power high performance three-axis linear accelerometer belonging to the \"pico\" family which leverages on the robust and mature manufacturing processes already used for the production of micromachined accelerometers. The LIS2DS12 has user-selectable full scales of 2g/4g/8g/16g and is capable of measuring accelerations with output data rates from 1 Hz to 6400 Hz. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", + "Aliases": ["lis2ds12"], + "Categories": ["accelerometer"], + "Connections": ["i2c", "spi", "gpio"], + "Project Type": ["imu", "prototyping"], + "Manufacturers": ["stmicro"], + "Kits": [], + "Examples": + { + "Java": ["LIS2DS12_Example.java"], + "Python": ["lis2ds12.py"], + "Node.js": ["lis2ds12.js"], + "C++": ["lis2ds12.cxx"], + "C": ["lis2ds12.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.62, "high": 1.98}, + "Operating Current": {"unit": "uA", "low": 0.7, "high": 150}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + }, + "Urls" : + { + "Product Pages": ["http://www.st.com/en/mems-and-sensors/lis2ds12.html"], + "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/ce/32/55/ac/e1/87/46/84/DM00177048.pdf/files/DM00177048.pdf/jcr:content/translations/en.DM00177048.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lis2ds12/pyupm_lis2ds12.i upm-1.7.1/src/lis2ds12/pyupm_lis2ds12.i --- upm-1.6.0/src/lis2ds12/pyupm_lis2ds12.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lis2ds12/pyupm_lis2ds12.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lis2ds12 -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lis2ds12_defs.h" -%include "lis2ds12.hpp" -%{ - #include "lis2ds12.hpp" -%} diff -Nru upm-1.6.0/src/lis3dh/javaupm_lis3dh.i upm-1.7.1/src/lis3dh/javaupm_lis3dh.i --- upm-1.6.0/src/lis3dh/javaupm_lis3dh.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lis3dh/javaupm_lis3dh.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -%module javaupm_lis3dh -%include "../upm.i" -%include "typemaps.i" -%include "../upm_vectortypes.i" - -%ignore getAccelerometer(float *, float *, float *); - -%{ - #include "lis3dh.hpp" - #include "lis3dh_defs.h" -%} -%include "lis3dh_defs.h" -%include "lis3dh.hpp" - - -%ignore installISR(LIS3DH_INTERRUPT_PINS_T , int , mraa::Edge , void *, void* ); - -%define INTERRUPT LIS3DH_INTERRUPT_PINS_T -%enddef -JAVA_ADD_INSTALLISR_INTERRUPT(upm::LIS3DH) - -JAVA_JNI_LOADLIBRARY(javaupm_lis3dh) diff -Nru upm-1.6.0/src/lis3dh/jsupm_lis3dh.i upm-1.7.1/src/lis3dh/jsupm_lis3dh.i --- upm-1.6.0/src/lis3dh/jsupm_lis3dh.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lis3dh/jsupm_lis3dh.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_lis3dh -%include "../upm.i" -%include "../upm_vectortypes.i" - - -%include "lis3dh_defs.h" -%include "lis3dh.hpp" -%{ - #include "lis3dh.hpp" -%} diff -Nru upm-1.6.0/src/lis3dh/lis3dh.i upm-1.7.1/src/lis3dh/lis3dh.i --- upm-1.6.0/src/lis3dh/lis3dh.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lis3dh/lis3dh.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,26 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../upm_vectortypes.i" + +%ignore getAccelerometer(float *, float *, float *); +%ignore installISR(LIS3DH_INTERRUPT_PINS_T , int , mraa::Edge , void *, void* ); + +%define INTERRUPT LIS3DH_INTERRUPT_PINS_T +%enddef + +JAVA_ADD_INSTALLISR_INTERRUPT(upm::LIS3DH) +JAVA_JNI_LOADLIBRARY(javaupm_lis3dh) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "../upm_vectortypes.i" +%{ +#include "lis3dh_defs.h" +#include "lis3dh.hpp" +%} +%include "lis3dh_defs.h" +%include "lis3dh.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lis3dh/lis3dh.json upm-1.7.1/src/lis3dh/lis3dh.json --- upm-1.6.0/src/lis3dh/lis3dh.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lis3dh/lis3dh.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "lis3dh", - "Description": "API for the LIS3DH 3-axis Accelerometer", - "Sensor Class": - { - "lis3dh": - { - "Name": "Digital 3-axis Accelerometer", - "Description": "The LIS3DH is an ultra-low-power high performance three-axis linear accelerometer belonging to the \"nano\" family which leverages the robust and mature manufacturing processes already used for the production of micromachined accelerometers. The LIS3DH has user-selectable full scales of 2g/4g/8g/16g and is capable of measuring accelerations with output data rates from 1 Hz to 5300 Hz. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", - "Aliases": ["lis3dh"], - "Categories": ["accelerometer"], - "Connections": ["i2c", "spi", "gpio"], - "Project Type": ["imu", "prototyping"], - "Manufacturers": ["stmicro"], - "Kits": [], - "Examples": - { - "Java": ["LIS3DH_Example.java"], - "Python": ["lis3dh.py"], - "Node.js": ["lis3dh.js"], - "C++": ["lis3dh.cxx"], - "C": ["lis3dh.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.71, "high": 3.6}, - "Operating Current": {"unit": "uA", "low": 0.5, "high": 11}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - }, - "Urls" : - { - "Product Pages": ["http://www.st.com/en/mems-and-sensors/lis3dh.html"], - "Datasheets": ["http://www.st.com/resource/en/datasheet/lis3dh.pdf"], - "Schematics": [] - } - } - } +{ + "Library": "lis3dh", + "Description": "API for the LIS3DH 3-axis Accelerometer", + "Sensor Class": + { + "lis3dh": + { + "Name": "Digital 3-axis Accelerometer", + "Description": "The LIS3DH is an ultra-low-power high performance three-axis linear accelerometer belonging to the \"nano\" family which leverages the robust and mature manufacturing processes already used for the production of micromachined accelerometers. The LIS3DH has user-selectable full scales of 2g/4g/8g/16g and is capable of measuring accelerations with output data rates from 1 Hz to 5300 Hz. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", + "Aliases": ["lis3dh"], + "Categories": ["accelerometer"], + "Connections": ["i2c", "spi", "gpio"], + "Project Type": ["imu", "prototyping"], + "Manufacturers": ["stmicro"], + "Kits": [], + "Examples": + { + "Java": ["LIS3DH_Example.java"], + "Python": ["lis3dh.py"], + "Node.js": ["lis3dh.js"], + "C++": ["lis3dh.cxx"], + "C": ["lis3dh.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.71, "high": 3.6}, + "Operating Current": {"unit": "uA", "low": 0.5, "high": 11}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + }, + "Urls" : + { + "Product Pages": ["http://www.st.com/en/mems-and-sensors/lis3dh.html"], + "Datasheets": ["http://www.st.com/resource/en/datasheet/lis3dh.pdf"], + "Schematics": [] + } + } + } } \ No newline at end of file diff -Nru upm-1.6.0/src/lis3dh/pyupm_lis3dh.i upm-1.7.1/src/lis3dh/pyupm_lis3dh.i --- upm-1.6.0/src/lis3dh/pyupm_lis3dh.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lis3dh/pyupm_lis3dh.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lis3dh -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lis3dh_defs.h" -%include "lis3dh.hpp" -%{ - #include "lis3dh.hpp" -%} diff -Nru upm-1.6.0/src/lm35/javaupm_lm35.i upm-1.7.1/src/lm35/javaupm_lm35.i --- upm-1.6.0/src/lm35/javaupm_lm35.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lm35/javaupm_lm35.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_lm35 -%include "../upm.i" - -%{ - #include "lm35.hpp" -%} - -%include "lm35.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_lm35) \ No newline at end of file diff -Nru upm-1.6.0/src/lm35/jsupm_lm35.i upm-1.7.1/src/lm35/jsupm_lm35.i --- upm-1.6.0/src/lm35/jsupm_lm35.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lm35/jsupm_lm35.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_lm35 -%include "../upm.i" - -%{ - #include "lm35.hpp" -%} - -%include "lm35.hpp" diff -Nru upm-1.6.0/src/lm35/lm35.json upm-1.7.1/src/lm35/lm35.json --- upm-1.6.0/src/lm35/lm35.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lm35/lm35.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "lm35", - "Description": "API for the DFRobot LM35 Linear Temperature Sensor", - "Sensor Class": - { - "LM35": - { - "Name": "Analog Temperature Sensor", - "Description": "This sensor returns an analog voltage proportional to the temperature of the ambient environment. This driver was developed using the DFRobot LM35 Linear Temperature Sensor", - "Aliases": ["lm35"], - "Categories": ["temperature"], - "Connections": ["analog"], - "Project Type": ["environmental", "monitoring", "prototyping"], - "Manufacturers": ["dfrobot", "nationalsemiconductor"], - "Kits": [], - "Image": "lm35.jpg", - "Examples": - { - "Java": [], - "Python": ["lm35.py"], - "Node.js": ["lm35.js"], - "C++": ["lm35.cxx"], - "C": ["lm35.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Measurement Range": {"unit": "degC", "low": 0, "high": 100} - }, - "Urls" : - { - "Product Pages": ["https://www.dfrobot.com/product-76.html"], - "Datasheets": ["http://image.dfrobot.com/image/data/DFR0023/DFR0023_Datasheet.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "lm35", + "Description": "API for the DFRobot LM35 Linear Temperature Sensor", + "Sensor Class": + { + "LM35": + { + "Name": "Analog Temperature Sensor", + "Description": "This sensor returns an analog voltage proportional to the temperature of the ambient environment. This driver was developed using the DFRobot LM35 Linear Temperature Sensor", + "Aliases": ["lm35"], + "Categories": ["temperature"], + "Connections": ["analog"], + "Project Type": ["environmental", "monitoring", "prototyping"], + "Manufacturers": ["dfrobot", "nationalsemiconductor"], + "Kits": [], + "Image": "lm35.jpg", + "Examples": + { + "Java": [], + "Python": ["lm35.py"], + "Node.js": ["lm35.js"], + "C++": ["lm35.cxx"], + "C": ["lm35.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, + "Measurement Range": {"unit": "degC", "low": 0, "high": 100} + }, + "Urls" : + { + "Product Pages": ["https://www.dfrobot.com/product-76.html"], + "Datasheets": ["http://image.dfrobot.com/image/data/DFR0023/DFR0023_Datasheet.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lm35/pyupm_lm35.i upm-1.7.1/src/lm35/pyupm_lm35.i --- upm-1.6.0/src/lm35/pyupm_lm35.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lm35/pyupm_lm35.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lm35 -%include "../upm.i" - -%include "lm35.hpp" -%{ - #include "lm35.hpp" -%} diff -Nru upm-1.6.0/src/lol/javaupm_lol.i upm-1.7.1/src/lol/javaupm_lol.i --- upm-1.6.0/src/lol/javaupm_lol.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lol/javaupm_lol.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -%module javaupm_lol -%include "../upm.i" -%include "stdint.i" -%include "arrays_java.i"; -%include "typemaps.i" - -%typemap(jni) unsigned char* "jbyteArray"; -%typemap(jtype) unsigned char* "byte[]"; -%typemap(jstype) unsigned char* "byte[]"; - -%typemap(javaout) unsigned char* { - return $jnicall; -} - -%typemap(out) unsigned char* { - $result = JCALL1(NewByteArray, jenv, LOL_X*LOL_Y); - JCALL4(SetByteArrayRegion, jenv, $result, 0, LOL_X*LOL_Y-1, reinterpret_cast($1)); - delete [] $1; -} - -%{ - #include "lol.hpp" -%} - -%include "lol.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_lol) \ No newline at end of file diff -Nru upm-1.6.0/src/lol/jsupm_lol.i upm-1.7.1/src/lol/jsupm_lol.i --- upm-1.6.0/src/lol/jsupm_lol.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lol/jsupm_lol.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_lol -%include "../upm.i" - -%{ - #include "lol.hpp" -%} - -%include "lol.hpp" diff -Nru upm-1.6.0/src/lol/lol.i upm-1.7.1/src/lol/lol.i --- upm-1.6.0/src/lol/lol.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lol/lol.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,29 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%typemap(jni) unsigned char* "jbyteArray"; +%typemap(jtype) unsigned char* "byte[]"; +%typemap(jstype) unsigned char* "byte[]"; + +%typemap(javaout) unsigned char* { + return $jnicall; +} + +%typemap(out) unsigned char* { + $result = JCALL1(NewByteArray, jenv, LOL_X*LOL_Y); + JCALL4(SetByteArrayRegion, jenv, $result, 0, LOL_X*LOL_Y-1, reinterpret_cast($1)); + delete [] $1; +} + +JAVA_JNI_LOADLIBRARY(javaupm_lol) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lol.hpp" +%} +%include "lol.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lol/lol.json upm-1.7.1/src/lol/lol.json --- upm-1.6.0/src/lol/lol.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lol/lol.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,32 +1,32 @@ -{ - "Library": "lol", - "Description": "API for the Olimex LoL Array", - "Sensor Class": - { - "LoL": - { - "Name": "Lots of LEDs (LoL) Array Rev A", - "Description": "This module defines the LoL API and implementation for a simple framebuffer.", - "Aliases": ["lol"], - "Categories": ["display"], - "Connections": ["gpio"], - "Project Type": ["prototyping"], - "Manufacturers": ["olimex"], - "Kits": [], - "Examples": - { - "Java": ["LoLSample.java", "LoL_exampleSample.java"], - "Python": [], - "Node.js": [], - "C++": ["lol.cxx"], - "C": [] - }, - "Urls" : - { - "Product Pages": ["https://www.olimex.com/Products/Duino/Shields/SHIELD-LOL/"], - "Datasheets": [], - "Schematics": [] - } - } - } -} +{ + "Library": "lol", + "Description": "API for the Olimex LoL Array", + "Sensor Class": + { + "LoL": + { + "Name": "Lots of LEDs (LoL) Array Rev A", + "Description": "This module defines the LoL API and implementation for a simple framebuffer.", + "Aliases": ["lol"], + "Categories": ["display"], + "Connections": ["gpio"], + "Project Type": ["prototyping"], + "Manufacturers": ["olimex"], + "Kits": [], + "Examples": + { + "Java": ["LoL_Example.java", "LoL_example_Example.java"], + "Python": [], + "Node.js": [], + "C++": ["lol.cxx"], + "C": [] + }, + "Urls" : + { + "Product Pages": ["https://www.olimex.com/Products/Duino/Shields/SHIELD-LOL/"], + "Datasheets": [], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lol/pyupm_lol.i upm-1.7.1/src/lol/pyupm_lol.i --- upm-1.6.0/src/lol/pyupm_lol.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lol/pyupm_lol.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lol -%include "../upm.i" - -%include "stdint.i" - -%include "lol.hpp" -%{ - #include "lol.hpp" -%} diff -Nru upm-1.6.0/src/loudness/javaupm_loudness.i upm-1.7.1/src/loudness/javaupm_loudness.i --- upm-1.6.0/src/loudness/javaupm_loudness.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/loudness/javaupm_loudness.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_loudness -%include "../upm.i" - -%{ - #include "loudness.hpp" -%} - -%include "loudness.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_loudness) \ No newline at end of file diff -Nru upm-1.6.0/src/loudness/jsupm_loudness.i upm-1.7.1/src/loudness/jsupm_loudness.i --- upm-1.6.0/src/loudness/jsupm_loudness.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/loudness/jsupm_loudness.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_loudness -%include "../upm.i" - -%{ - #include "loudness.hpp" -%} - -%include "loudness.hpp" diff -Nru upm-1.6.0/src/loudness/loudness.json upm-1.7.1/src/loudness/loudness.json --- upm-1.6.0/src/loudness/loudness.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/loudness/loudness.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "loudness", - "Description": "API for the Loudness Sensor", - "Sensor Class": - { - "Loudness": - { - "Name": "Loudness Sensor", - "Description": "This sensor family returns an analog voltage proportional to the loudness of the ambient environment. It's output does not correspond to a particular sound level in decibels. The higher the output voltage, the louder the ambient noise level. This device uses an electret microphone for sound input. This driver was developed using the DFRobot Loudness Sensor V2 and the Grove Loudness sensor.", - "Aliases": ["loudness"], - "Categories": ["audio"], - "Connections": ["analog"], - "Project Type": ["noise control", "prototyping"], - "Manufacturers": ["seeed", "dfrobot"], - "Kits": [], - "Image": "loudness.jpg", - "Examples": - { - "Java": [], - "Python": ["loudness.py"], - "Node.js": ["loudness.js"], - "C++": ["loudness.cxx"], - "C": ["loudness.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.5, "high": 10}, - "Measurement Range": {"unit": "Hz", "low": 50, "high": 2000} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Loudness-Sensor-p-1382.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Loudness_Sensor/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Loudness_Sensor/master/res/LM2904DR.pdf"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Loudness_Sensor/master/res/Grove_loudness_sensor.pdf"] - } - } - } -} +{ + "Library": "loudness", + "Description": "API for the Loudness Sensor", + "Sensor Class": + { + "Loudness": + { + "Name": "Loudness Sensor", + "Description": "This sensor family returns an analog voltage proportional to the loudness of the ambient environment. It's output does not correspond to a particular sound level in decibels. The higher the output voltage, the louder the ambient noise level. This device uses an electret microphone for sound input. This driver was developed using the DFRobot Loudness Sensor V2 and the Grove Loudness sensor.", + "Aliases": ["loudness"], + "Categories": ["audio"], + "Connections": ["analog"], + "Project Type": ["noise control", "prototyping"], + "Manufacturers": ["seeed", "dfrobot"], + "Kits": [], + "Image": "loudness.jpg", + "Examples": + { + "Java": [], + "Python": ["loudness.py"], + "Node.js": ["loudness.js"], + "C++": ["loudness.cxx"], + "C": ["loudness.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3.5, "high": 10}, + "Measurement Range": {"unit": "Hz", "low": 50, "high": 2000} + + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-Loudness-Sensor-p-1382.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Loudness_Sensor/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Loudness_Sensor/master/res/LM2904DR.pdf"], + "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Loudness_Sensor/master/res/Grove_loudness_sensor.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/loudness/pyupm_loudness.i upm-1.7.1/src/loudness/pyupm_loudness.i --- upm-1.6.0/src/loudness/pyupm_loudness.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/loudness/pyupm_loudness.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_loudness -%include "../upm.i" - -%include "loudness.hpp" -%{ - #include "loudness.hpp" -%} diff -Nru upm-1.6.0/src/lp8860/javaupm_lp8860.i upm-1.7.1/src/lp8860/javaupm_lp8860.i --- upm-1.6.0/src/lp8860/javaupm_lp8860.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lp8860/javaupm_lp8860.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -%module javaupm_lp8860 - -%import "../interfaces/javaupm_iLightController.i" - -%include "../upm.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%{ - #include "lp8860.hpp" -%} - -%include "lp8860.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_lp8860) diff -Nru upm-1.6.0/src/lp8860/jsupm_lp8860.i upm-1.7.1/src/lp8860/jsupm_lp8860.i --- upm-1.6.0/src/lp8860/jsupm_lp8860.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lp8860/jsupm_lp8860.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_lp8860 -%include "../upm.i" - -%{ - #include "lp8860.hpp" -%} - -%include "lp8860.hpp" diff -Nru upm-1.6.0/src/lp8860/lp8860.i upm-1.7.1/src/lp8860/lp8860.i --- upm-1.6.0/src/lp8860/lp8860.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lp8860/lp8860.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,17 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} +%import "../interfaces/javaupm_iLightController.i" + +JAVA_JNI_LOADLIBRARY(javaupm_lp8860) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lp8860.hpp" +%} +%include "lp8860.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lp8860/pyupm_lp8860.i upm-1.7.1/src/lp8860/pyupm_lp8860.i --- upm-1.6.0/src/lp8860/pyupm_lp8860.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lp8860/pyupm_lp8860.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module pyupm_lp8860 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%include "lp8860.hpp" -%{ - #include "lp8860.hpp" -%} diff -Nru upm-1.6.0/src/lpd8806/javaupm_lpd8806.i upm-1.7.1/src/lpd8806/javaupm_lpd8806.i --- upm-1.6.0/src/lpd8806/javaupm_lpd8806.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lpd8806/javaupm_lpd8806.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_lpd8806 -%include "../upm.i" - -%{ - #include "lpd8806.hpp" -%} - -%include "lpd8806.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_lpd8806) \ No newline at end of file diff -Nru upm-1.6.0/src/lpd8806/jsupm_lpd8806.i upm-1.7.1/src/lpd8806/jsupm_lpd8806.i --- upm-1.6.0/src/lpd8806/jsupm_lpd8806.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lpd8806/jsupm_lpd8806.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_lpd8806 -%include "../upm.i" - -%{ - #include "lpd8806.hpp" -%} - -%include "lpd8806.hpp" diff -Nru upm-1.6.0/src/lpd8806/lpd8806.json upm-1.7.1/src/lpd8806/lpd8806.json --- upm-1.6.0/src/lpd8806/lpd8806.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lpd8806/lpd8806.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "lpd8806", - "Description": "API for the LPD8806 RGB LED Strip Controller", - "Sensor Class": - { - "LPD8806": - { - "Name": "Digital RGB LED Strip Controller", - "Description": "FastPixel* LPD8806 is an RGB LED strip controller.", - "Aliases": ["lpd8806"], - "Categories": ["display"], - "Connections": ["spi"], - "Project Type": ["lighting", "rgb", "prototyping"], - "Manufacturers": ["adafruit"], - "Kits": [], - "Image": "lpd8806.jpg", - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["lpd8806.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "max": 5} - }, - "Urls" : - { - "Product Pages": ["https://www.adafruit.com/product/306"], - "Datasheets": ["https://cdn-learn.adafruit.com/downloads/pdf/digital-led-strip.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "lpd8806", + "Description": "API for the LPD8806 RGB LED Strip Controller", + "Sensor Class": + { + "LPD8806": + { + "Name": "Digital RGB LED Strip Controller", + "Description": "FastPixel* LPD8806 is an RGB LED strip controller.", + "Aliases": ["lpd8806"], + "Categories": ["display"], + "Connections": ["spi"], + "Project Type": ["lighting", "rgb", "prototyping"], + "Manufacturers": ["adafruit"], + "Kits": [], + "Image": "lpd8806.jpg", + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["lpd8806.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "max": 5} + }, + "Urls" : + { + "Product Pages": ["https://www.adafruit.com/product/306"], + "Datasheets": ["https://cdn-learn.adafruit.com/downloads/pdf/digital-led-strip.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lpd8806/pyupm_lpd8806.i upm-1.7.1/src/lpd8806/pyupm_lpd8806.i --- upm-1.6.0/src/lpd8806/pyupm_lpd8806.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lpd8806/pyupm_lpd8806.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lpd8806 -%include "../upm.i" - -%include "lpd8806.hpp" -%{ - #include "lpd8806.hpp" -%} diff -Nru upm-1.6.0/src/lsm303agr/javaupm_lsm303agr.i upm-1.7.1/src/lsm303agr/javaupm_lsm303agr.i --- upm-1.6.0/src/lsm303agr/javaupm_lsm303agr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303agr/javaupm_lsm303agr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -%module javaupm_lsm303agr -%include "../upm.i" -%include "typemaps.i" -%include "../upm_javastdvector.i" - -%ignore getMagnetometer(float *, float *, float *); -%ignore getAccelerometer(float *, float *, float *); - -%typemap(javaimports) SWIGTYPE %{ -import java.util.AbstractList; -import java.lang.Float; -%} - -%typemap(javaout) SWIGTYPE { - return new $&javaclassname($jnicall, true); -} -%typemap(javaout) std::vector { - return (AbstractList)(new $&javaclassname($jnicall, true)); -} -%typemap(jstype) std::vector "AbstractList" - -%template(floatVector) std::vector; - -%{ - #include "lsm303agr.hpp" - #include "lsm303agr_defs.h" -%} -%include "lsm303agr_defs.h" -%include "lsm303agr.hpp" - - -%ignore installISR(LSM303AGR_INTERRUPT_PINS_T , int , mraa::Edge , void *, void *); - -%define INTERRUPT LSM303AGR_INTERRUPT_PINS_T -%enddef -JAVA_ADD_INSTALLISR_INTERRUPT(upm::LSM303AGR) - -JAVA_JNI_LOADLIBRARY(javaupm_lsm303agr) diff -Nru upm-1.6.0/src/lsm303agr/jsupm_lsm303agr.i upm-1.7.1/src/lsm303agr/jsupm_lsm303agr.i --- upm-1.6.0/src/lsm303agr/jsupm_lsm303agr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303agr/jsupm_lsm303agr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_lsm303agr -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lsm303agr_defs.h" -%include "lsm303agr.hpp" -%{ - #include "lsm303agr.hpp" -%} diff -Nru upm-1.6.0/src/lsm303agr/lsm303agr.i upm-1.7.1/src/lsm303agr/lsm303agr.i --- upm-1.6.0/src/lsm303agr/lsm303agr.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lsm303agr/lsm303agr.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,53 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../upm_javastdvector.i" + +%ignore getMagnetometer(float *, float *, float *); +%ignore getAccelerometer(float *, float *, float *); +%ignore installISR(LSM303AGR_INTERRUPT_PINS_T , int , mraa::Edge , void *, void *); + +%typemap(javaimports) SWIGTYPE %{ +import java.util.AbstractList; +import java.lang.Float; +%} + +%typemap(javaout) SWIGTYPE { + return new $&javaclassname($jnicall, true); +} +%typemap(javaout) std::vector { + return (AbstractList)(new $&javaclassname($jnicall, true)); +} +%typemap(jstype) std::vector "AbstractList" + +%template(floatVector) std::vector; + +%define INTERRUPT LSM303AGR_INTERRUPT_PINS_T +%enddef + +JAVA_ADD_INSTALLISR_INTERRUPT(upm::LSM303AGR) +JAVA_JNI_LOADLIBRARY(javaupm_lsm303agr) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lsm303agr_defs.h" +#include "lsm303agr.hpp" +%} +%include "lsm303agr_defs.h" +%include "lsm303agr.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lsm303agr/lsm303agr.json upm-1.7.1/src/lsm303agr/lsm303agr.json --- upm-1.6.0/src/lsm303agr/lsm303agr.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303agr/lsm303agr.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "lsm303agr", - "Description": "API for the LSM303AGR 3-Axis Geomagnetic Sensor", - "Sensor Class": - { - "LSM303AGR": - { - "Name": "Ultra-Compact High-Performance eCompass Module", - "Description": "The LSM303AGR is an ultra-low-power high-performance system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor. The LSM303AGR has linear acceleration full scales of 2g/4g/8g/16g and a magnetic field dynamic range of 50 Gauss. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports only I2C operation.", - "Aliases": ["lsm303agr"], - "Categories": ["magnetometer"], - "Connections": ["i2c"], - "Project Type": ["imu", "prototyping"], - "Manufacturers": ["stmicro"], - "Kits": [], - "Examples": - { - "Java": ["LSM303AGR_Example.java"], - "Python": ["lsm303agr.py"], - "Node.js": ["lsm303agr.js"], - "C++": ["lsm303agr.cxx"], - "C": ["lsm303agr.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.71, "high": 3.6}, - "Operating Current": {"unit": "uA", "low": 2, "high": 200} - }, - "Urls" : - { - "Product Pages": ["http://www.st.com/en/mems-and-sensors/lsm303agr.html"], - "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/74/c4/19/54/62/c5/46/13/DM00177685.pdf/files/DM00177685.pdf/jcr:content/translations/en.DM00177685.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "lsm303agr", + "Description": "API for the LSM303AGR 3-Axis Geomagnetic Sensor", + "Sensor Class": + { + "LSM303AGR": + { + "Name": "Ultra-Compact High-Performance eCompass Module", + "Description": "The LSM303AGR is an ultra-low-power high-performance system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor. The LSM303AGR has linear acceleration full scales of 2g/4g/8g/16g and a magnetic field dynamic range of 50 Gauss. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports only I2C operation.", + "Aliases": ["lsm303agr"], + "Categories": ["magnetometer"], + "Connections": ["i2c"], + "Project Type": ["imu", "prototyping"], + "Manufacturers": ["stmicro"], + "Kits": [], + "Examples": + { + "Java": ["LSM303AGR_Example.java"], + "Python": ["lsm303agr.py"], + "Node.js": ["lsm303agr.js"], + "C++": ["lsm303agr.cxx"], + "C": ["lsm303agr.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.71, "high": 3.6}, + "Operating Current": {"unit": "uA", "low": 2, "high": 200} + }, + "Urls" : + { + "Product Pages": ["http://www.st.com/en/mems-and-sensors/lsm303agr.html"], + "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/74/c4/19/54/62/c5/46/13/DM00177685.pdf/files/DM00177685.pdf/jcr:content/translations/en.DM00177685.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lsm303agr/pyupm_lsm303agr.i upm-1.7.1/src/lsm303agr/pyupm_lsm303agr.i --- upm-1.6.0/src/lsm303agr/pyupm_lsm303agr.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303agr/pyupm_lsm303agr.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lsm303agr -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lsm303agr_defs.h" -%include "lsm303agr.hpp" -%{ - #include "lsm303agr.hpp" -%} diff -Nru upm-1.6.0/src/lsm303d/javaupm_lsm303d.i upm-1.7.1/src/lsm303d/javaupm_lsm303d.i --- upm-1.6.0/src/lsm303d/javaupm_lsm303d.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303d/javaupm_lsm303d.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -%module javaupm_lsm303d -%include "../upm.i" -%include "typemaps.i" -%include "../upm_javastdvector.i" - -%ignore getMagnetometer(float *, float *, float *); -%ignore getAccelerometer(float *, float *, float *); - -%typemap(javaimports) SWIGTYPE %{ -import java.util.AbstractList; -import java.lang.Float; -%} - -%typemap(javaout) SWIGTYPE { - return new $&javaclassname($jnicall, true); -} -%typemap(javaout) std::vector { - return (AbstractList)(new $&javaclassname($jnicall, true)); -} -%typemap(jstype) std::vector "AbstractList" - -%template(floatVector) std::vector; - -%include "lsm303d_defs.h" -%include "lsm303d.hpp" -%{ - #include "lsm303d.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_lsm303d) diff -Nru upm-1.6.0/src/lsm303d/jsupm_lsm303d.i upm-1.7.1/src/lsm303d/jsupm_lsm303d.i --- upm-1.6.0/src/lsm303d/jsupm_lsm303d.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303d/jsupm_lsm303d.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_lsm303d -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lsm303d_defs.h" -%include "lsm303d.hpp" -%{ - #include "lsm303d.hpp" -%} diff -Nru upm-1.6.0/src/lsm303d/lsm303d.i upm-1.7.1/src/lsm303d/lsm303d.i --- upm-1.6.0/src/lsm303d/lsm303d.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lsm303d/lsm303d.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,48 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../upm_javastdvector.i" + +%ignore getMagnetometer(float *, float *, float *); +%ignore getAccelerometer(float *, float *, float *); + +%typemap(javaimports) SWIGTYPE %{ +import java.util.AbstractList; +import java.lang.Float; +%} + +%typemap(javaout) SWIGTYPE { + return new $&javaclassname($jnicall, true); +} +%typemap(javaout) std::vector { + return (AbstractList)(new $&javaclassname($jnicall, true)); +} +%typemap(jstype) std::vector "AbstractList" + +%template(floatVector) std::vector; + +JAVA_JNI_LOADLIBRARY(javaupm_lsm303d) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../upm_vectortypes.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../upm_vectortypes.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lsm303d_defs.h" +#include "lsm303d.hpp" +%} +%include "lsm303d_defs.h" +%include "lsm303d.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lsm303d/lsm303d.json upm-1.7.1/src/lsm303d/lsm303d.json --- upm-1.6.0/src/lsm303d/lsm303d.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303d/lsm303d.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "lsm303d", - "Description": "API for the LSM303D 3-Axis Geomagnetic Sensor", - "Sensor Class": - { - "LSM303D": - { - "Name": "Ultra-compact high-performance eCompass module", - "Description": "The LSM303D is an ultra-low-power high-performance system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor. The LSM303D has linear acceleration full scales of 2g/4g/8g/16g and a magnetic field dynamic range of 50 Gauss. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports only I2C operation.", - "Aliases": ["lsm303d"], - "Categories": ["compass"], - "Connections": ["i2c"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["stmicro"], - "Kits": [], - "Examples": - { - "Java": ["LSM303D_Example.java"], - "Python": ["lsm303d.py"], - "Node.js": ["lsm303d.js"], - "C++": ["lsm303d.cxx"], - "C": ["lsm303d.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.16, "high": 3.6}, - "Operating Current": {"unit": "uA", "typ": 300}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - - }, - "Urls" : - { - "Product Pages": ["http://www.st.com/en/mems-and-sensors/lsm303d.html"], - "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/1c/9e/71/05/4e/b7/4d/d1/DM00057547.pdf/files/DM00057547.pdf/jcr:content/translations/en.DM00057547.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "lsm303d", + "Description": "API for the LSM303D 3-Axis Geomagnetic Sensor", + "Sensor Class": + { + "LSM303D": + { + "Name": "Ultra-compact high-performance eCompass module", + "Description": "The LSM303D is an ultra-low-power high-performance system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor. The LSM303D has linear acceleration full scales of 2g/4g/8g/16g and a magnetic field dynamic range of 50 Gauss. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports only I2C operation.", + "Aliases": ["lsm303d"], + "Categories": ["compass"], + "Connections": ["i2c"], + "Project Type": ["robotics", "prototyping"], + "Manufacturers": ["stmicro"], + "Kits": [], + "Examples": + { + "Java": ["LSM303D_Example.java"], + "Python": ["lsm303d.py"], + "Node.js": ["lsm303d.js"], + "C++": ["lsm303d.cxx"], + "C": ["lsm303d.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 2.16, "high": 3.6}, + "Operating Current": {"unit": "uA", "typ": 300}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + + }, + "Urls" : + { + "Product Pages": ["http://www.st.com/en/mems-and-sensors/lsm303d.html"], + "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/1c/9e/71/05/4e/b7/4d/d1/DM00057547.pdf/files/DM00057547.pdf/jcr:content/translations/en.DM00057547.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lsm303d/pyupm_lsm303d.i upm-1.7.1/src/lsm303d/pyupm_lsm303d.i --- upm-1.6.0/src/lsm303d/pyupm_lsm303d.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303d/pyupm_lsm303d.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lsm303d -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lsm303d_defs.h" -%include "lsm303d.hpp" -%{ - #include "lsm303d.hpp" -%} diff -Nru upm-1.6.0/src/lsm303dlh/javaupm_lsm303dlh.i upm-1.7.1/src/lsm303dlh/javaupm_lsm303dlh.i --- upm-1.6.0/src/lsm303dlh/javaupm_lsm303dlh.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303dlh/javaupm_lsm303dlh.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -%module javaupm_lsm303dlh -%include "../upm.i" - -%{ - #include "lsm303dlh.hpp" -%} - -%typemap(jni) int16_t* "jshortArray" -%typemap(jstype) int16_t* "short[]" -%typemap(jtype) int16_t* "short[]" - -%typemap(javaout) int16_t* { - return $jnicall; -} - -%typemap(out) int16_t *getRawAccelData { - $result = JCALL1(NewShortArray, jenv, 3); - JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); -} - -%include "lsm303dlh.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_lsm303dlh) diff -Nru upm-1.6.0/src/lsm303dlh/jsupm_lsm303dlh.i upm-1.7.1/src/lsm303dlh/jsupm_lsm303dlh.i --- upm-1.6.0/src/lsm303dlh/jsupm_lsm303dlh.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303dlh/jsupm_lsm303dlh.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -%module jsupm_lsm303dlh -%include "../upm.i" -%include "../carrays_int16_t.i" - -// Adding this typemap because SWIG is converting int16 into a short by default -// This forces SWIG to convert it correctly -%typemap(out) int16_t* { - jsresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%{ - #include "lsm303dlh.hpp" -%} - -%include "lsm303dlh.hpp" diff -Nru upm-1.6.0/src/lsm303dlh/lsm303dlh.i upm-1.7.1/src/lsm303dlh/lsm303dlh.i --- upm-1.6.0/src/lsm303dlh/lsm303dlh.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lsm303dlh/lsm303dlh.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,51 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%typemap(jni) int16_t* "jshortArray" +%typemap(jstype) int16_t* "short[]" +%typemap(jtype) int16_t* "short[]" + +%typemap(javaout) int16_t* { + return $jnicall; +} + +%typemap(out) int16_t *getRawAccelData { + $result = JCALL1(NewShortArray, jenv, 3); + JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1); +} + +JAVA_JNI_LOADLIBRARY(javaupm_lsm303dlh) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_int16_t.i" + +// Adding this typemap because SWIG is converting int16 into a short by default +// This forces SWIG to convert it correctly +%typemap(out) int16_t* { + jsresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_int16_t.i" + +// Adding this typemap because SWIG is converting int16 into a short by default +// This forces SWIG to convert it correctly +%typemap(out) int16_t* { + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); +} +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lsm303dlh.hpp" +%} +%include "lsm303dlh.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lsm303dlh/lsm303dlh.json upm-1.7.1/src/lsm303dlh/lsm303dlh.json --- upm-1.6.0/src/lsm303dlh/lsm303dlh.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303dlh/lsm303dlh.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,36 +1,36 @@ -{ - "Library": "lsm303dlh", - "Description": "API for the LSM303DLH Accelerometer & Compass", - "Sensor Class": - { - "LSM303DLH": - { - "Name": "Triaxial Accelerometer/magnetometer", - "Description": "This module defines the LSM303DLH 3-axis magnetometer/3-axis accelerometer. This module was tested with the Seeed Studio* Grove 6-Axis Accelerometer & Compass module used over I2C. The magnetometer and acceleromter are accessed at two seperate I2C addresses.", - "Aliases": ["lsm303dlh"], - "Categories": ["compass", "accelerometer"], - "Connections": ["i2c"], - "Project Type": ["imu", "prototyping"], - "Manufacturers": ["seeed", "adafruit", "stmicro"], - "Kits": [], - "Examples": - { - "Java": ["LSM303DLHSample.java"], - "Python": ["lsm303dlh.py"], - "Node.js": ["lsm303dhl.js"], - "C++": ["lsm303dlh.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 3.3} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/grove-6axis-accelerometercompass-p-1448.html?cPath=144_146"], - "Datasheets": ["http://wiki.seeedstudio.com/wiki/Grove_-_6-Axis_Accelerometer%26Compass_V1.0"], - "Schematics": [] - } - } - } -} +{ + "Library": "lsm303dlh", + "Description": "API for the LSM303DLH Accelerometer & Compass", + "Sensor Class": + { + "LSM303DLH": + { + "Name": "Triaxial Accelerometer/magnetometer", + "Description": "This module defines the LSM303DLH 3-axis magnetometer/3-axis accelerometer. This module was tested with the Seeed Studio* Grove 6-Axis Accelerometer & Compass module used over I2C. The magnetometer and acceleromter are accessed at two seperate I2C addresses.", + "Aliases": ["lsm303dlh"], + "Categories": ["compass", "accelerometer"], + "Connections": ["i2c"], + "Project Type": ["imu", "prototyping"], + "Manufacturers": ["seeed", "adafruit", "stmicro"], + "Kits": [], + "Examples": + { + "Java": ["LSM303DLH_Example.java"], + "Python": ["lsm303dlh.py"], + "Node.js": ["lsm303dhl.js"], + "C++": ["lsm303dlh.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "typ": 3.3} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/grove-6axis-accelerometercompass-p-1448.html?cPath=144_146"], + "Datasheets": ["http://wiki.seeedstudio.com/wiki/Grove_-_6-Axis_Accelerometer%26Compass_V1.0"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lsm303dlh/pyupm_lsm303dlh.i upm-1.7.1/src/lsm303dlh/pyupm_lsm303dlh.i --- upm-1.6.0/src/lsm303dlh/pyupm_lsm303dlh.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm303dlh/pyupm_lsm303dlh.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lsm303dlh -%include "../upm.i" -%include "../carrays_int16_t.i" - -// Adding this typemap because SWIG is converting int16 into a short by default -// This forces SWIG to convert it correctly -%typemap(out) int16_t* { - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 ); -} - -%include "lsm303dlh.hpp" -%{ - #include "lsm303dlh.hpp" -%} diff -Nru upm-1.6.0/src/lsm6ds3h/javaupm_lsm6ds3h.i upm-1.7.1/src/lsm6ds3h/javaupm_lsm6ds3h.i --- upm-1.6.0/src/lsm6ds3h/javaupm_lsm6ds3h.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm6ds3h/javaupm_lsm6ds3h.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -%module javaupm_lsm6ds3h -%include "../upm.i" -%include "typemaps.i" -%include "../upm_vectortypes.i" - -%ignore getAccelerometer(float *, float *, float *); -%ignore getGyroscope(float *, float *, float *); - -%{ - #include "lsm6ds3h.hpp" - #include "lsm6ds3h_defs.h" -%} -%include "lsm6ds3h_defs.h" -%include "lsm6ds3h.hpp" - -%ignore installISR(LSM6DS3H_INTERRUPT_PINS_T , int , mraa::Edge , void *, void *); - -%define INTERRUPT LSM6DS3H_INTERRUPT_PINS_T -%enddef -JAVA_ADD_INSTALLISR_INTERRUPT(upm::LSM6DS3H) - -JAVA_JNI_LOADLIBRARY(javaupm_lsm6ds3h) diff -Nru upm-1.6.0/src/lsm6ds3h/jsupm_lsm6ds3h.i upm-1.7.1/src/lsm6ds3h/jsupm_lsm6ds3h.i --- upm-1.6.0/src/lsm6ds3h/jsupm_lsm6ds3h.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm6ds3h/jsupm_lsm6ds3h.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_lsm6ds3h -%include "../upm.i" -%include "../upm_vectortypes.i" - - -%include "lsm6ds3h_defs.h" -%include "lsm6ds3h.hpp" -%{ - #include "lsm6ds3h.hpp" -%} diff -Nru upm-1.6.0/src/lsm6ds3h/lsm6ds3h.i upm-1.7.1/src/lsm6ds3h/lsm6ds3h.i --- upm-1.6.0/src/lsm6ds3h/lsm6ds3h.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lsm6ds3h/lsm6ds3h.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,28 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../upm_vectortypes.i" + +%ignore getAccelerometer(float *, float *, float *); +%ignore getGyroscope(float *, float *, float *); + +%ignore installISR(LSM6DS3H_INTERRUPT_PINS_T , int , mraa::Edge , void *, void *); + +%define INTERRUPT LSM6DS3H_INTERRUPT_PINS_T +%enddef + +JAVA_ADD_INSTALLISR_INTERRUPT(upm::LSM6DS3H) +JAVA_JNI_LOADLIBRARY(javaupm_lsm6ds3h) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "../upm_vectortypes.i" +%{ +#include "lsm6ds3h_defs.h" +#include "lsm6ds3h.hpp" +%} +%include "lsm6ds3h_defs.h" +%include "lsm6ds3h.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lsm6ds3h/lsm6ds3h.json upm-1.7.1/src/lsm6ds3h/lsm6ds3h.json --- upm-1.6.0/src/lsm6ds3h/lsm6ds3h.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm6ds3h/lsm6ds3h.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "lsm6ds3h", - "Description": "API for the LSM6DS3H 3-axis Accelerometer and Gyroscope", - "Sensor Class": - { - "LSM6DS3H": - { - "Name": "Digital 3-axis Accelerometer and Gyroscope", - "Description": "The LSM6DS3H is a system-in-package featuring a 3D digital accelerometer and a 3D digital gyroscope performing at 1.1 mA (up to 1.6 kHz ODR) in high performance mode and enabling always-on low-power features for an optimal motion experience for the consumer. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", - "Aliases": ["lsm6ds3h"], - "Categories": ["accelerometer", "gyroscope"], - "Connections": ["i2c", "spi", "gpio"], - "Project Type": ["imu", "prototyping"], - "Manufacturers": ["stmicro"], - "Kits": [], - "Examples": - { - "Java": ["LSM6DS3H_Example.java"], - "Python": ["lsm6ds3h.py"], - "Node.js": ["lsm6ds3h.js"], - "C++": ["lsm6ds3h.cxx"], - "C": ["lsm6ds3h.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.71, "high": 3.6}, - "Operating Current": {"unit": "mA", "low": 0.85, "high": 1.1}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - - }, - "Urls" : - { - "Product Pages": ["http://www.st.com/en/mems-and-sensors/lsm6ds3h.html"], - "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/group0/38/96/79/af/ab/62/42/c3/DM00229854/files/DM00229854.pdf/jcr:content/translations/en.DM00229854.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "lsm6ds3h", + "Description": "API for the LSM6DS3H 3-axis Accelerometer and Gyroscope", + "Sensor Class": + { + "LSM6DS3H": + { + "Name": "Digital 3-axis Accelerometer and Gyroscope", + "Description": "The LSM6DS3H is a system-in-package featuring a 3D digital accelerometer and a 3D digital gyroscope performing at 1.1 mA (up to 1.6 kHz ODR) in high performance mode and enabling always-on low-power features for an optimal motion experience for the consumer. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", + "Aliases": ["lsm6ds3h"], + "Categories": ["accelerometer", "gyroscope"], + "Connections": ["i2c", "spi", "gpio"], + "Project Type": ["imu", "prototyping"], + "Manufacturers": ["stmicro"], + "Kits": [], + "Examples": + { + "Java": ["LSM6DS3H_Example.java"], + "Python": ["lsm6ds3h.py"], + "Node.js": ["lsm6ds3h.js"], + "C++": ["lsm6ds3h.cxx"], + "C": ["lsm6ds3h.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.71, "high": 3.6}, + "Operating Current": {"unit": "mA", "low": 0.85, "high": 1.1}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + + }, + "Urls" : + { + "Product Pages": ["http://www.st.com/en/mems-and-sensors/lsm6ds3h.html"], + "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/group0/38/96/79/af/ab/62/42/c3/DM00229854/files/DM00229854.pdf/jcr:content/translations/en.DM00229854.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lsm6ds3h/pyupm_lsm6ds3h.i upm-1.7.1/src/lsm6ds3h/pyupm_lsm6ds3h.i --- upm-1.6.0/src/lsm6ds3h/pyupm_lsm6ds3h.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm6ds3h/pyupm_lsm6ds3h.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lsm6ds3h -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lsm6ds3h_defs.h" -%include "lsm6ds3h.hpp" -%{ - #include "lsm6ds3h.hpp" -%} diff -Nru upm-1.6.0/src/lsm6dsl/javaupm_lsm6dsl.i upm-1.7.1/src/lsm6dsl/javaupm_lsm6dsl.i --- upm-1.6.0/src/lsm6dsl/javaupm_lsm6dsl.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm6dsl/javaupm_lsm6dsl.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -%module javaupm_lsm6dsl -%include "../upm.i" -%include "typemaps.i" -%include "../upm_vectortypes.i" - -%ignore getAccelerometer(float *, float *, float *); -%ignore getGyroscope(float *, float *, float *); - -%{ - #include "lsm6dsl.hpp" - #include "lsm6dsl_defs.h" -%} -%include "lsm6dsl_defs.h" -%include "lsm6dsl.hpp" - - -%ignore installISR(LSM6DSL_INTERRUPT_PINS_T , int , mraa::Edge , void *, void *); - -%define INTERRUPT LSM6DSL_INTERRUPT_PINS_T -%enddef -JAVA_ADD_INSTALLISR_INTERRUPT(upm::LSM6DSL) -JAVA_JNI_LOADLIBRARY(javaupm_lsm6dsl) diff -Nru upm-1.6.0/src/lsm6dsl/jsupm_lsm6dsl.i upm-1.7.1/src/lsm6dsl/jsupm_lsm6dsl.i --- upm-1.6.0/src/lsm6dsl/jsupm_lsm6dsl.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm6dsl/jsupm_lsm6dsl.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_lsm6dsl -%include "../upm.i" -%include "../upm_vectortypes.i" - - -%include "lsm6dsl_defs.h" -%include "lsm6dsl.hpp" -%{ - #include "lsm6dsl.hpp" -%} diff -Nru upm-1.6.0/src/lsm6dsl/lsm6dsl.i upm-1.7.1/src/lsm6dsl/lsm6dsl.i --- upm-1.6.0/src/lsm6dsl/lsm6dsl.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lsm6dsl/lsm6dsl.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,28 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../upm_vectortypes.i" + +%ignore getAccelerometer(float *, float *, float *); +%ignore getGyroscope(float *, float *, float *); + +%ignore installISR(LSM6DSL_INTERRUPT_PINS_T , int , mraa::Edge , void *, void *); + +%define INTERRUPT LSM6DSL_INTERRUPT_PINS_T +%enddef + +JAVA_ADD_INSTALLISR_INTERRUPT(upm::LSM6DSL) +JAVA_JNI_LOADLIBRARY(javaupm_lsm6dsl) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "../upm_vectortypes.i" +%{ +#include "lsm6dsl_defs.h" +#include "lsm6dsl.hpp" +%} +%include "lsm6dsl_defs.h" +%include "lsm6dsl.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lsm6dsl/lsm6dsl.json upm-1.7.1/src/lsm6dsl/lsm6dsl.json --- upm-1.6.0/src/lsm6dsl/lsm6dsl.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm6dsl/lsm6dsl.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "lsm6dsl", - "Description": "API for the LSM6DSL 3-axis Accelerometer and Gyroscope", - "Sensor Class": - { - "LSM6DSL": - { - "Name": "Digital 3-axis Accelerometer and Gyroscope", - "Description": "The LSM6DSL is a system-in-package featuring a 3D digital accelerometer and a 3D digital gyroscope performing at 0.65 mA in high performance mode and enabling always-on low-power features for an optimal motion experience for the consumer. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", - "Aliases": ["lsm6dsl"], - "Categories": ["accelerometer", "gyroscope"], - "Connections": ["i2c", "spi", "gpio"], - "Project Type": ["imu", "prototyping"], - "Manufacturers": ["stmicro"], - "Kits": [], - "Examples": - { - "Java": ["LSM6DSL_Example.java"], - "Python": ["lsm6dsl.py"], - "Node.js": ["lsm6dsl.js"], - "C++": ["lsm6dsl.cxx"], - "C": ["lsm6dsl.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.71, "high": 3.6}, - "Operating Current": {"unit": "mA", "low": 0.4, "high": 0.65}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - - }, - "Urls" : - { - "Product Pages": ["http://www.st.com/en/mems-and-sensors/lsm6dsl.html"], - "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/ee/23/a0/dc/1d/68/45/52/DM00237456.pdf/files/DM00237456.pdf/jcr:content/translations/en.DM00237456.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "lsm6dsl", + "Description": "API for the LSM6DSL 3-axis Accelerometer and Gyroscope", + "Sensor Class": + { + "LSM6DSL": + { + "Name": "Digital 3-axis Accelerometer and Gyroscope", + "Description": "The LSM6DSL is a system-in-package featuring a 3D digital accelerometer and a 3D digital gyroscope performing at 0.65 mA in high performance mode and enabling always-on low-power features for an optimal motion experience for the consumer. Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.", + "Aliases": ["lsm6dsl"], + "Categories": ["accelerometer", "gyroscope"], + "Connections": ["i2c", "spi", "gpio"], + "Project Type": ["imu", "prototyping"], + "Manufacturers": ["stmicro"], + "Kits": [], + "Examples": + { + "Java": ["LSM6DSL_Example.java"], + "Python": ["lsm6dsl.py"], + "Node.js": ["lsm6dsl.js"], + "C++": ["lsm6dsl.cxx"], + "C": ["lsm6dsl.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.71, "high": 3.6}, + "Operating Current": {"unit": "mA", "low": 0.4, "high": 0.65}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + + }, + "Urls" : + { + "Product Pages": ["http://www.st.com/en/mems-and-sensors/lsm6dsl.html"], + "Datasheets": ["http://www.st.com/content/ccc/resource/technical/document/datasheet/ee/23/a0/dc/1d/68/45/52/DM00237456.pdf/files/DM00237456.pdf/jcr:content/translations/en.DM00237456.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/lsm6dsl/pyupm_lsm6dsl.i upm-1.7.1/src/lsm6dsl/pyupm_lsm6dsl.i --- upm-1.6.0/src/lsm6dsl/pyupm_lsm6dsl.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm6dsl/pyupm_lsm6dsl.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lsm6dsl -%include "../upm.i" -%include "../upm_vectortypes.i" - -%include "lsm6dsl_defs.h" -%include "lsm6dsl.hpp" -%{ - #include "lsm6dsl.hpp" -%} diff -Nru upm-1.6.0/src/lsm9ds0/javaupm_lsm9ds0.i upm-1.7.1/src/lsm9ds0/javaupm_lsm9ds0.i --- upm-1.6.0/src/lsm9ds0/javaupm_lsm9ds0.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm9ds0/javaupm_lsm9ds0.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -%module javaupm_lsm9ds0 -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%apply int {mraa::Edge}; -%apply float *INOUT { float *x, float *y, float *z }; - -%typemap(jni) float* "jfloatArray" -%typemap(jstype) float* "float[]" -%typemap(jtype) float* "float[]" - -%typemap(javaout) float* { - return $jnicall; -} - -%typemap(out) float *getAccelerometer { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); - delete [] $1; -} - -%typemap(out) float *getGyroscope { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); - delete [] $1; -} - -%typemap(out) float *getMagnetometer { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); - delete [] $1; -} - -%ignore getAccelerometer(float *, float *, float *); -%ignore getGyroscope(float *, float *, float *); -%ignore getMagnetometer(float *, float *, float *); - -%{ - #include "lsm9ds0.hpp" -%} - -%ignore installISR(LSM6DSL_INTERRUPT_PINS_T , int , mraa::Edge , void *, void *); - -%extend upm::LSM9DS0 { - installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level, - jobject runnable) - { - // delete any existing ISR and GPIO context - $self->uninstallISR(intr); - - // greate gpio context - getPin(intr) = new mraa::Gpio(gpio); - - getPin(intr)->dir(mraa::DIR_IN); - getPin(intr)->isr(level, runnable); - - } -} - -%include "lsm9ds0.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_lsm9ds0) diff -Nru upm-1.6.0/src/lsm9ds0/jsupm_lsm9ds0.i upm-1.7.1/src/lsm9ds0/jsupm_lsm9ds0.i --- upm-1.6.0/src/lsm9ds0/jsupm_lsm9ds0.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm9ds0/jsupm_lsm9ds0.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module jsupm_lsm9ds0 -%include "../upm.i" -%include "cpointer.i" - -%pointer_functions(float, floatp); - -%include "lsm9ds0.hpp" -%{ - #include "lsm9ds0.hpp" -%} - diff -Nru upm-1.6.0/src/lsm9ds0/lsm9ds0.hpp upm-1.7.1/src/lsm9ds0/lsm9ds0.hpp --- upm-1.6.0/src/lsm9ds0/lsm9ds0.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm9ds0/lsm9ds0.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -71,8 +71,8 @@ * * @image html lsm9ds0.jpg *
LSM9DS0 Sensor image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet lsm9ds0.cxx Interesting */ diff -Nru upm-1.6.0/src/lsm9ds0/lsm9ds0.i upm-1.7.1/src/lsm9ds0/lsm9ds0.i --- upm-1.6.0/src/lsm9ds0/lsm9ds0.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/lsm9ds0/lsm9ds0.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,69 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" + +%apply int {mraa::Edge}; +%apply float *INOUT { float *x, float *y, float *z }; + +%typemap(jni) float* "jfloatArray" +%typemap(jstype) float* "float[]" +%typemap(jtype) float* "float[]" + +%typemap(javaout) float* { + return $jnicall; +} + +%typemap(out) float *getAccelerometer { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); + delete [] $1; +} + +%typemap(out) float *getGyroscope { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); + delete [] $1; +} + +%typemap(out) float *getMagnetometer { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); + delete [] $1; +} + +%ignore getAccelerometer(float *, float *, float *); +%ignore getGyroscope(float *, float *, float *); +%ignore getMagnetometer(float *, float *, float *); + +%ignore installISR(INTERRUPT_PINS_T, int, mraa::Edge, void *, void *); + +%define INTERRUPT INTERRUPT_PINS_T +%enddef + +JAVA_ADD_INSTALLISR_INTERRUPT(upm::LSM9DS0) + +JAVA_JNI_LOADLIBRARY(javaupm_lsm9ds0) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "lsm9ds0.hpp" +%} +%include "lsm9ds0.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/lsm9ds0/lsm9ds0.json upm-1.7.1/src/lsm9ds0/lsm9ds0.json --- upm-1.6.0/src/lsm9ds0/lsm9ds0.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm9ds0/lsm9ds0.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "lsm9ds0", - "Description": "API for the LSM9DS0 Gyroscope/Accelerometer/Magnetometer", - "Sensor Class": - { - "LSM9DS0": - { - "Name": "Triaxial Gyroscope/Accelerometer/Magnetometer Sensor", - "Description": "The LSM9DS0 is a system-in-package featuring a 3D digital linear acceleration sensor, a 3D digital angular rate sensor, and a 3D digital magnetic sensor. The LSM9DS0 has a linear acceleration full scale of 2g/4g/6g/8g/16g, a magnetic field full scale of 2/4/8/12 gauss and an angular rate of 245/500/2000 dps. While not all of the functionality of this device is supported initially, methods and register definitions are provided that should allow an end user to implement whatever features are required. This driver was developed on a Sparkfun 9DOF edison block.", - "Aliases": ["lsm9ds0"], - "Categories": ["gyroscope", "accelerometer", "magnetometer"], - "Connections": ["i2c", "gpio"], - "Project Type": ["robotics", "wearables", "prototyping"], - "Manufacturers": ["sparkfun", "stmicro"], - "Kits": [], - "Image": "lsm9ds0.jpg", - "Examples": - { - "Java": [], - "Python": ["lsm9ds0.py"], - "Node.js": ["lsm9ds0.js"], - "C++": ["lsm9ds0.cxx"], - "C": [] - }, - "Specifications": - { - "Accelerometer Range (+-)": {"unit": "g", "low": 2, "high": 16}, - "Magnetometer Range (+-)": {"unit": "gauss", "low": 2, "high": 12}, - "Gyroscope Range (+-)": {"unit": "deg/s", "low": 245, "high": 2000} - }, - "Urls" : - { - "Product Pages": ["https://www.sparkfun.com/products/13033"], - "Datasheets": [], - "Schematics": ["https://cdn.sparkfun.com/datasheets/Dev/Edison/9dof_block.pdf"] - } - } - } -} +{ + "Library": "lsm9ds0", + "Description": "API for the LSM9DS0 Gyroscope/Accelerometer/Magnetometer", + "Sensor Class": + { + "LSM9DS0": + { + "Name": "Triaxial Gyroscope/Accelerometer/Magnetometer Sensor", + "Description": "The LSM9DS0 is a system-in-package featuring a 3D digital linear acceleration sensor, a 3D digital angular rate sensor, and a 3D digital magnetic sensor. The LSM9DS0 has a linear acceleration full scale of 2g/4g/6g/8g/16g, a magnetic field full scale of 2/4/8/12 gauss and an angular rate of 245/500/2000 dps. While not all of the functionality of this device is supported initially, methods and register definitions are provided that should allow an end user to implement whatever features are required. This driver was developed on a Sparkfun 9DOF edison block.", + "Aliases": ["lsm9ds0"], + "Categories": ["gyroscope", "accelerometer", "magnetometer"], + "Connections": ["i2c", "gpio"], + "Project Type": ["robotics", "wearables", "prototyping"], + "Manufacturers": ["sparkfun", "stmicro"], + "Kits": [], + "Image": "lsm9ds0.jpg", + "Examples": + { + "Java": [], + "Python": ["lsm9ds0.py"], + "Node.js": ["lsm9ds0.js"], + "C++": ["lsm9ds0.cxx"], + "C": [] + }, + "Specifications": + { + "Accelerometer Range (+-)": {"unit": "g", "low": 2, "high": 16}, + "Magnetometer Range (+-)": {"unit": "gauss", "low": 2, "high": 12}, + "Gyroscope Range (+-)": {"unit": "deg/s", "low": 245, "high": 2000} + }, + "Urls" : + { + "Product Pages": ["https://www.sparkfun.com/products/13033"], + "Datasheets": [], + "Schematics": ["https://cdn.sparkfun.com/datasheets/Dev/Edison/9dof_block.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/lsm9ds0/pyupm_lsm9ds0.i upm-1.7.1/src/lsm9ds0/pyupm_lsm9ds0.i --- upm-1.6.0/src/lsm9ds0/pyupm_lsm9ds0.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/lsm9ds0/pyupm_lsm9ds0.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_lsm9ds0 -%include "../upm.i" -%include "cpointer.i" - -%include "stdint.i" - -%pointer_functions(float, floatp); - -%include "lsm9ds0.hpp" -%{ - #include "lsm9ds0.hpp" -%} - diff -Nru upm-1.6.0/src/m24lr64e/javaupm_m24lr64e.i upm-1.7.1/src/m24lr64e/javaupm_m24lr64e.i --- upm-1.6.0/src/m24lr64e/javaupm_m24lr64e.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/m24lr64e/javaupm_m24lr64e.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -%module javaupm_m24lr64e -%include "../upm.i" -%include "stdint.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%typemap(jni) uint8_t * "jbyteArray" -%typemap(jtype) uint8_t * "byte[]" -%typemap(jstype) uint8_t * "byte[]" - -%typemap(javaout) uint8_t * { - return $jnicall; -} - -%typemap(out) uint8_t *{ - int length = upm::M24LR64E::UID_LENGTH; - $result = JCALL1(NewByteArray, jenv, length); - JCALL4(SetByteArrayRegion, jenv, $result, 0, length, reinterpret_cast($1)); - delete [] $1; -} - -%{ - #include "m24lr64e.hpp" -%} - -%include "m24lr64e.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_m24lr64e) \ No newline at end of file diff -Nru upm-1.6.0/src/m24lr64e/jsupm_m24lr64e.i upm-1.7.1/src/m24lr64e/jsupm_m24lr64e.i --- upm-1.6.0/src/m24lr64e/jsupm_m24lr64e.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/m24lr64e/jsupm_m24lr64e.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_m24lr64e -%include "../upm.i" - -%include "stdint.i" - -%{ - #include "m24lr64e.hpp" -%} - -%include "m24lr64e.hpp" diff -Nru upm-1.6.0/src/m24lr64e/m24lr64e.h upm-1.7.1/src/m24lr64e/m24lr64e.h --- upm-1.6.0/src/m24lr64e/m24lr64e.h 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/m24lr64e/m24lr64e.h 2018-10-12 04:47:41.000000000 +0000 @@ -113,9 +113,9 @@ */ typedef struct _m24lr64e_context { mraa_i2c_context i2c; - uint8_t bus; + int bus; uint8_t address; - m24lr64e_access_mode mode; + m24lr64e_access_mode mode; } *m24lr64e_context; /** diff -Nru upm-1.6.0/src/m24lr64e/m24lr64e.i upm-1.7.1/src/m24lr64e/m24lr64e.i --- upm-1.6.0/src/m24lr64e/m24lr64e.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/m24lr64e/m24lr64e.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,32 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" + +%typemap(jni) uint8_t * "jbyteArray" +%typemap(jtype) uint8_t * "byte[]" +%typemap(jstype) uint8_t * "byte[]" + +%typemap(javaout) uint8_t * { + return $jnicall; +} + +%typemap(out) uint8_t *{ + int length = upm::M24LR64E::UID_LENGTH; + $result = JCALL1(NewByteArray, jenv, length); + JCALL4(SetByteArrayRegion, jenv, $result, 0, length, reinterpret_cast($1)); + delete [] $1; +} + +JAVA_JNI_LOADLIBRARY(javaupm_m24lr64e) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "m24lr64e.hpp" +%} +%include "m24lr64e.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/m24lr64e/m24lr64e.json upm-1.7.1/src/m24lr64e/m24lr64e.json --- upm-1.6.0/src/m24lr64e/m24lr64e.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/m24lr64e/m24lr64e.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "m24lr64e", - "Description": "API for the M24LR64E NFC Tag", - "Sensor Class": - { - "M24LR64E": - { - "Name": "Dynamic NFC/RFID Tag Module", - "Description": "The M24LR64E NFC tag is an 8KB electrically erasable programmable read-only memory (EEPROM) that can be written to or read from using I2C and NFC-equipped devices. The user mode (default) allows read and write access to all 8KB of space, provided the sector security status (SSS) allows it. The root mode allows modification of the SSS data and other information, provided the proper password is submitted. The default password for a new tag is 0x00000000. See the datasheet for more details. The Seeed Studio* wiki page for this device includes a link to an Android* application that can be used to also read and write the device via NFC, as well as set NFC passwords, which cannot be done via I2C.", - "Aliases": ["m24lr64e"], - "Categories": ["rfid", "wireless"], - "Connections": ["i2c", "nfc"], - "Project Type": ["access control", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "m24lr64e.jpg", - "Examples": - { - "Java": ["M24LR64ESample.java"], - "Python": ["m24lr64e.py"], - "Node.js": ["m24lr64e.js"], - "C++": ["m24lr64e.cxx"], - "C": ["m24lr64e.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.8, "high": 5.5}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-NFC-Tag-p-1866.html"], - "Datasheets": ["http://www.seeedstudio.com/wiki/Grove_-_NFC_Tag", "https://raw.githubusercontent.com/SeeedDocument/Grove-NFC_Tag/master/res/M24LR64E-R.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "m24lr64e", + "Description": "API for the M24LR64E NFC Tag", + "Sensor Class": + { + "M24LR64E": + { + "Name": "Dynamic NFC/RFID Tag Module", + "Description": "The M24LR64E NFC tag is an 8KB electrically erasable programmable read-only memory (EEPROM) that can be written to or read from using I2C and NFC-equipped devices. The user mode (default) allows read and write access to all 8KB of space, provided the sector security status (SSS) allows it. The root mode allows modification of the SSS data and other information, provided the proper password is submitted. The default password for a new tag is 0x00000000. See the datasheet for more details. The Seeed Studio* wiki page for this device includes a link to an Android* application that can be used to also read and write the device via NFC, as well as set NFC passwords, which cannot be done via I2C.", + "Aliases": ["m24lr64e"], + "Categories": ["rfid", "wireless"], + "Connections": ["i2c", "nfc"], + "Project Type": ["access control", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "m24lr64e.jpg", + "Examples": + { + "Java": ["M24LR64E_Example.java"], + "Python": ["m24lr64e.py"], + "Node.js": ["m24lr64e.js"], + "C++": ["m24lr64e.cxx"], + "C": ["m24lr64e.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.8, "high": 5.5}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/Grove-NFC-Tag-p-1866.html"], + "Datasheets": ["http://www.seeedstudio.com/wiki/Grove_-_NFC_Tag", "https://raw.githubusercontent.com/SeeedDocument/Grove-NFC_Tag/master/res/M24LR64E-R.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/m24lr64e/pyupm_m24lr64e.i upm-1.7.1/src/m24lr64e/pyupm_m24lr64e.i --- upm-1.6.0/src/m24lr64e/pyupm_m24lr64e.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/m24lr64e/pyupm_m24lr64e.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_m24lr64e -%include "../upm.i" - -%include "stdint.i" - -%include "m24lr64e.hpp" -%{ - #include "m24lr64e.hpp" -%} diff -Nru upm-1.6.0/src/mag3110/javaupm_mag3110.i upm-1.7.1/src/mag3110/javaupm_mag3110.i --- upm-1.6.0/src/mag3110/javaupm_mag3110.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mag3110/javaupm_mag3110.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_mag3110 -%include "../upm.i" - -%{ - #include "mag3110.hpp" -%} - -%include "mag3110.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mag3110) \ No newline at end of file diff -Nru upm-1.6.0/src/mag3110/jsupm_mag3110.i upm-1.7.1/src/mag3110/jsupm_mag3110.i --- upm-1.6.0/src/mag3110/jsupm_mag3110.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mag3110/jsupm_mag3110.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mag3110 -%include "../upm.i" - -%{ - #include "mag3110.hpp" -%} - -%include "mag3110.hpp" diff -Nru upm-1.6.0/src/mag3110/mag3110.json upm-1.7.1/src/mag3110/mag3110.json --- upm-1.6.0/src/mag3110/mag3110.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mag3110/mag3110.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "mag3110", - "Description": "API for the MAG3110 Three-Axis Digital Magnetometer", - "Sensor Class": - { - "MAG3110": - { - "Name": "MAG3110 Three-Axis Digital Magnetometer", - "Description": "The MAG3110 is a small, low-power digital 3D magnetic sensor with a wide dynamic range to allow operation in PCBs with high extraneous magnetic fields. It measures the components of the local magnetic field, the sum of the geomagnetic field and the magnetic field created by components on the circuit board. It can be used in conjunction with a 3-axis accelerometer so that orientation-independent accurate compass heading information may be achieved It is capable of measuring local magnetic fields up to 10 Gauss with output data rates up to 80 Hz.", - "Aliases": ["mag3110"], - "Categories": ["magnetometer"], - "Connections": ["i2c"], - "Project Type": ["imu", "prototyping"], - "Manufacturers": ["freescale"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": ["mag3110.py"], - "Node.js": [], - "C++": ["mag3110.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.95, "high": 3.6}, - "Operating Current": {"unit": "uA", "low": 8.6, "high": 900}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - }, - "Urls" : - { - "Product Pages": ["http://www.nxp.com/products/sensors/magnetometers/high-accuracy-3d-magnetometer:MAG3110"], - "Datasheets": ["http://www.nxp.com/docs/en/data-sheet/MAG3110.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "mag3110", + "Description": "API for the MAG3110 Three-Axis Digital Magnetometer", + "Sensor Class": + { + "MAG3110": + { + "Name": "MAG3110 Three-Axis Digital Magnetometer", + "Description": "The MAG3110 is a small, low-power digital 3D magnetic sensor with a wide dynamic range to allow operation in PCBs with high extraneous magnetic fields. It measures the components of the local magnetic field, the sum of the geomagnetic field and the magnetic field created by components on the circuit board. It can be used in conjunction with a 3-axis accelerometer so that orientation-independent accurate compass heading information may be achieved It is capable of measuring local magnetic fields up to 10 Gauss with output data rates up to 80 Hz.", + "Aliases": ["mag3110"], + "Categories": ["magnetometer"], + "Connections": ["i2c"], + "Project Type": ["imu", "prototyping"], + "Manufacturers": ["freescale"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": ["mag3110.py"], + "Node.js": [], + "C++": ["mag3110.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.95, "high": 3.6}, + "Operating Current": {"unit": "uA", "low": 8.6, "high": 900}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} + }, + "Urls" : + { + "Product Pages": ["http://www.nxp.com/products/sensors/magnetometers/high-accuracy-3d-magnetometer:MAG3110"], + "Datasheets": ["http://www.nxp.com/docs/en/data-sheet/MAG3110.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/mag3110/pyupm_mag3110.i upm-1.7.1/src/mag3110/pyupm_mag3110.i --- upm-1.6.0/src/mag3110/pyupm_mag3110.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mag3110/pyupm_mag3110.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mag3110 -%include "../upm.i" - -%include "mag3110.hpp" -%{ - #include "mag3110.hpp" -%} diff -Nru upm-1.6.0/src/max30100/javaupm_max30100.i upm-1.7.1/src/max30100/javaupm_max30100.i --- upm-1.6.0/src/max30100/javaupm_max30100.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max30100/javaupm_max30100.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#ifdef ANDROID - %module javaupm_max30100 -#else - %module(directors="1", threads="1") javaupm_max30100 -#endif - -%include "../upm.i" - -%{ - #include "max30100.hpp" -%} - -#ifndef ANDROID - %feature("director") upm::Callback; -#endif - -%include "max30100_regs.h" -%include "max30100.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_max30100) diff -Nru upm-1.6.0/src/max30100/jsupm_max30100.i upm-1.7.1/src/max30100/jsupm_max30100.i --- upm-1.6.0/src/max30100/jsupm_max30100.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max30100/jsupm_max30100.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_max30100 -%include "../upm.i" - -%{ - #include "max30100.hpp" -%} - -%include "max30100_regs.h" -%include "max30100.hpp" diff -Nru upm-1.6.0/src/max30100/max30100.i upm-1.7.1/src/max30100/max30100.i --- upm-1.6.0/src/max30100/max30100.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/max30100/max30100.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,28 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +#ifndef ANDROID +%module(directors="1", threads="1") javaupm_max30100 +%feature("director") upm::Callback; +#endif +JAVA_JNI_LOADLIBRARY(javaupm_max30100) +#endif +/* END Java syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%module(directors="1", threads="1") pyupm_max30100 + +%feature("director") upm::Callback; +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "max30100_regs.h" +#include "max30100.hpp" +%} +%include "max30100_regs.h" +%include "max30100.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/max30100/max30100.json upm-1.7.1/src/max30100/max30100.json --- upm-1.6.0/src/max30100/max30100.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max30100/max30100.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,37 +1,37 @@ -{ - "Library": "max30100", - "Description": "API for the Pulse Oximeter and Heart-Rate Sensor", - "Sensor Class": - { - "MAX30100": - { - "Name": "Pulse Oximeter and Heart-rate Sensor", - "Description": "The MAX30100 is an integrated pulse oximetry and heartrate monitor sensor solution. It combines two LEDs, a photodetector, optimized optics, and low-noise analog signal processing to detect pulse oximetry and heart-rate signals.", - "Aliases": ["max30100"], - "Categories": ["heartrate", "pulse-ox"], - "Connections": ["i2c", "gpio"], - "Project Type": ["medical", "wearables", "prototyping"], - "Manufacturers": ["maxim"], - "Kits": [], - "Examples": - { - "Java": ["MAX30100_Example.java"], - "Python": ["max30100.py"], - "Node.js": ["max30100.js"], - "C++": ["max30100.cxx"], - "C": ["max30100.c"] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.8, "high": 3.3}, - "Operating Current": {"unit": "uA", "low": 0.7, "high": 1200} - }, - "Urls" : - { - "Product Pages": ["https://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX30100.html"], - "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/MAX30100.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "max30100", + "Description": "API for the Pulse Oximeter and Heart-Rate Sensor", + "Sensor Class": + { + "MAX30100": + { + "Name": "Pulse Oximeter and Heart-rate Sensor", + "Description": "The MAX30100 is an integrated pulse oximetry and heartrate monitor sensor solution. It combines two LEDs, a photodetector, optimized optics, and low-noise analog signal processing to detect pulse oximetry and heart-rate signals.", + "Aliases": ["max30100"], + "Categories": ["heartrate", "pulse-ox"], + "Connections": ["i2c", "gpio"], + "Project Type": ["medical", "wearables", "prototyping"], + "Manufacturers": ["maxim"], + "Kits": [], + "Examples": + { + "Java": ["MAX30100_Example.java"], + "Python": ["max30100.py"], + "Node.js": ["max30100.js"], + "C++": ["max30100.cxx"], + "C": ["max30100.c"] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.8, "high": 3.3}, + "Operating Current": {"unit": "uA", "low": 0.7, "high": 1200} + }, + "Urls" : + { + "Product Pages": ["https://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX30100.html"], + "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/MAX30100.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/max30100/pyupm_max30100.i upm-1.7.1/src/max30100/pyupm_max30100.i --- upm-1.6.0/src/max30100/pyupm_max30100.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max30100/pyupm_max30100.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%module(directors="1", threads="1") pyupm_max30100 -%include "pyupm_doxy2swig.i" -%include "../upm.i" - -%{ - #include "max30100.hpp" -%} - -%feature("director") upm::Callback; -%include "max30100_regs.h" -%include "max30100.hpp" diff -Nru upm-1.6.0/src/max31723/javaupm_max31723.i upm-1.7.1/src/max31723/javaupm_max31723.i --- upm-1.6.0/src/max31723/javaupm_max31723.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max31723/javaupm_max31723.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_max31723 -%include "../upm.i" - -%{ - #include "max31723.hpp" -%} - -%include "max31723.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_max31723) \ No newline at end of file diff -Nru upm-1.6.0/src/max31723/jsupm_max31723.i upm-1.7.1/src/max31723/jsupm_max31723.i --- upm-1.6.0/src/max31723/jsupm_max31723.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max31723/jsupm_max31723.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_max31723 -%include "../upm.i" - -%{ - #include "max31723.hpp" -%} - -%include "max31723.hpp" diff -Nru upm-1.6.0/src/max31723/max31723.json upm-1.7.1/src/max31723/max31723.json --- upm-1.6.0/src/max31723/max31723.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max31723/max31723.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "max31723", - "Description": "API for the MAX31723 Temperature Sensor", - "Sensor Class": - { - "MAX31723": - { - "Name": "SPI/3-wire Digital Thermometer", - "Description": "Maxim Integrated* [MAX31723](http://datasheets.maximintegrated.com/en/ds/MAX31722-MAX31723.pdf) is a low-voltage 3-wire/SPI temperature sensor controller. This module was tested on the Maxim Integrated [MAX31732PMB1 PMOD module](http://datasheets.maximintegrated.com/en/ds/MAX31723PMB1.pdf) from the analog PMOD kit.", - "Aliases": ["max31723"], - "Categories": ["temperature"], - "Connections": ["spi"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["maxim"], - "Kits": [], - "Examples": - { - "Java": [], - "Python": [], - "Node.js": [], - "C++": ["max31723.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.7, "high": 3.7}, - "Operating Current": {"unit": "uA", "low": 100, "high":1200}, - "Operating Temperature": {"unit": "degC", "low": -55, "high": 125} - - }, - "Urls" : - { - "Product Pages": ["https://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX31723.html"], - "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/MAX31722-MAX31723.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "max31723", + "Description": "API for the MAX31723 Temperature Sensor", + "Sensor Class": + { + "MAX31723": + { + "Name": "SPI/3-wire Digital Thermometer", + "Description": "Maxim Integrated* [MAX31723](http://datasheets.maximintegrated.com/en/ds/MAX31722-MAX31723.pdf) is a low-voltage 3-wire/SPI temperature sensor controller. This module was tested on the Maxim Integrated [MAX31732PMB1 PMOD module](http://datasheets.maximintegrated.com/en/ds/MAX31723PMB1.pdf) from the analog PMOD kit.", + "Aliases": ["max31723"], + "Categories": ["temperature"], + "Connections": ["spi"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["maxim"], + "Kits": [], + "Examples": + { + "Java": [], + "Python": [], + "Node.js": [], + "C++": ["max31723.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.7, "high": 3.7}, + "Operating Current": {"unit": "uA", "low": 100, "high":1200}, + "Operating Temperature": {"unit": "degC", "low": -55, "high": 125} + + }, + "Urls" : + { + "Product Pages": ["https://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX31723.html"], + "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/MAX31722-MAX31723.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/max31723/pyupm_max31723.i upm-1.7.1/src/max31723/pyupm_max31723.i --- upm-1.6.0/src/max31723/pyupm_max31723.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max31723/pyupm_max31723.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_max31723 -%include "../upm.i" - -%include "max31723.hpp" -%{ - #include "max31723.hpp" -%} diff -Nru upm-1.6.0/src/max31855/javaupm_max31855.i upm-1.7.1/src/max31855/javaupm_max31855.i --- upm-1.6.0/src/max31855/javaupm_max31855.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max31855/javaupm_max31855.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -//! [Interesting] -%module javaupm_max31855 -%include "../upm.i" - -%{ - #include "max31855.hpp" -%} - -%include "max31855.hpp" -//! [Interesting] - -JAVA_JNI_LOADLIBRARY(javaupm_max31855) \ No newline at end of file diff -Nru upm-1.6.0/src/max31855/jsupm_max31855.i upm-1.7.1/src/max31855/jsupm_max31855.i --- upm-1.6.0/src/max31855/jsupm_max31855.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max31855/jsupm_max31855.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -//! [Interesting] -%module jsupm_max31855 -%include "../upm.i" - -%{ - #include "max31855.hpp" -%} - -%include "max31855.hpp" -//! [Interesting] diff -Nru upm-1.6.0/src/max31855/max31855.i upm-1.7.1/src/max31855/max31855.i --- upm-1.6.0/src/max31855/max31855.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/max31855/max31855.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,17 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +//! [Interesting] + +JAVA_JNI_LOADLIBRARY(javaupm_max31855) +//! [Interesting] +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "max31855.hpp" +%} +%include "max31855.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/max31855/max31855.json upm-1.7.1/src/max31855/max31855.json --- upm-1.6.0/src/max31855/max31855.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max31855/max31855.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,38 +1,38 @@ -{ - "Library": "max31855", - "Description": "API for the MAX31855 Thermocouple Amplifier", - "Sensor Class": - { - "MAX31855": - { - "Name": "Thermocouple-to-Digital Converter", - "Description": "Maxim Integrated* [MAX31855](http://datasheets.maximintegrated.com/en/ds/MAX31855.pdf) is a cold-junction compensated thermocouple-to-digital converter. This module was tested on the Maxim Integrated [MAX31855PMB1 PMOD module] (http://datasheets.maximintegrated.com/en/ds/MAX31855PMB1.pdf) from the analog PMOD kit.", - "Aliases": ["max31855"], - "Categories": ["temperature"], - "Connections": ["spi"], - "Project Type": ["thermal", "prototyping"], - "Manufacturers": ["maxim", "adafruit"], - "Kits": [], - "Image": "max31855.jpg", - "Examples": - { - "Java": ["MAX31855Example.java"], - "Python": [], - "Node.js": [], - "C++": ["max31855.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3, "high": 3.6}, - "Operating Current": {"unit": "uA", "max": 1500} - }, - "Urls" : - { - "Product Pages": ["https://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX31855.html"], - "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/MAX31855.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "max31855", + "Description": "API for the MAX31855 Thermocouple Amplifier", + "Sensor Class": + { + "MAX31855": + { + "Name": "Thermocouple-to-Digital Converter", + "Description": "Maxim Integrated* [MAX31855](http://datasheets.maximintegrated.com/en/ds/MAX31855.pdf) is a cold-junction compensated thermocouple-to-digital converter. This module was tested on the Maxim Integrated [MAX31855PMB1 PMOD module] (http://datasheets.maximintegrated.com/en/ds/MAX31855PMB1.pdf) from the analog PMOD kit.", + "Aliases": ["max31855"], + "Categories": ["temperature"], + "Connections": ["spi"], + "Project Type": ["thermal", "prototyping"], + "Manufacturers": ["maxim", "adafruit"], + "Kits": [], + "Image": "max31855.jpg", + "Examples": + { + "Java": ["MAX31855_Example.java"], + "Python": [], + "Node.js": [], + "C++": ["max31855.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 3, "high": 3.6}, + "Operating Current": {"unit": "uA", "max": 1500} + }, + "Urls" : + { + "Product Pages": ["https://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX31855.html"], + "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/MAX31855.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/max31855/pyupm_max31855.i upm-1.7.1/src/max31855/pyupm_max31855.i --- upm-1.6.0/src/max31855/pyupm_max31855.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max31855/pyupm_max31855.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_max31855 -%include "../upm.i" - -%include "stdint.i" - -%include "max31855.hpp" -%{ - #include "max31855.hpp" -%} diff -Nru upm-1.6.0/src/max44000/javaupm_max44000.i upm-1.7.1/src/max44000/javaupm_max44000.i --- upm-1.6.0/src/max44000/javaupm_max44000.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max44000/javaupm_max44000.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_max44000 -%include "../upm.i" - -%{ - #include "max44000.hpp" -%} - -%include "max44000.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_max44000) \ No newline at end of file diff -Nru upm-1.6.0/src/max44000/jsupm_max44000.i upm-1.7.1/src/max44000/jsupm_max44000.i --- upm-1.6.0/src/max44000/jsupm_max44000.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max44000/jsupm_max44000.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_max44000 -%include "../upm.i" - -%{ - #include "max44000.hpp" -%} - -%include "max44000.hpp" diff -Nru upm-1.6.0/src/max44000/max44000.i upm-1.7.1/src/max44000/max44000.i --- upm-1.6.0/src/max44000/max44000.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/max44000/max44000.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_max44000) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "max44000.hpp" +%} +%include "max44000.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/max44000/max44000.json upm-1.7.1/src/max44000/max44000.json --- upm-1.6.0/src/max44000/max44000.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max44000/max44000.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "max44000", - "Description": "API for the MAX44000 Ambient and Infrared Proximity Sensor", - "Sensor Class": - { - "MAX44000": - { - "Name": "Ambient and Infrared Proximity Sensor", - "Description": "Maxim Integrated* [MAX44000](http://datasheets.maximintegrated.com/en/ds/MAX44000.pdf) is an ambient and infrared proximity sensor. This module was tested on the Maxim Integrated [MAX44000PMB1 PMOD module] (http://datasheets.maximintegrated.com/en/ds/MAX44000PMB1.pdf) from the analog PMOD kit.", - "Aliases": ["max44000"], - "Categories": ["proximity"], - "Connections": ["i2c"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["maxim"], - "Kits": [], - "Examples": - { - "Java": ["MAX44000Sample.java"], - "Python": [], - "Node.js": [], - "C++": ["max44000.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 1.7, "high": 3.6}, - "Operating Current": {"unit": "mA", "low": 10, "high":110}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 105} - - }, - "Urls" : - { - "Product Pages": ["https://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX44000.html"], - "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/MAX44000.pdf"], - "Schematics": [] - } - } - } -} +{ + "Library": "max44000", + "Description": "API for the MAX44000 Ambient and Infrared Proximity Sensor", + "Sensor Class": + { + "MAX44000": + { + "Name": "Ambient and Infrared Proximity Sensor", + "Description": "Maxim Integrated* [MAX44000](http://datasheets.maximintegrated.com/en/ds/MAX44000.pdf) is an ambient and infrared proximity sensor. This module was tested on the Maxim Integrated [MAX44000PMB1 PMOD module] (http://datasheets.maximintegrated.com/en/ds/MAX44000PMB1.pdf) from the analog PMOD kit.", + "Aliases": ["max44000"], + "Categories": ["proximity"], + "Connections": ["i2c"], + "Project Type": ["robotics", "prototyping"], + "Manufacturers": ["maxim"], + "Kits": [], + "Examples": + { + "Java": ["MAX44000_Example.java"], + "Python": [], + "Node.js": [], + "C++": ["max44000.cxx"], + "C": [] + }, + "Specifications": + { + "Operating Voltage": {"unit": "V", "low": 1.7, "high": 3.6}, + "Operating Current": {"unit": "mA", "low": 10, "high":110}, + "Operating Temperature": {"unit": "degC", "low": -40, "high": 105} + + }, + "Urls" : + { + "Product Pages": ["https://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX44000.html"], + "Datasheets": ["https://datasheets.maximintegrated.com/en/ds/MAX44000.pdf"], + "Schematics": [] + } + } + } +} diff -Nru upm-1.6.0/src/max44000/pyupm_max44000.i upm-1.7.1/src/max44000/pyupm_max44000.i --- upm-1.6.0/src/max44000/pyupm_max44000.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max44000/pyupm_max44000.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_max44000 -%include "../upm.i" - -%include "stdint.i" - -%include "max44000.hpp" -%{ - #include "max44000.hpp" -%} diff -Nru upm-1.6.0/src/max44009/javaupm_max44009.i upm-1.7.1/src/max44009/javaupm_max44009.i --- upm-1.6.0/src/max44009/javaupm_max44009.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max44009/javaupm_max44009.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -%module javaupm_max44009 - -%include "../upm.i" -%include "arrays_java.i"; -%include "../java_buffer.i" -%include "cpointer.i" -%include "typemaps.i" - -%import "../interfaces/javaupm_iLightSensor.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%{ - #include "max44009.hpp" -%} - -%include "max44009.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_max44009) diff -Nru upm-1.6.0/src/max44009/jsupm_max44009.i upm-1.7.1/src/max44009/jsupm_max44009.i --- upm-1.6.0/src/max44009/jsupm_max44009.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max44009/jsupm_max44009.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_max44009 -%include "../upm.i" - -%{ - #include "max44009.hpp" -%} - -%include "max44009.hpp" diff -Nru upm-1.6.0/src/max44009/max44009.i upm-1.7.1/src/max44009/max44009.i --- upm-1.6.0/src/max44009/max44009.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/max44009/max44009.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,19 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} +%import "../interfaces/javaupm_iLightSensor.i" + +JAVA_JNI_LOADLIBRARY(javaupm_max44009) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "max44009.hpp" +%} +%include "max44009.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/max44009/pyupm_max44009.i upm-1.7.1/src/max44009/pyupm_max44009.i --- upm-1.6.0/src/max44009/pyupm_max44009.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max44009/pyupm_max44009.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module pyupm_max44009 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - - -%include "stdint.i" - -%include "max44009.hpp" -%{ - #include "max44009.hpp" -%} diff -Nru upm-1.6.0/src/max5487/javaupm_max5487.i upm-1.7.1/src/max5487/javaupm_max5487.i --- upm-1.6.0/src/max5487/javaupm_max5487.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max5487/javaupm_max5487.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_max5487 -%include "../upm.i" - -%{ - #include "max5487.hpp" -%} - -%include "max5487.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_max5487) \ No newline at end of file diff -Nru upm-1.6.0/src/max5487/jsupm_max5487.i upm-1.7.1/src/max5487/jsupm_max5487.i --- upm-1.6.0/src/max5487/jsupm_max5487.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max5487/jsupm_max5487.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_max5487 -%include "../upm.i" - -%{ - #include "max5487.hpp" -%} - -%include "max5487.hpp" diff -Nru upm-1.6.0/src/max5487/max5487.json upm-1.7.1/src/max5487/max5487.json --- upm-1.6.0/src/max5487/max5487.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max5487/max5487.json 2018-10-12 04:47:41.000000000 +0000 @@ -11,7 +11,7 @@ "Project Type": ["prototyping", "commercial"], "Manufacturers": ["maxim"], "Examples": { - "Java": ["MAX5487Example.java"], + "Java": ["MAX5487_Example.java"], "C++": ["max5487.cxx"] }, "Specifications": { diff -Nru upm-1.6.0/src/max5487/pyupm_max5487.i upm-1.7.1/src/max5487/pyupm_max5487.i --- upm-1.6.0/src/max5487/pyupm_max5487.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/max5487/pyupm_max5487.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_max5487 -%include "../upm.i" - -%include "max5487.hpp" -%{ - #include "max5487.hpp" -%} diff -Nru upm-1.6.0/src/maxds3231m/javaupm_maxds3231m.i upm-1.7.1/src/maxds3231m/javaupm_maxds3231m.i --- upm-1.6.0/src/maxds3231m/javaupm_maxds3231m.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/maxds3231m/javaupm_maxds3231m.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_maxds3231m -%include "../upm.i" - -%{ - #include "maxds3231m.hpp" -%} - -%include "maxds3231m.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_maxds3231m) \ No newline at end of file diff -Nru upm-1.6.0/src/maxds3231m/jsupm_maxds3231m.i upm-1.7.1/src/maxds3231m/jsupm_maxds3231m.i --- upm-1.6.0/src/maxds3231m/jsupm_maxds3231m.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/maxds3231m/jsupm_maxds3231m.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_maxds3231m -%include "../upm.i" - -%{ - #include "maxds3231m.hpp" -%} - -%include "maxds3231m.hpp" diff -Nru upm-1.6.0/src/maxds3231m/maxds3231m.json upm-1.7.1/src/maxds3231m/maxds3231m.json --- upm-1.6.0/src/maxds3231m/maxds3231m.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/maxds3231m/maxds3231m.json 2018-10-12 04:47:41.000000000 +0000 @@ -11,7 +11,7 @@ "Project Type": ["prototyping", "commercial"], "Manufacturers": ["Maxim"], "Examples": { - "Java": ["MAXds3231mExample.java"], + "Java": ["MAXds3231m_Example.java"], "C++": ["maxds3231m.cxx"] }, "Specifications": { diff -Nru upm-1.6.0/src/maxds3231m/pyupm_maxds3231m.i upm-1.7.1/src/maxds3231m/pyupm_maxds3231m.i --- upm-1.6.0/src/maxds3231m/pyupm_maxds3231m.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/maxds3231m/pyupm_maxds3231m.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_maxds3231m -%include "../upm.i" - -%include "maxds3231m.hpp" -%{ - #include "maxds3231m.hpp" -%} diff -Nru upm-1.6.0/src/maxsonarez/javaupm_maxsonarez.i upm-1.7.1/src/maxsonarez/javaupm_maxsonarez.i --- upm-1.6.0/src/maxsonarez/javaupm_maxsonarez.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/maxsonarez/javaupm_maxsonarez.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_maxsonarez -%include "../upm.i" - -%{ - #include "maxsonarez.hpp" -%} - -%include "maxsonarez.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_maxsonarez) \ No newline at end of file diff -Nru upm-1.6.0/src/maxsonarez/jsupm_maxsonarez.i upm-1.7.1/src/maxsonarez/jsupm_maxsonarez.i --- upm-1.6.0/src/maxsonarez/jsupm_maxsonarez.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/maxsonarez/jsupm_maxsonarez.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_maxsonarez -%include "../upm.i" - -%{ - #include "maxsonarez.hpp" -%} - -%include "maxsonarez.hpp" diff -Nru upm-1.6.0/src/maxsonarez/maxsonarez.hpp upm-1.7.1/src/maxsonarez/maxsonarez.hpp --- upm-1.6.0/src/maxsonarez/maxsonarez.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/maxsonarez/maxsonarez.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -61,8 +61,8 @@ * * @image html maxsonarez.jpg *
LV-MaxSonar-EZ Ultrasonic Ranger image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet maxsonarez.cxx Interesting */ diff -Nru upm-1.6.0/src/maxsonarez/pyupm_maxsonarez.i upm-1.7.1/src/maxsonarez/pyupm_maxsonarez.i --- upm-1.6.0/src/maxsonarez/pyupm_maxsonarez.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/maxsonarez/pyupm_maxsonarez.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_maxsonarez -%include "../upm.i" - -%include "maxsonarez.hpp" -%{ - #include "maxsonarez.hpp" -%} diff -Nru upm-1.6.0/src/mb704x/javaupm_mb704x.i upm-1.7.1/src/mb704x/javaupm_mb704x.i --- upm-1.6.0/src/mb704x/javaupm_mb704x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mb704x/javaupm_mb704x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_mb704x -%include "../upm.i" -%include "std_string.i" -%include "stdint.i" -%include "typemaps.i" - -%include "mb704x.hpp" -%{ - #include "mb704x.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_mb704x) diff -Nru upm-1.6.0/src/mb704x/jsupm_mb704x.i upm-1.7.1/src/mb704x/jsupm_mb704x.i --- upm-1.6.0/src/mb704x/jsupm_mb704x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mb704x/jsupm_mb704x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mb704x -%include "../upm.i" -%include "std_string.i" - -%include "mb704x.hpp" -%{ - #include "mb704x.hpp" -%} diff -Nru upm-1.6.0/src/mb704x/mb704x.i upm-1.7.1/src/mb704x/mb704x.i --- upm-1.6.0/src/mb704x/mb704x.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/mb704x/mb704x.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_mb704x) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "mb704x.hpp" +%} +%include "mb704x.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/mb704x/pyupm_mb704x.i upm-1.7.1/src/mb704x/pyupm_mb704x.i --- upm-1.6.0/src/mb704x/pyupm_mb704x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mb704x/pyupm_mb704x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mb704x -%include "../upm.i" -%include "std_string.i" - -%include "mb704x.hpp" -%{ - #include "mb704x.hpp" -%} diff -Nru upm-1.6.0/src/mcp2515/javaupm_mcp2515.i upm-1.7.1/src/mcp2515/javaupm_mcp2515.i --- upm-1.6.0/src/mcp2515/javaupm_mcp2515.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mcp2515/javaupm_mcp2515.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -%module javaupm_mcp2515 -%include "../upm.i" -%include "typemaps.i" -%include "arrays_java.i" -%include "../java_buffer.i" -%include "std_string.i" - -%{ - #include "mcp2515.hpp" - #include "mcp2515_regs.h" -%} -%include "mcp2515_regs.h" -%include "mcp2515.hpp" - -%ignore installISR(int pin, void *, void *); - -JAVA_ADD_INSTALLISR_PIN(upm::MCP2515) -JAVA_JNI_LOADLIBRARY(javaupm_mcp2515) diff -Nru upm-1.6.0/src/mcp2515/jsupm_mcp2515.i upm-1.7.1/src/mcp2515/jsupm_mcp2515.i --- upm-1.6.0/src/mcp2515/jsupm_mcp2515.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mcp2515/jsupm_mcp2515.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module jsupm_mcp2515 -%include "../upm.i" -%include "cpointer.i" -%include "std_string.i" -%include "../carrays_uint8_t.i" - -%pointer_functions(float, floatp); - -%include "mcp2515_regs.h" -%include "mcp2515.hpp" -%{ - #include "mcp2515.hpp" -%} diff -Nru upm-1.6.0/src/mcp2515/mcp2515.c upm-1.7.1/src/mcp2515/mcp2515.c --- upm-1.6.0/src/mcp2515/mcp2515.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mcp2515/mcp2515.c 2018-10-12 04:47:41.000000000 +0000 @@ -456,8 +456,7 @@ << _MCP2515_CANSTAT_OPMODE_SHIFT); bool done = false; - upm_clock_t clock; - upm_clock_init(&clock); + upm_clock_t clock = upm_clock_init(); do { @@ -623,8 +622,7 @@ return UPM_SUCCESS; // now spin with timeout waiting for it to be transmitted - upm_clock_t clock; - upm_clock_init(&clock); + upm_clock_t clock = upm_clock_init(); bool done = false; do diff -Nru upm-1.6.0/src/mcp2515/mcp2515.i upm-1.7.1/src/mcp2515/mcp2515.i --- upm-1.6.0/src/mcp2515/mcp2515.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/mcp2515/mcp2515.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,25 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i" +%include "../java_buffer.i" + +%ignore installISR(int pin, void *, void *); + +JAVA_JNI_LOADLIBRARY(javaupm_mcp2515) +JAVA_ADD_INSTALLISR_PIN(upm::MCP2515) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "../carrays_uint8_t.i" +%pointer_functions(float, floatp); + +%{ +#include "mcp2515_regs.h" +#include "mcp2515.hpp" +%} +%include "mcp2515_regs.h" +%include "mcp2515.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/mcp2515/pyupm_mcp2515.i upm-1.7.1/src/mcp2515/pyupm_mcp2515.i --- upm-1.6.0/src/mcp2515/pyupm_mcp2515.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mcp2515/pyupm_mcp2515.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mcp2515 -%include "../upm.i" -%include "cpointer.i" -%include "std_string.i" -%include "../carrays_uint8_t.i" - -%include "stdint.i" - -%pointer_functions(float, floatp); - -%include "mcp2515_regs.h" -%include "mcp2515.hpp" -%{ - #include "mcp2515.hpp" -%} diff -Nru upm-1.6.0/src/mcp9808/javaupm_mcp9808.i upm-1.7.1/src/mcp9808/javaupm_mcp9808.i --- upm-1.6.0/src/mcp9808/javaupm_mcp9808.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mcp9808/javaupm_mcp9808.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_mcp9808 -%include "../upm.i" - -%{ - #include "mcp9808.hpp" -%} - -%include "mcp9808.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mcp9808) \ No newline at end of file diff -Nru upm-1.6.0/src/mcp9808/jsupm_mcp9808.i upm-1.7.1/src/mcp9808/jsupm_mcp9808.i --- upm-1.6.0/src/mcp9808/jsupm_mcp9808.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mcp9808/jsupm_mcp9808.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mcp9808 -%include "../upm.i" - -%{ - #include "mcp9808.hpp" -%} - -%include "mcp9808.hpp" diff -Nru upm-1.6.0/src/mcp9808/pyupm_mcp9808.i upm-1.7.1/src/mcp9808/pyupm_mcp9808.i --- upm-1.6.0/src/mcp9808/pyupm_mcp9808.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mcp9808/pyupm_mcp9808.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mcp9808 -%include "../upm.i" - -%include "mcp9808.hpp" -%{ - #include "mcp9808.hpp" -%} diff -Nru upm-1.6.0/src/md/javaupm_md.i upm-1.7.1/src/md/javaupm_md.i --- upm-1.6.0/src/md/javaupm_md.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/md/javaupm_md.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_md -%include "../upm.i" - -%{ - #include "md.hpp" -%} - -%include "md_defs.h" -%include "md.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_md) diff -Nru upm-1.6.0/src/md/jsupm_md.i upm-1.7.1/src/md/jsupm_md.i --- upm-1.6.0/src/md/jsupm_md.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/md/jsupm_md.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_md -%include "../upm.i" - -%include "md_defs.h" -%include "md.hpp" -%{ - #include "md.hpp" -%} - diff -Nru upm-1.6.0/src/md/md.i upm-1.7.1/src/md/md.i --- upm-1.6.0/src/md/md.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/md/md.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_md) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "md_defs.h" +#include "md.hpp" +%} +%include "md_defs.h" +%include "md.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/md/md.json upm-1.7.1/src/md/md.json --- upm-1.6.0/src/md/md.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/md/md.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,53 +1,53 @@ -{ - "Library": "md", - "Description": "I2C Motor Driver library", - "Sensor Class": { - "MD": { - "Name": "Grove I2C Motor Driver", - "Description": "This class implements support for the I2C Motor Driver. This device can support a single 4-wire stepper motor, or two 2-wire DC motors. The device contains an Atmel* ATmega8L microcontroller that manages an L298N H-bridge driver chip. This device supports an I2C bus speed of 100Khz only. The module does not provide any telemetry or status - it only accepts I2C commands for its various operations. This module was tested with version 1.3 of the I2C Motor Driver. For stepper operation, this driver can run in one of two modes - Mode 1, where this driver handles the stepping operation, and Mode 2, where this driver simply sends commands to the Motor Driver, and it handles the stepping operation. Mode2 requires updated (and working) firmware to be loaded onto the device. The default stepper operation mode is Mode1, which is generally more flexible and is supported on all firmware revisions.", - "Aliases": ["Grove - I2C Motor Driver"], - "Categories": ["motor"], - "Connections": ["i2c"], - "Project Type": ["prototyping", "robotics"], - "Manufacturers": ["Seeed"], - "Kits": ["robok"], - "Image": "md.jpg", - "Examples": { - "Java": ["GroveMDSample.java"], - "Python": ["grovemd-stepper.py", "grovemd.py"], - "Node.js": ["md-stepper.js", "md.js"], - "C++": ["md-stepper.cxx", "md.cxx"], - "C": ["md-stepper.c", "md.c"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "min": 3.3, - "max": 5.0 - }, - "Supply Current": { - "unit": "A", - "min" : 0.5, - "max" : 4 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Requires Grove Shield"] - }, - "Arduino 101": { - "Notes": ["Requires Grove Shield"] - } - }, - "Urls": { - "Product Pages": ["https://www.seeedstudio.com/Grove-I2C-Motor-Driver-p-907.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-I2C_Motor_Driver_V1.3/"] - } - } - } +{ + "Library": "md", + "Description": "I2C Motor Driver library", + "Sensor Class": { + "MD": { + "Name": "Grove I2C Motor Driver", + "Description": "This class implements support for the I2C Motor Driver. This device can support a single 4-wire stepper motor, or two 2-wire DC motors. The device contains an Atmel* ATmega8L microcontroller that manages an L298N H-bridge driver chip. This device supports an I2C bus speed of 100Khz only. The module does not provide any telemetry or status - it only accepts I2C commands for its various operations. This module was tested with version 1.3 of the I2C Motor Driver. For stepper operation, this driver can run in one of two modes - Mode 1, where this driver handles the stepping operation, and Mode 2, where this driver simply sends commands to the Motor Driver, and it handles the stepping operation. Mode2 requires updated (and working) firmware to be loaded onto the device. The default stepper operation mode is Mode1, which is generally more flexible and is supported on all firmware revisions.", + "Aliases": ["Grove - I2C Motor Driver"], + "Categories": ["motor"], + "Connections": ["i2c"], + "Project Type": ["prototyping", "robotics"], + "Manufacturers": ["Seeed"], + "Kits": ["robok"], + "Image": "md.jpg", + "Examples": { + "Java": ["GroveMD_Example.java"], + "Python": ["grovemd-stepper.py", "grovemd.py"], + "Node.js": ["md-stepper.js", "md.js"], + "C++": ["md-stepper.cxx", "md.cxx"], + "C": ["md-stepper.c", "md.c"] + }, + "Specifications": { + "Vsource": { + "unit": "V", + "min": 3.3, + "max": 5.0 + }, + "Supply Current": { + "unit": "A", + "min" : 0.5, + "max" : 4 + }, + "Operating Temperature": { + "unit": "°C", + "min": -40, + "max": 85 + } + }, + "Platforms": { + "Intel Edison": { + "Notes": ["Requires Grove Shield"] + }, + "Arduino 101": { + "Notes": ["Requires Grove Shield"] + } + }, + "Urls": { + "Product Pages": ["https://www.seeedstudio.com/Grove-I2C-Motor-Driver-p-907.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-I2C_Motor_Driver_V1.3/"] + } + } + } } \ No newline at end of file diff -Nru upm-1.6.0/src/md/pyupm_md.i upm-1.7.1/src/md/pyupm_md.i --- upm-1.6.0/src/md/pyupm_md.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/md/pyupm_md.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_md -%include "../upm.i" - -%include "md_defs.h" -%include "md.hpp" -%{ - #include "md.hpp" -%} diff -Nru upm-1.6.0/src/mg811/javaupm_mg811.i upm-1.7.1/src/mg811/javaupm_mg811.i --- upm-1.6.0/src/mg811/javaupm_mg811.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mg811/javaupm_mg811.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_mg811 -%include "../upm.i" - -%{ - #include "mg811.hpp" -%} - -%include "mg811.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mg811) \ No newline at end of file diff -Nru upm-1.6.0/src/mg811/jsupm_mg811.i upm-1.7.1/src/mg811/jsupm_mg811.i --- upm-1.6.0/src/mg811/jsupm_mg811.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mg811/jsupm_mg811.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mg811 -%include "../upm.i" - -%{ - #include "mg811.hpp" -%} - -%include "mg811.hpp" diff -Nru upm-1.6.0/src/mg811/pyupm_mg811.i upm-1.7.1/src/mg811/pyupm_mg811.i --- upm-1.6.0/src/mg811/pyupm_mg811.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mg811/pyupm_mg811.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mg811 -%include "../upm.i" - -%include "mg811.hpp" -%{ - #include "mg811.hpp" -%} diff -Nru upm-1.6.0/src/mhz16/javaupm_mhz16.i upm-1.7.1/src/mhz16/javaupm_mhz16.i --- upm-1.6.0/src/mhz16/javaupm_mhz16.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mhz16/javaupm_mhz16.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -%module javaupm_mhz16 -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%apply int *OUTPUT { int *gas, int *temp }; - -%{ - #include "mhz16.hpp" - speed_t int_B9600 = B9600; -%} - -%include "mhz16.hpp" -speed_t int_B9600 = B9600; - -JAVA_JNI_LOADLIBRARY(javaupm_mhz16) \ No newline at end of file diff -Nru upm-1.6.0/src/mhz16/jsupm_mhz16.i upm-1.7.1/src/mhz16/jsupm_mhz16.i --- upm-1.6.0/src/mhz16/jsupm_mhz16.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mhz16/jsupm_mhz16.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module jsupm_mhz16 -%include "../upm.i" -%include "cpointer.i" - -/* Send "int *" to JavaScript as intp */ -%pointer_functions(int, intp); -%{ - #include "mhz16.hpp" - speed_t int_B9600 = B9600; -%} - -%include "mhz16.hpp" -speed_t int_B9600 = B9600; diff -Nru upm-1.6.0/src/mhz16/mhz16.cxx upm-1.7.1/src/mhz16/mhz16.cxx --- upm-1.6.0/src/mhz16/mhz16.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mhz16/mhz16.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -41,7 +41,6 @@ { throw std::invalid_argument(std::string(__FUNCTION__) + ": mraa_uart_init() failed"); - return; } // This requires a recent MRAA (1/2015) @@ -51,17 +50,44 @@ { throw std::runtime_error(std::string(__FUNCTION__) + ": mraa_uart_get_dev_path() failed"); - return; } // now open the tty if ( (m_ttyFd = open(devPath, O_RDWR)) == -1) { throw std::runtime_error(std::string(__FUNCTION__) + - ": open of " + + ": open of " + + string(devPath) + " failed: " + + string(strerror(errno))); + } +} + +MHZ16::MHZ16(const std::string& uart_raw) +{ + m_ttyFd = -1; + + if ( !(m_uart = mraa_uart_init_raw(uart_raw.c_str())) ) + { + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_uart_init_raw() failed"); + } + + // This requires a recent MRAA (1/2015) + const char *devPath = mraa_uart_get_dev_path(m_uart); + + if (!devPath) + { + throw std::runtime_error(std::string(__FUNCTION__) + + ": mraa_uart_get_dev_path() failed"); + } + + // now open the tty + if ( (m_ttyFd = open(devPath, O_RDWR)) == -1) + { + throw std::runtime_error(std::string(__FUNCTION__) + + ": open of " + string(devPath) + " failed: " + string(strerror(errno))); - return; } } @@ -89,11 +115,11 @@ FD_ZERO(&readfds); FD_SET(m_ttyFd, &readfds); - + if (select(m_ttyFd + 1, &readfds, NULL, NULL, &timeout) > 0) return true; // data is ready - else - return false; + + return false; } int MHZ16::readData(char *buffer, int len) @@ -111,7 +137,6 @@ throw std::runtime_error(std::string(__FUNCTION__) + ": read() failed: " + string(strerror(errno))); - return rv; } return rv; @@ -132,7 +157,6 @@ throw std::runtime_error(std::string(__FUNCTION__) + ": write() failed: " + string(strerror(errno))); - return rv; } tcdrain(m_ttyFd); @@ -144,7 +168,7 @@ { if (m_ttyFd == -1) return(false); - + struct termios termio; // get current modes @@ -164,7 +188,6 @@ throw std::runtime_error(std::string(__FUNCTION__) + ": tcsetattr() failed: " + string(strerror(errno))); - return false; } return true; @@ -176,16 +199,15 @@ { throw std::runtime_error(std::string(__FUNCTION__) + ": invalid packet header received"); - return false; } - + return true; } bool MHZ16::getData() { // the query command - const unsigned char cmd[9] = + const unsigned char cmd[9] = {0xff, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79}; writeData((char *)cmd, 9); @@ -195,7 +217,6 @@ { throw std::runtime_error(std::string(__FUNCTION__) + ": Timed out waiting for response"); - return false; } // read the packet @@ -206,9 +227,8 @@ { throw std::runtime_error(std::string(__FUNCTION__) + ": Invalid packet size read"); - return false; } - + // will throw an exception if it fails verifyPacket(packet, sizeof(packet)); @@ -232,7 +252,7 @@ void MHZ16::calibrateZeroPoint() { // the query command - const unsigned char cmd[9] = + const unsigned char cmd[9] = {0xff, 0x01, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78}; writeData((char *)cmd, 9); diff -Nru upm-1.6.0/src/mhz16/mhz16.hpp upm-1.7.1/src/mhz16/mhz16.hpp --- upm-1.6.0/src/mhz16/mhz16.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mhz16/mhz16.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -40,12 +40,6 @@ #include -const int MHZ16_DEFAULT_UART = 0; - -// protocol start and end codes -const uint8_t MHZ16_START = 0x7e; -const uint8_t MHZ16_END = 0x7e; - namespace upm { /** * @brief MHZ16 Serial CO2 Sensor @@ -80,14 +74,21 @@ /** * MHZ16 constructor * - * @param uart Default UART to use (0 or 1) + * @param uart Default mraa UART index to use */ MHZ16(int uart); /** + * MHZ16 constructor + * + * @param uart_raw Full path to UART device. + */ + MHZ16(const std::string& uart_raw = "/dev/ttyS0"); + + /** * MHZ16 destructor */ - ~MHZ16(); + virtual ~MHZ16(); /** * Checks to see if there is data available for reading @@ -169,9 +170,9 @@ private: mraa_uart_context m_uart; - int m_ttyFd; - int gas; - int temp; + int m_ttyFd = 0; + int gas = 0; + int temp = 0; }; } diff -Nru upm-1.6.0/src/mhz16/mhz16.i upm-1.7.1/src/mhz16/mhz16.i --- upm-1.6.0/src/mhz16/mhz16.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/mhz16/mhz16.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,23 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" + +%apply int *OUTPUT { int *gas, int *temp }; + +JAVA_JNI_LOADLIBRARY(javaupm_mhz16) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(int, intp); + +%{ +#include "mhz16.hpp" +speed_t int_B9600 = B9600; +%} +%include "mhz16.hpp" +speed_t int_B9600 = B9600; +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/mhz16/mhz16.json upm-1.7.1/src/mhz16/mhz16.json --- upm-1.6.0/src/mhz16/mhz16.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mhz16/mhz16.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed", "Zhengzhou Winsen Electronics Technology"], "Image": "mhz16.jpg", "Examples": { - "Java" : ["MHZ16Sample.java"], + "Java" : ["MHZ16_Example.java"], "Python": ["mhz16.py"], "Node.js": ["mhz16.js"], "C++": ["mhz16.cxx"] diff -Nru upm-1.6.0/src/mhz16/pyupm_mhz16.i upm-1.7.1/src/mhz16/pyupm_mhz16.i --- upm-1.6.0/src/mhz16/pyupm_mhz16.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mhz16/pyupm_mhz16.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mhz16 -%include "../upm.i" -%include "cpointer.i" - -/* Send "int *" to JavaScript as intp */ -%pointer_functions(int, intp); -%{ - #include "mhz16.hpp" - speed_t int_B9600 = B9600; -%} -%include "mhz16.hpp" -speed_t int_B9600 = B9600; diff -Nru upm-1.6.0/src/mic/javaupm_mic.i upm-1.7.1/src/mic/javaupm_mic.i --- upm-1.6.0/src/mic/javaupm_mic.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mic/javaupm_mic.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -%module javaupm_mic -%include "../upm.i" -%include "stdint.i" -%include "arrays_java.i" - -%{ - #include "mic.hpp" -%} - -%typemap(jni) (uint16_t *buffer, int len) "jshortArray"; -%typemap(jtype) (uint16_t *buffer, int len) "short[]"; -%typemap(jstype) (uint16_t *buffer, int len) "short[]"; - -%typemap(javain) (uint16_t *buffer, int len) "$javainput"; - -%typemap(in) (uint16_t *buffer, int len) { - $1 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL); - $2 = JCALL1(GetArrayLength, jenv, $input); -} - -%typemap(freearg) (uint16_t *buffer, int len) { - JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$1, 0); -} - -%typemap(jni) (int numberOfSamples, uint16_t *buffer) "jshortArray"; -%typemap(jtype) (int numberOfSamples, uint16_t *buffer) "short[]"; -%typemap(jstype) (int numberOfSamples, uint16_t *buffer) "short[]"; - -%typemap(javain) (int numberOfSamples, uint16_t *buffer) "$javainput"; - -%typemap(in) (int numberOfSamples, uint16_t *buffer) { - $2 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL); - $1 = JCALL1(GetArrayLength, jenv, $input); -} - -%typemap(freearg) (int numberOfSamples, uint16_t *buffer) { - JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$2, 0); -} - -%include "mic.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mic) \ No newline at end of file diff -Nru upm-1.6.0/src/mic/jsupm_mic.i upm-1.7.1/src/mic/jsupm_mic.i --- upm-1.6.0/src/mic/jsupm_mic.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mic/jsupm_mic.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_mic -%include "../upm.i" -%include "../carrays_uint16_t.i" - -%{ - #include "mic.hpp" -%} - -%include "mic.hpp" diff -Nru upm-1.6.0/src/mic/mic.i upm-1.7.1/src/mic/mic.i --- upm-1.6.0/src/mic/mic.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/mic/mic.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,58 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i" + +%typemap(jni) (uint16_t *buffer, int len) "jshortArray"; +%typemap(jtype) (uint16_t *buffer, int len) "short[]"; +%typemap(jstype) (uint16_t *buffer, int len) "short[]"; + +%typemap(javain) (uint16_t *buffer, int len) "$javainput"; + +%typemap(in) (uint16_t *buffer, int len) { + $1 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL); + $2 = JCALL1(GetArrayLength, jenv, $input); +} + +%typemap(freearg) (uint16_t *buffer, int len) { + JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$1, 0); +} + +%typemap(jni) (int numberOfSamples, uint16_t *buffer) "jshortArray"; +%typemap(jtype) (int numberOfSamples, uint16_t *buffer) "short[]"; +%typemap(jstype) (int numberOfSamples, uint16_t *buffer) "short[]"; + +%typemap(javain) (int numberOfSamples, uint16_t *buffer) "$javainput"; + +%typemap(in) (int numberOfSamples, uint16_t *buffer) { + $2 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL); + $1 = JCALL1(GetArrayLength, jenv, $input); +} + +%typemap(freearg) (int numberOfSamples, uint16_t *buffer) { + JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$2, 0); +} + +JAVA_JNI_LOADLIBRARY(javaupm_mic) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint16_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_uint16_t.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "mic.hpp" +%} +%include "mic.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/mic/mic.json upm-1.7.1/src/mic/mic.json --- upm-1.6.0/src/mic/mic.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mic/mic.json 2018-10-12 04:47:41.000000000 +0000 @@ -16,7 +16,7 @@ "Image": "mic.jpg", "Examples": { - "Java": ["MicrophoneSample.java"], + "Java": ["Microphone_Example.java"], "Python": ["mic.py"], "Node.js": ["mic.js"], "C++": ["mic.cxx"] diff -Nru upm-1.6.0/src/mic/pyupm_mic.i upm-1.7.1/src/mic/pyupm_mic.i --- upm-1.6.0/src/mic/pyupm_mic.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mic/pyupm_mic.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mic -%include "../upm.i" -%include "../carrays_uint16_t.i" - -%{ - #include "mic.hpp" -%} -%include "mic.hpp" diff -Nru upm-1.6.0/src/micsv89/javaupm_micsv89.i upm-1.7.1/src/micsv89/javaupm_micsv89.i --- upm-1.6.0/src/micsv89/javaupm_micsv89.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/micsv89/javaupm_micsv89.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_micsv89 -%include "../upm.i" - -%{ - #include "micsv89.hpp" -%} - -%include "micsv89.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_micsv89) \ No newline at end of file diff -Nru upm-1.6.0/src/micsv89/jsupm_micsv89.i upm-1.7.1/src/micsv89/jsupm_micsv89.i --- upm-1.6.0/src/micsv89/jsupm_micsv89.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/micsv89/jsupm_micsv89.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_micsv89 -%include "../upm.i" - -%{ - #include "micsv89.hpp" -%} - -%include "micsv89.hpp" diff -Nru upm-1.6.0/src/micsv89/pyupm_micsv89.i upm-1.7.1/src/micsv89/pyupm_micsv89.i --- upm-1.6.0/src/micsv89/pyupm_micsv89.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/micsv89/pyupm_micsv89.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_micsv89 -%include "../upm.i" - -%include "micsv89.hpp" -%{ - #include "micsv89.hpp" -%} diff -Nru upm-1.6.0/src/mlx90614/javaupm_mlx90614.i upm-1.7.1/src/mlx90614/javaupm_mlx90614.i --- upm-1.6.0/src/mlx90614/javaupm_mlx90614.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mlx90614/javaupm_mlx90614.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_mlx90614 -%include "../upm.i" - -%{ - #include "mlx90614.hpp" -%} - -%include "mlx90614.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mlx90614) \ No newline at end of file diff -Nru upm-1.6.0/src/mlx90614/jsupm_mlx90614.i upm-1.7.1/src/mlx90614/jsupm_mlx90614.i --- upm-1.6.0/src/mlx90614/jsupm_mlx90614.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mlx90614/jsupm_mlx90614.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mlx90614 -%include "../upm.i" - -%{ - #include "mlx90614.hpp" -%} - -%include "mlx90614.hpp" diff -Nru upm-1.6.0/src/mlx90614/pyupm_mlx90614.i upm-1.7.1/src/mlx90614/pyupm_mlx90614.i --- upm-1.6.0/src/mlx90614/pyupm_mlx90614.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mlx90614/pyupm_mlx90614.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mlx90614 -%include "../upm.i" - -%include "mlx90614.hpp" -%{ - #include "mlx90614.hpp" -%} diff -Nru upm-1.6.0/src/mma7361/javaupm_mma7361.i upm-1.7.1/src/mma7361/javaupm_mma7361.i --- upm-1.6.0/src/mma7361/javaupm_mma7361.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7361/javaupm_mma7361.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -%module javaupm_mma7361 -%include "../upm.i" -%include "std_string.i" -%include "cpointer.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%apply int *OUTPUT { int *x, int *y, int *z }; -%apply float *OUTPUT { float *ax, float *ay, float *az }; - -%typemap(jni) float* "jfloatArray" -%typemap(jstype) float* "float[]" -%typemap(jtype) float* "float[]" - -%typemap(javaout) float* { - return $jnicall; -} - -%typemap(out) float *getAcceleration { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); -} - -%typemap(out) float *getVolts { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); -} - -%typemap(out) float *getNormalized { - $result = JCALL1(NewFloatArray, jenv, 3); - JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); -} - -%ignore getNormalized(float *, float *, float *); -%ignore getAcceleration(float *, float *, float *); -%ignore getVolts(float *, float *, float *); - -%include "mma7361.hpp" -%{ - #include "mma7361.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_mma7361) diff -Nru upm-1.6.0/src/mma7361/jsupm_mma7361.i upm-1.7.1/src/mma7361/jsupm_mma7361.i --- upm-1.6.0/src/mma7361/jsupm_mma7361.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7361/jsupm_mma7361.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module jsupm_mma7361 -%include "../upm.i" -%include "std_string.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to JavaScript as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "mma7361.hpp" -%{ - #include "mma7361.hpp" -%} - diff -Nru upm-1.6.0/src/mma7361/mma7361.i upm-1.7.1/src/mma7361/mma7361.i --- upm-1.6.0/src/mma7361/mma7361.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/mma7361/mma7361.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,61 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" + +%apply int *OUTPUT { int *x, int *y, int *z }; +%apply float *OUTPUT { float *ax, float *ay, float *az }; + +%typemap(jni) float* "jfloatArray" +%typemap(jstype) float* "float[]" +%typemap(jtype) float* "float[]" + +%typemap(javaout) float* { + return $jnicall; +} + +%typemap(out) float *getAcceleration { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); +} + +%typemap(out) float *getVolts { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); +} + +%typemap(out) float *getNormalized { + $result = JCALL1(NewFloatArray, jenv, 3); + JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1); +} + +%ignore getNormalized(float *, float *, float *); +%ignore getAcceleration(float *, float *, float *); +%ignore getVolts(float *, float *, float *); + +JAVA_JNI_LOADLIBRARY(javaupm_mma7361) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%pointer_functions(int, intp); +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "mma7361.hpp" +%} +%include "mma7361.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/mma7361/pyupm_mma7361.i upm-1.7.1/src/mma7361/pyupm_mma7361.i --- upm-1.6.0/src/mma7361/pyupm_mma7361.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7361/pyupm_mma7361.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mma7361 -%include "../upm.i" -%include "std_string.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to python as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "mma7361.hpp" -%{ - #include "mma7361.hpp" -%} - diff -Nru upm-1.6.0/src/mma7455/javaupm_mma7455.i upm-1.7.1/src/mma7455/javaupm_mma7455.i --- upm-1.6.0/src/mma7455/javaupm_mma7455.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7455/javaupm_mma7455.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -%module javaupm_mma7455 -%include "../upm.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i" -%include "std_vector.i" - -%template(ShortVector) std::vector; - -%apply short *OUTPUT { short * ptrX, short * ptrY, short * ptrZ }; - -%{ -#include "mma7455.hpp" -%} -%include "mma7455.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mma7455) diff -Nru upm-1.6.0/src/mma7455/jsupm_mma7455.i upm-1.7.1/src/mma7455/jsupm_mma7455.i --- upm-1.6.0/src/mma7455/jsupm_mma7455.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7455/jsupm_mma7455.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mma7455 -%include "../upm.i" - -%{ - #include "mma7455.hpp" -%} - -%include "mma7455.hpp" diff -Nru upm-1.6.0/src/mma7455/mma7455.i upm-1.7.1/src/mma7455/mma7455.i --- upm-1.6.0/src/mma7455/mma7455.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/mma7455/mma7455.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,20 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" +%include "std_vector.i" +%apply short *OUTPUT { short * ptrX, short * ptrY, short * ptrZ }; +%template(ShortVector) std::vector; + +JAVA_JNI_LOADLIBRARY(javaupm_mma7455) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "mma7455.hpp" +%} +%include "mma7455.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/mma7455/mma7455.json upm-1.7.1/src/mma7455/mma7455.json --- upm-1.6.0/src/mma7455/mma7455.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7455/mma7455.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["NXP", "Freescale"], "Image": "mma7455.jpg", "Examples": { - "Java": ["MMA7455Sample.java"], + "Java": ["MMA7455_Example.java"], "C++": ["mma7455.cxx"] }, "Specifications": { diff -Nru upm-1.6.0/src/mma7455/pyupm_mma7455.i upm-1.7.1/src/mma7455/pyupm_mma7455.i --- upm-1.6.0/src/mma7455/pyupm_mma7455.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7455/pyupm_mma7455.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mma7455 -%include "../upm.i" - -%include "mma7455.hpp" -%{ - #include "mma7455.hpp" -%} diff -Nru upm-1.6.0/src/mma7660/javaupm_mma7660.i upm-1.7.1/src/mma7660/javaupm_mma7660.i --- upm-1.6.0/src/mma7660/javaupm_mma7660.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7660/javaupm_mma7660.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -%module javaupm_mma7660 -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i" -%include "std_vector.i" - -%template(IntVector) std::vector; -%template(FloatVector) std::vector; - -%apply int *OUTPUT { int *x, int *y, int *z }; -%apply float *OUTPUT { float *ax, float *ay, float *az }; - -%{ -#include "mma7660.hpp" -#include "mma7660_regs.h" -%} -%include "mma7660_regs.h" -%include "mma7660.hpp" - -%ignore installISR(int , void *, void *); - -JAVA_ADD_INSTALLISR_PIN(upm::MMA7660) -JAVA_JNI_LOADLIBRARY(javaupm_mma7660) diff -Nru upm-1.6.0/src/mma7660/jsupm_mma7660.i upm-1.7.1/src/mma7660/jsupm_mma7660.i --- upm-1.6.0/src/mma7660/jsupm_mma7660.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7660/jsupm_mma7660.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module jsupm_mma7660 -%include "../upm.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to JavaScript as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "mma7660_regs.h" -%include "mma7660.hpp" -%{ - #include "mma7660.hpp" -%} - diff -Nru upm-1.6.0/src/mma7660/mma7660.i upm-1.7.1/src/mma7660/mma7660.i --- upm-1.6.0/src/mma7660/mma7660.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/mma7660/mma7660.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,31 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" +%include "std_vector.i" + +%apply float *OUTPUT { float *ax, float *ay, float *az }; +%apply int *OUTPUT { int *x, int *y, int *z }; +%ignore installISR(int , void *, void *); + +%template(IntVector) std::vector; +%template(FloatVector) std::vector; + +JAVA_ADD_INSTALLISR_PIN(upm::MMA7660) +JAVA_JNI_LOADLIBRARY(javaupm_mma7660) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(int, intp); +%pointer_functions(float, floatp); + +%{ +#include "mma7660_regs.h" +#include "mma7660.hpp" +%} +%include "mma7660_regs.h" +%include "mma7660.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/mma7660/mma7660.json upm-1.7.1/src/mma7660/mma7660.json --- upm-1.6.0/src/mma7660/mma7660.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7660/mma7660.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed", "NXP"], "Image": "mma7660.jpg", "Examples": { - "Java": ["MMA7660Sample.java"], + "Java": ["MMA7660_Example.java"], "Python": ["mma7660.py"], "Node.js": ["mma7660.js"], "C++": ["mma7660.cxx"], diff -Nru upm-1.6.0/src/mma7660/pyupm_mma7660.i upm-1.7.1/src/mma7660/pyupm_mma7660.i --- upm-1.6.0/src/mma7660/pyupm_mma7660.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma7660/pyupm_mma7660.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mma7660 -%include "../upm.i" -%include "cpointer.i" - -/* Send "int *" and "float *" to python as intp and floatp */ -%pointer_functions(int, intp); -%pointer_functions(float, floatp); - -%include "mma7660_regs.h" -%include "mma7660.hpp" -%{ - #include "mma7660.hpp" -%} diff -Nru upm-1.6.0/src/mma8x5x/javaupm_mma8x5x.i upm-1.7.1/src/mma8x5x/javaupm_mma8x5x.i --- upm-1.6.0/src/mma8x5x/javaupm_mma8x5x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma8x5x/javaupm_mma8x5x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_mma8x5x -%include "../upm.i" - -%{ - #include "mma8x5x.hpp" -%} - -%include "mma8x5x.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mma8x5x) \ No newline at end of file diff -Nru upm-1.6.0/src/mma8x5x/jsupm_mma8x5x.i upm-1.7.1/src/mma8x5x/jsupm_mma8x5x.i --- upm-1.6.0/src/mma8x5x/jsupm_mma8x5x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma8x5x/jsupm_mma8x5x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mma8x5x -%include "../upm.i" - -%{ - #include "mma8x5x.hpp" -%} - -%include "mma8x5x.hpp" diff -Nru upm-1.6.0/src/mma8x5x/pyupm_mma8x5x.i upm-1.7.1/src/mma8x5x/pyupm_mma8x5x.i --- upm-1.6.0/src/mma8x5x/pyupm_mma8x5x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mma8x5x/pyupm_mma8x5x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mma8x5x -%include "../upm.i" - -%include "mma8x5x.hpp" -%{ - #include "mma8x5x.hpp" -%} diff -Nru upm-1.6.0/src/mmc35240/javaupm_mmc35240.i upm-1.7.1/src/mmc35240/javaupm_mmc35240.i --- upm-1.6.0/src/mmc35240/javaupm_mmc35240.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mmc35240/javaupm_mmc35240.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_mmc35240 -%include "../upm.i" - -%{ - #include "mmc35240.hpp" -%} - -%include "mmc35240.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mmc35240) diff -Nru upm-1.6.0/src/mmc35240/jsupm_mmc35240.i upm-1.7.1/src/mmc35240/jsupm_mmc35240.i --- upm-1.6.0/src/mmc35240/jsupm_mmc35240.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mmc35240/jsupm_mmc35240.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mmc35240 -%include "../upm.i" - -%{ - #include "mmc35240.hpp" -%} - -%include "mmc35240.hpp" diff -Nru upm-1.6.0/src/mmc35240/pyupm_mmc35240.i upm-1.7.1/src/mmc35240/pyupm_mmc35240.i --- upm-1.6.0/src/mmc35240/pyupm_mmc35240.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mmc35240/pyupm_mmc35240.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module pyupm_mmc35240 -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%include "../upm.i" - -%include "mmc35240.hpp" -%{ - #include "mmc35240.hpp" -%} diff -Nru upm-1.6.0/src/moisture/javaupm_moisture.i upm-1.7.1/src/moisture/javaupm_moisture.i --- upm-1.6.0/src/moisture/javaupm_moisture.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/moisture/javaupm_moisture.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_moisture -%include "../upm.i" - -%{ - #include "moisture.hpp" -%} - -%include "moisture.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_moisture) \ No newline at end of file diff -Nru upm-1.6.0/src/moisture/jsupm_moisture.i upm-1.7.1/src/moisture/jsupm_moisture.i --- upm-1.6.0/src/moisture/jsupm_moisture.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/moisture/jsupm_moisture.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_moisture -%include "../upm.i" - -%{ - #include "moisture.hpp" -%} - -%include "moisture.hpp" \ No newline at end of file diff -Nru upm-1.6.0/src/moisture/moisture.json upm-1.7.1/src/moisture/moisture.json --- upm-1.6.0/src/moisture/moisture.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/moisture/moisture.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["eak", "hak"], "Image": "moisture.jpg", "Examples": { - "Java": ["MoistureSample.java"], + "Java": ["Moisture_Example.java"], "Python": ["moisture.py"], "Node.js": ["moisture.js"], "C++": ["moisture.cxx"], diff -Nru upm-1.6.0/src/moisture/pyupm_moisture.i upm-1.7.1/src/moisture/pyupm_moisture.i --- upm-1.6.0/src/moisture/pyupm_moisture.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/moisture/pyupm_moisture.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_moisture -%include "../upm.i" - -%include "moisture.hpp" -%{ - #include "moisture.hpp" -%} \ No newline at end of file diff -Nru upm-1.6.0/src/mpl3115a2/javaupm_mpl3115a2.i upm-1.7.1/src/mpl3115a2/javaupm_mpl3115a2.i --- upm-1.6.0/src/mpl3115a2/javaupm_mpl3115a2.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpl3115a2/javaupm_mpl3115a2.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_mpl3115a2 -%include "../upm.i" - -%{ - #include "mpl3115a2.hpp" -%} - -%include "mpl3115a2.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mpl3115a2) \ No newline at end of file diff -Nru upm-1.6.0/src/mpl3115a2/jsupm_mpl3115a2.i upm-1.7.1/src/mpl3115a2/jsupm_mpl3115a2.i --- upm-1.6.0/src/mpl3115a2/jsupm_mpl3115a2.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpl3115a2/jsupm_mpl3115a2.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mpl3115a2 -%include "../upm.i" - -%{ - #include "mpl3115a2.hpp" -%} - -%include "mpl3115a2.hpp" diff -Nru upm-1.6.0/src/mpl3115a2/mpl3115a2.json upm-1.7.1/src/mpl3115a2/mpl3115a2.json --- upm-1.6.0/src/mpl3115a2/mpl3115a2.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpl3115a2/mpl3115a2.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["NXP", "Adafruit"], "Image": "mpl3115a2.jpg", "Examples": { - "Java": ["MPL3115A2Sample.java"], + "Java": ["MPL3115A2_Example.java"], "C++": ["mpl3115a2.cxx"] }, "Specifications": { diff -Nru upm-1.6.0/src/mpl3115a2/pyupm_mpl3115a2.i upm-1.7.1/src/mpl3115a2/pyupm_mpl3115a2.i --- upm-1.6.0/src/mpl3115a2/pyupm_mpl3115a2.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpl3115a2/pyupm_mpl3115a2.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mpl3115a2 -%include "../upm.i" - -%include "mpl3115a2.hpp" -%{ - #include "mpl3115a2.hpp" -%} diff -Nru upm-1.6.0/src/mpr121/javaupm_mpr121.i upm-1.7.1/src/mpr121/javaupm_mpr121.i --- upm-1.6.0/src/mpr121/javaupm_mpr121.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpr121/javaupm_mpr121.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_mpr121 -%include "../upm.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%{ - #include "mpr121.hpp" -%} - -%include "mpr121.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mpr121) \ No newline at end of file diff -Nru upm-1.6.0/src/mpr121/jsupm_mpr121.i upm-1.7.1/src/mpr121/jsupm_mpr121.i --- upm-1.6.0/src/mpr121/jsupm_mpr121.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpr121/jsupm_mpr121.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mpr121 -%include "../upm.i" - -%{ - #include "mpr121.hpp" -%} - -%include "mpr121.hpp" diff -Nru upm-1.6.0/src/mpr121/mpr121.i upm-1.7.1/src/mpr121/mpr121.i --- upm-1.6.0/src/mpr121/mpr121.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/mpr121/mpr121.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,17 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" + +JAVA_JNI_LOADLIBRARY(javaupm_mpr121) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "mpr121.hpp" +%} +%include "mpr121.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/mpr121/mpr121.json upm-1.7.1/src/mpr121/mpr121.json --- upm-1.6.0/src/mpr121/mpr121.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpr121/mpr121.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["tsk"], "Image": "mpr121.jpg", "Examples": { - "Java": ["MPR121Sample.java"], + "Java": ["MPR121_Example.java"], "Python": ["mpr121.py"], "Node.js": ["mpr121.js"], "C++": ["mpr121.cxx"], diff -Nru upm-1.6.0/src/mpr121/pyupm_mpr121.i upm-1.7.1/src/mpr121/pyupm_mpr121.i --- upm-1.6.0/src/mpr121/pyupm_mpr121.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpr121/pyupm_mpr121.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mpr121 -%include "../upm.i" - -%include "mpr121.hpp" -%{ - #include "mpr121.hpp" -%} diff -Nru upm-1.6.0/src/mpu9150/javaupm_mpu9150.i upm-1.7.1/src/mpu9150/javaupm_mpu9150.i --- upm-1.6.0/src/mpu9150/javaupm_mpu9150.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpu9150/javaupm_mpu9150.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -%module javaupm_mpu9150 -%include "../upm.i" -%include "typemaps.i" -%include "arrays_java.i" -%include "../java_buffer.i" -%include "std_vector.i" - -%template(FloatVector) std::vector; - -%apply int {mraa::Edge}; - -%{ -#include "mpu60x0.hpp" -#include "mpu9150.hpp" -%} -%include "mpu60x0.hpp" -%include "mpu9150.hpp" - -%define GETTER get_gpioIRQ() -%enddef - -JAVA_ADD_INSTALLISR_GPIO(upm::MPU60X0) - -JAVA_JNI_LOADLIBRARY(javaupm_mpu9150) diff -Nru upm-1.6.0/src/mpu9150/jsupm_mpu9150.i upm-1.7.1/src/mpu9150/jsupm_mpu9150.i --- upm-1.6.0/src/mpu9150/jsupm_mpu9150.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpu9150/jsupm_mpu9150.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -%module jsupm_mpu9150 -%include "../upm.i" -%include "cpointer.i" - -%pointer_functions(float, floatp); - -%{ - #include "mpu9150.hpp" -%} - -%include "ak8975.hpp" -%{ - #include "ak8975.hpp" -%} - -%include "mpu60x0.hpp" -%{ - #include "mpu60x0.hpp" -%} - -%include "mpu9150.hpp" -%{ - #include "mpu9150.hpp" -%} - -%include "mpu9250.hpp" -%{ - #include "mpu9250.hpp" -%} - diff -Nru upm-1.6.0/src/mpu9150/mpu9150.i upm-1.7.1/src/mpu9150/mpu9150.i --- upm-1.6.0/src/mpu9150/mpu9150.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/mpu9150/mpu9150.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,47 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "std_vector.i" +%include "arrays_java.i" +%include "../java_buffer.i" + +%template(FloatVector) std::vector; + +%apply int {mraa::Edge}; + +%define GETTER get_gpioIRQ() +%enddef + +JAVA_ADD_INSTALLISR_GPIO(upm::MPU60X0) + +JAVA_JNI_LOADLIBRARY(javaupm_mpu9150) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "std_vector.i" +%pointer_functions(float, floatp); +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "std_vector.i" +%pointer_functions(float, floatp); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ak8975.hpp" +#include "mpu60x0.hpp" +#include "mpu9150.hpp" +#include "mpu9250.hpp" +%} +%include "ak8975.hpp" +%include "mpu60x0.hpp" +%include "mpu9150.hpp" +%include "mpu9250.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/mpu9150/mpu9150.json upm-1.7.1/src/mpu9150/mpu9150.json --- upm-1.6.0/src/mpu9150/mpu9150.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpu9150/mpu9150.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,59 +1,59 @@ -{ - "Library": "mpu9150", - "Description": "InvenSense/Seeed MPU9150 accelerometer library", - "Sensor Class": { - "MPU9150": { - "Name": "InvenSense/Seeed MPU9150 accelerometer", - "Description": "This is the UPM Module for the InvenSense/Seeed MPU9150 accelerometer. The MPU-9150 is the world's first integrated 9-axis motion tracking device designed for the low power, low cost, and high performance requirements of consumer electronics equipment including smartphones, tablets and wearable sensors. MPU-9150 features three 16-bit ADC for digitizing the gyroscope outputs and three 16-bit ADCs for digitizing the accelerometer outputs and three 13-bit ADCs for digitizing the magnetometer outputs", - "Aliases": ["mpu9150", "Grove - IMU 9DOF v1.0"], - "Categories": ["accelerometer", "gyroscope", "compass"], - "Connections": ["i2c", "gpio"], - "Project Type": ["prototyping", "industrial", "commercial"], - "Manufacturers": ["InvenSense", "Seeed"], - "Image": "mpu9150.jpg", - "Examples": { - "Java": ["MPU9150Sample.java"], - "Python": ["mpu9150.py"], - "Node.js": ["mpu9150.js"], - "C++": ["mpu9150-ak8975.cxx", "mpu9150-mpu60x0.cxx", "mpu9150-mpu9250.cxx", "mpu9150.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "typ" : 5 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - }, - "Communication Speed": { - "unit": "kHz", - "typ" : 400 - }, - "Gyroscope Range": { - "unit": "°/sec", - "min": "-/+250", - "max": "-/+2000" - }, - "Accelerometer Range": { - "unit": "g", - "min": "-/+2", - "max": "-/+16" - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Might need Grove base shield"] - }, - "Arduino 101": { - "Notes": ["Might need Grove base shield"] - } - }, - "Urls": { - "Product Pages": ["http://wiki.seeedstudio.com/wiki/Grove_-_IMU_9DOF_v1.0"], - "Datasheets": ["http://wiki.seeedstudio.com/images/5/51/MPU-9150.pdf"] - } - } - } -} +{ + "Library": "mpu9150", + "Description": "InvenSense/Seeed MPU9150 accelerometer library", + "Sensor Class": { + "MPU9150": { + "Name": "InvenSense/Seeed MPU9150 accelerometer", + "Description": "This is the UPM Module for the InvenSense/Seeed MPU9150 accelerometer. The MPU-9150 is the world's first integrated 9-axis motion tracking device designed for the low power, low cost, and high performance requirements of consumer electronics equipment including smartphones, tablets and wearable sensors. MPU-9150 features three 16-bit ADC for digitizing the gyroscope outputs and three 16-bit ADCs for digitizing the accelerometer outputs and three 13-bit ADCs for digitizing the magnetometer outputs", + "Aliases": ["mpu9150", "Grove - IMU 9DOF v1.0"], + "Categories": ["accelerometer", "gyroscope", "compass"], + "Connections": ["i2c", "gpio"], + "Project Type": ["prototyping", "industrial", "commercial"], + "Manufacturers": ["InvenSense", "Seeed"], + "Image": "mpu9150.jpg", + "Examples": { + "Java": ["MPU9150_Example.java"], + "Python": ["mpu9150.py"], + "Node.js": ["mpu9150.js"], + "C++": ["mpu9150-ak8975.cxx", "mpu9150-mpu60x0.cxx", "mpu9150-mpu9250.cxx", "mpu9150.cxx"] + }, + "Specifications": { + "Vsource": { + "unit": "V", + "typ" : 5 + }, + "Operating Temperature": { + "unit": "°C", + "min": -40, + "max": 85 + }, + "Communication Speed": { + "unit": "kHz", + "typ" : 400 + }, + "Gyroscope Range": { + "unit": "°/sec", + "min": "-/+250", + "max": "-/+2000" + }, + "Accelerometer Range": { + "unit": "g", + "min": "-/+2", + "max": "-/+16" + } + }, + "Platforms": { + "Intel Edison": { + "Notes": ["Might need Grove base shield"] + }, + "Arduino 101": { + "Notes": ["Might need Grove base shield"] + } + }, + "Urls": { + "Product Pages": ["http://wiki.seeedstudio.com/wiki/Grove_-_IMU_9DOF_v1.0"], + "Datasheets": ["http://wiki.seeedstudio.com/images/5/51/MPU-9150.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/mpu9150/pyupm_mpu9150.i upm-1.7.1/src/mpu9150/pyupm_mpu9150.i --- upm-1.6.0/src/mpu9150/pyupm_mpu9150.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mpu9150/pyupm_mpu9150.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mpu9150 -%include "../upm.i" -%include "cpointer.i" - -%include "stdint.i" - -%pointer_functions(float, floatp); - -%include "ak8975.hpp" -%{ - #include "ak8975.hpp" -%} - -%include "mpu60x0.hpp" -%{ - #include "mpu60x0.hpp" -%} - -%include "mpu9150.hpp" -%{ - #include "mpu9150.hpp" -%} - -%include "mpu9250.hpp" -%{ - #include "mpu9250.hpp" -%} - diff -Nru upm-1.6.0/src/mq303a/javaupm_mq303a.i upm-1.7.1/src/mq303a/javaupm_mq303a.i --- upm-1.6.0/src/mq303a/javaupm_mq303a.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mq303a/javaupm_mq303a.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_mq303a -%include "../upm.i" - -%{ - #include "mq303a.hpp" -%} - -%include "mq303a.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_mq303a) \ No newline at end of file diff -Nru upm-1.6.0/src/mq303a/jsupm_mq303a.i upm-1.7.1/src/mq303a/jsupm_mq303a.i --- upm-1.6.0/src/mq303a/jsupm_mq303a.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mq303a/jsupm_mq303a.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_mq303a -%include "../upm.i" - -%{ - #include "mq303a.hpp" -%} - -%include "mq303a.hpp" diff -Nru upm-1.6.0/src/mq303a/mq303a.c upm-1.7.1/src/mq303a/mq303a.c --- upm-1.6.0/src/mq303a/mq303a.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mq303a/mq303a.c 2018-10-12 04:47:41.000000000 +0000 @@ -41,10 +41,8 @@ if (!dev) return NULL; - dev->aio_pin = pin; - dev->gpio_pin = heater_pin; - dev->aio = mraa_aio_init(dev->aio_pin); - dev->gpio = mraa_gpio_init(dev->gpio_pin); + dev->aio = mraa_aio_init(pin); + dev->gpio = mraa_gpio_init(heater_pin); if(mraa_gpio_dir(dev->gpio, MRAA_GPIO_OUT) != MRAA_SUCCESS) { diff -Nru upm-1.6.0/src/mq303a/mq303a.h upm-1.7.1/src/mq303a/mq303a.h --- upm-1.6.0/src/mq303a/mq303a.h 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mq303a/mq303a.h 2018-10-12 04:47:41.000000000 +0000 @@ -43,8 +43,6 @@ typedef struct _mq303a_context { mraa_gpio_context gpio; mraa_aio_context aio; - uint8_t gpio_pin; - uint8_t aio_pin; } *mq303a_context; /** diff -Nru upm-1.6.0/src/mq303a/mq303a.json upm-1.7.1/src/mq303a/mq303a.json --- upm-1.6.0/src/mq303a/mq303a.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mq303a/mq303a.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["tsk"], "Image": "mq303a.jpg", "Examples": { - "Java": ["MQ303ASample.java"], + "Java": ["MQ303A_Example.java"], "Python": ["mq303a.py"], "Node.js": ["mq303a.js"], "C++": ["mq303a.cxx"], diff -Nru upm-1.6.0/src/mq303a/pyupm_mq303a.i upm-1.7.1/src/mq303a/pyupm_mq303a.i --- upm-1.6.0/src/mq303a/pyupm_mq303a.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/mq303a/pyupm_mq303a.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_mq303a -%include "../upm.i" - -%include "mq303a.hpp" -%{ - #include "mq303a.hpp" -%} diff -Nru upm-1.6.0/src/ms5611/javaupm_ms5611.i upm-1.7.1/src/ms5611/javaupm_ms5611.i --- upm-1.6.0/src/ms5611/javaupm_ms5611.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ms5611/javaupm_ms5611.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -%module javaupm_ms5611 -%include "../upm.i" - -%import "../interfaces/javaupm_iTemperatureSensor.i" -%import "../interfaces/javaupm_iPressureSensor.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%{ - #include "ms5611.hpp" -%} - -%include "ms5611.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ms5611) diff -Nru upm-1.6.0/src/ms5611/jsupm_ms5611.i upm-1.7.1/src/ms5611/jsupm_ms5611.i --- upm-1.6.0/src/ms5611/jsupm_ms5611.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ms5611/jsupm_ms5611.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ms5611 -%include "../upm.i" - -%{ - #include "ms5611.hpp" -%} - -%include "ms5611.hpp" diff -Nru upm-1.6.0/src/ms5611/ms5611.i upm-1.7.1/src/ms5611/ms5611.i --- upm-1.6.0/src/ms5611/ms5611.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ms5611/ms5611.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%import "../interfaces/javaupm_iTemperatureSensor.i" +%import "../interfaces/javaupm_iPressureSensor.i" +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} + +JAVA_JNI_LOADLIBRARY(javaupm_ms5611) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ms5611.hpp" +%} +%include "ms5611.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ms5611/pyupm_ms5611.i upm-1.7.1/src/ms5611/pyupm_ms5611.i --- upm-1.6.0/src/ms5611/pyupm_ms5611.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ms5611/pyupm_ms5611.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module pyupm_ms5611 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%include "ms5611.hpp" -%{ - #include "ms5611.hpp" -%} diff -Nru upm-1.6.0/src/ms5803/javaupm_ms5803.i upm-1.7.1/src/ms5803/javaupm_ms5803.i --- upm-1.6.0/src/ms5803/javaupm_ms5803.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ms5803/javaupm_ms5803.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -%module javaupm_ms5803 -%include "../upm.i" -%include "typemaps.i" -%include "arrays_java.i" -%include "../java_buffer.i" -%include "std_string.i" - -%include "ms5803_defs.h" -%include "ms5803.hpp" -%{ - #include "ms5803.hpp" -%} - - -JAVA_JNI_LOADLIBRARY(javaupm_ms5803) diff -Nru upm-1.6.0/src/ms5803/jsupm_ms5803.i upm-1.7.1/src/ms5803/jsupm_ms5803.i --- upm-1.6.0/src/ms5803/jsupm_ms5803.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ms5803/jsupm_ms5803.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module jsupm_ms5803 -%include "../upm.i" -%include "cpointer.i" -%include "std_string.i" - -%pointer_functions(float, floatp); - -%include "ms5803_defs.h" -%include "ms5803.hpp" -%{ - #include "ms5803.hpp" -%} diff -Nru upm-1.6.0/src/ms5803/ms5803.i upm-1.7.1/src/ms5803/ms5803.i --- upm-1.6.0/src/ms5803/ms5803.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ms5803/ms5803.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,21 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i" +%include "../java_buffer.i" + +JAVA_JNI_LOADLIBRARY(javaupm_ms5803) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(float, floatp); + +%{ +#include "ms5803_defs.h" +#include "ms5803.hpp" +%} +%include "ms5803_defs.h" +%include "ms5803.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ms5803/pyupm_ms5803.i upm-1.7.1/src/ms5803/pyupm_ms5803.i --- upm-1.6.0/src/ms5803/pyupm_ms5803.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ms5803/pyupm_ms5803.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ms5803 -%include "../upm.i" -%include "cpointer.i" -%include "std_string.i" - -%include "stdint.i" - -%pointer_functions(float, floatp); - -%include "ms5803_defs.h" -%include "ms5803.hpp" -%{ - #include "ms5803.hpp" -%} diff -Nru upm-1.6.0/src/my9221/javaupm_my9221.i upm-1.7.1/src/my9221/javaupm_my9221.i --- upm-1.6.0/src/my9221/javaupm_my9221.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/my9221/javaupm_my9221.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -%module javaupm_my9221 -%include "../upm.i" - -%include "my9221.hpp" -%{ - #include "my9221.hpp" -%} - -%include "groveledbar.hpp" -%{ - #include "groveledbar.hpp" -%} - -%include "grovecircularled.hpp" -%{ - #include "grovecircularled.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_my9221) diff -Nru upm-1.6.0/src/my9221/jsupm_my9221.i upm-1.7.1/src/my9221/jsupm_my9221.i --- upm-1.6.0/src/my9221/jsupm_my9221.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/my9221/jsupm_my9221.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -%module jsupm_my9221 -%include "../upm.i" - -%include "my9221.hpp" -%{ - #include "my9221.hpp" -%} - -%include "groveledbar.hpp" -%{ - #include "groveledbar.hpp" -%} - -%include "grovecircularled.hpp" -%{ - #include "grovecircularled.hpp" -%} - diff -Nru upm-1.6.0/src/my9221/my9221.c upm-1.7.1/src/my9221/my9221.c --- upm-1.6.0/src/my9221/my9221.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/my9221/my9221.c 2018-10-12 04:47:41.000000000 +0000 @@ -95,19 +95,6 @@ mraa_gpio_dir(dev->gpioData, MRAA_GPIO_OUT); -#if defined(UPM_PLATFORM_LINUX) - // we warn if these fail, since it may not be possible to handle - // more than one instance - - if (mraa_gpio_use_mmaped(dev->gpioClk, 1)) - printf("%s: Warning: mmap of Clk pin failed, correct operation " - "may be affected.\n", __FUNCTION__); - - if (mraa_gpio_use_mmaped(dev->gpioData, 1)) - printf("%s: Warning: mmap of Data pin failed, correct operation " - "may be affected.\n", __FUNCTION__); -#endif // UPM_PLATFORM_LINUX - my9221_set_low_intensity_value(dev, 0x00); // full off my9221_set_high_intensity_value(dev, 0xff); // full bright diff -Nru upm-1.6.0/src/my9221/my9221.i upm-1.7.1/src/my9221/my9221.i --- upm-1.6.0/src/my9221/my9221.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/my9221/my9221.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_my9221) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "groveledbar.hpp" +#include "my9221.hpp" +#include "grovecircularled.hpp" +%} +%include "my9221.hpp" +%include "groveledbar.hpp" +%include "grovecircularled.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/my9221/my9221.json upm-1.7.1/src/my9221/my9221.json --- upm-1.6.0/src/my9221/my9221.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/my9221/my9221.json 2018-10-12 04:47:41.000000000 +0000 @@ -60,7 +60,7 @@ "Kits": ["eak"], "Image": "my9221.jpg", "Examples": { - "Java": ["GroveLEDBar.java"], + "Java": ["GroveLEDBar_Example.java"], "Python": ["groveledbar.py"], "Node.js": ["groveledbar.js"], "C++": ["my9221-groveledbar.cxx"] diff -Nru upm-1.6.0/src/my9221/pyupm_my9221.i upm-1.7.1/src/my9221/pyupm_my9221.i --- upm-1.6.0/src/my9221/pyupm_my9221.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/my9221/pyupm_my9221.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_my9221 -%include "../upm.i" - -%include "my9221.hpp" -%{ - #include "my9221.hpp" -%} - -%include "groveledbar.hpp" -%{ - #include "groveledbar.hpp" -%} - -%include "grovecircularled.hpp" -%{ - #include "grovecircularled.hpp" -%} diff -Nru upm-1.6.0/src/nlgpio16/javaupm_nlgpio16.i upm-1.7.1/src/nlgpio16/javaupm_nlgpio16.i --- upm-1.6.0/src/nlgpio16/javaupm_nlgpio16.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nlgpio16/javaupm_nlgpio16.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_nlgpio16 -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "nlgpio16.hpp" -%} - -%include "nlgpio16.hpp" -%array_class(char, charArray); - -JAVA_JNI_LOADLIBRARY(javaupm_nlgpio16) diff -Nru upm-1.6.0/src/nlgpio16/jsupm_nlgpio16.i upm-1.7.1/src/nlgpio16/jsupm_nlgpio16.i --- upm-1.6.0/src/nlgpio16/jsupm_nlgpio16.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nlgpio16/jsupm_nlgpio16.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module jsupm_nlgpio16 -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "nlgpio16.hpp" -%} - -%include "nlgpio16.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/nlgpio16/nlgpio16.i upm-1.7.1/src/nlgpio16/nlgpio16.i --- upm-1.6.0/src/nlgpio16/nlgpio16.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/nlgpio16/nlgpio16.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_nlgpio16) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "carrays.i" +%{ +#include "nlgpio16.hpp" +%} +%include "nlgpio16.hpp" +%array_class(char, charArray); +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/nlgpio16/pyupm_nlgpio16.i upm-1.7.1/src/nlgpio16/pyupm_nlgpio16.i --- upm-1.6.0/src/nlgpio16/pyupm_nlgpio16.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nlgpio16/pyupm_nlgpio16.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_nlgpio16 -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "nlgpio16.hpp" -%} -%include "nlgpio16.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/nmea_gps/CMakeLists.txt upm-1.7.1/src/nmea_gps/CMakeLists.txt --- upm-1.6.0/src/nmea_gps/CMakeLists.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nmea_gps/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -6,4 +6,4 @@ CPP_SRC nmea_gps.cxx FTI_SRC nmea_gps_fti.c CPP_WRAPS_C - REQUIRES mraa utilities-c) + REQUIRES mraa utilities-c ${CMAKE_THREAD_LIBS_INIT}) diff -Nru upm-1.6.0/src/nmea_gps/javaupm_nmea_gps.i upm-1.7.1/src/nmea_gps/javaupm_nmea_gps.i --- upm-1.6.0/src/nmea_gps/javaupm_nmea_gps.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nmea_gps/javaupm_nmea_gps.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_nmea_gps -%include "../upm.i" -%include "std_string.i" -%include "stdint.i" -%include "typemaps.i" - -%include "nmea_gps.hpp" -%{ - #include "nmea_gps.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_nmea_gps) diff -Nru upm-1.6.0/src/nmea_gps/jsupm_nmea_gps.i upm-1.7.1/src/nmea_gps/jsupm_nmea_gps.i --- upm-1.6.0/src/nmea_gps/jsupm_nmea_gps.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nmea_gps/jsupm_nmea_gps.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_nmea_gps -%include "../upm.i" -%include "std_string.i" - -%include "nmea_gps.hpp" -%{ - #include "nmea_gps.hpp" -%} - diff -Nru upm-1.6.0/src/nmea_gps/nmea_gps.c upm-1.7.1/src/nmea_gps/nmea_gps.c --- upm-1.6.0/src/nmea_gps/nmea_gps.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nmea_gps/nmea_gps.c 2018-10-12 04:47:41.000000000 +0000 @@ -67,6 +67,51 @@ return rv; } +nmea_gps_context nmea_gps_init_raw(const char* uart, unsigned int baudrate) +{ + // make sure MRAA is initialized + int mraa_rv; + if ((mraa_rv = mraa_init()) != MRAA_SUCCESS) + { + printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv); + return NULL; + } + + nmea_gps_context dev = + (nmea_gps_context)malloc(sizeof(struct _nmea_gps_context)); + + if (!dev) + return NULL; + + // zero out context + memset((void *)dev, 0, sizeof(struct _nmea_gps_context)); + + dev->uart = NULL; + dev->i2c = NULL; + dev->gpio_en = NULL; + + // initialize the MRAA contexts + + // uart, default should be 8N1 + if (!(dev->uart = mraa_uart_init_raw(uart))) + { + printf("%s: mraa_uart_init_raw() failed.\n", __FUNCTION__); + nmea_gps_close(dev); + return NULL; + } + + if (nmea_gps_set_baudrate(dev, baudrate)) + { + printf("%s: nmea_gps_set_baudrate() failed.\n", __FUNCTION__); + nmea_gps_close(dev); + return NULL; + } + + mraa_uart_set_flowcontrol(dev->uart, false, false); + + return dev; +} + // uart init nmea_gps_context nmea_gps_init(unsigned int uart, unsigned int baudrate, int enable_pin) @@ -87,7 +132,7 @@ // zero out context memset((void *)dev, 0, sizeof(struct _nmea_gps_context)); - + dev->uart = NULL; dev->i2c = NULL; dev->gpio_en = NULL; @@ -107,7 +152,7 @@ printf("%s: nmea_gps_set_baudrate() failed.\n", __FUNCTION__); nmea_gps_close(dev); return NULL; - } + } mraa_uart_set_flowcontrol(dev->uart, false, false); @@ -294,7 +339,7 @@ { printf("%s: mraa_uart_set_baudrate() failed.\n", __FUNCTION__); return UPM_ERROR_OPERATION_FAILED; - } + } return UPM_SUCCESS; } diff -Nru upm-1.6.0/src/nmea_gps/nmea_gps.cxx upm-1.7.1/src/nmea_gps/nmea_gps.cxx --- upm-1.6.0/src/nmea_gps/nmea_gps.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nmea_gps/nmea_gps.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -22,9 +22,15 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include +#include +#include #include +#include +#include #include +#include "upm_utilities.h" #include "nmea_gps.hpp" using namespace upm; @@ -32,7 +38,25 @@ NMEAGPS::NMEAGPS(unsigned int uart, unsigned int baudrate, int enable_pin) : - m_nmea_gps(nmea_gps_init(uart, baudrate, enable_pin)) + m_nmea_gps(nmea_gps_init(uart, baudrate, enable_pin)), + _running(false), + _maxQueueDepth(10), + _sentences_since_start(0), + _bytes_since_start(0), + _seconds_since_start(0.0) +{ + if (!m_nmea_gps) + throw std::runtime_error(string(__FUNCTION__) + + ": nmea_gps_init() failed"); +} + +NMEAGPS::NMEAGPS(const std::string& uart, unsigned int baudrate) : + m_nmea_gps(nmea_gps_init_raw(uart.c_str(), baudrate)), + _running(false), + _maxQueueDepth(10), + _sentences_since_start(0), + _bytes_since_start(0), + _seconds_since_start(0.0) { if (!m_nmea_gps) throw std::runtime_error(string(__FUNCTION__) @@ -40,7 +64,12 @@ } NMEAGPS::NMEAGPS(unsigned int bus, uint8_t addr) : - m_nmea_gps(nmea_gps_init_ublox_i2c(bus, addr)) + m_nmea_gps(nmea_gps_init_ublox_i2c(bus, addr)), + _running(false), + _maxQueueDepth(10), + _sentences_since_start(0), + _bytes_since_start(0), + _seconds_since_start(0.0) { if (!m_nmea_gps) throw std::runtime_error(string(__FUNCTION__) @@ -49,6 +78,9 @@ NMEAGPS::~NMEAGPS() { + _running = false; + if (_parser.joinable()) + _parser.join(); nmea_gps_close(m_nmea_gps); } @@ -62,19 +94,23 @@ throw std::runtime_error(string(__FUNCTION__) + ": nmea_gps_read() failed"); - return string(buffer, rv); + /* Keep track of bytes read */ + _bytes_since_start += rv; + return buffer; } -int NMEAGPS::writeStr(std::string buffer) +int NMEAGPS::writeStr(const std::string& buffer) { int rv; - if ((rv = nmea_gps_write(m_nmea_gps, (char*)buffer.data(), + /* The write takes a char*. This should be OK since it's known that the mraa + * write call does not change buffer */ + if ((rv = nmea_gps_write(m_nmea_gps, const_cast(buffer.c_str()), buffer.size())) < 0) throw std::runtime_error(string(__FUNCTION__) + ": nmea_gps_write() failed"); - return rv; + return rv; } void NMEAGPS::enable(bool enable) @@ -95,3 +131,495 @@ { return nmea_gps_data_available(m_nmea_gps, millis); } + +size_t NMEAGPS::getMaxQueueDepth() +{ + return _maxQueueDepth; +} + +size_t NMEAGPS::setMaxQueueDepth(size_t depth) +{ + /* 1 <= depth <= 1000 */ + if (depth > 1000) depth = 1000; + if (depth == 0) depth = 1; + + _maxQueueDepth = depth; + return _maxQueueDepth; +} + +/* Given a NMEA sentence, return a checksum which is calculated on + * all characters between the '$' and the '*' */ +static uint8_t checksum(const std::string& sentence) +{ + uint8_t chksum = 0; + std::string::const_iterator it = sentence.begin(); + /* Skip the '$' */ + if (*it == '$') ++it; + + /* Calculate the checksum on all characters */ + while ((*it != '*') && (it != sentence.end())) + chksum ^= *it++; + return chksum; +} + +/* Regex for matching NMEA GGA coordinates + * Unfortunately these sentences appear-non standard between the devices tested + * so it can be expected that these would need updating to match additional + * devices. + * GPGGA,164800.00,4532.52680,N,12257.59972,W,1,10,0.93,73.3,M,-21.3,M,,*5E + */ +static std::regex rex_gga(R"(^\$GPGGA,(\d+\.\d+),(\d+)(\d{2}\.\d+),([NS]),(\d+)(\d{2}.\d+),([WE]),(\d+),(\d+),(\d+\.\d+),(\d+\.\d+),M,([+-]?\d+\.\d+),M,([+-]?\d+\.\d+)?,?(\S+)?[*]([A-Z0-9]{2}))"); +void NMEAGPS::_parse_gpgga(const std::string& sentence) +{ + /* Parse the GGA message */ + std::smatch m; + if (!std::regex_search(sentence, m, rex_gga)) + return; + + gps_fix fix; + fix.valid = true; + fix.time_utc = m[1]; + int deg = std::stoi(m[2]); + fix.coordinates.latitude = (deg + std::stof(m[3])/60.0) * + (m[4] == "N" ? 1.0 : m[4] == "S" ? -1.0 : fix.valid = false ); + deg = std::stoi(m[5]); + fix.coordinates.longitude = (deg + std::stof(m[6])/60.0) * + (m[7] == "E" ? 1.0 : m[7] == "W" ? -1.0 : fix.valid = false ); + fix.quality = static_cast(std::stoi(m[8])); + fix.satellites = std::stoi(m[9]); + fix.hdop = std::stof(m[10]); + fix.altitude_meters = std::stof(m[11]); + fix.geoid_height_meters = std::stof(m[12]); + fix.age_seconds = m[13].str().empty() ? 0.0 : std::stof(m[13]); + fix.station_id = m[14]; + fix.chksum_match = std::stoi(m[15], nullptr, 16) == checksum(sentence); + fix.valid &= fix.chksum_match; + + /* Throw away oldest if full, push to queue */ + _mtx_fix.lock(); + if (_queue_fix.size() == _maxQueueDepth) + _queue_fix.pop(); + _queue_fix.push(fix); + _mtx_fix.unlock(); +} + +/* Regex for matching NMEA GSV satellite sentences + * Unfortunately these sentences appear-non standard between the devices tested + * so it can be expected that these would need updating to match additional + * devices. + * + * Example sentence: + * + * $GPGSV,3,3,12,28,75,028,20,30,55,116,28,48,37,194,41,51,35,159,32*7A + */ +static std::regex rex_gsv_hdr(R"(^\$GPGSV,(\d+),(\d+),(\d\d),)"); +static std::regex rex_gsv_sat(R"((\d{2}),(\d{2}),(\d{3}),(\d+)?,?)"); +static std::regex rex_gsv_ftr("[*]([A-Z0-9]{2})$"); +void NMEAGPS::_parse_gpgsv(const std::string& sentence) +{ + /* Parse the GSV header message */ + std::smatch mhdr; + std::smatch mftr; + /* No further parsing if this message doesn't match the header + * or footer or the checksum is bad */ + if (!std::regex_search(sentence, mhdr, rex_gsv_hdr) || + !std::regex_search(sentence, mftr, rex_gsv_ftr) || + (std::stoi(mftr[1], nullptr, 16) != checksum(sentence))) + return; + + size_t total_svs = std::stoi(mhdr[3]); + + /* Match each satellite */ + std::sregex_iterator next(sentence.begin(), sentence.end(), rex_gsv_sat); + std::sregex_iterator end; + while (next != end) + { + std::smatch satmatches = *next++; + + /* Add these satellites. Only keep a max total_svs satellites at any + * one time. The latest are the most current */ + satellite sat = { + satmatches[1].str(), + std::stoi(satmatches[2].str()), + std::stoi(satmatches[3].str()), + satmatches[4].str().empty() ? 0 : + std::stoi(satmatches[4].str()) + }; + + /* Add to the back of satmap, remove any matching prn */ + _mtx_satlist.lock(); + auto sit = _satlist.begin(); + while(sit != _satlist.end()) + { + /* Remove */ + if ((*sit).prn == sat.prn) + { + sit = _satlist.erase(sit); + break; + } + ++sit; + } + /* Add satellite to the end */ + _satlist.push_back(sat); + + /* If more sats exist than current sat count, remove them */ + while (_satlist.size() > total_svs) _satlist.pop_front(); + _mtx_satlist.unlock(); + } +} + +/* + * Regex for matching NMEA GLL coordinates + * Unfortunately these sentences appear-non standard between the devices tested + * so it can be expected that these would need updating to match additional + * devices. + * + * For example, the HJ GPS compass returned GLL sentences + * with a duplicate ,A,A at the end :( + * "$GPGLL,4532.55107,N,12257.68422,W,170004.20,A,A*74" + */ +static std::regex rex_gll(R"(^\$GPGLL,(\d+)(\d{2}\.\d+),([NS]),(\d+)(\d{2}.\d+),([WE]),(\d+\.\d+)(,A)?,A[*]([A-Z0-9]{2}))"); +void NMEAGPS::_parse_gpgll(const std::string& sentence) +{ + /* Parse the GLL message */ + std::smatch m; + if (!std::regex_search(sentence, m, rex_gll)) + return; + + gps_fix fix; + fix.valid = true; + fix.time_utc = m[7]; + int deg = std::stoi(m[1]); + fix.coordinates.latitude = (deg + std::stof(m[2])/60.0) * + (m[3] == "N" ? 1.0 : m[3] == "S" ? -1.0 : fix.valid = false ); + deg = std::stoi(m[4]); + fix.coordinates.longitude = (deg + std::stof(m[5])/60.0) * + (m[6] == "E" ? 1.0 : m[6] == "W" ? -1.0 : fix.valid = false ); + fix.chksum_match = std::stoi(m[9], nullptr, 16) == checksum(sentence); + fix.valid &= fix.chksum_match; + + /* Throw away oldest if full, push to queue */ + _mtx_fix.lock(); + if (_queue_fix.size() == _maxQueueDepth) _queue_fix.pop(); + _queue_fix.push(fix); + _mtx_fix.unlock(); +} + +/* + * Regex for matching NMEA TXT messages + * Grab-bag of messages coming from a GPS device. Can basically be any + * additional information that the manufacture wants to send out. + * + * For example, the ublox GPS compass writes out data about itself: + * $GPTXT,01,01,02,u-blox ag - www.u-blox.com*50 + * $GPTXT,01,01,02,HW UBX-G60xx 00040007 *52 + * $GPTXT,01,01,02,EXT CORE 7.03 (45970) Mar 17 2011 16:26:24*44 + * $GPTXT,01,01,02,ROM BASE 6.02 (36023) Oct 15 2009 16:52:08*58 + * $GPTXT,01,01,02,MOD LEA-6H-0*2D + * $GPTXT,01,01,02,ANTSUPERV=AC SD PDoS SR*20 + * $GPTXT,01,01,02,ANTSTATUS=OK*3B + */ +static std::regex rex_txt(R"(^\$GPTXT,(\d{2}),(\d{2}),(\d{2}),(.*)[*]([A-Z0-9]{2}))"); +void NMEAGPS::_parse_gptxt(const std::string& sentence) +{ + /* Parse the GLL message */ + std::smatch m; + if (!std::regex_search(sentence, m, rex_txt) || + (std::stoi(m[5], nullptr, 16) != checksum(sentence)) ) + return; + + /* Throw away oldest if full, push to queue */ + _mtx_txt.lock(); + if (_queue_txt.size() == _maxQueueDepth) _queue_txt.pop(); + _queue_txt.push({std::stoi(m[3]), m[4]}); + _mtx_txt.unlock(); +} + +void NMEAGPS::parseNMEASentence(const std::string& sentence) +{ + /* Needs to start with $GP... and be (at least 6 characters + * long to call a parser. Otherwise skip parsing and put into + * raw sentence queue for debug */ + size_t msgsz = sentence.size(); + if ((sentence.find("$GP") == 0) && + (msgsz >= 5) && (msgsz <=100)) + { + auto cit = nmea_2_parser.find(sentence.substr(1, 5)); + if (cit != nmea_2_parser.end()) + { + fp parser = cit->second; + /* Call the corresponding parser */ + (this->*parser)(sentence); + } + + /* Keep track of total number of sentences */ + _sentences_since_start++; + } + + /* Throw away oldest if full, push to raw sentence queue */ + _mtx_nmea_sentence.lock(); + if (_queue_nmea_sentence.size() == _maxQueueDepth) + _queue_nmea_sentence.pop(); + _queue_nmea_sentence.push(sentence); + _mtx_nmea_sentence.unlock(); +} + +void NMEAGPS::_parse_thread() +{ + /* NMEA 0183 max sentence length is 82 characters. There seems to be + * varying specs out there. Using 94 characters between the $GP and + * the checksum as a max length for a basic max length sanity check. + * $GP(94 chars max)*XX length = 100 characters total + */ + std::regex rex(R"((\$GP.{5,94}\*[a-fA-F0-9][a-fA-F0-9])\r\n)"); + while (_running) + { + /* While data is available, read from the GPS. A 5s + * timeout appears long, but UARTS can be slow with minimal + * data getting returned, possible slow UART speeds, and it's + * better to maximize the UART buffer. This currently + * assumes whole sentences are returned each read. + * TODO: Handle leftover uart data + */ + if (dataAvailable(5000)) + { + /* Read a block */ + std::string buf = readStr(4095); + + std::sregex_iterator next(buf.begin(), buf.end(), rex); + std::sregex_iterator end; + while (next != end) + { + std::smatch matches = *next++; + parseNMEASentence(matches[1].str()); + } + + /* Let this thread do other stuff */ + upm_delay_us(100); + } + } +} + +static double getTimeSinceEpoch_s() +{ + auto now = std::chrono::system_clock::now(); + auto now_s = std::chrono::time_point_cast(now); + auto epoch = now_s.time_since_epoch(); + auto value = std::chrono::duration_cast(epoch); + return value.count()/1000.0; +} + +void NMEAGPS::parseStart() +{ + /* Don't create multiple running threads */ + if (_running) return; + + /* Set running flag */ + _running = true; + + /* Reset total number of bytes/sentences parsed */ + _sentences_since_start = 0; + _bytes_since_start = 0; + + /* Reset the total number of seconds */ + _seconds_since_start = getTimeSinceEpoch_s(); + + /* Start the thread */ + _parser = std::thread(&NMEAGPS::_parse_thread, this); +} + +void NMEAGPS::parseStop() +{ + /* Only stop if running */ + if (!_running) return; + + _running = false; + if (_parser.joinable()) + _parser.join(); + + /* Zero number of bytes/sentences parsed */ + _sentences_since_start = 0; +} + +gps_fix NMEAGPS::getFix() +{ + gps_fix x; + _mtx_fix.lock(); + if (!_queue_fix.empty()) + { + /* Get a copy of the structure, pop an element */ + x = _queue_fix.front(); + _queue_fix.pop(); + } + _mtx_fix.unlock(); + return x; +} + +std::string NMEAGPS::getRawSentence() +{ + std::string ret; + _mtx_nmea_sentence.lock(); + if (!_queue_nmea_sentence.empty()) + { + /* Get a copy of the sentence, pop an element */ + ret = _queue_nmea_sentence.front(); + _queue_nmea_sentence.pop(); + } + _mtx_nmea_sentence.unlock(); + return ret; +} + +nmeatxt NMEAGPS::getTxtMessage() +{ + nmeatxt ret; + _mtx_txt.lock(); + if (!_queue_txt.empty()) + { + /* Get a copy of the sentence, pop an element */ + ret = _queue_txt.front(); + _queue_txt.pop(); + } + _mtx_txt.unlock(); + return ret; +} + +size_t NMEAGPS::fixQueueSize() +{ + _mtx_fix.lock(); + size_t x =_queue_fix.size(); + _mtx_fix.unlock(); + return x; +} + +size_t NMEAGPS::rawSentenceQueueSize() +{ + _mtx_nmea_sentence.lock(); + size_t x =_queue_nmea_sentence.size(); + _mtx_nmea_sentence.unlock(); + return x; +} + +size_t NMEAGPS::txtMessageQueueSize() +{ + _mtx_txt.lock(); + size_t x =_queue_txt.size(); + _mtx_txt.unlock(); + return x; +} + +std::string gps_fix::__str__() +{ + std::ostringstream oss; + oss << "valid:" << (valid ? "T" : "F") << ", "; + if (time_utc.size() < 6) oss << "UNKNOWN UTC, "; + else + oss << time_utc.substr(0, 2) << ":" << time_utc.substr(2,2) << ":" + << time_utc.substr(4,2) << time_utc.substr(6) << " UTC, "; + oss << coordinates.latitude << ", " << coordinates.longitude << ", " + << "quality: " << static_cast(quality) << ", " + << "sats: " << static_cast(satellites) << ", " + << "hdop: " << hdop << ", " + << "alt (m): " << altitude_meters << ", " + << "geoid_ht (m): " << geoid_height_meters << ", " + << "age (s): " << age_seconds << ", " + << "dgps sid: " << station_id << ", " + << "chksum match: " << (chksum_match ? "T" : "F"); + return oss.str(); +} + +std::vector NMEAGPS::satellites() +{ + /* Create a new set for now */ + _mtx_satlist.lock(); + std::vector sats(_satlist.begin(), _satlist.end()); + _mtx_satlist.unlock(); + + return sats; +} + +std::string satellite::__str__() +{ + std::ostringstream oss; + oss << "id:" << std::setw(3) << prn << ", " + << "elevation (d):" << std::setw(3) << elevation_deg + << ", " << "azimuth (d):" << std::setw(3) << azimuth_deg + << ", " << "snr:" << std::setw(3) << snr; + return oss.str(); +} + +std::string nmeatxt::__str__() +{ + /* Return an emty string */ + if (!severity && message.empty()) return ""; + + std::ostringstream oss; + oss << "["; + switch (severity) + { + case 0: + oss << "ERROR"; + break; + case 1: + oss << "WARNING"; + break; + case 2: + oss << "NOTICE"; + break; + case 7: + oss << "USER"; + break; + default: + oss << "UNKNOWN"; + break; + } + oss << "] " << message; + + return oss.str(); +} + +double NMEAGPS::sentencesPerSecond() +{ + double now_s = getTimeSinceEpoch_s(); + return _sentences_since_start/(now_s - _seconds_since_start); +} + +double NMEAGPS::bytesPerSecond() +{ + double now_s = getTimeSinceEpoch_s(); + return _bytes_since_start/(now_s - _seconds_since_start); +} + +std::string NMEAGPS::__str__() +{ + std::ostringstream oss; + std::vector sats = satellites(); + size_t msgs = txtMessageQueueSize(); + size_t qsz = getMaxQueueDepth(); + oss << "NMEA GPS Instance" << std::endl + << " Parsing: " << (isRunning() ? "T" : "F") << std::endl + << " NMEA sentences/second: " << std::fixed << std::setprecision(2) + << sentencesPerSecond() + << " (" << bytesPerSecond() << " bps)" << std::endl + << " Available satellites: " << sats.size() << std::endl; + for(auto sat : sats) + oss << " " << sat.__str__() << std::endl; + oss << " Queues" << std::endl + << " Raw sentence Q: " << std::setw(4) << rawSentenceQueueSize() << "/" << qsz << std::endl + << " GPS fix Q: " << std::setw(4) << fixQueueSize() << "/" << qsz << std::endl + << " Messages Q: " << std::setw(4) << msgs << "/" << qsz; + if (msgs > 0) + { + oss << std::endl << " Messages" << std::endl; + for (size_t i = 0; i < msgs; i++) + oss << " " << getTxtMessage().__str__() << std::endl; + } + + return oss.str(); +} + +std::string coord_DD::__str__() +{ + std::ostringstream oss; + oss << latitude << ", " << longitude; + return oss.str(); +} diff -Nru upm-1.6.0/src/nmea_gps/nmea_gps.h upm-1.7.1/src/nmea_gps/nmea_gps.h --- upm-1.6.0/src/nmea_gps/nmea_gps.h 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nmea_gps/nmea_gps.h 2018-10-12 04:47:41.000000000 +0000 @@ -44,7 +44,7 @@ * An example using I2C. * @include nmea_gps_i2c.c */ - + /** * Device context */ @@ -53,11 +53,11 @@ mraa_gpio_context gpio_en; mraa_i2c_context i2c; } *nmea_gps_context; - + /** * NMEA_GPS Initializer for generic UART operation * - * @param uart Specify which uart to use. + * @param uart Specify which mraa uart index to use. * @param baudrate Specify the baudrate to use. The device defaults * to 9600 baud. * @param enable_pin Specify the GPIO pin to use for the enable pin, @@ -68,6 +68,16 @@ int enable_pin); /** + * NMEA_GPS Initializer for generic UART operation + * + * @param uart Specify which uart (fs device path) to use. + * @param baudrate Specify the baudrate to use. The device defaults + * to 9600 baud. + * @return an initialized device context on success, NULL on error. + */ + nmea_gps_context nmea_gps_init_raw(const char* uart, unsigned int baudrate); + + /** * NMEA_GPS Initializer for UBLOX I2C operation * * @param bus Specify which the I2C bus to use. diff -Nru upm-1.6.0/src/nmea_gps/nmea_gps.hpp upm-1.7.1/src/nmea_gps/nmea_gps.hpp --- upm-1.6.0/src/nmea_gps/nmea_gps.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nmea_gps/nmea_gps.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -23,133 +23,431 @@ */ #pragma once -#include +#include #include - -#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include "nmea_gps.h" namespace upm { - /** - * @brief Generic NMEA GPS Serial Device Library - * @defgroup nmea_gps libupm-nmea_gps - * @ingroup uart gpio gps - */ - - /** - * @library nmea_gps - * @sensor nmea_gps - * @comname Generic Serial Interface for GPS NMEA Devices - * @type gps - * @man dfrobot seeed - * @con uart gpio - * @altname VK2828u7 ublox LEA-6H - * - * @brief API for the NMEA GPS Module - * - * This driver was tested with a number of GPS devices that emit - * NMEA data via a serial interface of some sort (typically a UART). - * - * The I2C capablity was tested with a UBLOX LEA-6H based GPS shield - * from DFRobot. Currently, the I2C capability is only supported - * for UBLOX devices (or compatibles) that conform to the - * specifications outlined in the u-blox6 Receiver Description - * Protocol Specification, Chapter 4, DDC Port. - * - * An example using the UART. - * @snippet nmea_gps.cxx Interesting - * An example using I2C. - * @snippet nmea_gps-i2c.cxx Interesting - */ - - class NMEAGPS { - public: - /** - * NMEAGPS object constructor for a UART - * - * @param uart Specify which uart to use. - * @param baudrate Specify the baudrate to use. The device defaults - * to 9600 baud. - * @param enable_pin Specify the GPIO pin to use for the enable pin, - * -1 to not use an enable pin. + * @brief Generic NMEA GPS Serial Device Library + * @defgroup nmea_gps libupm-nmea_gps + * @ingroup uart gpio gps */ - NMEAGPS(unsigned int uart, unsigned int baudrate, - int enable_pin); /** - * NMEAGPS object constructor for a UBLOX I2C interface + * @file nmea_gps.hpp + * @library nmea_gps + * @sensor nmea_gps + * @comname Generic Serial Interface for GPS NMEA Devices + * @type gps + * @man dfrobot seeed + * @con uart gpio + * @altname VK2828u7 ublox LEA-6H * - * @param bus Specify which the I2C bus to use. - * @param addr Specify the I2C address to use. For UBLOX devices, - * this typically defaults to 0x42. - */ - NMEAGPS(unsigned int bus, uint8_t addr); - - /** - * NMEAGPS object destructor - */ - ~NMEAGPS(); - - /** - * Read character data from the device. + * @brief API for the NMEA GPS Module * - * @param size The maximum number of characters to read. - * @return string containing the data read. - */ - std::string readStr(size_t size); - - /** - * Write character data to the device. This is only valid for a - * UART device. + * This driver was tested with a number of GPS devices that emit + * NMEA data via a serial interface of some sort (typically a UART). * - * @param buffer The string containing the data to write. - * @return The number of bytes written. - */ - int writeStr(std::string buffer); - - /** - * Enable or disable the device. When disabled, the device enters a - * low power mode and does not emit NMEA data. It will still - * maintain location data however. + * The I2C capablity was tested with a UBLOX LEA-6H based GPS shield + * from DFRobot. Currently, the I2C capability is only supported + * for UBLOX devices (or compatibles) that conform to the + * specifications outlined in the u-blox6 Receiver Description + * Protocol Specification, Chapter 4, DDC Port. * - * @param enable true to enable the device, false otherwise. + * An example using the UART. + * @snippet nmea_gps.cxx Interesting + * An example using I2C. + * @snippet nmea_gps-i2c.cxx Interesting */ - void enable(bool enable); + class NMEAGPS; - /** - * Set the baudrate of the device. By default, the constructor - * will set the baudrate to 9600. This is only valid for UART - * devices. - * - * @param baudrate The baud rate to set for the device. - */ - void setBaudrate(unsigned int baudrate); + /** Coordinates for lat/long as decimal degrees (DD) */ + struct coord_DD { + /** Latitude in decimal degrees */ + double latitude = 0.0; + /** Longitude in decimal degrees */ + double longitude = 0.0; + /** + * Provide a string representation of this structure. + * @return String representing coordinates + */ + std::string __str__(); + }; + + /** Satellite structure definition */ + struct satellite { + /** PRN pseudo-random-noise value which identifies a satellite */ + std::string prn; + /** Satellite elevation angle in degrees */ + int elevation_deg; + /** Satellite azimuth angle in degrees */ + int azimuth_deg; + /** Satellite signal-to-noise ratio */ + int snr; + /** Default constructor */ + satellite():satellite("", 0, 0, 0){} + /** + * Create a satellite from arguments constructor + * @param sprn Target PRN string + * @param elevation Target elevation angle in degrees + * @param azimuth Target azimuth angle in degrees + * @param snr Target signal to noise ratio (usually in dB, + * unfortunately non-standard) + */ + satellite(const std::string& sprn, int elevation, int azimuth, int snr): + prn(sprn), elevation_deg(elevation), azimuth_deg(azimuth), snr(snr) {} + /** + * Provide a string representation of this structure. + * @return String representing a satellite + */ + std::string __str__(); + }; + + /** Text structure definition */ + struct nmeatxt { + /** Message severity */ + int severity; + /** Message text */ + std::string message; + /** Default constructor */ + nmeatxt():nmeatxt(0, "") {} + /** + * Create a nmeatxt from arguments constructor + * @param severity Message severity + * @param message Target message + */ + nmeatxt(int severity, const std::string& message): + severity(severity), message(message){} + /** + * Provide a string representation of this structure. + * @return String representing a nmeatxt + */ + std::string __str__(); + }; + + /** GPS fix quality values */ + enum class gps_fix_quality { + /** No fix available or invalid */ + no_fix = 0, + /** Fix - single point */ + fix_sp, + /** Fix - differential point */ + fix_dp, + /** Fix - pulse per second */ + fix_pps, + /** Fix - real time kinematic */ + fix_rtk, + /** Fix - float real time kinematic */ + fix_frtk, + /** Fix - dead reckoning */ + fix_dr, + /** Fix - manual input */ + fix_manual, + /** Fix - simulation mode */ + fix_simulation + }; - /** - * Determine whether there is data available to be read. In the - * case of a UART, this function will wait up to "millis" - * milliseconds for data to become available. In the case of an I2C - * device, the millis argument is ignored and the function will - * return immediately, indicating whether data is available. - * - * @param millis The number of milliseconds to wait for data to - * become available. - * @return true if data is available to be read, false otherwise. + /** GPS fix definition. A GPS fix structure should only be used if + * valid == true */ - bool dataAvailable(unsigned int millis); - - protected: - // nmeaGPS device context - nmea_gps_context m_nmea_gps; - - private: - /* Disable implicit copy and assignment operators */ - NMEAGPS(const NMEAGPS&) = delete; - NMEAGPS &operator=(const NMEAGPS&) = delete; - }; + struct gps_fix { + /** Fix coordinates */ + coord_DD coordinates; + /** UTC time string as HHMMSS.mS */ + std::string time_utc = std::string(""); + /** GPS fix signal quality */ + gps_fix_quality quality = gps_fix_quality::no_fix; + /** Number of satellites in use */ + uint8_t satellites = 0; + /** Horizontal dilution of precision, unitless, lower is better */ + float hdop = 0.0; + /** Altitude above mean sea level in meters */ + float altitude_meters = 0.0; + /** Difference between the WGS-84 earth ellipsoid and mean-sea-level */ + float geoid_height_meters = 0.0; + /** Time in seconds since last differential GPS fix */ + float age_seconds = 0.0; + /** Differential GPS station ID */ + std::string station_id = std::string(""); + /** True if this gps_fix structure is valid to use */ + bool valid = false; + /** True if the checksum matched, valid is set to false on mismatch */ + bool chksum_match = false; + /** + * Provide a string representation of this structure. + * @return String representing a GPS Fix + */ + std::string __str__(); + }; + + class NMEAGPS { + public: + + /** + * NMEAGPS object constructor for a UART + * + * @param uart Specify which mraa uart index to use. + * @param baudrate Specify the baudrate to use. The device defaults + * to 9600 baud. + * @param enable_pin Specify the GPIO pin to use for the enable pin, + * -1 to not use an enable pin. + */ + NMEAGPS(unsigned int uart, unsigned int baudrate, + int enable_pin); + + /** + * NMEAGPS object constructor for a UART + * + * @param uart Specify which uart to use (fs device path) + * @param baudrate Specify the baudrate to use. The device defaults + * to 9600 baud. + */ + NMEAGPS(const std::string& uart, unsigned int baudrate); + + /** + * NMEAGPS object constructor for a UBLOX I2C interface + * + * @param bus Specify which the I2C bus to use. + * @param addr Specify the I2C address to use. For UBLOX devices, + * this typically defaults to 0x42. + */ + NMEAGPS(unsigned int bus, uint8_t addr); + + /** + * NMEAGPS object destructor + */ + ~NMEAGPS(); + + /** + * Read character data from the device. + * + * @param size The maximum number of characters to read. + * @return string containing the data read. + */ + std::string readStr(size_t size); + + /** + * Write character data to the device. This is only valid for a + * UART device. + * + * @param buffer The string containing the data to write. + * @return The number of bytes written. + */ + int writeStr(const std::string& buffer); + + /** + * Enable or disable the device. When disabled, the device enters a + * low power mode and does not emit NMEA data. It will still + * maintain location data however. + * + * @param enable true to enable the device, false otherwise. + */ + void enable(bool enable); + + /** + * Set the baudrate of the device. By default, the constructor + * will set the baudrate to 9600. This is only valid for UART + * devices. + * + * @param baudrate The baud rate to set for the device. + */ + void setBaudrate(unsigned int baudrate); + + /** + * Determine whether there is data available to be read. In the + * case of a UART, this function will wait up to "millis" + * milliseconds for data to become available. In the case of an I2C + * device, the millis argument is ignored and the function will + * return immediately, indicating whether data is available. + * + * @param millis The number of milliseconds to wait for data to + * become available. + * @return true if data is available to be read, false otherwise. + */ + bool dataAvailable(unsigned int millis); + + /** + * Return the current maximum queue depth. + * @return Maximum queue depth + */ + size_t getMaxQueueDepth(); + + /** + * Set the current maximum queue depth. + * @param depth New target queue depth + * 1 <= depth <= 1000 + * @return Actual maximum queue depth + */ + size_t setMaxQueueDepth(size_t depth); + + /** + * Start a NMEA parsing thread for reading/parsing NMEA sentences. The + * thread calls the readStr method, parsing NMEA sentences as they are + * encountered. Each sentence type is pushed into a corresponding queue + * of size + */ + void parseStart(); + + /** + * Stop a running NMEA parsing thread + */ + void parseStop(); + + /** + * Is the parsing thread currently running? + * @return True if parsing + */ + bool isRunning() {return _running;} + + /** + * Pop and return a GPS fix structure from the GPS fix queue. + * A GPS fix should only be used if valid is true. + * @return GPS fix structure + */ + gps_fix getFix(); + + /** + * Pop and return a raw NMEA sentence from the NMEA sentence queue. + * If the queue contains no elements, an empty string is returned + * @return NMEA raw sentence + */ + std::string getRawSentence(); + + /** + * Pop and return a message from the message queue (GPTXT sentences) + * If the queue contains no elements, an empty string is returned + * @return NMEA text message + */ + nmeatxt getTxtMessage(); + + /** + * Get the number of elements in the GPS fix queue. + * @return Number of fixes in the GPS fix queue + */ + size_t fixQueueSize(); + + /** + * Get the number of elements in the NMEA raw sentence queue. + * @return Number of sentences in the raw NMEA sentence queue + */ + size_t rawSentenceQueueSize(); + + /** + * Get the number of messages in the NMEA message queue. + * @return Number of messages in the message queue + */ + size_t txtMessageQueueSize(); + + /** + * Parse NMEA sentences. + * Raw sentence is placed into sentence queue. Additional structures are + * parsed depending on sentence type + * @param sentence NMEA raw sentence ($...\r\n) inclusive + */ + void parseNMEASentence(const std::string& sentence); + + /** + * Return a vector of the current satellites + * @return Current satellites + */ + std::vector satellites(); + + /** + * Get the number of sentences parsed per second + * @return Sentences parsed per second + */ + double sentencesPerSecond(); + + /** + * Get the throughput of the device. This number shows a rough + * data-rate as well as provides a bit of debug since it will show + * bps even if sentences are not getting parsed correctly. + + * @return Total bytes read from the device/second (bps) + */ + double bytesPerSecond(); + + /** + * Provide a string representation of this class + * @return String representing this instance + */ + std::string __str__(); + protected: + /** nmeaGPS device context */ + nmea_gps_context m_nmea_gps; + + private: + /** Disable implicit copy and assignment operators */ + NMEAGPS(const NMEAGPS&) = delete; + NMEAGPS &operator=(const NMEAGPS&) = delete; + + /** Handle reading/parsing NMEA data */ + std::thread _parser; + + /** Method runs in a spawned thread for parsing NMEA sentences */ + void _parse_thread(); + + /** Helper for thread syncronization */ + std::atomic _running; + + /** Parse GPGGA sentences, place in GPS fix queue */ + void _parse_gpgga(const std::string& string); + /** Parse GPGSV sentences, place in satellite collection */ + void _parse_gpgsv(const std::string& string); + /** Parse GPGLL sentences, place in satellite collection */ + void _parse_gpgll(const std::string& string); + /** Parse GPTXT sentences, place in text collection */ + void _parse_gptxt(const std::string& string); + + /** Provide function pointer typedef for handling NMEA chunks */ + using fp = void (NMEAGPS::*)(const std::string &); + /** Map of NMEA type to parser method */ + const std::map nmea_2_parser = + { + {"GPGGA", &NMEAGPS::_parse_gpgga}, + {"GPGSV", &NMEAGPS::_parse_gpgsv}, + {"GPGLL", &NMEAGPS::_parse_gpgll}, + {"GPTXT", &NMEAGPS::_parse_gptxt}, + }; + + /** Raw NMEA sentence fix queue */ + std::queue _queue_nmea_sentence; + std::mutex _mtx_nmea_sentence; + + /** GPS fix queue */ + std::queue _queue_fix; + std::mutex _mtx_fix; + + /** Message queue */ + std::queue _queue_txt; + std::mutex _mtx_txt; + + /** Specify a queue size for parsed objects */ + std::atomic _maxQueueDepth; + + /** Count # of parsed sentences each time thread is started */ + std::atomic _sentences_since_start; + + /** Count # oharacters read each time thread is started */ + std::atomic _bytes_since_start; + + /** Count # of parsed sentences each time thread is started */ + std::atomic _seconds_since_start; + + /** Set of current satellites */ + std::list _satlist; + std::mutex _mtx_satlist; + }; } - - diff -Nru upm-1.6.0/src/nmea_gps/nmea_gps.i upm-1.7.1/src/nmea_gps/nmea_gps.i --- upm-1.6.0/src/nmea_gps/nmea_gps.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/nmea_gps/nmea_gps.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,28 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_nmea_gps) +#endif +/* END Java syntax */ + +/* BEGIN Python syntax ------------------------------------------------------- */ +#ifdef SWIGPYTHON +/* Attach pythons __str__ method to a similar method in C++ */ +%feature("python:slot", "tp_str", functype="reprfunc") upm::gps_fix::__str__; +%feature("python:slot", "tp_str", functype="reprfunc") upm::satellite::__str__; +%feature("python:slot", "tp_str", functype="reprfunc") upm::nmeatxt::__str__; +%feature("python:slot", "tp_str", functype="reprfunc") upm::NMEAGPS::__str__; +%feature("python:slot", "tp_str", functype="reprfunc") upm::coord_DD::__str__; +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "std_vector.i" + +%{ +#include "nmea_gps.hpp" +%} +%template(satellitevec) std::vector; +%include "nmea_gps.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/nmea_gps/pyupm_nmea_gps.i upm-1.7.1/src/nmea_gps/pyupm_nmea_gps.i --- upm-1.6.0/src/nmea_gps/pyupm_nmea_gps.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nmea_gps/pyupm_nmea_gps.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_nmea_gps -%include "../upm.i" -%include "std_string.i" - -%include "nmea_gps.hpp" -%{ - #include "nmea_gps.hpp" -%} - diff -Nru upm-1.6.0/src/nrf24l01/javaupm_nrf24l01.i upm-1.7.1/src/nrf24l01/javaupm_nrf24l01.i --- upm-1.6.0/src/nrf24l01/javaupm_nrf24l01.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nrf24l01/javaupm_nrf24l01.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -%include "../upm.i" - -#ifdef ANDROID - %module javaupm_nrf24l01 -#else - %module(directors="1") javaupm_nrf24l01 - %feature("director") Callback; - SWIG_DIRECTOR_OWNED(Callback) -#endif - - -%include "arrays_java.i"; -%apply signed char[] {uint8_t *}; - -%include "Callback.hpp" -%{ - #include "nrf24l01.hpp" -%} - -%include "nrf24l01.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_nrf24l01) diff -Nru upm-1.6.0/src/nrf24l01/jsupm_nrf24l01.i upm-1.7.1/src/nrf24l01/jsupm_nrf24l01.i --- upm-1.6.0/src/nrf24l01/jsupm_nrf24l01.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nrf24l01/jsupm_nrf24l01.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_nrf24l01 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%{ - #include "nrf24l01.hpp" -%} - -%include "nrf24l01.hpp" diff -Nru upm-1.6.0/src/nrf24l01/nrf24l01.i upm-1.7.1/src/nrf24l01/nrf24l01.i --- upm-1.6.0/src/nrf24l01/nrf24l01.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/nrf24l01/nrf24l01.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,35 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +#ifndef ANDROID +%module(directors="1") javaupm_nrf24l01 +%feature("director") Callback; +SWIG_DIRECTOR_OWNED(Callback) +#endif +%include "arrays_java.i"; +%apply signed char[] {uint8_t *}; + +JAVA_JNI_LOADLIBRARY(javaupm_nrf24l01) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint8_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_uint8_t.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "nrf24l01.hpp" +%} +%include "Callback.hpp" +%include "nrf24l01.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/nrf24l01/nrf24l01.json upm-1.7.1/src/nrf24l01/nrf24l01.json --- upm-1.6.0/src/nrf24l01/nrf24l01.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nrf24l01/nrf24l01.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Nordic Semiconductor", "SparkFun"], "Image": "nrf24l01.jpg", "Examples": { - "Java": ["NRF24L01_receiverSample.java", "NRF24L01_transmitterSample.java"], + "Java": ["NRF24L01_receiver_Example.java", "NRF24L01_transmitter_Example.java"], "C++": ["nrf24l01-broadcast.cxx", "nrf24l01-receiver.cxx", "nrf24l01-transmitter.cxx"] }, "Specifications": { diff -Nru upm-1.6.0/src/nrf24l01/pyupm_nrf24l01.i upm-1.7.1/src/nrf24l01/pyupm_nrf24l01.i --- upm-1.6.0/src/nrf24l01/pyupm_nrf24l01.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nrf24l01/pyupm_nrf24l01.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_nrf24l01 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%include "nrf24l01.hpp" -%{ - #include "nrf24l01.hpp" -%} diff -Nru upm-1.6.0/src/nrf8001/CMakeLists.txt upm-1.7.1/src/nrf8001/CMakeLists.txt --- upm-1.6.0/src/nrf8001/CMakeLists.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nrf8001/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -1,5 +1,8 @@ -set (libname "nrf8001") -set (libdescription "Bluetooth Low Energy (BLE) Module") -set (module_src hal_aci_tl.cpp aci_setup.cpp aci_queue.cpp acilib.cpp lib_aci.cpp ${libname}.cxx) -set (module_hpp hal_aci_tl.h aci_setup.h aci_queue.h acilib.h lib_aci.h ${libname}.hpp) -upm_module_init(mraa) +upm_mixed_module_init (NAME nrf8001 + DESCRIPTION "Bluetooth Low Energy (BLE) Module" + CPP_HDR aci.h aci_cmds.h aci_evts.h acilib_defs.h acilib.h acilib_if.h + acilib_types.h aci_protocol_defines.h aci_queue.h aci_setup.h + boards.h dtm.h hal_aci_tl.h hal_platform.h lib_aci.h uart_over_ble.h + CPP_SRC acilib.cpp aci_queue.cpp aci_setup.cpp hal_aci_tl.cpp lib_aci.cpp + nrf8001.cxx + REQUIRES mraa) diff -Nru upm-1.6.0/src/nrf8001/hal_aci_tl.h upm-1.7.1/src/nrf8001/hal_aci_tl.h --- upm-1.6.0/src/nrf8001/hal_aci_tl.h 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nrf8001/hal_aci_tl.h 2018-10-12 04:47:41.000000000 +0000 @@ -121,7 +121,7 @@ * that was pending. * @return Points to data buffer for received data. Length byte in buffer is 0 if no data received. */ -hal_aci_data_t * hal_aci_tl_poll_get(void); +//hal_aci_data_t * hal_aci_tl_poll_get(void); /** @brief Get an ACI event from the event queue * @details diff -Nru upm-1.6.0/src/nrf8001/javaupm_nrf8001.i upm-1.7.1/src/nrf8001/javaupm_nrf8001.i --- upm-1.6.0/src/nrf8001/javaupm_nrf8001.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nrf8001/javaupm_nrf8001.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_nrf8001 -%include "../upm.i" - -%{ - #include "nrf8001.hpp" -%} - -%include "nrf8001.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_nrf8001) diff -Nru upm-1.6.0/src/nrf8001/jsupm_nrf8001.i upm-1.7.1/src/nrf8001/jsupm_nrf8001.i --- upm-1.6.0/src/nrf8001/jsupm_nrf8001.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nrf8001/jsupm_nrf8001.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_nrf8001 -%include "../upm.i" - -%{ - #include "nrf8001.hpp" -%} - -%include "nrf8001.hpp" diff -Nru upm-1.6.0/src/nrf8001/pyupm_nrf8001.i upm-1.7.1/src/nrf8001/pyupm_nrf8001.i --- upm-1.6.0/src/nrf8001/pyupm_nrf8001.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nrf8001/pyupm_nrf8001.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_nrf8001 -%include "../upm.i" - -%include "nrf8001.hpp" -%{ - #include "nrf8001.hpp" -%} diff -Nru upm-1.6.0/src/nunchuck/javaupm_nunchuck.i upm-1.7.1/src/nunchuck/javaupm_nunchuck.i --- upm-1.6.0/src/nunchuck/javaupm_nunchuck.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nunchuck/javaupm_nunchuck.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_nunchuck -%include "../upm.i" -%include "../java_buffer.i" - -%{ - #include "nunchuck.hpp" -%} - -%include "nunchuck.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_nunchuck) \ No newline at end of file diff -Nru upm-1.6.0/src/nunchuck/jsupm_nunchuck.i upm-1.7.1/src/nunchuck/jsupm_nunchuck.i --- upm-1.6.0/src/nunchuck/jsupm_nunchuck.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nunchuck/jsupm_nunchuck.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_nunchuck -%include "../upm.i" - -%{ - #include "nunchuck.hpp" -%} - -%include "nunchuck.hpp" diff -Nru upm-1.6.0/src/nunchuck/nunchuck.i upm-1.7.1/src/nunchuck/nunchuck.i --- upm-1.6.0/src/nunchuck/nunchuck.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/nunchuck/nunchuck.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../java_buffer.i" + +JAVA_JNI_LOADLIBRARY(javaupm_nunchuck) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "nunchuck.hpp" +%} +%include "nunchuck.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/nunchuck/nunchuck.json upm-1.7.1/src/nunchuck/nunchuck.json --- upm-1.6.0/src/nunchuck/nunchuck.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nunchuck/nunchuck.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["robok"], "Image": "nunchuck.jpg", "Examples": { - "Java": ["NUNCHUCKSample.java"], + "Java": ["NUNCHUCK_Example.java"], "Python": ["nunchuck.py"], "Node.js": ["nunchuck.js"], "C++": ["nunchuck.cxx"], diff -Nru upm-1.6.0/src/nunchuck/pyupm_nunchuck.i upm-1.7.1/src/nunchuck/pyupm_nunchuck.i --- upm-1.6.0/src/nunchuck/pyupm_nunchuck.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/nunchuck/pyupm_nunchuck.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_nunchuck -%include "../upm.i" - -%include "nunchuck.hpp" -%{ - #include "nunchuck.hpp" -%} diff -Nru upm-1.6.0/src/o2/javaupm_o2.i upm-1.7.1/src/o2/javaupm_o2.i --- upm-1.6.0/src/o2/javaupm_o2.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/o2/javaupm_o2.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_o2 -%include "../upm.i" - -%{ - #include "o2.hpp" -%} - -%include "o2.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_o2) \ No newline at end of file diff -Nru upm-1.6.0/src/o2/jsupm_o2.i upm-1.7.1/src/o2/jsupm_o2.i --- upm-1.6.0/src/o2/jsupm_o2.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/o2/jsupm_o2.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_o2 -%include "../upm.i" - -%{ - #include "o2.hpp" -%} - -%include "o2.hpp" diff -Nru upm-1.6.0/src/o2/o2.json upm-1.7.1/src/o2/o2.json --- upm-1.6.0/src/o2/o2.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/o2/o2.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,39 +1,39 @@ -{ - "Library": "o2", - "Description": "O2 Oxygen Gas Sensor Library", - "Sensor Class": - { - "O2": - { - "Name": "Oxygen (O2) Concentration Sensor", - "Description": "The Grove O2 Oxygen Gas sensor measures the oxygen concentration in the air.", - "Aliases": ["o2"], - "Categories": ["gas", "oxygen"], - "Connections": ["analog"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "o2.jpg", - "Examples": - { - "Java": ["O2Example.java"], - "Python": ["o2.py"], - "Node.js": ["o2.js"], - "C++": ["o2.cxx"], - "C": ["o2.c"] - }, - "Specifications": - { - "Measurement Range": {"unit": "% Vol", "low": 0, "high": 25}, - "Sensitivity": {"unit": "mA (in air)", "low": 0.1, "high": 0.3}, - "Operating Temperature": {"unit": "degC", "low": -20, "high": 50} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/grove-gas-sensoro2-p-1541.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-O2/"], - "Schematics": ["https://github.com/SeeedDocument/Grove_Gas_Sensor_O2/raw/master/resources/Schematics_O2.zip"] - } - } - } -} +{ + "Library": "o2", + "Description": "O2 Oxygen Gas Sensor Library", + "Sensor Class": + { + "O2": + { + "Name": "Oxygen (O2) Concentration Sensor", + "Description": "The Grove O2 Oxygen Gas sensor measures the oxygen concentration in the air.", + "Aliases": ["o2"], + "Categories": ["gas", "oxygen"], + "Connections": ["analog"], + "Project Type": ["environmental", "prototyping"], + "Manufacturers": ["seeed"], + "Kits": [], + "Image": "o2.jpg", + "Examples": + { + "Java": ["O2_Example.java"], + "Python": ["o2.py"], + "Node.js": ["o2.js"], + "C++": ["o2.cxx"], + "C": ["o2.c"] + }, + "Specifications": + { + "Measurement Range": {"unit": "% Vol", "low": 0, "high": 25}, + "Sensitivity": {"unit": "mA (in air)", "low": 0.1, "high": 0.3}, + "Operating Temperature": {"unit": "degC", "low": -20, "high": 50} + }, + "Urls" : + { + "Product Pages": ["https://www.seeedstudio.com/grove-gas-sensoro2-p-1541.html"], + "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-O2/"], + "Schematics": ["https://github.com/SeeedDocument/Grove_Gas_Sensor_O2/raw/master/resources/Schematics_O2.zip"] + } + } + } +} diff -Nru upm-1.6.0/src/o2/pyupm_o2.i upm-1.7.1/src/o2/pyupm_o2.i --- upm-1.6.0/src/o2/pyupm_o2.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/o2/pyupm_o2.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_o2 -%include "../upm.i" - -%include "o2.hpp" -%{ - #include "o2.hpp" -%} diff -Nru upm-1.6.0/src/otp538u/javaupm_otp538u.i upm-1.7.1/src/otp538u/javaupm_otp538u.i --- upm-1.6.0/src/otp538u/javaupm_otp538u.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/otp538u/javaupm_otp538u.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_otp538u -%include "../upm.i" - -%{ - #include "otp538u.hpp" -%} - -%include "otp538u.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_otp538u) \ No newline at end of file diff -Nru upm-1.6.0/src/otp538u/jsupm_otp538u.i upm-1.7.1/src/otp538u/jsupm_otp538u.i --- upm-1.6.0/src/otp538u/jsupm_otp538u.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/otp538u/jsupm_otp538u.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_otp538u -%include "../upm.i" - -%{ - #include "otp538u.hpp" -%} - -%include "otp538u.hpp" diff -Nru upm-1.6.0/src/otp538u/otp538u.json upm-1.7.1/src/otp538u/otp538u.json --- upm-1.6.0/src/otp538u/otp538u.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/otp538u/otp538u.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["hak"], "Image": "otp538u.jpg", "Examples": { - "Java": ["OTP538USample.java"], + "Java": ["OTP538U_Example.java"], "Python": ["otp538u.py"], "Node.js": ["otp538u.js"], "C++": ["otp538u.cxx"], diff -Nru upm-1.6.0/src/otp538u/pyupm_otp538u.i upm-1.7.1/src/otp538u/pyupm_otp538u.i --- upm-1.6.0/src/otp538u/pyupm_otp538u.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/otp538u/pyupm_otp538u.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_otp538u -%include "../upm.i" - -%include "otp538u.hpp" -%{ - #include "otp538u.hpp" -%} diff -Nru upm-1.6.0/src/ozw/javaupm_ozw.i upm-1.7.1/src/ozw/javaupm_ozw.i --- upm-1.6.0/src/ozw/javaupm_ozw.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ozw/javaupm_ozw.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -%module javaupm_ozw -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%apply unsigned char *OUTPUT { uint8_t *val }; - -%include "ozw.hpp" -%{ - #include "ozw.hpp" -%} - -%include "ozwinterface.hpp" -%{ - #include "ozwinterface.hpp" -%} - -%include "ozwdump.hpp" -%{ - #include "ozwdump.hpp" -%} - -%include "aeotecss6.hpp" -%{ - #include "aeotecss6.hpp" -%} - -%include "aeotecsdg2.hpp" -%{ - #include "aeotecsdg2.hpp" -%} - -%include "aeotecdw2e.hpp" -%{ - #include "aeotecdw2e.hpp" -%} - -%include "aeotecdsb09104.hpp" -%{ - #include "aeotecdsb09104.hpp" -%} - -%include "tzemt400.hpp" -%{ - #include "tzemt400.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_ozw) diff -Nru upm-1.6.0/src/ozw/jsupm_ozw.i upm-1.7.1/src/ozw/jsupm_ozw.i --- upm-1.6.0/src/ozw/jsupm_ozw.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ozw/jsupm_ozw.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -%module jsupm_ozw -%include "../upm.i" -%include "cpointer.i" -%include "stdint.i" - -%pointer_functions(float, floatp); - -%include "ozw.hpp" -%{ - #include "ozw.hpp" -%} - -%include "ozwinterface.hpp" -%{ - #include "ozwinterface.hpp" -%} - -%include "ozwdump.hpp" -%{ - #include "ozwdump.hpp" -%} - -%include "aeotecss6.hpp" -%{ - #include "aeotecss6.hpp" -%} - -%include "aeotecsdg2.hpp" -%{ - #include "aeotecsdg2.hpp" -%} - -%include "aeotecdw2e.hpp" -%{ - #include "aeotecdw2e.hpp" -%} - -%include "aeotecdsb09104.hpp" -%{ - #include "aeotecdsb09104.hpp" -%} - -%include "tzemt400.hpp" -%{ - #include "tzemt400.hpp" -%} diff -Nru upm-1.6.0/src/ozw/ozw.i upm-1.7.1/src/ozw/ozw.i --- upm-1.6.0/src/ozw/ozw.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ozw/ozw.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,34 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" +%apply unsigned char *OUTPUT { uint8_t *val }; + +JAVA_JNI_LOADLIBRARY(javaupm_ozw) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(float, floatp); + +%{ +#include "ozwinterface.hpp" +#include "ozw.hpp" +#include "aeotecdsb09104.hpp" +#include "aeotecdw2e.hpp" +#include "aeotecsdg2.hpp" +#include "aeotecss6.hpp" +#include "ozwdump.hpp" +#include "tzemt400.hpp" +%} +%include "ozwinterface.hpp" +%include "ozw.hpp" +%include "aeotecdsb09104.hpp" +%include "aeotecdw2e.hpp" +%include "aeotecsdg2.hpp" +%include "aeotecss6.hpp" +%include "ozwdump.hpp" +%include "tzemt400.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ozw/pyupm_ozw.i upm-1.7.1/src/ozw/pyupm_ozw.i --- upm-1.6.0/src/ozw/pyupm_ozw.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ozw/pyupm_ozw.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ozw -%include "../upm.i" -%include "cpointer.i" - -%include "stdint.i" - -%pointer_functions(float, floatp); - -%include "ozw.hpp" -%{ - #include "ozw.hpp" -%} - -%include "ozwinterface.hpp" -%{ - #include "ozwinterface.hpp" -%} - -%include "ozwdump.hpp" -%{ - #include "ozwdump.hpp" -%} - -%include "aeotecss6.hpp" -%{ - #include "aeotecss6.hpp" -%} - -%include "aeotecsdg2.hpp" -%{ - #include "aeotecsdg2.hpp" -%} - -%include "aeotecdw2e.hpp" -%{ - #include "aeotecdw2e.hpp" -%} - -%include "aeotecdsb09104.hpp" -%{ - #include "aeotecdsb09104.hpp" -%} - -%include "tzemt400.hpp" -%{ - #include "tzemt400.hpp" -%} diff -Nru upm-1.6.0/src/p9813/javaupm_p9813.i upm-1.7.1/src/p9813/javaupm_p9813.i --- upm-1.6.0/src/p9813/javaupm_p9813.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/p9813/javaupm_p9813.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_p9813 - -%include "../upm.i" -%include "typemaps.i" - -%{ - #include "p9813.hpp" -%} -%include "p9813.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_p9813) diff -Nru upm-1.6.0/src/p9813/jsupm_p9813.i upm-1.7.1/src/p9813/jsupm_p9813.i --- upm-1.6.0/src/p9813/jsupm_p9813.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/p9813/jsupm_p9813.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -%module jsupm_p9813 -%include "../upm.i" - -%include "p9813.hpp" -%{ - #include "p9813.hpp" -%} diff -Nru upm-1.6.0/src/p9813/p9813.i upm-1.7.1/src/p9813/p9813.i --- upm-1.6.0/src/p9813/p9813.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/p9813/p9813.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_p9813) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "p9813.hpp" +%} +%include "p9813.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/p9813/p9813.json upm-1.7.1/src/p9813/p9813.json --- upm-1.6.0/src/p9813/p9813.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/p9813/p9813.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Adafruit", "Shiji Lighting"], "Image": "p9813.jpg", "Examples": { - "Java": ["P9813Sample.java"], + "Java": ["P9813_Example.java"], "Python": ["p9813.py"], "Node.js": ["p9813.js"], "C++": ["p9813.cxx"] diff -Nru upm-1.6.0/src/p9813/pyupm_p9813.i upm-1.7.1/src/p9813/pyupm_p9813.i --- upm-1.6.0/src/p9813/pyupm_p9813.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/p9813/pyupm_p9813.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_p9813 -%include "../upm.i" - -%include "p9813.hpp" -%{ - #include "p9813.hpp" -%} diff -Nru upm-1.6.0/src/pca9685/javaupm_pca9685.i upm-1.7.1/src/pca9685/javaupm_pca9685.i --- upm-1.6.0/src/pca9685/javaupm_pca9685.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pca9685/javaupm_pca9685.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_pca9685 -%include "../upm.i" -%include "cpointer.i" - -%{ - #include "pca9685.hpp" -%} - -%include "pca9685.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_pca9685) \ No newline at end of file diff -Nru upm-1.6.0/src/pca9685/jsupm_pca9685.i upm-1.7.1/src/pca9685/jsupm_pca9685.i --- upm-1.6.0/src/pca9685/jsupm_pca9685.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pca9685/jsupm_pca9685.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_pca9685 -%include "../upm.i" -%include "cpointer.i" - -%{ - #include "pca9685.hpp" -%} - -%include "pca9685.hpp" diff -Nru upm-1.6.0/src/pca9685/pca9685.i upm-1.7.1/src/pca9685/pca9685.i --- upm-1.6.0/src/pca9685/pca9685.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/pca9685/pca9685.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_pca9685) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "pca9685.hpp" +%} +%include "pca9685.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/pca9685/pyupm_pca9685.i upm-1.7.1/src/pca9685/pyupm_pca9685.i --- upm-1.6.0/src/pca9685/pyupm_pca9685.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pca9685/pyupm_pca9685.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_pca9685 -%include "../upm.i" - -%include "pca9685.hpp" -%{ - #include "pca9685.hpp" -%} diff -Nru upm-1.6.0/src/pn532/javaupm_pn532.i upm-1.7.1/src/pn532/javaupm_pn532.i --- upm-1.6.0/src/pn532/javaupm_pn532.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pn532/javaupm_pn532.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -%module javaupm_pn532 -%include "../upm.i" -%include "typemaps.i" -%include "arrays_java.i" - -%apply signed char[] {uint8_t *}; -%apply unsigned char *INOUT {uint8_t *responseLength}; -%apply unsigned char *OUTPUT {uint8_t *uidLength}; - -%ignore i2cContext; - -%{ - #include "pn532.hpp" -%} - -%include "pn532.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_pn532) \ No newline at end of file diff -Nru upm-1.6.0/src/pn532/jsupm_pn532.i upm-1.7.1/src/pn532/jsupm_pn532.i --- upm-1.6.0/src/pn532/jsupm_pn532.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pn532/jsupm_pn532.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_pn532 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%{ - #include "pn532.hpp" -%} - -%include "pn532.hpp" diff -Nru upm-1.6.0/src/pn532/pn532.i upm-1.7.1/src/pn532/pn532.i --- upm-1.6.0/src/pn532/pn532.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/pn532/pn532.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,32 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i" +%ignore i2cContext; +%apply signed char[] {uint8_t *}; +%apply unsigned char *OUTPUT {uint8_t *uidLength}; +%apply unsigned char *INOUT {uint8_t *responseLength}; + +JAVA_JNI_LOADLIBRARY(javaupm_pn532) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint8_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_uint8_t.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "pn532.hpp" +%} +%include "pn532.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/pn532/pyupm_pn532.i upm-1.7.1/src/pn532/pyupm_pn532.i --- upm-1.6.0/src/pn532/pyupm_pn532.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pn532/pyupm_pn532.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_pn532 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%include "pn532.hpp" -%{ - #include "pn532.hpp" -%} diff -Nru upm-1.6.0/src/ppd42ns/javaupm_ppd42ns.i upm-1.7.1/src/ppd42ns/javaupm_ppd42ns.i --- upm-1.6.0/src/ppd42ns/javaupm_ppd42ns.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ppd42ns/javaupm_ppd42ns.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_ppd42ns -%include "../upm.i" - -%include "ppd42ns_data.h" -%include "ppd42ns.hpp" -%{ - #include "ppd42ns.hpp" -%} - - -JAVA_JNI_LOADLIBRARY(javaupm_ppd42ns) diff -Nru upm-1.6.0/src/ppd42ns/jsupm_ppd42ns.i upm-1.7.1/src/ppd42ns/jsupm_ppd42ns.i --- upm-1.6.0/src/ppd42ns/jsupm_ppd42ns.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ppd42ns/jsupm_ppd42ns.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_ppd42ns -%include "../upm.i" - -%include "ppd42ns_data.h" -%include "ppd42ns.hpp" -%{ - #include "ppd42ns.hpp" -%} - diff -Nru upm-1.6.0/src/ppd42ns/ppd42ns.c upm-1.7.1/src/ppd42ns/ppd42ns.c --- upm-1.6.0/src/ppd42ns/ppd42ns.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ppd42ns/ppd42ns.c 2018-10-12 04:47:41.000000000 +0000 @@ -99,7 +99,7 @@ unsigned int low_pulse_occupancy = 0; - upm_clock_init(&max_loop_time); + max_loop_time = upm_clock_init(); do { low_pulse_occupancy += ppd42ns_pulse_in(dev, 0); @@ -132,11 +132,10 @@ assert(dev != NULL); // we run for no more than 1 second at a time - upm_clock_t max_time; upm_clock_t pulse_time; uint32_t total_pulse_time = 0; - upm_clock_init(&max_time); + upm_clock_t max_time = upm_clock_init(); bool pin_level; bool is_timing = false; @@ -146,7 +145,7 @@ if (!is_timing && pin_level == high_low_value) { // level is desired level, but not currently timing - upm_clock_init(&pulse_time); + pulse_time = upm_clock_init(); is_timing = true; } else if (is_timing && pin_level != high_low_value) diff -Nru upm-1.6.0/src/ppd42ns/ppd42ns.i upm-1.7.1/src/ppd42ns/ppd42ns.i --- upm-1.6.0/src/ppd42ns/ppd42ns.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ppd42ns/ppd42ns.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,15 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_ppd42ns) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ppd42ns.hpp" +%} +%include "ppd42ns_data.h" +%include "ppd42ns.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ppd42ns/ppd42ns.json upm-1.7.1/src/ppd42ns/ppd42ns.json --- upm-1.6.0/src/ppd42ns/ppd42ns.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ppd42ns/ppd42ns.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["eak"], "Image": "ppd42ns.jpg", "Examples": { - "Java": ["PPD42NSSample.java"], + "Java": ["PPD42NS_Example.java"], "Python": ["ppd42ns.py"], "Node.js": ["ppd42ns.js"], "C++": ["ppd42ns.cxx"], diff -Nru upm-1.6.0/src/ppd42ns/pyupm_ppd42ns.i upm-1.7.1/src/ppd42ns/pyupm_ppd42ns.i --- upm-1.6.0/src/ppd42ns/pyupm_ppd42ns.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ppd42ns/pyupm_ppd42ns.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ppd42ns -%include "../upm.i" - -%include "ppd42ns_data.h" -%include "ppd42ns.hpp" -%{ - #include "ppd42ns.hpp" -%} diff -Nru upm-1.6.0/src/pulsensor/javaupm_pulsensor.i upm-1.7.1/src/pulsensor/javaupm_pulsensor.i --- upm-1.6.0/src/pulsensor/javaupm_pulsensor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pulsensor/javaupm_pulsensor.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#ifdef ANDROID - %module javaupm_pulsensor -#else - %module(directors="1") javaupm_pulsensor -#endif - -%include "../upm.i" -%include "arrays_java.i" - -#ifndef ANDROID - %feature("director") Callback; - SWIG_DIRECTOR_OWNED(Callback) -#endif - -%ignore sample_thread; -%ignore pin_ctx; -%ignore do_sample; -%ignore callback; - -%include "Callback.hpp" -%{ - #include "pulsensor.hpp" -%} - -%include "pulsensor.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_pulsensor) diff -Nru upm-1.6.0/src/pulsensor/jsupm_pulsensor.i upm-1.7.1/src/pulsensor/jsupm_pulsensor.i --- upm-1.6.0/src/pulsensor/jsupm_pulsensor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pulsensor/jsupm_pulsensor.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_pulsensor -%include "../upm.i" - -%{ - #include "pulsensor.hpp" -%} - -%include "pulsensor.hpp" diff -Nru upm-1.6.0/src/pulsensor/pulsensor.i upm-1.7.1/src/pulsensor/pulsensor.i --- upm-1.6.0/src/pulsensor/pulsensor.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/pulsensor/pulsensor.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,27 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +#ifndef ANDROID +%module(directors="1") javaupm_pulsensor +%feature("director") Callback; +SWIG_DIRECTOR_OWNED(Callback) +#endif +%include "arrays_java.i" + +%ignore sample_thread; +%ignore pin_ctx; +%ignore do_sample; +%ignore callback; + +JAVA_JNI_LOADLIBRARY(javaupm_pulsensor) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "pulsensor.hpp" +%} +%include "pulsensor.hpp" +%include "Callback.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/pulsensor/pulsensor.json upm-1.7.1/src/pulsensor/pulsensor.json --- upm-1.6.0/src/pulsensor/pulsensor.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pulsensor/pulsensor.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Adafruit"], "Image": "pulsensor.jpg", "Examples": { - "Java": ["PulsensorSample.java"], + "Java": ["Pulsensor_Example.java"], "C++": ["pulsensor.cxx"] }, "Specifications": { diff -Nru upm-1.6.0/src/pulsensor/pyupm_pulsensor.i upm-1.7.1/src/pulsensor/pyupm_pulsensor.i --- upm-1.6.0/src/pulsensor/pyupm_pulsensor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/pulsensor/pyupm_pulsensor.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_pulsensor -%include "../upm.i" - -%include "stdint.i" - -%include "pulsensor.hpp" -%{ - #include "pulsensor.hpp" -%} diff -Nru upm-1.6.0/src/relay/javaupm_relay.i upm-1.7.1/src/relay/javaupm_relay.i --- upm-1.6.0/src/relay/javaupm_relay.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/relay/javaupm_relay.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_relay -%include "../upm.i" - -%{ - #include "relay.hpp" -%} - -%include "relay.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_relay) diff -Nru upm-1.6.0/src/relay/jsupm_relay.i upm-1.7.1/src/relay/jsupm_relay.i --- upm-1.6.0/src/relay/jsupm_relay.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/relay/jsupm_relay.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_relay -%include "../upm.i" - -%{ - #include "relay.hpp" -%} - -%include "relay.hpp" diff -Nru upm-1.6.0/src/relay/pyupm_relay.i upm-1.7.1/src/relay/pyupm_relay.i --- upm-1.6.0/src/relay/pyupm_relay.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/relay/pyupm_relay.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_relay -%include "../upm.i" - -%include "relay.hpp" -%{ - #include "relay.hpp" -%} diff -Nru upm-1.6.0/src/relay/relay.json upm-1.7.1/src/relay/relay.json --- upm-1.6.0/src/relay/relay.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/relay/relay.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["gsk", "eak", "hak"], "Image": "relay.jpg", "Examples": { - "Java": ["RelaySample.java"], + "Java": ["Relay_Example.java"], "Python": ["relay.py"], "Node.js": ["relay.js"], "C++": ["relay.cxx"] diff -Nru upm-1.6.0/src/rf22/javaupm_rf22.i upm-1.7.1/src/rf22/javaupm_rf22.i --- upm-1.6.0/src/rf22/javaupm_rf22.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rf22/javaupm_rf22.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#ifdef ANDROID - %module javaupm_rf22 -#else - %module(directors="1") javaupm_rf22 -#endif - -%include "../upm.i" -%include "arrays_java.i" -%include "typemaps.i" - -%apply uint8_t *INOUT { uint8_t* len }; -%apply signed char[] {uint8_t*}; - -%{ - #include "rf22.hpp" -%} - -%include "rf22.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_rf22) diff -Nru upm-1.6.0/src/rf22/jsupm_rf22.i upm-1.7.1/src/rf22/jsupm_rf22.i --- upm-1.6.0/src/rf22/jsupm_rf22.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rf22/jsupm_rf22.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_rf22 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%{ - #include "rf22.hpp" -%} - -%include "rf22.hpp" diff -Nru upm-1.6.0/src/rf22/pyupm_rf22.i upm-1.7.1/src/rf22/pyupm_rf22.i --- upm-1.6.0/src/rf22/pyupm_rf22.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rf22/pyupm_rf22.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_rf22 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%include "rf22.hpp" -%{ - #include "rf22.hpp" -%} diff -Nru upm-1.6.0/src/rf22/rf22.hpp upm-1.7.1/src/rf22/rf22.hpp --- upm-1.6.0/src/rf22/rf22.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rf22/rf22.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -430,8 +430,8 @@ * * @image html rf22.jpg *
RF22 Sensor image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet rf22-server.cxx Interesting * @snippet rf22-client.cxx Interesting diff -Nru upm-1.6.0/src/rf22/rf22.i upm-1.7.1/src/rf22/rf22.i --- upm-1.6.0/src/rf22/rf22.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/rf22/rf22.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,34 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +#ifndef ANDROID +%module(directors="1") javaupm_rf22 +#endif + +%include "arrays_java.i" +%apply uint8_t *INOUT { uint8_t* len }; +%apply signed char[] {uint8_t*}; + +JAVA_JNI_LOADLIBRARY(javaupm_rf22) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint8_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_uint8_t.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "rf22.hpp" +%} +%include "rf22.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/rfr359f/javaupm_rfr359f.i upm-1.7.1/src/rfr359f/javaupm_rfr359f.i --- upm-1.6.0/src/rfr359f/javaupm_rfr359f.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rfr359f/javaupm_rfr359f.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_rfr359f -%include "../upm.i" - -%{ - #include "rfr359f.hpp" -%} - -%include "rfr359f.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_rfr359f) \ No newline at end of file diff -Nru upm-1.6.0/src/rfr359f/jsupm_rfr359f.i upm-1.7.1/src/rfr359f/jsupm_rfr359f.i --- upm-1.6.0/src/rfr359f/jsupm_rfr359f.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rfr359f/jsupm_rfr359f.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_rfr359f -%include "../upm.i" - -%{ - #include "rfr359f.hpp" -%} - -%include "rfr359f.hpp" diff -Nru upm-1.6.0/src/rfr359f/pyupm_rfr359f.i upm-1.7.1/src/rfr359f/pyupm_rfr359f.i --- upm-1.6.0/src/rfr359f/pyupm_rfr359f.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rfr359f/pyupm_rfr359f.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_rfr359f -%include "../upm.i" - -%include "rfr359f.hpp" -%{ - #include "rfr359f.hpp" -%} diff -Nru upm-1.6.0/src/rfr359f/rfr359f.json upm-1.7.1/src/rfr359f/rfr359f.json --- upm-1.6.0/src/rfr359f/rfr359f.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rfr359f/rfr359f.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["robot", "tsk"], "Image": "rfr359f.jpg", "Examples": { - "Java": ["RFR359FSample.java"], + "Java": ["RFR359F_Example.java"], "Python": ["rfr359f.py"], "Node.js": ["rfr359f.js"], "C++": ["rfr359f.cxx"] diff -Nru upm-1.6.0/src/rgbringcoder/javaupm_rgbringcoder.i upm-1.7.1/src/rgbringcoder/javaupm_rgbringcoder.i --- upm-1.6.0/src/rgbringcoder/javaupm_rgbringcoder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rgbringcoder/javaupm_rgbringcoder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_rgbringcoder -%include "../upm.i" - -%{ - #include "rgbringcoder.hpp" -%} - -%include "rgbringcoder.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_rgbringcoder) \ No newline at end of file diff -Nru upm-1.6.0/src/rgbringcoder/jsupm_rgbringcoder.i upm-1.7.1/src/rgbringcoder/jsupm_rgbringcoder.i --- upm-1.6.0/src/rgbringcoder/jsupm_rgbringcoder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rgbringcoder/jsupm_rgbringcoder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_rgbringcoder -%include "../upm.i" -%include "stdint.i" - -%{ - #include "rgbringcoder.hpp" -%} - -%include "rgbringcoder.hpp" diff -Nru upm-1.6.0/src/rgbringcoder/pyupm_rgbringcoder.i upm-1.7.1/src/rgbringcoder/pyupm_rgbringcoder.i --- upm-1.6.0/src/rgbringcoder/pyupm_rgbringcoder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rgbringcoder/pyupm_rgbringcoder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_rgbringcoder -%include "../upm.i" - -%include "rgbringcoder.hpp" -%{ - #include "rgbringcoder.hpp" -%} diff -Nru upm-1.6.0/src/rgbringcoder/rgbringcoder.i upm-1.7.1/src/rgbringcoder/rgbringcoder.i --- upm-1.6.0/src/rgbringcoder/rgbringcoder.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/rgbringcoder/rgbringcoder.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_rgbringcoder) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "rgbringcoder.hpp" +%} +%include "rgbringcoder.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/rhusb/javaupm_rhusb.i upm-1.7.1/src/rhusb/javaupm_rhusb.i --- upm-1.6.0/src/rhusb/javaupm_rhusb.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rhusb/javaupm_rhusb.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module javaupm_rhusb -%include "../upm.i" -%include "typemaps.i" -%include "cpointer.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%{ - #include "rhusb.hpp" -%} - -%include "rhusb.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_rhusb) diff -Nru upm-1.6.0/src/rhusb/jsupm_rhusb.i upm-1.7.1/src/rhusb/jsupm_rhusb.i --- upm-1.6.0/src/rhusb/jsupm_rhusb.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rhusb/jsupm_rhusb.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_rhusb -%include "../upm.i" -%include "stdint.i" - -%include "rhusb.hpp" -%{ - #include "rhusb.hpp" -%} diff -Nru upm-1.6.0/src/rhusb/pyupm_rhusb.i upm-1.7.1/src/rhusb/pyupm_rhusb.i --- upm-1.6.0/src/rhusb/pyupm_rhusb.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rhusb/pyupm_rhusb.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_rhusb -%include "../upm.i" -%include "stdint.i" - -%include "rhusb.hpp" -%{ - #include "rhusb.hpp" -%} diff -Nru upm-1.6.0/src/rhusb/rhusb.i upm-1.7.1/src/rhusb/rhusb.i --- upm-1.6.0/src/rhusb/rhusb.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/rhusb/rhusb.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" +JAVA_JNI_LOADLIBRARY(javaupm_rhusb) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "rhusb.hpp" +%} +%include "rhusb.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/rn2903/javaupm_rn2903.i upm-1.7.1/src/rn2903/javaupm_rn2903.i --- upm-1.6.0/src/rn2903/javaupm_rn2903.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rn2903/javaupm_rn2903.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_rn2903 -%include "../upm.i" -%include "std_string.i" -%include "stdint.i" -%include "typemaps.i" - -%include "rn2903_defs.h" -%include "rn2903.hpp" -%{ - #include "rn2903.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_rn2903) diff -Nru upm-1.6.0/src/rn2903/jsupm_rn2903.i upm-1.7.1/src/rn2903/jsupm_rn2903.i --- upm-1.6.0/src/rn2903/jsupm_rn2903.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rn2903/jsupm_rn2903.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_rn2903 -%include "../upm.i" -%include "std_string.i" - -%include "rn2903_defs.h" -%include "rn2903.hpp" -%{ - #include "rn2903.hpp" -%} diff -Nru upm-1.6.0/src/rn2903/pyupm_rn2903.i upm-1.7.1/src/rn2903/pyupm_rn2903.i --- upm-1.6.0/src/rn2903/pyupm_rn2903.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rn2903/pyupm_rn2903.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_rn2903 -%include "../upm.i" -%include "std_string.i" - -%include "rn2903_defs.h" -%include "rn2903.hpp" -%{ - #include "rn2903.hpp" -%} diff -Nru upm-1.6.0/src/rn2903/rn2903.c upm-1.7.1/src/rn2903/rn2903.c --- upm-1.6.0/src/rn2903/rn2903.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rn2903/rn2903.c 2018-10-12 04:47:41.000000000 +0000 @@ -150,7 +150,7 @@ rn2903_close(dev); return NULL; } - strncpy(dev->hardware_eui, dev->resp_data, RN2903_MAX_HEX_EUI64); + memcpy(dev->hardware_eui, dev->resp_data, RN2903_MAX_HEX_EUI64); return dev; } @@ -317,8 +317,7 @@ memset(dev->resp_data, 0, RN2903_MAX_BUFFER); dev->resp_len = 0; - upm_clock_t clock; - upm_clock_init(&clock); + upm_clock_t clock = upm_clock_init(); uint32_t elapsed = 0; do diff -Nru upm-1.6.0/src/rn2903/rn2903.i upm-1.7.1/src/rn2903/rn2903.i --- upm-1.6.0/src/rn2903/rn2903.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/rn2903/rn2903.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_rn2903) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "rn2903_defs.h" +#include "rn2903.hpp" +%} +%include "rn2903_defs.h" +%include "rn2903.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/rotary/javaupm_rotary.i upm-1.7.1/src/rotary/javaupm_rotary.i --- upm-1.6.0/src/rotary/javaupm_rotary.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rotary/javaupm_rotary.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_rotary -%include "../upm.i" - -%{ - #include "rotary.hpp" -%} - -%include "rotary.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_rotary) diff -Nru upm-1.6.0/src/rotary/jsupm_rotary.i upm-1.7.1/src/rotary/jsupm_rotary.i --- upm-1.6.0/src/rotary/jsupm_rotary.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rotary/jsupm_rotary.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_rotary -%include "../upm.i" - -%{ - #include "rotary.hpp" -%} - -%include "rotary.hpp" diff -Nru upm-1.6.0/src/rotary/pyupm_rotary.i upm-1.7.1/src/rotary/pyupm_rotary.i --- upm-1.6.0/src/rotary/pyupm_rotary.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rotary/pyupm_rotary.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_rotary -%include "../upm.i" - -%include "rotary.hpp" -%{ - #include "rotary.hpp" -%} diff -Nru upm-1.6.0/src/rotary/rotary.json upm-1.7.1/src/rotary/rotary.json --- upm-1.6.0/src/rotary/rotary.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rotary/rotary.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["gsk"], "Image": "rotary.jpg", "Examples": { - "Java": ["RotarySample.java"], + "Java": ["Rotary_Example.java"], "Python": ["rotary.py"], "Node.js": ["rotary.js"], "C++": ["rotary.cxx"] diff -Nru upm-1.6.0/src/rotaryencoder/javaupm_rotaryencoder.i upm-1.7.1/src/rotaryencoder/javaupm_rotaryencoder.i --- upm-1.6.0/src/rotaryencoder/javaupm_rotaryencoder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rotaryencoder/javaupm_rotaryencoder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_rotaryencoder -%include "../upm.i" - -%ignore signalAISR; - -%{ - #include "rotaryencoder.hpp" -%} - -%include "rotaryencoder.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_rotaryencoder) \ No newline at end of file diff -Nru upm-1.6.0/src/rotaryencoder/jsupm_rotaryencoder.i upm-1.7.1/src/rotaryencoder/jsupm_rotaryencoder.i --- upm-1.6.0/src/rotaryencoder/jsupm_rotaryencoder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rotaryencoder/jsupm_rotaryencoder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_rotaryencoder -%include "../upm.i" - -%{ - #include "rotaryencoder.hpp" -%} - -%include "rotaryencoder.hpp" diff -Nru upm-1.6.0/src/rotaryencoder/pyupm_rotaryencoder.i upm-1.7.1/src/rotaryencoder/pyupm_rotaryencoder.i --- upm-1.6.0/src/rotaryencoder/pyupm_rotaryencoder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rotaryencoder/pyupm_rotaryencoder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_rotaryencoder -%include "../upm.i" - -%include "rotaryencoder.hpp" -%{ - #include "rotaryencoder.hpp" -%} diff -Nru upm-1.6.0/src/rotaryencoder/rotaryencoder.i upm-1.7.1/src/rotaryencoder/rotaryencoder.i --- upm-1.6.0/src/rotaryencoder/rotaryencoder.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/rotaryencoder/rotaryencoder.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore signalAISR; + +JAVA_JNI_LOADLIBRARY(javaupm_rotaryencoder) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "rotaryencoder.hpp" +%} +%include "rotaryencoder.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/rotaryencoder/rotaryencoder.json upm-1.7.1/src/rotaryencoder/rotaryencoder.json --- upm-1.6.0/src/rotaryencoder/rotaryencoder.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rotaryencoder/rotaryencoder.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["hak"], "Image": "rotaryencoder.jpg", "Examples": { - "Java": ["RotaryEncoderSample.java"], + "Java": ["RotaryEncoder_Example.java"], "Python": ["rotaryencoder.py"], "Node.js": ["rotaryencoder.js"], "C++": ["rotaryencoder.cxx"], diff -Nru upm-1.6.0/src/rpr220/javaupm_rpr220.i upm-1.7.1/src/rpr220/javaupm_rpr220.i --- upm-1.6.0/src/rpr220/javaupm_rpr220.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rpr220/javaupm_rpr220.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_rpr220 -%include "../upm.i" - - -%{ - #include "rpr220.hpp" -%} -%include "rpr220.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_rpr220) - -JAVA_ADD_INSTALLISR(upm::RPR220) diff -Nru upm-1.6.0/src/rpr220/jsupm_rpr220.i upm-1.7.1/src/rpr220/jsupm_rpr220.i --- upm-1.6.0/src/rpr220/jsupm_rpr220.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rpr220/jsupm_rpr220.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_rpr220 -%include "../upm.i" - -%{ - #include "rpr220.hpp" -%} - -%include "rpr220.hpp" diff -Nru upm-1.6.0/src/rpr220/pyupm_rpr220.i upm-1.7.1/src/rpr220/pyupm_rpr220.i --- upm-1.6.0/src/rpr220/pyupm_rpr220.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rpr220/pyupm_rpr220.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_rpr220 -%include "../upm.i" - -%include "rpr220.hpp" -%{ - #include "rpr220.hpp" -%} diff -Nru upm-1.6.0/src/rpr220/rpr220.i upm-1.7.1/src/rpr220/rpr220.i --- upm-1.6.0/src/rpr220/rpr220.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/rpr220/rpr220.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,15 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_ADD_INSTALLISR(upm::RPR220) +JAVA_JNI_LOADLIBRARY(javaupm_rpr220) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "rpr220.hpp" +%} +%include "rpr220.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/rpr220/rpr220.json upm-1.7.1/src/rpr220/rpr220.json --- upm-1.6.0/src/rpr220/rpr220.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rpr220/rpr220.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["tsk", "hak"], "Image": "rpr220.jpg", "Examples": { - "Java": ["RPR220Sample.java", "RPR220_intrSample.java"], + "Java": ["RPR220_Example.java", "RPR220_intr_Example.java"], "Python": ["rpr220.py"], "Node.js": ["rpr220.js"], "C++": ["rpr220-intr.cxx", "rpr220.cxx"], diff -Nru upm-1.6.0/src/rsc/javaupm_rsc.i upm-1.7.1/src/rsc/javaupm_rsc.i --- upm-1.6.0/src/rsc/javaupm_rsc.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rsc/javaupm_rsc.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_rsc -%include "../upm.i" - -%{ - #include "rsc.hpp" -%} - -%include "rsc.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_rsc) diff -Nru upm-1.6.0/src/rsc/jsupm_rsc.i upm-1.7.1/src/rsc/jsupm_rsc.i --- upm-1.6.0/src/rsc/jsupm_rsc.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rsc/jsupm_rsc.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_rsc -%include "../upm.i" - -%{ - #include "rsc.hpp" -%} - -%include "rsc.hpp" diff -Nru upm-1.6.0/src/rsc/pyupm_rsc.i upm-1.7.1/src/rsc/pyupm_rsc.i --- upm-1.6.0/src/rsc/pyupm_rsc.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/rsc/pyupm_rsc.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_rsc -%include "../upm.i" - -%include "rsc.hpp" -%{ - #include "rsc.hpp" -%} diff -Nru upm-1.6.0/src/scam/javaupm_scam.i upm-1.7.1/src/scam/javaupm_scam.i --- upm-1.6.0/src/scam/javaupm_scam.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/scam/javaupm_scam.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_scam -%include "../upm.i" -%include "../java_buffer.i" - -%{ - #include "scam.hpp" -%} - -%include "scam.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_scam) diff -Nru upm-1.6.0/src/scam/jsupm_scam.i upm-1.7.1/src/scam/jsupm_scam.i --- upm-1.6.0/src/scam/jsupm_scam.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/scam/jsupm_scam.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_scam -%include "../upm.i" - -%{ - #include "scam.hpp" -%} - -%include "scam.hpp" diff -Nru upm-1.6.0/src/scam/pyupm_scam.i upm-1.7.1/src/scam/pyupm_scam.i --- upm-1.6.0/src/scam/pyupm_scam.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/scam/pyupm_scam.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_scam -%include "../upm.i" - -%{ - #include "scam.hpp" -%} -%include "scam.hpp" diff -Nru upm-1.6.0/src/scam/scam.i upm-1.7.1/src/scam/scam.i --- upm-1.6.0/src/scam/scam.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/scam/scam.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../java_buffer.i" + +JAVA_JNI_LOADLIBRARY(javaupm_scam) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "scam.hpp" +%} +%include "scam.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/scam/scam.json upm-1.7.1/src/scam/scam.json --- upm-1.6.0/src/scam/scam.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/scam/scam.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed"], "Image": "scam.jpg", "Examples": { - "Java": ["SCAMSample.java"], + "Java": ["SCAM_Example.java"], "Python": ["scam.py"], "Node.js": ["scam.js"], "C++": ["scam.cxx"] diff -Nru upm-1.6.0/src/sensortemplate/common.i upm-1.7.1/src/sensortemplate/common.i --- upm-1.6.0/src/sensortemplate/common.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sensortemplate/common.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Include global UPM interface file */ -%include "../upm.i" - -%{ - /* SWIG preprocessor copies this directly to the output wrapper*/ - #include "sensortemplate.hpp" -%} - -/* %include is a SWIG directive. SWIG will wrap types exposed in this - * header to the target language. */ -%include "sensortemplate.hpp" diff -Nru upm-1.6.0/src/sensortemplate/javaupm_sensortemplate.i upm-1.7.1/src/sensortemplate/javaupm_sensortemplate.i --- upm-1.6.0/src/sensortemplate/javaupm_sensortemplate.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sensortemplate/javaupm_sensortemplate.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -/* Specify the name of the target JAVA module */ -%module javaupm_sensortemplate - -/* Include the base sensor interface file */ -%include "common.i" - -/* Add the JAVA code to load the module */ -JAVA_JNI_LOADLIBRARY(javaupm_sensortemplate) diff -Nru upm-1.6.0/src/sensortemplate/jsupm_sensortemplate.i upm-1.7.1/src/sensortemplate/jsupm_sensortemplate.i --- upm-1.6.0/src/sensortemplate/jsupm_sensortemplate.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sensortemplate/jsupm_sensortemplate.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -/* Specify the name of the target JavaScript module */ -%module jsupm_sensortemplate - -/* Include the base sensor interface file */ -%include "common.i" diff -Nru upm-1.6.0/src/sensortemplate/pyupm_sensortemplate.i upm-1.7.1/src/sensortemplate/pyupm_sensortemplate.i --- upm-1.6.0/src/sensortemplate/pyupm_sensortemplate.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sensortemplate/pyupm_sensortemplate.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -/* Specify the name of the target JAVA module */ -%module pyupm_sensortemplate - -/* If documentation is enabled, a full "pyupm_doxy2swig.i file will be - * generated and used... Otherwise, use a stub */ -%include "pyupm_doxy2swig.i" - -/* Include the base sensor interface file */ -%include "common.i" diff -Nru upm-1.6.0/src/sensortemplate/sensortemplate.i upm-1.7.1/src/sensortemplate/sensortemplate.i --- upm-1.6.0/src/sensortemplate/sensortemplate.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/sensortemplate/sensortemplate.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,29 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +/* Add the JAVA code to load the module */ +JAVA_JNI_LOADLIBRARY(javaupm_sensortemplate) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +/* SWIG preprocessor copies this directly to the output wrapper*/ +#include "sensortemplate.hpp" +%} + +/* %include is a SWIG directive. SWIG will wrap types exposed in this + * header to the target language. */ +%include "sensortemplate.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/sensortemplate/sensortemplate.json upm-1.7.1/src/sensortemplate/sensortemplate.json --- upm-1.6.0/src/sensortemplate/sensortemplate.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sensortemplate/sensortemplate.json 2018-10-12 04:47:41.000000000 +0000 @@ -99,7 +99,7 @@ "required": false }, "Java": [ - "SensorTemplateSample.java" + "SensorTemplate_Example_Example_Example.java" ], "// Python": { "comment": "One or more Python examples.", diff -Nru upm-1.6.0/src/servo/javaupm_servo.i upm-1.7.1/src/servo/javaupm_servo.i --- upm-1.6.0/src/servo/javaupm_servo.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/servo/javaupm_servo.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -%module javaupm_servo -%include "../upm.i" - -%include "servo.hpp" -%{ - #include "servo.hpp" -%} - -%include "es08a.hpp" -%{ - #include "es08a.hpp" -%} - -%include "es9257.hpp" -%{ - #include "es9257.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_servo) \ No newline at end of file diff -Nru upm-1.6.0/src/servo/jsupm_servo.i upm-1.7.1/src/servo/jsupm_servo.i --- upm-1.6.0/src/servo/jsupm_servo.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/servo/jsupm_servo.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -%module jsupm_servo -%include "../upm.i" - -%include "servo.hpp" -%{ - #include "servo.hpp" -%} - -%include "es08a.hpp" -%{ - #include "es08a.hpp" -%} - -%include "es9257.hpp" -%{ - #include "es9257.hpp" -%} diff -Nru upm-1.6.0/src/servo/pyupm_servo.i upm-1.7.1/src/servo/pyupm_servo.i --- upm-1.6.0/src/servo/pyupm_servo.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/servo/pyupm_servo.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_servo -%include "../upm.i" - -%include "servo.hpp" -%{ - #include "servo.hpp" -%} - -%include "es08a.hpp" -%{ - #include "es08a.hpp" -%} - -%include "es9257.hpp" -%{ - #include "es9257.hpp" -%} diff -Nru upm-1.6.0/src/servo/servo.i upm-1.7.1/src/servo/servo.i --- upm-1.6.0/src/servo/servo.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/servo/servo.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_servo) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "es08a.hpp" +#include "servo.hpp" +#include "es9257.hpp" +%} +%include "servo.hpp" +%include "es9257.hpp" +%include "es08a.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/servo/servo.json upm-1.7.1/src/servo/servo.json --- upm-1.6.0/src/servo/servo.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/servo/servo.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["gsk"], "Image": "es08a.jpg", "Examples": { - "Java": ["ES08ASample.java"], + "Java": ["ES08A_Example.java"], "Python": ["es08a.py"], "Node.js": ["es08a.js"], "C++": ["servo-es08a.cxx"] @@ -99,7 +99,7 @@ "Manufacturers": ["EMAX"], "Image": "es08a.jpg", "Examples": { - "Java": ["ES08ASample.java"], + "Java": ["ES08A_Example.java"], "Python": ["es08a.py", "es08a.py"], "Node.js": ["es08a.js", "es08a.js"], "C++": ["servo-es08a.cxx", "servo-es08a.cxx"] diff -Nru upm-1.6.0/src/sht1x/javaupm_sht1x.i upm-1.7.1/src/sht1x/javaupm_sht1x.i --- upm-1.6.0/src/sht1x/javaupm_sht1x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sht1x/javaupm_sht1x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_sht1x -%include "../upm.i" -%include "std_string.i" -%include "stdint.i" -%include "typemaps.i" - -%include "sht1x_defs.h" -%include "sht1x.hpp" -%{ - #include "sht1x.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_sht1x) diff -Nru upm-1.6.0/src/sht1x/jsupm_sht1x.i upm-1.7.1/src/sht1x/jsupm_sht1x.i --- upm-1.6.0/src/sht1x/jsupm_sht1x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sht1x/jsupm_sht1x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_sht1x -%include "../upm.i" -%include "std_string.i" - -%include "sht1x_defs.h" -%include "sht1x.hpp" -%{ - #include "sht1x.hpp" -%} diff -Nru upm-1.6.0/src/sht1x/pyupm_sht1x.i upm-1.7.1/src/sht1x/pyupm_sht1x.i --- upm-1.6.0/src/sht1x/pyupm_sht1x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sht1x/pyupm_sht1x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_sht1x -%include "../upm.i" -%include "std_string.i" - -%include "sht1x_defs.h" -%include "sht1x.hpp" -%{ - #include "sht1x.hpp" -%} diff -Nru upm-1.6.0/src/sht1x/sht1x.i upm-1.7.1/src/sht1x/sht1x.i --- upm-1.6.0/src/sht1x/sht1x.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/sht1x/sht1x.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_sht1x) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "sht1x_defs.h" +#include "sht1x.hpp" +%} +%include "sht1x_defs.h" +%include "sht1x.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/si1132/javaupm_si1132.i upm-1.7.1/src/si1132/javaupm_si1132.i --- upm-1.6.0/src/si1132/javaupm_si1132.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si1132/javaupm_si1132.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -#ifdef ANDROID - %module javaupm_si1132 -#else - %module(directors="1") javaupm_si1132 -#endif - -%include "../upm.i" - -%import "../interfaces/javaupm_iLightSensor.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -JAVA_JNI_LOADLIBRARY(javaupm_si1132) - -%include "si1132.hpp" -%{ - #include "si1132.hpp" -%} - - diff -Nru upm-1.6.0/src/si1132/jsupm_si1132.i upm-1.7.1/src/si1132/jsupm_si1132.i --- upm-1.6.0/src/si1132/jsupm_si1132.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si1132/jsupm_si1132.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_si1132 -%include "../upm.i" - -%{ - #include "si1132.hpp" -%} - -%include "si1132.hpp" diff -Nru upm-1.6.0/src/si1132/pyupm_si1132.i upm-1.7.1/src/si1132/pyupm_si1132.i --- upm-1.6.0/src/si1132/pyupm_si1132.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si1132/pyupm_si1132.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module pyupm_si1132 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - - -%include "stdint.i" - -%include "si1132.hpp" -%{ - #include "si1132.hpp" -%} diff -Nru upm-1.6.0/src/si1132/si1132.i upm-1.7.1/src/si1132/si1132.i --- upm-1.6.0/src/si1132/si1132.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/si1132/si1132.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,21 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +#ifndef ANDROID + %module(directors="1") javaupm_si1132 +#endif + +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} +%import "../interfaces/javaupm_iLightSensor.i" + +JAVA_JNI_LOADLIBRARY(javaupm_si1132) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "si1132.hpp" +%} +%include "si1132.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/si1132/si1132.json upm-1.7.1/src/si1132/si1132.json --- upm-1.6.0/src/si1132/si1132.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si1132/si1132.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,50 +1,50 @@ -{ - "Library": "si1132", - "Description": "Silicon Labs Si1132 UV and visible light sensor library", - "Sensor Class": { - "SI1132": { - "Name": "API for the Silicon Labs Si1132 UV and Visible Light Sensor", - "Description": "This is the UPM Module for the Silicon Labs Si1132 UV and Visible Light Sensor. The Silicon Labs Si1132 is a low-power, ultraviolet (UV) index, and ambient light sensor with I2C digital interface and programmable-event interrupt output.", - "Aliases": ["si1132"], - "Categories": ["light"], - "Connections": ["i2c"], - "Project Type": ["industrial", "commercial"], - "Manufacturers": ["Silicon Labs"], - "Examples": { - "C++": ["si1132.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "min": 1.71, - "max": 3.6 - }, - "Supply Current": { - "Standby Mode": { - "unit": "uA", - "min": "0.15", - "max": "1.4" - }, - "Actively Measuring": { - "unit": "mA", - "min": "4.3", - "max": "5.5" - } - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - }, - "Measurement Time": { - "unit": "us", - "typ": 285 - } - }, - "Urls": { - "Product Pages": ["https://www.silabs.com/products/sensors/optical/si1132"], - "Datasheets": ["https://www.silabs.com/documents/public/data-sheets/Si1132.pdf"] - } - } - } -} +{ + "Library": "si1132", + "Description": "Silicon Labs Si1132 UV and visible light sensor library", + "Sensor Class": { + "SI1132": { + "Name": "API for the Silicon Labs Si1132 UV and Visible Light Sensor", + "Description": "This is the UPM Module for the Silicon Labs Si1132 UV and Visible Light Sensor. The Silicon Labs Si1132 is a low-power, ultraviolet (UV) index, and ambient light sensor with I2C digital interface and programmable-event interrupt output.", + "Aliases": ["si1132"], + "Categories": ["light"], + "Connections": ["i2c"], + "Project Type": ["industrial", "commercial"], + "Manufacturers": ["Silicon Labs"], + "Examples": { + "C++": ["si1132.cxx"] + }, + "Specifications": { + "Vsource": { + "unit": "V", + "min": 1.71, + "max": 3.6 + }, + "Supply Current": { + "Standby Mode": { + "unit": "uA", + "min": "0.15", + "max": "1.4" + }, + "Actively Measuring": { + "unit": "mA", + "min": "4.3", + "max": "5.5" + } + }, + "Operating Temperature": { + "unit": "°C", + "min": -40, + "max": 85 + }, + "Measurement Time": { + "unit": "us", + "typ": 285 + } + }, + "Urls": { + "Product Pages": ["https://www.silabs.com/products/sensors/optical/si1132"], + "Datasheets": ["https://www.silabs.com/documents/public/data-sheets/Si1132.pdf"] + } + } + } +} diff -Nru upm-1.6.0/src/si114x/javaupm_si114x.i upm-1.7.1/src/si114x/javaupm_si114x.i --- upm-1.6.0/src/si114x/javaupm_si114x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si114x/javaupm_si114x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_si114x -%include "../upm.i" -%include "cpointer.i" - -%{ - #include "si114x.hpp" -%} - -%include "si114x.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_si114x) \ No newline at end of file diff -Nru upm-1.6.0/src/si114x/jsupm_si114x.i upm-1.7.1/src/si114x/jsupm_si114x.i --- upm-1.6.0/src/si114x/jsupm_si114x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si114x/jsupm_si114x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_si114x -%include "../upm.i" -%include "cpointer.i" - -%{ - #include "si114x.hpp" -%} - -%include "si114x.hpp" diff -Nru upm-1.6.0/src/si114x/pyupm_si114x.i upm-1.7.1/src/si114x/pyupm_si114x.i --- upm-1.6.0/src/si114x/pyupm_si114x.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si114x/pyupm_si114x.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_si114x -%include "../upm.i" - -%include "si114x.hpp" -%{ - #include "si114x.hpp" -%} diff -Nru upm-1.6.0/src/si114x/si114x.i upm-1.7.1/src/si114x/si114x.i --- upm-1.6.0/src/si114x/si114x.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/si114x/si114x.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_si114x) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "si114x.hpp" +%} +%include "si114x.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/si7005/javaupm_si7005.i upm-1.7.1/src/si7005/javaupm_si7005.i --- upm-1.6.0/src/si7005/javaupm_si7005.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si7005/javaupm_si7005.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -%module javaupm_si7005 - -%include "../upm.i" -%include "arrays_java.i"; -%include "../java_buffer.i" -%include "cpointer.i" -%include "typemaps.i" - -%import "../interfaces/javaupm_iTemperatureSensor.i" -%import "../interfaces/javaupm_iHumiditySensor.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%{ - #include "si7005.hpp" -%} - -%include "si7005.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_si7005) diff -Nru upm-1.6.0/src/si7005/jsupm_si7005.i upm-1.7.1/src/si7005/jsupm_si7005.i --- upm-1.6.0/src/si7005/jsupm_si7005.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si7005/jsupm_si7005.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_si7005 -%include "../upm.i" - -%{ - #include "si7005.hpp" -%} - -%include "si7005.hpp" diff -Nru upm-1.6.0/src/si7005/pyupm_si7005.i upm-1.7.1/src/si7005/pyupm_si7005.i --- upm-1.6.0/src/si7005/pyupm_si7005.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/si7005/pyupm_si7005.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module pyupm_si7005 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - - -%include "stdint.i" - -%include "si7005.hpp" -%{ - #include "si7005.hpp" -%} diff -Nru upm-1.6.0/src/si7005/si7005.i upm-1.7.1/src/si7005/si7005.i --- upm-1.6.0/src/si7005/si7005.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/si7005/si7005.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,21 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} + +%import "../interfaces/javaupm_iTemperatureSensor.i" +%import "../interfaces/javaupm_iHumiditySensor.i" + +JAVA_JNI_LOADLIBRARY(javaupm_si7005) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "si7005.hpp" +%} +%include "si7005.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/slide/javaupm_slide.i upm-1.7.1/src/slide/javaupm_slide.i --- upm-1.6.0/src/slide/javaupm_slide.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/slide/javaupm_slide.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_slide -%include "../upm.i" - -%{ - #include "slide.hpp" -%} - -%include "slide.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_slide) diff -Nru upm-1.6.0/src/slide/jsupm_slide.i upm-1.7.1/src/slide/jsupm_slide.i --- upm-1.6.0/src/slide/jsupm_slide.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/slide/jsupm_slide.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_slide -%include "../upm.i" - -%{ - #include "slide.hpp" -%} - -%include "slide.hpp" diff -Nru upm-1.6.0/src/slide/pyupm_slide.i upm-1.7.1/src/slide/pyupm_slide.i --- upm-1.6.0/src/slide/pyupm_slide.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/slide/pyupm_slide.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_slide -%include "../upm.i" - -%include "slide.hpp" -%{ - #include "slide.hpp" -%} diff -Nru upm-1.6.0/src/slide/slide.json upm-1.7.1/src/slide/slide.json --- upm-1.6.0/src/slide/slide.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/slide/slide.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed"], "Image": "slide.jpg", "Examples": { - "Java" : ["SlideSample.java"], + "Java" : ["Slide_Example.java"], "Python": ["slide.py"], "Node.js": ["slide.js"], "C++": ["slide.cxx"], diff -Nru upm-1.6.0/src/sm130/javaupm_sm130.i upm-1.7.1/src/sm130/javaupm_sm130.i --- upm-1.6.0/src/sm130/javaupm_sm130.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sm130/javaupm_sm130.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_sm130 -%include "../upm.i" - -%{ - #include "sm130.hpp" -%} - -%include "sm130.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_sm130) \ No newline at end of file diff -Nru upm-1.6.0/src/sm130/jsupm_sm130.i upm-1.7.1/src/sm130/jsupm_sm130.i --- upm-1.6.0/src/sm130/jsupm_sm130.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sm130/jsupm_sm130.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_sm130 -%include "../upm.i" - -%{ - #include "sm130.hpp" -%} - -%include "sm130.hpp" diff -Nru upm-1.6.0/src/sm130/pyupm_sm130.i upm-1.7.1/src/sm130/pyupm_sm130.i --- upm-1.6.0/src/sm130/pyupm_sm130.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sm130/pyupm_sm130.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_sm130 -%include "../upm.i" - -%include "sm130.hpp" -%{ - #include "sm130.hpp" -%} diff -Nru upm-1.6.0/src/sm130/sm130.hpp upm-1.7.1/src/sm130/sm130.hpp --- upm-1.6.0/src/sm130/sm130.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sm130/sm130.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -70,8 +70,8 @@ * * @image html sm130.jpg *
SM130 RFID Reader image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet sm130.cxx Interesting */ diff -Nru upm-1.6.0/src/sm130/sm130.json upm-1.7.1/src/sm130/sm130.json --- upm-1.6.0/src/sm130/sm130.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sm130/sm130.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["SonMicro", "RFID Module - SM130 MIFARE (13.56 MHz)"], "Image": "sm130.jpg", "Examples": { - "Java": ["SM130Example.java"], + "Java": ["SM130_Example.java"], "Python": ["sm130.py"], "Node.js": ["sm130.js"], "C++": ["sm130.cxx"] diff -Nru upm-1.6.0/src/smartdrive/javaupm_smartdrive.i upm-1.7.1/src/smartdrive/javaupm_smartdrive.i --- upm-1.6.0/src/smartdrive/javaupm_smartdrive.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/smartdrive/javaupm_smartdrive.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_smartdrive -%include "../upm.i" - -%{ - #include "smartdrive.hpp" -%} - -%include "smartdrive.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_smartdrive) diff -Nru upm-1.6.0/src/smartdrive/jsupm_smartdrive.i upm-1.7.1/src/smartdrive/jsupm_smartdrive.i --- upm-1.6.0/src/smartdrive/jsupm_smartdrive.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/smartdrive/jsupm_smartdrive.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_smartdrive -%include "../upm.i" - -%{ - #include "smartdrive.hpp" -%} - -%include "smartdrive.hpp" diff -Nru upm-1.6.0/src/smartdrive/pyupm_smartdrive.i upm-1.7.1/src/smartdrive/pyupm_smartdrive.i --- upm-1.6.0/src/smartdrive/pyupm_smartdrive.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/smartdrive/pyupm_smartdrive.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module pyupm_smartdrive -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - - -%include "stdint.i" - -%include "smartdrive.hpp" -%{ - #include "smartdrive.hpp" -%} diff -Nru upm-1.6.0/src/smartdrive/smartdrive.i upm-1.7.1/src/smartdrive/smartdrive.i --- upm-1.6.0/src/smartdrive/smartdrive.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/smartdrive/smartdrive.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_smartdrive) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "smartdrive.hpp" +%} +%include "smartdrive.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/speaker/javaupm_speaker.i upm-1.7.1/src/speaker/javaupm_speaker.i --- upm-1.6.0/src/speaker/javaupm_speaker.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/speaker/javaupm_speaker.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_speaker -%include "../upm.i" - -%{ - #include "speaker.hpp" -%} - -%include "speaker.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_speaker) \ No newline at end of file diff -Nru upm-1.6.0/src/speaker/jsupm_speaker.i upm-1.7.1/src/speaker/jsupm_speaker.i --- upm-1.6.0/src/speaker/jsupm_speaker.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/speaker/jsupm_speaker.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_speaker -%include "../upm.i" - -%{ - #include "speaker.hpp" -%} - -%include "speaker.hpp" diff -Nru upm-1.6.0/src/speaker/pyupm_speaker.i upm-1.7.1/src/speaker/pyupm_speaker.i --- upm-1.6.0/src/speaker/pyupm_speaker.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/speaker/pyupm_speaker.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_speaker -%include "../upm.i" - -%include "speaker.hpp" -%{ - #include "speaker.hpp" -%} diff -Nru upm-1.6.0/src/speaker/speaker.c upm-1.7.1/src/speaker/speaker.c --- upm-1.6.0/src/speaker/speaker.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/speaker/speaker.c 2018-10-12 04:47:41.000000000 +0000 @@ -100,11 +100,6 @@ return NULL; } -#if defined(UPM_PLATFORM_LINUX) - // Would prefer, but not fatal if not available - mraa_gpio_use_mmaped(dev->gpio, 1); -#endif // UPM_PLATFORM_LINUX - mraa_gpio_dir(dev->gpio, MRAA_GPIO_OUT); return dev; @@ -206,8 +201,7 @@ if (speaker_set_frequency(dev, freq)) return UPM_ERROR_OPERATION_FAILED; - upm_clock_t clock; - upm_clock_init(&clock); + upm_clock_t clock = upm_clock_init(); mraa_pwm_enable(dev->pwm, 1); while (upm_elapsed_ms(&clock) < emit_ms) diff -Nru upm-1.6.0/src/speaker/speaker.json upm-1.7.1/src/speaker/speaker.json --- upm-1.6.0/src/speaker/speaker.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/speaker/speaker.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["hak"], "Image": "speaker.jpg", "Examples": { - "Java": ["SpeakerPWMSample.java", "SpeakerSample.java"], + "Java": ["SpeakerPWM_Example.java", "Speaker_Example.java"], "Python": ["speaker_pwm.py", "speaker.py"], "Node.js": ["speaker_pwm.js", "speaker.js"], "C++": ["speaker-pwm.cxx", "speaker.cxx"], diff -Nru upm-1.6.0/src/ssd1351/javaupm_ssd1351.i upm-1.7.1/src/ssd1351/javaupm_ssd1351.i --- upm-1.6.0/src/ssd1351/javaupm_ssd1351.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ssd1351/javaupm_ssd1351.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -%module javaupm_ssd1351 -%include "../upm.i" -%include "typemaps.i" -%include "stdint.i" - -%ignore m_map; -%ignore font; - -%include "ssd1351_gfx.hpp" -%{ - #include "ssd1351_gfx.hpp" -%} - -%include "ssd1351.hpp" -%{ - #include "ssd1351.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_ssd1351) \ No newline at end of file diff -Nru upm-1.6.0/src/ssd1351/jsupm_ssd1351.i upm-1.7.1/src/ssd1351/jsupm_ssd1351.i --- upm-1.6.0/src/ssd1351/jsupm_ssd1351.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ssd1351/jsupm_ssd1351.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module jsupm_ssd1351 -%include "../upm.i" - -%include "ssd1351_gfx.hpp" -%{ - #include "ssd1351_gfx.hpp" -%} - -%include "ssd1351.hpp" -%{ - #include "ssd1351.hpp" -%} diff -Nru upm-1.6.0/src/ssd1351/pyupm_ssd1351.i upm-1.7.1/src/ssd1351/pyupm_ssd1351.i --- upm-1.6.0/src/ssd1351/pyupm_ssd1351.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ssd1351/pyupm_ssd1351.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ssd1351 -%include "../upm.i" - -%include "ssd1351_gfx.hpp" -%{ - #include "ssd1351_gfx.hpp" -%} - -%include "ssd1351.hpp" -%{ - #include "ssd1351.hpp" -%} diff -Nru upm-1.6.0/src/ssd1351/ssd1351.cxx upm-1.7.1/src/ssd1351/ssd1351.cxx --- upm-1.6.0/src/ssd1351/ssd1351.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ssd1351/ssd1351.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -53,13 +53,11 @@ ": Could not initialize CS pin"); return; } - m_oc.useMmap(true); if (m_dc.dir(mraa::DIR_OUT) != mraa::SUCCESS) { throw std::runtime_error(string(__FUNCTION__) + ": Could not initialize data/cmd pin"); return; } - m_dc.useMmap(true); if (m_rst.dir(mraa::DIR_OUT) != mraa::SUCCESS) { throw std::runtime_error(string(__FUNCTION__) + ": Could not initialize reset pin"); diff -Nru upm-1.6.0/src/ssd1351/ssd1351.i upm-1.7.1/src/ssd1351/ssd1351.i --- upm-1.6.0/src/ssd1351/ssd1351.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ssd1351/ssd1351.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,19 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore font; +%ignore m_map; + +JAVA_JNI_LOADLIBRARY(javaupm_ssd1351) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ssd1351.hpp" +#include "ssd1351_gfx.hpp" +%} +%include "ssd1351_gfx.hpp" +%include "ssd1351.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/st7735/javaupm_st7735.i upm-1.7.1/src/st7735/javaupm_st7735.i --- upm-1.6.0/src/st7735/javaupm_st7735.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/st7735/javaupm_st7735.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -%module javaupm_st7735 -%include "../upm.i" -%include "arrays_java.i" -%include "typemaps.i" -%include "stdint.i" - -%ignore m_map; -%ignore Bcmd; -%ignore font; -%ignore Rcmd1; -%ignore Rcmd2green; -%ignore Rcmd2red; -%ignore Rcmd3; - - -/* -%typemap(jni) unsigned char[] "jbyteArray"; -%typemap(jtype) unsigned char[] "byte[]"; -%typemap(jstype) unsigned char[] "byte[]"; - -%typemap(out) unsigned char[] { - $result = SWIG_JavaArrayOutSchar(jenv, reinterpret_cast($1), sizeof($1)); -} -%typemap(freearg) unsigned char* { - JCALL3(ReleaseByteArrayElements, jenv, $input, reinterpret_cast($1), 0); -} -*/ -%typemap(jni) unsigned char* "jbyteArray"; -%typemap(jtype) unsigned char* "byte[]"; -%typemap(jstype) unsigned char* "byte[]"; - -%typemap(javain) unsigned char* "$javainput" - -%typemap(in) unsigned char* { - $1 = (unsigned char *)JCALL2(GetByteArrayElements, jenv, $input, NULL); -} - -%include "st7735_gfx.hpp" -%{ - #include "st7735_gfx.hpp" -%} - -%include "st7735.hpp" -%{ - #include "st7735.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_st7735) \ No newline at end of file diff -Nru upm-1.6.0/src/st7735/jsupm_st7735.i upm-1.7.1/src/st7735/jsupm_st7735.i --- upm-1.6.0/src/st7735/jsupm_st7735.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/st7735/jsupm_st7735.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module jsupm_st7735 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%include "st7735_gfx.hpp" -%{ - #include "st7735_gfx.hpp" -%} - -%include "st7735.hpp" -%{ - #include "st7735.hpp" -%} diff -Nru upm-1.6.0/src/st7735/pyupm_st7735.i upm-1.7.1/src/st7735/pyupm_st7735.i --- upm-1.6.0/src/st7735/pyupm_st7735.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/st7735/pyupm_st7735.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_st7735 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%include "st7735_gfx.hpp" -%{ - #include "st7735_gfx.hpp" -%} - -%include "st7735.hpp" -%{ - #include "st7735.hpp" -%} diff -Nru upm-1.6.0/src/st7735/st7735.i upm-1.7.1/src/st7735/st7735.i --- upm-1.6.0/src/st7735/st7735.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/st7735/st7735.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,59 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i" +%ignore m_map; +%ignore Bcmd; +%ignore font; +%ignore Rcmd1; +%ignore Rcmd2green; +%ignore Rcmd2red; +%ignore Rcmd3; + +/* +%typemap(jni) unsigned char[] "jbyteArray"; +%typemap(jtype) unsigned char[] "byte[]"; +%typemap(jstype) unsigned char[] "byte[]"; + +%typemap(out) unsigned char[] { + $result = SWIG_JavaArrayOutSchar(jenv, reinterpret_cast($1), sizeof($1)); +} +%typemap(freearg) unsigned char* { + JCALL3(ReleaseByteArrayElements, jenv, $input, reinterpret_cast($1), 0); +} +*/ +%typemap(jni) unsigned char* "jbyteArray"; +%typemap(jtype) unsigned char* "byte[]"; +%typemap(jstype) unsigned char* "byte[]"; + +%typemap(javain) unsigned char* "$javainput" + +%typemap(in) unsigned char* { + $1 = (unsigned char *)JCALL2(GetByteArrayElements, jenv, $input, NULL); +} + +JAVA_JNI_LOADLIBRARY(javaupm_st7735) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint8_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_uint8_t.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "st7735_gfx.hpp" +#include "st7735.hpp" +%} +%include "st7735_gfx.hpp" +%include "st7735.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/st7735/st7735.json upm-1.7.1/src/st7735/st7735.json --- upm-1.6.0/src/st7735/st7735.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/st7735/st7735.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Adafruit", "Truly Semiconductors", "Sitronix"], "Image": "st7735.jpg", "Examples": { - "Java": ["ST7735Sample.java"], + "Java": ["ST7735_Example.java"], "Node.js": ["st7735.js"], "C++": ["st7735.cxx"] }, diff -Nru upm-1.6.0/src/stepmotor/javaupm_stepmotor.i upm-1.7.1/src/stepmotor/javaupm_stepmotor.i --- upm-1.6.0/src/stepmotor/javaupm_stepmotor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/stepmotor/javaupm_stepmotor.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_stepmotor -%include "../upm.i" - -%{ - #include "stepmotor.hpp" -%} - -%include "stepmotor.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_stepmotor) \ No newline at end of file diff -Nru upm-1.6.0/src/stepmotor/jsupm_stepmotor.i upm-1.7.1/src/stepmotor/jsupm_stepmotor.i --- upm-1.6.0/src/stepmotor/jsupm_stepmotor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/stepmotor/jsupm_stepmotor.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_stepmotor -%include "../upm.i" - -%{ - #include "stepmotor.hpp" -%} - -%include "stepmotor.hpp" diff -Nru upm-1.6.0/src/stepmotor/pyupm_stepmotor.i upm-1.7.1/src/stepmotor/pyupm_stepmotor.i --- upm-1.6.0/src/stepmotor/pyupm_stepmotor.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/stepmotor/pyupm_stepmotor.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_stepmotor -%include "../upm.i" - -%include "stdint.i" - -%include "stepmotor.hpp" -%{ - #include "stepmotor.hpp" -%} diff -Nru upm-1.6.0/src/stepmotor/stepmotor.cxx upm-1.7.1/src/stepmotor/stepmotor.cxx --- upm-1.6.0/src/stepmotor/stepmotor.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/stepmotor/stepmotor.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -47,7 +47,6 @@ ": Could not initialize dirPin as output"); return; } - m_dirPinCtx.useMmap(true); m_dirPinCtx.write(0); if (m_stePinCtx.dir(mraa::DIR_OUT) != mraa::SUCCESS) { @@ -55,7 +54,6 @@ ": Could not initialize stePin as output"); return; } - m_stePinCtx.useMmap(true); m_stePinCtx.write(0); if (enPin >= 0) { @@ -65,7 +63,6 @@ ": Could not initialize enPin as output"); return; } - m_enPinCtx->useMmap(true); enable(true); } } diff -Nru upm-1.6.0/src/stepmotor/stepmotor.hpp upm-1.7.1/src/stepmotor/stepmotor.hpp --- upm-1.6.0/src/stepmotor/stepmotor.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/stepmotor/stepmotor.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -70,8 +70,8 @@ * * @image html stepmotor.jpg *
EasyDriver Sensor image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet stepmotor.cxx Interesting */ diff -Nru upm-1.6.0/src/stepmotor/stepmotor.i upm-1.7.1/src/stepmotor/stepmotor.i --- upm-1.6.0/src/stepmotor/stepmotor.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/stepmotor/stepmotor.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_stepmotor) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "stepmotor.hpp" +%} +%include "stepmotor.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/stepmotor/stepmotor.json upm-1.7.1/src/stepmotor/stepmotor.json --- upm-1.6.0/src/stepmotor/stepmotor.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/stepmotor/stepmotor.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Allegro", "SparkFun", "generic"], "Image": "stepmotor.jpg", "Examples": { - "Java": ["StepMotorSample.java"], + "Java": ["StepMotor_Example.java"], "Python": ["stepmotor.py"], "Node.js": ["stepmotor.js"], "C++": ["stepmotor.cxx"] diff -Nru upm-1.6.0/src/swigme.i.in upm-1.7.1/src/swigme.i.in --- upm-1.6.0/src/swigme.i.in 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/swigme.i.in 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +/* This SWIG .i file is generated from UPM CMake. If additional functionality + * is required, custom .i files can be placed in the library directory. + */ + +/* Common SWIG syntax */ +%include "../common_top.i" + +%{ +@SWIG_HASH_INCLUDES@ +%} +@SWIG_PERCENT_INCLUDES@ + +/* Java-specific SWIG syntax */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_@libname@) +#endif diff -Nru upm-1.6.0/src/sx1276/javaupm_sx1276.i upm-1.7.1/src/sx1276/javaupm_sx1276.i --- upm-1.6.0/src/sx1276/javaupm_sx1276.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sx1276/javaupm_sx1276.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -%module javaupm_sx1276 -%include "../upm.i" -%include "cpointer.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%{ - #include "sx1276.hpp" -%} - -%ignore send(uint8_t *buffer, uint8_t size, int txTimeout); -%ignore getRxBuffer(); - -%include "sx1276.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_sx1276) diff -Nru upm-1.6.0/src/sx1276/jsupm_sx1276.i upm-1.7.1/src/sx1276/jsupm_sx1276.i --- upm-1.6.0/src/sx1276/jsupm_sx1276.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sx1276/jsupm_sx1276.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_sx1276 -%include "../upm.i" -%include "cpointer.i" - -%include "sx1276.hpp" -%{ - #include "sx1276.hpp" -%} - diff -Nru upm-1.6.0/src/sx1276/pyupm_sx1276.i upm-1.7.1/src/sx1276/pyupm_sx1276.i --- upm-1.6.0/src/sx1276/pyupm_sx1276.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sx1276/pyupm_sx1276.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_sx1276 -%include "../upm.i" -%include "cpointer.i" - -%include "stdint.i" - -%pointer_functions(float, floatp); - -%include "sx1276.hpp" -%{ - #include "sx1276.hpp" -%} - diff -Nru upm-1.6.0/src/sx1276/sx1276.cxx upm-1.7.1/src/sx1276/sx1276.cxx --- upm-1.6.0/src/sx1276/sx1276.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sx1276/sx1276.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -80,7 +80,6 @@ m_spi.frequency(10000000); // 10Mhz, if supported m_gpioCS.dir(mraa::DIR_OUT); - m_gpioCS.useMmap(true); csOff(); m_gpioReset.dir(mraa::DIR_IN); diff -Nru upm-1.6.0/src/sx1276/sx1276.i upm-1.7.1/src/sx1276/sx1276.i --- upm-1.6.0/src/sx1276/sx1276.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/sx1276/sx1276.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,22 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" + +%ignore getRxBuffer(); +%ignore send(uint8_t *buffer, uint8_t size, int txTimeout); + +JAVA_JNI_LOADLIBRARY(javaupm_sx1276) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(float, floatp); + +%{ +#include "sx1276.hpp" +%} +%include "sx1276.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/sx6119/javaupm_sx6119.i upm-1.7.1/src/sx6119/javaupm_sx6119.i --- upm-1.6.0/src/sx6119/javaupm_sx6119.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sx6119/javaupm_sx6119.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_sx6119 -%include "../upm.i" - -%{ - #include "sx6119.hpp" -%} - -%include "sx6119.hpp" - - -JAVA_JNI_LOADLIBRARY(javaupm_sx6119) \ No newline at end of file diff -Nru upm-1.6.0/src/sx6119/jsupm_sx6119.i upm-1.7.1/src/sx6119/jsupm_sx6119.i --- upm-1.6.0/src/sx6119/jsupm_sx6119.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sx6119/jsupm_sx6119.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_sx6119 -%include "../upm.i" - -%{ - #include "sx6119.hpp" -%} - -%include "sx6119.hpp" - diff -Nru upm-1.6.0/src/sx6119/pyupm_sx6119.i upm-1.7.1/src/sx6119/pyupm_sx6119.i --- upm-1.6.0/src/sx6119/pyupm_sx6119.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/sx6119/pyupm_sx6119.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_sx6119 -%include "../upm.i" - -%{ - #include "sx6119.hpp" -%} - -%include "sx6119.hpp" - diff -Nru upm-1.6.0/src/t3311/javaupm_t3311.i upm-1.7.1/src/t3311/javaupm_t3311.i --- upm-1.6.0/src/t3311/javaupm_t3311.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/t3311/javaupm_t3311.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -%module javaupm_t3311 -%include "../upm.i" -%include "typemaps.i" -%include "cpointer.i" -%include "arrays_java.i"; -%include "../java_buffer.i" - -%{ - #include "t3311.hpp" -%} - -%include "t3311.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_t3311) diff -Nru upm-1.6.0/src/t3311/jsupm_t3311.i upm-1.7.1/src/t3311/jsupm_t3311.i --- upm-1.6.0/src/t3311/jsupm_t3311.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/t3311/jsupm_t3311.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module jsupm_t3311 -%include "../upm.i" -%include "stdint.i" -%include "cpointer.i" - -%pointer_functions(float, floatp); - -%include "t3311.hpp" -%{ - #include "t3311.hpp" -%} diff -Nru upm-1.6.0/src/t3311/pyupm_t3311.i upm-1.7.1/src/t3311/pyupm_t3311.i --- upm-1.6.0/src/t3311/pyupm_t3311.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/t3311/pyupm_t3311.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_t3311 -%include "../upm.i" -%include "stdint.i" -%include "cpointer.i" - -%pointer_functions(float, floatp); - -%include "t3311.hpp" -%{ - #include "t3311.hpp" -%} diff -Nru upm-1.6.0/src/t3311/t3311.i upm-1.7.1/src/t3311/t3311.i --- upm-1.6.0/src/t3311/t3311.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/t3311/t3311.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,19 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" + +JAVA_JNI_LOADLIBRARY(javaupm_t3311) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%pointer_functions(float, floatp); + +%{ +#include "t3311.hpp" +%} +%include "t3311.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/t6713/javaupm_t6713.i upm-1.7.1/src/t6713/javaupm_t6713.i --- upm-1.6.0/src/t6713/javaupm_t6713.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/t6713/javaupm_t6713.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -%module javaupm_t6713 -%include "../upm.i" - -%import "../interfaces/javaupm_iCO2Sensor.i" - -%include "arrays_java.i"; -%include "../java_buffer.i" -%include "cpointer.i" -%include "typemaps.i" - -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%{ - #include "t6713.hpp" -%} - -%include "t6713.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_t6713) diff -Nru upm-1.6.0/src/t6713/jsupm_t6713.i upm-1.7.1/src/t6713/jsupm_t6713.i --- upm-1.6.0/src/t6713/jsupm_t6713.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/t6713/jsupm_t6713.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_t6713 -%include "../upm.i" -%include "../carrays_uint16_t.i" - -%{ - #include "t6713.hpp" -%} - -%include "t6713.hpp" diff -Nru upm-1.6.0/src/t6713/pyupm_t6713.i upm-1.7.1/src/t6713/pyupm_t6713.i --- upm-1.6.0/src/t6713/pyupm_t6713.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/t6713/pyupm_t6713.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module pyupm_t6713 -%include "../upm.i" -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" - -%include "stdint.i" - -%include "t6713.hpp" -%{ - #include "t6713.hpp" -%} diff -Nru upm-1.6.0/src/t6713/t6713.i upm-1.7.1/src/t6713/t6713.i --- upm-1.6.0/src/t6713/t6713.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/t6713/t6713.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,25 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i" +%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%} +%import "../interfaces/javaupm_iCO2Sensor.i" + +JAVA_JNI_LOADLIBRARY(javaupm_t6713) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint16_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "t6713.hpp" +%} +%include "t6713.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/t8100/javaupm_t8100.i upm-1.7.1/src/t8100/javaupm_t8100.i --- upm-1.6.0/src/t8100/javaupm_t8100.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/t8100/javaupm_t8100.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_t8100 -%include "../upm.i" -%include "typemaps.i" - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" -%include "t8100.hpp" -%{ - #include "t8100.hpp" -%} - - -JAVA_JNI_LOADLIBRARY(javaupm_t8100) diff -Nru upm-1.6.0/src/t8100/jsupm_t8100.i upm-1.7.1/src/t8100/jsupm_t8100.i --- upm-1.6.0/src/t8100/jsupm_t8100.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/t8100/jsupm_t8100.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_t8100 -%include "../upm.i" -%include "stdint.i" - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" -%include "t8100.hpp" -%{ - #include "t8100.hpp" -%} diff -Nru upm-1.6.0/src/t8100/pyupm_t8100.i upm-1.7.1/src/t8100/pyupm_t8100.i --- upm-1.6.0/src/t8100/pyupm_t8100.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/t8100/pyupm_t8100.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_t8100 -%include "../upm.i" -%include "stdint.i" - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" -%include "t8100.hpp" -%{ - #include "t8100.hpp" -%} diff -Nru upm-1.6.0/src/t8100/t8100.i upm-1.7.1/src/t8100/t8100.i --- upm-1.6.0/src/t8100/t8100.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/t8100/t8100.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,18 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_t8100) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bacnetmstp.hpp" +#include "bacnetutil.hpp" +#include "t8100.hpp" +%} +%include "bacnetmstp.hpp" +%include "bacnetutil.hpp" +%include "t8100.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ta12200/javaupm_ta12200.i upm-1.7.1/src/ta12200/javaupm_ta12200.i --- upm-1.6.0/src/ta12200/javaupm_ta12200.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ta12200/javaupm_ta12200.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_ta12200 -%include "../upm.i" - -%{ - #include "ta12200.hpp" -%} - -%include "ta12200.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ta12200) \ No newline at end of file diff -Nru upm-1.6.0/src/ta12200/jsupm_ta12200.i upm-1.7.1/src/ta12200/jsupm_ta12200.i --- upm-1.6.0/src/ta12200/jsupm_ta12200.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ta12200/jsupm_ta12200.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ta12200 -%include "../upm.i" - -%{ - #include "ta12200.hpp" -%} - -%include "ta12200.hpp" diff -Nru upm-1.6.0/src/ta12200/pyupm_ta12200.i upm-1.7.1/src/ta12200/pyupm_ta12200.i --- upm-1.6.0/src/ta12200/pyupm_ta12200.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ta12200/pyupm_ta12200.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ta12200 -%include "../upm.i" - -%include "ta12200.hpp" -%{ - #include "ta12200.hpp" -%} diff -Nru upm-1.6.0/src/tb7300/javaupm_tb7300.i upm-1.7.1/src/tb7300/javaupm_tb7300.i --- upm-1.6.0/src/tb7300/javaupm_tb7300.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tb7300/javaupm_tb7300.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -%module javaupm_tb7300 -%include "../upm.i" -%include "typemaps.i" - -// We need to use this method for enum wrapping since the enum typedefs used -// by the derived classes (like ANALOG_VALUES_T) are passed to methods -// in the base class which expect a uint32_t. This is fine, and -// works everywhere except Java. It's type safety is a little too -// stringent in these cases. %javaconst(1) is generally recommended -// as it avoids JNI calls to determine the enumerant values at -// runtime. -%include "enumtypeunsafe.swg" -%javaconst(1); - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" -%include "tb7300.hpp" -%{ - #include "tb7300.hpp" -%} - - -JAVA_JNI_LOADLIBRARY(javaupm_tb7300) diff -Nru upm-1.6.0/src/tb7300/jsupm_tb7300.i upm-1.7.1/src/tb7300/jsupm_tb7300.i --- upm-1.6.0/src/tb7300/jsupm_tb7300.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tb7300/jsupm_tb7300.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_tb7300 -%include "../upm.i" -%include "stdint.i" - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" -%include "tb7300.hpp" -%{ - #include "tb7300.hpp" -%} diff -Nru upm-1.6.0/src/tb7300/pyupm_tb7300.i upm-1.7.1/src/tb7300/pyupm_tb7300.i --- upm-1.6.0/src/tb7300/pyupm_tb7300.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tb7300/pyupm_tb7300.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_tb7300 -%include "../upm.i" -%include "stdint.i" - -%include "bacnetmstp.hpp" -%include "bacnetutil.hpp" -%include "tb7300.hpp" -%{ - #include "tb7300.hpp" -%} diff -Nru upm-1.6.0/src/tb7300/tb7300.i upm-1.7.1/src/tb7300/tb7300.i --- upm-1.6.0/src/tb7300/tb7300.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/tb7300/tb7300.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,29 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +/* We need to use this method for enum wrapping since the enum typedefs used + * by the derived classes (like ANALOG_VALUES_T) are passed to methods + * in the base class which expect a uint32_t. This is fine, and + * works everywhere except Java. It's type safety is a little too + * stringent in these cases. %javaconst(1) is generally recommended + * as it avoids JNI calls to determine the enumerant values at + * runtime. + */ +%include "enumtypeunsafe.swg" +%javaconst(1); + +JAVA_JNI_LOADLIBRARY(javaupm_tb7300) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "bacnetmstp.hpp" +#include "bacnetutil.hpp" +#include "tb7300.hpp" +%} +%include "bacnetmstp.hpp" +%include "bacnetutil.hpp" +%include "tb7300.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/tca9548a/javaupm_tca9548a.i upm-1.7.1/src/tca9548a/javaupm_tca9548a.i --- upm-1.6.0/src/tca9548a/javaupm_tca9548a.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tca9548a/javaupm_tca9548a.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_tca9548a -%include "../upm.i" - -%{ - #include "tca9548a.hpp" -%} - -%include "tca9548a.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_tca9548a) diff -Nru upm-1.6.0/src/tca9548a/jsupm_tca9548a.i upm-1.7.1/src/tca9548a/jsupm_tca9548a.i --- upm-1.6.0/src/tca9548a/jsupm_tca9548a.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tca9548a/jsupm_tca9548a.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_tca9548a -%include "../upm.i" - -%{ - #include "tca9548a.hpp" -%} - -%include "tca9548a.hpp" diff -Nru upm-1.6.0/src/tca9548a/pyupm_tca9548a.i upm-1.7.1/src/tca9548a/pyupm_tca9548a.i --- upm-1.6.0/src/tca9548a/pyupm_tca9548a.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tca9548a/pyupm_tca9548a.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_tca9548a -%include "../upm.i" - -%include "tca9548a.hpp" -%{ - #include "tca9548a.hpp" -%} diff -Nru upm-1.6.0/src/tcs3414cs/javaupm_tcs3414cs.i upm-1.7.1/src/tcs3414cs/javaupm_tcs3414cs.i --- upm-1.6.0/src/tcs3414cs/javaupm_tcs3414cs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tcs3414cs/javaupm_tcs3414cs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_tcs3414cs -%include "../upm.i" - -%{ - #include "tcs3414cs.hpp" -%} - -%include "tcs3414cs.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_tcs3414cs) \ No newline at end of file diff -Nru upm-1.6.0/src/tcs3414cs/jsupm_tcs3414cs.i upm-1.7.1/src/tcs3414cs/jsupm_tcs3414cs.i --- upm-1.6.0/src/tcs3414cs/jsupm_tcs3414cs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tcs3414cs/jsupm_tcs3414cs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_tcs3414cs -%include "../upm.i" - -%{ - #include "tcs3414cs.hpp" -%} - -%include "tcs3414cs.hpp" diff -Nru upm-1.6.0/src/tcs3414cs/pyupm_tcs3414cs.i upm-1.7.1/src/tcs3414cs/pyupm_tcs3414cs.i --- upm-1.6.0/src/tcs3414cs/pyupm_tcs3414cs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tcs3414cs/pyupm_tcs3414cs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_tcs3414cs -%include "../upm.i" - -%include "tcs3414cs.hpp" -%{ - #include "tcs3414cs.hpp" -%} diff -Nru upm-1.6.0/src/tcs37727/javaupm_tcs37727.i upm-1.7.1/src/tcs37727/javaupm_tcs37727.i --- upm-1.6.0/src/tcs37727/javaupm_tcs37727.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tcs37727/javaupm_tcs37727.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_tcs37727 -%include "../upm.i" - -%{ - #include "tcs37727.hpp" -%} - -%include "tcs37727.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_tcs37727) \ No newline at end of file diff -Nru upm-1.6.0/src/tcs37727/jsupm_tcs37727.i upm-1.7.1/src/tcs37727/jsupm_tcs37727.i --- upm-1.6.0/src/tcs37727/jsupm_tcs37727.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tcs37727/jsupm_tcs37727.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_tcs37727 -%include "../upm.i" - -%{ - #include "tcs37727.hpp" -%} - -%include "tcs37727.hpp" diff -Nru upm-1.6.0/src/tcs37727/pyupm_tcs37727.i upm-1.7.1/src/tcs37727/pyupm_tcs37727.i --- upm-1.6.0/src/tcs37727/pyupm_tcs37727.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tcs37727/pyupm_tcs37727.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_tcs37727 -%include "../upm.i" - -%include "tcs37727.hpp" -%{ - #include "tcs37727.hpp" -%} diff -Nru upm-1.6.0/src/teams/javaupm_teams.i upm-1.7.1/src/teams/javaupm_teams.i --- upm-1.6.0/src/teams/javaupm_teams.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/teams/javaupm_teams.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_teams -%include "../upm.i" -%include "std_string.i" - -%include "teams.hpp" -%{ - #include "teams.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_teams) diff -Nru upm-1.6.0/src/teams/jsupm_teams.i upm-1.7.1/src/teams/jsupm_teams.i --- upm-1.6.0/src/teams/jsupm_teams.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/teams/jsupm_teams.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_teams -%include "../upm.i" -%include "std_string.i" - -%{ - #include "teams.hpp" -%} - -%include "teams.hpp" - diff -Nru upm-1.6.0/src/teams/pyupm_teams.i upm-1.7.1/src/teams/pyupm_teams.i --- upm-1.6.0/src/teams/pyupm_teams.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/teams/pyupm_teams.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_teams -%include "../upm.i" -%include "std_string.i" - -%{ - #include "teams.hpp" -%} -%include "teams.hpp" - diff -Nru upm-1.6.0/src/teams/teams.i upm-1.7.1/src/teams/teams.i --- upm-1.6.0/src/teams/teams.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/teams/teams.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_teams) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "teams.hpp" +%} +%include "teams.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/temperature/javaupm_temperature.i upm-1.7.1/src/temperature/javaupm_temperature.i --- upm-1.6.0/src/temperature/javaupm_temperature.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/temperature/javaupm_temperature.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module (docstring="Temperature sensor") javaupm_temperature - -%include "../upm.i" - -%include "temperature.hpp" -%{ - #include "temperature.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_temperature) diff -Nru upm-1.6.0/src/temperature/jsupm_temperature.i upm-1.7.1/src/temperature/jsupm_temperature.i --- upm-1.6.0/src/temperature/jsupm_temperature.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/temperature/jsupm_temperature.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -%module jsupm_temperature -%include "../upm.i" - -%include "temperature.hpp" -%{ - #include "temperature.hpp" -%} diff -Nru upm-1.6.0/src/temperature/pyupm_temperature.i upm-1.7.1/src/temperature/pyupm_temperature.i --- upm-1.6.0/src/temperature/pyupm_temperature.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/temperature/pyupm_temperature.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_temperature -%include "../upm.i" - -%include "temperature.hpp" -%{ - #include "temperature.hpp" -%} diff -Nru upm-1.6.0/src/temperature/temperature.json upm-1.7.1/src/temperature/temperature.json --- upm-1.6.0/src/temperature/temperature.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/temperature/temperature.json 2018-10-12 04:47:41.000000000 +0000 @@ -16,7 +16,7 @@ "Image": "temp.jpg", "Examples": { - "Java": ["TemperatureSample.java"], + "Java": ["Temperature_Example.java"], "Python": ["temperature.py"], "Node.js": ["temperature.js"], "C++": ["temperature.cxx"] diff -Nru upm-1.6.0/src/tex00/javaupm_tex00.i upm-1.7.1/src/tex00/javaupm_tex00.i --- upm-1.6.0/src/tex00/javaupm_tex00.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tex00/javaupm_tex00.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_tex00 -%include "../upm.i" -%include "std_string.i" - -%include "tex00.hpp" -%{ - #include "tex00.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_tex00) diff -Nru upm-1.6.0/src/tex00/jsupm_tex00.i upm-1.7.1/src/tex00/jsupm_tex00.i --- upm-1.6.0/src/tex00/jsupm_tex00.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tex00/jsupm_tex00.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_tex00 -%include "../upm.i" -%include "std_string.i" - -%{ - #include "tex00.hpp" -%} - -%include "tex00.hpp" - diff -Nru upm-1.6.0/src/tex00/pyupm_tex00.i upm-1.7.1/src/tex00/pyupm_tex00.i --- upm-1.6.0/src/tex00/pyupm_tex00.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tex00/pyupm_tex00.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_tex00 -%include "../upm.i" -%include "std_string.i" - -%{ - #include "tex00.hpp" -%} -%include "tex00.hpp" - diff -Nru upm-1.6.0/src/tex00/tex00.i upm-1.7.1/src/tex00/tex00.i --- upm-1.6.0/src/tex00/tex00.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/tex00/tex00.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_tex00) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "tex00.hpp" +%} +%include "tex00.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/th02/javaupm_th02.i upm-1.7.1/src/th02/javaupm_th02.i --- upm-1.6.0/src/th02/javaupm_th02.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/th02/javaupm_th02.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_th02 -%include "../upm.i" - -%{ - #include "th02.hpp" -%} - -%include "th02.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_th02) \ No newline at end of file diff -Nru upm-1.6.0/src/th02/jsupm_th02.i upm-1.7.1/src/th02/jsupm_th02.i --- upm-1.6.0/src/th02/jsupm_th02.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/th02/jsupm_th02.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_th02 -%include "../upm.i" - -%{ - #include "th02.hpp" -%} - -%include "th02.hpp" diff -Nru upm-1.6.0/src/th02/pyupm_th02.i upm-1.7.1/src/th02/pyupm_th02.i --- upm-1.6.0/src/th02/pyupm_th02.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/th02/pyupm_th02.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_th02 -%include "../upm.i" - -%include "th02.hpp" -%{ - #include "th02.hpp" -%} diff -Nru upm-1.6.0/src/th02/th02.json upm-1.7.1/src/th02/th02.json --- upm-1.6.0/src/th02/th02.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/th02/th02.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed"], "Image": "th02.jpg", "Examples": { - "Java": ["Th02Example.java"], + "Java": ["Th02_Example.java"], "C++": ["th02.cxx"] }, "Specifications": { diff -Nru upm-1.6.0/src/tm1637/javaupm_tm1637.i upm-1.7.1/src/tm1637/javaupm_tm1637.i --- upm-1.6.0/src/tm1637/javaupm_tm1637.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tm1637/javaupm_tm1637.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -%module javaupm_tm1637 -%include "../upm.i" -%include "stdint.i" -%include "typemaps.i" - -%varargs(4, int digit = 0) write; - -%rename("writeArray") write(uint8_t *digits); -%rename("writeString") write(std::string digits); - -%apply uint8_t *INPUT { uint8_t *digits } - -%{ - #include "tm1637.hpp" -%} - -%include "tm1637.hpp" - - -JAVA_JNI_LOADLIBRARY(javaupm_tm1637) \ No newline at end of file diff -Nru upm-1.6.0/src/tm1637/jsupm_tm1637.i upm-1.7.1/src/tm1637/jsupm_tm1637.i --- upm-1.6.0/src/tm1637/jsupm_tm1637.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tm1637/jsupm_tm1637.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -%module jsupm_tm1637 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%varargs(4, int digit = 0) write; - -%rename("writeArray") write(uint8_t *digits); -%rename("writeString") write(std::string digits); - -%{ - #include "tm1637.hpp" -%} - -%include "tm1637.hpp" - diff -Nru upm-1.6.0/src/tm1637/pyupm_tm1637.i upm-1.7.1/src/tm1637/pyupm_tm1637.i --- upm-1.6.0/src/tm1637/pyupm_tm1637.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tm1637/pyupm_tm1637.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_tm1637 -%include "../upm.i" -%include "../carrays_uint8_t.i" - -%varargs(4, int digit = 0) write; - -%{ - #include "tm1637.hpp" -%} -%include "tm1637.hpp" diff -Nru upm-1.6.0/src/tm1637/tm1637.cxx upm-1.7.1/src/tm1637/tm1637.cxx --- upm-1.6.0/src/tm1637/tm1637.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tm1637/tm1637.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -40,7 +40,7 @@ using namespace std; using namespace upm; -upm::TM1637::TM1637(int clk_pin, int dio_pin, int bright, M_FAST_GPIO mmio) { +upm::TM1637::TM1637(int clk_pin, int dio_pin, int bright) { if((m_clk = mraa_gpio_init(clk_pin)) == NULL){ throw std::invalid_argument(std::string(__FUNCTION__) + @@ -61,15 +61,6 @@ mraa_gpio_mode(m_clk, MRAA_GPIO_PULLUP); mraa_gpio_mode(m_dio, MRAA_GPIO_PULLUP); - if(mmio){ - if(mraa_gpio_use_mmaped(m_clk, 1) != MRAA_SUCCESS || - mraa_gpio_use_mmaped(m_dio, 1) != MRAA_SUCCESS){ - throw std::runtime_error(std::string(__FUNCTION__) + - ": mraa_gpio_use_mmaped() failed"); - return; - } - } - mraa_gpio_write(m_clk, 0); mraa_gpio_write(m_dio, 0); diff -Nru upm-1.6.0/src/tm1637/tm1637.hpp upm-1.7.1/src/tm1637/tm1637.hpp --- upm-1.6.0/src/tm1637/tm1637.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tm1637/tm1637.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -75,21 +75,13 @@ { public: /** - * Enum for the memory-mapped GPIO - */ - typedef enum { - NO = 0, - YES = 1 - } M_FAST_GPIO; - /** * TM1637 constructor * * @param clk_pin Clock pin the sensor is connected to * @param dio_pin Data pin the sensor is connected to * @param bright Initial brightness, from 0 (dark) to 7 (bright) (default is 3) - * @param mmio Fast memory-mapped GPIO writes; default is yes */ - TM1637(int clk_pin, int dio_pin, int bright = 3, M_FAST_GPIO mmio = YES); + TM1637(int clk_pin, int dio_pin, int bright = 3); /** * TM1637 destructor */ diff -Nru upm-1.6.0/src/tm1637/tm1637.i upm-1.7.1/src/tm1637/tm1637.i --- upm-1.6.0/src/tm1637/tm1637.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/tm1637/tm1637.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,32 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_tm1637) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint8_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%include "../carrays_uint8_t.i" +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%rename("writeArray") write(uint8_t *digits); +%rename("writeString") write(std::string digits); + +%varargs(4, int digit = 0) write; +%apply uint8_t *INPUT { uint8_t *digits } + +%{ +#include "tm1637.hpp" +%} +%include "tm1637.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/tm1637/tm1637.json upm-1.7.1/src/tm1637/tm1637.json --- upm-1.6.0/src/tm1637/tm1637.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tm1637/tm1637.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed", "Titan Micro Electronics"], "Image": "tm1637.jpeg", "Examples": { - "Java": ["TM1637Sample.java"], + "Java": ["TM1637_Example.java"], "Python": ["tm1637.py"], "Node.js": ["tm1637.js"], "C++": ["tm1637.cxx"] diff -Nru upm-1.6.0/src/tmp006/javaupm_tmp006.i upm-1.7.1/src/tmp006/javaupm_tmp006.i --- upm-1.6.0/src/tmp006/javaupm_tmp006.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tmp006/javaupm_tmp006.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_tmp006 -%include "../upm.i" - -%{ - #include "tmp006.hpp" -%} - -%include "tmp006.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_tmp006) \ No newline at end of file diff -Nru upm-1.6.0/src/tmp006/jsupm_tmp006.i upm-1.7.1/src/tmp006/jsupm_tmp006.i --- upm-1.6.0/src/tmp006/jsupm_tmp006.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tmp006/jsupm_tmp006.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_tmp006 -%include "../upm.i" - -%{ - #include "tmp006.hpp" -%} - -%include "tmp006.hpp" diff -Nru upm-1.6.0/src/tmp006/pyupm_tmp006.i upm-1.7.1/src/tmp006/pyupm_tmp006.i --- upm-1.6.0/src/tmp006/pyupm_tmp006.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tmp006/pyupm_tmp006.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_tmp006 -%include "../upm.i" - -%include "tmp006.hpp" -%{ - #include "tmp006.hpp" -%} diff -Nru upm-1.6.0/src/tsl2561/javaupm_tsl2561.i upm-1.7.1/src/tsl2561/javaupm_tsl2561.i --- upm-1.6.0/src/tsl2561/javaupm_tsl2561.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tsl2561/javaupm_tsl2561.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_tsl2561 -%include "../upm.i" - -%{ - #include "tsl2561.hpp" -%} - -%include "tsl2561.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_tsl2561) \ No newline at end of file diff -Nru upm-1.6.0/src/tsl2561/jsupm_tsl2561.i upm-1.7.1/src/tsl2561/jsupm_tsl2561.i --- upm-1.6.0/src/tsl2561/jsupm_tsl2561.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tsl2561/jsupm_tsl2561.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_tsl2561 -%include "../upm.i" - -%{ - #include "tsl2561.hpp" -%} - -%include "tsl2561.hpp" diff -Nru upm-1.6.0/src/tsl2561/pyupm_tsl2561.i upm-1.7.1/src/tsl2561/pyupm_tsl2561.i --- upm-1.6.0/src/tsl2561/pyupm_tsl2561.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tsl2561/pyupm_tsl2561.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_tsl2561 -%include "../upm.i" - -%include "tsl2561.hpp" -%{ - #include "tsl2561.hpp" -%} diff -Nru upm-1.6.0/src/tsl2561/tsl2561.json upm-1.7.1/src/tsl2561/tsl2561.json --- upm-1.6.0/src/tsl2561/tsl2561.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/tsl2561/tsl2561.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["eak"], "Image": "tsl2561.jpg", "Examples": { - "Java": ["TSL2561Sample.java", "Tsl2561.java"], + "Java": ["TSL2561_Example.java"], "Python": ["tsl2561.py"], "Node.js": ["tsl2561.js"], "C++": ["tsl2561.cxx"], diff -Nru upm-1.6.0/src/ttp223/javaupm_ttp223.i upm-1.7.1/src/ttp223/javaupm_ttp223.i --- upm-1.6.0/src/ttp223/javaupm_ttp223.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ttp223/javaupm_ttp223.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -%module (docstring="TTP223 Touch Sensor") javaupm_ttp223 - -%include "../upm.i" - -%apply int {mraa::Edge} - - -%{ - #include "ttp223.hpp" -%} - -%include "ttp223.hpp" - -#%ignore installISR(mraa::Edge , void *, void *) - -JAVA_ADD_INSTALLISR_EDGE(upm::TTP223) - -JAVA_JNI_LOADLIBRARY(javaupm_ttp223) diff -Nru upm-1.6.0/src/ttp223/jsupm_ttp223.i upm-1.7.1/src/ttp223/jsupm_ttp223.i --- upm-1.6.0/src/ttp223/jsupm_ttp223.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ttp223/jsupm_ttp223.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ttp223 -%include "../upm.i" - -%{ - #include "ttp223.hpp" -%} - -%include "ttp223.hpp" diff -Nru upm-1.6.0/src/ttp223/pyupm_ttp223.i upm-1.7.1/src/ttp223/pyupm_ttp223.i --- upm-1.6.0/src/ttp223/pyupm_ttp223.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ttp223/pyupm_ttp223.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ttp223 -%include "../upm.i" - -%include "ttp223.hpp" -%{ - #include "ttp223.hpp" -%} - diff -Nru upm-1.6.0/src/ttp223/ttp223.c upm-1.7.1/src/ttp223/ttp223.c --- upm-1.6.0/src/ttp223/ttp223.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ttp223/ttp223.c 2018-10-12 04:47:41.000000000 +0000 @@ -42,9 +42,7 @@ return NULL; } - dev->gpio_pin = pin; - - dev->gpio = mraa_gpio_init(dev->gpio_pin); + dev->gpio = mraa_gpio_init(pin); mraa_gpio_dir(dev->gpio, MRAA_GPIO_IN); dev->isr_installed = false; diff -Nru upm-1.6.0/src/ttp223/ttp223.h upm-1.7.1/src/ttp223/ttp223.h --- upm-1.6.0/src/ttp223/ttp223.h 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ttp223/ttp223.h 2018-10-12 04:47:41.000000000 +0000 @@ -46,7 +46,6 @@ */ typedef struct _ttp223_context { mraa_gpio_context gpio; - uint8_t gpio_pin; bool isr_installed; } *ttp223_context; diff -Nru upm-1.6.0/src/ttp223/ttp223.i upm-1.7.1/src/ttp223/ttp223.i --- upm-1.6.0/src/ttp223/ttp223.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ttp223/ttp223.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,20 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%module (docstring="TTP223 Touch Sensor") javaupm_ttp223 + +%apply int {mraa::Edge} + +JAVA_ADD_INSTALLISR_EDGE(upm::TTP223) + +JAVA_JNI_LOADLIBRARY(javaupm_ttp223) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ttp223.hpp" +%} +%include "ttp223.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/ttp223/ttp223.json upm-1.7.1/src/ttp223/ttp223.json --- upm-1.6.0/src/ttp223/ttp223.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ttp223/ttp223.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed"], "Image": "ttp223.jpg", "Examples": { - "Java": ["TTP223Sample.java"], + "Java": ["TTP223_Example.java"], "Python": ["ttp223.py"], "Node.js": ["ttp223.js"], "C++": ["ttp223.cxx"], diff -Nru upm-1.6.0/src/uartat/javaupm_uartat.i upm-1.7.1/src/uartat/javaupm_uartat.i --- upm-1.6.0/src/uartat/javaupm_uartat.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/uartat/javaupm_uartat.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_uartat -%include "../upm.i" -%include "std_string.i" -%include "stdint.i" -%include "typemaps.i" - -%include "uartat_defs.h" -%include "uartat.hpp" -%{ - #include "uartat.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_uartat) diff -Nru upm-1.6.0/src/uartat/jsupm_uartat.i upm-1.7.1/src/uartat/jsupm_uartat.i --- upm-1.6.0/src/uartat/jsupm_uartat.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/uartat/jsupm_uartat.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_uartat -%include "../upm.i" -%include "std_string.i" - -%include "uartat_defs.h" -%include "uartat.hpp" -%{ - #include "uartat.hpp" -%} diff -Nru upm-1.6.0/src/uartat/pyupm_uartat.i upm-1.7.1/src/uartat/pyupm_uartat.i --- upm-1.6.0/src/uartat/pyupm_uartat.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/uartat/pyupm_uartat.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_uartat -%include "../upm.i" -%include "std_string.i" - -%include "uartat_defs.h" -%include "uartat.hpp" -%{ - #include "uartat.hpp" -%} diff -Nru upm-1.6.0/src/uartat/uartat.c upm-1.7.1/src/uartat/uartat.c --- upm-1.6.0/src/uartat/uartat.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/uartat/uartat.c 2018-10-12 04:47:41.000000000 +0000 @@ -265,8 +265,7 @@ { memset(resp, 0, resp_len); - upm_clock_t clock; - upm_clock_init(&clock); + upm_clock_t clock = upm_clock_init(); size_t idx = 0; @@ -320,8 +319,7 @@ memset(resp, 0, resp_len); - upm_clock_t clock; - upm_clock_init(&clock); + upm_clock_t clock = upm_clock_init(); size_t idx = 0; diff -Nru upm-1.6.0/src/uartat/uartat.i upm-1.7.1/src/uartat/uartat.i --- upm-1.6.0/src/uartat/uartat.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/uartat/uartat.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_uartat) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "uartat_defs.h" +#include "uartat.hpp" +%} +%include "uartat_defs.h" +%include "uartat.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/uln200xa/javaupm_uln200xa.i upm-1.7.1/src/uln200xa/javaupm_uln200xa.i --- upm-1.6.0/src/uln200xa/javaupm_uln200xa.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/uln200xa/javaupm_uln200xa.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_uln200xa -%include "../upm.i" - -%include "uln200xa_defs.h" -%include "uln200xa.hpp" -%{ - #include "uln200xa.hpp" -%} - - -JAVA_JNI_LOADLIBRARY(javaupm_uln200xa) diff -Nru upm-1.6.0/src/uln200xa/jsupm_uln200xa.i upm-1.7.1/src/uln200xa/jsupm_uln200xa.i --- upm-1.6.0/src/uln200xa/jsupm_uln200xa.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/uln200xa/jsupm_uln200xa.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module jsupm_uln200xa -%include "../upm.i" - -%include "uln200xa_defs.h" -%include "uln200xa.hpp" -%{ - #include "uln200xa.hpp" -%} - diff -Nru upm-1.6.0/src/uln200xa/pyupm_uln200xa.i upm-1.7.1/src/uln200xa/pyupm_uln200xa.i --- upm-1.6.0/src/uln200xa/pyupm_uln200xa.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/uln200xa/pyupm_uln200xa.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_uln200xa -%include "../upm.i" - -%include "uln200xa_defs.h" -%include "uln200xa.hpp" -%{ - #include "uln200xa.hpp" -%} diff -Nru upm-1.6.0/src/uln200xa/uln200xa.i upm-1.7.1/src/uln200xa/uln200xa.i --- upm-1.6.0/src/uln200xa/uln200xa.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/uln200xa/uln200xa.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,15 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_uln200xa) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "uln200xa.hpp" +%} +%include "uln200xa_defs.h" +%include "uln200xa.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/uln200xa/uln200xa.json upm-1.7.1/src/uln200xa/uln200xa.json --- upm-1.6.0/src/uln200xa/uln200xa.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/uln200xa/uln200xa.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed"], "Image": "uln200xa.jpg", "Examples": { - "Java": ["ULN200XASample.java"], + "Java": ["ULN200XA_Example.java"], "Python": ["uln200xa.py"], "Node.js": ["uln200xa.js"], "C++": ["uln200xa.cxx"], diff -Nru upm-1.6.0/src/ultrasonic/javaupm_ultrasonic.i upm-1.7.1/src/ultrasonic/javaupm_ultrasonic.i --- upm-1.6.0/src/ultrasonic/javaupm_ultrasonic.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ultrasonic/javaupm_ultrasonic.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_ultrasonic -%include "../upm.i" - -%ignore signalISR; - -%{ - #include "ultrasonic.hpp" -%} - -%include "ultrasonic.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_ultrasonic) diff -Nru upm-1.6.0/src/ultrasonic/jsupm_ultrasonic.i upm-1.7.1/src/ultrasonic/jsupm_ultrasonic.i --- upm-1.6.0/src/ultrasonic/jsupm_ultrasonic.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ultrasonic/jsupm_ultrasonic.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_ultrasonic -%include "../upm.i" - -%{ - #include "ultrasonic.hpp" -%} - -%include "ultrasonic.hpp" diff -Nru upm-1.6.0/src/ultrasonic/pyupm_ultrasonic.i upm-1.7.1/src/ultrasonic/pyupm_ultrasonic.i --- upm-1.6.0/src/ultrasonic/pyupm_ultrasonic.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ultrasonic/pyupm_ultrasonic.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ultrasonic -%include "../upm.i" - -%include "ultrasonic.hpp" -%{ - #include "ultrasonic.hpp" -%} diff -Nru upm-1.6.0/src/ultrasonic/ultrasonic.cxx upm-1.7.1/src/ultrasonic/ultrasonic.cxx --- upm-1.6.0/src/ultrasonic/ultrasonic.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/ultrasonic/ultrasonic.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -44,7 +44,6 @@ fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", pin); exit (1); } - mraa_gpio_use_mmaped(m_pinCtx, 1); mraa_gpio_isr (m_pinCtx, MRAA_GPIO_EDGE_BOTH, &signalISR, this); } diff -Nru upm-1.6.0/src/ultrasonic/ultrasonic.i upm-1.7.1/src/ultrasonic/ultrasonic.i --- upm-1.6.0/src/ultrasonic/ultrasonic.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/ultrasonic/ultrasonic.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore signalISR; + +JAVA_JNI_LOADLIBRARY(javaupm_ultrasonic) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "ultrasonic.hpp" +%} +%include "ultrasonic.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/upm_exception.i upm-1.7.1/src/upm_exception.i --- upm-1.6.0/src/upm_exception.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/upm_exception.i 2018-10-12 04:47:41.000000000 +0000 @@ -1,65 +1,63 @@ -/* Standardized exception handling for UPM +/* Standardized exception handling for UPM * * catch blocks should be listed in order from most specific to least * specific. */ +%{#include %} %include "exception.i" -%exception { - try { - $action - } catch (std::invalid_argument& e) { - std::string s1("UPM Invalid Argument: "), s2(e.what()); - s1 = s1 + s2; - SWIG_exception(SWIG_ValueError, s1.c_str()); - - } catch (std::domain_error& e) { - std::string s1("UPM Domain Error: "), s2(e.what()); - s1 = s1 + s2; - SWIG_exception(SWIG_ValueError, s1.c_str() ); - - } catch (std::overflow_error& e) { - std::string s1("UPM Overflow Error: "), s2(e.what()); - s1 = s1 + s2; - SWIG_exception(SWIG_OverflowError, s1.c_str() ); - - } catch (std::out_of_range& e) { - std::string s1("UPM Out of Range: "), s2(e.what()); - s1 = s1 + s2; - SWIG_exception(SWIG_IndexError, s1.c_str() ); - - } catch (std::length_error& e) { - std::string s1("UPM Length Error: "), s2(e.what()); - s1 = s1 + s2; - SWIG_exception(SWIG_IndexError, s1.c_str() ); - - } catch (std::logic_error& e) { - std::string s1("UPM Logic Error: "), s2(e.what()); - s1 = s1 + s2; - SWIG_exception(SWIG_RuntimeError, s1.c_str() ); - - } catch (std::bad_alloc& e) { - /* for an allocation exception, don't try to create a string... */ - SWIG_exception(SWIG_MemoryError, e.what() ); - - } catch (std::runtime_error& e) { - /* catch other std::runtime_error exceptions here */ - std::string s1("UPM Runtime Error: "), s2(e.what()); - s1 = s1 + s2; - SWIG_exception(SWIG_RuntimeError, s1.c_str()); - - } catch (std::exception& e) { - /* catch other std::exceptions here */ - std::string s1("UPM Error: "), s2(e.what()); - s1 = s1 + s2; - SWIG_exception(SWIG_SystemError, s1.c_str() ); - - } catch (...) { - /* catch everything else */ - SWIG_exception(SWIG_UnknownError, "UPM Unknown exception" ); - - } - +%exception { +try { + $action +} catch (std::invalid_argument& e) { + std::string s1("UPM Invalid Argument: "), s2(e.what()); + s1 = s1 + s2; + SWIG_exception(SWIG_ValueError, s1.c_str()); + +} catch (std::domain_error& e) { + std::string s1("UPM Domain Error: "), s2(e.what()); + s1 = s1 + s2; + SWIG_exception(SWIG_ValueError, s1.c_str() ); + +} catch (std::overflow_error& e) { + std::string s1("UPM Overflow Error: "), s2(e.what()); + s1 = s1 + s2; + SWIG_exception(SWIG_OverflowError, s1.c_str() ); + +} catch (std::out_of_range& e) { + std::string s1("UPM Out of Range: "), s2(e.what()); + s1 = s1 + s2; + SWIG_exception(SWIG_IndexError, s1.c_str() ); + +} catch (std::length_error& e) { + std::string s1("UPM Length Error: "), s2(e.what()); + s1 = s1 + s2; + SWIG_exception(SWIG_IndexError, s1.c_str() ); + +} catch (std::logic_error& e) { + std::string s1("UPM Logic Error: "), s2(e.what()); + s1 = s1 + s2; + SWIG_exception(SWIG_RuntimeError, s1.c_str() ); + +} catch (std::bad_alloc& e) { + /* for an allocation exception, don't try to create a string... */ + SWIG_exception(SWIG_MemoryError, e.what() ); + +} catch (std::runtime_error& e) { + /* catch other std::runtime_error exceptions here */ + std::string s1("UPM Runtime Error: "), s2(e.what()); + s1 = s1 + s2; + SWIG_exception(SWIG_RuntimeError, s1.c_str()); + +} catch (std::exception& e) { + /* catch other std::exceptions here */ + std::string s1("UPM Error: "), s2(e.what()); + s1 = s1 + s2; + SWIG_exception(SWIG_SystemError, s1.c_str() ); + +} catch (...) { + /* catch everything else */ + SWIG_exception(SWIG_UnknownError, "UPM Unknown exception" ); +} } - diff -Nru upm-1.6.0/src/_upm.i upm-1.7.1/src/_upm.i --- upm-1.6.0/src/_upm.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/_upm.i 2018-10-12 04:47:41.000000000 +0000 @@ -1,7 +1,7 @@ /* * This file provides additional non-wrapper code functionality for use * throughout the UPM repository. This file is intended to be %imported - * from the top-level upm.i (not directly by UPM libraries). + * from the top-level common_top.i (not directly by UPM libraries). * * No wrapper code will be generated from importing this .i file. */ diff -Nru upm-1.6.0/src/upm.i upm-1.7.1/src/upm.i --- upm-1.6.0/src/upm.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/upm.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -%include "std_string.i" -%include "stdint.i" -%include "upm_exception.i" - -/* Import additional SWIG helps (not exposed in wrapper) */ -%import _upm.i - -%{ -#include "version.hpp" -%} -%include "version.hpp" - -%apply int { speed_t }; -%apply int { mraa_result_t }; -%apply int { mraa::Result }; -%apply int { upm_result_t }; - -#if (SWIG_JAVASCRIPT_V8) -%{ -/* Because there's no guarantee that v8 will ever call garbage collection, - * we're adding a function that will allow a user to call it manually - */ -void cleanUp() -{ - /* Call the v8 garbage collector as long as there is memory to clean up - * See https://codereview.chromium.org/412163003 for this API change - */ -#if (SWIG_V8_VERSION < 0x032838) - while (!v8::V8::IdleNotification()) -#else - while (!v8::Isolate::GetCurrent()->IdleNotification(1000)) -#endif - {;} -} -%} -void cleanUp(); -#endif - -#if (SWIGJAVA) -%typemap(jtype) jobject runnable "java.lang.Runnable" -%typemap(jstype) jobject runnable "java.lang.Runnable" -#endif - -// Disable nested struct warnings -#pragma SWIG nowarn=312,325 diff -Nru upm-1.6.0/src/urm37/javaupm_urm37.i upm-1.7.1/src/urm37/javaupm_urm37.i --- upm-1.6.0/src/urm37/javaupm_urm37.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/urm37/javaupm_urm37.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_urm37 -%include "../upm.i" -%include "std_string.i" - -%{ - #include "urm37.hpp" -%} - -%include "urm37.hpp" - - -JAVA_JNI_LOADLIBRARY(javaupm_urm37) \ No newline at end of file diff -Nru upm-1.6.0/src/urm37/jsupm_urm37.i upm-1.7.1/src/urm37/jsupm_urm37.i --- upm-1.6.0/src/urm37/jsupm_urm37.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/urm37/jsupm_urm37.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_urm37 -%include "../upm.i" -%include "std_string.i" - -%{ - #include "urm37.hpp" -%} - -%include "urm37.hpp" - diff -Nru upm-1.6.0/src/urm37/pyupm_urm37.i upm-1.7.1/src/urm37/pyupm_urm37.i --- upm-1.6.0/src/urm37/pyupm_urm37.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/urm37/pyupm_urm37.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_urm37 -%include "../upm.i" -%include "std_string.i" - -%{ - #include "urm37.hpp" -%} -%include "urm37.hpp" - diff -Nru upm-1.6.0/src/urm37/urm37.i upm-1.7.1/src/urm37/urm37.i --- upm-1.6.0/src/urm37/urm37.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/urm37/urm37.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_urm37) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "urm37.hpp" +%} +%include "urm37.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/utilities/CMakeLists.txt upm-1.7.1/src/utilities/CMakeLists.txt --- upm-1.6.0/src/utilities/CMakeLists.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/utilities/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -3,4 +3,5 @@ CPP_HDR upm_utilities.hpp CPP_SRC upm_utilities.cxx C_HDR upm_utilities.h - C_SRC upm_utilities.c) + C_SRC upm_utilities.c + CPP_WRAPS_C) diff -Nru upm-1.6.0/src/utilities/javaupm_utilities.i upm-1.7.1/src/utilities/javaupm_utilities.i --- upm-1.6.0/src/utilities/javaupm_utilities.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/utilities/javaupm_utilities.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_utilities - -%pragma(java) jniclasscode=%{ - static { - try { - System.loadLibrary("javaupm_utilities"); - } catch (UnsatisfiedLinkError e) { - System.err.println("Native code library failed to load. \n" + e); - System.exit(1); - } - } -%} diff -Nru upm-1.6.0/src/utilities/jsupm_utilities.i upm-1.7.1/src/utilities/jsupm_utilities.i --- upm-1.6.0/src/utilities/jsupm_utilities.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/utilities/jsupm_utilities.i 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -%module jsupm_utilities diff -Nru upm-1.6.0/src/utilities/pyupm_utilities.i upm-1.7.1/src/utilities/pyupm_utilities.i --- upm-1.6.0/src/utilities/pyupm_utilities.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/utilities/pyupm_utilities.i 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -%module pyupm_utilities diff -Nru upm-1.6.0/src/utilities/upm_utilities.c upm-1.7.1/src/utilities/upm_utilities.c --- upm-1.6.0/src/utilities/upm_utilities.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/utilities/upm_utilities.c 2018-10-12 04:47:41.000000000 +0000 @@ -26,48 +26,54 @@ */ #ifndef _POSIX_C_SOURCE -// We need at least 199309L for nanosleep() +// We need at least 199309L for clock_nanosleep() # define _POSIX_C_SOURCE 200809L #endif +#include #include #include #include "upm_platform.h" #include "upm_utilities.h" -// https://www3.epa.gov/airnow/aqi-technical-assistance-document-may2016.pdf -static struct aqi { - float clow; - float chigh; - int llow; - int lhigh; -} aqi[] = { - {0.0, 12.0, 0, 50}, - {12.1, 35.4, 51, 100}, - {35.5, 55.4, 101, 150}, - {55.5, 150.4, 151, 200}, - {150.5, 250.4, 201, 300}, - {250.5, 350.4, 301, 400}, - {350.5, 500.4, 401, 500}, -}; -void upm_delay(unsigned int time) +/** + * Calculate the delta of two upm_clock_t values as + * delta = finish - start + * + * @param finish Ending upm_clock_t time + * @param start Beginning upm_clock_t time + * @return Time in nanoseconds + */ +static uint64_t _delta_ns(const upm_clock_t* finish, const upm_clock_t* start) { - if (time <= 0) - time = 1; + uint64_t delta; + assert((finish != NULL) && (start != NULL) && "_delta_ns, arguments cannot be NULL"); -#if defined(UPM_PLATFORM_LINUX) +#if defined(UPM_PLATFORM_ZEPHYR) + delta = SYS_CLOCK_HW_CYCLES_TO_NS64(*finish - *start); +#elif defined(UPM_PLATFORM_LINUX) + + delta = (finish->tv_sec * 1000000000UL + finish->tv_nsec) - + (start->tv_sec * 1000000000UL + start->tv_nsec); +#else +#error "Unknown platform, valid platforms are {UPM_PLATFORM_ZEPHYR, UPM_PLATFORM_LINUX}" +#endif + return delta; +} - struct timespec delay_time; +void upm_delay(uint32_t time) +{ + /* Return if time == 0 */ + if (!time) + return; - delay_time.tv_sec = time; - delay_time.tv_nsec = 0; - // The advantage over sleep(3) here is that it will not use - // an alarm signal or handler. +#if defined(UPM_PLATFORM_LINUX) + + upm_clock_t delay_time = {time, 0}; // here we spin until the delay is complete - detecting signals // and continuing where we left off - while (nanosleep(&delay_time, &delay_time) && errno == EINTR) - ; // loop + while (clock_nanosleep(CLOCK_MONOTONIC, 0, &delay_time, &delay_time) == EINTR); #elif defined(UPM_PLATFORM_ZEPHYR) # if KERNEL_VERSION_MAJOR == 1 && KERNEL_VERSION_MINOR >= 6 @@ -87,24 +93,24 @@ # endif +#else +#error "Unknown platform, valid platforms are {UPM_PLATFORM_ZEPHYR, UPM_PLATFORM_LINUX}" #endif } -void upm_delay_ms(unsigned int time) +void upm_delay_ms(uint32_t time) { - if (time <= 0) - time = 1; + /* Return if time == 0 */ + if (!time) + return; #if defined(UPM_PLATFORM_LINUX) - struct timespec delay_time; + upm_clock_t delay_time = {time / 1000, (time % 1000) * 1000000UL}; - delay_time.tv_sec = time / 1000; - delay_time.tv_nsec = (time % 1000) * 1000000; // here we spin until the delay is complete - detecting signals // and continuing where we left off - while (nanosleep(&delay_time, &delay_time) && errno == EINTR) - ; // loop + while (clock_nanosleep(CLOCK_MONOTONIC, 0, &delay_time, &delay_time) == EINTR); #elif defined(UPM_PLATFORM_ZEPHYR) # if KERNEL_VERSION_MAJOR == 1 && KERNEL_VERSION_MINOR >= 6 @@ -123,34 +129,32 @@ nano_timer_test(&timer, TICKS_UNLIMITED); # endif +#else +#error "Unknown platform, valid platforms are {UPM_PLATFORM_ZEPHYR, UPM_PLATFORM_LINUX}" #endif } -void upm_delay_us(unsigned int time) +void upm_delay_us(uint32_t time) { - if (time <= 0) - time = 1; + /* Return if time == 0 */ + if (!time) + return; #if defined(UPM_PLATFORM_LINUX) - struct timespec delay_time; + upm_clock_t delay_time = {time / 1000000, (time % 1000000) * 1000}; - delay_time.tv_sec = time / 1000000; - delay_time.tv_nsec = (time % 1000000) * 1000; // here we spin until the delay is complete - detecting signals // and continuing where we left off - while (nanosleep(&delay_time, &delay_time) && errno == EINTR) - ; // loop + while (clock_nanosleep(CLOCK_MONOTONIC, 0, &delay_time, &delay_time) == EINTR); #elif defined(UPM_PLATFORM_ZEPHYR) # if KERNEL_VERSION_MAJOR == 1 && KERNEL_VERSION_MINOR >= 6 // we will use a upm_clock to do microsecond timings here as k_timer has // only a millisecond resolution. So we init a clock and spin. - upm_clock_t timer; - upm_clock_init(&timer); - while (upm_elapsed_us(&timer) < time) - ; // spin + upm_clock_t timer = upm_clock_init(); + while (upm_elapsed_us(&timer) < time); // spin # else @@ -162,109 +166,129 @@ # endif +#else +#error "Unknown platform, valid platforms are {UPM_PLATFORM_ZEPHYR, UPM_PLATFORM_LINUX}" #endif } -void upm_clock_init(upm_clock_t *clock) +void upm_delay_ns(uint64_t time) { -#if defined(UPM_PLATFORM_LINUX) - - gettimeofday(clock, NULL); - -#elif defined(UPM_PLATFORM_ZEPHYR) - *clock = sys_cycle_get_32(); -#endif -} + /* Return if time == 0 */ + if (!time) + return; -uint32_t upm_elapsed_ms(upm_clock_t *clock) -{ #if defined(UPM_PLATFORM_LINUX) - struct timeval elapsed, now; - uint32_t elapse; - - // get current time - gettimeofday(&now, NULL); + upm_clock_t delay_time = {time / 1000000000UL, time % 1000000000UL}; - struct timeval startTime = *clock; - - // compute the delta since startTime - if( (elapsed.tv_usec = now.tv_usec - startTime.tv_usec) < 0 ) - { - elapsed.tv_usec += 1000000; - elapsed.tv_sec = now.tv_sec - startTime.tv_sec - 1; - } - else - { - elapsed.tv_sec = now.tv_sec - startTime.tv_sec; - } - - elapse = (uint32_t)((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000)); + // here we spin until the delay is complete - detecting signals + // and continuing where we left off + while (clock_nanosleep(CLOCK_MONOTONIC, 0, &delay_time, &delay_time) == EINTR); - // never return 0 - if (elapse == 0) - elapse = 1; +#elif defined(UPM_PLATFORM_ZEPHYR) +# if KERNEL_VERSION_MAJOR == 1 && KERNEL_VERSION_MINOR >= 6 + // we will use a upm_clock to do microsecond timings here as k_timer has + // only a millisecond resolution. So we init a clock and spin. - return elapse; + upm_clock_t timer = upm_clock_init(); + while (upm_elapsed_ns(&timer) < time); // spin -#elif defined(UPM_PLATFORM_ZEPHYR) - uint32_t now = sys_cycle_get_32(); +# else - uint32_t elapsed = - (uint32_t)(SYS_CLOCK_HW_CYCLES_TO_NS64(now - *clock)/(uint64_t)1000000); + struct nano_timer timer; + void *timer_data[1]; + nano_timer_init(&timer, timer_data); + nano_timer_start(&timer, time + 1); + nano_timer_test(&timer, TICKS_UNLIMITED); - if (elapsed == 0) - elapsed = 1; +# endif - return elapsed; +#else +#error "Unknown platform, valid platforms are {UPM_PLATFORM_ZEPHYR, UPM_PLATFORM_LINUX}" #endif } -uint32_t upm_elapsed_us(upm_clock_t *clock) +upm_clock_t upm_clock_init(void) { + upm_clock_t clock = {0}; #if defined(UPM_PLATFORM_LINUX) + clock_gettime(CLOCK_MONOTONIC, &clock); +#elif defined(UPM_PLATFORM_ZEPHYR) + clock = sys_cycle_get_32(); +#else +#error "Unknown platform, valid platforms are {UPM_PLATFORM_ZEPHYR, UPM_PLATFORM_LINUX}" +#endif - struct timeval elapsed, now; - uint32_t elapse; + return clock; +} - // get current time - gettimeofday(&now, NULL); +uint64_t upm_elapsed_ms(const upm_clock_t *clock) +{ + assert((clock != NULL) && "upm_elapsed_ms, clock cannot be NULL"); - struct timeval startTime = *clock; + upm_clock_t now = {0}; - // compute the delta since startTime - if( (elapsed.tv_usec = now.tv_usec - startTime.tv_usec) < 0 ) - { - elapsed.tv_usec += 1000000; - elapsed.tv_sec = now.tv_sec - startTime.tv_sec - 1; - } - else - { - elapsed.tv_sec = now.tv_sec - startTime.tv_sec; - } +#if defined(UPM_PLATFORM_LINUX) + clock_gettime(CLOCK_MONOTONIC, &now); +#elif defined(UPM_PLATFORM_ZEPHYR) + now = sys_cycle_get_32(); +#else +#error "Unknown platform, valid platforms are {UPM_PLATFORM_ZEPHYR, UPM_PLATFORM_LINUX}" +#endif - elapse = (uint32_t)((elapsed.tv_sec * 1000000) + elapsed.tv_usec); + return _delta_ns(&now, clock)/1000000; +} - // never return 0 - if (elapse == 0) - elapse = 1; +uint64_t upm_elapsed_us(const upm_clock_t *clock) +{ + assert((clock != NULL) && "upm_elapsed_us, clock cannot be NULL"); - return elapse; + upm_clock_t now = {0}; +#if defined(UPM_PLATFORM_LINUX) + clock_gettime(CLOCK_MONOTONIC, &now); #elif defined(UPM_PLATFORM_ZEPHYR) - uint32_t now = sys_cycle_get_32(); + now = sys_cycle_get_32(); +#else +#error "Unknown platform, valid platforms are {UPM_PLATFORM_ZEPHYR, UPM_PLATFORM_LINUX}" +#endif - uint32_t elapsed = - (uint32_t)(SYS_CLOCK_HW_CYCLES_TO_NS64(now - *clock)/(uint64_t)1000); + return _delta_ns(&now, clock)/1000; +} + +uint64_t upm_elapsed_ns(const upm_clock_t *clock) +{ + assert((clock != NULL) && "upm_elapsed_ns, clock cannot be NULL"); - // never return 0 - if (elapsed == 0) - elapsed = 1; + upm_clock_t now = {0}; - return elapsed; +#if defined(UPM_PLATFORM_LINUX) + clock_gettime(CLOCK_MONOTONIC, &now); +#elif defined(UPM_PLATFORM_ZEPHYR) + now = sys_cycle_get_32(); +#else +#error "Unknown platform, valid platforms are {UPM_PLATFORM_ZEPHYR, UPM_PLATFORM_LINUX}" #endif + + return _delta_ns(&now, clock); } +// https://www3.epa.gov/airnow/aqi-technical-assistance-document-may2016.pdf +static struct aqi { + float clow; + float chigh; + int llow; + int lhigh; +} aqi[] = { + {0.0, 12.0, 0, 50}, + {12.1, 35.4, 51, 100}, + {35.5, 55.4, 101, 150}, + {55.5, 150.4, 151, 200}, + {150.5, 250.4, 201, 300}, + {250.5, 350.4, 301, 400}, + {350.5, 500.4, 401, 500}, +}; + int upm_ugm3_to_aqi (double ugm3) { int i; diff -Nru upm-1.6.0/src/utilities/upm_utilities.h upm-1.7.1/src/utilities/upm_utilities.h --- upm-1.6.0/src/utilities/upm_utilities.h 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/utilities/upm_utilities.h 2018-10-12 04:47:41.000000000 +0000 @@ -40,7 +40,7 @@ #include #include -typedef struct timeval upm_clock_t; +typedef struct timespec upm_clock_t; #endif /* UPM_PLATFORM_LINUX */ #if defined(UPM_PLATFORM_ZEPHYR) @@ -58,38 +58,55 @@ #define PRINT printk #endif -typedef uint32_t upm_clock_t; +typedef uint64_t upm_clock_t; #endif /* UPM_PLATFORM_ZEPHYR */ /** - * Delay for a number of seconds + * Delay for a number of seconds (s) * * @param time The number of seconds to delay for */ -void upm_delay(unsigned int time); +void upm_delay(uint32_t time); /** - * Delay for a number of milliseconds + * Delay for a number of milliseconds (ms) * * @param time The number of milliseconds to delay for */ -void upm_delay_ms(unsigned int time); +void upm_delay_ms(uint32_t time); /** - * Delay for a number of microseconds + * Delay for a number of microseconds (us) * * @param time The number of microseconds to delay for */ -void upm_delay_us(unsigned int time); +void upm_delay_us(uint32_t time); + +/** + * Delay for a number of nanoseconds (ns) + * + * Note, sub-microsecond accurate time on *nix is generally not available OOB + * and high resolution times are also not supported on all HW architectures. + * + * @param time The number of nanoseconds to delay for + */ +void upm_delay_ns(uint64_t time); /** * Initialize a clock. This can be used with upm_elapsed_ms() and * upm_elapsed_us() for measuring a duration. * - * @param clock The upm_clock_t to initialize to the current time + * For *nix operating systems, this initializes a MONOTONIC clock. + * + * Example: + * upm_clock_t start = upm_clock_init(); + * ... do stuff ... + * uint64_t delta_ns = upm_elapsed_us(&start); + * + * @return The upm_clock_t initialized to the current time */ -void upm_clock_init(upm_clock_t *clock); +upm_clock_t upm_clock_init(void); /** * Return the elapsed time in milliseconds since upm_init_clock() was @@ -99,7 +116,7 @@ * @return the number of milliseconds elapsed since upm_init_clock() * was called on the clock parameter. */ -uint32_t upm_elapsed_ms(upm_clock_t *clock); +uint64_t upm_elapsed_ms(const upm_clock_t *clock); /** * Return the elapsed time in microseconds since upm_init_clock() was @@ -109,7 +126,20 @@ * @return the number of microseconds elapsed since upm_init_clock() * was called on the clock parameter. */ -uint32_t upm_elapsed_us(upm_clock_t *clock); +uint64_t upm_elapsed_us(const upm_clock_t *clock); + +/** + * Return the elapsed time in nanoseconds since upm_init_clock() was + * last called. + * + * Note, sub-microsecond accurate time on *nix is generally not available OOB + * and high resolution times are also not supported on all HW architectures. + * + * @param clock A upm_clock_t initialized by upm_init_clock() + * @return the number of nanoseconds elapsed since upm_init_clock() + * was called on the clock parameter. + */ +uint64_t upm_elapsed_ns(const upm_clock_t *clock); /** * Return the AQI (based on EPA standards) using the ugm3 value diff -Nru upm-1.6.0/src/utilities/utilities.i upm-1.7.1/src/utilities/utilities.i --- upm-1.6.0/src/utilities/utilities.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/utilities/utilities.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_utilities) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "upm_utilities.hpp" +%} +%include "upm_utilities.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/vcap/javaupm_vcap.i upm-1.7.1/src/vcap/javaupm_vcap.i --- upm-1.6.0/src/vcap/javaupm_vcap.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/vcap/javaupm_vcap.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_vcap -%include "../upm.i" -%include "std_string.i" - -%include "vcap.hpp" -%{ - #include "vcap.hpp" -%} - -JAVA_JNI_LOADLIBRARY(javaupm_vcap) diff -Nru upm-1.6.0/src/vcap/jsupm_vcap.i upm-1.7.1/src/vcap/jsupm_vcap.i --- upm-1.6.0/src/vcap/jsupm_vcap.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/vcap/jsupm_vcap.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_vcap -%include "../upm.i" -%include "std_string.i" - -%include "vcap.hpp" -%{ - #include "vcap.hpp" -%} - - diff -Nru upm-1.6.0/src/vcap/pyupm_vcap.i upm-1.7.1/src/vcap/pyupm_vcap.i --- upm-1.6.0/src/vcap/pyupm_vcap.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/vcap/pyupm_vcap.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_vcap -%include "../upm.i" -%include "std_string.i" - -%include "vcap.hpp" -%{ - #include "vcap.hpp" -%} - - diff -Nru upm-1.6.0/src/vcap/vcap.i upm-1.7.1/src/vcap/vcap.i --- upm-1.6.0/src/vcap/vcap.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/vcap/vcap.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_vcap) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "vcap.hpp" +%} +%include "vcap.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/vdiv/javaupm_vdiv.i upm-1.7.1/src/vdiv/javaupm_vdiv.i --- upm-1.6.0/src/vdiv/javaupm_vdiv.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/vdiv/javaupm_vdiv.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_vdiv -%include "../upm.i" - -%{ - #include "vdiv.hpp" -%} - -%include "vdiv.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_vdiv) \ No newline at end of file diff -Nru upm-1.6.0/src/vdiv/jsupm_vdiv.i upm-1.7.1/src/vdiv/jsupm_vdiv.i --- upm-1.6.0/src/vdiv/jsupm_vdiv.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/vdiv/jsupm_vdiv.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_vdiv -%include "../upm.i" - -%{ - #include "vdiv.hpp" -%} - -%include "vdiv.hpp" diff -Nru upm-1.6.0/src/vdiv/pyupm_vdiv.i upm-1.7.1/src/vdiv/pyupm_vdiv.i --- upm-1.6.0/src/vdiv/pyupm_vdiv.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/vdiv/pyupm_vdiv.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_vdiv -%include "../upm.i" - -%include "vdiv.hpp" -%{ - #include "vdiv.hpp" -%} diff -Nru upm-1.6.0/src/vdiv/vdiv.json upm-1.7.1/src/vdiv/vdiv.json --- upm-1.6.0/src/vdiv/vdiv.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/vdiv/vdiv.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["robok"], "Image": "vdiv.jpg", "Examples": { - "Java": ["VDivSample.java"], + "Java": ["VDiv_Example.java"], "Python": ["vdiv.py"], "Node.js": ["vdiv.js"], "C++": ["vdiv.cxx"], diff -Nru upm-1.6.0/src/veml6070/javaupm_veml6070.i upm-1.7.1/src/veml6070/javaupm_veml6070.i --- upm-1.6.0/src/veml6070/javaupm_veml6070.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/veml6070/javaupm_veml6070.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module javaupm_veml6070 -%include "../upm.i" -%include "stdint.i" -%include "typemaps.i" - -%{ - #include "veml6070.hpp" -%} -%include "veml6070.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_veml6070) diff -Nru upm-1.6.0/src/veml6070/jsupm_veml6070.i upm-1.7.1/src/veml6070/jsupm_veml6070.i --- upm-1.6.0/src/veml6070/jsupm_veml6070.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/veml6070/jsupm_veml6070.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_veml6070 -%include "../upm.i" - -%{ - #include "veml6070.hpp" -%} - -%include "veml6070.hpp" diff -Nru upm-1.6.0/src/veml6070/pyupm_veml6070.i upm-1.7.1/src/veml6070/pyupm_veml6070.i --- upm-1.6.0/src/veml6070/pyupm_veml6070.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/veml6070/pyupm_veml6070.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_veml6070 -%include "../upm.i" - -%include "veml6070.hpp" -%{ - #include "veml6070.hpp" -%} diff -Nru upm-1.6.0/src/veml6070/veml6070.i upm-1.7.1/src/veml6070/veml6070.i --- upm-1.6.0/src/veml6070/veml6070.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/veml6070/veml6070.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,14 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_veml6070) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "veml6070.hpp" +%} +%include "veml6070.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/veml6070/veml6070.json upm-1.7.1/src/veml6070/veml6070.json --- upm-1.6.0/src/veml6070/veml6070.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/veml6070/veml6070.json 2018-10-12 04:47:41.000000000 +0000 @@ -11,7 +11,7 @@ "Project Type": ["prototyping", "commercial"], "Manufacturers": ["Vishay", "Adafruit"], "Examples": { - "Java": ["VEML6070Sample.java"], + "Java": ["VEML6070_Example.java"], "Python": ["veml6070.py"], "Node.js": ["veml6070.js"], "C++": ["veml6070.cxx"], diff -Nru upm-1.6.0/src/water/javaupm_water.i upm-1.7.1/src/water/javaupm_water.i --- upm-1.6.0/src/water/javaupm_water.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/water/javaupm_water.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_water -%include "../upm.i" - -%{ - #include "water.hpp" -%} - -%include "water.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_water) \ No newline at end of file diff -Nru upm-1.6.0/src/water/jsupm_water.i upm-1.7.1/src/water/jsupm_water.i --- upm-1.6.0/src/water/jsupm_water.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/water/jsupm_water.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_water -%include "../upm.i" - -%{ - #include "water.hpp" -%} - -%include "water.hpp" diff -Nru upm-1.6.0/src/water/pyupm_water.i upm-1.7.1/src/water/pyupm_water.i --- upm-1.6.0/src/water/pyupm_water.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/water/pyupm_water.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_water -%include "../upm.i" - -%include "water.hpp" -%{ - #include "water.hpp" -%} diff -Nru upm-1.6.0/src/water/water.json upm-1.7.1/src/water/water.json --- upm-1.6.0/src/water/water.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/water/water.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["eak"], "Image": "water.jpg", "Examples": { - "Java": ["WaterSample.java"], + "Java": ["Water_Example.java"], "Python": ["water.py"], "Node.js": ["water.js"], "C++": ["water.cxx"], diff -Nru upm-1.6.0/src/waterlevel/javaupm_waterlevel.i upm-1.7.1/src/waterlevel/javaupm_waterlevel.i --- upm-1.6.0/src/waterlevel/javaupm_waterlevel.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/waterlevel/javaupm_waterlevel.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_waterlevel -%include "../upm.i" - -%{ - #include "waterlevel.hpp" -%} - -%include "waterlevel.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_waterlevel) \ No newline at end of file diff -Nru upm-1.6.0/src/waterlevel/jsupm_waterlevel.i upm-1.7.1/src/waterlevel/jsupm_waterlevel.i --- upm-1.6.0/src/waterlevel/jsupm_waterlevel.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/waterlevel/jsupm_waterlevel.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_waterlevel -%include "../upm.i" - -%{ - #include "waterlevel.hpp" -%} - -%include "waterlevel.hpp" diff -Nru upm-1.6.0/src/waterlevel/pyupm_waterlevel.i upm-1.7.1/src/waterlevel/pyupm_waterlevel.i --- upm-1.6.0/src/waterlevel/pyupm_waterlevel.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/waterlevel/pyupm_waterlevel.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_waterlevel -%include "../upm.i" - -%include "waterlevel.hpp" -%{ - #include "waterlevel.hpp" -%} diff -Nru upm-1.6.0/src/waterlevel/waterlevel.json upm-1.7.1/src/waterlevel/waterlevel.json --- upm-1.6.0/src/waterlevel/waterlevel.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/waterlevel/waterlevel.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed"], "Image": "waterlevel.jpg", "Examples": { - "Java": ["WaterLevelSensor.java"], + "Java": ["WaterLevelSensor_Example.java"], "Python": ["waterlevel.py"], "Node.js": ["waterlevel.js"], "C++": ["waterlevel.cxx"] diff -Nru upm-1.6.0/src/wfs/javaupm_wfs.i upm-1.7.1/src/wfs/javaupm_wfs.i --- upm-1.6.0/src/wfs/javaupm_wfs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wfs/javaupm_wfs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module javaupm_wfs -%include "../upm.i" - -%ignore flowISR; - -%{ - #include "wfs.hpp" -%} - -%include "wfs.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_wfs) diff -Nru upm-1.6.0/src/wfs/jsupm_wfs.i upm-1.7.1/src/wfs/jsupm_wfs.i --- upm-1.6.0/src/wfs/jsupm_wfs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wfs/jsupm_wfs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_wfs -%include "../upm.i" - -%{ - #include "wfs.hpp" -%} - -%include "wfs.hpp" diff -Nru upm-1.6.0/src/wfs/pyupm_wfs.i upm-1.7.1/src/wfs/pyupm_wfs.i --- upm-1.6.0/src/wfs/pyupm_wfs.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wfs/pyupm_wfs.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_wfs -%include "../upm.i" - -%include "wfs.hpp" -%{ - #include "wfs.hpp" -%} diff -Nru upm-1.6.0/src/wfs/wfs.c upm-1.7.1/src/wfs/wfs.c --- upm-1.6.0/src/wfs/wfs.c 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wfs/wfs.c 2018-10-12 04:47:41.000000000 +0000 @@ -88,7 +88,7 @@ { assert(dev != NULL); - upm_clock_init(&dev->clock); + dev->clock = upm_clock_init(); } uint32_t wfs_get_millis(const wfs_context dev) diff -Nru upm-1.6.0/src/wfs/wfs.i upm-1.7.1/src/wfs/wfs.i --- upm-1.6.0/src/wfs/wfs.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/wfs/wfs.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%ignore flowISR; + +JAVA_JNI_LOADLIBRARY(javaupm_wfs) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%{ +#include "wfs.hpp" +%} +%include "wfs.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/wfs/wfs.json upm-1.7.1/src/wfs/wfs.json --- upm-1.6.0/src/wfs/wfs.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wfs/wfs.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["eak"], "Image": "wfs.jpg", "Examples": { - "Java": ["WFSSample.java"], + "Java": ["WFS_Example.java"], "Python": ["wfs.py"], "Node.js": ["wfs.js"], "C++": ["wfs.cxx"], diff -Nru upm-1.6.0/src/wheelencoder/javaupm_wheelencoder.i upm-1.7.1/src/wheelencoder/javaupm_wheelencoder.i --- upm-1.6.0/src/wheelencoder/javaupm_wheelencoder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wheelencoder/javaupm_wheelencoder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_wheelencoder -%include "../upm.i" - -%{ - #include "wheelencoder.hpp" -%} - -%include "wheelencoder.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_wheelencoder) \ No newline at end of file diff -Nru upm-1.6.0/src/wheelencoder/jsupm_wheelencoder.i upm-1.7.1/src/wheelencoder/jsupm_wheelencoder.i --- upm-1.6.0/src/wheelencoder/jsupm_wheelencoder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wheelencoder/jsupm_wheelencoder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_wheelencoder -%include "../upm.i" - -%{ - #include "wheelencoder.hpp" -%} - -%include "wheelencoder.hpp" diff -Nru upm-1.6.0/src/wheelencoder/pyupm_wheelencoder.i upm-1.7.1/src/wheelencoder/pyupm_wheelencoder.i --- upm-1.6.0/src/wheelencoder/pyupm_wheelencoder.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wheelencoder/pyupm_wheelencoder.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_wheelencoder -%include "../upm.i" - -%include "wheelencoder.hpp" -%{ - #include "wheelencoder.hpp" -%} diff -Nru upm-1.6.0/src/wheelencoder/wheelencoder.json upm-1.7.1/src/wheelencoder/wheelencoder.json --- upm-1.6.0/src/wheelencoder/wheelencoder.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wheelencoder/wheelencoder.json 2018-10-12 04:47:41.000000000 +0000 @@ -1,53 +1,53 @@ -{ - "Library": "wheelencoder", - "Description": "FRobot Wheel Encoder Library", - "Sensor Class": { - "WheelEncoder": { - "Name": "API for the DFRobot Wheel Encoder", - "Description": "This is the UPM Module for the DFRobot Wheel Encoder. This sensor was developed for the DFRobot Wheel Encoder, though it could be used for any counting time-based task. When you instantiate a class of this type, the gpio pin specified is connected to an interrupt. Whenever a low to high transition occurs on the gpio pin, the internal counter is incremented by one. This class also includes a millisecond counter, so that you can correlate the number of counts to a time period for calculating an RPM or other value as needed.", - "Aliases": ["wheelencoder", "Gravity:TT Motor Encoders Kit"], - "Categories": ["other"], - "Connections": ["gpio"], - "Project Type": ["prototyping", "robotics"], - "Manufacturers": ["DFRobot"], - "Image": "wheelencoder.jpg", - "Examples": { - "Python": ["wheelencoder.py"], - "Node.js": ["wheelencoder.js"], - "C++": ["wheelencoder.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "max": 5.0 - }, - "Supply Current": { - "unit": "mA", - "max" : 20 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - }, - "Resolution": { - "unit": "PPR", - "resolution": 20 - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Might need the Gravity: IO Expansion Shield"] - }, - "Arduino 101": { - "Notes": ["Might need the Gravity: IO Expansion Shield"] - } - }, - "Urls": { - "Product Pages": ["https://www.dfrobot.com/product-98.html"], - "Datasheets": ["https://www.dfrobot.com/wiki/index.php/Wheel_Encoders_for_DFRobot_3PA_and_4WD_Rovers_(SKU:SEN0038)"], - "Schematics": ["http://www.dfrobot.com/wiki/images/b/b9/FIT0029_Encoder_Schematics.png"] - } - } - } -} +{ + "Library": "wheelencoder", + "Description": "FRobot Wheel Encoder Library", + "Sensor Class": { + "WheelEncoder": { + "Name": "API for the DFRobot Wheel Encoder", + "Description": "This is the UPM Module for the DFRobot Wheel Encoder. This sensor was developed for the DFRobot Wheel Encoder, though it could be used for any counting time-based task. When you instantiate a class of this type, the gpio pin specified is connected to an interrupt. Whenever a low to high transition occurs on the gpio pin, the internal counter is incremented by one. This class also includes a millisecond counter, so that you can correlate the number of counts to a time period for calculating an RPM or other value as needed.", + "Aliases": ["wheelencoder", "Gravity:TT Motor Encoders Kit"], + "Categories": ["other"], + "Connections": ["gpio"], + "Project Type": ["prototyping", "robotics"], + "Manufacturers": ["DFRobot"], + "Image": "wheelencoder.jpg", + "Examples": { + "Python": ["wheelencoder.py"], + "Node.js": ["wheelencoder.js"], + "C++": ["wheelencoder.cxx"] + }, + "Specifications": { + "Vsource": { + "unit": "V", + "max": 5.0 + }, + "Supply Current": { + "unit": "mA", + "max" : 20 + }, + "Operating Temperature": { + "unit": "°C", + "min": -40, + "max": 85 + }, + "Resolution": { + "unit": "PPR", + "resolution": 20 + } + }, + "Platforms": { + "Intel Edison": { + "Notes": ["Might need the Gravity: IO Expansion Shield"] + }, + "Arduino 101": { + "Notes": ["Might need the Gravity: IO Expansion Shield"] + } + }, + "Urls": { + "Product Pages": ["https://www.dfrobot.com/product-98.html"], + "Datasheets": ["https://www.dfrobot.com/wiki/index.php/Wheel_Encoders_for_DFRobot_3PA_and_4WD_Rovers_(SKU:SEN0038)"], + "Schematics": ["http://www.dfrobot.com/wiki/images/b/b9/FIT0029_Encoder_Schematics.png"] + } + } + } +} diff -Nru upm-1.6.0/src/wt5001/javaupm_wt5001.i upm-1.7.1/src/wt5001/javaupm_wt5001.i --- upm-1.6.0/src/wt5001/javaupm_wt5001.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wt5001/javaupm_wt5001.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -%module javaupm_wt5001 -%include "../upm.i" -%include "stdint.i" -%include "typemaps.i" -%include "../java_buffer.i" -%include "../java_exceptions.i" - -%apply uint8_t *OUTPUT { uint8_t *vol }; -%apply uint8_t *OUTPUT { uint8_t *ps }; -%apply uint16_t *OUTPUT { uint16_t *numf }; -%apply uint16_t *OUTPUT { uint16_t *curf }; -%apply uint16_t *OUTPUT { uint16_t *year }; -%apply uint8_t *OUTPUT { uint8_t *month, uint8_t *day }; -%apply uint8_t *OUTPUT { uint8_t *hour, uint8_t *minute, uint8_t *second }; - -%{ - #include "wt5001.hpp" - speed_t int_B9600 = B9600; -%} - -%ignore getVolume(uint8_t *vol); -READDATA_EXCEPTION(getVolume()) - -%ignore getPlayState(uint8_t *ps); -READDATA_EXCEPTION(getPlayState()) - -%ignore getNumFiles(WT5001_PLAYSOURCE_T psrc, uint16_t *numf); -READDATA_EXCEPTION(getNumFiles(WT5001_PLAYSOURCE_T psrc)) - -%ignore getCurrentFile(uint16_t *curf); -READDATA_EXCEPTION(getCurrentFile()) - -%include "wt5001.hpp" -speed_t int_B9600 = B9600; - -JAVA_JNI_LOADLIBRARY(javaupm_wt5001) \ No newline at end of file diff -Nru upm-1.6.0/src/wt5001/jsupm_wt5001.i upm-1.7.1/src/wt5001/jsupm_wt5001.i --- upm-1.6.0/src/wt5001/jsupm_wt5001.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wt5001/jsupm_wt5001.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -%module jsupm_wt5001 -%include "../upm.i" -%include "../carrays_uint8_t.i" -%include "../carrays_uint16_t.i" - -%{ - #include "wt5001.hpp" - speed_t int_B9600 = B9600; -%} - -%include "wt5001.hpp" -speed_t int_B9600 = B9600; diff -Nru upm-1.6.0/src/wt5001/pyupm_wt5001.i upm-1.7.1/src/wt5001/pyupm_wt5001.i --- upm-1.6.0/src/wt5001/pyupm_wt5001.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wt5001/pyupm_wt5001.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_wt5001 -%include "../upm.i" -%include "../carrays_uint8_t.i" -%include "../carrays_uint16_t.i" - -%rename("getVolumeNoParam") getVolume(); -%rename("getPlayStateNoParam") getPlayState(); -%rename("getNumFilesOneParam") getNumFiles(WT5001_PLAYSOURCE_T psrc); -%rename("getCurrentFileNoParam") getCurrentFile(); - -%{ - #include "wt5001.hpp" - speed_t int_B9600 = B9600; -%} -%include "wt5001.hpp" -speed_t int_B9600 = B9600; diff -Nru upm-1.6.0/src/wt5001/wt5001.i upm-1.7.1/src/wt5001/wt5001.i --- upm-1.6.0/src/wt5001/wt5001.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/wt5001/wt5001.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,58 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "../java_buffer.i" +%include "../java_exceptions.i" + +%apply uint8_t *OUTPUT { uint8_t *vol }; +%apply uint8_t *OUTPUT { uint8_t *ps }; +%apply uint16_t *OUTPUT { uint16_t *numf }; +%apply uint16_t *OUTPUT { uint16_t *curf }; +%apply uint16_t *OUTPUT { uint16_t *year }; +%apply uint8_t *OUTPUT { uint8_t *month, uint8_t *day }; +%apply uint8_t *OUTPUT { uint8_t *hour, uint8_t *minute, uint8_t *second }; + +%ignore getVolume(uint8_t *vol); +READDATA_EXCEPTION(getVolume()) + +%ignore getPlayState(uint8_t *ps); +READDATA_EXCEPTION(getPlayState()) + +%ignore getNumFiles(WT5001_PLAYSOURCE_T psrc, uint16_t *numf); +READDATA_EXCEPTION(getNumFiles(WT5001_PLAYSOURCE_T psrc)) + +%ignore getCurrentFile(uint16_t *curf); +READDATA_EXCEPTION(getCurrentFile()) + +JAVA_JNI_LOADLIBRARY(javaupm_wt5001) +#endif +/* END Java syntax */ + +/* BEGIN Javascript syntax ------------------------------------------------- */ +#ifdef SWIGJAVASCRIPT +%include "../carrays_uint8_t.i" +%include "../carrays_uint16_t.i" +#endif +/* END Javascript syntax */ + +/* BEGIN Python syntax ----------------------------------------------------- */ +#ifdef SWIGPYTHON +%rename("getVolumeNoParam") getVolume(); +%rename("getPlayStateNoParam") getPlayState(); +%rename("getNumFilesOneParam") getNumFiles(WT5001_PLAYSOURCE_T psrc); +%rename("getCurrentFileNoParam") getCurrentFile(); +#endif +/* END Python syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "../carrays_uint8_t.i" +%include "../carrays_uint16_t.i" + +%{ +#include "wt5001.hpp" +speed_t int_B9600 = B9600; +%} +%include "wt5001.hpp" +speed_t int_B9600 = B9600; +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/wt5001/wt5001.json upm-1.7.1/src/wt5001/wt5001.json --- upm-1.6.0/src/wt5001/wt5001.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/wt5001/wt5001.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed"], "Image": "wt5001.jpg", "Examples": { - "Java": ["WT5001Sample.java"], + "Java": ["WT5001_Example.java"], "Python": ["wt5001.py"], "Node.js": ["wt5001.js"], "C++": ["wt5001.cxx"] diff -Nru upm-1.6.0/src/xbee/javaupm_xbee.i upm-1.7.1/src/xbee/javaupm_xbee.i --- upm-1.6.0/src/xbee/javaupm_xbee.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/xbee/javaupm_xbee.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -%module javaupm_xbee -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "xbee.hpp" -%} - -%include "xbee.hpp" -%array_class(char, charArray); - -JAVA_JNI_LOADLIBRARY(javaupm_xbee) \ No newline at end of file diff -Nru upm-1.6.0/src/xbee/jsupm_xbee.i upm-1.7.1/src/xbee/jsupm_xbee.i --- upm-1.6.0/src/xbee/jsupm_xbee.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/xbee/jsupm_xbee.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%module jsupm_xbee -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "xbee.hpp" -%} - -%include "xbee.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/xbee/pyupm_xbee.i upm-1.7.1/src/xbee/pyupm_xbee.i --- upm-1.6.0/src/xbee/pyupm_xbee.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/xbee/pyupm_xbee.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_xbee -%include "../upm.i" -%include "carrays.i" -%include "std_string.i" - -%{ - #include "xbee.hpp" -%} -%include "xbee.hpp" -%array_class(char, charArray); diff -Nru upm-1.6.0/src/xbee/xbee.hpp upm-1.7.1/src/xbee/xbee.hpp --- upm-1.6.0/src/xbee/xbee.hpp 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/xbee/xbee.hpp 2018-10-12 04:47:41.000000000 +0000 @@ -72,8 +72,8 @@ * * @image html xbee.jpg *
XBee Sensor image provided by SparkFun* under - * - * CC BY-NC-SA-3.0. + * + * CC BY 2.0. * * @snippet xbee.cxx Interesting */ diff -Nru upm-1.6.0/src/xbee/xbee.i upm-1.7.1/src/xbee/xbee.i --- upm-1.6.0/src/xbee/xbee.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/xbee/xbee.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,16 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +JAVA_JNI_LOADLIBRARY(javaupm_xbee) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%include "carrays.i" +%{ +#include "xbee.hpp" +%} +%include "xbee.hpp" +%array_class(char, charArray); +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/yg1006/javaupm_yg1006.i upm-1.7.1/src/yg1006/javaupm_yg1006.i --- upm-1.6.0/src/yg1006/javaupm_yg1006.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/yg1006/javaupm_yg1006.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module javaupm_yg1006 -%include "../upm.i" - -%{ - #include "yg1006.hpp" -%} - -%include "yg1006.hpp" - -JAVA_JNI_LOADLIBRARY(javaupm_yg1006) \ No newline at end of file diff -Nru upm-1.6.0/src/yg1006/jsupm_yg1006.i upm-1.7.1/src/yg1006/jsupm_yg1006.i --- upm-1.6.0/src/yg1006/jsupm_yg1006.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/yg1006/jsupm_yg1006.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -%module jsupm_yg1006 -%include "../upm.i" - -%{ - #include "yg1006.hpp" -%} - -%include "yg1006.hpp" diff -Nru upm-1.6.0/src/yg1006/pyupm_yg1006.i upm-1.7.1/src/yg1006/pyupm_yg1006.i --- upm-1.6.0/src/yg1006/pyupm_yg1006.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/yg1006/pyupm_yg1006.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_yg1006 -%include "../upm.i" - -%include "yg1006.hpp" -%{ - #include "yg1006.hpp" -%} diff -Nru upm-1.6.0/src/yg1006/yg1006.json upm-1.7.1/src/yg1006/yg1006.json --- upm-1.6.0/src/yg1006/yg1006.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/yg1006/yg1006.json 2018-10-12 04:47:41.000000000 +0000 @@ -13,7 +13,7 @@ "Kits": ["hak"], "Image": "yg1006.jpg", "Examples": { - "Java": ["YG1006Sample.java"], + "Java": ["YG1006_Example.java"], "Python": ["yg1006.py"], "Node.js": ["yg1006.js"], "C++": ["yg1006.cxx"], diff -Nru upm-1.6.0/src/zfm20/common.i upm-1.7.1/src/zfm20/common.i --- upm-1.6.0/src/zfm20/common.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/zfm20/common.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -%include "../upm.i" - -/* Make it easy to use the methods which take a uint& id and score */ -%include "typemaps.i" -%apply uint16_t &OUTPUT {uint16_t &id}; -%apply uint16_t &OUTPUT {uint16_t &score}; - -%{ - #include "zfm20.hpp" -%} -%include "zfm20.hpp" diff -Nru upm-1.6.0/src/zfm20/javaupm_zfm20.i upm-1.7.1/src/zfm20/javaupm_zfm20.i --- upm-1.6.0/src/zfm20/javaupm_zfm20.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/zfm20/javaupm_zfm20.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -%module javaupm_zfm20 -%include "stdint.i" -%include "typemaps.i" -%include "arrays_java.i"; -%include "../java_buffer.i"; - -%include "common.i" - -JAVA_JNI_LOADLIBRARY(javaupm_zfm20) diff -Nru upm-1.6.0/src/zfm20/jsupm_zfm20.i upm-1.7.1/src/zfm20/jsupm_zfm20.i --- upm-1.6.0/src/zfm20/jsupm_zfm20.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/zfm20/jsupm_zfm20.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -%module jsupm_zfm20 -%include "../carrays_uint8_t.i" -%include "../carrays_uint16_t.i" -%include "../carrays_uint32_t.i" -%include "cpointer.i" - -/* Send "int *" to JavaScript as intp */ -%pointer_functions(int, intp); - -%include "common.i" diff -Nru upm-1.6.0/src/zfm20/pyupm_zfm20.i upm-1.7.1/src/zfm20/pyupm_zfm20.i --- upm-1.6.0/src/zfm20/pyupm_zfm20.i 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/zfm20/pyupm_zfm20.i 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_zfm20 -%include "../carrays_uint8_t.i" -%include "../carrays_uint16_t.i" -%include "../carrays_uint32_t.i" -%include "cpointer.i" - -%include "common.i" diff -Nru upm-1.6.0/src/zfm20/zfm20.cxx upm-1.7.1/src/zfm20/zfm20.cxx --- upm-1.6.0/src/zfm20/zfm20.cxx 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/zfm20/zfm20.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -131,7 +131,7 @@ void ZFM20::initClock() { - upm_clock_init(&m_clock); + m_clock = upm_clock_init(); } uint32_t ZFM20::getMillis() diff -Nru upm-1.6.0/src/zfm20/zfm20.i upm-1.7.1/src/zfm20/zfm20.i --- upm-1.6.0/src/zfm20/zfm20.i 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/src/zfm20/zfm20.i 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,24 @@ +%include "../common_top.i" + +/* BEGIN Java syntax ------------------------------------------------------- */ +#ifdef SWIGJAVA +%include "arrays_java.i"; +%include "../java_buffer.i"; + +JAVA_JNI_LOADLIBRARY(javaupm_zfm20) +#endif +/* END Java syntax */ + +/* BEGIN Common SWIG syntax ------------------------------------------------- */ +%apply uint16_t &OUTPUT {uint16_t &id}; +%apply uint16_t &OUTPUT {uint16_t &score}; +%include "../carrays_uint8_t.i" +%include "../carrays_uint16_t.i" +%include "../carrays_uint32_t.i" +%pointer_functions(int, intp); + +%{ +#include "zfm20.hpp" +%} +%include "zfm20.hpp" +/* END Common SWIG syntax */ diff -Nru upm-1.6.0/src/zfm20/zfm20.json upm-1.7.1/src/zfm20/zfm20.json --- upm-1.6.0/src/zfm20/zfm20.json 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/src/zfm20/zfm20.json 2018-10-12 04:47:41.000000000 +0000 @@ -12,7 +12,7 @@ "Manufacturers": ["Seeed", "ZhianTec"], "Image": "zfm20.jpg", "Examples": { - "Java": ["ZFM20Sample.java"], + "Java": ["ZFM20_Example.java"], "Python": ["zfm20-register.py", "zfm20.py"], "Node.js": ["zfm20-register.js", "zfm20.js"], "C++": ["zfm20-register.cxx", "zfm20.cxx"] diff -Nru upm-1.6.0/tests/check_autoloadlibrary.py upm-1.7.1/tests/check_autoloadlibrary.py --- upm-1.6.0/tests/check_autoloadlibrary.py 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/tests/check_autoloadlibrary.py 2018-10-12 04:47:41.000000000 +0000 @@ -1,4 +1,5 @@ #!/usr/bin/python +from __future__ import print_function import unittest as u import re, fnmatch, os @@ -25,7 +26,7 @@ for subdir, dirs, files in os.walk(rootDir): for fileName in files: - if fnmatch.fnmatch(fileName, 'javaupm_*.i'): + if fnmatch.fnmatch(fileName, '*.i'): moduleName = fileName[:-2] snippet = prefix + moduleName + suffix @@ -34,7 +35,7 @@ data = f.read() #Make sure it is module if not '%module' in data: - print "%%module not found in %s, skipping" % fileName + print ("%%module not found in %s, skipping" % fileName) continue # Check for the autoload code or the autoload macro if (not 'JAVA_JNI_LOADLIBRARY(javaupm_' in data) and \ diff -Nru upm-1.6.0/tests/check_consistency.py upm-1.7.1/tests/check_consistency.py --- upm-1.6.0/tests/check_consistency.py 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/tests/check_consistency.py 2018-10-12 04:47:41.000000000 +0000 @@ -18,7 +18,7 @@ for libraryName in blacklist: files = os.listdir( os.path.join(rootDir, libraryName)) - interfaceFileName = "javaupm_" + libraryName + ".i" + interfaceFileName = libraryName + ".i" if interfaceFileName in files: self.fail("\n" + libraryName + " is in javaswig blacklist.\n" + \ diff -Nru upm-1.6.0/tests/check_pythonload.py upm-1.7.1/tests/check_pythonload.py --- upm-1.6.0/tests/check_pythonload.py 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/tests/check_pythonload.py 2018-10-12 04:47:41.000000000 +0000 @@ -51,6 +51,9 @@ print('Skipping blacklisted %s ...' % pyfile) continue + # Append the path of this python module + sys.path.append(os.path.dirname(pyfile)) + try: pyfile = imp.load_source(module, pyfile) except Exception as x: diff -Nru upm-1.6.0/tests/CMakeLists.txt upm-1.7.1/tests/CMakeLists.txt --- upm-1.6.0/tests/CMakeLists.txt 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/tests/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -75,10 +75,13 @@ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/) endif (BUILDSWIGPYTHON AND PYTHON3INTERP_FOUND) -# add JSON test -if(NPM_EXECUTABLE) - add_test (NAME check_jsons COMMAND ${CMAKE_COMMAND} - -DNPMEXEC=${NPM_EXECUTABLE} - -DUPMBASEDIR=${CMAKE_SOURCE_DIR} - -P ${CMAKE_SOURCE_DIR}/tests/runjsontest.cmake) -endif(NPM_EXECUTABLE) +## Check json library descriptor files for required fields +#if(NPM_EXECUTABLE) +# add_test (NAME check_jsons COMMAND ${CMAKE_COMMAND} +# -DNPMEXEC=${NPM_EXECUTABLE} +# -DUPMBASEDIR=${CMAKE_SOURCE_DIR} +# -P ${CMAKE_SOURCE_DIR}/tests/runjsontest.cmake) +#endif(NPM_EXECUTABLE) + +# Unit tests +add_subdirectory (unit) diff -Nru upm-1.6.0/tests/unit/CMakeLists.txt upm-1.7.1/tests/unit/CMakeLists.txt --- upm-1.6.0/tests/unit/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/tests/unit/CMakeLists.txt 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,35 @@ +# For now, Google Test is NOT required */ +find_package(GTest) + +# If not found, print a status message and return +if(NOT GTEST_FOUND) + message(STATUS "Install Google Test to enable additional unit testing") + return () +endif() + +# Unit tests - utilities library +add_executable(utilities_tests utilities/utilities_tests.cxx) +target_link_libraries(utilities_tests utilities GTest::GTest GTest::Main) +gtest_add_tests(utilities_tests "" AUTO) +list(APPEND GTEST_UNIT_TEST_TARGETS utilities_tests) + +# Unit tests - Json header +add_executable(json_tests json/json_tests.cxx) +target_link_libraries(json_tests GTest::GTest GTest::Main) +target_include_directories(json_tests PRIVATE "${UPM_COMMON_HEADER_DIRS}/") +gtest_add_tests(json_tests "" AUTO) +list(APPEND GTEST_UNIT_TEST_TARGETS json_tests) + +# Unit tests - nmea_gps library +if (TARGET nmea_gps) + add_executable(nmea_gps_tests nmea_gps/nmea_gps_tests.cxx) + target_link_libraries(nmea_gps_tests nmea_gps GTest::GTest GTest::Main) + gtest_add_tests(nmea_gps_tests "" AUTO) + list(APPEND GTEST_UNIT_TEST_TARGETS nmea_gps_tests) +endif() + +# Add a custom target for unit tests +add_custom_target(tests-unit ALL + DEPENDS + ${GTEST_UNIT_TEST_TARGETS} + COMMENT "UPM unit test collection") diff -Nru upm-1.6.0/tests/unit/json/json_tests.cxx upm-1.7.1/tests/unit/json/json_tests.cxx --- upm-1.6.0/tests/unit/json/json_tests.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/tests/unit/json/json_tests.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,104 @@ +/* + * Author: Noel Eck + * Copyright (c) 2018 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 "gtest/gtest.h" +#include "external/json/json.hpp" + +namespace +{ + class source + { + public: + std::string unit; + float max; + float min; + float accuracy; + }; + + void to_json(nlohmann::json& j, const source& p) { + j = nlohmann::json{ + {"unit", p.unit}, + {"min", p.min}, + {"max", p.max}, + {"accuracy", p.accuracy}}; + } + + void from_json(const nlohmann::json& j, source& p) { + p.unit = j.at("unit").get(); + p.min = j.at("min").get(); + p.max = j.at("max").get(); + p.accuracy = j.at("accuracy").get(); + } + + bool operator==(const source& lhs, const source& rhs) + { + return lhs.unit == rhs.unit && lhs.min == rhs.min; + } +} + +/* Json test fixture */ +class json_unit : public ::testing::Test +{ + protected: + /* One-time setup logic if needed */ + json_unit() {} + + /* One-time tear-down logic if needed */ + virtual ~json_unit() {} + + /* Per-test setup logic if needed */ + virtual void SetUp() {} + + /* Per-test tear-down logic if needed */ + virtual void TearDown() {} +}; + +/* Test basic json serialization */ +TEST_F(json_unit, test_basic_class_serialization) +{ + source s_temp {"C", -40.0, 85.0, 1.0}; + source s_humi {"%", 0.0, 100.0, 1.0}; + + /* Create the json objects */ + nlohmann::json j_temp = s_temp; + nlohmann::json j_humi = s_humi; + + /* Serialize/deserialize the originals */ + source clone_temp = j_temp; + source clone_humi = j_humi; + ASSERT_EQ(s_temp, clone_temp); + + /* Populate an stl container */ + std::map sources; + sources["temperature"] = s_temp; + sources["humidity-relative"] = s_humi; + + /* Create the json object */ + nlohmann::json j_sources = sources; + + /* Serialize/deserialize the container */ + std::map clone_sources = j_sources; + ASSERT_EQ(sources, j_sources); +} diff -Nru upm-1.6.0/tests/unit/nmea_gps/nmea_gps_tests.cxx upm-1.7.1/tests/unit/nmea_gps/nmea_gps_tests.cxx --- upm-1.6.0/tests/unit/nmea_gps/nmea_gps_tests.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/tests/unit/nmea_gps/nmea_gps_tests.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,301 @@ +/* + * Author: Noel Eck + * Copyright (c) 2018 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 "gtest/gtest.h" +#include "nmea_gps.hpp" +#include "mraa.hpp" + +#include +#include + +/* NMEA GPS test fixture */ +class nmea_gps_unit : public ::testing::Test +{ + protected: + /* One-time setup logic if needed */ + nmea_gps_unit() = default; + + /* One-time tear-down logic if needed */ + ~nmea_gps_unit() override = default; + + /* Fail if not MOCK platform */ + void SetUp() override + { + ASSERT_EQ(mraa::getPlatformType(), mraa::MOCK_PLATFORM) << + "NMEA_GPS test requires mraa compiled with mraa::MOCK_PLATFORM"; + } + + /* Per-test tear-down logic if needed */ + void TearDown() override {} +}; + +/* Basic tests */ +TEST_F(nmea_gps_unit, DOA) +{ + upm::NMEAGPS gps(0, 115200, -1); + + /* Min queue size is 1 */ + gps.setMaxQueueDepth(0); + ASSERT_EQ(gps.getMaxQueueDepth(), 1); + + /* Max queue size is 1000 */ + gps.setMaxQueueDepth(1001); + ASSERT_EQ(gps.getMaxQueueDepth(), 1000); + + /* Queues should be empty */ + ASSERT_EQ(gps.fixQueueSize(), 0); + ASSERT_EQ(gps.rawSentenceQueueSize(), 0); +} + +/* Check parsing varying length sentences */ +TEST_F(nmea_gps_unit, parse_max_size) +{ + upm::NMEAGPS gps(0, 115200, -1); + + /* Parse an sentence that is too long to be NMEA */ + gps.parseNMEASentence("$GPGSV,2,1,08,07,64,079,,08,39,066,,09,25,159,,09,25,159,,09,25,159,,09,25,159,,09,25,159,,09,25,159,,09,25,159,,07,64,079,*73"); + ASSERT_EQ(gps.rawSentenceQueueSize(), 1); + ASSERT_EQ(gps.satellites().size(), 0); +} + +/* Basic test */ +TEST_F(nmea_gps_unit, parse_basic) +{ + upm::NMEAGPS gps(0, 115200, -1); + + /* Parse an invalid sentence */ + gps.parseNMEASentence("$GPGGA,182333.50,,,,,0,00,99.99,,,,,,*6B"); +} + +/* Parse an invalid sentence */ +TEST_F(nmea_gps_unit, parse_gps_fix_invalid) +{ + upm::NMEAGPS gps(0, 115200, -1); + + /* Parse an invalid sentence */ + gps.parseNMEASentence("$GPGGA,182333.50,,,,,0,00,99.99,,,,,,*6B"); + + /* Should be 1 entry in the raw queue */ + ASSERT_EQ(gps.rawSentenceQueueSize(), 1); + /* Should be 0 in GPS fix queue */ + ASSERT_EQ(gps.fixQueueSize(), 0); + + /* Get the GPS fix */ + upm::gps_fix f = gps.getFix(); + ASSERT_EQ(f.valid, false); + ASSERT_EQ(f.quality, upm::gps_fix_quality::no_fix); + /* Call the string method for coverage */ + f.__str__(); + + /* Get the 1 raw sentence */ + gps.getRawSentence(); + + /* Should be 0 entries in each queue */ + ASSERT_EQ(gps.rawSentenceQueueSize(), 0); + ASSERT_EQ(gps.fixQueueSize(), 0); +} + +std::string randstr(size_t size) +{ + std::string retstr(".", size); + + std::random_device rd; + std::default_random_engine eng(rd()); + std::uniform_int_distribution distr(32, 126); + for (size_t i = 0; i < size; i++) + retstr[i] = distr(eng); + return retstr; +} + +/* Parse bogus sentences */ +TEST_F(nmea_gps_unit, parse_gps_fix_bogus) +{ + upm::NMEAGPS gps(0, 115200, -1); + + /* Parse some bogus sentences */ + std::string gga = "$GPGGA,182333.50,,,,,0,00,99.99,,,,,,*6B"; + gps.parseNMEASentence(gga); + + for (size_t i = 0; i < gga.size(); i++) + { + std::string tmp = gga; + gps.parseNMEASentence(tmp.replace(i, 1, "x")); + } + + for (int i = 0; i < 1000; i++) + gps.parseNMEASentence(randstr(40)); + + /* Still no GPS fix */ + ASSERT_EQ(gps.fixQueueSize(), 0); +} + +/* Parse valid gga sentences */ +TEST_F(nmea_gps_unit, parse_gps_fix_valid) +{ + upm::NMEAGPS gps(0, 115200, -1); + + /* Parse a valid sentence */ + gps.parseNMEASentence("$GPGGA,172814.0,3723.46587704,N,12202.26957864,W," + + std::string("2,6,1.2,18.893,M,-25.669,M,2.0,0031*4F")); + + /* Should be 1 entry in GPS fix queue */ + ASSERT_EQ(gps.fixQueueSize(), 1); + + upm::gps_fix f = gps.getFix(); + ASSERT_EQ(f.valid, true) << f.__str__(); +} + +/* Parse valid gsv sentences */ +TEST_F(nmea_gps_unit, parse_gsv_valid) +{ + upm::NMEAGPS gps(0, 115200, -1); + std::vector snts = + { + "$GPGSV,2,1,08,07,64,079,,08,39,066,,09,25,159,,11,15,117,*7B", + "$GPGSV,2,2,08,13,25,313,,30,78,336,22,48,37,194,,51,35,158,*75", + "$GPGSV,2,2,08,13,25,313,,30,78,336,21,48,37,194,,51,35,158,*76", + "$GPGSV,2,2,08,13,25,313,,30,78,336,,48,37,194,,51,35,158,*75", + "$GPGSV,2,1,08,07,64,079,,08,39,066,,09,25,159,,11,15,117,*7B", + "$GPGSV,2,2,08,13,25,313,,30,78,336,21,48,37,194,,51,35,158,*76", + "$GPGSV,2,2,08,13,25,313,,30,78,336,20,48,37,194,,51,35,158,*77", + "$GPGSV,2,1,08,07,64,079,,08,39,066,,09,25,159,,11,15,117,*7B", + "$GPGSV,2,2,08,13,25,313,,30,78,336,18,48,37,194,,51,35,158,*7C", + "$GPGSV,2,2,08,13,25,313,,30,78,336,17,48,37,194,,51,35,158,*73", + "$GPGSV,2,1,08,07,64,080,,08,39,066,,09,25,159,,11,15,117,*7D", + "$GPGSV,2,2,08,13,26,313,,30,78,336,13,48,37,194,,51,35,158,*74", + "$GPGSV,2,1,08,07,64,080,,08,39,066,,09,25,159,,11,15,117,*7D", + "$GPGSV,2,2,08,13,26,313,,30,78,336,09,48,37,194,,51,35,158,*7F", + "$GPGSV,2,1,08,07,64,080,,08,39,066,,09,25,160,,11,15,117,*77", + "$GPGSV,2,2,08,13,26,313,,30,78,336,23,48,37,194,,51,35,158,*77", + "$GPGSV,3,3,09,51,35,158,*4E", + "$GPGSV,2,1,08,07,64,080,22,08,39,066,,09,25,160,,11,15,117,*77", + "$GPGSV,2,1,08,07,64,080,21,08,39,066,,09,25,160,,11,15,117,*74" + }; + + /* Parse the first sentence */ + gps.parseNMEASentence(snts.front()); + + /* Should have 4 satellites */ + auto sats = gps.satellites(); + ASSERT_EQ(sats.size(), 4); + + ASSERT_EQ(sats[0].prn, "07"); + ASSERT_EQ(sats[0].elevation_deg, 64); + ASSERT_EQ(sats[0].azimuth_deg, 79); + ASSERT_EQ(sats[0].snr, 0); + + ASSERT_EQ(sats[1].prn, "08"); + ASSERT_EQ(sats[1].elevation_deg, 39); + ASSERT_EQ(sats[1].azimuth_deg, 66); + ASSERT_EQ(sats[1].snr, 0); + + ASSERT_EQ(sats[2].prn, "09"); + ASSERT_EQ(sats[2].elevation_deg, 25); + ASSERT_EQ(sats[2].azimuth_deg, 159); + ASSERT_EQ(sats[2].snr, 0); + + ASSERT_EQ(sats[3].prn, "11"); + ASSERT_EQ(sats[3].elevation_deg, 15); + ASSERT_EQ(sats[3].azimuth_deg, 117); + ASSERT_EQ(sats[3].snr, 0); + + /* Parse the rest */ + for(const auto& sentence : snts) + gps.parseNMEASentence(sentence); + + /* Finish up with 8 satellites */ + sats = gps.satellites(); + ASSERT_EQ(sats.size(), 8); + + /* Verify the last satellite */ + ASSERT_EQ(sats.back().prn, "11"); + ASSERT_EQ(sats.back().elevation_deg, 15); + ASSERT_EQ(sats.back().azimuth_deg, 117); + ASSERT_EQ(sats.back().snr, 0); + + /* The 4th should have a non-zero snr */ + ASSERT_EQ(sats[4].snr, 21); +} + +/* Parse valid gll sentences */ +TEST_F(nmea_gps_unit, parse_gll_valid) +{ + upm::NMEAGPS gps(0, 115200, -1); + std::vector snts = + { + "$GPGLL,4532.55107,N,12257.68422,W,170004.20,A,A*74", + "$GPGLL,4532.55008,N,12257.68195,W,170005.00,A,A*70", + "$GPGLL,4532.55027,N,12257.68252,W,170006.10,A,A*77", + "$GPGLL,4532.54370,N,12257.65873,W,170006.90,A,A*7B", + "$GPGLL,4532.54230,N,12257.65302,W,170008.00,A,A*74" + }; + + /* Parse the first sentence */ + gps.parseNMEASentence(snts.front()); + + /* Get the fix */ + upm::gps_fix f = gps.getFix(); + ASSERT_EQ(f.valid, true) << f.__str__(); + ASSERT_FLOAT_EQ(f.coordinates.latitude, 45.542517833333335) << f.__str__(); + ASSERT_FLOAT_EQ(f.coordinates.longitude, -122.96140366666667) << f.__str__(); + ASSERT_EQ(f.time_utc, "170004.20") << f.__str__(); + + /* Parse the rest */ + for(const auto& sentence : snts) + gps.parseNMEASentence(sentence); + + /* Should have 5 GPS fixes */ + ASSERT_EQ(gps.fixQueueSize(), 5); +} + +/* Parse example txt sentences */ +TEST_F(nmea_gps_unit, parse_txt_valid) +{ + upm::NMEAGPS gps(0, 115200, -1); + std::vector snts = + { + "$GPTXT,01,01,02,u-blox ag - www.u-blox.com*50", + "$GPTXT,01,01,02,HW UBX-G60xx 00040007 *52", + "$GPTXT,01,01,02,EXT CORE 7.03 (45970) Mar 17 2011 16:26:24*44", + "$GPTXT,01,01,02,ROM BASE 6.02 (36023) Oct 15 2009 16:52:08*58", + "$GPTXT,01,01,02,MOD LEA-6H-0*2D", + "$GPTXT,01,01,02,ANTSUPERV=AC SD PDoS SR*20", + "$GPTXT,01,01,02,ANTSTATUS=OK*3B" + }; + + /* Parse the first sentence */ + gps.parseNMEASentence(snts.front()); + + ASSERT_EQ(gps.txtMessageQueueSize(), 1); + /* Get the message */ + upm::nmeatxt msg = gps.getTxtMessage(); + ASSERT_EQ(msg.severity, 2); + + /* Parse the rest */ + for(const auto& sentence : snts) + gps.parseNMEASentence(sentence); + + /* Should have 5 GPS fixes */ + ASSERT_EQ(gps.txtMessageQueueSize(), 7); +} diff -Nru upm-1.6.0/tests/unit/utilities/utilities_tests.cxx upm-1.7.1/tests/unit/utilities/utilities_tests.cxx --- upm-1.6.0/tests/unit/utilities/utilities_tests.cxx 1970-01-01 00:00:00.000000000 +0000 +++ upm-1.7.1/tests/unit/utilities/utilities_tests.cxx 2018-10-12 04:47:41.000000000 +0000 @@ -0,0 +1,168 @@ +/* + * Author: Noel Eck + * Copyright (c) 2018 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 +#include + +#include "gtest/gtest.h" +#include "upm_utilities.h" +#include "upm_utilities.hpp" + +/* Average over AVG_CNT iterations */ +#define AVG_CNT 5 + +/* Specify a delay for all tests under 1s */ +#define ms_50 std::chrono::milliseconds(50) + +/* Specify a +/- value for all tests under 1s. Since the delay methods in + * non-realtime operating systems can vary greatly, use a lenient value for + * testing these methods. */ +#define time_range std::chrono::milliseconds(5) + +/* Helper defines */ +#define to_ms std::chrono::duration_cast +#define to_us std::chrono::duration_cast +#define to_ns std::chrono::duration_cast + +/* Utilities test fixture */ +class utilities_unit : public ::testing::Test +{ + protected: + /* One-time setup logic if needed */ + utilities_unit() {} + + /* One-time tear-down logic if needed */ + virtual ~utilities_unit() {} + + /* Per-test setup logic if needed */ + virtual void SetUp() {} + + /* Per-test tear-down logic if needed */ + virtual void TearDown() {} +}; + +/* Sanity check on min_delay_ns */ +TEST_F(utilities_unit, min_delay_LT_500us) +{ + /* Determine a rough-average for the minimum delay using chrono */ + std::chrono::nanoseconds min_delay_ns = std::chrono::nanoseconds::zero(); + for (int i = 0; i < AVG_CNT; i++) + { + auto start = std::chrono::steady_clock::now(); + std::this_thread::sleep_for(std::chrono::nanoseconds(1)); + auto end = std::chrono::steady_clock::now(); + min_delay_ns += to_ns(end-start); + } + min_delay_ns /= AVG_CNT; + + ASSERT_LT(to_us(min_delay_ns).count(), 3000); +} + +/* Test the second delay method */ +TEST_F(utilities_unit, test_upm_delay) +{ + upm_clock_t clock = upm_clock_init(); + + /* Test a corner case */ + upm_delay(0); + + /* +- check for 0s */ + EXPECT_EQ(upm_elapsed_ms(&clock), 0); + + clock = upm_clock_init(); + upm_delay(1); + + /* +- check near 1s */ + EXPECT_NEAR(upm_elapsed_ms(&clock), 1000, time_range.count()); +} + +/* Test the millisecond delay method */ +TEST_F(utilities_unit, test_upm_delay_ms) +{ + upm_clock_t clock = upm_clock_init(); + + /* Test a corner case */ + upm_delay_ms(0); + + /* +- check for 0ms */ + EXPECT_EQ(upm_elapsed_ms(&clock), 0); + + clock = upm_clock_init(); + upm_delay_ms(ms_50.count() * AVG_CNT); + + /* +- check near 50ms */ + EXPECT_NEAR(upm_elapsed_ms(&clock)/AVG_CNT, ms_50.count(), time_range.count()); +} + +/* Test the microsecond delay method */ +TEST_F(utilities_unit, test_upm_delay_us) +{ + upm_clock_t clock = upm_clock_init(); + + /* Test a corner case */ + upm_delay_us(0); + + /* +- check for 0us +/- 100us */ + EXPECT_NEAR(upm_elapsed_us(&clock), 0, 100); + + clock = upm_clock_init(); + upm_delay_us(to_us(ms_50).count() * AVG_CNT); + + /* +- check near 50ms */ + EXPECT_NEAR(upm_elapsed_us(&clock)/AVG_CNT, to_us(ms_50).count(), + to_us(time_range).count()); +} + +/* Test the nanosecond delay method */ +TEST_F(utilities_unit, test_upm_delay_ns) +{ + upm_clock_t clock = upm_clock_init(); + + /* Test a corner case */ + upm_delay_ns(0); + + /* +- check for 0us +/- 100us */ + EXPECT_NEAR(upm_elapsed_ns(&clock), 0, 100000); + + clock = upm_clock_init(); + upm_delay_ns(to_ns(ms_50).count() * AVG_CNT); + + /* +- check near 50ms */ + EXPECT_NEAR(upm_elapsed_ns(&clock)/AVG_CNT, to_ns(ms_50).count(), + to_ns(time_range).count()); +} + +/* Test the max us delay (default to disabled) */ +TEST_F(utilities_unit, DISABLED_test_upm_delay_us_max) +{ + upm_clock_t clock = upm_clock_init(); + upm_delay_us(4294967295); + EXPECT_NEAR(upm_elapsed_us(&clock), 4294967295, 150); +} + +/* Test the Air Quality Index method */ +TEST_F(utilities_unit, test_upm_ugm3_to_aqi) +{ + EXPECT_EQ(upm_ugm3_to_aqi(10), 41); +} diff -Nru upm-1.6.0/.travis.yml upm-1.7.1/.travis.yml --- upm-1.6.0/.travis.yml 2018-02-20 15:45:15.000000000 +0000 +++ upm-1.7.1/.travis.yml 2018-10-12 04:47:41.000000000 +0000 @@ -14,6 +14,19 @@ 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 @@ -69,6 +82,8 @@ - <<: *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