mirror of
https://github.com/eclipse/upm.git
synced 2025-07-06 20:01:12 +03:00
Compare commits
138 Commits
Author | SHA1 | Date | |
---|---|---|---|
78eb975435 | |||
a0ea3d5f3d | |||
f77863dfb5 | |||
7e5f6e9856 | |||
d004aa68b7 | |||
3aef2ea70e | |||
39df7fd10f | |||
b8738b32ca | |||
cdb697fd7b | |||
27dc4a5742 | |||
e2fe04927f | |||
a655235c70 | |||
96b219d2fb | |||
52879b0b04 | |||
048f1ac08e | |||
76a12af15f | |||
e6ed49427a | |||
c57a0d2c30 | |||
8d43c431f2 | |||
336251740d | |||
356f0348ed | |||
dc7c012c24 | |||
96eb834e9b | |||
b239866e99 | |||
6a4f06d51b | |||
e765dcf57b | |||
a594036778 | |||
c014ffddcd | |||
aeaf84ccc6 | |||
7d789ec208 | |||
3d0461b40a | |||
5aed632782 | |||
3c5a5b87c8 | |||
22a6c52795 | |||
b8fa948f7d | |||
f61b615704 | |||
8dcd22794b | |||
33f3c882b8 | |||
5943dad78c | |||
2f051a202c | |||
a760f2952a | |||
9549529faf | |||
65969462d1 | |||
13eea53090 | |||
fa8ab6194d | |||
8048e8734f | |||
8262a4203b | |||
01f9dd2f41 | |||
ccb9fa2a4f | |||
05435eed4f | |||
54a84af1c3 | |||
27c6ac1d31 | |||
8779700d82 | |||
f9b5d7c52c | |||
a10e798682 | |||
8cd91624ee | |||
68e42a22d6 | |||
fdef953859 | |||
3f334ed1f3 | |||
1a0bdf00cf | |||
54cd191d43 | |||
9fa4dad1ab | |||
080c121e07 | |||
545e288967 | |||
aecdac255d | |||
5c837f22cb | |||
12c81adeba | |||
8342b4c079 | |||
e83b8ef114 | |||
fabf4287d6 | |||
4ea01180a1 | |||
ab171573f9 | |||
d965b92af1 | |||
cc0174910b | |||
c4a506f5a3 | |||
58cdfadf4e | |||
b3a5275183 | |||
b314f56c00 | |||
d4b536b593 | |||
2bdde21a2f | |||
6ceebc9a17 | |||
65fc70a31a | |||
51a181a14f | |||
cfb4105dd8 | |||
b7faba556f | |||
95801b395d | |||
1f18369fbe | |||
f8663c90f3 | |||
1d6d660769 | |||
b57710cd78 | |||
6d41566e93 | |||
7a60cd5abe | |||
b9988469ba | |||
4fff3a500d | |||
a53ab5cb80 | |||
bd8104f6ee | |||
dbac88d225 | |||
70bcdfefa4 | |||
762c28f000 | |||
283fce619e | |||
7a5c8a6cb3 | |||
4342b880b9 | |||
ddddbd024d | |||
67e0ceb48d | |||
2298846fef | |||
567476b89a | |||
d345006c03 | |||
7f0e03b0e3 | |||
08a46ee8e6 | |||
fb88fda5cb | |||
90d856d128 | |||
d2e0327c30 | |||
2e97aa9979 | |||
cdb75e8c13 | |||
dac31a0347 | |||
0749f130e1 | |||
1bbb9386b7 | |||
f914159e21 | |||
849711c47d | |||
0a91eb0b46 | |||
806b00c2b7 | |||
e8151640a1 | |||
123e611f45 | |||
8d5278b9d4 | |||
ab96e8f3a3 | |||
d3b864362d | |||
6769d976a0 | |||
bd47b9ed45 | |||
6ea65a16a4 | |||
0849fbc674 | |||
e25be536a1 | |||
a70629e3b2 | |||
fed0478dc9 | |||
fcb4d9d36d | |||
5eb8af6d70 | |||
3c93eba4af | |||
78953b110f | |||
53124e9704 |
@ -118,8 +118,10 @@ find_package (PkgConfig REQUIRED)
|
||||
|
||||
# Force a libmraa search and minimum required version every time a config is generated
|
||||
unset(MRAA_FOUND CACHE)
|
||||
set(MRAA_MINIMUM 1.1.1)
|
||||
set(MRAA_MINIMUM 1.6.1)
|
||||
pkg_check_modules (MRAA REQUIRED mraa>=${MRAA_MINIMUM})
|
||||
# Also, get full path to the mraa library
|
||||
find_library(MRAA_LIBRARY NAMES mraa PATHS ${MRAA_LIBDIR} NO_DEFAULT_PATH)
|
||||
|
||||
# Check for BACNET
|
||||
pkg_check_modules (BACNET libbacnet)
|
||||
@ -143,6 +145,8 @@ if (BUILDSWIGJAVA)
|
||||
find_package (Java REQUIRED)
|
||||
find_package (JNI REQUIRED)
|
||||
pkg_check_modules (MRAAJAVA REQUIRED mraajava>=0.8.0)
|
||||
# Also, get full path to the mraajava library
|
||||
find_library(MRAAJAVA_LIBRARY NAMES mraajava PATHS ${MRAA_LIBDIR} NO_DEFAULT_PATH)
|
||||
endif (BUILDSWIGJAVA)
|
||||
|
||||
# Find swig if any wrapper is enabled
|
||||
@ -193,7 +197,7 @@ include (GetGitRevisionDescription)
|
||||
git_describe (VERSION "--tags")
|
||||
# If git_describe fails, use a dirty version
|
||||
if (${VERSION} MATCHES -NOTFOUND)
|
||||
set (VERSION "v1.0.2")
|
||||
set (VERSION "v1.2.0")
|
||||
message (WARNING "Failed to retrieve UPM version with 'git describe' (using "
|
||||
"${VERSION}). Check that git is installed and this is a valid git repo.")
|
||||
endif ()
|
||||
@ -415,18 +419,11 @@ set (UPM_COMMON_HEADER_DIRS
|
||||
${CMAKE_HOME_DIRECTORY}/include
|
||||
${CMAKE_HOME_DIRECTORY}/include/fti)
|
||||
|
||||
# UPM source
|
||||
add_subdirectory (src)
|
||||
if(BUILDEXAMPLES)
|
||||
add_subdirectory (examples/c)
|
||||
if(BUILDCPP)
|
||||
add_subdirectory (examples/c++)
|
||||
endif(BUILDCPP)
|
||||
endif()
|
||||
|
||||
# Build java examples
|
||||
if(BUILDSWIGJAVA AND BUILDEXAMPLES)
|
||||
add_subdirectory (examples/java)
|
||||
endif()
|
||||
# UPM examples
|
||||
add_subdirectory (examples)
|
||||
|
||||
# Python interp is previously found if BUILDTESTS=ON
|
||||
if (BUILDTESTS)
|
||||
|
3
LICENSE
3
LICENSE
@ -1,4 +1,5 @@
|
||||
Copyright © 2014-2015 Intel Corporation
|
||||
The MIT License (MIT)
|
||||
Copyright © 2014-2016 Intel Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
45
README.md
45
README.md
@ -30,28 +30,20 @@ sensors and actuators and provide feedback on interface design.
|
||||
A sensor/actuator is expected to work as such (here is the MMA7660 accelerometer API):
|
||||
```C++
|
||||
// Instantiate an MMA7660 on I2C bus 0
|
||||
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_I2C_BUS,
|
||||
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_DEFAULT_I2C_BUS,
|
||||
MMA7660_DEFAULT_I2C_ADDR);
|
||||
|
||||
// place device in standby mode so we can write registers
|
||||
accel->setModeStandby();
|
||||
|
||||
// enable 64 samples per second
|
||||
accel->setSampleRate(upm::MMA7660::AUTOSLEEP_64);
|
||||
accel->setSampleRate(MMA7660_AUTOSLEEP_64);
|
||||
|
||||
// place device into active mode
|
||||
accel->setModeActive();
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
int x, y, z;
|
||||
|
||||
accel->getRawValues(&x, &y, &z);
|
||||
cout << "Raw values: x = " << x
|
||||
<< " y = " << y
|
||||
<< " z = " << z
|
||||
<< endl;
|
||||
|
||||
float ax, ay, az;
|
||||
|
||||
accel->getAcceleration(&ax, &ay, &az);
|
||||
@ -82,6 +74,10 @@ please refer to the Intel Developer Zone IDE page.
|
||||
|
||||
<a href="https://software.intel.com/iot/software/ide"><img src="docs/icons/allides.png"/></a>
|
||||
|
||||
### Installing UPM
|
||||
|
||||
Find notes on how to install UPM on various OS'es on this [page](docs/installing.md).
|
||||
|
||||
### Building UPM
|
||||
|
||||
See building documentation [here](docs/building.md).
|
||||
@ -90,24 +86,34 @@ See building documentation [here](docs/building.md).
|
||||
|
||||
### Making your own UPM module
|
||||
|
||||
Porting [link](docs/porting.md) has more information on making new UPM modules.
|
||||
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.
|
||||
|
||||
There is also an example available gfor max31855 [sensor](docs/max31855.md).
|
||||
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).
|
||||
|
||||
Guide on creating Java [bindings](docs/creating_java_bindings.md).
|
||||
Read more on creating Java [bindings](docs/creating_java_bindings.md) for your
|
||||
new driver.
|
||||
|
||||
### Naming conventions and rules for new UPM contributions
|
||||
### Guidelines and rules for new UPM contributions
|
||||
|
||||
Before you begin development, take a look at our naming [conventions](docs/naming.md).
|
||||
The name you pick for a newly added sensor needs to be unique in the UPM library.
|
||||
|
||||
Also, please read the guidelines for contributions [to UPM](docs/contributions.md).
|
||||
|
||||
Don't forget to check the documentation [section](docs/documentation.md).
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
about this in our [section](docs/documentation.md) on documenting a sensor API.
|
||||
Finally, if you really want to ensure consistency with the rest of the library,
|
||||
and the intel-iot-devkit repositories in general, take a look at our extensive
|
||||
[author guide](docs/guidelines.md).
|
||||
|
||||
API Documentation
|
||||
==============
|
||||
|
||||
@ -122,7 +128,8 @@ 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*!
|
||||
**NOTE** - Several important API changes are currently underway for some of our
|
||||
widely used libraries including `libupm-grove` and `libupm-i2clcd`!
|
||||
|
||||
### Changelog
|
||||
Version changelog [here](docs/changelog.md).
|
||||
|
@ -4,6 +4,191 @@ API Changes {#apichanges}
|
||||
Here's a list of other API changes made to the library that break source/binary
|
||||
compatibility between releases:
|
||||
|
||||
# v1.2.0
|
||||
|
||||
* **Note for all drivers ported to C** As a general note concerning
|
||||
all of the drivers that have been ported to C: **external constants
|
||||
have likely been renamed**. Previously in C++, most these constants
|
||||
were defined as enums in the *upm::classname* namespace.
|
||||
|
||||
For drivers written in C, all of these constants are no longer in
|
||||
a class (or UPM) namespace, and instead have the driver name
|
||||
prefixed to the original value.
|
||||
|
||||
The driver name is prefixed to these constants to avoid name
|
||||
collisions when using multiple drivers in a given application, and
|
||||
to make it clear which constants belong to which driver.
|
||||
|
||||
For drivers that used *#define* for constants, only the prefix has
|
||||
been added if not already present. In some cases, names that were
|
||||
not very descriptive were changed, for example *ADDR* renamed to
|
||||
*BMPX8X_DEFAULT_I2C_ADDR*.
|
||||
|
||||
So for example, a constant that might once have been referred to
|
||||
in a C++ example as *upm::MMA7660::AUTOSLEEP_64*, would now be
|
||||
referenced as *MMA7660_AUTOSLEEP_64*.
|
||||
|
||||
This holds true for most, if not all drivers that have been ported
|
||||
to C. Not all of these changes are listed in this file due to the
|
||||
sheer number of them.
|
||||
|
||||
If you run into problems with constants that were working
|
||||
previously, and now cannot be found, this is likely the reason.
|
||||
Check the driver documentation and the source code to see what the
|
||||
new name is.
|
||||
|
||||
In C, constants are now usually implemented in a separate header
|
||||
file named *drivername_defs.h* or *drivername_regs.h*, for easier
|
||||
integration into the SWIG languages, and shared use between C++ and
|
||||
C implementations.
|
||||
|
||||
* **bmpx8x** This driver has been rewritten from scratch in C, with a
|
||||
C++ wrapper.
|
||||
|
||||
All exported symbols have been renamed for consistency and to
|
||||
avoid symbol collisions by having a *BMPX8X_* prefix. As an example,
|
||||
*ADDR* has been renamed to *BMPX8X_DEFAULT_I2C_ADDR*. Most C
|
||||
ported drivers follow this rule.
|
||||
|
||||
The *getPressureRaw()* and *getTemperatureRaw()* functions have
|
||||
been removed. This functionality was only needed internally to
|
||||
the driver.
|
||||
|
||||
The constructor no longer accepts a mode argument. Only the I2C
|
||||
bus and I2C address are accepted. By default, the device will be
|
||||
configured for it's maximum resolution *BMPX8X_OSS_ULTRAHIGHRES*,
|
||||
the previous default. You can use the new method
|
||||
*setOversampling()* to change the mode to something else if
|
||||
desired.
|
||||
|
||||
The methods related to calibration, like *computeB5()* are no
|
||||
longer exposed.
|
||||
|
||||
New methods, *init()* and *reset()* have been added. *reset()*
|
||||
resets the device to a freshly powered up state. *init()* can be
|
||||
used to re-initialize the device after a reset (reload calibration
|
||||
data) and set a default oversampling mode.
|
||||
|
||||
A new method, *update()* has been added. This method will update
|
||||
all internal state from the device, and **must** be called before
|
||||
querying the pressure, temperature, sea level and altitude values.
|
||||
|
||||
The *getSeaLevelPressure()* method has been split into two
|
||||
overloaded methods. One which **requires** an argument in meters
|
||||
(previously, a default was provided), and another which does not
|
||||
accept arguments at all and computes the sea level pressure based
|
||||
on current altitude.
|
||||
|
||||
The *i2cReadReg_16()*, *i2CWriteReg()* and *i2cReadReg_8()* have
|
||||
been replaced with *readReg()*, *readRegs()*, and *writeReg()*, in
|
||||
line with other I2C/SPI drivers of this type. They are marked
|
||||
protected (in C++) now as well. Please see the updated
|
||||
documentation and examples for this driver.
|
||||
|
||||
* **mma7660** This driver has been rewritten in C. Some exported
|
||||
symbols have been changed, for example, *MMA7660_I2C_BUS* was renamed
|
||||
to *MMA7660_DEFAULT_I2C_BUS*.
|
||||
|
||||
See updated documentation and examples for other changes.
|
||||
|
||||
* **bmx055, bmi055, bmc150, bma250e, bmg160, bmm150** This driver has
|
||||
been split up. The *bma250e*, *bmg160*, *bmm150* drivers have been
|
||||
rewritten in C (with C++ wrappers) and now reside in their own
|
||||
libraries. The versions of these drivers that used to be present in
|
||||
*bmx055* have been removed, and *bmx055* now uses the new libraries
|
||||
for it's functionality. The other two composite devices, *bmi055*,
|
||||
and *bmc150* are still contained within the *bmx055* library, and
|
||||
also use the new libraries for their functionality.
|
||||
|
||||
In addition, for all of these drivers some private methods are no
|
||||
longer exposed (such as the compensation routines).
|
||||
|
||||
The C++ driver methods that once returned pointers to a floating
|
||||
point array now return *std::vectors* of the appropriate type.
|
||||
The SWIG language examples for these drivers have been modified to
|
||||
use these methods instead of the C pointer based SWIG methods
|
||||
previously used.
|
||||
|
||||
* **sainsmartks** This driver has been renamed to *lcdks* (LCD Keypad
|
||||
Shield) and moved into it's own library. It uses the *lcm1602*
|
||||
library to do most of it's work. In addition, an additional argument
|
||||
was added to the constructor to optionally allow specifying a GPIO
|
||||
pin to be used to control the backlight. This driver supports the
|
||||
SainsmartKS and DFRobot LCD Keypad Shields. Similar devices from
|
||||
other manufacturers should also work with this driver.
|
||||
|
||||
* **lcm1602/jhd1313m1** These drivers had been rewritten in C, with
|
||||
C++ wrappers and placed into their own libraries in the previous
|
||||
version of UPM, however, the original C++ implementation was kept in
|
||||
the lcd/i2clcd library for compatibility reasons with existing code.
|
||||
To avoid collisions with the header files, the new *lcm1602* and
|
||||
*jhd1313m1* drivers had their C++ headers renamed to use a **.hxx**
|
||||
suffix.
|
||||
|
||||
In this version of UPM, the *lcm1602* and *jhd1313m1* drivers have
|
||||
been removed from the lcd/i2clcd library. In addition, the header
|
||||
files for the new implementation have been renamed from their
|
||||
**.hxx** suffix to the normal **.hpp** suffix.
|
||||
|
||||
A change was also made to the new *lcm1602* and *jhd1313m1* C++
|
||||
drivers. The *createChar()* function now accepts a byte vector
|
||||
*std::vector<uint8_t>* rather than the *char ** pointer that was
|
||||
used previously. This should make it easier to use with the SWIG
|
||||
language bindings (Python, JavaScript, and especially Java).
|
||||
|
||||
* **bmp280/bme280** Some private methods are no longer exposed (such
|
||||
as the calibration and compensation routines). In addition,
|
||||
the *getHumidity()* method no longer accepts an argument representing
|
||||
pressure at sea level. A separate method is provided to set this now.
|
||||
|
||||
* **bno055** This module no longer uses std::strings to pass around
|
||||
binary data (*read/writeCalibrationData()*). Rather, now *std::vectors* of
|
||||
the appropriate type are used. In addition, methods that previously
|
||||
returned certain data in the form of an array, like *getEulerAngles()*,
|
||||
now return a *std::vector* instead. This simplifies the Python,
|
||||
JavaScript, and Java bindings considerably, and leads to more
|
||||
"natural" looking Python/JavaScript/Java code. For JavaScript, Java,
|
||||
and Python, the examples have been modified to use these methods
|
||||
rather than the methods that return data in argument pointers or
|
||||
arrays.
|
||||
|
||||
* **lpd8806** The constructor for this driver was updated to allow specifying
|
||||
a SPI bus number. This is now the first parameter, the number of LEDs on the
|
||||
strip is now the last (3rd) parameter instead.
|
||||
|
||||
* **max31723** The constructor for this driver was updated to allow specifying
|
||||
a SPI bus number. This is now the first parameter, CS pin second.
|
||||
|
||||
* **tcs3414cs** The constructor for this can now accept an I2C bus and
|
||||
address.
|
||||
|
||||
# v1.1.0 and prior
|
||||
|
||||
* **i2clcd/jhd1313m1/lcm1602** LCD devices supported by the i2clcd module are
|
||||
being separated into individual libraries. The APIs will be preserved, but
|
||||
we recommend changing your code to use the new libraries as they become
|
||||
available. Once this transition is complete, the i2clcd module will be
|
||||
deprecated. So far, the following libraries have been made available
|
||||
separately: jhd1313m1, lcm1602.
|
||||
|
||||
* **nunchuck** This driver no longer supports the init() function.
|
||||
All initialization is now done in the C nunchuck_init() function,
|
||||
or the C++ constructor. In addition, the *NUNCHUCK_I2C_ADDR*
|
||||
define is no longer exposed, as it is not possible to use any other
|
||||
I2C address than *0x52*. The readBytes() and writeByte() functions
|
||||
are also no longer exposed, since aside from what the driver does
|
||||
to initialize and read data, there are no other options available.
|
||||
|
||||
* **enc03r** This driver no longer supports the value() function. In
|
||||
addition, an update() function has been added. This function must be
|
||||
called prior to calling angularVelocity(). angularVelocity() no
|
||||
longer accepts an argument. Additional functions have been added,
|
||||
however they do not affect compatibility with previous versions.
|
||||
|
||||
* **ds18b20** The C++ interface init() function has been deprecated.
|
||||
It is still present, but currently does nothing. It will be removed
|
||||
in a future release.
|
||||
|
||||
* **grove<name>** Starting with UPM 1.0 the Grove libraries have been renamed
|
||||
from *upm-grove<name>* to simply *upm-<name>*. Class names also match this new
|
||||
format, with old classes marked as deprecated throughout the documentation.
|
||||
@ -11,27 +196,35 @@ compatibility between releases:
|
||||
groveelectromagnet, groveemg, grovegprs, grovegsr, grovelinefinder, grovemd,
|
||||
grovemoisture, groveo2, grovescam, grovespeaker, groveultrasonic, grovevdiv,
|
||||
grovewater, grovewfs.
|
||||
|
||||
* **grove** As of UPM 1.0 the Grove classes for sensors in the starter kit are
|
||||
being separated into individual libraries. The old classes will be deprecated
|
||||
over time and eventually removed. Corresponding libraries have the grove
|
||||
prefix removed. Affected classes are GroveButton, GroveLed, GroveLight,
|
||||
GroveRelay, GroveRotary, GroveSlide and GroveTemp.
|
||||
|
||||
* The **ublox6** driver has been replaced with a generic implementation called
|
||||
nmea_gps as of UPM 1.0. This driver should handle all generic serial GPS
|
||||
devices that output NMEA data going forward. This new driver has been tested
|
||||
with ublox6, DFRobot VK2828U7 (ublox7) and ublox LEA-6H GPS devices.
|
||||
|
||||
* **grove** Binary compatibility was broken for the GroveTemp class as of UPM
|
||||
v0.7.3. C++ code using this class has to be recompiled.
|
||||
|
||||
* There were frequent misspellings of the word *Celsius* in the UPM
|
||||
code. In some cases, these were in method names, which will cause
|
||||
some API compatibility issues. These have all been corrected for UPM
|
||||
versions after v.0.7.2.
|
||||
|
||||
* 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,31 @@ Changelog {#changelog}
|
||||
Here's a list summarizing some of the key undergoing changes to our library
|
||||
from earlier versions:
|
||||
|
||||
### v1.2.0
|
||||
|
||||
* Improved JAVA binding compiler compatibility and added JAVA interfaces that
|
||||
match existing C++ interfaces
|
||||
* Ported Bosch drivers to C thus now they can be used on supported MCUs
|
||||
* Completely redesigned C/C++ example handling by cmake to avoid maintaining
|
||||
a list by hand
|
||||
* Fixed several existing drivers, mostly based on static code analysis reports
|
||||
* Added a sensor driver template plus bash script that can be easily used by
|
||||
developers to start writing their own sensor driver
|
||||
* Numerous documentation improvements
|
||||
* New sensors: p9813, abp, rsc, mmc35240, tcs37727, tmp006, mma8x6x, mag3110,
|
||||
hdc1000
|
||||
|
||||
### v1.1.0
|
||||
|
||||
* Reworked cmake handling of internal and external dependencies
|
||||
* Documentation improvements for sensor names, sensor descriptions, external
|
||||
contributor guides and added new section on installing UPM on a supported OS
|
||||
* Fixed issues with C11 builds on some WRLinux gateways and Debian systems
|
||||
* New examples and functionality for speaker and ads1x15 modules
|
||||
* Modified JAVA builds to ensure the SWIG generated wrappers include all
|
||||
functionality and typemaps
|
||||
* New sensors: mcp2515, max30100, uartat, le910
|
||||
|
||||
### v1.0.2
|
||||
|
||||
* Minor cmake changes for Java builds and Java examples are now toggled with
|
||||
|
@ -94,3 +94,55 @@ then you just add a line to each of your commits with `--signoff` saying
|
||||
|
||||
using your real name (sorry, no pseudonyms or anonymous contributions.)
|
||||
Unsigned commits will not be accepted.
|
||||
|
||||
|
||||
Creating a new sensor library using the sensortemplate
|
||||
=======================================
|
||||
|
||||
A stubbed-out sensor library is available which can be leveraged to get
|
||||
up-and-running quickly when writing a new sensor library. Use the shell
|
||||
commands below to generate collateral files for your new sensor library.
|
||||
|
||||
|
||||
```shell
|
||||
#!/bin/bash
|
||||
|
||||
function make_new_sensor {
|
||||
SensorName=$1
|
||||
# Make sure this is run from the root UPM directory
|
||||
if ! grep -q 'UPM ' README.md; then echo "Please run from the root UPM directory"; return -1; fi
|
||||
|
||||
# Copy/paste the below commands into a bash shell...
|
||||
# Get a lowercase version of the string
|
||||
sensorname=${SensorName,,}
|
||||
# Copy sensortemplate files to ${sensorname}
|
||||
find docs/ examples/ src/ -name '*sensortemplate*' -exec bash -c 'cp -r $0 ${0/sensortemplate/${sensorname}}' {} \;
|
||||
# Copy SensorTemplate files to ${SensorName}
|
||||
find examples/ src/ -name '*SensorTemplate*' -exec bash -c 'cp -r $0 ${0/SensorTemplate/${SensorName}}' {} \;
|
||||
# Rename sernsortemplate src files
|
||||
rename "s/sensortemplate/${sensorname}/" src/${sensorname}/*
|
||||
# Search/replace the new files, replacing all instances of sensortemplate
|
||||
perl -p -i -e "s/SensorTemplate/${SensorName}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
|
||||
perl -p -i -e "s/sensortemplate/${sensorname}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
|
||||
# Add mynewmodule example target for java
|
||||
perl -p -i -e "s/^((.*)SensorTemplateSample sensortemplate(.*))/\1\n\2${SensorName}Sample ${sensorname}\3/g" examples/java/CMakeLists.txt
|
||||
# Add mynewmodule example mappings for doxygen
|
||||
perl -p -i -e "s/^(.*SensorTemplateSample.*)$/\1\n${sensorname}.cxx\t${SensorName}Sample.java\t${sensorname}.js\t${sensorname}.py/g" doxy/samples.mapping.txt
|
||||
# Display TODO's
|
||||
printf "Generation complete for sensor library: ${SensorName}\n"
|
||||
printf "TODO's:\n"
|
||||
printf "\t1. Update src/hdr files: src/${sensorname}/${sensorname}.hpp src/${sensorname}/${sensorname}.cxx\n"
|
||||
printf "\t\tChange the Author\n"
|
||||
printf "\t\tChange the Copyright\n"
|
||||
printf "\t\tUpdate all doxygen tags (follow directions for @tags)\n"
|
||||
printf "\t2. Update examples: examples/*/${sensorname}.* examples/java/*${SensorName}*.java\n"
|
||||
printf "\t3. Overwrite docs/images/${sensorname}.png with a valid image of your sensor\n"
|
||||
}
|
||||
|
||||
# Call make_new_sensor with your new sensor name, example: 'MyNewSensor1234'
|
||||
make_new_sensor MyNewSensor1234
|
||||
```
|
||||
|
||||
Once all files have been created, they can be used as a starting-point for your
|
||||
new library. They will need additional customization (your name/email address,
|
||||
documentation, sensor images, etc).
|
||||
|
@ -52,8 +52,9 @@ Here's an example (disregard the "@verbatim" tags in your actual code):
|
||||
- `<chip-id>` Usually the chip number used by the sensor. When this is not
|
||||
available or relevant, use a unique descriptor that makes sense. Must match
|
||||
class name. *Mandatory*
|
||||
- `<component-name>` A short name for your sensor, try to avoid including the
|
||||
manufacturer's name here. *Mandatory*
|
||||
- `<component-name>` Title Case descriptive name for your sensor, try to avoid
|
||||
including the manufacturer's name here. Examples: Digital Pressure Sensor,
|
||||
Serial MP3 Module, etc... *Mandatory*
|
||||
- `<alt-name>` Alternative names that your sensor driver might have. This may
|
||||
include manufacturer's name. *Optional*
|
||||
- `<alt-id>` Alternative chip-ids that your sensor driver supports. *Optional*
|
||||
|
348
docs/guidelines.md
Normal file
348
docs/guidelines.md
Normal file
@ -0,0 +1,348 @@
|
||||
# Code Commenting And Documentation Authoring Guidelines
|
||||
|
||||
#### [Part I. Code Commenting](#code-commenting)
|
||||
|
||||
[Grammar](#grammar)
|
||||
|
||||
- [Active vs passive voice](#voice)
|
||||
|
||||
- [Capitalization](#capitalization)
|
||||
|
||||
- [No possessive case](#possessive-case)
|
||||
|
||||
- [Present tense](#present-tense)
|
||||
|
||||
- [Second person vs the user / reader / programmer / engineer](#second-person)
|
||||
|
||||
- [Third person vs infinitive](#third-person)
|
||||
|
||||
[Punctuation](#punctuation)
|
||||
|
||||
- [Comma in enumerations](#comma)
|
||||
|
||||
- [No period at the end of description](#period)
|
||||
|
||||
[Specific word usage](#word-usage)
|
||||
|
||||
- [Abbreviations and acronyms](#abbr-acr)
|
||||
|
||||
- [Adjectives containing numbers](#adj-num)
|
||||
|
||||
- [App vs application](#app)
|
||||
|
||||
- [Function vs method](#func-meth)
|
||||
|
||||
- [Onboard vs on-board](#onboard)
|
||||
|
||||
- [Sensor name vs sensor model](#name-model)
|
||||
|
||||
- [Setup vs set up](#setup)
|
||||
|
||||
- [Wi-Fi vs WiFi / Wifi / Wi-fi / wifi / wi-fi](#setup)
|
||||
|
||||
[Trademarks](#trademarks)
|
||||
|
||||
- [Intel products](#intel-prod)
|
||||
|
||||
- [Third-party technology](#third-party)
|
||||
|
||||
- [Trademark + noun](#tm-noun)
|
||||
|
||||
#### [Part II. Documentation Authoring](#doc-authoring)
|
||||
|
||||
[Grammar](#da-grammar)
|
||||
|
||||
- [Capitalization](#da-capitalization)
|
||||
|
||||
[Styling](#da-styling)
|
||||
|
||||
- [Bolding](#da-bolding)
|
||||
|
||||
- [Backticks](#da-backticks)
|
||||
|
||||
- [Links](#da-links)
|
||||
|
||||
- [Numbered list vs bullet points](#da-lists)
|
||||
|
||||
[Specific word usage](#da-word-usage)
|
||||
|
||||
- [Login vs log in](#da-login)
|
||||
|
||||
- [Click](#da-click)
|
||||
|
||||
- [SSH](#da-ssh)
|
||||
|
||||
# <a name="code-commenting"></a>Code Commenting Guidelines
|
||||
|
||||
## <a name="grammar"></a>Grammar
|
||||
|
||||
### <a name="voice"></a>Active vs passive voice
|
||||
|
||||
Where possible, prefer active voice over passive.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| It can be put into the configuration mode by grounding the CONFIG pin on the transceiver. | - You can put it into the configuration mode by grounding the CONFIG pin on the transceiver.<br>- To put it into the configuration mode, ground the CONFIG pin on the transceiver.<br>- Put it into the configuration mode by grounding the CONFIG pin on the transceiver. |
|
||||
|
||||
### <a name="capitalization"></a>Capitalization
|
||||
|
||||
- Capitalize the first word in the description of an entity.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| checks to see if there is data available for reading | Checks to see if there is data available for reading |
|
||||
| @param len length of the buffer | @param len Length of the buffer |
|
||||
|
||||
- Be consistent with the capitalization of boolean values.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| Returns True on success, false otherwise | - Returns true on success, false otherwise<br>- Returns True on success, False otherwise |
|
||||
|
||||
### <a name="possessive-case"></a>No possessive case
|
||||
|
||||
Do not use possessive case to avoid unnecessary personalization.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| method's output | - method output<br>- output of the method |
|
||||
|
||||
### <a name="present-tense"></a>Present tense
|
||||
|
||||
Use the present simple tense instead of future, past, or present perfect.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| When specified, this value will be used in computing the voltage. | When specified, this value is used in computing the voltage. |
|
||||
| Once the data has been read… | Once the data is read… |
|
||||
|
||||
### <a name="second-person"></a>Second person vs the user / reader / programmer / engineer
|
||||
|
||||
Use second person when addressing the target reader of your comment.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| The user can easily override this method. | You can easily override this method. |
|
||||
|
||||
### <a name="third-person"></a>Third person vs infinitive
|
||||
|
||||
Use third-person verb forms in short descriptions of classes, methods, functions, etc., not infinitive.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| Get the proximity value from the sensor | Gets the proximity value from the sensor |
|
||||
|
||||
## <a name="punctuation"></a>Punctuation
|
||||
|
||||
### <a name="comma"></a>Comma in enumerations
|
||||
|
||||
Add an extra comma before the last item in a list joined by **and** / **or**.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| Returns raw values for the X, Y and Z axes. | Returns raw values for the X, Y, and Z axes. |
|
||||
|
||||
### <a name="period"></a>No period at the end of description
|
||||
|
||||
Do not put a period if the description of an entity is one sentence long.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| Returns the name of the sensor. | Returns the name of the sensor |
|
||||
| Sets the frequency modulation<br>Valid values are between 10 and 160 (in kHz) | Sets the frequency modulation. Valid values are between 10 and 160 (in kHz). |
|
||||
| @param millis Maximum time in milliseconds to wait for the input<br>-1 means waiting forever (default) | @param millis Maximum time in milliseconds to wait for the input. -1 means waiting forever (default). |
|
||||
|
||||
<font color="purple">**Exception:**</font> if the description contains more than one sentence, put periods after each sentence.
|
||||
|
||||
## <a name="word-usage"></a>Specific word usage
|
||||
|
||||
### <a name="abbr-acr"></a>Abbreviations and acronyms
|
||||
|
||||
- Spell out the first occurrence or the first prominent use of an abbreviation or acronym, followed by a shortened form.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| @brief API for the GP2Y0A family of IR Proximity Sensors | @brief API for the GP2Y0A family of infrared (IR) Proximity Sensors |
|
||||
|
||||
- Do not use Latin abbreviations.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| Works best with halved values; e.g., 1.0, 0.5, 0.25, etc. | Works best with halved values; for example, 1.0, 0.5, 0.25, and so on. |
|
||||
|
||||
- Know exactly what the abbreviation or acronym means to avoid unnecessary duplication.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| - LCD display<br>- ISR routine | - LCD / liquid-crystal display<br>- ISR / interrupt service routine |
|
||||
|
||||
### <a name="adj-num"></a>Adjectives containing numbers
|
||||
|
||||
Adjectives of the form **number + noun / participle** should be hyphenated. It does not matter if a number is represented by one or more digits or spelled out.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| - 4 wire stepper motor<br>- 3 axis gyroscope<br>- zero based indexing<br>- one byte register | - 4-wire stepper motor<br>- 3-axis gyroscope<br>- zero-based indexing<br>- one-byte register |
|
||||
|
||||
### <a name="app"></a>App vs application
|
||||
|
||||
Use **app** when referring to a program running on a device, and **application** when referring to a program running on a desktop / laptop computer.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| The wiki page for this device includes a link to an Android\* application that can be used to read the device via NFC. | The wiki page for this device includes a link to an Android\* app that can be used to read the device via NFC. |
|
||||
|
||||
### <a name="func-meth"></a>Function vs method
|
||||
|
||||
If a function is associated with a class, use **method** instead.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| class WheelEncoder {<br>...<br>/**<br>* Starts the counter. This function also clears<br>* the current count and resets the clock.<br>*/<br>void startCounter(); | class WheelEncoder {<br>...<br>/**<br>* Starts the counter. This method also clears<br>* the current count and resets the clock.<br>*/<br>void startCounter(); |
|
||||
|
||||
### <a name="onboard"></a>Onboard vs on-board
|
||||
|
||||
Use **onboard**.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| This ADC features an on-board reference and oscillator. | This ADC features an onboard reference and oscillator. |
|
||||
|
||||
### <a name="name-model"></a>Sensor name vs sensor model
|
||||
|
||||
Use a sensor name alone or a sensor model followed by a sensor name, not a sensor model alone.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| ADXL345 is compatible with… | - The ADXL345 3-axis digital accelerometer is compatible with…<br>- The accelerometer is compatible with… |
|
||||
|
||||
<font color="purple">**Exception:**</font> you can use a sensor model alone when introducing a
|
||||
sensor for the first time:
|
||||
|
||||
ADXL345 is a 3-axis digital accelerometer…
|
||||
|
||||
### <a name="setup"></a>Setup vs set up
|
||||
|
||||
**Setup** is a noun, **set up** is a verb.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| It does not require any additional set up. | It does not require any additional setup. |
|
||||
| For instructions on how to setup…, refer to... | For instructions on how to set up…, refer to... |
|
||||
|
||||
### <a name="wi-fi"></a>Wi-Fi vs WiFi / Wifi / Wi-fi / wifi / wi-fi
|
||||
|
||||
Use **Wi-Fi**.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| It was tested with the XBee\* S6B WiFi module. | It is tested with the XBee\* S6B Wi-Fi\* module. |
|
||||
|
||||
## <a name="trademarks"></a>Trademarks
|
||||
|
||||
### <a name="intel-prod"></a>Intel products
|
||||
|
||||
Use the correct official names of Intel products. When in doubt, check the TM names database.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| It is a 64x48 pixel OLED display that connects directly to an edison via its 80-pin connector. | It is a 64x48 pixel OLED display that connects directly to an Intel(R) Edison board via its 80-pin connector. |
|
||||
|
||||
**Note:** if an Intel product has a legally approved short name, you may use it in subsequent instances, after spelling it out the first time.
|
||||
|
||||
### <a name="third-party"></a>Third-party technology
|
||||
|
||||
Add an asterisk (\*) after a name to indicate a third-party trademark or registered intellectual property. If you are not sure whether an asterisk is necessary after a particular name, the rule of thumb is to put one, to be on the safe side.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| The Grove MQ2 Gas Sensor module is useful for gas leakage detection. | The Grove\* MQ2 Gas Sensor module is useful for gas leakage detection. |
|
||||
|
||||
### <a name="tm-noun"></a>Trademark + noun
|
||||
|
||||
Always follow trademarks by an appropriate noun. For a list of approved nouns for a particular trademark, check the TM names database.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| It is a 64x48 pixel OLED display that connects directly to an Intel(R) Edison via its 80-pin connector. | It is a 64x48 pixel OLED display that connects directly to an Intel(R) Edison board via its 80-pin connector. |
|
||||
|
||||
# <a name="doc-authoring"></a>Documentation Authoring Guidelines
|
||||
|
||||
## <a name="da-grammar"></a>Grammar
|
||||
|
||||
### <a name="da-capitalization"></a>Capitalization
|
||||
|
||||
For titles, use sentence capitalization.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| Add a New Device | Add a new device |
|
||||
|
||||
## <a name="da-styling"></a>Styling
|
||||
|
||||
### <a name="da-bolding"></a>Bolding
|
||||
|
||||
For GUI elements and file names, use bolding instead of quotes.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| In the “Environment Variables” window, click “OK”. | In the **Environment Variables** window, click **OK**. |
|
||||
| Copy the “example.zip” archive into the installation directory. | Copy the **example.zip** archive into the installation directory. |
|
||||
|
||||
### <a name="da-backticks"></a>Backticks
|
||||
|
||||
Enclose program commands, code blocks, and file paths in backticks (\`).
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| To create a new device, use the **create-thing** command. | To create a new device, use the \`create-thing\` (rendered as `create-thing`) command. |
|
||||
| Go to **C:\Users\me\Documents\GitHub\intel-iot-examples-mqtt\support\aws**. | Go to \`C:\Users\me\Documents\GitHub\intel-iot-examples-mqtt\support\aws\` (rendered as `C:\Users\me\Documents\GitHub\intel-iot-examples-mqtt\support\aws`). |
|
||||
|
||||
### <a name="da-links"></a>Links
|
||||
|
||||
Do not use embedded links to third-party websites.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| Create an account on [Microsoft Azure](https://azure.microsoft.com/en-us), if you do not yet have one. | Create an account on [https://azure.microsoft.com/en-us](https://azure.microsoft.com/en-us), if you do not yet have one. |
|
||||
|
||||
### <a name="da-lists"></a>Numbered list vs bullet points
|
||||
|
||||
- For a logical sequence of steps, use a numbered list.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| When running your C++ code on the Edison, you need to set the MQTT parameters in Eclipse. Go to "Run configurations", and change the "Commands to execute before application" to the following:<br>…<br>Click on the "Apply" button to save these settings.<br>Click on the "Run" button to run the code on the Edison. | When running your C++ code on the Intel® Edison board, you need to set the MQTT\* client parameters in Eclipse\*. To do that:<br>1. Go to **Run configurations** and, in the **Commands to execute before application** field, type the following:<br>…<br>2. Click the **Apply** button to save these settings.<br>3. Click the **Run** button to run the code on your board. |
|
||||
|
||||
- For a list of equally important options, use a bulleted list.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| From this exercise, developers will learn how to:<br>1. Connect the Intel® Edison board...<br>2. Run these code samples in the Intel® System Studio IoT Edition...<br>3. Set up a web application server... | From this exercise, developers will learn how to:<br>- Connect the Intel® Edison board…<br>- Run these code samples in the Intel® System Studio IoT Edition…<br>- Set up a web application server… |
|
||||
|
||||
## <a name="da-word-usage"></a>Specific word usage
|
||||
|
||||
### <a name="da-login"></a>Login vs log in
|
||||
|
||||
**Login** is a noun, **log in** is a verb.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| Provide your log in and password. | Provide your login and password. |
|
||||
| Login to your account. | Log in( )to your account. |
|
||||
|
||||
### <a name="da-click"></a>Click
|
||||
|
||||
Omit **on** after **click**.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| Click on **Advanced system settings**. | Click **Advanced system settings**. |
|
||||
|
||||
### <a name="da-ssh"></a>SSH
|
||||
|
||||
Do not use SSH as a verb. It is considered slang and is to be avoided.
|
||||
|
||||
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
|
||||
| --- | --- |
|
||||
| SSH into your Intel® Edison board. | Establish an SSH connection to your Intel® Edison board. |
|
BIN
docs/images/es9257.jpg
Normal file
BIN
docs/images/es9257.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
docs/images/max30100.png
Normal file
BIN
docs/images/max30100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
BIN
docs/images/p9813.jpg
Normal file
BIN
docs/images/p9813.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
BIN
docs/images/sensortemplate.png
Normal file
BIN
docs/images/sensortemplate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
77
docs/installing.md
Normal file
77
docs/installing.md
Normal file
@ -0,0 +1,77 @@
|
||||
Installing UPM {#installing}
|
||||
============
|
||||
|
||||
UPM packages are provided for some of the major supported distributions, making
|
||||
it very easy to install UPM and its dependencies without having to go through a
|
||||
full build.
|
||||
|
||||
### Poky Linux
|
||||
|
||||
Yocto Project based Poky Linux builds are provided for Intel Galileo, Intel
|
||||
Edison and Minnowboard. These are the official images released with the Intel
|
||||
IoT Developer Kit and can found [here](https://iotdk.intel.com/images/3.5/).
|
||||
|
||||
To update to the latest stable UPM version:
|
||||
|
||||
```bash
|
||||
echo "src intel-iotdk https://iotdk.intel.com/repos/3.5/intelgalactic/opkg/i586/" > /etc/opkg/intel-iotdk.conf
|
||||
opkg update
|
||||
opkg upgrade mraa upm
|
||||
```
|
||||
|
||||
If you would like to try the development version use `intelgalactic-dev`
|
||||
instead.
|
||||
|
||||
### WindRiver Pulsar Linux
|
||||
|
||||
WR Pulsar uses SmartPM for software updates. Updating to the latest UPM version
|
||||
requires:
|
||||
|
||||
```bash
|
||||
smart channel -y --add upm_mraa_channel type=rpm-md name="MRAA/UPM" baseurl=http://iotdk.intel.com/repos/pulsar/8/x64
|
||||
smart update
|
||||
smart install -y mraa upm
|
||||
```
|
||||
|
||||
For Pulsar 7 use the following baseurl instead: `baseurl=http://iotdk.intel.com/repos/pulsar/7/x64`
|
||||
|
||||
Wind River Linux 7 uses 01.org repositories and will have a default update
|
||||
channel that includes MRAA & UPM. Thus you only have to update and install.
|
||||
|
||||
### Ubuntu Desktop/Server
|
||||
|
||||
MRAA and UPM are available through a Personal Package Archive (PPA) on Ubuntu
|
||||
that can be found [here](https://launchpad.net/~mraa/+archive/ubuntu/mraa).
|
||||
|
||||
To install:
|
||||
|
||||
```bash
|
||||
sudo add-apt-repository ppa:mraa/mraa
|
||||
sudo apt-get update
|
||||
sudo apt-get install libupm-dev python-upm python3-upm upm-examples
|
||||
```
|
||||
|
||||
Note that the Ubuntu PPA only provides the C/C++ and Python packages. Node.js
|
||||
developers will have to install MRAA and UPM using NPM instead.
|
||||
|
||||
### Node.js bindings only (NPM)
|
||||
|
||||
This option allows compiling MRAA/UPM on any system with npm and node-gyp.
|
||||
|
||||
The UPM modules have a hard dependency on MRAA, thus you will have to install
|
||||
it first. Also, make sure Node can find MRAA by updating the `NODE_PATH`
|
||||
variable if necessary. A global installation is preferred:
|
||||
|
||||
`npm install mraa -g`
|
||||
|
||||
After this, to install a UPM module using npm simply type:
|
||||
|
||||
`npm install jsupm_<module-name> -g`
|
||||
|
||||
In order to initialize the platform, require MRAA *before* you load a UPM
|
||||
module in your code:
|
||||
|
||||
```js
|
||||
require('mraa');
|
||||
var lib = require('jsupm_<module-name>');
|
||||
```
|
@ -156,7 +156,7 @@ FULL_PATH_NAMES = YES
|
||||
# will be relative from the directory where doxygen is started.
|
||||
# This tag requires that the tag FULL_PATH_NAMES is set to YES.
|
||||
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
|
||||
|
||||
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
|
||||
# path mentioned in the documentation of a class, which tells the reader which
|
||||
|
@ -5,15 +5,16 @@ adc121c021.cxx ADC121C021Sample.java adc121c021.js adc121c021.py
|
||||
adxl345.cxx Adxl345Sample.java adxl345.js adxl345.py
|
||||
biss0001.cxx BISS0001Sample.java biss0001.js biss0001.py
|
||||
bmpx8x.cxx BMPX8XSample.java bmpx8x.js bmpx8x.py
|
||||
bno055.cxx BNO055_Example.java bno055.js bno055.py
|
||||
button.cxx ButtonSample.java button.js button.py
|
||||
buzzer.cxx BuzzerSample.java buzzer.js buzzer.py
|
||||
cjq4435.cxx CJQ4435Sample.java cjq4435.js cjq4435.py
|
||||
ds1307.cxx DS1307Sample.java ds1307.js ds1307.py
|
||||
enc03r.cxx ENC03RSample.java enc03r.js enc03r.py
|
||||
es08a.cxx ES08ASample.java es08a.js es08a.py
|
||||
servo-es08a.cxx ES08ASample.java es08a.js es08a.py
|
||||
groveehr.cxx GroveEHRSample.java groveehr.js groveehr.py
|
||||
groveledbar.cxx GroveLEDBar.java groveledbar.js groveledbar.py
|
||||
groveled.cxx GroveLEDSample.java groveled.js groveled.py
|
||||
my9221-groveledbar.cxx GroveLEDBar.java groveledbar.js groveledbar.py
|
||||
grove-groveled.cxx GroveLEDSample.java groveled.js groveled.py
|
||||
grovelinefinder.cxx GroveLineFinderSample.java grovelinefinder.js grovelinefinder.py
|
||||
grovemoisture.cxx GroveMoistureSample.java grovemoisture.js grovemoisture.py
|
||||
grovescam.cxx GROVESCAMSample.java grovescam.js grovescam.py
|
||||
@ -41,9 +42,9 @@ mma7660.cxx MMA7660Sample.java mma7660.js mma7660.py
|
||||
mpl3115a2.cxx MPL3115A2Sample.java mpl3115a2.js mpl3115a2.py
|
||||
mpr121.cxx MPR121Sample.java mpr121.js mpr121.py
|
||||
mpu9150.cxx MPU9150Sample.java mpu9150.js mpu9150.py
|
||||
mq2.cxx MQ2Sample.java mq2.js mq2.py
|
||||
gas-mq2.cxx MQ2Sample.java mq2.js mq2.py
|
||||
mq303a.cxx MQ303ASample.java mq303a.js mq303a.py
|
||||
mq5.cxx MQ5Sample.java mq5.js mq5.py
|
||||
gas-mq5.cxx MQ5Sample.java mq5.js mq5.py
|
||||
nrf24l01-receiver.cxx NRF24L01_receiverSample.java nrf24l01-receiver.js nrf24l01-receiver.py
|
||||
nrf24l01-transmitter.cxx NRF24L01_transmitterSample.java nrf24l01-transmitter.js nrf24l01-transmitter.py
|
||||
nunchuck.cxx NUNCHUCKSample.java nunchuck.js nunchuck.py
|
||||
@ -58,12 +59,12 @@ rpr220.cxx RPR220Sample.java rpr220.js rpr220.py
|
||||
rpr220-intr.cxx RPR220_intrSample.java rpr220-intr.js rpr220-intr.py
|
||||
slide.cxx SlideSample.java slide.js slide.py
|
||||
speaker.cxx SpeakerSample.java speaker.js speaker.py
|
||||
ssd1308-oled.cxx SSD1308_oledSample.java ssd1308-oled.js ssd1308-oled.py
|
||||
ssd1327-oled.cxx SSD1327_oledSample.java ssd1327-oled.js ssd1327-oled.py
|
||||
i2clcd-ssd1308-oled.cxx SSD1308_oledSample.java ssd1308-oled.js ssd1308-oled.py
|
||||
i2clcd-ssd1327-oled.cxx SSD1327_oledSample.java ssd1327-oled.js ssd1327-oled.py
|
||||
st7735.cxx ST7735Sample.java st7735.js st7735.py
|
||||
stepmotor.cxx StepMotorSample.java stepmotor.js stepmotor.py
|
||||
tm1637.cxx TM1637Sample.java tm1637.js tm1637.py
|
||||
tp401.cxx TP401Sample.java tp401.js tp401.py
|
||||
gas-tp401.cxx TP401Sample.java tp401.js tp401.py
|
||||
tsl2561.cxx TSL2561Sample.java tsl2561.js tsl2561.py
|
||||
ttp223.cxx TTP223Sample.java ttp223.js ttp223.py
|
||||
uln200xa.cxx ULN200XASample.java uln200xa.js uln200xa.py
|
||||
@ -71,3 +72,10 @@ vdiv.cxx VDivSample.java vdiv.js vdiv.py
|
||||
water.cxx WaterSample.java water.js water.py
|
||||
wt5001.cxx WT5001Sample.java wt5001.js wt5001.py
|
||||
yg1006.cxx YG1006Sample.java yg1006.js yg1006.py
|
||||
sensortemplate.cxx SensorTemplateSample.java sensortemplate.js sensortemplate.py
|
||||
p9813.cxx P9813Sample.java p9813.js p9813.py
|
||||
tcs37727.cxx tcs37727.py
|
||||
tmp006.cxx tmp006.py
|
||||
mma8x5x.cxx mma8x5x.py
|
||||
mag3110.cxx mag3110.py
|
||||
hdc1000.cxx hdc1000.py
|
||||
|
119
examples/CMakeLists.txt
Normal file
119
examples/CMakeLists.txt
Normal file
@ -0,0 +1,119 @@
|
||||
# Add an example executable target for the provided source file which depends
|
||||
# on a UPM library target. Strings after the first '-' are ignored.
|
||||
#
|
||||
# Usage:
|
||||
# add_example(source_file TARGETS <target0> <target1> <targetn> SUFFIX <target_suffix>)
|
||||
#
|
||||
# Parameters:
|
||||
# source_file - C/C++ source file. Filename must follow a specific format:
|
||||
# <library>-[additional].c(xx)
|
||||
# library: Name of UPM library required by example
|
||||
# -additional: Any other string used to identify the example
|
||||
# TARGETS - Additional dependency target/s required to BUILD/RUN this example. If TARGETS is
|
||||
# set, these are in addition to the dependency library provided by the example filename.
|
||||
# SUFFIX - Provide a means to differentiate between C/C++ dependency targets and
|
||||
# example names. Leave empty for CXX examples. Use '-c' for c targets.
|
||||
# SUFFIX Example file Dependency target Example binary
|
||||
# ------ ------------ ----------------- --------------
|
||||
# "-c" foo.c foo-c foo-example-c
|
||||
# foo.cxx foo foo-example-cxx
|
||||
#
|
||||
# Parent scope variable:
|
||||
# example_src_list - Any example target which is successfully created by
|
||||
# add_example will be removed from the parent scope variable
|
||||
# example_src_list (if it exists). This provides a means to handle
|
||||
# special case examples BEFORE handling all files in example_src_list.
|
||||
#
|
||||
# Examples:
|
||||
# # Creates sensorfoo-example-cxx, depends on target: sensorfoo
|
||||
# add_example(sensorfoo.cxx)
|
||||
#
|
||||
# # Creates sensorfoo-example-c, depends on target: sensorfoo-c
|
||||
# add_example(sensorfoo.c SUFFIX "-c")
|
||||
#
|
||||
# # Creates sensorfoo-bar-example-c, depends on target: sensorfoo-c
|
||||
# add_example(sensorfoo-bar.c SUFFIX "-c")
|
||||
#
|
||||
# # Creates testfoobar-cxx, depends on targets: blib, blah
|
||||
# add_example(testfoobar.c TARGETS blib blah)
|
||||
#
|
||||
# Examples:
|
||||
# a110x.c Requires libupmc-a110x
|
||||
# lcm1602-i2c.c Requires libupmc-lcm1602
|
||||
# bmp280-bme280.c Requires libupmc-bmp280
|
||||
# i2clcd-eboled.cxx Requires libupm-i2clcd
|
||||
#
|
||||
#
|
||||
function (add_example example_src)
|
||||
set (oneValueArgs SUFFIX)
|
||||
set (multiValueArgs TARGETS)
|
||||
# Parse function parameters
|
||||
cmake_parse_arguments(add_example "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
# Get the base filename from the full filename
|
||||
# For file /some/path/to/sensorfoo-bar.c, example_name = sensorfoo-bar
|
||||
get_filename_component(example_name ${example_src} NAME_WE)
|
||||
|
||||
# Parse out <library>
|
||||
# Example: sensorfoo-bar.c, library = sensorfoo
|
||||
string (REPLACE "-" ";" split_name ${example_name})
|
||||
list (GET split_name 0 library_name)
|
||||
|
||||
# Parse dependency target name from example_src filename (add on suffix)
|
||||
# For sensorfoo, lib_target_names = sensorfoo-c
|
||||
set (lib_target_names "${library_name}${add_example_SUFFIX}")
|
||||
|
||||
# If TARGETS is provided, add additional dependency targets
|
||||
if (add_example_TARGETS)
|
||||
list (APPEND lib_target_names "${add_example_TARGETS}")
|
||||
endif ()
|
||||
|
||||
# Unfortunately, c++ and c library targets are not named the same. If
|
||||
# no suffix is provided, assume C++ and add a suffix of -cxx to the
|
||||
# example target name
|
||||
# library example target
|
||||
# c: sensorfoo-c sensorfoo-bar-example-c
|
||||
# cxx: sensorfoo sensorfoo-bar-example-cxx
|
||||
if (NOT add_example_SUFFIX)
|
||||
set(add_example_SUFFIX "-cxx")
|
||||
endif ()
|
||||
|
||||
# Create the target name for this example: mylibrary-bar-example-c
|
||||
set (this_target_name "${example_name}-example${add_example_SUFFIX}")
|
||||
|
||||
# If a dependency target does NOT exist, print a warning and skip
|
||||
foreach(_dep_target ${lib_target_names})
|
||||
if (NOT TARGET ${_dep_target})
|
||||
message(STATUS "Missing CMake target (${_dep_target}), skipping example ${example_src}")
|
||||
return()
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Create an executable target for this example
|
||||
add_executable (${this_target_name} ${example_src})
|
||||
|
||||
# Add each dependency to the library target
|
||||
foreach(_dep_target ${lib_target_names})
|
||||
target_link_libraries(${this_target_name} ${_dep_target} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endforeach ()
|
||||
|
||||
# Special case...
|
||||
list (REMOVE_ITEM example_src_list ${example_src})
|
||||
set (example_src_list ${example_src_list} PARENT_SCOPE)
|
||||
endfunction (add_example example_src)
|
||||
|
||||
# Add subdirectories if BUILDEXAMPLES=on
|
||||
if(BUILDEXAMPLES)
|
||||
# Add C examples
|
||||
add_subdirectory (c)
|
||||
|
||||
# Add C++ examples?
|
||||
if (BUILDCPP)
|
||||
add_subdirectory (c++)
|
||||
endif ()
|
||||
|
||||
# Add java examples?
|
||||
if(BUILDSWIGJAVA)
|
||||
add_subdirectory (java)
|
||||
endif()
|
||||
endif()
|
@ -1,371 +1,20 @@
|
||||
# Selectively disable certain warnings for the examples
|
||||
# nrf examples flag -Wtautological-compare
|
||||
set (CXX_DISABLED_WARNINGS -Wno-tautological-compare)
|
||||
# Create an list of all C++ source files in this directory
|
||||
file (GLOB example_src_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cxx")
|
||||
|
||||
# Extract module name from non-standard example name
|
||||
macro(get_module_name example_name module_name)
|
||||
string(LENGTH ${example_name} length)
|
||||
string(FIND ${example_name} "-" index)
|
||||
if (${index} GREATER 1)
|
||||
string(SUBSTRING ${example_name} 0 ${index} substr)
|
||||
set(${module_name} ${substr})
|
||||
elseif (${example_name} MATCHES "^grove")
|
||||
set (${module_name} "grove")
|
||||
elseif ((${example_name} MATCHES "^mq" AND ${length} EQUAL 3) OR ${example_name} STREQUAL "tp401")
|
||||
set (${module_name} "gas")
|
||||
else()
|
||||
set(${module_name} ${example_name})
|
||||
endif()
|
||||
endmacro()
|
||||
# - Handle special cases here --------------------------------------------------
|
||||
|
||||
# Set source file, include and linker settings for an example
|
||||
# If example cannot be built, example_bin is cleared
|
||||
macro(add_custom_example example_bin example_src example_module_list)
|
||||
set(found_all_modules TRUE)
|
||||
foreach (module ${example_module_list})
|
||||
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/${module}")
|
||||
set(found_all_modules FALSE)
|
||||
endif()
|
||||
if (MODULE_LIST)
|
||||
list(FIND MODULE_LIST ${module} index)
|
||||
if (${index} EQUAL -1)
|
||||
set(found_all_modules FALSE)
|
||||
endif()
|
||||
endif()
|
||||
# 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)
|
||||
|
||||
# - Create an executable for all other src files in this directory -------------
|
||||
foreach (_example_src ${example_src_list})
|
||||
add_example(${_example_src})
|
||||
endforeach ()
|
||||
if (found_all_modules)
|
||||
add_executable (${example_bin} ${example_src})
|
||||
target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
# Disable warnings from CXX_DISABLED_WARNINGS
|
||||
foreach(flag ${CXX_DISABLED_WARNINGS})
|
||||
compiler_flag_supported(CXX is_supported ${flag})
|
||||
if (is_supported)
|
||||
target_compile_options(${example_bin} PRIVATE "${flag}")
|
||||
endif(is_supported)
|
||||
endforeach(flag ${CXX_DISABLED_WARNINGS})
|
||||
|
||||
foreach (module ${example_module_list})
|
||||
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module}")
|
||||
include_directories (${module_dir})
|
||||
if (${module} STREQUAL "lcd")
|
||||
set(module "i2clcd")
|
||||
endif()
|
||||
target_link_libraries (${example_bin} ${module})
|
||||
endforeach()
|
||||
else()
|
||||
message (WARNING "Ignored ${example_bin}")
|
||||
set (example_bin "")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
# Add specified example by name
|
||||
# Note special case for grove based examples
|
||||
macro(add_example example_name)
|
||||
set(example_src "${example_name}.cxx")
|
||||
set(example_bin "${example_name}-example-cxx")
|
||||
get_module_name(${example_name} module_name)
|
||||
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}")
|
||||
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_src}"
|
||||
AND EXISTS ${module_dir}
|
||||
AND IS_DIRECTORY ${module_dir})
|
||||
add_custom_example(${example_bin} ${example_src} ${module_name})
|
||||
if ((NOT ${example_bin} STREQUAL "") AND (${module_name} STREQUAL "grove"))
|
||||
set(grove_module_path "${PROJECT_SOURCE_DIR}/src/${example_name}")
|
||||
if (EXISTS ${grove_module_path})
|
||||
include_directories(${grove_module_path})
|
||||
target_link_libraries (${example_bin} ${example_name})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message (WARNING "Ignored ${example_bin}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
|
||||
|
||||
# UPM c include directories
|
||||
include_directories (${PROJECT_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/src/utilities)
|
||||
|
||||
# Set the mraa include and link directories prior to adding examples
|
||||
include_directories (${MRAA_INCLUDE_DIRS})
|
||||
link_directories (${MRAA_LIBDIR})
|
||||
|
||||
# If your sample source file matches the name of the module it tests, add it here
|
||||
# Exceptions are as follows:
|
||||
# string after first '-' is ignored (e.g. nrf24l01-transmitter maps to nrf24l01)
|
||||
# mq? will use module gas
|
||||
# grove* will use module grove
|
||||
add_example (hmc5883l)
|
||||
add_example (led)
|
||||
add_example (groveled)
|
||||
add_example (relay)
|
||||
add_example (groverelay)
|
||||
add_example (light)
|
||||
add_example (grovelight)
|
||||
add_example (temperature)
|
||||
add_example (grovetemp)
|
||||
add_example (button)
|
||||
add_example (grovebutton)
|
||||
add_example (rotary)
|
||||
add_example (groverotary)
|
||||
add_example (slide)
|
||||
add_example (groveslide)
|
||||
add_example (buzzer)
|
||||
add_example (nrf24l01-transmitter)
|
||||
add_example (nrf24l01-receiver)
|
||||
add_example (nrf24l01-broadcast)
|
||||
add_example (hcsr04)
|
||||
add_example (max44000)
|
||||
add_example (mma7455)
|
||||
add_example (st7735)
|
||||
add_example (max31855)
|
||||
add_example (bmpx8x)
|
||||
add_example (stepmotor)
|
||||
add_example (pulsensor)
|
||||
add_example (mic)
|
||||
add_example (mpu9150)
|
||||
add_example (maxds3231m)
|
||||
add_example (max31723)
|
||||
add_example (max5487)
|
||||
add_example (nrf8001-broadcast)
|
||||
add_example (nrf8001-helloworld)
|
||||
add_example (lpd8806)
|
||||
add_example (mlx90614)
|
||||
add_example (ecs1030)
|
||||
add_example (mq2)
|
||||
add_example (mq3)
|
||||
add_example (mq4)
|
||||
add_example (mq5)
|
||||
add_example (mq6)
|
||||
add_example (mq7)
|
||||
add_example (mq8)
|
||||
add_example (mq9)
|
||||
add_example (tp401)
|
||||
add_example (tcs3414cs)
|
||||
add_example (th02)
|
||||
add_example (ttp223)
|
||||
add_example (lsm303)
|
||||
add_example (joystick12)
|
||||
add_example (lol)
|
||||
add_example (tsl2561)
|
||||
add_example (htu21d)
|
||||
add_example (mpl3115a2)
|
||||
add_example (ldt0028)
|
||||
add_example (am2315)
|
||||
add_example (itg3200)
|
||||
add_example (enc03r)
|
||||
add_example (adc121c021)
|
||||
add_example (ds1307)
|
||||
add_example (a110x)
|
||||
add_example (gp2y0a)
|
||||
add_example (moisture)
|
||||
add_example (grovemoisture)
|
||||
add_example (ehr)
|
||||
add_example (groveehr)
|
||||
add_example (ta12200)
|
||||
add_example (grovelinefinder)
|
||||
add_example (linefinder)
|
||||
add_example (vdiv)
|
||||
add_example (grovevdiv)
|
||||
add_example (water)
|
||||
add_example (grovewater)
|
||||
add_example (guvas12d)
|
||||
add_example (mpr121)
|
||||
add_example (yg1006)
|
||||
add_example (wt5001)
|
||||
add_example (ppd42ns)
|
||||
add_example (mq303a)
|
||||
add_example (speaker)
|
||||
add_example (grovespeaker)
|
||||
add_example (rfr359f)
|
||||
add_example (biss0001)
|
||||
add_example (rotaryencoder)
|
||||
add_example (adxl345)
|
||||
add_example (rpr220)
|
||||
add_example (rpr220-intr)
|
||||
add_example (mma7660)
|
||||
add_example (cjq4435)
|
||||
add_example (adxl335)
|
||||
add_example (hmtrp)
|
||||
add_example (nunchuck)
|
||||
add_example (otp538u)
|
||||
add_example (collision)
|
||||
add_example (grovecollision)
|
||||
add_example (electromagnet)
|
||||
add_example (groveelectromagnet)
|
||||
add_example (emg)
|
||||
add_example (groveemg)
|
||||
add_example (o2)
|
||||
add_example (groveo2)
|
||||
add_example (gsr)
|
||||
add_example (grovegsr)
|
||||
add_example (ina132)
|
||||
add_example (l298)
|
||||
add_example (l298-stepper)
|
||||
add_example (at42qt1070)
|
||||
add_example (grovemd)
|
||||
add_example (md)
|
||||
add_example (grovemd-stepper)
|
||||
add_example (md-stepper)
|
||||
add_example (pca9685)
|
||||
add_example (eldriver)
|
||||
add_example (groveeldriver)
|
||||
add_example (adafruitss)
|
||||
add_example (adafruitms1438)
|
||||
add_example (adafruitms1438-stepper)
|
||||
add_example (hx711)
|
||||
add_example (flex)
|
||||
add_example (a110x-intr)
|
||||
add_example (mhz16)
|
||||
add_example (apds9002)
|
||||
add_example (waterlevel)
|
||||
add_example (tm1637)
|
||||
add_example (zfm20)
|
||||
add_example (zfm20-register)
|
||||
add_example (uln200xa)
|
||||
add_example (grovewfs)
|
||||
add_example (wfs)
|
||||
add_example (isd1820)
|
||||
add_example (sx6119)
|
||||
add_example (si114x)
|
||||
add_example (maxsonarez)
|
||||
add_example (hm11)
|
||||
add_example (ht9170)
|
||||
add_example (h3lis331dl)
|
||||
add_example (ad8232)
|
||||
add_example (grovescam)
|
||||
add_example (scam)
|
||||
add_example (m24lr64e)
|
||||
add_example (rgbringcoder)
|
||||
add_example (hp20x)
|
||||
add_example (pn532)
|
||||
add_example (pn532-writeurl)
|
||||
add_example (lsm9ds0)
|
||||
add_example (loudness)
|
||||
add_example (mg811)
|
||||
add_example (wheelencoder)
|
||||
add_example (sm130)
|
||||
add_example (gprs)
|
||||
add_example (grovegprs)
|
||||
add_example (lm35)
|
||||
add_example (micsv89)
|
||||
add_example (xbee)
|
||||
add_example (urm37)
|
||||
add_example (urm37-uart)
|
||||
add_example (adxrs610)
|
||||
add_example (bma220)
|
||||
add_example (dfrph)
|
||||
add_example (mcp9808)
|
||||
add_example (groveultrasonic)
|
||||
add_example (ultrasonic)
|
||||
add_example (sx1276-lora)
|
||||
add_example (sx1276-fsk)
|
||||
add_example (ili9341)
|
||||
add_example (nlgpio16)
|
||||
add_example (ads1x15)
|
||||
if (MODBUS_FOUND)
|
||||
include_directories(${MODBUS_INCLUDE_DIRS})
|
||||
add_example (t3311)
|
||||
add_example (hwxpxx)
|
||||
add_example (h803x)
|
||||
endif()
|
||||
add_example (hdxxvxta)
|
||||
add_example (rhusb)
|
||||
add_example (apds9930)
|
||||
add_example (kxcjk1013)
|
||||
add_example (ssd1351)
|
||||
add_example (ds1808lc)
|
||||
add_example (hlg150h)
|
||||
add_example (lp8860)
|
||||
add_example (max44009)
|
||||
add_example (si1132)
|
||||
add_example (si7005)
|
||||
add_example (t6713)
|
||||
add_example (cwlsxxa)
|
||||
add_example (teams)
|
||||
add_example (apa102)
|
||||
add_example (tex00)
|
||||
add_example (bmi160)
|
||||
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)
|
||||
add_example (t8100)
|
||||
add_example (tb7300)
|
||||
endif()
|
||||
if (JPEG_FOUND)
|
||||
add_example (vcap)
|
||||
endif (JPEG_FOUND)
|
||||
add_example (ds2413)
|
||||
add_example (ds18b20)
|
||||
add_example (bmp280)
|
||||
add_example (bno055)
|
||||
add_example (l3gd20)
|
||||
add_example (l3gd20-i2c)
|
||||
add_example (bmx055)
|
||||
add_example (ms5611)
|
||||
add_example (nmea_gps)
|
||||
add_example (mma7361)
|
||||
add_example (bh1750)
|
||||
add_example (hka5)
|
||||
add_example (dfrorp)
|
||||
add_example (dfrec)
|
||||
add_example (sht1x)
|
||||
add_example (ms5803)
|
||||
add_example (ims)
|
||||
add_example (ecezo)
|
||||
add_example (mb704x)
|
||||
add_example (rf22-server)
|
||||
add_example (rf22-client)
|
||||
|
||||
# These are special cases where you specify example binary, source file and module(s)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src)
|
||||
add_custom_example (groveled-multi-example-cxx groveled-multi.cxx grove)
|
||||
add_custom_example (lcm1602-i2c-example-cxx lcm1602-i2c.cxx lcd)
|
||||
add_custom_example (lcm1602-parallel-example-cxx lcm1602-parallel.cxx lcd)
|
||||
add_custom_example (jhd1313m1-lcd-example-cxx jhd1313m1-lcd.cxx lcd)
|
||||
add_custom_example (es08a-example-cxx es08a.cxx servo)
|
||||
add_custom_example (ssd1306-oled-example-cxx ssd1306-oled.cxx lcd)
|
||||
add_custom_example (ssd1308-oled-example-cxx ssd1308-oled.cxx lcd)
|
||||
add_custom_example (ssd1327-oled-example-cxx ssd1327-oled.cxx lcd)
|
||||
add_custom_example (sainsmartks-example-cxx sainsmartks.cxx lcd)
|
||||
add_custom_example (eboled-example-cxx eboled.cxx lcd)
|
||||
add_custom_example (mpu60x0-example-cxx mpu60x0.cxx mpu9150)
|
||||
add_custom_example (ak8975-example-cxx ak8975.cxx mpu9150)
|
||||
add_custom_example (mpu9250-example-cxx mpu9250.cxx mpu9150)
|
||||
add_custom_example (groveledbar-example-cxx groveledbar.cxx my9221)
|
||||
add_custom_example (grovecircularled-example-cxx grovecircularled.cxx my9221)
|
||||
add_custom_example (temperature-sensor-example-cxx temperature-sensor.cxx "si7005;bmpx8x;bmp280")
|
||||
add_custom_example (humidity-sensor-example-cxx humidity-sensor.cxx "si7005;bmp280")
|
||||
add_custom_example (pressure-sensor-example-cxx pressure-sensor.cxx "bmpx8x;bmp280")
|
||||
add_custom_example (co2-sensor-example-cxx co2-sensor.cxx "t6713")
|
||||
add_custom_example (adc-example-cxx adc-sensor.cxx "ads1x15")
|
||||
add_custom_example (light-sensor-example-cxx light-sensor.cxx "si1132;max44009")
|
||||
add_custom_example (light-controller-example-cxx light-controller.cxx "lp8860;ds1808lc;hlg150h")
|
||||
add_custom_example (bme280-example-cxx bme280.cxx bmp280)
|
||||
add_custom_example (bma250e-example-cxx bma250e.cxx bmx055)
|
||||
add_custom_example (bmg160-example-cxx bmg160.cxx bmx055)
|
||||
add_custom_example (bmm150-example-cxx bmm150.cxx bmx055)
|
||||
add_custom_example (bmc150-example-cxx bmc150.cxx bmx055)
|
||||
add_custom_example (bmi055-example-cxx bmi055.cxx bmx055)
|
||||
if (OPENZWAVE_FOUND)
|
||||
include_directories(${OPENZWAVE_INCLUDE_DIRS})
|
||||
|
||||
add_custom_example (ozwdump-example-cxx ozwdump.cxx ozw)
|
||||
add_custom_example (aeotecss6-example-cxx aeotecss6.cxx ozw)
|
||||
add_custom_example (aeotecsdg2-example-cxx aeotecsdg2.cxx ozw)
|
||||
add_custom_example (aeotecdw2e-example-cxx aeotecdw2e.cxx ozw)
|
||||
add_custom_example (aeotecdsb09104-example-cxx aeotecdsb09104.cxx ozw)
|
||||
add_custom_example (tzemt400-example-cxx tzemt400.cxx ozw)
|
||||
endif()
|
||||
add_custom_example (nmea_gps_i2c_example-cxx nmea_gps_i2c.cxx nmea_gps)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -23,10 +23,9 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "sainsmartks.hpp"
|
||||
#include <signal.h>
|
||||
#include "abp.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -39,28 +38,24 @@ void sig_handler(int signo)
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main ()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// use default pins
|
||||
upm::SAINSMARTKS* lcd = new upm::SAINSMARTKS();
|
||||
lcd->setCursor(0,0);
|
||||
lcd->write("Sainsmart KS");
|
||||
lcd->setCursor(1,2);
|
||||
lcd->write("Hello World");
|
||||
// Instantiate an ABP sensor on i2c bus 0
|
||||
upm::ABP* abp = new upm::ABP(0, ABP_DEFAULT_ADDRESS);
|
||||
while (shouldRun) {
|
||||
abp->update();
|
||||
cout << "Retrieved pressure: " << abp->getPressure() << endl;
|
||||
cout << "Retrieved Temperature: " << abp->getTemperature() << endl;
|
||||
|
||||
// output current key value every second.
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << "Button value: " << lcd->getRawKeyValue() << endl;
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
delete lcd;
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete abp;
|
||||
return 0;
|
||||
}
|
@ -40,7 +40,7 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "adis16448.h"
|
||||
#include "adis16448.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
104
examples/c++/ads1x15-ads1015.cxx
Normal file
104
examples/c++/ads1x15-ads1015.cxx
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.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.
|
||||
*/
|
||||
|
||||
/* This example demonstrates how to use one the ADS1015 ADC on the Grove Joule
|
||||
* Shield or the Sparkfun ADC Block for Edison with devices that output a small
|
||||
* differential voltage (e.g. geophones, piezoelectric bands or pads,
|
||||
* thermocouples).
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ads1015.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
bool running = true; // Controls main read/write loop
|
||||
|
||||
// Thread function
|
||||
void stop()
|
||||
{
|
||||
sleep(10);
|
||||
running = false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
//! [Interesting]
|
||||
long id = 0; // Sample number
|
||||
string fileName = "./ads1015.data"; // Output filename
|
||||
ofstream f;
|
||||
|
||||
// Initialize and configure the ADS1015
|
||||
ADS1015 *ads1015 = new upm::ADS1015(0, 0x48);
|
||||
|
||||
// Put the ADC into differential mode for pins A0 and A1
|
||||
ads1015->getSample(ADS1X15::DIFF_0_1);
|
||||
|
||||
// Set the gain based on expected VIN range to -/+ 2.048 V
|
||||
// Can be adjusted based on application to as low as -/+ 0.256 V, see API
|
||||
// documentation for details
|
||||
ads1015->setGain(ADS1X15::GAIN_TWO);
|
||||
|
||||
// Set the sample rate to 3300 samples per second (max) and turn on continuous
|
||||
// sampling
|
||||
ads1015->setSPS(ADS1015::SPS_3300);
|
||||
ads1015->setContinuous(true);
|
||||
|
||||
// Enable exceptions from the output stream
|
||||
f.exceptions(ofstream::failbit | ofstream::badbit);
|
||||
// Open the file
|
||||
try{
|
||||
f.open(fileName);
|
||||
|
||||
// Output formatting
|
||||
f.setf(ios_base::fixed);
|
||||
f.precision(7);
|
||||
|
||||
// Start the thread that will stop logging after 10 seconds
|
||||
thread timer (stop);
|
||||
|
||||
// Read sensor data and write it to the output file every ms
|
||||
while(running){
|
||||
f << id++ << " " << ads1015->getLastSample() << endl;
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
// Clean-up and exit
|
||||
timer.join();
|
||||
f.close();
|
||||
delete ads1015;
|
||||
} catch (ios_base::failure &e) {
|
||||
cout << "Failed to write to file: " << e.what() << endl;
|
||||
return 1;
|
||||
}
|
||||
cout << "Wrote " << id << " samples to file: " << fileName << endl;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
107
examples/c++/ads1x15-ads1115.cxx
Normal file
107
examples/c++/ads1x15-ads1115.cxx
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.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.
|
||||
*/
|
||||
|
||||
/* This example demonstrates how to use one of the ADS1115 ADCs on the
|
||||
* DFRobot Joule Shield with devices that output a small differential
|
||||
* voltage (e.g. geophones, piezoelectric bands or pads, thermocouples).
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ads1115.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
bool running = true; // Controls main read/write loop
|
||||
|
||||
// Thread function
|
||||
void stop()
|
||||
{
|
||||
sleep(10);
|
||||
running = false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
//! [Interesting]
|
||||
long id = 0; // Sample number
|
||||
string fileName = "./ads1115.data"; // Output filename
|
||||
ofstream f;
|
||||
|
||||
// Initialize and configure the ADS1115 for the SM-24 Geophone
|
||||
// There are two ADS1115 chips on the DFRobot Joule Shield on the same I2C bus
|
||||
// - 0x48 gives access to pins A0 - A3
|
||||
// - 0x49 gives access to pins A4 - A7
|
||||
ADS1115 *ads1115 = new upm::ADS1115(0, 0x48);
|
||||
|
||||
// Put the ADC into differential mode for pins A0 and A1,
|
||||
// the SM-24 Geophone is connected to these pins
|
||||
ads1115->getSample(ADS1X15::DIFF_0_1);
|
||||
|
||||
// Set the gain based on expected VIN range to -/+ 2.048 V
|
||||
// Can be adjusted based on application to as low as -/+ 0.256 V, see API
|
||||
// documentation for details
|
||||
ads1115->setGain(ADS1X15::GAIN_TWO);
|
||||
|
||||
// Set the sample rate to 860 samples per second (max) and turn on continuous
|
||||
// sampling
|
||||
ads1115->setSPS(ADS1115::SPS_860);
|
||||
ads1115->setContinuous(true);
|
||||
|
||||
// Enable exceptions from the output stream
|
||||
f.exceptions(ofstream::failbit | ofstream::badbit);
|
||||
// Open the file
|
||||
try{
|
||||
f.open(fileName);
|
||||
|
||||
// Output formatting
|
||||
f.setf(ios_base::fixed);
|
||||
f.precision(7);
|
||||
|
||||
// Start the thread that will stop logging after 10 seconds
|
||||
thread timer (stop);
|
||||
|
||||
// Read sensor data and write it to the output file every ms
|
||||
while(running){
|
||||
f << id++ << " " << ads1115->getLastSample() << endl;
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
// Clean-up and exit
|
||||
timer.join();
|
||||
f.close();
|
||||
delete ads1115;
|
||||
} catch (ios_base::failure &e) {
|
||||
cout << "Failed to write to file: " << e.what() << endl;
|
||||
return 1;
|
||||
}
|
||||
cout << "Wrote " << id << " samples to file: " << fileName << endl;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ int main()
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
int command;
|
||||
//! [Interesting]
|
||||
//Select the device you are testing here and adjust case 6 for the correct sample rates.
|
||||
//upm::ADS1015 *ads = new upm::ADS1015(1);
|
||||
upm::ADS1115 *ads = new upm::ADS1115(1, 0x49);
|
||||
@ -315,6 +316,7 @@ int main()
|
||||
}while (command != -1 );
|
||||
|
||||
delete ads;
|
||||
//! [Interesting]
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ int main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate an BMA250E using default I2C parameters
|
||||
upm::BMA250E *sensor = new upm::BMA250E();
|
||||
upm::BMA250E sensor;
|
||||
|
||||
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
|
||||
// for CS: BMA250E(0, -1, 10);
|
||||
@ -54,9 +54,9 @@ int main(int argc, char **argv)
|
||||
{
|
||||
float x, y, z;
|
||||
|
||||
sensor->update();
|
||||
sensor.update();
|
||||
|
||||
sensor->getAccelerometer(&x, &y, &z);
|
||||
sensor.getAccelerometer(&x, &y, &z);
|
||||
cout << "Accelerometer x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
@ -64,8 +64,8 @@ int main(int argc, char **argv)
|
||||
<< endl;
|
||||
|
||||
// we show both C and F for temperature
|
||||
cout << "Compensation Temperature: " << sensor->getTemperature()
|
||||
<< " C / " << sensor->getTemperature(true) << " F"
|
||||
cout << "Compensation Temperature: " << sensor.getTemperature()
|
||||
<< " C / " << sensor.getTemperature(true) << " F"
|
||||
<< endl;
|
||||
|
||||
cout << endl;
|
||||
@ -77,7 +77,5 @@ int main(int argc, char **argv)
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ int main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate an BMG160 using default I2C parameters
|
||||
upm::BMG160 *sensor = new upm::BMG160();
|
||||
upm::BMG160 sensor;
|
||||
|
||||
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
|
||||
// for CS: BMG160(0, -1, 10);
|
||||
@ -54,9 +54,9 @@ int main(int argc, char **argv)
|
||||
{
|
||||
float x, y, z;
|
||||
|
||||
sensor->update();
|
||||
sensor.update();
|
||||
|
||||
sensor->getGyroscope(&x, &y, &z);
|
||||
sensor.getGyroscope(&x, &y, &z);
|
||||
cout << "Gyroscope x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
@ -64,8 +64,8 @@ int main(int argc, char **argv)
|
||||
<< endl;
|
||||
|
||||
// we show both C and F for temperature
|
||||
cout << "Compensation Temperature: " << sensor->getTemperature()
|
||||
<< " C / " << sensor->getTemperature(true) << " F"
|
||||
cout << "Compensation Temperature: " << sensor.getTemperature()
|
||||
<< " C / " << sensor.getTemperature(true) << " F"
|
||||
<< endl;
|
||||
|
||||
cout << endl;
|
||||
@ -77,7 +77,5 @@ int main(int argc, char **argv)
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ int main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate an BMM150 using default I2C parameters
|
||||
upm::BMM150 *sensor = new upm::BMM150();
|
||||
upm::BMM150 sensor;
|
||||
|
||||
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
|
||||
// for CS: BMM150(0, -1, 10);
|
||||
@ -54,9 +54,9 @@ int main(int argc, char **argv)
|
||||
{
|
||||
float x, y, z;
|
||||
|
||||
sensor->update();
|
||||
sensor.update();
|
||||
|
||||
sensor->getMagnetometer(&x, &y, &z);
|
||||
sensor.getMagnetometer(&x, &y, &z);
|
||||
cout << "Magnetometer x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
@ -72,7 +72,5 @@ int main(int argc, char **argv)
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int shouldRun = true;
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -31,7 +33,7 @@
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int shouldRun = true;
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
|
@ -1,6 +1,11 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* This driver was rewritten based on the original driver written by:
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -24,57 +29,50 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "bmpx8x.hpp"
|
||||
#include <signal.h>
|
||||
|
||||
int doWork = 0;
|
||||
upm::BMPX8X *sensor = NULL;
|
||||
#include "bmpx8x.hpp"
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
using namespace std;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
printf("got signal\n");
|
||||
if (signo == SIGINT) {
|
||||
printf("exiting application\n");
|
||||
doWork = 1;
|
||||
}
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
uint32_t presure = 0;
|
||||
float temperature = 0;
|
||||
float altitude = 0;
|
||||
uint32_t sealevel = 0;
|
||||
|
||||
// Instantiate a BMPX8X sensor on I2C
|
||||
sensor = new upm::BMPX8X(0, ADDR);
|
||||
// Instantiate a BMPX8X sensor on I2C using defaults.
|
||||
upm::BMPX8X sensor;
|
||||
|
||||
// Print the pressure, altitude, sea level, and
|
||||
// temperature values every 0.1 seconds
|
||||
while (!doWork) {
|
||||
presure = sensor->getPressure ();
|
||||
temperature = sensor->getTemperature ();
|
||||
altitude = sensor->getAltitude ();
|
||||
sealevel = sensor->getSealevelPressure ();
|
||||
// temperature values every 0.5 seconds
|
||||
while (shouldRun)
|
||||
{
|
||||
sensor.update();
|
||||
|
||||
std::cout << "pressure value = " <<
|
||||
presure <<
|
||||
", altitude value = " <<
|
||||
altitude <<
|
||||
", sealevel value = " <<
|
||||
sealevel <<
|
||||
", temperature = " <<
|
||||
temperature << std::endl;
|
||||
usleep (100000);
|
||||
cout << "Pressure: "
|
||||
<< sensor.getPressure()
|
||||
<< " Pa, Temperature: "
|
||||
<< sensor.getTemperature()
|
||||
<< " C, Altitude: "
|
||||
<< sensor.getAltitude()
|
||||
<< " m, Sea level: "
|
||||
<< sensor.getSealevelPressure()
|
||||
<< " Pa"
|
||||
<< endl;
|
||||
|
||||
usleep(500000);
|
||||
}
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
std::cout << "exiting application" << std::endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -44,23 +44,23 @@ int main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate an BMC150 using default I2C parameters
|
||||
upm::BMC150 *sensor = new upm::BMC150();
|
||||
upm::BMC150 sensor;
|
||||
|
||||
// now output data every 250 milliseconds
|
||||
while (shouldRun)
|
||||
{
|
||||
float x, y, z;
|
||||
|
||||
sensor->update();
|
||||
sensor.update();
|
||||
|
||||
sensor->getAccelerometer(&x, &y, &z);
|
||||
sensor.getAccelerometer(&x, &y, &z);
|
||||
cout << "Accelerometer x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
<< " g"
|
||||
<< endl;
|
||||
|
||||
sensor->getMagnetometer(&x, &y, &z);
|
||||
sensor.getMagnetometer(&x, &y, &z);
|
||||
cout << "Magnetometer x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
@ -76,7 +76,5 @@ int main(int argc, char **argv)
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
@ -44,23 +44,23 @@ int main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate an BMI055 using default I2C parameters
|
||||
upm::BMI055 *sensor = new upm::BMI055();
|
||||
upm::BMI055 sensor;
|
||||
|
||||
// now output data every 250 milliseconds
|
||||
while (shouldRun)
|
||||
{
|
||||
float x, y, z;
|
||||
|
||||
sensor->update();
|
||||
sensor.update();
|
||||
|
||||
sensor->getAccelerometer(&x, &y, &z);
|
||||
sensor.getAccelerometer(&x, &y, &z);
|
||||
cout << "Accelerometer x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
<< " g"
|
||||
<< endl;
|
||||
|
||||
sensor->getGyroscope(&x, &y, &z);
|
||||
sensor.getGyroscope(&x, &y, &z);
|
||||
cout << "Gyroscope x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
@ -76,7 +76,5 @@ int main(int argc, char **argv)
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
@ -44,30 +44,30 @@ int main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate an BMX055 using default I2C parameters
|
||||
upm::BMX055 *sensor = new upm::BMX055();
|
||||
upm::BMX055 sensor;
|
||||
|
||||
// now output data every 250 milliseconds
|
||||
while (shouldRun)
|
||||
{
|
||||
float x, y, z;
|
||||
|
||||
sensor->update();
|
||||
sensor.update();
|
||||
|
||||
sensor->getAccelerometer(&x, &y, &z);
|
||||
sensor.getAccelerometer(&x, &y, &z);
|
||||
cout << "Accelerometer x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
<< " g"
|
||||
<< endl;
|
||||
|
||||
sensor->getGyroscope(&x, &y, &z);
|
||||
sensor.getGyroscope(&x, &y, &z);
|
||||
cout << "Gyroscope x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
<< " degrees/s"
|
||||
<< endl;
|
||||
|
||||
sensor->getMagnetometer(&x, &y, &z);
|
||||
sensor.getMagnetometer(&x, &y, &z);
|
||||
cout << "Magnetometer x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
@ -83,7 +83,5 @@ int main(int argc, char **argv)
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ main(int argc, char **argv)
|
||||
printf("motion is: %d, %d, %d, %d, %d, %d\n", m, n, o, p, q, r);
|
||||
|
||||
delete sensor;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,11 +8,11 @@
|
||||
#define EDISON_I2C_BUS 1 // Edison I2C-1
|
||||
#define DS1808_GPIO_PWR 15 // Edison GP165
|
||||
|
||||
void printState(upm::ILightController *lightController)
|
||||
void printState(upm::ILightController &lightController)
|
||||
{
|
||||
if (lightController->isPowered())
|
||||
if (lightController.isPowered())
|
||||
{
|
||||
std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
|
||||
std::cout << "Light is powered, brightness = " << lightController.getBrightness() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -22,30 +22,22 @@ void printState(upm::ILightController *lightController)
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
int status = 0;
|
||||
upm::ILightController* lightController = nullptr;
|
||||
|
||||
try {
|
||||
lightController = new upm::DS1808LC(DS1808_GPIO_PWR, EDISON_I2C_BUS);
|
||||
//! [Interesting]
|
||||
upm::DS1808LC lightController(DS1808_GPIO_PWR, EDISON_I2C_BUS);
|
||||
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();
|
||||
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;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
||||
delete lightController;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -49,9 +49,6 @@ int main(int argc, char **argv)
|
||||
// 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;
|
||||
|
||||
@ -59,18 +56,26 @@ int main(int argc, char **argv)
|
||||
if (!sensor.devicesFound())
|
||||
return 1;
|
||||
|
||||
// update and print available values every second
|
||||
// update and print available values every 2 seconds
|
||||
while (shouldRun)
|
||||
{
|
||||
// update our values for the first sensor
|
||||
sensor.update(0);
|
||||
// update our values for all of the detected sensors
|
||||
sensor.update(-1);
|
||||
|
||||
// we show both C and F for temperature for the first sensor
|
||||
cout << "Temperature: " << sensor.getTemperature(0)
|
||||
<< " C / " << sensor.getTemperature(0, true) << " F"
|
||||
// we show both C and F for temperature for the sensors
|
||||
int i;
|
||||
for (i=0; i<sensor.devicesFound(); i++)
|
||||
{
|
||||
cout << "Device "
|
||||
<< i
|
||||
<< ": Temperature: "
|
||||
<< sensor.getTemperature(i)
|
||||
<< " C / " << sensor.getTemperature(i, true) << " F"
|
||||
<< endl;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
sleep(1);
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Copyright (c) 2014-2017 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -62,11 +62,12 @@ int main()
|
||||
// waiting 0.1 seconds between readings
|
||||
while (shouldRun)
|
||||
{
|
||||
unsigned int val = gyro->value();
|
||||
double av = gyro->angularVelocity(val);
|
||||
gyro->update();
|
||||
|
||||
cout << "Raw value: " << val << ", "
|
||||
<< "angular velocity: " << av << " deg/s" << endl;
|
||||
cout << "Angular velocity: "
|
||||
<< gyro->angularVelocity()
|
||||
<< " deg/s"
|
||||
<< endl;
|
||||
|
||||
usleep(100000);
|
||||
}
|
||||
|
67
examples/c++/hdc1000.cxx
Normal file
67
examples/c++/hdc1000.cxx
Normal file
@ -0,0 +1,67 @@
|
||||
/* Author: Norbert Wesp <nwesp@phytec.de>
|
||||
* Copyright (c) 2017 Phytec Messtechnik GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* 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 "hdc1000.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
bool run = true;
|
||||
|
||||
void sig_handler(int sig)
|
||||
{
|
||||
if (sig == SIGINT)
|
||||
run = false;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
std::cout << "Initializing test-application..." << std::endl;
|
||||
|
||||
// Instantiate an HDC1000 instance on bus 1
|
||||
upm::HDC1000 *mySensor = new upm::HDC1000(1);
|
||||
|
||||
// update and print available values every second
|
||||
while (run)
|
||||
{
|
||||
std::cout << "Humidity: " << mySensor->getHumidity(true) << std::endl
|
||||
<< "Temperature: " << mySensor->getTemperature(true) << std::endl;
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
std::cout << "Exiting test-application..." << std::endl;
|
||||
|
||||
delete mySensor;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -8,11 +8,11 @@
|
||||
#define HLG150H_GPIO_RELAY 21
|
||||
#define HLG150H_GPIO_PWM 22
|
||||
|
||||
void printState(upm::ILightController *lightController)
|
||||
void printState(upm::ILightController &lightController)
|
||||
{
|
||||
if (lightController->isPowered())
|
||||
if (lightController.isPowered())
|
||||
{
|
||||
std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
|
||||
std::cout << "Light is powered, brightness = " << lightController.getBrightness() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -22,30 +22,23 @@ void printState(upm::ILightController *lightController)
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
int status = 0;
|
||||
upm::ILightController* lightController;
|
||||
|
||||
try {
|
||||
lightController = new upm::HLG150H(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
|
||||
//! [Interesting]
|
||||
upm::HLG150H lightController(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
|
||||
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();
|
||||
if (brightness > 0)
|
||||
{
|
||||
lightController.setPowerOn();
|
||||
lightController.setBrightness(brightness);
|
||||
}
|
||||
else
|
||||
lightController.setPowerOff();
|
||||
}
|
||||
std::cout << "Now: ";printState(lightController);
|
||||
delete lightController;
|
||||
} catch (std::exception& e) {
|
||||
std::cout << "Error: " << e.what() << std::endl;
|
||||
status = 1;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,16 +32,17 @@ main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
// Instantiate on I2C
|
||||
upm::Hmc5883l* compass = new upm::Hmc5883l(0);
|
||||
int16_t *pos;
|
||||
|
||||
compass->set_declination(0.2749); // Set your declination from true north in radians
|
||||
compass->set_declination(0.2749); // Set your declination from
|
||||
// true north in radians
|
||||
|
||||
// Print out the coordinates, heading, and direction every second
|
||||
while(true){
|
||||
compass->update(); // Update the coordinates
|
||||
pos = compass->coordinates();
|
||||
const int16_t *pos = compass->coordinates();
|
||||
fprintf(stdout, "coor: %5d %5d %5d ", pos[0], pos[1], pos[2]);
|
||||
fprintf(stdout, "heading: %5.2f direction: %3.2f\n", compass->heading(), compass->direction());
|
||||
fprintf(stdout, "heading: %5.2f direction: %3.2f\n",
|
||||
compass->heading(), compass->direction());
|
||||
sleep(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
@ -95,4 +95,4 @@ int main( int argc, char **argv )
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
//! [Interesting]
|
73
examples/c++/lcdks.cxx
Normal file
73
examples/c++/lcdks.cxx
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "lcdks.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]
|
||||
|
||||
// Instantiate a LCDKS (LCD Keypad Shield) using default pins
|
||||
|
||||
// NOTE: The default pins do not include support for a gpio
|
||||
// controlled backlight. If you need one, you will need to specify
|
||||
// all neccessary pins to the constructor.
|
||||
upm::LCDKS* lcd = new upm::LCDKS();
|
||||
|
||||
lcd->setCursor(0,0);
|
||||
lcd->write("LCDKS driver");
|
||||
lcd->setCursor(1,2);
|
||||
lcd->write("Hello World");
|
||||
|
||||
// output current key value every second.
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << "Button value: " << lcd->getKeyValue() << endl;
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
delete lcd;
|
||||
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
@ -44,7 +44,7 @@ main(int argc, char **argv)
|
||||
std::cout << "For the next " << NUMBER_OF_SECONDS << " seconds, "
|
||||
<< SAMPLES_PER_SECOND << " samples will be taken every second."
|
||||
<< std::endl << std::endl;
|
||||
uint16_t* buffer = new uint16_t[NUMBER_OF_SECONDS * SAMPLES_PER_SECOND];
|
||||
uint16_t buffer[NUMBER_OF_SECONDS * SAMPLES_PER_SECOND];
|
||||
for (int i=0; i < NUMBER_OF_SECONDS * SAMPLES_PER_SECOND; i++) {
|
||||
buffer[i] = (uint16_t) sensor->getSample();
|
||||
usleep(MICROSECONDS_PER_SECOND / SAMPLES_PER_SECOND);
|
||||
|
@ -34,10 +34,11 @@ main(int argc, char **argv)
|
||||
// Create the light sensor object using AIO pin 0
|
||||
upm::Light* light = new upm::Light(0);
|
||||
|
||||
// Read the input and print both the raw value and a rough lux value,
|
||||
// waiting one second between readings
|
||||
// Read the input and print both the normalized ADC value and a
|
||||
// rough lux value, waiting one second between readings
|
||||
while( 1 ) {
|
||||
std::cout << light->name() << " raw value is " << light->raw_value() <<
|
||||
std::cout << light->name() << " normalized value is "
|
||||
<< light->getNormalized() <<
|
||||
", which is roughly " << light->value() << " lux" << std::endl;
|
||||
sleep(1);
|
||||
}
|
||||
|
@ -9,11 +9,11 @@
|
||||
#define LP8860_GPIO_PWR 45 // Edison GP45
|
||||
|
||||
|
||||
void printState(upm::ILightController *lightController)
|
||||
void printState(upm::ILightController &lightController)
|
||||
{
|
||||
if (lightController->isPowered())
|
||||
if (lightController.isPowered())
|
||||
{
|
||||
std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
|
||||
std::cout << "Light is powered, brightness = " << lightController.getBrightness() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -23,30 +23,23 @@ void printState(upm::ILightController *lightController)
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
int status = 0;
|
||||
upm::LP8860* lightController;
|
||||
|
||||
try {
|
||||
lightController = new upm::LP8860(LP8860_GPIO_PWR, EDISON_I2C_BUS);
|
||||
//! [Interesting]
|
||||
upm::LP8860 lightController(LP8860_GPIO_PWR, EDISON_I2C_BUS);
|
||||
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();
|
||||
if (brightness > 0)
|
||||
{
|
||||
lightController.setPowerOn();
|
||||
lightController.setBrightness(brightness);
|
||||
}
|
||||
else
|
||||
lightController.setPowerOff();
|
||||
}
|
||||
std::cout << "Now: ";printState(lightController);
|
||||
delete lightController;
|
||||
} catch (std::exception& e) {
|
||||
std::cout << "Error: " << e.what() << std::endl;
|
||||
status = 1;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
sensor = new upm::LPD8806(10, 7);
|
||||
sensor = new upm::LPD8806(0, 7, 10);
|
||||
usleep (1000000);
|
||||
|
||||
sensor->show ();
|
||||
|
76
examples/c++/mag3110.cxx
Normal file
76
examples/c++/mag3110.cxx
Normal file
@ -0,0 +1,76 @@
|
||||
/* Author: Norbert Wesp <nwesp@phytec.de>
|
||||
* Copyright (c) 2017 Phytec Messtechnik GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* 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 "mag3110.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
bool run = true;
|
||||
|
||||
void sig_handler(int sig)
|
||||
{
|
||||
if (sig == SIGINT)
|
||||
run = false;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
upm::mag3110_data_t data;
|
||||
|
||||
std::cout << "Initializing test-application..." << std::endl;
|
||||
|
||||
// Instantiate an MAG3110 instance on bus 1
|
||||
upm::MAG3110 *mySensor = new upm::MAG3110(1);
|
||||
|
||||
// activate periodic measurements
|
||||
mySensor->setActive();
|
||||
|
||||
// update and print available values every second
|
||||
while (run)
|
||||
{
|
||||
mySensor->getData (&data, true);
|
||||
std::cout << "x: " << data.x << std::endl
|
||||
<< "y: " << data.y << std::endl
|
||||
<< "z: " << data.z << std::endl
|
||||
<< "Status: " << data.status << std::endl
|
||||
<< "Die temperature: " << data.dtemp << std::endl;
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
std::cout << "Exiting test-application..." << std::endl;
|
||||
|
||||
delete mySensor;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
99
examples/c++/max30100.cxx
Normal file
99
examples/c++/max30100.cxx
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Author: Noel Eck <noel.eck@intel.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 "max30100.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
// Example Callback handler
|
||||
class mycallback : public Callback
|
||||
{
|
||||
public:
|
||||
virtual void run(max30100_value samp)
|
||||
{
|
||||
std::cout << "My callback sample IR: "
|
||||
<< samp.IR << " R: " << samp.R << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a MAX30100 instance using i2c bus 0
|
||||
upm::MAX30100 sensor(0);
|
||||
|
||||
// Create an instance of the Callback class
|
||||
mycallback cb;
|
||||
|
||||
// Read the temperature and version
|
||||
std::cout << "Temperature: " << sensor.temperature() << " C" << std::endl;
|
||||
std::cout << "Version: " << sensor.version() << std::endl;
|
||||
|
||||
// Set high-res (50 Hz, 16-bit)
|
||||
sensor.high_res_enable(true);
|
||||
|
||||
// Set to sample SpO2
|
||||
sensor.mode(MAX30100_MODE_SPO2_EN);
|
||||
|
||||
// Read continuously, stepping up the LED current every second,
|
||||
// us GPIO 0 as the interrupt pin
|
||||
sensor.sample_continuous(0, false, &cb);
|
||||
for (int i = MAX30100_LED_CURRENT_0_0_MA;
|
||||
i <= MAX30100_LED_CURRENT_50_0_MA && shouldRun; i++)
|
||||
{
|
||||
// Toggle the LED current
|
||||
std::cout << "Setting LED current = " << i << std::endl;
|
||||
|
||||
sensor.current((MAX30100_LED_CURRENT)i, (MAX30100_LED_CURRENT)i);
|
||||
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
// Read individual samples
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
max30100_value val = sensor.sample();
|
||||
std::cout << "Single value IR: " << val.IR << " R: " << val.R << std::endl;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
std::cout << "Exiting..." << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -44,7 +44,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
sensor = new upm::MAX31723(7);
|
||||
sensor = new upm::MAX31723(0, 7);
|
||||
usleep (1000000);
|
||||
|
||||
while (!doWork) {
|
||||
|
@ -30,17 +30,13 @@
|
||||
|
||||
int main ()
|
||||
{
|
||||
try {
|
||||
upm::MAX44009* lightSensor = new upm::MAX44009(EDISON_I2C_BUS);
|
||||
//! [Interesting]
|
||||
upm::MAX44009 lightSensor(EDISON_I2C_BUS);
|
||||
while (true) {
|
||||
float value = lightSensor->getVisibleLux();
|
||||
float value = lightSensor.getVisibleLux();
|
||||
std::cout << "Light level = " << value << " lux" << std::endl;
|
||||
sleep(1);
|
||||
}
|
||||
delete lightSensor;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
125
examples/c++/mcp2515-txrx.cxx
Normal file
125
examples/c++/mcp2515-txrx.cxx
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <upm_utilities.h>
|
||||
|
||||
#include "mcp2515.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);
|
||||
|
||||
// by default we just receive packets
|
||||
bool do_tx = false;
|
||||
|
||||
// if an argument is given, we will transmit packets
|
||||
if (argc > 1)
|
||||
do_tx = true;
|
||||
//! [Interesting]
|
||||
|
||||
// NOTE: This example assumes that only two devices are connected
|
||||
// to the CAN bus, and that both devices are running this example;
|
||||
// one in TX (transmit) mode, and one in RX (receive) mode.
|
||||
|
||||
// If this is not the case, then in rx mode you may see other
|
||||
// packets from other devices, or not, depending on whether the
|
||||
// speed is correct for the network. In tx mode, errors may be
|
||||
// generated on the bus, especially if the CAN bus speed does not
|
||||
// match the rest of the network.
|
||||
|
||||
// You should start the receiver example first. The transmitter
|
||||
// example will fail after about 5 seconds (timeout) of not being
|
||||
// able to transmit a message.
|
||||
|
||||
// Instantiate a MCP2515 on SPI bus 0 using a hw CS pin (-1).
|
||||
upm::MCP2515 *sensor = new upm::MCP2515(0, 9);
|
||||
|
||||
// By default, after initialization, the baud rate is set to
|
||||
// 50Kbps, and the mode is NORMAL, so we don't need to set any of
|
||||
// that here.
|
||||
|
||||
// our TX payload. If transmitting, the first number will be
|
||||
// incremented (and rollover) on each transmission.
|
||||
string myPayload = "01234567";
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
if (do_tx)
|
||||
{
|
||||
cout << "Loading a packet of 8 numbers (0-7) into a TX buffer..."
|
||||
<< endl;
|
||||
sensor->loadTXBuffer(MCP2515_TX_BUFFER0, 0, false, false,
|
||||
myPayload);
|
||||
|
||||
// now lets try to transmit it
|
||||
cout << "Transmitting packet..." << endl;
|
||||
sensor->transmitBuffer(MCP2515_TX_BUFFER0, true);
|
||||
|
||||
myPayload[0]++;
|
||||
cout << "Transmit successful" << endl;
|
||||
cout << endl;
|
||||
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
else
|
||||
{
|
||||
// RX mode
|
||||
// Look for a packet waiting for us in RXB0
|
||||
if (sensor->rxStatusMsgs() == MCP2515_RXMSG_RXB0)
|
||||
{
|
||||
cout << "Packet received in RXB0, decoding..." << endl;
|
||||
|
||||
// now lets retrieve and print it
|
||||
sensor->getRXMsg(MCP2515_RX_BUFFER0);
|
||||
|
||||
sensor->printMsg();
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
upm_delay_ms(100);
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
79
examples/c++/mcp2515.cxx
Normal file
79
examples/c++/mcp2515.cxx
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "mcp2515.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a MCP2515 on SPI bus 0 using a hw CS pin (-1).
|
||||
upm::MCP2515 *sensor = new upm::MCP2515(0, -1);
|
||||
|
||||
cout << "Setting loopback mode..." << endl;
|
||||
|
||||
// set the mode to loopback mode. In loopback mode, transmitted
|
||||
// packets are sent directly to an appropriate receive buffer
|
||||
// without actually going out onto the CAN bus.
|
||||
sensor->setOpmode(MCP2515_OPMODE_LOOPBACK);
|
||||
|
||||
// lets build up a packet and try loading it (8 bytes max).
|
||||
string myPayload = "01234567";
|
||||
cout << "Loading a packet of 8 numbers (0-7) into a TX buffer..." << endl;
|
||||
sensor->loadTXBuffer(MCP2515_TX_BUFFER0, 0, false, false, myPayload);
|
||||
|
||||
// now lets try to transmit it
|
||||
cout << "Transmitting packet..." << endl;
|
||||
sensor->transmitBuffer(MCP2515_TX_BUFFER0, true);
|
||||
|
||||
cout << "Transmit successful" << endl;
|
||||
|
||||
// There should now be a packet waiting for us in RXB0
|
||||
if (sensor->rxStatusMsgs() == MCP2515_RXMSG_RXB0)
|
||||
{
|
||||
cout << "Packet received in RXB0, decoding..." << endl;
|
||||
|
||||
// now lets retrieve and print it
|
||||
sensor->getRXMsg(MCP2515_RX_BUFFER0);
|
||||
|
||||
sensor->printMsg();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "No packet found, how strange." << endl;
|
||||
}
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -159,5 +159,5 @@ int main()
|
||||
|
||||
}while (command != -1 );
|
||||
//! [Interesting]
|
||||
return MRAA_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
@ -74,5 +74,5 @@ int main()
|
||||
delete sensor;
|
||||
//! [Interesting]
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
91
examples/c++/mma8x5x.cxx
Normal file
91
examples/c++/mma8x5x.cxx
Normal file
@ -0,0 +1,91 @@
|
||||
/* Author: Norbert Wesp <nwesp@phytec.de>
|
||||
* Copyright (c) 2017 Phytec Messtechnik GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* 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 "mma8x5x.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
bool run = true;
|
||||
|
||||
void sig_handler(int sig)
|
||||
{
|
||||
if (sig == SIGINT)
|
||||
run = false;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
upm::mma8x5x_data_t data;
|
||||
|
||||
// U can set your own parameters for an MMA8X5X instance with
|
||||
/*
|
||||
upm::mma8x5x_params_t params;
|
||||
params.type = <device-id>; device-id of your sensor
|
||||
params.rate = <sampling-rate>; between 0<<3 and 7<<3
|
||||
params.range = <range>; between 0 and 2
|
||||
params.offsetX = <x-axis offset>; between 0 and 255
|
||||
params.offsetY = <y-axis offset>; between 0 and 255
|
||||
params.offsetZ = <z-axis offset>; between 0 and 255
|
||||
*/
|
||||
|
||||
std::cout << "Initializing test-application..." << std::endl;
|
||||
|
||||
// Instantiate an MMA8X5X instance on bus 1 with default parameters
|
||||
// The sensor-type will be detected by reading out the device-id
|
||||
upm::MMA8X5X *mySensor = new upm::MMA8X5X(1);
|
||||
|
||||
// If u have set own parameters use this one
|
||||
/*
|
||||
upm::MMA8X5X *mySensor = new upm::MMA8X5X(1, ¶ms);
|
||||
*/
|
||||
|
||||
// activate periodic measurements
|
||||
mySensor->setActive();
|
||||
|
||||
// update and print available values every second
|
||||
while (run)
|
||||
{
|
||||
mySensor->getData (&data, true);
|
||||
std::cout << "x: " << (int)data.x << std::endl
|
||||
<< "y: " << (int)data.y << std::endl
|
||||
<< "z: " << (int)data.z << std::endl;
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
std::cout << "Exiting test-application..." << std::endl;
|
||||
|
||||
delete mySensor;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
111
examples/c++/mmc35240.cxx
Normal file
111
examples/c++/mmc35240.cxx
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.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 <iostream>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <math.h>
|
||||
#include "mmc35240.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
upm::MMC35240* magnetometer;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
void
|
||||
data_callback(char* data)
|
||||
{
|
||||
float x, y, z;
|
||||
double azimuth;
|
||||
int level;
|
||||
magnetometer->extract3Axis(data, &x, &y, &z);
|
||||
/* calibrated level
|
||||
* UNRELIABLE = 0
|
||||
* ACCURACY_LOW = 1
|
||||
* ACCURACY_MEDIUM = 2
|
||||
* ACCURACY_HIGH = >=3
|
||||
*/
|
||||
level = magnetometer->getCalibratedLevel();
|
||||
|
||||
if ((x == 0) && (y == 0)) {
|
||||
cout << "Point (0, 0) is invalid!\n" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (x == 0) {
|
||||
if (y > 0)
|
||||
azimuth = 0;
|
||||
else
|
||||
azimuth = 180;
|
||||
} else if (y == 0) {
|
||||
if (x > 0)
|
||||
azimuth = 90;
|
||||
else
|
||||
azimuth = 270;
|
||||
} else {
|
||||
if (x > 0)
|
||||
azimuth = 90 - atan(y / x) * 180 / M_PI;
|
||||
else
|
||||
azimuth = 270 - atan(y / x) * 180 / M_PI;
|
||||
}
|
||||
|
||||
cout << "[Calibrated Level:" << level << ']' << "[Azimuth:" << (int) (360 - azimuth) << ']'
|
||||
<< '\t' << (int) x << '\t' << (int) y << '\t' << (int) z << "[uT]" << endl;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
// Instantiate a MMC35240 Magnetic Sensor on iio device 5. This configuration is a reference and
|
||||
// should be changed per platform/board type.
|
||||
magnetometer = new upm::MMC35240(5);
|
||||
// Kernel driver does not allow changing the value of scale at run-time, default scale is
|
||||
// 0.001000
|
||||
magnetometer->setScale(0.001000);
|
||||
// Available sampling frequency are 1.5, 13, 25, 50
|
||||
magnetometer->setSamplingFrequency(25.000000);
|
||||
magnetometer->enable3AxisChannel();
|
||||
magnetometer->installISR(data_callback, NULL);
|
||||
magnetometer->enableBuffer(16);
|
||||
|
||||
while (shouldRun) {
|
||||
sleep(1);
|
||||
}
|
||||
magnetometer->disableBuffer();
|
||||
|
||||
//! [Interesting]
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
delete magnetometer;
|
||||
|
||||
return 0;
|
||||
}
|
@ -31,6 +31,7 @@
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
//! [Interesting]
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Instantiate a NLGPIO16 Module on the default UART (/dev/ttyACM0)
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <lib_aci.h>
|
||||
#include <aci_setup.h>
|
||||
#include <signal.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef SERVICES_PIPE_TYPE_MAPPING_CONTENT
|
||||
static services_pipe_type_mapping_t
|
||||
@ -77,11 +78,11 @@ init_aci_setup () {
|
||||
/**
|
||||
* Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001
|
||||
*/
|
||||
if (NULL != services_pipe_type_mapping) {
|
||||
aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
|
||||
} else {
|
||||
aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
|
||||
}
|
||||
// abort if this is NULL
|
||||
assert(services_pipe_type_mapping != NULL);
|
||||
|
||||
aci_state.aci_setup_info.services_pipe_type_mapping =
|
||||
&services_pipe_type_mapping[0];
|
||||
|
||||
aci_state.aci_setup_info.number_of_pipes = NUMBER_OF_PIPES;
|
||||
aci_state.aci_setup_info.setup_msgs = setup_msgs;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <lib_aci.h>
|
||||
#include <aci_setup.h>
|
||||
#include <signal.h>
|
||||
#include <assert.h>
|
||||
#include "uart_over_ble.h"
|
||||
|
||||
/*
|
||||
@ -95,11 +96,11 @@ init_aci_setup () {
|
||||
/**
|
||||
* Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001
|
||||
*/
|
||||
if (NULL != services_pipe_type_mapping) {
|
||||
aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
|
||||
} else {
|
||||
aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
|
||||
}
|
||||
// abort if this is NULL
|
||||
assert(services_pipe_type_mapping != NULL);
|
||||
|
||||
aci_state.aci_setup_info.services_pipe_type_mapping =
|
||||
&services_pipe_type_mapping[0];
|
||||
|
||||
aci_state.aci_setup_info.number_of_pipes = NUMBER_OF_PIPES;
|
||||
aci_state.aci_setup_info.setup_msgs = setup_msgs;
|
||||
|
@ -43,16 +43,8 @@ int main(int argc, char **argv)
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a nunchuck controller bus 0
|
||||
upm::NUNCHUCK *nunchuck = new upm::NUNCHUCK(0);
|
||||
|
||||
// always do this first
|
||||
cout << "Initializing... " << endl;
|
||||
if (!nunchuck->init())
|
||||
{
|
||||
cerr << "nunchuck->init() failed." << endl;
|
||||
return 0;
|
||||
}
|
||||
// Instantiate a nunchuck controller bus 3
|
||||
upm::NUNCHUCK *nunchuck = new upm::NUNCHUCK(3);
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
|
@ -119,5 +119,6 @@ int main(int argc, char **argv)
|
||||
|
||||
delete sensor;
|
||||
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
@ -104,6 +104,7 @@ int main(int argc, char **argv)
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -122,6 +122,7 @@ int main(int argc, char **argv)
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -112,6 +112,7 @@ int main(int argc, char **argv)
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
@ -110,5 +110,6 @@ int main(int argc, char **argv)
|
||||
|
||||
delete sensor;
|
||||
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
48
examples/c++/p9813.cxx
Normal file
48
examples/c++/p9813.cxx
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Author: Sergey Kiselev <sergey.kiselev@intel.com>
|
||||
* Copyright (c) 2017 Sergey Kiselev
|
||||
* Based on the p9813 driver writen by Yannick Adam <yannick.adam@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* 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 "p9813.hpp"
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate a chain of 2 LEDs using pin 2 for clock and pin 3 for data
|
||||
upm::P9813 ledChain(2, 2, 3);
|
||||
|
||||
// Set all LEDs to Red
|
||||
ledChain.setAllLeds(255, 0, 0);
|
||||
|
||||
// Set a single LED to green
|
||||
ledChain.setLed(1, 0, 255, 0);
|
||||
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
@ -38,9 +38,9 @@ sig_handler (int signo) {
|
||||
int
|
||||
main (int argc, char ** argv) {
|
||||
// SPI bus 0, CS pin 10, INTR pin 2
|
||||
upm::RF22* rf22 = new upm::RF22 (0, 10, 2);
|
||||
upm::RF22 rf22(0, 10, 2);
|
||||
|
||||
if (!rf22->init()) {
|
||||
if (!rf22.init()) {
|
||||
std::cout << "RF22 init failed" << std::endl;
|
||||
return 0x1;
|
||||
}
|
||||
@ -53,13 +53,13 @@ main (int argc, char ** argv) {
|
||||
while (amWorking) {
|
||||
std::cout << "Sending to rf22_server" << std::endl;
|
||||
// Send a message to rf22_server
|
||||
rf22->send(data, sizeof(data));
|
||||
rf22->waitPacketSent();
|
||||
rf22.send(data, sizeof(data));
|
||||
rf22.waitPacketSent();
|
||||
// Now wait for a reply
|
||||
|
||||
rf22->waitAvailableTimeout(1000000);
|
||||
rf22.waitAvailableTimeout(1000000);
|
||||
|
||||
if (rf22->recv(buf, &len)) {
|
||||
if (rf22.recv(buf, &len)) {
|
||||
std::cout << "got response: " << (char*)buf << std::endl;
|
||||
} else {
|
||||
std::cout << "!!! NO RESPONSE !!!" << std::endl;
|
||||
|
@ -38,9 +38,9 @@ sig_handler (int signo) {
|
||||
int
|
||||
main (int argc, char ** argv) {
|
||||
// SPI bus 0, CS pin 10, INTR pin 2
|
||||
upm::RF22* rf22 = new upm::RF22 (0, 10, 2);
|
||||
upm::RF22 rf22(0, 10, 2);
|
||||
|
||||
if (!rf22->init()) {
|
||||
if (!rf22.init()) {
|
||||
std::cout << "RF22 init failed" << std::endl;
|
||||
return 0x1;
|
||||
}
|
||||
@ -50,23 +50,22 @@ main (int argc, char ** argv) {
|
||||
|
||||
signal (SIGINT, sig_handler);
|
||||
while (amWorking) {
|
||||
// rf22->waitAvailable();
|
||||
rf22->waitAvailableTimeout (500);
|
||||
// rf22.waitAvailable();
|
||||
rf22.waitAvailableTimeout (500);
|
||||
|
||||
// Should be a message for us now
|
||||
if (rf22->recv(buf, &len)) {
|
||||
if (rf22.recv(buf, &len)) {
|
||||
std::cout << "got request: " << (char*)buf << std::endl;
|
||||
|
||||
// Send a reply
|
||||
uint8_t data[] = "And hello back to you";
|
||||
rf22->send(data, sizeof(data));
|
||||
rf22->waitPacketSent();
|
||||
rf22.send(data, sizeof(data));
|
||||
rf22.waitPacketSent();
|
||||
} else {
|
||||
// Do whatever you need.
|
||||
}
|
||||
}
|
||||
|
||||
delete rf22;
|
||||
std::cout << "Exit 'rfm22-server'" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
64
examples/c++/rsc.cxx
Normal file
64
examples/c++/rsc.cxx
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "rsc.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
upm::RSC* rsc = new upm::RSC(0, 9, 8);
|
||||
|
||||
cout << "Sensor Name: " << rsc->getSensorName() << endl;
|
||||
rsc->setMode(NORMAL_MODE);
|
||||
rsc->setDataRate(N_DR_330_SPS);
|
||||
while (shouldRun) {
|
||||
cout << "inH2O pressure: " << rsc->getPressure() << endl;
|
||||
cout << "Temp (C): " << rsc->getTemperature() << endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete rsc;
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user