mirror of
https://github.com/eclipse/upm.git
synced 2025-07-06 11:51:10 +03:00
Compare commits
60 Commits
Author | SHA1 | Date | |
---|---|---|---|
29bfa7ef79 | |||
a5e3cc89f3 | |||
1eafab7932 | |||
de986764d4 | |||
3eda1bce16 | |||
72b975b6cc | |||
f850f5b7d8 | |||
8e8b35273b | |||
dbb4f1749d | |||
05730dba68 | |||
48d5426350 | |||
e51c5f3018 | |||
f6816797bb | |||
cc5e3b2634 | |||
c3285ea523 | |||
456bde0726 | |||
d045dded7c | |||
89d5ce152f | |||
dbbb30c3d2 | |||
8df446958a | |||
411b4abcb7 | |||
7d64a67670 | |||
6b0a9c5272 | |||
12e1e6309e | |||
c833c75cd3 | |||
03354ccf9a | |||
6241e20dda | |||
84144d0c8f | |||
dd2bca97b9 | |||
cf74a260a3 | |||
61f7803d92 | |||
e3b59eb05b | |||
398d50de2e | |||
bbb31fcab2 | |||
5467620bf7 | |||
e679d40d44 | |||
bf9059c846 | |||
e1bda1f44b | |||
893b35f77b | |||
a7e803873f | |||
612f53ee40 | |||
922e0cc26b | |||
b3a8fd7172 | |||
4455c81866 | |||
6b273a1b49 | |||
d355f76226 | |||
4f6be750c7 | |||
bf7d7d1bda | |||
9acc752074 | |||
b6b7d892c2 | |||
1ca8d100ea | |||
96f1afffe3 | |||
899d873cbc | |||
dc8be495a9 | |||
c7b5204fe4 | |||
527615758a | |||
16b6fcf807 | |||
5a9f234a3e | |||
c7bd37b322 | |||
edcaed90e6 |
48
.travis.yml
48
.travis.yml
@ -1,10 +1,21 @@
|
||||
language: cpp
|
||||
env:
|
||||
- CC=gcc CXX=gcc
|
||||
- CC=clang CXX=clang++
|
||||
- NODE4=true
|
||||
- NODE5=true
|
||||
- NODE012=true
|
||||
global:
|
||||
- MRAA_ROOT=/tmp/mraa
|
||||
- MRAA_BUILD=$MRAA_ROOT/build
|
||||
- MRAA_INSTALL=$MRAA_ROOT/install
|
||||
- UPM_ROOT=$TRAVIS_BUILD_DIR
|
||||
- UPM_BUILD=$UPM_ROOT/build
|
||||
- UPM_INSTALL=$UPM_ROOT/install
|
||||
- JAVA_HOME=/usr/lib/jvm/java-8-oracle
|
||||
matrix:
|
||||
- NODE010=true
|
||||
- NODE012=true
|
||||
- NODE4=true
|
||||
- NODE5=true
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
install:
|
||||
- sudo add-apt-repository --yes ppa:fenics-packages/fenics-exp/swig
|
||||
- sudo apt-get update -qq
|
||||
@ -12,27 +23,24 @@ install:
|
||||
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
|
||||
- sudo update-java-alternatives -s java-8-oracle
|
||||
before_script:
|
||||
- export NODE_ROOT_DIR="/home/travis/.nvm/v0.10.36"
|
||||
- if [ "$CC" = "gcc" ]; then export BUILDJAVA=ON; else export BUILDJAVA=OFF; fi
|
||||
- export JAVA_HOME=/usr/lib/jvm/java-8-oracle
|
||||
- if [ "${NODE4}" ]; then nvm install 4.1; export CC=gcc-4.8; export CXX=g++-4.8; export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; fi
|
||||
- if [ "${NODE5}" ]; then nvm install 5; export CC=gcc-4.8; export CXX=g++-4.8; export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; fi
|
||||
- if [ "${NODE012}" ]; then nvm install 0.12; export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; fi
|
||||
# Turn off JAVA SWIG for clang++, use 4.8 for all g++ builds
|
||||
- if [ "$CC" == "gcc" ]; then export BUILDJAVA=ON; export CC=gcc-4.8; export CXX=g++-4.8; else export BUILDJAVA=OFF; fi
|
||||
- if [ "${NODE012}" ]; then nvm install 0.12; fi
|
||||
- if [ "${NODE4}" ]; then nvm install 4.1; fi
|
||||
- if [ "${NODE5}" ]; then nvm install 5; fi
|
||||
# Handle 0.10 NODE_ROOT_DIR differently than other versions
|
||||
- if [ -z ${NODE010} ]; then export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; else export NODE_ROOT_DIR=/home/travis/.nvm/v0.10.36; fi
|
||||
script:
|
||||
- git clone https://github.com/intel-iot-devkit/mraa.git
|
||||
- cd mraa && mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDSWIGNODE=OFF -DBUILDSWIGPYTHON=OFF -DFIRMATA=ON -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=. .. && make && make install
|
||||
- export PKG_CONFIG_PATH=$PWD/lib/pkgconfig:$PWD/lib/x86_64-linux-gnu/pkgconfig
|
||||
- export CPLUS_INCLUDE_PATH=$PWD/include
|
||||
- export LIBRARY_PATH=$PWD/lib:$PWD/lib/x86_64-linux-gnu
|
||||
- cd ../.. && mkdir build && cd build && cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA .. && make
|
||||
- echo "CC=$CC BUILDJAVA=$BUILDJAVA NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
|
||||
- git clone https://github.com/intel-iot-devkit/mraa.git $MRAA_ROOT
|
||||
- mkdir -p $MRAA_BUILD && cd $_ && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDSWIGNODE=OFF -DBUILDSWIGPYTHON=OFF -DFIRMATA=ON -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=$MRAA_INSTALL $MRAA_ROOT && make install
|
||||
- cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && PKG_CONFIG_PATH=$MRAA_INSTALL/lib/pkgconfig cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA -DCMAKE_INSTALL_PREFIX:PATH=$UPM_INSTALL .. && make install
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-precise-3.6
|
||||
- ubuntu-toolchain-r-test
|
||||
- george-edison55-precise-backports
|
||||
packages:
|
||||
- clang-3.6
|
||||
- g++-4.8
|
||||
- cmake
|
||||
- cmake-data
|
||||
- g++-4.8
|
||||
|
@ -10,27 +10,22 @@ find_package (PkgConfig REQUIRED)
|
||||
|
||||
# Force a libmraa search and minimum required version every time a config is generated
|
||||
unset(MRAA_FOUND CACHE)
|
||||
pkg_check_modules (MRAA REQUIRED mraa>=0.9.1)
|
||||
pkg_check_modules (MRAA REQUIRED mraa>=1.0.0)
|
||||
message (INFO " found mraa version: ${MRAA_VERSION}")
|
||||
|
||||
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
||||
# Older cmake might not pick CMAKE_INSTALL_LIBDIR right
|
||||
if (CMAKE_INSTALL_LIBDIR)
|
||||
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
|
||||
else ()
|
||||
set (LIB_INSTALL_DIR "lib" CACHE PATH "Installation path for libraries")
|
||||
endif ()
|
||||
|
||||
# Set CMAKE_LIB_INSTALL_DIR if not defined
|
||||
# Set CMAKE_INSTALL_LIBDIR if not defined
|
||||
include(GNUInstallDirs)
|
||||
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
|
||||
|
||||
# Make a version file containing the current version from git.
|
||||
include (GetGitRevisionDescription)
|
||||
git_describe (VERSION "--tags")
|
||||
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
|
||||
message (WARNING " - Install git to compile a production UPM!")
|
||||
set (VERSION "v0.6.1-dirty")
|
||||
set (VERSION "v0.7.0-dirty")
|
||||
endif ()
|
||||
|
||||
message (INFO " - UPM Version ${VERSION}")
|
||||
@ -83,6 +78,11 @@ include (TargetArch)
|
||||
target_architecture (DETECTED_ARCH)
|
||||
message( INFO " - Target arch is ${DETECTED_ARCH}")
|
||||
|
||||
#-march=native for ARM when not defined/forced
|
||||
if (DETECTED_ARCH MATCHES "arm.*" AND NOT CMAKE_CXX_FLAGS MATCHES "-march")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
||||
endif()
|
||||
|
||||
# enable c++11 standards support
|
||||
if (ENABLECXX11)
|
||||
include(CheckCXXCompilerFlag)
|
||||
@ -157,9 +157,9 @@ if (BUILDDOC)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxy/node/${JSDOC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${JSDOC_FILE} COPYONLY)
|
||||
endforeach()
|
||||
add_custom_target(jsdoc ALL
|
||||
COMMAND ${NODE_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
|
||||
COMMAND ${NODEJS_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
|
||||
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers generators/yuidoc/helper.js --themedir generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
|
||||
COMMAND ${NODE_EXECUTABLE} tolower -i html/node
|
||||
COMMAND ${NODEJS_EXECUTABLE} tolower -i html/node
|
||||
DEPENDS doc
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Yuidoc" VERBATIM
|
||||
@ -210,12 +210,17 @@ if (RPM)
|
||||
set(CPACK_PACKAGE_VERSION ${VERSION})
|
||||
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}")
|
||||
"${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*\\.//"
|
||||
|
34
README.md
34
README.md
@ -1,29 +1,29 @@
|
||||
UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
|
||||
==============
|
||||
|
||||
UPM is a high level repository for sensors that use MRAA. Each sensor links
|
||||
to MRAA and are not meant to be interlinked although some groups of sensors
|
||||
may be. Each sensor contains a header which allows to interface with it.
|
||||
Typically a sensor is represented as a class and instantiated.
|
||||
The UPM repository provides software drivers for a wide variety of commonly
|
||||
used sensors and actuators. These software drivers interact with the
|
||||
underlying hardware platform (or microcontroller), as well as with the attached
|
||||
sensors, through calls to [MRAA](github.com/intel-iot-devkit/mraa) APIs.
|
||||
|
||||
The constructor is expected to initialise the sensor and parameters may be used
|
||||
to provide identification/pin location on the board.
|
||||
Programmers can access the interfaces for each sensor by including the sensor’s
|
||||
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.
|
||||
|
||||
Typically an update() function will be called in order to get new data from the
|
||||
sensor in order to reduce load when doing multiple reads to sensor data.
|
||||
|
||||
Although implementation and API design is up to the developer, C++ interfaces have
|
||||
been defined for the following sensor/actuator types and developers are encouraged to
|
||||
implement them. Interface header files are in the src/upm folder.
|
||||
C++ interfaces have been defined for the following sensor/actuator types, but
|
||||
they are subject to change:
|
||||
|
||||
* Light controller
|
||||
* Light sensor
|
||||
* Temperature sensor
|
||||
* Humidity sensor
|
||||
* Pressure sensor
|
||||
* Gas sensor
|
||||
* Analog to digital converter
|
||||
|
||||
Feedback on interface design and additions for new types are welcome
|
||||
The developer community is encouraged to help expand the list of supported
|
||||
sensors and actuators and provide feedback on interface design.
|
||||
|
||||
### Example
|
||||
|
||||
@ -114,6 +114,14 @@ API Documentation
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
|
||||
|
||||
### API Compatibility
|
||||
Even if we try our best not to, every once in a while we are forced to modify
|
||||
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** - Our **C++ header files** changed extension from *.h* to *.hpp*!
|
||||
|
||||
### Changelog
|
||||
Version changelog [here](docs/changelog.md).
|
||||
|
||||
|
@ -94,4 +94,4 @@ if (NODEJS_EXECUTABLE)
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (NODE_EXECUTABLE)
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
|
15
docs/apichanges.md
Normal file
15
docs/apichanges.md
Normal file
@ -0,0 +1,15 @@
|
||||
API Changes {#apichanges}
|
||||
===============
|
||||
|
||||
Here's a list of other API changes made to the library that break source/binary
|
||||
compatibility between releases:
|
||||
|
||||
* Our **C++ header files** changed their extension from *.h* to *.hpp* in
|
||||
version 0.7.0, Intel provided examples and code samples also reflect this
|
||||
change but you will need to modify your `#include` directives in existing code
|
||||
* **my9221**, **groveledbar** and **grovecircularled** are now all part of the
|
||||
same library (my9221) and new functionality was added going to v.0.5.1
|
||||
* **stepmotor** driver API was changed significantly from v.0.4.1 to v.0.5.0
|
||||
* **eboled** library was greatly improved in version 0.4.0 and the `draw()`
|
||||
function was removed in favor of a more complete GFX library implementation
|
||||
|
@ -4,6 +4,26 @@ Changelog {#changelog}
|
||||
Here's a list summarizing some of the key undergoing changes to our library
|
||||
from earlier versions:
|
||||
|
||||
### v0.7.0
|
||||
|
||||
* C++ header files have been renamed from *.h to *.hpp along with all Intel
|
||||
provided examples and code samples to allow for native C drivers
|
||||
* Updated driver compatibility to new MRAA 1.0 API
|
||||
* First sensor implementations for our newly added Dallas One Wire support
|
||||
* Several fixes based on issues reported on Github
|
||||
* Changed SWIG linking strategy, more robust Travis CI build checks
|
||||
* New sensors: ds2413, ds18b20, bmp280, bno055, l3gd20
|
||||
|
||||
### v0.6.2
|
||||
|
||||
* Added a generic driver for taking snapshots from an USB camera device
|
||||
* New API changes section in documentation to let users know when the UPM API
|
||||
gets modified
|
||||
* Fixed some spelling errors and improved JavaScript documentation builds with
|
||||
newer versions of YUI and Node
|
||||
* Enhanced Cmake scripts and the build process
|
||||
* New sensors: vcap, e50hx
|
||||
|
||||
### v0.6.1
|
||||
|
||||
* Fixed library build process for different configurations across multiple
|
||||
|
@ -13,7 +13,7 @@ This is a spi module so we will use the mraa spi functions to build our module.
|
||||
First thing to do is to create a tree structure like this in upm/src/max31855:
|
||||
|
||||
* max31855.cxx
|
||||
* max31855.h
|
||||
* max31855.hpp
|
||||
* jsupm_max31855.i
|
||||
* pyupm_max31855.i
|
||||
* CMakeLists.txt
|
||||
@ -36,11 +36,11 @@ used swig wrappers for UPM sensors, it's not obligatory but recommended.
|
||||
|
||||
### API
|
||||
|
||||
Then we create the header (max31855.h) , a very simple header in our case we
|
||||
Then we create the header (max31855.hpp) , a very simple header in our case we
|
||||
will have only a very basic api. We provide a getTemp() function which will
|
||||
return the same type as in the arduino library, a double.
|
||||
|
||||
@snippet max31855.h Interesting
|
||||
@snippet max31855.hpp Interesting
|
||||
|
||||
Note that the header contains both the io that we will use, the gpio is in this
|
||||
case used as the chip select pin.
|
||||
|
@ -14,16 +14,16 @@ example is explained in detail on @ref max31855
|
||||
|
||||
### CmakeLists.txt
|
||||
|
||||
By default you need a header called modulename.h and a C++ file called
|
||||
By default you need a header called modulename.hpp and a C++ file called
|
||||
modulename.cxx. You can have multiple headers and source files. Only public
|
||||
headers need to be added to module_h and all source files need to be in
|
||||
headers need to be added to module_hpp and all source files need to be in
|
||||
module_src.
|
||||
|
||||
~~~~~~~~~~~
|
||||
set (libname "modulename")
|
||||
set (libdescription "Module Description")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_h ${libname}.h)
|
||||
set (module_hpp ${libname}.hpp)
|
||||
upm_module_init()
|
||||
~~~~~~~~~~~
|
||||
|
||||
|
@ -859,6 +859,9 @@ EXCLUDE_SYMLINKS = NO
|
||||
# Note that the wildcards are matched against the file with absolute path, so to
|
||||
# exclude all test directories for example use the pattern */test/*
|
||||
|
||||
# bmi160 driver contains code provided by bosch. This source contains
|
||||
# tags which are picked up by doxygen (namely \mainpage) and
|
||||
# incorrectly get added to docs.
|
||||
EXCLUDE_PATTERNS = bosch_*
|
||||
|
||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||
|
@ -241,7 +241,6 @@ add_example (rhusb)
|
||||
add_example (apds9930)
|
||||
add_example (kxcjk1013)
|
||||
add_example (ssd1351)
|
||||
add_example (bme280)
|
||||
add_example (ds1808lc)
|
||||
add_example (hlg150h)
|
||||
add_example (lp8860)
|
||||
@ -258,6 +257,18 @@ add_example (smartdrive)
|
||||
if (HAVE_FIRMATA)
|
||||
add_example (curieimu)
|
||||
endif ()
|
||||
if (BACNET_FOUND)
|
||||
include_directories(${BACNET_INCLUDE_DIRS})
|
||||
# we need access to bacnetmstp headers too
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src/bacnetmstp)
|
||||
add_example (e50hx)
|
||||
endif()
|
||||
add_example (vcap)
|
||||
add_example (ds2413)
|
||||
add_example (ds18b20)
|
||||
add_example (bmp280)
|
||||
add_example (bno055)
|
||||
add_example (l3gd20)
|
||||
|
||||
# These are special cases where you specify example binary, source file and module(s)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src)
|
||||
@ -276,10 +287,11 @@ add_custom_example (ak8975-example ak8975.cxx mpu9150)
|
||||
add_custom_example (mpu9250-example mpu9250.cxx mpu9150)
|
||||
add_custom_example (groveledbar-example groveledbar.cxx my9221)
|
||||
add_custom_example (grovecircularled-example grovecircularled.cxx my9221)
|
||||
add_custom_example (temperature-sensor-example temperature-sensor.cxx "si7005;bmp180;bme280")
|
||||
add_custom_example (temperature-sensor-example temperature-sensor.cxx "si7005;bmpx8x;bme280")
|
||||
add_custom_example (humidity-sensor-example humidity-sensor.cxx "si7005;bme280")
|
||||
add_custom_example (pressure-sensor-example pressure-sensor.cxx "bmp180;bme280")
|
||||
add_custom_example (pressure-sensor-example pressure-sensor.cxx "bmpx8x;bme280")
|
||||
add_custom_example (co2-sensor-example co2-sensor.cxx "t6713")
|
||||
add_custom_example (adc-example adc-sensor.cxx "ads1x15")
|
||||
add_custom_example (light-sensor-example light-sensor.cxx "si1132;max44009")
|
||||
add_custom_example (light-controller-example light-controller.cxx "lp8860;ds1808lc;hlg150h")
|
||||
add_custom_example (bme280-example bme280.cxx bmp280)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "a110x.h"
|
||||
#include "a110x.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "a110x.h"
|
||||
#include "a110x.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "ad8232.h"
|
||||
#include "ad8232.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#include "adafruitms1438.h"
|
||||
#include "adafruitms1438.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#include "adafruitms1438.h"
|
||||
#include "adafruitms1438.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "adafruitss.h"
|
||||
#include "adafruitss.hpp"
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "ads1015.h"
|
||||
#include "ads1015.hpp"
|
||||
#include "mraa/gpio.hpp"
|
||||
|
||||
#define EDISON_I2C_BUS 1
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#include "adc121c021.h"
|
||||
#include "adc121c021.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include "ads1015.h"
|
||||
#include "ads1115.h"
|
||||
#include "ads1015.hpp"
|
||||
#include "ads1115.hpp"
|
||||
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "adxl335.h"
|
||||
#include "adxl335.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "adxl345.h"
|
||||
#include "adxl345.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "adxrs610.h"
|
||||
#include "adxrs610.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "mpu9150.h"
|
||||
#include "mpu9150.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "am2315.h"
|
||||
#include "am2315.hpp"
|
||||
|
||||
volatile int doWork = 0;
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "apa102.h"
|
||||
#include "apa102.hpp"
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "apds9002.h"
|
||||
#include "apds9002.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "apds9930.h"
|
||||
#include "apds9930.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#include "at42qt1070.h"
|
||||
#include "at42qt1070.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "biss0001.h"
|
||||
#include "biss0001.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "bma220.h"
|
||||
#include "bma220.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -24,28 +24,55 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "bme280.h"
|
||||
#include <signal.h>
|
||||
|
||||
#define FT4222_I2C_BUS 0
|
||||
#include "bme280.hpp"
|
||||
|
||||
int main ()
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
try {
|
||||
upm::BME280* bme280 = new upm::BME280 (mraa_get_sub_platform_id(FT4222_I2C_BUS));
|
||||
while (true) {
|
||||
int temperature = bme280->getTemperatureCelcius();
|
||||
int humidity = bme280->getHumidityRelative();
|
||||
int pressure = bme280->getPressurePa();
|
||||
std::cout << "Temperature = " << temperature << "C" << std::endl;
|
||||
std::cout << "Humidity = " << humidity << "%" << std::endl;
|
||||
std::cout << "Pressure = " << pressure << "Pa" << std::endl;
|
||||
sleep(1);
|
||||
}
|
||||
delete bme280;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a BME280 instance using default i2c bus and address
|
||||
upm::BME280 *sensor = new upm::BME280();
|
||||
|
||||
// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
|
||||
// BME280(0, -1, 10);
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
// update our values from the sensor
|
||||
sensor->update();
|
||||
|
||||
// we show both C and F for temperature
|
||||
cout << "Compensation Temperature: " << sensor->getTemperature()
|
||||
<< " C / " << sensor->getTemperature(true) << " F"
|
||||
<< endl;
|
||||
cout << "Pressure: " << sensor->getPressure() << " Pa" << endl;
|
||||
cout << "Computed Altitude: " << sensor->getAltitude() << " m" << endl;
|
||||
cout << "Humidity: " << sensor->getHumidity() << " %RH" << endl;
|
||||
|
||||
cout << endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "bmi160.h"
|
||||
#include "bmi160.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
77
examples/c++/bmp280.cxx
Normal file
77
examples/c++/bmp280.cxx
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "bmp280.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a BMP280 instance using default i2c bus and address
|
||||
upm::BMP280 *sensor = new upm::BMP280();
|
||||
|
||||
// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
|
||||
// BMP280(0, -1, 10);
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
// update our values from the sensor
|
||||
sensor->update();
|
||||
|
||||
// we show both C and F for temperature
|
||||
cout << "Compensation Temperature: " << sensor->getTemperature()
|
||||
<< " C / " << sensor->getTemperature(true) << " F"
|
||||
<< endl;
|
||||
cout << "Pressure: " << sensor->getPressure() << " Pa" << endl;
|
||||
cout << "Computed Altitude: " << sensor->getAltitude() << " m" << endl;
|
||||
|
||||
cout << endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "bmpx8x.h"
|
||||
#include "bmpx8x.hpp"
|
||||
#include <signal.h>
|
||||
|
||||
int doWork = 0;
|
||||
|
129
examples/c++/bno055.cxx
Normal file
129
examples/c++/bno055.cxx
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "bno055.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]
|
||||
|
||||
// Instantiate an BNO055 using default parameters (bus 0, addr
|
||||
// 0x28). The default running mode is NDOF absolute orientation
|
||||
// mode.
|
||||
upm::BNO055 *sensor = new upm::BNO055();
|
||||
|
||||
// First we need to calibrate....
|
||||
cout << "First we need to calibrate. 4 numbers will be output every"
|
||||
<< endl;
|
||||
cout << "second for each sensor. 0 means uncalibrated, and 3 means"
|
||||
<< endl;
|
||||
cout << "fully calibrated."
|
||||
<< endl;
|
||||
cout << "See the UPM documentation on this sensor for instructions on"
|
||||
<< endl;
|
||||
cout << "what actions are required to calibrate."
|
||||
<< endl;
|
||||
cout << endl;
|
||||
|
||||
// do the calibration...
|
||||
while (shouldRun && !sensor->isFullyCalibrated())
|
||||
{
|
||||
int mag, acc, gyr, sys;
|
||||
sensor->getCalibrationStatus(&mag, &acc, &gyr, &sys);
|
||||
|
||||
cout << "Magnetometer: " << mag
|
||||
<< " Accelerometer: " << acc
|
||||
<< " Gyroscope: " << gyr
|
||||
<< " System: " << sys
|
||||
<< endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
cout << "Calibration complete." << endl;
|
||||
cout << endl;
|
||||
|
||||
// now output various fusion data every 250 milliseconds
|
||||
while (shouldRun)
|
||||
{
|
||||
float w, x, y, z;
|
||||
|
||||
sensor->update();
|
||||
|
||||
sensor->getEulerAngles(&x, &y, &z);
|
||||
cout << "Euler: Heading: " << x
|
||||
<< " Roll: " << y
|
||||
<< " Pitch: " << z
|
||||
<< " degrees"
|
||||
<< endl;
|
||||
|
||||
sensor->getQuaternions(&w, &x, &y, &z);
|
||||
cout << "Quaternion: W: " << w
|
||||
<< " X: " << x
|
||||
<< " Y: " << y
|
||||
<< " Z: " << z
|
||||
<< endl;
|
||||
|
||||
sensor->getLinearAcceleration(&x, &y, &z);
|
||||
cout << "Linear Acceleration: X: " << x
|
||||
<< " Y: " << y
|
||||
<< " Z: " << z
|
||||
<< " m/s^2"
|
||||
<< endl;
|
||||
|
||||
sensor->getGravityVectors(&x, &y, &z);
|
||||
cout << "Gravity Vector: X: " << x
|
||||
<< " Y: " << y
|
||||
<< " Z: " << z
|
||||
<< " m/s^2"
|
||||
<< endl;
|
||||
|
||||
cout << endl;
|
||||
usleep(250000);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "buzzer.h"
|
||||
#include "buzzer.hpp"
|
||||
|
||||
|
||||
int
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "cjq4435.h"
|
||||
#include "cjq4435.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "t6713.h"
|
||||
#include "t6713.hpp"
|
||||
|
||||
#define EDISON_I2C_BUS 1
|
||||
#define FT4222_I2C_BUS 0
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "cwlsxxa.h"
|
||||
#include "cwlsxxa.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "dfrph.h"
|
||||
#include "dfrph.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "ds1307.h"
|
||||
#include "ds1307.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "ds1808lc.h"
|
||||
#include "ds1808lc.hpp"
|
||||
|
||||
#define EDISON_I2C_BUS 1 // Edison I2C-1
|
||||
#define DS1808_GPIO_PWR 15 // Edison GP165
|
||||
|
81
examples/c++/ds18b20.cxx
Normal file
81
examples/c++/ds18b20.cxx
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "ds18b20.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Initializing..." << endl;
|
||||
|
||||
// Instantiate an DS18B20 instance using the default values (uart 0)
|
||||
upm::DS18B20 sensor;
|
||||
|
||||
// locate and setup our devices
|
||||
sensor.init();
|
||||
|
||||
cout << "Found " << sensor.devicesFound() << " device(s)" << endl;
|
||||
cout << endl;
|
||||
|
||||
// bail if we didn't find anything
|
||||
if (!sensor.devicesFound())
|
||||
return 1;
|
||||
|
||||
// update and print available values every second
|
||||
while (shouldRun)
|
||||
{
|
||||
// update our values for the first sensor
|
||||
sensor.update(0);
|
||||
|
||||
// we show both C and F for temperature for the first sensor
|
||||
cout << "Temperature: " << sensor.getTemperature(0)
|
||||
<< " C / " << sensor.getTemperature(0, true) << " F"
|
||||
<< endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
59
examples/c++/ds2413.cxx
Normal file
59
examples/c++/ds2413.cxx
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include "ds2413.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
|
||||
upm::DS2413* sensor = new upm::DS2413(0);
|
||||
|
||||
// find all of the DS2413 devices present on the bus
|
||||
sensor->init();
|
||||
|
||||
// how many devices were found?
|
||||
cout << "Found "<< sensor->devicesFound() << " device(s)" << endl;
|
||||
|
||||
// read the gpio and latch values from the first device
|
||||
// the lower 4 bits are of the form:
|
||||
// <gpioB latch> <gpioB value> <gpioA latch> <gpioA value>
|
||||
cout << "GPIO device 0 values: " << sensor->readGpios(0) << endl;
|
||||
|
||||
// set the gpio latch values of the first device
|
||||
cout << "Setting GPIO latches to on" << endl;
|
||||
sensor->writeGpios(0, 0x03);
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
112
examples/c++/e50hx.cxx
Normal file
112
examples/c++/e50hx.cxx
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "e50hx.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// You will need to edit this example to conform to your site and your
|
||||
// devices, specifically the Device Object Instance ID passed to the
|
||||
// constructor, and the arguments to initMaster() that are
|
||||
// appropriate for your BACnet network.
|
||||
|
||||
string defaultDev = "/dev/ttyUSB0";
|
||||
|
||||
// if an argument was specified, use it as the device instead
|
||||
if (argc > 1)
|
||||
defaultDev = string(argv[1]);
|
||||
|
||||
cout << "Using device " << defaultDev << endl;
|
||||
cout << "Initializing..." << endl;
|
||||
|
||||
// Instantiate an E50HX object for an E50HX device that has 1075425
|
||||
// as it's unique Device Object Instance ID. NOTE: You will
|
||||
// certainly want to change this to the correct value for your
|
||||
// device(s).
|
||||
E50HX *sensor = new E50HX(1075425);
|
||||
|
||||
// Initialize our BACnet master, if it has not already been
|
||||
// initialized, with the device and baudrate, choosing 1000001 as
|
||||
// our unique Device Object Instance ID, 2 as our MAC address and
|
||||
// using default values for maxMaster and maxInfoFrames
|
||||
sensor->initMaster(defaultDev, 38400, 1000001, 2);
|
||||
|
||||
// Uncomment to enable debugging output
|
||||
// sensor->setDebug(true);
|
||||
|
||||
cout << endl;
|
||||
cout << "Device Description: " << sensor->getDescription() << endl;
|
||||
cout << "Device Location: " << sensor->getLocation() << endl;
|
||||
cout << endl;
|
||||
|
||||
// update and print a few values every 5 seconds
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << "System Voltage: "
|
||||
<< sensor->getAnalogValue(E50HX::AV_System_Voltage)
|
||||
<< " " << sensor->getAnalogValueUnits(E50HX::AV_System_Voltage)
|
||||
<< endl;
|
||||
|
||||
cout << "System Type: "
|
||||
<< sensor->getAnalogValue(E50HX::AV_System_Type)
|
||||
<< endl;
|
||||
|
||||
cout << "Energy Consumption: " << sensor->getAnalogInput(E50HX::AI_Energy)
|
||||
<< " " << sensor->getAnalogInputUnits(E50HX::AI_Energy)
|
||||
<< endl;
|
||||
|
||||
cout << "Power Up Counter: "
|
||||
<< sensor->getAnalogInput(E50HX::AI_Power_Up_Count)
|
||||
<< endl;
|
||||
|
||||
cout << endl;
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "eboled.h"
|
||||
#include "eboled.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include "ecs1030.h"
|
||||
#include "ecs1030.hpp"
|
||||
|
||||
int is_running = 0;
|
||||
upm::ECS1030 *sensor = NULL;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "enc03r.h"
|
||||
#include "enc03r.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "es08a.h"
|
||||
#include "es08a.hpp"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "flex.h"
|
||||
#include "flex.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "gp2y0a.h"
|
||||
#include "gp2y0a.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "grove.h"
|
||||
#include "grove.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grovecircularled.h"
|
||||
#include "grovecircularled.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "grovecollision.h"
|
||||
#include "grovecollision.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "groveehr.h"
|
||||
#include "groveehr.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "groveeldriver.h"
|
||||
#include "groveeldriver.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include "groveelectromagnet.h"
|
||||
#include "groveelectromagnet.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "groveemg.h"
|
||||
#include "groveemg.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include "grovegprs.h"
|
||||
#include "grovegprs.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grovegsr.h"
|
||||
#include "grovegsr.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grove.h"
|
||||
#include "grove.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "grove.h"
|
||||
#include "grove.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "groveledbar.h"
|
||||
#include "groveledbar.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "grove.h"
|
||||
#include "grove.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grovelinefinder.h"
|
||||
#include "grovelinefinder.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#include "grovemd.h"
|
||||
#include "grovemd.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#include "grovemd.h"
|
||||
#include "grovemd.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grovemoisture.h"
|
||||
#include "grovemoisture.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "groveo2.h"
|
||||
#include "groveo2.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "grove.h"
|
||||
#include "grove.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "grove.h"
|
||||
#include "grove.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include "grovescam.h"
|
||||
#include "grovescam.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "grove.h"
|
||||
#include "grove.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grovespeaker.h"
|
||||
#include "grovespeaker.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "grove.h"
|
||||
#include "grove.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "groveultrasonic.h"
|
||||
#include "groveultrasonic.hpp"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grovevdiv.h"
|
||||
#include "grovevdiv.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grovewater.h"
|
||||
#include "grovewater.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grovewfs.h"
|
||||
#include "grovewfs.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "guvas12d.h"
|
||||
#include "guvas12d.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#include "h3lis331dl.h"
|
||||
#include "h3lis331dl.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "h803x.h"
|
||||
#include "h803x.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "hcsr04.h"
|
||||
#include "hcsr04.hpp"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "hdxxvxta.h"
|
||||
#include "hdxxvxta.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "hlg150h.h"
|
||||
#include "hlg150h.hpp"
|
||||
|
||||
#define HLG150H_GPIO_RELAY 21
|
||||
#define HLG150H_GPIO_PWM 22
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include "hm11.h"
|
||||
#include "hm11.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "hmc5883l.h"
|
||||
#include "hmc5883l.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "hmtrp.h"
|
||||
#include "hmtrp.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -135,7 +135,7 @@ int main (int argc, char **argv)
|
||||
if (rv > 0)
|
||||
cout << "Received: " << radioBuffer << endl;
|
||||
|
||||
if (rv < 0) // some sort of read error occured
|
||||
if (rv < 0) // some sort of read error occurred
|
||||
{
|
||||
cerr << "Port read error." << endl;
|
||||
break;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#include "hp20x.h"
|
||||
#include "hp20x.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "ht9170.h"
|
||||
#include "ht9170.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "htu21d.h"
|
||||
#include "htu21d.hpp"
|
||||
|
||||
volatile int doWork = 0;
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "si7005.h"
|
||||
#include "bme280.h"
|
||||
#include "si7005.hpp"
|
||||
#include "bme280.hpp"
|
||||
|
||||
#define EDISON_I2C_BUS 1
|
||||
#define FT4222_I2C_BUS 0
|
||||
@ -41,6 +41,7 @@
|
||||
upm::IHumiditySensor* getHumiditySensor()
|
||||
{
|
||||
upm::IHumiditySensor* humiditySensor = NULL;
|
||||
|
||||
try {
|
||||
humiditySensor = new upm::BME280 (mraa_get_sub_platform_id(FT4222_I2C_BUS));
|
||||
return humiditySensor ;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "hwxpxx.h"
|
||||
#include "hwxpxx.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
//! [Interesting]
|
||||
#include "hx711.h"
|
||||
#include "hx711.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ili9341.h"
|
||||
#include "ili9341.hpp"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
//! [Interesting]
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "ina132.h"
|
||||
#include "ina132.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "isd1820.h"
|
||||
#include "isd1820.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "itg3200.h"
|
||||
#include "itg3200.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "jhd1313m1.h"
|
||||
#include "jhd1313m1.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "joystick12.h"
|
||||
#include "joystick12.hpp"
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user