@ -12,7 +12,7 @@ before_install:
|
||||
jobs:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: TARGET=ipk
|
||||
- env: TARGET=android
|
||||
include:
|
||||
- &run-with-clang-minimal
|
||||
stage: Clang 3.8 - minimal with unit tests
|
||||
@ -87,9 +87,5 @@ jobs:
|
||||
env: TARGET=examples
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=sonar-scan
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=ipk
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=rpm
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=npm
|
||||
|
@ -10,8 +10,6 @@ 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)
|
||||
option (NPM "Generate NPM/GYP tarballs" OFF)
|
||||
option (BUILDTESTS "Generate check-ups for upm" OFF)
|
||||
option (WERROR "Make all warnings into errors." ON)
|
||||
@ -91,13 +89,16 @@ endfunction ()
|
||||
|
||||
# Compiler flags common to both C and CXX
|
||||
# Enable -Wall
|
||||
# GCC-6 added -Wmisleading-indentation to -Wall, skip these for now
|
||||
set (C_CXX_WARNING_FLAGS -Wall
|
||||
-Wno-misleading-indentation
|
||||
-Wno-strict-aliasing
|
||||
-Wno-deprecated-declarations # Temp fix for MRAA deprecated methods
|
||||
)
|
||||
|
||||
# GCC-6 added -Wmisleading-indentation to -Wall, skip these for now
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "6")
|
||||
list (APPEND C_CXX_WARNING_FLAGS -Wno-misleading-indentation)
|
||||
endif ()
|
||||
|
||||
# Warnings as errors?
|
||||
if (WERROR)
|
||||
list (APPEND C_CXX_WARNING_FLAGS -Werror)
|
||||
@ -150,6 +151,11 @@ pkg_check_modules (MODBUS libmodbus>=3.1.2)
|
||||
# Check for OPENZWAVE
|
||||
pkg_check_modules (OPENZWAVE libopenzwave)
|
||||
|
||||
# Check for TinyB
|
||||
pkg_check_modules (TINYB tinyb>=0.5.1)
|
||||
# And get full path to the tinyb library
|
||||
find_library(TINYB_LIBRARY NAMES tinyb HINTS ${TINYB_LIBDIR})
|
||||
|
||||
# Find JPEG
|
||||
find_package (JPEG)
|
||||
|
||||
@ -252,11 +258,6 @@ set (upm_VERSION_MINOR ${VERSION_MINOR})
|
||||
set (upm_VERSION_PATCH ${VERSION_PATCH})
|
||||
set (upm_VERSION_STRING ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH})
|
||||
|
||||
# Detect arch
|
||||
include (TargetArch)
|
||||
target_architecture (DETECTED_ARCH)
|
||||
message (STATUS "Target arch is ${DETECTED_ARCH}")
|
||||
|
||||
# enable c++11 standards support unconditionally
|
||||
include(CheckCXXCompilerFlag)
|
||||
if (CMAKE_VERSION VERSION_LESS "3.1")
|
||||
@ -417,68 +418,6 @@ function (CreateDocumentationTargets)
|
||||
endif(BUILDSWIGNODE)
|
||||
endfunction()
|
||||
|
||||
if (IPK)
|
||||
# Get target package arch from Yocto ADT sysroot if set or host OS, mapping to Ubuntu name if necessary
|
||||
if (DEFINED ENV{OECORE_TARGET_SYSROOT})
|
||||
GET_FILENAME_COMPONENT (DETECTED_SYSROOT $ENV{OECORE_TARGET_SYSROOT} NAME)
|
||||
string (REGEX REPLACE "-poky-linux" "" TARGET_ARCH "${DETECTED_SYSROOT}")
|
||||
else ()
|
||||
# Debian uses amd64 to denote x86_64
|
||||
if (DETECTED_ARCH STREQUAL "x86_64")
|
||||
set (TARGET_ARCH "amd64")
|
||||
else ()
|
||||
set (TARGET_ARCH ${DETECTED_ARCH})
|
||||
endif ()
|
||||
endif ()
|
||||
message (STATUS "Package arch is ${TARGET_ARCH}")
|
||||
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
set(OPKG_ARCH ${TARGET_ARCH})
|
||||
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
|
||||
set(upm_PACKAGE_ON_TAG ".")
|
||||
if ("${VERSION_COMMIT}" STREQUAL "")
|
||||
set(upm_PACKAGE_ON_TAG "")
|
||||
endif()
|
||||
set(CPACK_PACKAGE_VERSION
|
||||
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
|
||||
set(CPACK_PACKAGE_NAME "upm")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${TARGET_ARCH})
|
||||
set(CPACK_SYSTEM_NAME ${TARGET_ARCH})
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "mraa (>= ${MRAA_VERSION})")
|
||||
set(CPACK_DEBIAN_PACKAGE_PROVIDES "upm-dev, upm-dbg, upm-doc")
|
||||
set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
|
||||
set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
|
||||
set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
|
||||
include (CPack)
|
||||
endif()
|
||||
|
||||
if (RPM)
|
||||
message (STATUS "RPM packaging enabled for ${DETECTED_ARCH}")
|
||||
set(CPACK_GENERATOR "RPM")
|
||||
set(CPACK_PACKAGE_NAME "upm")
|
||||
set(upm_PACKAGE_ON_TAG ".")
|
||||
if ("${VERSION_COMMIT}" STREQUAL "")
|
||||
set(upm_PACKAGE_ON_TAG "")
|
||||
endif()
|
||||
set(CPACK_PACKAGE_VERSION
|
||||
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
|
||||
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
|
||||
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
|
||||
set(CPACK_RPM_PACKAGE_REQUIRES "mraa >= ${MRAA_VERSION}")
|
||||
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
|
||||
EXECUTE_PROCESS(COMMAND rpm --showrc
|
||||
COMMAND grep -E "dist[[:space:]]*\\."
|
||||
COMMAND sed -e "s/^.*dist\\s*\\.//"
|
||||
COMMAND tr \\n \\t
|
||||
COMMAND sed -e s/\\t//
|
||||
OUTPUT_VARIABLE DIST_TAG)
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${DIST_TAG}.${DETECTED_ARCH}")
|
||||
include(CPack)
|
||||
endif()
|
||||
|
||||
# UPM common headers
|
||||
set (UPM_COMMON_HEADER_DIRS ${CMAKE_HOME_DIRECTORY}/include)
|
||||
|
||||
|
36
README.md
@ -14,21 +14,21 @@ Programmers can access the interfaces for each sensor by including the sensor’
|
||||
corresponding header file and instantiating the associated sensor class. In the
|
||||
typical use case, a constructor initializes the sensor based on parameters that
|
||||
identify the sensor, the I/O protocol used and the pin location of the sensor.
|
||||
As of UPM 2.0, sensor initialization can also be done, in most cases, via
|
||||
overloaded constructors that accept string identifiers.
|
||||
|
||||
We endorse additions that implement the generic C and C++ interfaces provided
|
||||
with the libraries. Multiple sensor and actuator types have been defined, for
|
||||
instance:
|
||||
with the libraries. With the 2.0 release, UPM introduces the following sensor
|
||||
interfaces: iAcceleration, iAngle, iButton, iClock, iCollision, iDistance,
|
||||
iDistanceInterrupter, iEC, iElectromagnet, iEmg, iGas, iGps, iGyroscope,
|
||||
iHallEffect, iHeartRate, iHumidity, iLight, iLineFinder, iMagnetometer,
|
||||
iMoisture, iMotion, iOrp, iPH, iPressure, iProximity, iTemperature, iVDiv,
|
||||
iWater.
|
||||
|
||||
* Light controller
|
||||
* Light sensor
|
||||
* Temperature sensor
|
||||
* Humidity sensor
|
||||
* Pressure sensor
|
||||
* Gas sensor
|
||||
* Analog to digital converter
|
||||
The developer community is invited to propose new interfaces for actuator types.
|
||||
|
||||
The developer community is welcome to submit feedback on existing categories or
|
||||
suggest new ones.
|
||||
The UPM project is joining the Eclipse Foundation as an Eclipse IoT project.
|
||||
You can read more about this [here](https://projects.eclipse.org/proposals/eclipse-upm).
|
||||
|
||||
### Example
|
||||
|
||||
@ -97,12 +97,16 @@ See building documentation [here](docs/building.md).
|
||||
|
||||
A quick way to add a new sensor driver is to port existing code from another
|
||||
platform (e.g. Arduino) and swap the IO calls to the MRAA API. This of course
|
||||
assumes either ownership of the original code or licensing that allows
|
||||
unrestricted redistribution.
|
||||
assumes either ownership of the original code or a MIT compatible license that
|
||||
allows unrestricted redistribution.
|
||||
|
||||
The [porting](docs/porting.md) section has more information on this process,
|
||||
and there is an example available based on the max31855 [sensor](docs/max31855.md).
|
||||
|
||||
We have an [on demand webinar](https://software.seek.intel.com/IoT_WebinarSeries_Reg)
|
||||
available that covers using an IDE to develop for the UPM project along with other
|
||||
considerations for new contributions.
|
||||
|
||||
Read more on creating Java [bindings](docs/creating_java_bindings.md) for your
|
||||
new driver.
|
||||
|
||||
@ -114,7 +118,8 @@ The name you pick for a newly added sensor needs to be unique in the UPM library
|
||||
Then, please go over this short set of rules for new [contributions](docs/contributions.md).
|
||||
Make sure you add yourself as an author on every new code file submitted.
|
||||
If you are providing a fix with significant changes, feel free to add yourself
|
||||
as a contributor. Signing-off your commits is mandatory.
|
||||
as a contributor. Signing-off your commits is mandatory and acts as an
|
||||
acknowledgment of the committer agreement.
|
||||
|
||||
Documenting your code is also a big part of the task. We have a strict set of
|
||||
tags used to classify our sensors and their capabilities. You can find out more
|
||||
@ -137,9 +142,6 @@ our API in a way that will break backwards compatibility. If you find yourself
|
||||
unable to compile code that was working fine before a library update, make sure
|
||||
you check the [API changes](docs/apichanges.md) section first.
|
||||
|
||||
**NOTE** - Several important API changes are currently underway for some of our
|
||||
widely used libraries including `libupm-grove`
|
||||
|
||||
### Changelog
|
||||
Version changelog [here](docs/changelog.md).
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
# this toolchain file comes from gnuradio project
|
||||
|
||||
set( CMAKE_SYSTEM_NAME Linux )
|
||||
#set( CMAKE_C_COMPILER $ENV{CC} )
|
||||
#set( CMAKE_CXX_COMPILER $ENV{CXX} )
|
||||
string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR $ENV{SDKTARGETSYSROOT})
|
||||
string(REGEX REPLACE "sysroots/" "" CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
|
||||
set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE )
|
||||
set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) #same flags for C sources
|
||||
set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE ) #same flags for C sources
|
||||
set( CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib )
|
||||
set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
|
||||
set( CMAKE_INSTALL_PREFIX $ENV{OECORE_TARGET_SYSROOT}/usr CACHE STRING "" FORCE)
|
||||
set( ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4 )
|
||||
set( ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib )
|
||||
|
||||
# for java
|
||||
set( JAVA_AWT_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
|
||||
set( JAVA_AWT_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjawt.so CACHE FILEPATH "" FORCE)
|
||||
set( JAVA_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
|
||||
set( JAVA_INCLUDE_PATH2 $ENV{JAVA_HOME}/include/linux CACHE PATH "" FORCE)
|
||||
set( JAVA_JVM_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjvm.so CACHE FILEPATH "" FORCE)
|
@ -1,136 +0,0 @@
|
||||
# Based on the Qt 5 processor detection code, so should be very accurate
|
||||
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
|
||||
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
|
||||
|
||||
# Regarding POWER/PowerPC, just as is noted in the Qt source,
|
||||
# "There are many more known variants/revisions that we do not handle/detect."
|
||||
|
||||
set(archdetect_c_code "
|
||||
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
|
||||
#if defined(__ARM_ARCH_7__) \\
|
||||
|| defined(__ARM_ARCH_7A__) \\
|
||||
|| defined(__ARM_ARCH_7R__) \\
|
||||
|| defined(__ARM_ARCH_7M__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
|
||||
#error cmake_ARCH armv7
|
||||
#elif defined(__ARM_ARCH_6__) \\
|
||||
|| defined(__ARM_ARCH_6J__) \\
|
||||
|| defined(__ARM_ARCH_6T2__) \\
|
||||
|| defined(__ARM_ARCH_6Z__) \\
|
||||
|| defined(__ARM_ARCH_6K__) \\
|
||||
|| defined(__ARM_ARCH_6ZK__) \\
|
||||
|| defined(__ARM_ARCH_6M__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
|
||||
#error cmake_ARCH armv6
|
||||
#elif defined(__ARM_ARCH_5TEJ__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
|
||||
#error cmake_ARCH armv5
|
||||
#else
|
||||
#error cmake_ARCH arm
|
||||
#endif
|
||||
#elif defined(__i586) || defined(__i586__)
|
||||
#error cmake_ARCH i586
|
||||
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#error cmake_ARCH i386
|
||||
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
|
||||
#error cmake_ARCH x86_64
|
||||
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||
#error cmake_ARCH ia64
|
||||
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|
||||
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|
||||
|| defined(_M_MPPC) || defined(_M_PPC)
|
||||
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
|
||||
#error cmake_ARCH ppc64
|
||||
#else
|
||||
#error cmake_ARCH ppc
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#error cmake_ARCH unknown
|
||||
")
|
||||
|
||||
# Set ppc_support to TRUE before including this file or ppc and ppc64
|
||||
# will be treated as invalid architectures since they are no longer supported by Apple
|
||||
|
||||
function(target_architecture output_var)
|
||||
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
||||
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
|
||||
# First let's normalize the order of the values
|
||||
|
||||
# Note that it's not possible to compile PowerPC applications if you are using
|
||||
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
|
||||
# disable it by default
|
||||
# See this page for more information:
|
||||
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
|
||||
|
||||
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
|
||||
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
|
||||
|
||||
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
|
||||
set(osx_arch_ppc TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "i386")
|
||||
set(osx_arch_i386 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "x86_64")
|
||||
set(osx_arch_x86_64 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
|
||||
set(osx_arch_ppc64 TRUE)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Now add all the architectures in our normalized order
|
||||
if(osx_arch_ppc)
|
||||
list(APPEND ARCH ppc)
|
||||
endif()
|
||||
|
||||
if(osx_arch_i386)
|
||||
list(APPEND ARCH i386)
|
||||
endif()
|
||||
|
||||
if(osx_arch_x86_64)
|
||||
list(APPEND ARCH x86_64)
|
||||
endif()
|
||||
|
||||
if(osx_arch_ppc64)
|
||||
list(APPEND ARCH ppc64)
|
||||
endif()
|
||||
else()
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
|
||||
|
||||
enable_language(C)
|
||||
|
||||
# Detect the architecture in a rather creative way...
|
||||
# This compiles a small C program which is a series of ifdefs that selects a
|
||||
# particular #error preprocessor directive whose message string contains the
|
||||
# target architecture. The program will always fail to compile (both because
|
||||
# file is not a valid C program, and obviously because of the presence of the
|
||||
# #error preprocessor directives... but by exploiting the preprocessor in this
|
||||
# way, we can detect the correct target architecture even when cross-compiling,
|
||||
# since the program itself never needs to be run (only the compiler/preprocessor)
|
||||
try_run(
|
||||
run_result_unused
|
||||
compile_result_unused
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
"${CMAKE_BINARY_DIR}/arch.c"
|
||||
COMPILE_OUTPUT_VARIABLE ARCH
|
||||
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
|
||||
)
|
||||
|
||||
# Parse the architecture name from the compiler output
|
||||
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
|
||||
|
||||
# Get rid of the value marker leaving just the architecture name
|
||||
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
|
||||
|
||||
# If we are compiling with an unknown architecture this variable should
|
||||
# already be set to "unknown" but in the case that it's empty (i.e. due
|
||||
# to a typo in the code), then set it to unknown
|
||||
if (NOT ARCH)
|
||||
set(ARCH unknown)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(${output_var} "${ARCH}" PARENT_SCOPE)
|
||||
endfunction()
|
@ -56,20 +56,6 @@ services:
|
||||
- BUILDEXAMPLES=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8"
|
||||
|
||||
ipk:
|
||||
extends: all
|
||||
environment:
|
||||
- IPK=ON
|
||||
- BUILDDOC=OFF
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 package"
|
||||
|
||||
rpm:
|
||||
extends: all
|
||||
environment:
|
||||
- RPM=ON
|
||||
- BUILDDOC=OFF
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 package"
|
||||
|
||||
npm:
|
||||
extends: all
|
||||
environment:
|
||||
@ -78,12 +64,10 @@ services:
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 npmpkg"
|
||||
|
||||
sonar-scan:
|
||||
extends: all
|
||||
extends: base
|
||||
image: inteliotdevkit/upm-sonar
|
||||
environment:
|
||||
- BUILDSWIGPYTHON=ON
|
||||
- BUILDSWIGNODE=ON
|
||||
- BUILDSWIGJAVA=ON
|
||||
- BUILDEXAMPLES=ON
|
||||
- BUILDTESTS=OFF
|
||||
- SONAR_TOKEN
|
||||
- SONAR_ORG
|
||||
- SONAR_PROJ_KEY
|
||||
|
@ -4,6 +4,13 @@ API Changes {#apichanges}
|
||||
Here's a list of other API changes made to the library that break source/binary
|
||||
compatibility between releases:
|
||||
|
||||
# v2.0.0
|
||||
* Sensors implementing the old interfaces (bme280, bmpx8x, si7005, si1132,
|
||||
max44009, lp8860, ds1808lc, hlg150h) have been updated to use the new ones,
|
||||
hence some function names and parameters will be different.
|
||||
* Removed deprecated basic grove classes from project, see API changes for
|
||||
v1.1.0 and prior for a complete list
|
||||
|
||||
# v1.7.0
|
||||
* The interface of **kx122** has been modified to return values instead
|
||||
of receiving pointers. This applies to member functions: getWhoAmI,
|
||||
|
@ -4,6 +4,21 @@ Changelog {#changelog}
|
||||
Here's a list summarizing some of the key undergoing changes to our library
|
||||
from earlier versions:
|
||||
|
||||
### v2.0.0
|
||||
|
||||
* Reworked existing interfaces and extended the list to include iAcceleration,
|
||||
iAngle, iButton, iClock, iCollision, iDistance, iDistanceInterrupter, iEC,
|
||||
iElectromagnet, iEmg, iGas, iGps, iGyroscope, iHallEffect, iHeartRate, iHumidity,
|
||||
iLight, iLineFinder, iMagnetometer, iMoisture, iMotion, iOrp, iPH, iPressure,
|
||||
iProximity, iTemperature, iVDiv, iWater
|
||||
* Provided overloaded string based constructors for a good number of sensors,
|
||||
allowing initialization from external frameworks without type knowledge
|
||||
* Removed deprecated basic grove classes from project
|
||||
* Replaced 6 unsafe occurrences of sprintf() usage
|
||||
* Cleaned-up build system around target arch detection and cpack usage, added
|
||||
detection and resolution of tinyb library when used as a dependency
|
||||
* New sensors: 2jciebu01_ble, 2jciebu01_usb
|
||||
|
||||
### v1.7.1
|
||||
|
||||
* Bumped library compatibility to new MRAA 2.0 APIs
|
||||
|
Before Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 159 KiB |
Before Width: | Height: | Size: 138 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 167 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 97 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 90 KiB |
539
examples/c++/2jciebu01_ble.cxx
Normal file
@ -0,0 +1,539 @@
|
||||
/*
|
||||
* Author: Hiroyuki Mino <omronsupportupm@omron.com>
|
||||
* Copyright (c) 2019 Omron Electronic Components - Americas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
/* omron sensor headers */
|
||||
#include "2jciebu01_ble.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
#define PREVIOUS_MENU_CHOICE 8
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
|
||||
upm::OM2JCIEBU_BLE::om2jciebuData_t om2jciebuSensorData;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if(signum == SIGABRT) {
|
||||
std::cout << "Exiting..." << std::endl;
|
||||
}
|
||||
if(signum == SIGINT) {
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void getSensorData(OM2JCIEBU_BLE *p_om2jcieble)
|
||||
{
|
||||
|
||||
if(p_om2jcieble == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
uint16_t parameterChoice = 0;
|
||||
int displayDelay = 0;
|
||||
uint16_t sensorParamData = 0;
|
||||
uint32_t pressureData = 0;
|
||||
bool seconds_validate = false;
|
||||
|
||||
p_om2jcieble->getDiscoveredServices(OM2JCIEBU_BLE::ALL_PARAM);
|
||||
while(true) {
|
||||
printf("************************************************************\r\n");
|
||||
printf("Please select sensor attribute for display\r\n");
|
||||
printf("0) All parameter\r\n");
|
||||
printf("1) Temperature data\r\n");
|
||||
printf("2) Relative humidity data\r\n");
|
||||
printf("3) Ambient light data\r\n");
|
||||
printf("4) Barometric pressure data\r\n");
|
||||
printf("5) Sound noise data\r\n");
|
||||
printf("6) eTVOC data\r\n");
|
||||
printf("7) eCO2 data\r\n");
|
||||
printf("8) Return to main menu\r\n");
|
||||
printf("Note :: Press Ctrl+C for sensor attribute display menu\r\n");
|
||||
printf("************************************************************\r\n");
|
||||
while(!(std::cin >> parameterChoice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
if(parameterChoice >= OM2JCIEBU_BLE::ALL_PARAM && parameterChoice <= OM2JCIEBU_BLE::ECO2) {
|
||||
flag = 1;
|
||||
printf("Please enter time interval (in Seconds), for display sensor data\r\n");
|
||||
while(!seconds_validate) {
|
||||
cin >> displayDelay;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (displayDelay >= 1 && displayDelay <= 10)) {
|
||||
seconds_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an second between 1 to 10!" << endl;
|
||||
}
|
||||
}
|
||||
while(flag) {
|
||||
switch(parameterChoice) {
|
||||
case OM2JCIEBU_BLE::ALL_PARAM:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::ALL_PARAM, &om2jciebuSensorData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Sensor Attribute Values ***************\r\n");
|
||||
printf("Sequence Number :: %d \r\n", om2jciebuSensorData.sequence_number);
|
||||
printf("Temperature :: %d degC\r\n", om2jciebuSensorData.temperature);
|
||||
printf("Relative humidity :: %d RH\r\n", om2jciebuSensorData.relative_humidity);
|
||||
printf("Ambient light :: %d lx\r\n", om2jciebuSensorData.ambient_light);
|
||||
printf("Barometric pressure :: %d hPa\r\n", om2jciebuSensorData.pressure);
|
||||
printf("Sound noise :: %d dB\r\n", om2jciebuSensorData.noise);
|
||||
printf("eTVOC :: %d ppb\r\n", om2jciebuSensorData.eTVOC);
|
||||
printf("eCO2 :: %d ppm\r\n", om2jciebuSensorData.eCO2);
|
||||
printf("**********************************************************\r\n");
|
||||
memset(&om2jciebuSensorData, 0, sizeof(om2jciebuSensorData));
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::TEMP:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::TEMP, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Temperature Attribute Values ***************\r\n");
|
||||
printf("Temperature :: %d degC\r\n", sensorParamData);
|
||||
printf("************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::HUMIDITY:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::HUMIDITY, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Relative humidity Attribute Values ***************\r\n");
|
||||
printf("Relative humidity :: %d RH\r\n", sensorParamData);
|
||||
printf("******************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::AMBIENT_LIGHT:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::AMBIENT_LIGHT, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Ambient light Attribute Values ***************\r\n");
|
||||
printf("Ambient light :: %d lx\r\n", sensorParamData);
|
||||
printf("***************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::PRESSURE:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::PRESSURE, &pressureData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Barometric pressure Attribute Values ***************\r\n");
|
||||
printf("Barometric pressure :: %d hPa\r\n", pressureData);
|
||||
printf("********************************************************************\r\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_BLE::NOISE:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::NOISE, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Sound noise Attribute Values ***************\r\n");
|
||||
printf("Sound noise :: %d dB\r\n", sensorParamData);
|
||||
printf("*************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_BLE::ETVOC:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::ETVOC, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** eTVOC Attribute Values ***************\r\n");
|
||||
printf("eTVOC :: %d ppb\r\n", sensorParamData);
|
||||
printf("*******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ECO2:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::ECO2, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** eCO2 Attribute Values ***************\r\n");
|
||||
printf("eCO2 :: %d ppm\r\n\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
printf("\r\n");
|
||||
p_om2jcieble->delay(displayDelay);
|
||||
}
|
||||
} else if(parameterChoice == PREVIOUS_MENU_CHOICE) {
|
||||
break;
|
||||
} else {
|
||||
printf("Invalid choice\r\n");
|
||||
}
|
||||
seconds_validate = false;
|
||||
}
|
||||
}
|
||||
|
||||
void getAdvSensorData(OM2JCIEBU_BLE *p_om2jcieble)
|
||||
{
|
||||
if(p_om2jcieble == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t parameterChoice = 0, sensorParamData = 0;
|
||||
int displayDelay = 0;
|
||||
uint32_t pressureData = 0;
|
||||
bool seconds_validate = false;
|
||||
|
||||
while(true) {
|
||||
printf("************************************************************\r\n");
|
||||
printf("Please select sensor attribute for display\r\n");
|
||||
printf("0) All parameter\r\n");
|
||||
printf("1) Temperature data\r\n");
|
||||
printf("2) Relative humidity data\r\n");
|
||||
printf("3) Ambient light data\r\n");
|
||||
printf("4) Barometric pressure data\r\n");
|
||||
printf("5) Sound noise data\r\n");
|
||||
printf("6) eTVOC data\r\n");
|
||||
printf("7) eCO2 data\r\n");
|
||||
printf("8) Return to main menu\r\n");
|
||||
printf("Note :: Press Ctrl+C for sensor attribute display menu\r\n");
|
||||
printf("************************************************************\r\n");
|
||||
while(!(std::cin >> parameterChoice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
if(parameterChoice >= OM2JCIEBU_BLE::ALL_PARAM && parameterChoice <= OM2JCIEBU_BLE::ECO2) {
|
||||
flag = 1;
|
||||
printf("Please enter time interval (in Seconds), for display sensor data\r\n");
|
||||
while(!seconds_validate) {
|
||||
cin >> displayDelay;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (displayDelay >= 1 && displayDelay <= 10)) {
|
||||
seconds_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an second between 1 and 10!" << endl;
|
||||
}
|
||||
}
|
||||
while(flag) {
|
||||
switch(parameterChoice) {
|
||||
case OM2JCIEBU_BLE::ALL_PARAM:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::ALL_PARAM, &om2jciebuSensorData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Sensor Attribute Values ***************\r\n");
|
||||
printf("Sequence Number :: %d \r\n", om2jciebuSensorData.sequence_number);
|
||||
printf("Temperature :: %d degC\r\n", om2jciebuSensorData.temperature);
|
||||
printf("Relative humidity :: %d RH\r\n", om2jciebuSensorData.relative_humidity);
|
||||
printf("Ambient light :: %d lx\r\n", om2jciebuSensorData.ambient_light);
|
||||
printf("Barometric pressure :: %d hPa\r\n", om2jciebuSensorData.pressure);
|
||||
printf("Sound noise :: %d dB\r\n", om2jciebuSensorData.noise);
|
||||
printf("eTVOC :: %d ppb\r\n", om2jciebuSensorData.eTVOC);
|
||||
printf("eCO2 :: %d ppm\r\n", om2jciebuSensorData.eCO2);
|
||||
printf("*********************************************************************\r\n");
|
||||
memset(&om2jciebuSensorData, 0, sizeof(om2jciebuSensorData));
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::TEMP:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::TEMP, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Temperature Attribute Values ***************\r\n");
|
||||
printf("Temperature :: %d degC\r\n", sensorParamData);
|
||||
printf("**************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::HUMIDITY:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::HUMIDITY, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Relative humidity Attribute Values ***************\r\n");
|
||||
printf("Relative humidity :: %d RH\r\n", sensorParamData);
|
||||
printf("********************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::AMBIENT_LIGHT:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::AMBIENT_LIGHT, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Ambient light Attribute Values ***************\r\n");
|
||||
printf("Ambient light :: %d lx\r\n", sensorParamData);
|
||||
printf("***************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::PRESSURE:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::PRESSURE, &pressureData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Barometric pressure Attribute Values ***************\r\n");
|
||||
printf("Barometric pressure :: %d hPa\r\n", pressureData);
|
||||
printf("*********************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_BLE::NOISE:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::NOISE, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Sound noise Attribute Values ***************\r\n");
|
||||
printf("Sound noise :: %d dB\r\n", sensorParamData);
|
||||
printf("*************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_BLE::ETVOC:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::ETVOC, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("**************** Advertisement eTVOC Attribute Values ******************\r\n");
|
||||
printf("eTVOC :: %d ppb\r\n", sensorParamData);
|
||||
printf("************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ECO2:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::ECO2, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement eCO2 Attribute Values ***************\r\n");
|
||||
printf("eCO2 :: %d ppm\r\n\r\n", sensorParamData);
|
||||
printf("******************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
printf("\r\n");
|
||||
p_om2jcieble->delay(displayDelay);
|
||||
}
|
||||
} else if(parameterChoice == PREVIOUS_MENU_CHOICE) {
|
||||
break;
|
||||
} else {
|
||||
printf("Invalid choice\r\n");
|
||||
}
|
||||
seconds_validate = false;
|
||||
}
|
||||
}
|
||||
|
||||
void configureLEDSetting(OM2JCIEBU_BLE *p_om2jcieble)
|
||||
{
|
||||
if(p_om2jcieble == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
int led_choice = 0;
|
||||
unsigned short int red_scale = 0, green_scale = 0, blue_scale = 0;
|
||||
bool red_scale_validate = false, green_scale_validate = false, blue_scale_validate = false;
|
||||
printf("************** Sensor LED Configuration ***************\r\n");
|
||||
printf("Please select a operation for LED\r\n");
|
||||
printf("0) Normally OFF\r\n");
|
||||
printf("1) Normally ON\r\n");
|
||||
printf("2) Temperature value scales\r\n");
|
||||
printf("3) Relative humidity value scales\r\n");
|
||||
printf("4) Ambient light value scales\r\n");
|
||||
printf("5) Barometric pressure value scales\r\n");
|
||||
printf("6) Sound noise value scales\r\n");
|
||||
printf("7) eTVOC value scales\r\n");
|
||||
printf("8) SI vale scales\r\n");
|
||||
printf("9) PGA value scales\r\n");
|
||||
printf("**********************************************************\r\n");
|
||||
while(!(std::cin >> led_choice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
|
||||
if(led_choice == OM2JCIEBU_BLE::NORMALLY_ON) {
|
||||
printf("Please select a LED color scale\r\n");
|
||||
printf("Please enter Red Color scale (scale range 0 to 255)\r\n");
|
||||
while(!red_scale_validate) {
|
||||
cin >> red_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (red_scale >= 0 && red_scale <= 255)) {
|
||||
red_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an red color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please enter Green Color scale(scale range 0 to 255)\r\n");
|
||||
while(!green_scale_validate) {
|
||||
cin >> green_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (green_scale >= 0 && green_scale <= 255)) {
|
||||
green_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an green color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please enter Blue Color scale(scale range 0 to 255)\r\n");
|
||||
while(!blue_scale_validate) {
|
||||
cin >> blue_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (blue_scale >= 0 && blue_scale <= 255)) {
|
||||
blue_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an blue color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::NORMALLY_ON, red_scale, green_scale, blue_scale);
|
||||
} else {
|
||||
switch(led_choice) {
|
||||
case OM2JCIEBU_BLE::NORMALLY_OFF:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::NORMALLY_OFF, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::TEMP_SACLE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::TEMP_SACLE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::HUMIDITY_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::HUMIDITY_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::AMBIENT_LIGHT_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::AMBIENT_LIGHT_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::PRESSURE_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::PRESSURE_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::NOISE_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::NOISE_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ETVOC_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::ETVOC_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::SI_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::SI_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::PGA_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::PGA_SCALE, 0, 0, 0);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Wrong LED scale choice please try again" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void configureAdvInterval(OM2JCIEBU_BLE *p_om2jcieble)
|
||||
{
|
||||
if(p_om2jcieble == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
uint16_t millisecond = 0;
|
||||
bool milisecond_validate = false;
|
||||
int advertising_mode = 0;
|
||||
printf("************** Sensor Advertise Configuration ***************\r\n");
|
||||
printf("Please enter time interval (in Milliseconds), for changing Advertise interval, between 100 to 10240 milliseconds\r\n");
|
||||
while(!milisecond_validate) {
|
||||
cin >> millisecond;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (millisecond >= 100 && millisecond <= 10240)) {
|
||||
milisecond_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an millisecond between 100 and 10240!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please select an Advertise mode with the selected Advertise interval \r\n");
|
||||
printf("1) Sensor data\r\n");
|
||||
printf("2) Calculation data\r\n");
|
||||
printf("3) Sensor data and Calculation data\r\n");
|
||||
printf("4) Sensor flag and Calculation flag\r\n");
|
||||
printf("5) Serial number\r\n");
|
||||
while(!(std::cin >> advertising_mode)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
switch(advertising_mode) {
|
||||
case OM2JCIEBU_BLE::SENSOR_DATA:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::SENSOR_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ACCELERATION_DATA:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::ACCELERATION_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ACCELERATION_SENSOR_DATA:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::ACCELERATION_SENSOR_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ACCELERATION_SENSOR_FLAG:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::ACCELERATION_SENSOR_FLAG);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::SERIAL_NUMBER:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::SERIAL_NUMBER);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Invalid choice\n";
|
||||
}
|
||||
printf("**************************************************************\r\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int operation_choice = 0;
|
||||
if(argc <= 1) {
|
||||
std::cout << "usage ./a.out xx:xx:xx:xx:xx:xx" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
signal(SIGABRT, sig_handler);
|
||||
signal(SIGINT, sig_handler);
|
||||
upm::OM2JCIEBU_BLE om2jciebu_ble(argv[1]);
|
||||
while(true) {
|
||||
std::cout << "*************************************************************" << std::endl;
|
||||
std::cout << "Please choose one option for Omron sensor operation" << std::endl;
|
||||
std::cout << "1) Display Advertisement Sensor attriutes" << std::endl;
|
||||
std::cout << "2) Display Sensor attriutes" << std::endl;
|
||||
std::cout << "3) Configure LED setting " << std::endl;
|
||||
std::cout << "4) Configure advertise setting" << std::endl;
|
||||
std::cout << "5) Exit" << std::endl;
|
||||
std::cout << "*************************************************************" << std::endl;
|
||||
while(!(std::cin >> operation_choice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
|
||||
switch(operation_choice) {
|
||||
case 1:
|
||||
getAdvSensorData(&om2jciebu_ble);
|
||||
break;
|
||||
case 2:
|
||||
getSensorData(&om2jciebu_ble);
|
||||
break;
|
||||
case 3:
|
||||
configureLEDSetting(&om2jciebu_ble);
|
||||
break;
|
||||
case 4:
|
||||
configureAdvInterval(&om2jciebu_ble);
|
||||
break;
|
||||
case 5:
|
||||
std::cout << "Application Exited" << std::endl;
|
||||
om2jciebu_ble.removeBleDevice();
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Invalid choice" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
414
examples/c++/2jciebu01_usb.cxx
Normal file
@ -0,0 +1,414 @@
|
||||
/*
|
||||
* Author: Hiroyuki Mino <omronsupportupm@omron.com>
|
||||
* Copyright (c) 2019 Omron Electronic Components - Americas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
/* omron sensor headers */
|
||||
#include "2jciebu01_usb.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
#define PREVIOUS_MENU_CHOICE 10
|
||||
|
||||
upm::OM2JCIEBU_UART::om2jciebuData_t om2jciebuSensorData;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if(signum == SIGABRT) { //check for Abort signal
|
||||
std::cout << "Exiting..." << std::endl;
|
||||
}
|
||||
if(signum == SIGINT) { //check for Interrupt signal
|
||||
std::cout << "Exiting..." << std::endl;
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void getSensorData(OM2JCIEBU_UART *p_om2jcieuart)
|
||||
{
|
||||
if(p_om2jcieuart == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
uint16_t parameterChoice = 0;
|
||||
int displayDelay = 0;
|
||||
bool seconds_validate = false;
|
||||
uint16_t sensorParamData = 0;
|
||||
uint32_t pressureData = 0;
|
||||
|
||||
while(true) {
|
||||
printf("************************************************************\r\n");
|
||||
printf("Please select sensor attribute for display\r\n");
|
||||
printf("0) All parameter\r\n");
|
||||
printf("1) Temperature data\r\n");
|
||||
printf("2) Relative humidity data\r\n");
|
||||
printf("3) Ambient light data\r\n");
|
||||
printf("4) Barometric pressure data\r\n");
|
||||
printf("5) Sound noise data\r\n");
|
||||
printf("6) eTVOC data\r\n");
|
||||
printf("7) eCO2 data\r\n");
|
||||
printf("8) Discomfort index data\r\n");
|
||||
printf("9) Heat stroke data\r\n");
|
||||
printf("10) Return to main menu\r\n");
|
||||
printf("Note :: Press Ctrl+C for sensor attribute display menu\r\n");
|
||||
printf("************************************************************\r\n");
|
||||
while(!(std::cin >> parameterChoice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
if(parameterChoice >= OM2JCIEBU_UART::ALL_PARAM && parameterChoice <= OM2JCIEBU_UART::HEAT_STROKE) {
|
||||
flag = 1;
|
||||
printf("Please enter time interval (in Seconds), for display sensor data\r\n");
|
||||
while(!seconds_validate) { //validate user input values
|
||||
cin >> displayDelay;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (displayDelay >= 1 && displayDelay <= 10)) {
|
||||
seconds_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an second between 1 to 10!" << endl;
|
||||
}
|
||||
}
|
||||
while(flag) {
|
||||
switch(parameterChoice) {
|
||||
case OM2JCIEBU_UART::ALL_PARAM:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::ALL_PARAM, &om2jciebuSensorData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Sensor Attribute Values ***************\r\n");
|
||||
printf("Sequence Number :: %d \r\n", om2jciebuSensorData.sequence_number);
|
||||
printf("Temperature :: %d degC\r\n", om2jciebuSensorData.temperature);
|
||||
printf("Relative humidity :: %d RH\r\n", om2jciebuSensorData.relative_humidity);
|
||||
printf("Ambient light :: %d lx\r\n", om2jciebuSensorData.ambient_light);
|
||||
printf("Barometric pressure :: %d hPa\r\n", om2jciebuSensorData.pressure);
|
||||
printf("Sound noise :: %d dB\r\n", om2jciebuSensorData.noise);
|
||||
printf("eTVOC :: %d ppb\r\n", om2jciebuSensorData.eTVOC);
|
||||
printf("eCO2 :: %d ppm\r\n", om2jciebuSensorData.eCO2);
|
||||
printf("Discomfort index :: %d \r\n", om2jciebuSensorData.discomfort_index);
|
||||
printf("Heat stroke :: %d degC\r\n", om2jciebuSensorData.heat_stroke);
|
||||
printf("**********************************************************\r\n");
|
||||
memset(&om2jciebuSensorData, 0, sizeof(om2jciebuSensorData));
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::TEMP:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::TEMP, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Temperature Attribute Values ***************\r\n");
|
||||
printf("Temperature :: %d degC\r\n", sensorParamData);
|
||||
printf("************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::HUMIDITY:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::HUMIDITY, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Relative humidity Attribute Values ***************\r\n");
|
||||
printf("Relative humidity :: %d RH\r\n", sensorParamData);
|
||||
printf("******************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::AMBIENT_LIGHT:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::AMBIENT_LIGHT, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Ambient light Attribute Values ***************\r\n");
|
||||
printf("Ambient light :: %d lx\r\n", sensorParamData);
|
||||
printf("**************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::PRESSURE:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::PRESSURE, &pressureData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Barometric pressure Attribute Values ***************\r\n");
|
||||
printf("Barometric pressure :: %d hPa\r\n", pressureData);
|
||||
printf("********************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_UART::NOISE:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::NOISE, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Sound noise Attribute Values ***************\r\n");
|
||||
printf("Sound noise :: %d dB\r\n", sensorParamData);
|
||||
printf("************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_UART::ETVOC:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::ETVOC, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** eTVOC Attribute Values ***************\r\n");
|
||||
printf("eTVOC :: %d ppb\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::ECO2:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::ECO2, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** eCO2 Attribute Values ***************\r\n");
|
||||
printf("eCO2 :: %d ppm\r\n\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::DISCOMFORT_INDEX:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::DISCOMFORT_INDEX, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** eCO2 Attribute Values ***************\r\n");
|
||||
printf("Discomfort index :: %d \r\n\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::HEAT_STROKE:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::HEAT_STROKE, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** eCO2 Attribute Values ***************\r\n");
|
||||
printf("Heat stroke :: %d degC\r\n\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
printf("\r\n");
|
||||
p_om2jcieuart->delay(displayDelay);
|
||||
}
|
||||
} else if(parameterChoice == PREVIOUS_MENU_CHOICE) {
|
||||
break;
|
||||
} else {
|
||||
printf("Invalid choice\r\n");
|
||||
}
|
||||
seconds_validate = false;
|
||||
}
|
||||
}
|
||||
|
||||
void configureLEDSetting(OM2JCIEBU_UART *p_om2jcieuart)
|
||||
{
|
||||
if(p_om2jcieuart == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
int led_choice = 0;
|
||||
bool red_scale_validate = false, green_scale_validate = false, blue_scale_validate = false;
|
||||
unsigned short int red_scale = 0, green_scale = 0, blue_scale = 0;
|
||||
printf("************** Sensor LED Configuration ***************\r\n");
|
||||
printf("Please select a operation for LED\r\n");
|
||||
printf("0) Normally OFF\r\n");
|
||||
printf("1) Normally ON\r\n");
|
||||
printf("2) Temperature value scales\r\n");
|
||||
printf("3) Relative humidity value scales\r\n");
|
||||
printf("4) Ambient light value scales\r\n");
|
||||
printf("5) Barometric pressure value scales\r\n");
|
||||
printf("6) Sound noise value scales\r\n");
|
||||
printf("7) eTVOC value scales\r\n");
|
||||
printf("8) SI vale scales\r\n");
|
||||
printf("9) PGA value scales\r\n");
|
||||
printf("**********************************************************\r\n");
|
||||
while(!(std::cin >> led_choice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
|
||||
if(led_choice == OM2JCIEBU_UART::NORMALLY_ON) {
|
||||
printf("Please Select a LED color scale\r\n");
|
||||
printf("Please enter Red Color scale (scale range 0 to 255)\r\n");
|
||||
while(!red_scale_validate) {
|
||||
cin >> red_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (red_scale >= 0 && red_scale <= 255)) {
|
||||
red_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an red color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please enter Green Color scale(scale range 0 to 255)\r\n");
|
||||
while(!green_scale_validate) {
|
||||
cin >> green_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (green_scale >= 0 && green_scale <= 255)) {
|
||||
green_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an green color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please enter Blue Color scale(scale range 0 to 255)\r\n");
|
||||
while(!blue_scale_validate) {
|
||||
cin >> blue_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (blue_scale >= 0 && blue_scale <= 255)) {
|
||||
blue_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an blue color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::NORMALLY_ON, red_scale, green_scale, blue_scale);
|
||||
} else {
|
||||
switch(led_choice) {
|
||||
case OM2JCIEBU_UART::NORMALLY_OFF:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::NORMALLY_OFF, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::TEMP_SACLE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::TEMP_SACLE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::HUMIDITY_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::HUMIDITY_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::AMBIENT_LIGHT_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::AMBIENT_LIGHT_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::PRESSURE_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::PRESSURE_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::NOISE_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::NOISE_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::ETVOC_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::ETVOC_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::SI_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::SI_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::PGA_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::PGA_SCALE, 0, 0, 0);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Wrong LED scale choice please try again" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void configureAdvInterval(OM2JCIEBU_UART *p_om2jcieuart)
|
||||
{
|
||||
if(p_om2jcieuart == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
bool millisecond_validate = false;
|
||||
uint16_t millisecond = 0;
|
||||
int advertising_mode = 0;
|
||||
printf("************** Sensor Advertise Configuration ***************\r\n");
|
||||
printf("Please enter time interval (in Milliseconds), for changing Advertise interval, between 100 to 10240 milliseconds\r\n");
|
||||
while(!millisecond_validate) {//validate millisecond
|
||||
cin >> millisecond;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (millisecond >= 100 && millisecond <= 10240)) {
|
||||
millisecond_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an milisecond between 100 and 10240!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please select an Advertise mode with the selected Advertise interval \r\n");
|
||||
printf("1) Sensor data\r\n");
|
||||
printf("2) Calculation data\r\n");
|
||||
printf("3) Sensor data and Calculation data\r\n");
|
||||
printf("4) Sensor flag and Calculation flag\r\n");
|
||||
printf("5) Serial number\r\n");
|
||||
while(!(std::cin >> advertising_mode)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
switch(advertising_mode) {
|
||||
case OM2JCIEBU_UART::SENSOR_DATA:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::SENSOR_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_UART::ACCELERATION_DATA:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::ACCELERATION_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_UART::ACCELERATION_SENSOR_DATA:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::ACCELERATION_SENSOR_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_UART::ACCELERATION_SENSOR_FLAG:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::ACCELERATION_SENSOR_FLAG);
|
||||
break;
|
||||
case OM2JCIEBU_UART::SERIAL_NUMBER:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::SERIAL_NUMBER);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Invalid choice\n";
|
||||
}
|
||||
printf("**************************************************************\r\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int operation_choice = 0;
|
||||
if(argc <= 1) {
|
||||
std::cout << "usage ./a.out /dev/ttyUSB*" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
signal(SIGABRT, sig_handler);
|
||||
signal(SIGINT, sig_handler);
|
||||
upm::OM2JCIEBU_UART om2jciebu_uart(argv[1], 115200);
|
||||
om2jciebu_uart.setMode(8, mraa::UART_PARITY_NONE, 1);
|
||||
om2jciebu_uart.setFlowControl(false, false);
|
||||
while(true) {
|
||||
std::cout << "*************************************************************" << std::endl;
|
||||
std::cout << "Please choose one option for Omron sensor operation" << std::endl;
|
||||
std::cout << "1) Display Sensor attriutes" << std::endl;
|
||||
std::cout << "2) Configure LED setting " << std::endl;
|
||||
std::cout << "3) Configure advertise setting" << std::endl;
|
||||
std::cout << "4) Exit" << std::endl;
|
||||
std::cout << "*************************************************************" << std::endl;
|
||||
while(!(std::cin >> operation_choice)) { //validate operation choice from user input
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
switch(operation_choice) {
|
||||
case 1:
|
||||
getSensorData(&om2jciebu_uart);
|
||||
break;
|
||||
case 2:
|
||||
configureLEDSetting(&om2jciebu_uart);
|
||||
break;
|
||||
case 3:
|
||||
configureAdvInterval(&om2jciebu_uart);
|
||||
break;
|
||||
case 4:
|
||||
std::cout << "Application Exited" << std::endl;
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Invalid choice" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,16 +3,10 @@ file (GLOB example_src_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cxx")
|
||||
|
||||
# - Handle special cases here --------------------------------------------------
|
||||
|
||||
# Test humidity interface for 2 sensor libraries
|
||||
add_example(interfaces-humiditysensor.cxx TARGETS si7005 bmp280)
|
||||
# Test pressure interface for 2 sensor libraries
|
||||
add_example(interfaces-pressuresensor.cxx TARGETS bmp280 bmpx8x)
|
||||
# Test temperature interface for 3 sensor libraries
|
||||
add_example(interfaces-temperaturesensor.cxx TARGETS bmp280 bmpx8x si7005)
|
||||
# Test light interface for 2 sensor libraries
|
||||
add_example(interfaces-lightsensor.cxx TARGETS si1132 max44009)
|
||||
# Test light controller interface for 3 sensor libraries
|
||||
add_example(interfaces-lightcontroller.cxx TARGETS lp8860 ds1808lc hlg150h)
|
||||
# Test temperature interface for 2 sensor libraries
|
||||
add_example(iTemperature_sample.cxx TARGETS interfaces lm35 abp)
|
||||
# Test light interface for 3 sensor libraries
|
||||
add_example(iLight_sample.cxx TARGETS interfaces apds9002 bh1750 max44009)
|
||||
|
||||
# - Create an executable for all other src files in this directory -------------
|
||||
foreach (_example_src ${example_src_list})
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ads1015.hpp"
|
||||
#include "iADC.hpp"
|
||||
#include "mraa/gpio.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
@ -39,24 +38,21 @@ int
|
||||
main()
|
||||
{
|
||||
/* Create an instance of the ADS1015 sensor */
|
||||
upm::ADS1015 sensor(EDISON_I2C_BUS);
|
||||
upm::ADS1015 adc(EDISON_I2C_BUS);
|
||||
mraa::Gpio gpio(EDISON_GPIO_SI7005_CS);
|
||||
gpio.dir(mraa::DIR_OUT_HIGH);
|
||||
|
||||
/* Show usage from the IADC interface */
|
||||
upm::IADC* adc = static_cast<upm::IADC*>(&sensor);
|
||||
|
||||
if (adc == NULL) {
|
||||
std::cout << "ADC not detected" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "ADC " << adc->getModuleName() << " detected. ";
|
||||
std::cout << adc->getNumInputs() << " inputs available" << std::endl;
|
||||
// if (adc == NULL) {
|
||||
// std::cout << "ADC not detected" << std::endl;
|
||||
// return 1;
|
||||
// }
|
||||
std::cout << "ADC " << adc.getModuleName() << " detected. ";
|
||||
std::cout << adc.getNumInputs() << " inputs available" << std::endl;
|
||||
while (true) {
|
||||
for (unsigned int i = 0; i < adc->getNumInputs(); ++i) {
|
||||
for (unsigned int i = 0; i < adc.getNumInputs(); ++i) {
|
||||
std::cout << "Input " << i;
|
||||
try {
|
||||
float voltage = adc->getVoltage(i);
|
||||
float voltage = adc.getVoltage(i);
|
||||
std::cout << ": Voltage = " << voltage << "V" << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
|
12
examples/c++/buzzer-initio.cxx
Normal file
@ -0,0 +1,12 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "buzzer.hpp"
|
||||
#include "buzzer_tones.h"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
upm::Buzzer buzzer("p:32,vol:0.01,play:3800:500000");
|
||||
return 0;
|
||||
}
|
@ -35,7 +35,7 @@ main(int argc, char** argv)
|
||||
int chord[] = { BUZZER_DO, BUZZER_RE, BUZZER_MI, BUZZER_FA, BUZZER_SOL, BUZZER_LA, BUZZER_SI };
|
||||
|
||||
// create Buzzer instance
|
||||
upm::Buzzer sound(5);
|
||||
upm::Buzzer sound(32);
|
||||
// print sensor name
|
||||
std::cout << sound.name() << std::endl;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define DS1808_GPIO_PWR 15 // Edison GP165
|
||||
|
||||
void
|
||||
printState(upm::ILightController& lightController)
|
||||
printState(upm::DS1808LC& lightController)
|
||||
{
|
||||
if (lightController.isPowered()) {
|
||||
std::cout << "Light is powered, brightness = " << lightController.getBrightness()
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "grovebutton.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
// This example uses GPIO 0
|
||||
//! [Interesting]
|
||||
|
||||
// Create the button object using GPIO pin 0
|
||||
upm::GroveButton button(0);
|
||||
|
||||
// Read the input and print, waiting one second between readings
|
||||
while (1) {
|
||||
std::cout << button.name() << " value is " << button.value() << std::endl;
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
// Delete the button object
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014-2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "groveled.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a 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::GroveLed led(2);
|
||||
|
||||
// start the light show
|
||||
led.on();
|
||||
|
||||
// just upm_delay until interrupted
|
||||
while (shouldRun)
|
||||
upm_delay(1);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
led.off();
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Contributions: Sarah Knepper <sarah.knepper@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "groveled.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
|
||||
// Create the Grove LED object using GPIO pin 2
|
||||
upm::GroveLed led(2);
|
||||
|
||||
// Print the name
|
||||
std::cout << led.name() << std::endl;
|
||||
|
||||
// Turn the LED on and off 10 times, pausing one second
|
||||
// between transitions
|
||||
for (int i = 0; i < 10; i++) {
|
||||
led.on();
|
||||
upm_delay(1);
|
||||
led.off();
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
// Delete the Grove LED object
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Contributions: Sarah Knepper <sarah.knepper@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "grovelight.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// Create the light sensor object using AIO pin 0
|
||||
upm::GroveLight light(0);
|
||||
|
||||
// Read the input and print both the raw value and a rough lux value,
|
||||
// waiting one second between readings
|
||||
while (1) {
|
||||
std::cout << light.name() << " raw value is " << light.raw_value() << ", which is roughly "
|
||||
<< light.value() << " lux" << std::endl;
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
// Delete the light sensor object
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "groverelay.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
// This example uses GPIO 0
|
||||
//! [Interesting]
|
||||
|
||||
// Create the relay switch object using GPIO pin 0
|
||||
upm::GroveRelay relay(0);
|
||||
|
||||
// Close and then open the relay switch 3 times,
|
||||
// waiting one second each time. The LED on the relay switch
|
||||
// will light up when the switch is on (closed).
|
||||
// The switch will also make a noise between transitions.
|
||||
for (int i = 0; i < 3; i++) {
|
||||
relay.on();
|
||||
if (relay.isOn())
|
||||
std::cout << relay.name() << " is on" << std::endl;
|
||||
upm_delay(1);
|
||||
relay.off();
|
||||
if (relay.isOff())
|
||||
std::cout << relay.name() << " is off" << std::endl;
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
// Delete the relay switch object
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#include "groverotary.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate a rotary sensor on analog pin A0
|
||||
upm::GroveRotary knob(0);
|
||||
|
||||
// Print sensor name to confirm it initialized properly
|
||||
cout << knob.name() << endl;
|
||||
|
||||
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
|
||||
|
||||
fprintf(stdout,
|
||||
"Absolute: %4d raw %5.2f deg = %3.2f rad Relative: %4d raw %5.2f "
|
||||
"deg %3.2f rad\n",
|
||||
(int16_t) abs_value,
|
||||
abs_deg,
|
||||
abs_rad,
|
||||
(int16_t) rel_value,
|
||||
rel_deg,
|
||||
rel_rad);
|
||||
|
||||
upm_delay_us(2500000); // Sleep for 2.5s
|
||||
}
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#include "groveslide.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
//! [Interesting]
|
||||
upm::GroveSlide slide(0);
|
||||
|
||||
cout << slide.name() << endl;
|
||||
|
||||
while (true) {
|
||||
float adc_value = slide.raw_value(); // Read raw value
|
||||
float volts = slide.voltage_value(); // Read voltage, board reference set at 5.0V
|
||||
fprintf(stdout, "%4d = %.2f V\n", (uint16_t) adc_value, volts);
|
||||
|
||||
upm_delay_us(2500000); // Sleep for 2.5s
|
||||
}
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Contributions: Sarah Knepper <sarah.knepper@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#include "grovetemp.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
|
||||
// Create the temperature sensor object using AIO pin 0
|
||||
upm::GroveTemp temp(0);
|
||||
std::cout << temp.name() << std::endl;
|
||||
|
||||
// Read the temperature ten times, printing both the Celsius and
|
||||
// equivalent Fahrenheit temperature, waiting one second between readings
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int celsius = temp.value();
|
||||
int fahrenheit = (int) (celsius * 9.0 / 5.0 + 32.0);
|
||||
printf("%d degrees Celsius, or %d degrees Fahrenheit\n", celsius, fahrenheit);
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
// Delete the temperature sensor object
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Author: Zion Orent <zorent@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "grovecollision.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// The was tested with the Grove Collision Sensor
|
||||
// Instantiate a Grove Collision on digital pin D2
|
||||
upm::GroveCollision collision(2);
|
||||
|
||||
bool collisionState = false;
|
||||
cout << "No collision" << endl;
|
||||
while (shouldRun) {
|
||||
if (collision.isColliding() && !collisionState) {
|
||||
cout << "Collision!" << endl;
|
||||
collisionState = true;
|
||||
} else if (collisionState) {
|
||||
cout << "No collision" << endl;
|
||||
collisionState = false;
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "groveehr.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
|
||||
upm::GroveEHR heart(2);
|
||||
|
||||
// set the beat counter to 0, init the clock and start counting beats
|
||||
heart.clearBeatCounter();
|
||||
heart.initClock();
|
||||
heart.startBeatCounter();
|
||||
|
||||
while (shouldRun) {
|
||||
// we grab these just for display purposes in this example
|
||||
uint32_t millis = heart.getMillis();
|
||||
uint32_t 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
|
||||
cout << "Millis: " << millis << " Beats: " << beats;
|
||||
cout << " Heart Rate: " << hr << endl;
|
||||
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
heart.stopBeatCounter();
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Author: Zion Orent <zorent@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "groveeldriver.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// The was tested with the Grove El Driver Module
|
||||
// Instantiate a Grove El Driver on digital pin D2
|
||||
upm::GroveElDriver eldriver(2);
|
||||
|
||||
bool lightState = true;
|
||||
|
||||
while (shouldRun) {
|
||||
if (lightState)
|
||||
eldriver.on();
|
||||
else
|
||||
eldriver.off();
|
||||
lightState = !lightState;
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
eldriver.off();
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Author: Zion Orent <zorent@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "groveelectromagnet.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
float
|
||||
get_time()
|
||||
{
|
||||
return ((float) (clock())) / CLOCKS_PER_SEC;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// The was tested with the Grove Electromagnetic Module
|
||||
// Instantiate a Grove Electromagnet on digital pin D2
|
||||
upm::GroveElectromagnet magnet(2);
|
||||
cout << "Starting up magnet...." << endl;
|
||||
magnet.off();
|
||||
|
||||
bool magnetState = false;
|
||||
float time_passed = get_time();
|
||||
|
||||
// Turn magnet on and off every 5 seconds
|
||||
while (shouldRun) {
|
||||
if ((get_time() - time_passed) > 5.0) {
|
||||
magnetState = !magnetState;
|
||||
if (magnetState)
|
||||
magnet.on();
|
||||
else
|
||||
magnet.off();
|
||||
cout << "Turning magnet " << ((magnetState) ? "on" : "off") << endl;
|
||||
time_passed = get_time();
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
magnet.off();
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Author: Zion Orent <zorent@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "groveemg.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// The was tested with the GroveEMG Muscle Signal Reader Sensor Module
|
||||
// Instantiate a GroveEMG on analog pin A0
|
||||
upm::GroveEMG emg(0);
|
||||
cout << "Calibrating...." << endl;
|
||||
emg.calibrate();
|
||||
|
||||
while (shouldRun) {
|
||||
cout << emg.value() << endl;
|
||||
upm_delay_us(100000);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
cout << "Exiting" << endl;
|
||||
return 0;
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "grovegprs.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
void
|
||||
printUsage(char* progname)
|
||||
{
|
||||
cout << "Usage: " << progname << " [AT command]" << endl;
|
||||
cout << endl;
|
||||
|
||||
cout << "If an argument is supplied on the command line, that argument is" << endl;
|
||||
cout << "sent to the module and the response is printed out." << endl;
|
||||
cout << endl;
|
||||
cout << "If no argument is used, then the manufacturer and the current" << endl;
|
||||
cout << "saved profiles are queried and the results printed out." << endl;
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
// simple helper function to send a command and wait for a response
|
||||
void
|
||||
sendCommand(upm::GroveGPRS& sensor, string cmd)
|
||||
{
|
||||
// commands need to be terminated with a carriage return
|
||||
cmd += "\r";
|
||||
|
||||
sensor.writeDataStr(cmd);
|
||||
|
||||
// wait up to 1 second
|
||||
if (sensor.dataAvailable(1000)) {
|
||||
cout << "Returned: " << sensor.readDataStr(1024) << endl;
|
||||
} else {
|
||||
cerr << "Timed out waiting for response" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a GroveGPRS Module on UART 0
|
||||
upm::GroveGPRS sensor(0);
|
||||
|
||||
// Set the baud rate, 19200 baud is the default.
|
||||
if (sensor.setBaudRate(19200) != 0) {
|
||||
cerr << "Failed to set tty baud rate" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
printUsage(argv[0]);
|
||||
|
||||
if (argc > 1) {
|
||||
cout << "Sending command line argument (" << argv[1] << ")..." << endl;
|
||||
sendCommand(sensor, argv[1]);
|
||||
} else {
|
||||
// query the module manufacturer
|
||||
cout << "Querying module manufacturer (AT+CGMI)..." << endl;
|
||||
sendCommand(sensor, "AT+CGMI");
|
||||
|
||||
upm_delay(1);
|
||||
|
||||
// query the saved profiles
|
||||
cout << "Querying the saved profiles (AT&V)..." << endl;
|
||||
sendCommand(sensor, "AT&V");
|
||||
|
||||
// A comprehensive list is available from the datasheet at:
|
||||
// http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Author: Zion Orent <zorent@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "grovegsr.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// The was tested with the GroveGSR Galvanic Skin Response Sensor module.
|
||||
|
||||
// Instantiate a GroveGSR on analog pin A0
|
||||
upm::GroveGSR gsr(0);
|
||||
cout << "Calibrating...." << endl;
|
||||
gsr.calibrate();
|
||||
|
||||
while (shouldRun) {
|
||||
cout << gsr.value() << endl;
|
||||
upm_delay_us(500000);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "grovelinefinder.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove Line Finder sensor on digital pin D2
|
||||
upm::GroveLineFinder finder(2);
|
||||
|
||||
// check every second for the presence of white detection
|
||||
while (shouldRun) {
|
||||
bool val = finder.whiteDetected();
|
||||
if (val)
|
||||
cout << "White detected." << endl;
|
||||
else
|
||||
cout << "Black detected." << endl;
|
||||
|
||||
upm_delay(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "grovemd.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate an I2C Grove Motor Driver on I2C bus 0
|
||||
|
||||
upm::GroveMD motors(GROVEMD_I2C_BUS, GROVEMD_DEFAULT_I2C_ADDR);
|
||||
|
||||
// This example demonstrates using the GroveMD to drive a stepper motor
|
||||
|
||||
// configure it, for this example, we'll assume 200 steps per rev
|
||||
motors.configStepper(200);
|
||||
|
||||
// set for half a rotation
|
||||
motors.setStepperSteps(100);
|
||||
|
||||
// let it go - clockwise rotation, 10 RPM speed
|
||||
motors.enableStepper(upm::GroveMD::STEP_DIR_CW, 10);
|
||||
|
||||
upm_delay(3);
|
||||
|
||||
// Now do it backwards...
|
||||
motors.setStepperSteps(100);
|
||||
motors.enableStepper(upm::GroveMD::STEP_DIR_CCW, 10);
|
||||
|
||||
// now disable
|
||||
motors.disableStepper();
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "grovemd.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate an I2C Grove Motor Driver on I2C bus 0
|
||||
|
||||
upm::GroveMD motors(GROVEMD_I2C_BUS, GROVEMD_DEFAULT_I2C_ADDR);
|
||||
|
||||
// set direction to CW and set speed to 50%
|
||||
cout << "Spin M1 and M2 at half speed for 3 seconds" << endl;
|
||||
motors.setMotorDirections(upm::GroveMD::DIR_CW, upm::GroveMD::DIR_CW);
|
||||
motors.setMotorSpeeds(127, 127);
|
||||
|
||||
upm_delay(3);
|
||||
// counter clockwise
|
||||
cout << "Reversing M1 and M2 for 3 seconds" << endl;
|
||||
motors.setMotorDirections(upm::GroveMD::DIR_CCW, upm::GroveMD::DIR_CCW);
|
||||
upm_delay(3);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Stopping motors" << endl;
|
||||
motors.setMotorSpeeds(0, 0);
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "grovemoisture.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove Moisture sensor on analog pin A0
|
||||
upm::GroveMoisture moisture(0);
|
||||
|
||||
// Values (approximate):
|
||||
// 0-300, sensor in air or dry soil
|
||||
// 300-600, sensor in humid soil
|
||||
// 600+, sensor in wet soil or submerged in water.
|
||||
// Read the value every second and print the corresponding moisture level
|
||||
while (shouldRun) {
|
||||
int val = moisture.value();
|
||||
cout << "Moisture value: " << val << ", ";
|
||||
if (val >= 0 && val < 300)
|
||||
cout << "dry";
|
||||
else if (val >= 300 && val < 600)
|
||||
cout << "moist";
|
||||
else
|
||||
cout << "wet";
|
||||
|
||||
cout << endl;
|
||||
|
||||
upm_delay(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Author: Zion Orent <zorent@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "groveo2.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// The was tested with the O2 Oxygen Concentration Sensor Module
|
||||
// Instantiate a GroveO2 on analog pin A0
|
||||
upm::GroveO2 O2(0);
|
||||
while (shouldRun) {
|
||||
cout << "The output voltage is: " << O2.voltageValue() << "mV" << endl;
|
||||
upm_delay_us(100000);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
cout << "Exiting" << endl;
|
||||
return 0;
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "grovescam.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a Grove Serial Camera on UART 0
|
||||
upm::GROVESCAM camera(0);
|
||||
|
||||
// make sure port is initialized properly. 115200 baud is the default.
|
||||
if (!camera.setupTty()) {
|
||||
cerr << "Failed to setup tty port parameters" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (camera.init())
|
||||
cout << "Initialized..." << endl;
|
||||
else
|
||||
cout << "init() failed" << endl;
|
||||
|
||||
if (camera.preCapture())
|
||||
cout << "preCapture succeeded..." << endl;
|
||||
else
|
||||
cout << "preCapture failed." << endl;
|
||||
|
||||
if (camera.doCapture())
|
||||
cout << "doCapture succeeded..." << endl;
|
||||
else
|
||||
cout << "doCapture failed." << endl;
|
||||
|
||||
cout << "Image size is " << camera.getImageSize() << " bytes" << endl;
|
||||
|
||||
if (camera.getImageSize() > 0) {
|
||||
cout << "Storing image.jpg..." << endl;
|
||||
if (camera.storeImage("image.jpg"))
|
||||
cout << "storeImage succeeded..." << endl;
|
||||
else
|
||||
cout << "storeImage failed." << endl;
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "grovespeaker.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove Speaker on digital pin D2
|
||||
upm::GroveSpeaker speaker(2);
|
||||
|
||||
// Play all 7 of the lowest notes
|
||||
speaker.playAll();
|
||||
|
||||
// Play a medium C-sharp
|
||||
speaker.playSound('c', true, "med");
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Author: Jun Kato <i@junkato.jp>
|
||||
* Copyright (c) 2015 Jun Kato.
|
||||
*
|
||||
* Thanks to Seeed Studio for a working arduino sketch
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "groveultrasonic.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
bool running = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
// upm::GroveUltraSonic *sonar = NULL;
|
||||
upm::GroveUltraSonic sonar(2);
|
||||
while (running) {
|
||||
int width = sonar.getDistance();
|
||||
printf("Echo width = %d\n", width);
|
||||
printf("Distance inches = %f.2\n\n", width / 148.0);
|
||||
upm_delay(3);
|
||||
}
|
||||
//! [Interesting]
|
||||
printf("exiting application\n");
|
||||
return 0;
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "grovevdiv.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove Voltage Divider sensor on analog pin A0
|
||||
upm::GroveVDiv vDiv(0);
|
||||
|
||||
// collect data and output measured voltage according to the setting
|
||||
// of the scaling switch (3 or 10)
|
||||
while (shouldRun) {
|
||||
unsigned int val = vDiv.value(100);
|
||||
float gain3val = vDiv.computedValue(3, val);
|
||||
float gain10val = vDiv.computedValue(10, val);
|
||||
cout << "ADC value: " << val << " Gain 3: " << gain3val << "v Gain 10: " << gain10val << "v"
|
||||
<< endl;
|
||||
|
||||
upm_delay(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "grovewater.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove Water sensor on digital pin D2
|
||||
upm::GroveWater water(2);
|
||||
|
||||
while (shouldRun) {
|
||||
bool val = water.isWet();
|
||||
if (val)
|
||||
cout << "Sensor is wet." << endl;
|
||||
else
|
||||
cout << "Sensor is dry." << endl;
|
||||
|
||||
upm_delay(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "grovewfs.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove Water Flow Sensor on digital pin D2
|
||||
upm::GroveWFS flow(2);
|
||||
|
||||
// set the flow counter to 0 and start counting
|
||||
flow.clearFlowCounter();
|
||||
flow.startFlowCounter();
|
||||
|
||||
while (shouldRun) {
|
||||
// we grab these (,illis and flowCount) just for display
|
||||
// purposes in this example
|
||||
uint32_t millis = flow.getMillis();
|
||||
uint32_t flowCount = flow.flowCounter();
|
||||
|
||||
float fr = flow.flowRate();
|
||||
|
||||
// output milliseconds passed, flow count, and computed flow rate
|
||||
cout << "Millis: " << millis << " Flow Count: " << flowCount;
|
||||
cout << " Flow Rate: " << fr << " LPM" << endl;
|
||||
|
||||
// best to gather data for at least one second for reasonable
|
||||
// results.
|
||||
upm_delay(2);
|
||||
}
|
||||
|
||||
flow.stopFlowCounter();
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -3,13 +3,12 @@
|
||||
#include <string>
|
||||
|
||||
#include "hlg150h.hpp"
|
||||
#include "iLightController.hpp"
|
||||
|
||||
#define HLG150H_GPIO_RELAY 21
|
||||
#define HLG150H_GPIO_PWM 22
|
||||
|
||||
void
|
||||
printState(upm::ILightController& lightController)
|
||||
printState(upm::HLG150H& lightController)
|
||||
{
|
||||
if (lightController.isPowered()) {
|
||||
std::cout << "Light is powered, brightness = " << lightController.getBrightness()
|
||||
|
28
examples/c++/iLight-sample.cxx
Normal file
@ -0,0 +1,28 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#include "apds9002.hpp"
|
||||
#include "bh1750.hpp"
|
||||
#include "max44009.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::list<upm::iLight*> lightSensors;
|
||||
|
||||
// Populate list of light sensors
|
||||
lightSensors.push_back(new upm::APDS9002(0));
|
||||
lightSensors.push_back(new upm::BH1750());
|
||||
lightSensors.push_back(new upm::MAX44009(1));
|
||||
|
||||
// Measure luminance level from all 3 individual sensors
|
||||
for (auto& sensor : lightSensors) {
|
||||
sensor->getLuminance();
|
||||
}
|
||||
|
||||
for (auto& sensor : lightSensors) {
|
||||
delete sensor;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
26
examples/c++/iTemperature-sample.cxx
Normal file
@ -0,0 +1,26 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "abp.hpp"
|
||||
#include "lm35.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::vector<upm::iTemperature*> tempSensors{ new upm::LM35(0),
|
||||
new upm::ABP(0, ABP_DEFAULT_ADDRESS) };
|
||||
|
||||
for (auto& sensor : tempSensors) {
|
||||
float celsiusTemp = sensor->getTemperature();
|
||||
std::cout << "Temperature in Celsius degrees: " << celsiusTemp << std::endl;
|
||||
std::cout << "Temperature in Kelvin: "
|
||||
<< upm::iTemperature::convertCelsiusTo(celsiusTemp, upm::TemperatureUnit::KELVIN)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
for (auto& sensor : tempSensors) {
|
||||
delete sensor;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "bme280.hpp"
|
||||
#include "iHumiditySensor.hpp"
|
||||
#include "mraa/common.h"
|
||||
#include "si7005.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
#define EDISON_I2C_BUS 1
|
||||
#define FT4222_I2C_BUS 0
|
||||
|
||||
#define EDISON_GPIO_SI7005_CS 20
|
||||
|
||||
//! [Interesting]
|
||||
// Simple example of using ILightSensor to determine
|
||||
// which sensor is present and return its name.
|
||||
// ILightSensor is then used to get readings from sensor
|
||||
|
||||
upm::IHumiditySensor*
|
||||
getHumiditySensor()
|
||||
{
|
||||
upm::IHumiditySensor* humiditySensor = NULL;
|
||||
|
||||
try {
|
||||
humiditySensor = new upm::BME280(mraa_get_sub_platform_id(FT4222_I2C_BUS));
|
||||
return humiditySensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "BME280: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
try {
|
||||
humiditySensor = new upm::SI7005(EDISON_I2C_BUS, EDISON_GPIO_SI7005_CS);
|
||||
return humiditySensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "SI7005: " << e.what() << std::endl;
|
||||
}
|
||||
return humiditySensor;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
upm::IHumiditySensor* humiditySensor = getHumiditySensor();
|
||||
if (humiditySensor == NULL) {
|
||||
std::cout << "Humidity sensor not detected" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Humidity sensor " << humiditySensor->getModuleName() << " detected" << std::endl;
|
||||
while (true) {
|
||||
try {
|
||||
int value = humiditySensor->getHumidityRelative();
|
||||
std::cout << "Humidity = " << value << "%" << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
upm_delay(1);
|
||||
}
|
||||
delete humiditySensor;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
@ -1,98 +0,0 @@
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#include "ds1808lc.hpp"
|
||||
#include "hlg150h.hpp"
|
||||
#include "iLightController.hpp"
|
||||
#include "lp8860.hpp"
|
||||
|
||||
#define EDISON_I2C_BUS 1 // Edison I2C-1
|
||||
#define GPIO_SI7005_CS 20 // Edison GP12
|
||||
#define HLG150H_GPIO_RELAY 21
|
||||
#define HLG150H_GPIO_PWM 22
|
||||
#define LP8860_GPIO_PWR 45 // Edison GP45
|
||||
#define DS1808_GPIO_PWR 15 // Edison GP165
|
||||
#define DS1808_GPIO_EDISON_LIVE 36 // Edison GP14
|
||||
|
||||
//! [Interesting]
|
||||
// Simple example of using ILightController to determine
|
||||
// which controller is present and return its name.
|
||||
// ILightController is then used to get readings from sensor
|
||||
|
||||
upm::ILightController*
|
||||
getLightController()
|
||||
{
|
||||
upm::ILightController* lightController = NULL;
|
||||
try {
|
||||
lightController = new upm::LP8860(LP8860_GPIO_PWR, EDISON_I2C_BUS);
|
||||
return lightController;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "LP8860: " << e.what() << std::endl;
|
||||
}
|
||||
try {
|
||||
lightController = new upm::DS1808LC(DS1808_GPIO_PWR, EDISON_I2C_BUS);
|
||||
return lightController;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "DS1808LC: " << e.what() << std::endl;
|
||||
}
|
||||
try {
|
||||
lightController = new upm::HLG150H(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
|
||||
return lightController;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "HLG150H: " << e.what() << std::endl;
|
||||
}
|
||||
return lightController;
|
||||
}
|
||||
|
||||
void
|
||||
printState(upm::ILightController* lightController)
|
||||
{
|
||||
if (lightController->isPowered()) {
|
||||
std::cout << "Light is powered, brightness = " << lightController->getBrightness()
|
||||
<< std::endl;
|
||||
} else {
|
||||
std::cout << "Light is not powered." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
int status = 0;
|
||||
// MraaUtils::setGpio(GPIO_SI7005_CS, 1);
|
||||
|
||||
upm::ILightController* lightController = getLightController();
|
||||
if (lightController != NULL) {
|
||||
std::cout << "Detected light controller " << lightController->getModuleName() << std::endl;
|
||||
} else {
|
||||
std::cerr << "Error. Unsupported platform." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
std::cout << "Existing state: ";
|
||||
printState(lightController);
|
||||
if (argc == 2) {
|
||||
std::string arg = argv[1];
|
||||
int brightness = ::atoi(argv[1]);
|
||||
if (brightness > 0) {
|
||||
lightController->setPowerOn();
|
||||
lightController->setBrightness(brightness);
|
||||
} else
|
||||
lightController->setPowerOff();
|
||||
}
|
||||
std::cout << "Now: ";
|
||||
printState(lightController);
|
||||
} catch (std::exception& e) {
|
||||
std::cout << "Error: " << e.what() << std::endl;
|
||||
status = 1;
|
||||
}
|
||||
|
||||
delete lightController;
|
||||
return status;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "iLightSensor.hpp"
|
||||
#include "max44009.hpp"
|
||||
#include "mraa/common.h"
|
||||
#include "si1132.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
#define EDISON_I2C_BUS 1
|
||||
#define FT4222_I2C_BUS 0
|
||||
|
||||
//! [Interesting]
|
||||
// Simple example of using ILightSensor to determine
|
||||
// which sensor is present and return its name.
|
||||
// ILightSensor is then used to get readings from sensor
|
||||
|
||||
upm::ILightSensor*
|
||||
getLightSensor()
|
||||
{
|
||||
upm::ILightSensor* lightSensor = NULL;
|
||||
try {
|
||||
lightSensor = new upm::SI1132(mraa_get_sub_platform_id(FT4222_I2C_BUS));
|
||||
return lightSensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "SI1132: " << e.what() << std::endl;
|
||||
}
|
||||
try {
|
||||
lightSensor = new upm::MAX44009(EDISON_I2C_BUS);
|
||||
return lightSensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "MAX44009: " << e.what() << std::endl;
|
||||
}
|
||||
return lightSensor;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
upm::ILightSensor* lightSensor = getLightSensor();
|
||||
if (lightSensor == NULL) {
|
||||
std::cout << "Light sensor not detected" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Light sensor " << lightSensor->getModuleName() << " detected" << std::endl;
|
||||
while (true) {
|
||||
try {
|
||||
float value = lightSensor->getVisibleLux();
|
||||
std::cout << "Light level = " << value << " lux" << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
upm_delay(1);
|
||||
}
|
||||
delete lightSensor;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "bme280.hpp"
|
||||
#include "bmpx8x.hpp"
|
||||
#include "iPressureSensor.hpp"
|
||||
#include "mraa/common.h"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
#define EDISON_I2C_BUS 1
|
||||
#define FT4222_I2C_BUS 0
|
||||
|
||||
//! [Interesting]
|
||||
// Simple example of using ILightSensor to determine
|
||||
// which sensor is present and return its name.
|
||||
// ILightSensor is then used to get readings from sensor
|
||||
|
||||
upm::IPressureSensor*
|
||||
getPressureSensor()
|
||||
{
|
||||
upm::IPressureSensor* pressureSensor = NULL;
|
||||
try {
|
||||
pressureSensor = new upm::BME280(mraa_get_sub_platform_id(FT4222_I2C_BUS));
|
||||
return pressureSensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "BME280: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
try {
|
||||
pressureSensor = new upm::BMPX8X(EDISON_I2C_BUS);
|
||||
return pressureSensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "BMPX8X: " << e.what() << std::endl;
|
||||
}
|
||||
return pressureSensor;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
upm::IPressureSensor* pressureSensor = getPressureSensor();
|
||||
if (pressureSensor == NULL) {
|
||||
std::cout << "Pressure sensor not detected" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Pressure sensor " << pressureSensor->getModuleName() << " detected" << std::endl;
|
||||
while (true) {
|
||||
try {
|
||||
int value = pressureSensor->getPressurePa();
|
||||
std::cout << "Pressure = " << value << " Pa" << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
upm_delay(1);
|
||||
}
|
||||
delete pressureSensor;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "bme280.hpp"
|
||||
#include "bmpx8x.hpp"
|
||||
#include "iTemperatureSensor.hpp"
|
||||
#include "mraa/common.h"
|
||||
#include "si7005.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
#define EDISON_I2C_BUS 1
|
||||
#define FT4222_I2C_BUS 0
|
||||
|
||||
#define EDISON_GPIO_SI7005_CS 20
|
||||
|
||||
//! [Interesting]
|
||||
// Simple example of using ITemperatureSensor to determine
|
||||
// which sensor is present and return its name.
|
||||
// ITemperatureSensor is then used to get readings from sensor
|
||||
|
||||
upm::ITemperatureSensor*
|
||||
getTemperatureSensor()
|
||||
{
|
||||
upm::ITemperatureSensor* temperatureSensor = NULL;
|
||||
|
||||
try {
|
||||
temperatureSensor = new upm::BME280(mraa_get_sub_platform_id(FT4222_I2C_BUS));
|
||||
return temperatureSensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "BME280: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
try {
|
||||
temperatureSensor = new upm::SI7005(EDISON_I2C_BUS, EDISON_GPIO_SI7005_CS);
|
||||
return temperatureSensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "SI7005: " << e.what() << std::endl;
|
||||
}
|
||||
try {
|
||||
temperatureSensor = new upm::BMPX8X(EDISON_I2C_BUS);
|
||||
return temperatureSensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "BMPX8X: " << e.what() << std::endl;
|
||||
}
|
||||
return temperatureSensor;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
upm::ITemperatureSensor* temperatureSensor = getTemperatureSensor();
|
||||
if (temperatureSensor == NULL) {
|
||||
std::cout << "Temperature sensor not detected" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Temperature sensor " << temperatureSensor->getModuleName() << " detected"
|
||||
<< std::endl;
|
||||
while (true) {
|
||||
try {
|
||||
int value = temperatureSensor->getTemperatureCelsius();
|
||||
std::cout << "Temperature = " << value << "C" << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
upm_delay(1);
|
||||
}
|
||||
delete temperatureSensor;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
@ -48,12 +48,12 @@ main()
|
||||
|
||||
// Instantiate a LM35 on analog pin A0, with a default analog
|
||||
// reference voltage of 5.0
|
||||
upm::LM35 sensor(0);
|
||||
upm::iTemperature* sensor = new upm::LM35(0);
|
||||
|
||||
// Every half second, sample the sensor and output the temperature
|
||||
|
||||
while (shouldRun) {
|
||||
cout << "Temperature: " << sensor.getTemperature() << " C" << endl;
|
||||
cout << "Temperature: " << sensor->getTemperature() << " C" << endl;
|
||||
|
||||
upm_delay_us(500000);
|
||||
}
|
||||
@ -61,6 +61,7 @@ main()
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,14 +2,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#include "iLightController.hpp"
|
||||
#include "lp8860.hpp"
|
||||
|
||||
#define EDISON_I2C_BUS 1 // Edison I2C-1
|
||||
#define LP8860_GPIO_PWR 45 // Edison GP45
|
||||
|
||||
void
|
||||
printState(upm::ILightController& lightController)
|
||||
printState(upm::LP8860& lightController)
|
||||
{
|
||||
if (lightController.isPowered()) {
|
||||
std::cout << "Light is powered, brightness = " << lightController.getBrightness()
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "iCO2Sensor.hpp"
|
||||
#include "mraa/common.h"
|
||||
#include "t6713.hpp"
|
||||
#include "upm_utilities.h"
|
||||
@ -40,19 +39,16 @@ int
|
||||
main()
|
||||
{
|
||||
/* Create an instance of the T6713 sensor */
|
||||
upm::T6713 sensor(EDISON_I2C_BUS);
|
||||
upm::T6713 cO2Sensor(EDISON_I2C_BUS);
|
||||
|
||||
/* Show usage from the ICO2Sensor interface */
|
||||
upm::ICO2Sensor* cO2Sensor = static_cast<upm::ICO2Sensor*>(&sensor);
|
||||
|
||||
if (cO2Sensor == NULL) {
|
||||
std::cout << "CO2 sensor not detected" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "CO2 sensor " << cO2Sensor->getModuleName() << " detected" << std::endl;
|
||||
// if (cO2Sensor == NULL) {
|
||||
// std::cout << "CO2 sensor not detected" << std::endl;
|
||||
// return 1;
|
||||
// }
|
||||
std::cout << "CO2 sensor " << cO2Sensor.getModuleName() << " detected" << std::endl;
|
||||
while (true) {
|
||||
try {
|
||||
uint16_t value = cO2Sensor->getPpm();
|
||||
uint16_t value = cO2Sensor.getPpm();
|
||||
std::cout << "CO2 level = " << value << " ppm" << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
|
@ -49,7 +49,7 @@ int main(int argc, char **argv)
|
||||
// Initialize a BNO055 using default parameters (bus 0, addr
|
||||
// 0x28). The default running mode is NDOF absolute orientation
|
||||
// mode.
|
||||
bno055_context sensor = bno055_init(0, BNO055_DEFAULT_ADDR);
|
||||
bno055_context sensor = bno055_init(0, BNO055_DEFAULT_ADDR, NULL);
|
||||
|
||||
if (!sensor)
|
||||
{
|
||||
|
@ -35,9 +35,9 @@ public class BME280_Interface_Example
|
||||
// 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;
|
||||
iTemperature t_sensor = sensor;
|
||||
iHumidity h_sensor = sensor;
|
||||
iPressure p_sensor = sensor;
|
||||
|
||||
// For SPI, bus 0, you would pass -1 as the address, and a
|
||||
// valid pin for CS:
|
||||
@ -51,15 +51,15 @@ public class BME280_Interface_Example
|
||||
System.out.println("Calling Interface Functions: ");
|
||||
|
||||
System.out.println("Compensation Temperature: "
|
||||
+ t_sensor.getTemperatureCelsius()
|
||||
+ t_sensor.getTemperature()
|
||||
+ " C / ");
|
||||
|
||||
System.out.println("Pressure: "
|
||||
+ p_sensor.getPressurePa()
|
||||
+ p_sensor.getPressure()
|
||||
+ " Pa");
|
||||
|
||||
System.out.println("Humidity: "
|
||||
+ h_sensor.getHumidityRelative()
|
||||
+ h_sensor.getHumidity()
|
||||
+ " %RH");
|
||||
|
||||
System.out.println();
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
import upm_bmg160.BMG160;
|
||||
import upm_interfaces.*;
|
||||
import java.util.AbstractList;
|
||||
import java.lang.Float;
|
||||
|
||||
|
@ -22,6 +22,9 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.util.AbstractList;
|
||||
import upm_interfaces.*;
|
||||
|
||||
import upm_bmi160.BMI160;
|
||||
|
||||
public class BMI160_Example
|
||||
@ -39,35 +42,35 @@ public class BMI160_Example
|
||||
// update our values from the sensor
|
||||
sensor.update();
|
||||
|
||||
float dataA[] = sensor.getAccelerometer();
|
||||
AbstractList<Float> dataA = sensor.getAcceleration();
|
||||
|
||||
System.out.println("Accelerometer: "
|
||||
+ "AX: "
|
||||
+ dataA[0]
|
||||
+ dataA.get(0)
|
||||
+ " AY: "
|
||||
+ dataA[1]
|
||||
+ dataA.get(1)
|
||||
+ " AZ: "
|
||||
+ dataA[2]);
|
||||
+ dataA.get(2));
|
||||
|
||||
float dataG[] = sensor.getGyroscope();
|
||||
AbstractList<Float> dataG = sensor.getGyroscope();
|
||||
|
||||
System.out.println("Gryoscope: "
|
||||
+ "GX: "
|
||||
+ dataG[0]
|
||||
+ dataG.get(0)
|
||||
+ " GY: "
|
||||
+ dataG[1]
|
||||
+ dataG.get(1)
|
||||
+ " GZ: "
|
||||
+ dataG[2]);
|
||||
+ dataG.get(2));
|
||||
|
||||
float dataM[] = sensor.getMagnetometer();
|
||||
AbstractList<Float> dataM = sensor.getMagnetometer();
|
||||
|
||||
System.out.println("Magnetometer: "
|
||||
+ "MX: "
|
||||
+ dataM[0]
|
||||
+ dataM.get(0)
|
||||
+ " MY: "
|
||||
+ dataM[1]
|
||||
+ dataM.get(1)
|
||||
+ " MZ: "
|
||||
+ dataM[2]);
|
||||
+ dataM.get(2));
|
||||
|
||||
System.out.println();
|
||||
Thread.sleep(500);
|
||||
|
@ -24,10 +24,12 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_interfaces.*;
|
||||
import upm_bmm150.BMM150;
|
||||
import java.util.AbstractList;
|
||||
import java.lang.Float;
|
||||
|
||||
|
||||
public class BMM150_Example
|
||||
{
|
||||
public static void main(String[] args) throws InterruptedException
|
||||
|
@ -35,8 +35,6 @@ public class BMPX8X_Example {
|
||||
// temperature values every .5 seconds
|
||||
while (true)
|
||||
{
|
||||
sensor.update();
|
||||
|
||||
System.out.println("Pressure: "
|
||||
+ sensor.getPressure()
|
||||
+ " Pa, Temperature: "
|
||||
|
@ -64,84 +64,61 @@ function(add_example example_class_name dependency_list)
|
||||
add_dependencies(${example_class_name} ${java_targets_list})
|
||||
endfunction()
|
||||
|
||||
add_example(A110X_Example a110x)
|
||||
add_example(A110X_intr_Example a110x)
|
||||
add_example(A110X_Example "a110x;interfaces")
|
||||
add_example(A110X_intr_Example "a110x;interfaces")
|
||||
add_example(Ad8232_Example ad8232)
|
||||
add_example(ADC121C021_Example adc121c021)
|
||||
add_example(Ads1015_Example "ads1x15;interfaces")
|
||||
add_example(Ads1015_Example "ads1x15")
|
||||
add_example(Ads1115_Example ads1x15)
|
||||
add_example(Adxl345_Example adxl345)
|
||||
add_example(AM2315_Example am2315)
|
||||
add_example(AM2315_Example "am2315;interfaces")
|
||||
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(Apds9002_Example "apds9002;interfaces")
|
||||
add_example(BH1750_Example "bh1750;interfaces")
|
||||
add_example(BISS0001_Example "biss0001;interfaces")
|
||||
add_example(BMA250E_Example "bma250e;interfaces")
|
||||
add_example(BMC150_Example "bmx055;interfaces")
|
||||
add_example(BME280_Example "bmp280;interfaces")
|
||||
add_example(BMG160_Example bmg160)
|
||||
add_example(BMI055_Example bmx055)
|
||||
add_example(BMI160_Example bmi160)
|
||||
add_example(BMM150_Example bmm150)
|
||||
add_example(BMG160_Example "bmg160;interfaces")
|
||||
add_example(BMI055_Example "bmx055;interfaces")
|
||||
add_example(BMI160_Example "bmi160;interfaces")
|
||||
add_example(BMM150_Example "bmm150;interfaces")
|
||||
add_example(BMP280_Example "bmp280;interfaces")
|
||||
add_example(BMPX8X_Example "bmpx8x;interfaces")
|
||||
add_example(BMX055_Example bmx055)
|
||||
add_example(BMX055_Example "bmx055;interfaces")
|
||||
add_example(BNO055_Example bno055)
|
||||
add_example(Button_Example button)
|
||||
add_example(Button_intr_Example button)
|
||||
add_example(Button_Example "button;interfaces")
|
||||
add_example(Button_intr_Example "button;interfaces")
|
||||
add_example(Buzzer_Example buzzer)
|
||||
add_example(CJQ4435_Example cjq4435)
|
||||
add_example(Collision_Example collision)
|
||||
add_example(CWLSXXA_Example cwlsxxa)
|
||||
add_example(DFREC_Example dfrec)
|
||||
add_example(DFRORP_Example dfrorp)
|
||||
add_example(Collision_Example "collision;interfaces")
|
||||
add_example(CWLSXXA_Example "cwlsxxa;interfaces")
|
||||
add_example(DFREC_Example "dfrec;interfaces")
|
||||
add_example(DFRORP_Example "dfrorp;interfaces")
|
||||
add_example(DS1307_Example ds1307)
|
||||
add_example(ECEZO_Example ecezo)
|
||||
add_example(ECEZO_Example "ecezo;interfaces")
|
||||
add_example(ECS1030_Example ecs1030)
|
||||
add_example(EHR_Example ehr)
|
||||
add_example(Emg_Example emg)
|
||||
add_example(EHR_Example "ehr;interfaces")
|
||||
add_example(Emg_Example "emg;interfaces")
|
||||
add_example(ENC03R_Example enc03r)
|
||||
add_example(ES08A_Example "servo;interfaces")
|
||||
add_example(ES08A_Example "servo")
|
||||
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(Gp2y0a_Example "gp2y0a;interfaces")
|
||||
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(GroveMQ3_Example "gas;interfaces")
|
||||
add_example(GroveMQ9_Example "gas;interfaces")
|
||||
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(Gsr_Example "gsr;interfaces")
|
||||
add_example(GUVAS12D_Example guvas12d)
|
||||
add_example(H3LIS331DL_Example h3lis331dl)
|
||||
add_example(HCSR04_Example hcsr04)
|
||||
add_example(H3LIS331DL_Example "h3lis331dl;interfaces")
|
||||
add_example(HCSR04_Example "hcsr04;interfaces")
|
||||
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(HP20x_Example "hp20x;interfaces")
|
||||
add_example(HTU21D_Example "htu21d;interfaces")
|
||||
add_example(Itg3200_Example "itg3200;interfaces")
|
||||
add_example(Jhd1313m1_Example jhd1313m1)
|
||||
add_example(Jhd1313m1_lcd_Example jhd1313m1)
|
||||
add_example(Joystick12_Example joystick12)
|
||||
@ -152,60 +129,64 @@ 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(Light_Example "light;interfaces")
|
||||
add_example(LineFinder_Example "linefinder;interfaces")
|
||||
add_example(LIS2DS12_Example "lis2ds12;interfaces")
|
||||
add_example(LoL_Example lol)
|
||||
add_example(LSM303AGR_Example lsm303agr)
|
||||
add_example(LSM303D_Example lsm303d)
|
||||
add_example(LSM303AGR_Example "lsm303agr;interfaces")
|
||||
add_example(LSM303D_Example "lsm303d;interfaces")
|
||||
add_example(LSM303DLH_Example lsm303dlh)
|
||||
add_example(LSM6DS3H_Example lsm6ds3h)
|
||||
add_example(LSM6DSL_Example lsm6dsl)
|
||||
add_example(LSM6DS3H_Example "lsm6ds3h;interfaces")
|
||||
add_example(LSM6DSL_Example "lsm6dsl;interfaces")
|
||||
add_example(M24LR64E_Example m24lr64e)
|
||||
add_example(MAX30100_Example max30100)
|
||||
add_example(MAX31855_Example max31855)
|
||||
add_example(MAX44000_Example max44000)
|
||||
add_example(MAX44000_Example "max44000;interfaces")
|
||||
add_example(MAX5487_Example max5487)
|
||||
add_example(MAXds3231m_Example maxds3231m)
|
||||
add_example(MB704X_Example mb704x)
|
||||
add_example(MB704X_Example "mb704x;interfaces")
|
||||
add_example(MCP2515_Example mcp2515)
|
||||
add_example(MCP2515_TXRX_Example mcp2515)
|
||||
add_example(MD_Example md)
|
||||
add_example(MHZ16_Example mhz16)
|
||||
add_example(MHZ16_Example "mhz16;interfaces")
|
||||
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(MMA7455_Example "mma7455;interfaces")
|
||||
add_example(MMA7660_Example "mma7660;interfaces")
|
||||
add_example(Moisture_Example "moisture;interfaces")
|
||||
add_example(MPL3115A2_Example "mpl3115a2;interfaces")
|
||||
add_example(MPR121_Example mpr121)
|
||||
add_example(MPU9150_Example mpu9150)
|
||||
add_example(MQ2_Example gas)
|
||||
add_example(MPU9150_Example "mpu9150;interfaces")
|
||||
add_example(MQ2_Example "gas;interfaces")
|
||||
add_example(MQ4_Example "gas;interfaces")
|
||||
add_example(MQ5_Example "gas;interfaces")
|
||||
add_example(MQ6_Example "gas;interfaces")
|
||||
add_example(MQ7_Example "gas;interfaces")
|
||||
add_example(MQ8_Example "gas;interfaces")
|
||||
add_example(MQ303A_Example mq303a)
|
||||
add_example(MQ5_Example gas)
|
||||
add_example(MS5803_Example ms5803)
|
||||
add_example(MS5803_Example "ms5803;interfaces")
|
||||
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(O2_Example "o2;interfaces")
|
||||
add_example(OTP538U_Example "otp538u;interfaces")
|
||||
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(RFR359F_Example "rfr359f;interfaces")
|
||||
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(RotaryEncoder_Example "rotaryencoder;interfaces")
|
||||
add_example(Rotary_Example "rotary;interfaces")
|
||||
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(SHT1X_Example "sht1x;interfaces")
|
||||
add_example(Slide_Example slide)
|
||||
add_example(SM130_Example sm130)
|
||||
add_example(Speaker_Example speaker)
|
||||
@ -213,18 +194,18 @@ 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(TEAMS_Example "teams;interfaces")
|
||||
add_example(Temperature_Example "temperature;interfaces")
|
||||
add_example(TEX00_Example "tex00;interfaces")
|
||||
add_example(Th02_Example "th02;interfaces")
|
||||
add_example(TM1637_Example tm1637)
|
||||
add_example(TP401_Example gas)
|
||||
add_example(TSL2561_Example tsl2561)
|
||||
add_example(TTP223_Example ttp223)
|
||||
add_example(TP401_Example "gas;interfaces")
|
||||
add_example(TSL2561_Example "tsl2561;interfaces")
|
||||
add_example(TTP223_Example "ttp223;interfaces")
|
||||
add_example(ULN200XA_Example uln200xa)
|
||||
add_example(VDiv_Example vdiv)
|
||||
add_example(VDiv_Example "vdiv;interfaces")
|
||||
add_example(VEML6070_Example veml6070)
|
||||
add_example(Water_Example water)
|
||||
add_example(Water_Example "water;interfaces")
|
||||
add_example(WaterLevelSensor_Example waterlevel)
|
||||
add_example(WFS_Example wfs)
|
||||
add_example(WT5001_Example wt5001)
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class 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]
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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!");
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_grovecollision.*;
|
||||
|
||||
public class GroveCollision_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]
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class 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]
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
import upm_groveemg.GroveEMG;
|
||||
|
||||
public class GroveEmg_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]
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_grovegsr.GroveGSR;
|
||||
|
||||
public class GroveGsr_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]
|
||||
}
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Author: Andrei Vasiliu <andrei.vasiliu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class GroveLed_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]
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_groveo2.GroveO2;
|
||||
|
||||
public class 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]
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Author: Andrei Vasiliu <andrei.vasiliu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Author: Andrei Vasiliu <andrei.vasiliu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Author: Andrei Vasiliu <andrei.vasiliu@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class 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]
|
||||
}
|
||||
}
|