Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
88eaced5a2 | |||
b8e1b5850c | |||
e3177c260c | |||
3ed11d7c37 | |||
52198840b8 | |||
cb9d8e2339 | |||
02fb40f058 | |||
cbe211c8cf | |||
94a49a8f36 | |||
2aeb9ddea3 | |||
6d239b9f63 | |||
ee2d398bfa | |||
50fd1d7478 | |||
e7d811e4df | |||
03fa37b130 | |||
b5066c3d55 | |||
30187ba5f9 | |||
4eb6c4e19d | |||
0ea310ac71 | |||
5c4de1b926 | |||
59a66b41bb |
@ -20,7 +20,7 @@ include (GetGitRevisionDescription)
|
||||
git_describe (VERSION "--tags")
|
||||
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
|
||||
message (WARNING " - Install git to compile a production libmraa!")
|
||||
set (VERSION "v0.1.7-dirty")
|
||||
set (VERSION "v0.1.8-dirty")
|
||||
endif ()
|
||||
|
||||
message (INFO " - UPM Version ${VERSION}")
|
||||
|
18
Doxyfile.in
@ -99,7 +99,7 @@ BRIEF_MEMBER_DESC = YES
|
||||
# brief descriptions will be completely suppressed.
|
||||
# The default value is: YES.
|
||||
|
||||
REPEAT_BRIEF = YES
|
||||
REPEAT_BRIEF = NO
|
||||
|
||||
# This tag implements a quasi-intelligent brief description abbreviator that is
|
||||
# used to form the text in various listings. Each string in this list, if found
|
||||
@ -129,6 +129,8 @@ ABBREVIATE_BRIEF = "The $name class" \
|
||||
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
|
||||
DETAILS_AT_TOP = YES
|
||||
|
||||
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
|
||||
# inherited members of a class in the documentation of that class as if those
|
||||
# members were ordinary class members. Constructors, destructors and assignment
|
||||
@ -510,7 +512,7 @@ HIDE_SCOPE_NAMES = YES
|
||||
# the files that are included by a file in the documentation of that file.
|
||||
# The default value is: YES.
|
||||
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
SHOW_INCLUDE_FILES = NO
|
||||
|
||||
# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
|
||||
# grouped member an include statement to the documentation, telling the reader
|
||||
@ -536,7 +538,7 @@ INLINE_INFO = YES
|
||||
# name. If set to NO the members will appear in declaration order.
|
||||
# The default value is: YES.
|
||||
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_MEMBER_DOCS = NO
|
||||
|
||||
# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
|
||||
# descriptions of file, namespace and class members alphabetically by member
|
||||
@ -671,7 +673,7 @@ FILE_VERSION_FILTER =
|
||||
# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
|
||||
# tag is left empty.
|
||||
|
||||
LAYOUT_FILE =
|
||||
LAYOUT_FILE = @CMAKE_CURRENT_SOURCE_DIR@/DoxygenLayout.xml
|
||||
|
||||
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
|
||||
# the reference definitions. This must be a list of .bib files. The .bib
|
||||
@ -847,7 +849,9 @@ EXCLUDE_SYMLINKS = NO
|
||||
# Note that the wildcards are matched against the file with absolute path, so to
|
||||
# exclude all test directories for example use the pattern */test/*
|
||||
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_PATTERNS = @PROJECT_SOURCE_DIR@/src/nrf8001/aci* \
|
||||
@PROJECT_SOURCE_DIR@/src/nrf8001/lib* \
|
||||
@PROJECT_SOURCE_DIR@/src/nrf8001/hal*
|
||||
|
||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||
# (namespaces, classes, functions, etc.) that should be excluded from the
|
||||
@ -886,7 +890,7 @@ EXAMPLE_RECURSIVE = NO
|
||||
# that contain images that are to be included in the documentation (see the
|
||||
# \image command).
|
||||
|
||||
IMAGE_PATH =
|
||||
IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/docs/images/
|
||||
|
||||
# The INPUT_FILTER tag can be used to specify a program that doxygen should
|
||||
# invoke to filter for each input file. Doxygen will invoke the filter program
|
||||
@ -2209,7 +2213,7 @@ INCLUDE_GRAPH = YES
|
||||
# The default value is: YES.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = NO
|
||||
|
||||
# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
|
||||
# dependency graph for every global function or class method.
|
||||
|
194
DoxygenLayout.xml
Normal file
@ -0,0 +1,194 @@
|
||||
<doxygenlayout version="1.0">
|
||||
<!-- Generated by doxygen 1.8.7 -->
|
||||
<!-- Navigation index tabs for HTML output -->
|
||||
<navindex>
|
||||
<tab type="mainpage" visible="yes" title=""/>
|
||||
<tab type="pages" visible="yes" title="" intro=""/>
|
||||
<tab type="modules" visible="yes" title="" intro=""/>
|
||||
<tab type="namespaces" visible="yes" title="">
|
||||
<tab type="namespacelist" visible="yes" title="" intro=""/>
|
||||
<tab type="namespacemembers" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="classes" visible="yes" title="">
|
||||
<tab type="classlist" visible="yes" title="" intro=""/>
|
||||
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
|
||||
<tab type="hierarchy" visible="yes" title="" intro=""/>
|
||||
<tab type="classmembers" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="files" visible="yes" title="">
|
||||
<tab type="filelist" visible="yes" title="" intro=""/>
|
||||
<tab type="globals" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="examples" visible="yes" title="" intro=""/>
|
||||
</navindex>
|
||||
|
||||
<!-- Layout definition for a class page -->
|
||||
<class>
|
||||
<briefdescription visible="yes"/>
|
||||
<detaileddescription title=""/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<memberdecl>
|
||||
<nestedclasses visible="yes" title=""/>
|
||||
<publictypes title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<publicslots title=""/>
|
||||
<signals title=""/>
|
||||
<publicmethods title=""/>
|
||||
<publicstaticmethods title=""/>
|
||||
<publicattributes title=""/>
|
||||
<publicstaticattributes title=""/>
|
||||
<protectedtypes title=""/>
|
||||
<protectedslots title=""/>
|
||||
<protectedmethods title=""/>
|
||||
<protectedstaticmethods title=""/>
|
||||
<protectedattributes title=""/>
|
||||
<protectedstaticattributes title=""/>
|
||||
<packagetypes title=""/>
|
||||
<packagemethods title=""/>
|
||||
<packagestaticmethods title=""/>
|
||||
<packageattributes title=""/>
|
||||
<packagestaticattributes title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
<privatetypes title=""/>
|
||||
<privateslots title=""/>
|
||||
<privatemethods title=""/>
|
||||
<privatestaticmethods title=""/>
|
||||
<privateattributes title=""/>
|
||||
<privatestaticattributes title=""/>
|
||||
<friends title=""/>
|
||||
<related title="" subtitle=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<constructors title=""/>
|
||||
<functions title=""/>
|
||||
<related title=""/>
|
||||
<variables title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
</memberdef>
|
||||
<allmemberslink visible="yes"/>
|
||||
<inheritancegraph visible="$CLASS_GRAPH"/>
|
||||
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
|
||||
<usedfiles visible="$SHOW_USED_FILES"/>
|
||||
<authorsection visible="yes"/>
|
||||
</class>
|
||||
|
||||
<!-- Layout definition for a namespace page -->
|
||||
<namespace>
|
||||
<briefdescription visible="yes"/>
|
||||
<memberdecl>
|
||||
<nestednamespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</namespace>
|
||||
|
||||
<!-- Layout definition for a file page -->
|
||||
<file>
|
||||
<briefdescription visible="no"/>
|
||||
<includegraph visible="$INCLUDE_GRAPH"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<detaileddescription title="API Description"/>
|
||||
<sourcelink visible="yes"/>
|
||||
<memberdecl>
|
||||
<classes visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<functions title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<functions title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
|
||||
<authorsection/>
|
||||
</file>
|
||||
|
||||
<!-- Layout definition for a group page -->
|
||||
<group>
|
||||
<briefdescription visible="yes"/>
|
||||
<groupgraph visible="$GROUP_GRAPHS"/>
|
||||
<memberdecl>
|
||||
<nestedgroups visible="yes" title=""/>
|
||||
<dirs visible="yes" title=""/>
|
||||
<files visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<pagedocs/>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</group>
|
||||
|
||||
<!-- Layout definition for a directory page -->
|
||||
<directory>
|
||||
<briefdescription visible="yes"/>
|
||||
<directorygraph visible="yes"/>
|
||||
<memberdecl>
|
||||
<dirs visible="yes"/>
|
||||
<files visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
</directory>
|
||||
</doxygenlayout>
|
51
README.md
@ -21,6 +21,57 @@ However implementation and API design is compeltely up to the developer, some
|
||||
enumerable sensors for example may provide much clever instanciation. Displays
|
||||
may also create more complex structures in order to interface with them.
|
||||
|
||||
### Supported Sensors
|
||||
|
||||
Temperature Sensors:
|
||||
* upm::MAX31723
|
||||
* upm::MAX31855
|
||||
* upm::TH02
|
||||
* upm::GroveTemp
|
||||
|
||||
Compass/Gyro/Magnometer Sensors:
|
||||
* upm::Hmc5883l
|
||||
* upm::MPU9150
|
||||
|
||||
Atmospheric Pressure Sensors:
|
||||
* upm::GY65
|
||||
|
||||
Light/Proximity Sensors:
|
||||
* upm::MAXDS3231M
|
||||
* upm::MAX44000
|
||||
* upm::HCSR04
|
||||
* upm::GroveLight
|
||||
|
||||
Gas Sensors:
|
||||
* upm::MQ2
|
||||
* upm::MQ3
|
||||
* upm::MQ5
|
||||
* upm::MQ9
|
||||
|
||||
Displays:
|
||||
* upm::Jhd1313m1
|
||||
* upm::Lcm1602
|
||||
* upm::ST7735
|
||||
* upm::SSD1308
|
||||
* upm::SSD1327
|
||||
|
||||
LED controllers/segment displays:
|
||||
* upm::TM1637
|
||||
* upm::MY9221
|
||||
|
||||
RFID:
|
||||
* upm::SM130
|
||||
|
||||
Wireless Communication:
|
||||
* upm::NRF24l01
|
||||
|
||||
Servo/motors:
|
||||
* upm::ES08A
|
||||
* upm::StepMotor
|
||||
|
||||
Digital potentiometer
|
||||
* upm::MAX5487
|
||||
|
||||
### Building UPM
|
||||
|
||||
See @ref building
|
||||
|
27
TODO
Normal file
@ -0,0 +1,27 @@
|
||||
Easy:
|
||||
MAX7221 - SPI 8 digit LED
|
||||
- https://mbed.org/components/MAX7221/
|
||||
-
|
||||
SCA61T - inclinometer SPI
|
||||
- https://mbed.org/components/SCA61T-Inclinometer/
|
||||
DS1721 - i2c temperature/thermostat
|
||||
- https://mbed.org/components/DS1721/
|
||||
MPL3115A2 - i2c altimeter
|
||||
- https://mbed.org/components/MPL3115A2/
|
||||
- http://www.ebay.co.uk/itm/Barometric-Pressure-Altitude-Temperature-Sensor-I2C-MPL3115A2-/221499210102?pt=UK_BOI_Electrical_Test_Measurement_Equipment_ET&hash=item339261b976
|
||||
TEMT6200 - Ambient light sensor
|
||||
- https://mbed.org/components/TEMT6200/
|
||||
CMPS03 - i2c digital compass
|
||||
- https://mbed.org/components/CMPS03-Digital-Compass/
|
||||
- http://www.ebay.co.uk/itm/Magnetic-Compass-CMPS03-/221437925374?pt=UK_BOI_Electrical_Test_Measurement_Equipment_ET&hash=item338eba97fe
|
||||
- http://www.robot-italy.com/it/cmps03-robot-compass-module.html
|
||||
|
||||
Medium
|
||||
E-ink sharp 1.3" LCD
|
||||
- https://mbed.org/components/13-SHARP-Memory-LCD/
|
||||
LCD-S401
|
||||
- https://mbed.org/components/Lumex-LCD-S401/
|
||||
|
||||
Hard:
|
||||
RA8875 - 480x272 SPI 4 wire
|
||||
- https://mbed.org/components/RA8875-Based-Display/
|
@ -9,7 +9,7 @@ Here are the rules of contribution:
|
||||
is MIT but any permissive license is fine. Please consider that people using
|
||||
UPM may want to write proprietary programs with your sensors so we like to
|
||||
avoid GPL. (LGPL is fine). If your license is not MIT please include a
|
||||
LICENSE file in src/<mymodule>/
|
||||
LICENSE file in src/mymodule/
|
||||
- Please test your module builds before contributing and make sure it works on
|
||||
the latest version of mraa. If you tested on a specific board/platform please
|
||||
tell us what this was in your PR.
|
||||
|
BIN
docs/images/grovegas.jpeg
Normal file
After Width: | Height: | Size: 131 KiB |
BIN
docs/images/grovergblcd.jpeg
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
docs/images/lcm1602.jpeg
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
docs/images/lpd8806.jpeg
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
docs/images/max31723.jpeg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
docs/images/max31855.jpeg
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
docs/images/max44000.jpeg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
docs/images/max5487.jpeg
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
docs/images/mq9.jpeg
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
docs/images/ssd1308.jpeg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
docs/images/ssd1327.jpeg
Normal file
After Width: | Height: | Size: 62 KiB |
@ -93,5 +93,5 @@ target_link_libraries (max31855-example max31855 ${CMAKE_THREAD_LIBS_INIT})
|
||||
~~~~~~~~~~~
|
||||
|
||||
Note you dont have to rebuild everything, cmake keeps target lists so if you
|
||||
named your example target <modulename>-example you can simply do make
|
||||
named your example target modulename-example you can simply do make
|
||||
max31855-example and both the library & example will build.
|
||||
|
@ -9,13 +9,13 @@ example is explained in detail on @ref max31855
|
||||
### Adding a new module to UPM
|
||||
|
||||
1. Choose a name for your module (see @ref naming)
|
||||
2. Make a new folder in src/<modulename>
|
||||
3. Create a CMakeLists.txt file inside src/<modulename>
|
||||
2. Make a new folder in src/modulename
|
||||
3. Create a CMakeLists.txt file inside src/modulename
|
||||
|
||||
### CmakeLists.txt
|
||||
|
||||
By default you need a header called <modulename>.h and a C++ file called
|
||||
<modulename>.cxx. You can have multiple headers and source files. Only public
|
||||
By default you need a header called modulename.h and a C++ file called
|
||||
modulename.cxx. You can have multiple headers and source files. Only public
|
||||
headers need to be added to module_h and all source files need to be in
|
||||
module_src.
|
||||
|
||||
@ -60,6 +60,6 @@ The last step is when you're happy with your module and it works send us a pull
|
||||
request! We'd love to include your sensor in our repository.
|
||||
|
||||
If you don't like github you can also send brendan.le.foll@intel.com a git
|
||||
formatted patch if your sensor. More details are on @ref contributing and on
|
||||
formatted patch if your sensor. More details are on @ref contributions and on
|
||||
https://help.github.com/articles/creating-a-pull-request
|
||||
|
||||
|
@ -27,6 +27,14 @@ add_executable (max5487-example max5487.cxx)
|
||||
add_executable (nrf8001-broadcast-example nrf8001_broadcast.cxx)
|
||||
add_executable (nrf8001-helloworld-example nrf8001_helloworld.cxx)
|
||||
add_executable (lpd8806-example lpd8806-example.cxx)
|
||||
add_executable (mlx90614-example mlx90614-example.cxx)
|
||||
add_executable (ecs1030-example ecs1030-example.cxx)
|
||||
add_executable (mq2-example mq2-example.cxx)
|
||||
add_executable (mq3-example mq3-example.cxx)
|
||||
add_executable (mq5-example mq5-example.cxx)
|
||||
add_executable (mq9-example mq9-example.cxx)
|
||||
add_executable (tcs3414cs-example tcs3414cs-example.cxx)
|
||||
add_executable (th02-example th02-example.cxx)
|
||||
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
|
||||
@ -51,6 +59,11 @@ include_directories (${PROJECT_SOURCE_DIR}/src/max31723)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/max5487)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/nrf8001)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/lpd8806)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/mlx90614)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ecs1030)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/gas)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/tcs3414cs)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/th02)
|
||||
|
||||
target_link_libraries (compass hmc5883l ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveled grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
@ -81,3 +94,11 @@ target_link_libraries (max5487-example max5487 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (nrf8001-broadcast-example nrf8001 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (nrf8001-helloworld-example nrf8001 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (lpd8806-example lpd8806 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mlx90614-example mlx90614 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ecs1030-example ecs1030 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq2-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq3-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq5-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (mq9-example gas ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (tcs3414cs-example tcs3414cs ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (th02-example th02 ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
61
examples/ecs1030-example.cxx
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include "ecs1030.h"
|
||||
|
||||
int is_running = 0;
|
||||
upm::ECS1030 *sensor = NULL;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
printf("got signal\n");
|
||||
if (signo == SIGINT) {
|
||||
is_running = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
sensor = new upm::ECS1030(0);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
while (!is_running) {
|
||||
std::cout << "I = " << sensor->getCurrency_A () << ", Power = " << sensor->getPower_A () << std::endl;
|
||||
std::cout << "I = " << sensor->getCurrency_B () << ", Power = " << sensor->getPower_B () << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "exiting application" << std::endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
//! [Interesting]
|
60
examples/mlx90614-example.cxx
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "mlx90614.h"
|
||||
#include <signal.h>
|
||||
|
||||
int doWork = 0;
|
||||
upm::MLX90614 *sensor = NULL;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
printf("got signal\n");
|
||||
if (signo == SIGINT) {
|
||||
printf("exiting application\n");
|
||||
doWork = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
sensor = new upm::MLX90614(0, DEVICE_ADDR);
|
||||
|
||||
while (!doWork) {
|
||||
std::cout << "Object Temperature (" << sensor->readObjectTempC() << ") Ambient Temperature (" << sensor->readAmbientTempC() << ")" << std::endl;
|
||||
usleep (1000000);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
std::cout << "exiting application" << std::endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
74
examples/mq2-example.cxx
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "mq2.h"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int is_running = 0;
|
||||
uint16_t buffer [128];
|
||||
upm::MQ2 *sensor = NULL;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
printf("got signal\n");
|
||||
if (signo == SIGINT) {
|
||||
is_running = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
sensor = new upm::MQ2(0);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
thresholdContext ctx;
|
||||
ctx.averageReading = 0;
|
||||
ctx.runningAverage = 0;
|
||||
ctx.averagedOver = 2;
|
||||
|
||||
while (!is_running) {
|
||||
int len = sensor->getSampledWindow (2, 128, buffer);
|
||||
if (len) {
|
||||
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
|
||||
sensor->printGraph(&ctx, 5);
|
||||
if (thresh) {
|
||||
// do something ....
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "exiting application" << std::endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
//! [Interesting]
|
74
examples/mq3-example.cxx
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "mq3.h"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int is_running = 0;
|
||||
uint16_t buffer [128];
|
||||
upm::MQ3 *sensor = NULL;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
printf("got signal\n");
|
||||
if (signo == SIGINT) {
|
||||
is_running = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
sensor = new upm::MQ3(0);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
thresholdContext ctx;
|
||||
ctx.averageReading = 0;
|
||||
ctx.runningAverage = 0;
|
||||
ctx.averagedOver = 2;
|
||||
|
||||
while (!is_running) {
|
||||
int len = sensor->getSampledWindow (2, 128, buffer);
|
||||
if (len) {
|
||||
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
|
||||
sensor->printGraph(&ctx, 5);
|
||||
if (thresh) {
|
||||
// do something ....
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "exiting application" << std::endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
//! [Interesting]
|
74
examples/mq5-example.cxx
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "mq5.h"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int is_running = 0;
|
||||
uint16_t buffer [128];
|
||||
upm::MQ5 *sensor = NULL;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
printf("got signal\n");
|
||||
if (signo == SIGINT) {
|
||||
is_running = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
sensor = new upm::MQ5(0);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
thresholdContext ctx;
|
||||
ctx.averageReading = 0;
|
||||
ctx.runningAverage = 0;
|
||||
ctx.averagedOver = 2;
|
||||
|
||||
while (!is_running) {
|
||||
int len = sensor->getSampledWindow (2, 128, buffer);
|
||||
if (len) {
|
||||
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
|
||||
sensor->printGraph(&ctx, 7);
|
||||
if (thresh) {
|
||||
// do something ....
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "exiting application" << std::endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
//! [Interesting]
|
74
examples/mq9-example.cxx
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "mq9.h"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int is_running = 0;
|
||||
uint16_t buffer [128];
|
||||
upm::MQ9 *sensor = NULL;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
printf("got signal\n");
|
||||
if (signo == SIGINT) {
|
||||
is_running = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
sensor = new upm::MQ9(0);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
thresholdContext ctx;
|
||||
ctx.averageReading = 0;
|
||||
ctx.runningAverage = 0;
|
||||
ctx.averagedOver = 2;
|
||||
|
||||
while (!is_running) {
|
||||
int len = sensor->getSampledWindow (2, 128, buffer);
|
||||
if (len) {
|
||||
int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
|
||||
sensor->printGraph(&ctx, 5);
|
||||
if (thresh) {
|
||||
// do something ....
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "exiting application" << std::endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
//! [Interesting]
|
62
examples/tcs3414cs-example.cxx
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "tcs3414cs.h"
|
||||
#include <signal.h>
|
||||
|
||||
int doWork = 0;
|
||||
upm::TCS3414CS *sensor = NULL;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
printf("got signal\n");
|
||||
if (signo == SIGINT) {
|
||||
printf("exiting application\n");
|
||||
doWork = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
upm::tcs3414sc_rgb_t rgb;
|
||||
sensor = new upm::TCS3414CS ();
|
||||
|
||||
while (!doWork) {
|
||||
sensor->readRGB (&rgb);
|
||||
std::cout << (int)rgb.r << ", " << (int)rgb.g << ", " << (int)rgb.b << ", " << rgb.clr << std::endl;
|
||||
usleep (500000);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
std::cout << "exiting application" << std::endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
64
examples/th02-example.cxx
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "th02.h"
|
||||
#include <signal.h>
|
||||
|
||||
int doWork = 0;
|
||||
upm::TH02 *sensor = NULL;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
printf("got signal\n");
|
||||
if (signo == SIGINT) {
|
||||
printf("exiting application\n");
|
||||
doWork = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
float temperature = 0.0;
|
||||
float humidity = 0.0;
|
||||
sensor = new upm::TH02 ();
|
||||
|
||||
while (!doWork) {
|
||||
temperature = sensor->getTemperature ();
|
||||
// humidity = sensor->getHumidity ();
|
||||
std::cout << "Temperature = " << temperature << ", Humidity = " << humidity << std::endl;
|
||||
usleep (500000);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
std::cout << "exiting application" << std::endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
5
src/ecs1030/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
set (libname "ecs1030")
|
||||
set (libdescription "Non-invasive current sensor")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_h ${libname}.h)
|
||||
upm_module_init()
|
101
src/ecs1030/ecs1030.cxx
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ecs1030.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
struct ECS1030Exception : public std::exception {
|
||||
std::string message;
|
||||
ECS1030Exception (std::string msg) : message (msg) { }
|
||||
~ECS1030Exception () throw () { }
|
||||
const char* what() const throw () { return message.c_str(); }
|
||||
};
|
||||
|
||||
ECS1030::ECS1030 (uint8_t pinNumber) {
|
||||
m_dataPinCtx = mraa_aio_init(pinNumber);
|
||||
if (m_dataPinCtx == NULL) {
|
||||
throw ECS1030Exception ("GPIO failed to initilize");
|
||||
}
|
||||
|
||||
m_calibration = 111.1;
|
||||
}
|
||||
|
||||
ECS1030::~ECS1030 () {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
error = mraa_aio_close (m_dataPinCtx);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
ECS1030::getCurrency_A () {
|
||||
int sensorValue = 0;
|
||||
float rLoad = 0;
|
||||
float volt = 0;
|
||||
float rms = 0;
|
||||
|
||||
for (int i = 0; i < NUMBER_OF_SAMPLES; i++) {
|
||||
sensorValue = mraa_aio_read (m_dataPinCtx);
|
||||
volt = (VOLT_M * sensorValue) - 2.5;
|
||||
volt = volt * volt;
|
||||
rms = rms + volt;
|
||||
usleep (DELAY_MS);
|
||||
}
|
||||
|
||||
rms = rms / (float)NUMBER_OF_SAMPLES;
|
||||
rms = sqrt(rms);
|
||||
return rms / R_LOAD;
|
||||
}
|
||||
|
||||
double
|
||||
ECS1030::getCurrency_B () {
|
||||
double sumCurrency = 0;
|
||||
|
||||
for (int i = 0; i < NUMBER_OF_SAMPLES; i++) {
|
||||
m_lastSample = m_sample;
|
||||
m_sample = mraa_aio_read (m_dataPinCtx);
|
||||
m_lastFilter = m_filteredSample;
|
||||
m_filteredSample = 0.996 * (m_lastFilter + m_sample - m_lastSample);
|
||||
sumCurrency += (m_filteredSample * m_filteredSample);
|
||||
}
|
||||
|
||||
double ratio = m_calibration * ((SUPPLYVOLTAGE / 1000.0) / (ADC_RESOLUTION));
|
||||
return ( ratio * sqrt(sumCurrency / NUMBER_OF_SAMPLES) );
|
||||
}
|
||||
|
||||
double
|
||||
ECS1030::getPower_A () {
|
||||
return 220.0 * getCurrency_A ();
|
||||
}
|
||||
|
||||
double
|
||||
ECS1030::getPower_B () {
|
||||
return 220.0 * getCurrency_B ();
|
||||
}
|
97
src/ecs1030/ecs1030.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <math.h>
|
||||
#include <mraa/aio.h>
|
||||
#include <mraa/gpio.h>
|
||||
|
||||
#define NUMBER_OF_SAMPLES 500
|
||||
#define ADC_RESOLUTION 1024
|
||||
#define SUPPLYVOLTAGE 5100
|
||||
#define CURRENT_RATIO 2000.0
|
||||
|
||||
#define HIGH 1
|
||||
#define LOW 0
|
||||
|
||||
#define TRUE HIGH
|
||||
#define FALSE LOW
|
||||
|
||||
namespace upm {
|
||||
class ECS1030 {
|
||||
public:
|
||||
static const uint8_t DELAY_MS = 20000 / NUMBER_OF_SAMPLES; /* 1/50Hz is 20ms period */
|
||||
static const uint8_t VOLT_M = 5.1 / 1023;
|
||||
static const uint8_t R_LOAD = 2000.0 / CURRENT_RATIO;
|
||||
|
||||
/**
|
||||
* Instanciates a ECS1030 (current sensor) object
|
||||
*
|
||||
* @param pinNumber number of the data pin
|
||||
*/
|
||||
ECS1030 (uint8_t pinNumber);
|
||||
|
||||
/**
|
||||
* ECS1030 object destructor, basicaly it close the GPIO.
|
||||
*/
|
||||
~ECS1030 ();
|
||||
|
||||
/**
|
||||
* Return currency data for the sampled period
|
||||
*/
|
||||
double getCurrency_A ();
|
||||
|
||||
/**
|
||||
* Return power data for the sampled period
|
||||
*/
|
||||
double getPower_A ();
|
||||
|
||||
/**
|
||||
* Return currency data for the sampled period
|
||||
*/
|
||||
double getCurrency_B ();
|
||||
|
||||
/**
|
||||
* Return power data for the sampled period
|
||||
*/
|
||||
double getPower_B ();
|
||||
|
||||
/**
|
||||
* Return name of the component
|
||||
*/
|
||||
std::string name() {
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
mraa_aio_context m_dataPinCtx;
|
||||
|
||||
double m_calibration;
|
||||
int m_lastSample;
|
||||
double m_lastFilter;
|
||||
int m_sample;
|
||||
double m_filteredSample;
|
||||
};
|
||||
}
|
8
src/ecs1030/jsupm_ecs1030.i
Normal file
@ -0,0 +1,8 @@
|
||||
%module jsupm_ecs1030
|
||||
%include "../upm.i"
|
||||
|
||||
%{
|
||||
#include "ecs1030.h"
|
||||
%}
|
||||
|
||||
%include "ecs1030.h"
|
11
src/ecs1030/pyupm_ecs1030.i
Normal file
@ -0,0 +1,11 @@
|
||||
%module pyupm_ecs1030
|
||||
%include "../upm.i"
|
||||
|
||||
%include "stdint.i"
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%include "ecs1030.h"
|
||||
%{
|
||||
#include "ecs1030.h"
|
||||
%}
|
5
src/gas/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
set (libname "gas")
|
||||
set (libdescription "Gas sensors")
|
||||
set (module_src ${libname}.cxx mq2.cxx mq3.cxx mq5.cxx mq9.cxx)
|
||||
set (module_h ${libname}.h mq2.h mq3.h mq5.h mq9.h)
|
||||
upm_module_init()
|
6
src/gas/README.txt
Normal file
@ -0,0 +1,6 @@
|
||||
Grove - Gas Sensor(MQ-2):Combustible Gas Smoke [middle sensitivity]
|
||||
Grove - Gas Sensor(MQ-3):Alcohol and Benzine [HIGH sensitivity] Long warmup
|
||||
Grove - Gas Sensor(MQ-5):LPG, Natural Gas, Town Gas [high sensitivity]
|
||||
Grove - Gas Sensor(MQ-9):LPG, CO, CH4 [low sensitivity]
|
||||
|
||||
Note - Gas sensor need to be heated, first minute the data is incorrect.
|
105
src/gas/gas.cxx
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <functional>
|
||||
#include <string.h>
|
||||
#include "gas.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
Gas::Gas(int gasPin) {
|
||||
// initialise analog gas input
|
||||
m_gasCtx = mraa_aio_init(gasPin);
|
||||
}
|
||||
|
||||
Gas::~Gas() {
|
||||
// close analog input
|
||||
mraa_result_t error;
|
||||
error = mraa_aio_close(m_gasCtx);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print(error);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Gas::getSampledWindow (unsigned int freqMS, unsigned int numberOfSamples,
|
||||
uint16_t * buffer) {
|
||||
int sampleIdx = 0;
|
||||
|
||||
// must have freq
|
||||
if (!freqMS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// too much samples
|
||||
if (numberOfSamples > 0xFFFFFF) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (sampleIdx < numberOfSamples) {
|
||||
buffer[sampleIdx++] = mraa_aio_read (m_gasCtx);
|
||||
usleep(freqMS * 1000);
|
||||
}
|
||||
|
||||
return sampleIdx;
|
||||
}
|
||||
|
||||
int
|
||||
Gas::findThreshold (thresholdContext* ctx, unsigned int threshold,
|
||||
uint16_t * buffer, unsigned int len) {
|
||||
long sum = 0;
|
||||
for (unsigned int i = 0; i < len; i++) {
|
||||
sum += buffer[i];
|
||||
}
|
||||
|
||||
ctx->averageReading = sum / len;
|
||||
ctx->runningAverage = (((ctx->averagedOver-1) * ctx->runningAverage) + ctx->averageReading) / ctx->averagedOver;
|
||||
|
||||
if (ctx->runningAverage > threshold) {
|
||||
return ctx->runningAverage;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Gas::getSampledData (thresholdContext* ctx) {
|
||||
return ctx->runningAverage;
|
||||
}
|
||||
|
||||
int
|
||||
Gas::getSample (thresholdContext* ctx) {
|
||||
return mraa_aio_read (m_gasCtx);
|
||||
}
|
||||
|
||||
void
|
||||
Gas::printGraph (thresholdContext* ctx, uint8_t resolution) {
|
||||
std::cout << "(" << ctx->runningAverage << ") | ";
|
||||
for (int i = 0; i < ctx->runningAverage / resolution; i++)
|
||||
std::cout << "*";
|
||||
std::cout << std::endl;
|
||||
}
|
104
src/gas/gas.h
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <mraa/gpio.h>
|
||||
#include <mraa/aio.h>
|
||||
|
||||
struct thresholdContext {
|
||||
long averageReading;
|
||||
long runningAverage;
|
||||
int averagedOver;
|
||||
};
|
||||
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
* @brief C++ API for Gas sensors
|
||||
*
|
||||
* This file defines the Gas Analog sensors virtual functions
|
||||
*/
|
||||
class Gas {
|
||||
public:
|
||||
/**
|
||||
* Instanciates a Gas object
|
||||
*
|
||||
* @param gasPin pin where gas is connected
|
||||
*/
|
||||
Gas(int gasPin);
|
||||
|
||||
/**
|
||||
* Gas object destructor
|
||||
*/
|
||||
~Gas();
|
||||
|
||||
/**
|
||||
* Get samples from gas sensor according to provided window and
|
||||
* number of samples
|
||||
*
|
||||
* @param freqMS time between each sample (in microseconds)
|
||||
* @param numberOfSamples number of sample to sample for this window
|
||||
* @param buffer bufer with sampled data
|
||||
*/
|
||||
virtual int getSampledWindow (unsigned int freqMS, unsigned int numberOfSamples, uint16_t * buffer);
|
||||
|
||||
/**
|
||||
* Given sampled buffer this method will return TRUE/FALSE if threshold
|
||||
* was reached
|
||||
*
|
||||
* @param ctx threshold context
|
||||
* @param threshold sample threshold
|
||||
* @param buffer buffer with samples
|
||||
* @param len bufer len
|
||||
*/
|
||||
virtual int findThreshold (thresholdContext* ctx, unsigned int threshold, uint16_t * buffer, unsigned int len);
|
||||
|
||||
/**
|
||||
* Return avarage data for the sampled window
|
||||
*
|
||||
* @param ctx threshold context
|
||||
*/
|
||||
virtual int getSampledData (thresholdContext* ctx);
|
||||
|
||||
/**
|
||||
* Return one sample from the sensor
|
||||
*
|
||||
* @param ctx threshold context
|
||||
*/
|
||||
virtual int getSample (thresholdContext* ctx);
|
||||
|
||||
/**
|
||||
*
|
||||
* Print running average of threshold context
|
||||
*
|
||||
* @param ctx threshold context
|
||||
*/
|
||||
virtual void printGraph (thresholdContext* ctx, uint8_t resolution);
|
||||
|
||||
protected:
|
||||
mraa_aio_context m_gasCtx;
|
||||
};
|
||||
|
||||
}
|
9
src/gas/jsupm_gas.i
Normal file
@ -0,0 +1,9 @@
|
||||
%module jsupm_gas
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint16_t.i"
|
||||
|
||||
%{
|
||||
#include "gas.h"
|
||||
%}
|
||||
|
||||
%include "gas.h"
|
33
src/gas/mq2.cxx
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "mq2.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
MQ2::MQ2 (int gasPin) : Gas (gasPin) {
|
||||
}
|
||||
|
||||
MQ2::~MQ2 () {
|
||||
}
|
66
src/gas/mq2.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "gas.h"
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
* @brief C++ API for MQ2 gas sensor
|
||||
*
|
||||
* The Grove - Gas Sensor (MQ2) module is useful for gas leakage detecting
|
||||
* (in home and industry). It can detect LPG, i-butane, methane, alcohol,
|
||||
* Hydrogen, smoke and other combustible gases. It's a medium sensitivity
|
||||
* sensor with a detect concentration of 300-10000ppm.
|
||||
*
|
||||
* @snippet mq2-example.cxx Interesting
|
||||
* @image html grovegas.jpeg
|
||||
*/
|
||||
class MQ2 : public Gas {
|
||||
public:
|
||||
/**
|
||||
* MQ2 constructor
|
||||
*
|
||||
* @param gasPin analog pin where sensor connected
|
||||
*/
|
||||
MQ2 (int gasPin);
|
||||
|
||||
/**
|
||||
* MQ2 destructor
|
||||
*/
|
||||
~MQ2 ();
|
||||
|
||||
/**
|
||||
* Return name of the component
|
||||
*/
|
||||
std::string name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
};
|
||||
}
|
33
src/gas/mq3.cxx
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "mq3.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
MQ3::MQ3 (int gasPin) : Gas (gasPin) {
|
||||
}
|
||||
|
||||
MQ3::~MQ3 () {
|
||||
}
|
66
src/gas/mq3.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "gas.h"
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
* @brief C++ API for MQ3 gas sensor
|
||||
*
|
||||
* The Grove MQ3 Gas Sensor module is useful for gas leakage detecting (in
|
||||
* home and industry). It can detect Alcohol Vapour and Benzine. It's
|
||||
* highly sensitive but has a long warmup time of about 1minute. It's
|
||||
* detect rate is of 0.04-4mg/L Alcohol.
|
||||
*
|
||||
* @snippet mq3-example.cxx Interesting
|
||||
* @image html grovegas.jpeg
|
||||
*/
|
||||
class MQ3 : public Gas {
|
||||
public:
|
||||
/**
|
||||
* MQ3 constructor
|
||||
*
|
||||
* @param gasPin analog pin where sensor connected
|
||||
*/
|
||||
MQ3 (int gasPin);
|
||||
|
||||
/**
|
||||
* MQ3 destructor
|
||||
*/
|
||||
~MQ3 ();
|
||||
|
||||
/**
|
||||
* Return name of the component
|
||||
*/
|
||||
std::string name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
};
|
||||
}
|
33
src/gas/mq5.cxx
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "mq5.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
MQ5::MQ5 (int gasPin) : Gas (gasPin) {
|
||||
}
|
||||
|
||||
MQ5::~MQ5 () {
|
||||
}
|
66
src/gas/mq5.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "gas.h"
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
* @brief C++ API for MQ5 gas sensor
|
||||
*
|
||||
* The Grove - Gas Sensor (MQ5) module is useful for gas leakage detecting
|
||||
* (in home and industry). It can detect LPG, natural gas, town gas and so
|
||||
* on. It is highly sensitive and has a detection concentration of
|
||||
* 300-10000ppm.
|
||||
*
|
||||
* @snippet mq5-example.cxx Interesting
|
||||
* @image html grovegas.jpeg
|
||||
*/
|
||||
class MQ5 : public Gas {
|
||||
public:
|
||||
/**
|
||||
* MQ5 constructor
|
||||
*
|
||||
* @param gasPin analog pin where sensor connected
|
||||
*/
|
||||
MQ5 (int gasPin);
|
||||
|
||||
/**
|
||||
* MQ9 destructor
|
||||
*/
|
||||
~MQ5 ();
|
||||
|
||||
/**
|
||||
* Return name of the component
|
||||
*/
|
||||
std::string name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
};
|
||||
}
|
33
src/gas/mq9.cxx
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "mq9.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
MQ9::MQ9 (int gasPin) : Gas (gasPin) {
|
||||
}
|
||||
|
||||
MQ9::~MQ9 () {
|
||||
}
|
65
src/gas/mq9.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "gas.h"
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
* @brief C++ API for MQ9 gas sensor
|
||||
*
|
||||
* The Grove MQ9 Gas Sensor module is useful for gas leakage detecting (in
|
||||
* home and industry). It can detect Carbon Monoxide, Coal Gas and
|
||||
* Liquefied Gas. It's sensitivty is 10-1000ppmCO 100-10000PPm Gas.
|
||||
*
|
||||
* @snippet mq9-example.cxx Interesting
|
||||
* @image html mq9.jpeg
|
||||
*/
|
||||
class MQ9 : public Gas {
|
||||
public:
|
||||
/**
|
||||
* Jhd1313m1 constructor
|
||||
*
|
||||
* @param gasPin analog pin where sensor connected
|
||||
*/
|
||||
MQ9 (int gasPin);
|
||||
|
||||
/**
|
||||
* MQ9 destructor
|
||||
*/
|
||||
~MQ9 ();
|
||||
|
||||
/**
|
||||
* Return name of the component
|
||||
*/
|
||||
std::string name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
};
|
||||
}
|
12
src/gas/pyupm_gas.i
Normal file
@ -0,0 +1,12 @@
|
||||
%module pyupm_gas
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint16_t.i"
|
||||
|
||||
%include "stdint.i"
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%include "gas.h"
|
||||
%{
|
||||
#include "gas.h"
|
||||
%}
|
@ -32,7 +32,14 @@ namespace upm {
|
||||
* @brief C++ API for Jhd1313m1 i2c controller for HD44780 based displays with
|
||||
* an RGB backlight such as the Grove RGB i2c LCD display
|
||||
*
|
||||
* The Jhd1313m1 has two i2c addreses, one belongs to a controller very similar
|
||||
* to the upm::Lcm1602 LCD driver which controls the HD44780 based display and the
|
||||
* other controls solely the backlight. This module was tested with the Seed
|
||||
* [Grove LCD RGB Backlight v2.0 display]
|
||||
* (http://www.seeedstudio.com/depot/Grove-LCD-RGB-Backlight-p-1643.html?cPath=34_36)
|
||||
*
|
||||
* @snippet rgb-lcd.cxx Interesting
|
||||
* @image html grovergblcd.jpeg
|
||||
*/
|
||||
class Jhd1313m1 : public I2CLcd {
|
||||
public:
|
||||
|
@ -37,9 +37,13 @@ namespace upm {
|
||||
*
|
||||
* This supports all sizes of HD44780 displays from 16x2 to 4x20, the
|
||||
* controller has no idea of the actual display hardware so will let you write
|
||||
* further than you can see
|
||||
* further than you can see. These displays with such controllers are available
|
||||
* from various manufacturers with different i2c addresses. The adafruit
|
||||
* [TC1602A-01T](https://www.adafruit.com/datasheets/TC1602A-01T.pdf) seems to
|
||||
* the best documented example.
|
||||
*
|
||||
* @snippet lcm-lcd.cxx Interesting
|
||||
* @image html lcm1602.jpeg
|
||||
*/
|
||||
class Lcm1602 : public I2CLcd {
|
||||
public:
|
||||
|
@ -148,7 +148,15 @@ typedef enum {
|
||||
/**
|
||||
* @brief C++ API for SSD1308 i2c controlled OLED displays
|
||||
*
|
||||
* @snippet lcm-lcd.cxx Interesting
|
||||
* The [SSD1308](http://garden.seeedstudio.com/images/4/46/SSD1308_1.0.pdf) is
|
||||
* a 128x64 Dot matrix OLED/PLED segment driver with controller. This
|
||||
* implementation was tested using the
|
||||
* [Grove LED 128×64 Display module]
|
||||
* (http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_0.96%22)
|
||||
* which is an OLED monochrome display
|
||||
*
|
||||
* @snippet oled-1308.cxx Interesting
|
||||
* @image html ssd1308.jpeg
|
||||
*/
|
||||
class SSD1308 : public I2CLcd {
|
||||
public:
|
||||
|
@ -145,10 +145,23 @@ typedef enum {
|
||||
PAGE = 2
|
||||
} displayAddressingMode;
|
||||
|
||||
/**
|
||||
* @brief C++ API for SSD1327 i2c controlled OLED displays
|
||||
*
|
||||
* The [SSD1327](http://garden.seeedstudio.com/images/8/82/SSD1327_datasheet.pdf)
|
||||
* is a 96x96 Dot matrix OLED/PLED segment driver with controller. This
|
||||
* implementation was tested using the
|
||||
* [Grove LED 96×96 Display module]
|
||||
* (http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_1.12%22)
|
||||
* which is an OLED monochrome display
|
||||
*
|
||||
* @snippet oled-1327.cxx Interesting
|
||||
* @image html ssd1327.jpeg
|
||||
*/
|
||||
class SSD1327 : public I2CLcd {
|
||||
public:
|
||||
/**
|
||||
* SSD1308 Constructor, calls libmraa initialisation functions
|
||||
* SSD1327 Constructor, calls libmraa initialisation functions
|
||||
*
|
||||
* @param bus i2c bus to use
|
||||
* @param address the slave address the lcd is registered on
|
||||
|
@ -36,8 +36,10 @@ namespace upm {
|
||||
/**
|
||||
* @brief C++ API for LPD8806
|
||||
*
|
||||
* This file defines the LPD8806 C++ interface for liblpd8806
|
||||
* The FastPixel lpd8806 is an RGB led strip controller.
|
||||
*
|
||||
* @snippet lpd8806-example.cxx Interesting
|
||||
* @image html lpd8806.jpeg
|
||||
*/
|
||||
class LPD8806 {
|
||||
public:
|
||||
|
@ -36,8 +36,15 @@ namespace upm {
|
||||
/**
|
||||
* @brief C++ API for MAX31723 chip (Temperature sensor)
|
||||
*
|
||||
* This file defines the MAX31723 C++ interface for libmax31723
|
||||
* The Maxim Integrated
|
||||
* [MAX31723](http://datasheets.maximintegrated.com/en/ds/MAX31722-MAX31723.pdf)
|
||||
* is a Low-Voltage 3-Wire/SPI Temperature Sensor controller. This module was
|
||||
* tested on the Maxim Integrated [MAX31732PMB1 PMOD
|
||||
* module](http://datasheets.maximintegrated.com/en/ds/MAX31723PMB1.pdf) from
|
||||
* the analog PMOD kit.
|
||||
*
|
||||
* @snippet max31723.cxx Interesting
|
||||
* @image html max31723.jpeg
|
||||
*/
|
||||
class MAX31723 {
|
||||
public:
|
||||
|
@ -32,12 +32,17 @@ namespace upm {
|
||||
/**
|
||||
* @brief C++ API for MAX31855
|
||||
*
|
||||
* This file defines the max31855 SPI sensor
|
||||
*
|
||||
* @snippet examples/max31855.cxx Interesting
|
||||
* The Maxim Integrated
|
||||
* [MAX31855](http://datasheets.maximintegrated.com/en/ds/MAX31855.pdf)
|
||||
* is a Cold-Junction Compensated Thermocouple-to-Digital Converter. This
|
||||
* module was * tested on the Maxim Integrated
|
||||
* [MAX31855PMB1 PMOD module]
|
||||
* (http://datasheets.maximintegrated.com/en/ds/MAX31855PMB1.pdf) from the
|
||||
* analog PMOD kit.
|
||||
*
|
||||
* @snippet max31855.cxx Interesting
|
||||
* @image html max31855.jpeg
|
||||
*/
|
||||
//! [Interesting]
|
||||
class MAX31855 {
|
||||
public:
|
||||
/**
|
||||
@ -64,6 +69,5 @@ class MAX31855 {
|
||||
mraa_spi_context m_sensor;
|
||||
mraa_gpio_context m_gpio;
|
||||
};
|
||||
//! [Interesting]
|
||||
|
||||
}
|
||||
|
@ -55,20 +55,16 @@ namespace upm {
|
||||
/**
|
||||
* @brief C++ API for MAX44000 chip (Ambient and Infrared Proximity Sensor)
|
||||
*
|
||||
* This file defines the MAX44000 C++ interface for libmax44000
|
||||
*
|
||||
* @snippet proximity.cxx Interesting
|
||||
*
|
||||
* PMOD pins for MAX44000PMB1 board
|
||||
*
|
||||
* ( -= J1 =- )
|
||||
* (1) - NUL
|
||||
* (2) - IRQ
|
||||
* (3) - SCL
|
||||
* (4) - SDA
|
||||
* (5) - GND
|
||||
* (6) - VCC
|
||||
* The Maxim Integrated
|
||||
* [MAX44000](http://datasheets.maximintegrated.com/en/ds/MAX44000.pdf)
|
||||
* is Ambient and Infrared Proximity Sensor. This module was tested on the
|
||||
* Maxim Integrated
|
||||
* [MAX44000PMB1 PMOD module]
|
||||
* (http://datasheets.maximintegrated.com/en/ds/MAX44000PMB1.pdf) from the
|
||||
* analog PMOD kit.
|
||||
*
|
||||
* @snippet max44000.cxx Interesting
|
||||
* @image html max44000.jpeg
|
||||
*/
|
||||
class MAX44000 {
|
||||
public:
|
||||
|
@ -37,18 +37,21 @@ struct MAX5487Exception : public std::exception {
|
||||
const char* what() const throw () { return message.c_str(); }
|
||||
};
|
||||
|
||||
MAX5487::MAX5487 (int csn) {
|
||||
MAX5487::MAX5487 (int csn = -1) {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
m_name = "MAX5487";
|
||||
|
||||
m_csnPinCtx = mraa_gpio_init (csn);
|
||||
if (m_csnPinCtx == NULL) {
|
||||
throw MAX5487Exception ("GPIO failed to initilize");
|
||||
}
|
||||
m_csnPinCtx = NULL;
|
||||
if (csn != -1) {
|
||||
m_csnPinCtx = mraa_gpio_init (csn);
|
||||
if (m_csnPinCtx == NULL) {
|
||||
throw MAX5487Exception ("GPIO failed to initilize");
|
||||
}
|
||||
|
||||
error = mraa_gpio_dir (m_csnPinCtx, MRAA_GPIO_OUT);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
throw MAX5487Exception ("GPIO failed to initilize");
|
||||
error = mraa_gpio_dir (m_csnPinCtx, MRAA_GPIO_OUT);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
throw MAX5487Exception ("GPIO failed to initilize");
|
||||
}
|
||||
}
|
||||
|
||||
m_spi = mraa_spi_init (0);
|
||||
@ -66,9 +69,11 @@ MAX5487::~MAX5487() {
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print(error);
|
||||
}
|
||||
error = mraa_gpio_close (m_csnPinCtx);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print(error);
|
||||
if (m_csnPinCtx != NULL) {
|
||||
error = mraa_gpio_close (m_csnPinCtx);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,10 +113,14 @@ MAX5487::setWiperB (uint8_t wiper) {
|
||||
|
||||
mraa_result_t
|
||||
MAX5487::CSOn () {
|
||||
return mraa_gpio_write (m_csnPinCtx, LOW);
|
||||
if (m_csnPinCtx != NULL)
|
||||
return mraa_gpio_write (m_csnPinCtx, LOW);
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
MAX5487::CSOff () {
|
||||
return mraa_gpio_write (m_csnPinCtx, HIGH);
|
||||
if (m_csnPinCtx != NULL)
|
||||
return mraa_gpio_write (m_csnPinCtx, HIGH);
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
@ -34,10 +34,17 @@
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
* @brief C++ API for MAX5487 chip (Temperature sensor)
|
||||
* @brief C++ API for MAX5487 chip (SPI digital potentionmeter)
|
||||
*
|
||||
* This file defines the MAX5487 C++ interface for libmax5487
|
||||
* The Maxim Integrated
|
||||
* [MAX5487](http://datasheets.maximintegrated.com/en/ds/MAX5487-MAX5489.pdf)
|
||||
* is a Dual, 256-Tap, Nonvolatile, SPI-Interface, Linear-Taper Digital
|
||||
* Potentiometer. This module was tested on the Maxim Integrated [MAX5487PMB1
|
||||
* PMOD module](http://datasheets.maximintegrated.com/en/ds/MAX5487PMB1.pdf)
|
||||
* from the analog PMOD kit.
|
||||
*
|
||||
* @snippet max5487.cxx Interesting
|
||||
* @image html max5487.jpeg
|
||||
*/
|
||||
class MAX5487 {
|
||||
public:
|
||||
@ -47,13 +54,12 @@ class MAX5487 {
|
||||
/**
|
||||
* Instanciates a MAX5487 object
|
||||
*
|
||||
* @param bus number of used bus
|
||||
* @param devAddr addres of used i2c device
|
||||
* @param csn to use if any, by default will use ICSP CS (-1)
|
||||
*/
|
||||
MAX5487 (int csn);
|
||||
|
||||
/**
|
||||
* MAX5487 object destructor, basicaly it close SPI connection and GPIO.
|
||||
* MAX5487 object destructor, closes all IO connections
|
||||
*/
|
||||
~MAX5487 ();
|
||||
|
||||
|
BIN
src/mlx90614/.DS_Store
vendored
Normal file
BIN
src/mlx90614/._.DS_Store
Normal file
5
src/mlx90614/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
set (libname "mlx90614")
|
||||
set (libdescription "Infrared thermometer designed for non-contact emperature sensing")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_h ${libname}.h)
|
||||
upm_module_init()
|
8
src/mlx90614/jsupm_mlx90614.i
Normal file
@ -0,0 +1,8 @@
|
||||
%module jsupm_mlx90614
|
||||
%include "../upm.i"
|
||||
|
||||
%{
|
||||
#include "mlx90614.h"
|
||||
%}
|
||||
|
||||
%include "mlx90614.h"
|
129
src/mlx90614/mlx90614.cxx
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mlx90614.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
struct MLX90614Exception : public std::exception {
|
||||
std::string message;
|
||||
MLX90614Exception (std::string msg) : message (msg) { }
|
||||
~MLX90614Exception () throw () { }
|
||||
const char* what() const throw () { return message.c_str(); }
|
||||
};
|
||||
|
||||
MLX90614::MLX90614 (int bus, int devAddr) {
|
||||
m_name = "MLX90614";
|
||||
|
||||
m_i2cAddr = devAddr;
|
||||
m_bus = bus;
|
||||
|
||||
m_i2Ctx = mraa_i2c_init(m_bus);
|
||||
|
||||
mraa_result_t ret = mraa_i2c_address(m_i2Ctx, m_i2cAddr);
|
||||
if (ret != MRAA_SUCCESS) {
|
||||
throw MLX90614Exception ("Couldn't initilize I2C.");
|
||||
}
|
||||
}
|
||||
|
||||
MLX90614::~MLX90614() {
|
||||
mraa_i2c_stop(m_i2Ctx);
|
||||
}
|
||||
|
||||
float
|
||||
MLX90614::readObjectTempF(void) {
|
||||
return (readTemperature (MLX90614_TOBJ1) * 9 / 5) + 32;
|
||||
}
|
||||
|
||||
float
|
||||
MLX90614::readAmbientTempF(void) {
|
||||
return (readTemperature (MLX90614_TA) * 9 / 5) + 32;
|
||||
}
|
||||
|
||||
float
|
||||
MLX90614::readObjectTempC(void) {
|
||||
return readTemperature (MLX90614_TOBJ1);
|
||||
}
|
||||
|
||||
float
|
||||
MLX90614::readAmbientTempC(void) {
|
||||
return readTemperature (MLX90614_TA);
|
||||
}
|
||||
|
||||
/*
|
||||
* **************
|
||||
* private area
|
||||
* **************
|
||||
*/
|
||||
uint16_t
|
||||
MLX90614::i2cReadReg_N (int reg, unsigned int len, uint8_t * buffer) {
|
||||
int readByte = 0;
|
||||
|
||||
if (m_i2Ctx == NULL) {
|
||||
throw MLX90614Exception ("Couldn't find initilized I2C.");
|
||||
}
|
||||
|
||||
mraa_i2c_address(m_i2Ctx, m_i2cAddr);
|
||||
mraa_i2c_write_byte(m_i2Ctx, reg);
|
||||
|
||||
readByte = mraa_i2c_read(m_i2Ctx, buffer, len);
|
||||
return readByte;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
MLX90614::i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer) {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
if (m_i2Ctx == NULL) {
|
||||
throw MLX90614Exception ("Couldn't find initilized I2C.");
|
||||
}
|
||||
|
||||
error = mraa_i2c_address (m_i2Ctx, m_i2cAddr);
|
||||
error = mraa_i2c_write (m_i2Ctx, buffer, len);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
float
|
||||
MLX90614::readTemperature (uint8_t address) {
|
||||
uint8_t buffer[3];
|
||||
float temperature = 0;
|
||||
|
||||
/* Reading temperature from sensor.
|
||||
Answer contained of 3 bytes (TEMP_LSB | TEMP_MSB | PEC)
|
||||
*/
|
||||
if (i2cReadReg_N (address, 3, buffer) > 2) {
|
||||
temperature = buffer[0];
|
||||
temperature = buffer[1] << 8;
|
||||
|
||||
temperature *= .02;
|
||||
temperature -= 273.15;
|
||||
}
|
||||
|
||||
return temperature;
|
||||
}
|
115
src/mlx90614/mlx90614.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <mraa/i2c.h>
|
||||
|
||||
#define DEVICE_ADDR 0x5A // device address
|
||||
|
||||
// RAM
|
||||
#define MLX90614_RAWIR1 0x04
|
||||
#define MLX90614_RAWIR2 0x05
|
||||
#define MLX90614_TA 0x06
|
||||
#define MLX90614_TOBJ1 0x07
|
||||
#define MLX90614_TOBJ2 0x08
|
||||
// EEPROM
|
||||
#define MLX90614_TOMAX 0x20
|
||||
#define MLX90614_TOMIN 0x21
|
||||
#define MLX90614_PWMCTRL 0x22
|
||||
#define MLX90614_TARANGE 0x23
|
||||
#define MLX90614_EMISS 0x24
|
||||
#define MLX90614_CONFIG 0x25
|
||||
#define MLX90614_ADDR 0x0E
|
||||
#define MLX90614_ID1 0x3C
|
||||
#define MLX90614_ID2 0x3D
|
||||
#define MLX90614_ID3 0x3E
|
||||
#define MLX90614_ID4 0x3F
|
||||
|
||||
#define HIGH 1
|
||||
#define LOW 0
|
||||
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
* @brief C++ API for MLX90614
|
||||
*
|
||||
* This file defines the MLX90614 C++ interface for libmlx90614
|
||||
*
|
||||
*/
|
||||
class MLX90614 {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Instanciates a MLX90614 object
|
||||
*
|
||||
* @param bus number of used bus
|
||||
* @param devAddr addres of used i2c device
|
||||
*/
|
||||
MLX90614 (int bus, int devAddr);
|
||||
|
||||
/**
|
||||
* MLX90614 object destructor, basicaly it close i2c connection.
|
||||
*/
|
||||
~MLX90614 ();
|
||||
|
||||
/**
|
||||
* Read object temperature in Fahrenheit
|
||||
*/
|
||||
float readObjectTempF(void);
|
||||
|
||||
/**
|
||||
* Read ambient temperature in Fahrenheit
|
||||
*/
|
||||
float readAmbientTempF(void);
|
||||
/**
|
||||
* Read object temperature in Celsius
|
||||
*/
|
||||
float readObjectTempC(void);
|
||||
|
||||
/**
|
||||
* Read ambient temperature in Celsius
|
||||
*/
|
||||
float readAmbientTempC(void);
|
||||
|
||||
/**
|
||||
* Return name of the component
|
||||
*/
|
||||
std::string name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
|
||||
int m_i2cAddr;
|
||||
int m_bus;
|
||||
mraa_i2c_context m_i2Ctx;
|
||||
|
||||
uint16_t i2cReadReg_N (int reg, unsigned int len, uint8_t * buffer);
|
||||
mraa_result_t i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer);
|
||||
float readTemperature (uint8_t address);
|
||||
};
|
||||
|
||||
}
|
9
src/mlx90614/pyupm_mlx90614.i
Normal file
@ -0,0 +1,9 @@
|
||||
%module pyupm_mlx90614
|
||||
%include "../upm.i"
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%include "mlx90614.h"
|
||||
%{
|
||||
#include "mlx90614.h"
|
||||
%}
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"name" : "jsupm_@libname@",
|
||||
"main" : "./jsupm_@libname@.node",
|
||||
"engines": {
|
||||
"version" : "@upm_VERSION_STRING@",
|
||||
"engines" : {
|
||||
"node": ">= 1.0.x"
|
||||
},
|
||||
"license": "MIT"
|
||||
|
@ -44,7 +44,6 @@ namespace upm {
|
||||
* @brief C++ API for SM130 RFID reader module
|
||||
*
|
||||
* This file defines the SM130 C++ interface for libsm130
|
||||
*
|
||||
*/
|
||||
class SM130 {
|
||||
|
||||
|
BIN
src/tcs3414cs/.DS_Store
vendored
Normal file
BIN
src/tcs3414cs/._.DS_Store
Normal file
5
src/tcs3414cs/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
set (libname "tcs3414cs")
|
||||
set (libdescription "I2C Color sensor")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_h ${libname}.h)
|
||||
upm_module_init()
|
8
src/tcs3414cs/jsupm_tcs3414cs.i
Normal file
@ -0,0 +1,8 @@
|
||||
%module jsupm_tcs3414cs
|
||||
%include "../upm.i"
|
||||
|
||||
%{
|
||||
#include "tcs3414cs.h"
|
||||
%}
|
||||
|
||||
%include "tcs3414cs.h"
|
9
src/tcs3414cs/pyupm_tcs3414cs.i
Normal file
@ -0,0 +1,9 @@
|
||||
%module pyupm_tcs3414cs
|
||||
%include "../upm.i"
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%include "tcs3414cs.h"
|
||||
%{
|
||||
#include "tcs3414cs.h"
|
||||
%}
|
156
src/tcs3414cs/tcs3414cs.cxx
Normal file
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Credits to Seeed Studeo.
|
||||
* Based on Seeed Studeo code example,
|
||||
* http://www.seeedstudio.com/wiki/index.php?title=Twig_-_I2C_Color_Sensor_v0.9b.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#include "tcs3414cs.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
struct TCS3414CSException : public std::exception {
|
||||
std::string message;
|
||||
TCS3414CSException (std::string msg) : message (msg) { }
|
||||
~TCS3414CSException () throw () { }
|
||||
const char* what() const throw () { return message.c_str(); }
|
||||
};
|
||||
|
||||
TCS3414CS::TCS3414CS () {
|
||||
m_name = "TCS3414CS";
|
||||
m_i2Ctx = mraa_i2c_init(0);
|
||||
|
||||
mraa_result_t ret = mraa_i2c_address(m_i2Ctx, ADDR);
|
||||
if (ret != MRAA_SUCCESS) {
|
||||
throw TCS3414CSException ("Couldn't initilize I2C.");
|
||||
}
|
||||
|
||||
// Set timing register
|
||||
i2cWriteReg (REG_TIMING, INTEG_MODE_FREE);
|
||||
usleep (100000);
|
||||
|
||||
// Set interrupt source register
|
||||
i2cWriteReg (REG_INT_SOURCE, INT_SOURCE_GREEN);
|
||||
usleep (100000);
|
||||
|
||||
// Set interrupt control register
|
||||
i2cWriteReg (REG_INT, INTR_LEVEL | INTR_PERSIST_EVERY);
|
||||
usleep (100000);
|
||||
|
||||
// Set gain
|
||||
i2cWriteReg (REG_GAIN, GAIN_1 | PRESCALER_4);
|
||||
usleep (100000);
|
||||
|
||||
// Enable ADC
|
||||
i2cWriteReg (REG_CTL, CTL_DAT_INIITIATE);
|
||||
usleep (100000);
|
||||
}
|
||||
|
||||
TCS3414CS::~TCS3414CS () {
|
||||
mraa_i2c_stop(m_i2Ctx);
|
||||
}
|
||||
|
||||
void
|
||||
TCS3414CS::readRGB (tcs3414sc_rgb_t * rgb) {
|
||||
uint8_t buffer[8];
|
||||
|
||||
// We need 7 bytes of data.
|
||||
if (i2cReadReg_N (REG_BLOCK_READ, 8, buffer) > 7) {
|
||||
rgb->g = buffer[1] * 256 + buffer[0];
|
||||
rgb->r = buffer[3] * 256 + buffer[2];
|
||||
rgb->b = buffer[5] * 256 + buffer[4];
|
||||
rgb->clr = buffer[7] * 256 + buffer[6];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TCS3414CS::clearInterrupt () {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
if (m_i2Ctx == NULL) {
|
||||
throw TCS3414CSException ("Couldn't find initilized I2C.");
|
||||
}
|
||||
|
||||
error = mraa_i2c_address (m_i2Ctx, ADDR);
|
||||
error = mraa_i2c_write_byte (m_i2Ctx, CLR_INT);
|
||||
|
||||
if (error != MRAA_SUCCESS) {
|
||||
throw TCS3414CSException ("Couldn't clear interrupt.");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* **************
|
||||
* private area
|
||||
* **************
|
||||
*/
|
||||
uint16_t
|
||||
TCS3414CS::i2cReadReg_N (int reg, unsigned int len, uint8_t * buffer) {
|
||||
int readByte = 0;
|
||||
|
||||
if (m_i2Ctx == NULL) {
|
||||
throw TCS3414CSException ("Couldn't find initilized I2C.");
|
||||
}
|
||||
|
||||
mraa_i2c_address(m_i2Ctx, ADDR);
|
||||
mraa_i2c_write_byte(m_i2Ctx, reg);
|
||||
|
||||
mraa_i2c_address(m_i2Ctx, ADDR);
|
||||
readByte = mraa_i2c_read(m_i2Ctx, buffer, len);
|
||||
return readByte;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
TCS3414CS::i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer) {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
if (m_i2Ctx == NULL) {
|
||||
throw TCS3414CSException ("Couldn't find initilized I2C.");
|
||||
}
|
||||
|
||||
error = mraa_i2c_address (m_i2Ctx, ADDR);
|
||||
error = mraa_i2c_write_byte (m_i2Ctx, reg);
|
||||
error = mraa_i2c_write (m_i2Ctx, buffer, len);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
TCS3414CS::i2cWriteReg (uint8_t reg, uint8_t data) {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
if (m_i2Ctx == NULL) {
|
||||
throw TCS3414CSException ("Couldn't find initilized I2C.");
|
||||
}
|
||||
|
||||
error = mraa_i2c_address (m_i2Ctx, ADDR);
|
||||
error = mraa_i2c_write_byte (m_i2Ctx, reg);
|
||||
error = mraa_i2c_write_byte (m_i2Ctx, data);
|
||||
|
||||
return error;
|
||||
}
|
155
src/tcs3414cs/tcs3414cs.h
Normal file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Credits to Seeed Studeo.
|
||||
* Based on Seeed Studeo code example,
|
||||
* http://www.seeedstudio.com/wiki/index.php?title=Twig_-_I2C_Color_Sensor_v0.9b.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <mraa/i2c.h>
|
||||
|
||||
#define ADDR 0x39 // device address
|
||||
|
||||
#define REG_CTL 0x80
|
||||
#define REG_TIMING 0x81
|
||||
#define REG_INT 0x82
|
||||
#define REG_INT_SOURCE 0x83
|
||||
#define REG_ID 0x84
|
||||
#define REG_GAIN 0x87
|
||||
#define REG_LOW_THRESH_LOW_BYTE 0x88
|
||||
#define REG_LOW_THRESH_HIGH_BYTE 0x89
|
||||
#define REG_HIGH_THRESH_LOW_BYTE 0x8A
|
||||
#define REG_HIGH_THRESH_HIGH_BYTE 0x8B
|
||||
#define REG_BLOCK_READ 0xCF
|
||||
#define REG_GREEN_LOW 0xD0
|
||||
#define REG_GREEN_HIGH 0xD1
|
||||
#define REG_RED_LOW 0xD2
|
||||
#define REG_RED_HIGH 0xD3
|
||||
#define REG_BLUE_LOW 0xD4
|
||||
#define REG_BLUE_HIGH 0xD5
|
||||
#define REG_CLEAR_LOW 0xD6
|
||||
#define REG_CLEAR_HIGH 0xD7
|
||||
#define CTL_DAT_INIITIATE 0x03
|
||||
#define CLR_INT 0xE0
|
||||
|
||||
/* Timing Register */
|
||||
#define SYNC_EDGE 0x40
|
||||
#define INTEG_MODE_FREE 0x00
|
||||
#define INTEG_MODE_MANUAL 0x10
|
||||
#define INTEG_MODE_SYN_SINGLE 0x20
|
||||
#define INTEG_MODE_SYN_MULTI 0x30
|
||||
|
||||
#define INTEG_PARAM_PULSE_COUNT1 0x00
|
||||
#define INTEG_PARAM_PULSE_COUNT2 0x01
|
||||
#define INTEG_PARAM_PULSE_COUNT4 0x02
|
||||
#define INTEG_PARAM_PULSE_COUNT8 0x03
|
||||
|
||||
/* Interrupt Control Register */
|
||||
#define INTR_STOP 40
|
||||
#define INTR_DISABLE 0x00
|
||||
#define INTR_LEVEL 0x10
|
||||
#define INTR_PERSIST_EVERY 0x00
|
||||
#define INTR_PERSIST_SINGLE 0x01
|
||||
|
||||
/* Interrupt Souce Register */
|
||||
#define INT_SOURCE_GREEN 0x00
|
||||
#define INT_SOURCE_RED 0x01
|
||||
#define INT_SOURCE_BLUE 0x10
|
||||
#define INT_SOURCE_CLEAR 0x03
|
||||
|
||||
/* Gain Register */
|
||||
#define GAIN_1 0x00
|
||||
#define GAIN_4 0x10
|
||||
#define GAIN_16 0x20
|
||||
#define GANI_64 0x30
|
||||
#define PRESCALER_1 0x00
|
||||
#define PRESCALER_2 0x01
|
||||
#define PRESCALER_4 0x02
|
||||
#define PRESCALER_8 0x03
|
||||
#define PRESCALER_16 0x04
|
||||
#define PRESCALER_32 0x05
|
||||
#define PRESCALER_64 0x06
|
||||
|
||||
#define HIGH 1
|
||||
#define LOW 0
|
||||
|
||||
namespace upm {
|
||||
|
||||
typedef struct {
|
||||
uint16_t r;
|
||||
uint16_t g;
|
||||
uint16_t b;
|
||||
uint16_t clr;
|
||||
} tcs3414sc_rgb_t;
|
||||
|
||||
/**
|
||||
* @brief C++ API for TCS3414CS chip (Color sensor)
|
||||
*
|
||||
* This file defines the TCS3414CS C++ interface for libtcs3414cs
|
||||
*
|
||||
*/
|
||||
class TCS3414CS {
|
||||
public:
|
||||
/**
|
||||
* Instanciates a TCS3414CS object
|
||||
*
|
||||
* @param bus number of used bus
|
||||
*/
|
||||
TCS3414CS ();
|
||||
|
||||
/**
|
||||
* TCS3414CS object destructor, basicaly it close i2c connection.
|
||||
*/
|
||||
~TCS3414CS ();
|
||||
|
||||
/**
|
||||
* Get the RGB value from sensor.
|
||||
*
|
||||
* @param rgb color values
|
||||
*/
|
||||
void readRGB (tcs3414sc_rgb_t * rgb);
|
||||
|
||||
/**
|
||||
* Clear interrupts.
|
||||
*/
|
||||
void clearInterrupt ();
|
||||
|
||||
/**
|
||||
* Return name of the component
|
||||
*/
|
||||
std::string name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
mraa_i2c_context m_i2Ctx;
|
||||
|
||||
uint16_t i2cReadReg_N (int reg, unsigned int len, uint8_t * buffer);
|
||||
mraa_result_t i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer);
|
||||
mraa_result_t i2cWriteReg (uint8_t reg, uint8_t data);
|
||||
};
|
||||
|
||||
}
|
5
src/th02/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
set (libname "th02")
|
||||
set (libdescription "Temperature and Humidity Sensor Pro")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_h ${libname}.h)
|
||||
upm_module_init()
|
8
src/th02/jsupm_th02.i
Normal file
@ -0,0 +1,8 @@
|
||||
%module jsupm_th02
|
||||
%include "../upm.i"
|
||||
|
||||
%{
|
||||
#include "th02.h"
|
||||
%}
|
||||
|
||||
%include "th02.h"
|
9
src/th02/pyupm_th02.i
Normal file
@ -0,0 +1,9 @@
|
||||
%module pyupm_th02
|
||||
%include "../upm.i"
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%include "th02.h"
|
||||
%{
|
||||
#include "th02.h"
|
||||
%}
|
160
src/th02/th02.cxx
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Credits to Seeed Studeo.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#include "th02.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
struct TH02Exception : public std::exception {
|
||||
std::string message;
|
||||
TH02Exception (std::string msg) : message (msg) { }
|
||||
~TH02Exception () throw () { }
|
||||
const char* what() const throw () { return message.c_str(); }
|
||||
};
|
||||
|
||||
TH02::TH02 () {
|
||||
m_name = "TH02";
|
||||
m_i2Ctx = mraa_i2c_init(0);
|
||||
|
||||
mraa_result_t ret = mraa_i2c_address(m_i2Ctx, ADDR);
|
||||
if (ret != MRAA_SUCCESS) {
|
||||
throw TH02Exception ("Couldn't initilize I2C.");
|
||||
}
|
||||
}
|
||||
|
||||
TH02::~TH02 () {
|
||||
mraa_i2c_stop(m_i2Ctx);
|
||||
}
|
||||
|
||||
float
|
||||
TH02::getTemperature () {
|
||||
uint8_t buffer[3];
|
||||
uint16_t temperature = 0;
|
||||
|
||||
/* Start a new temperature conversion */
|
||||
i2cWriteReg (REG_CONFIG, CMD_MEASURE_TEMP);
|
||||
|
||||
/* Wait until conversion is done */
|
||||
while (getStatus() == false);
|
||||
|
||||
if (i2cReadReg_N (REG_DATA_H, 3, buffer) > 2) {
|
||||
temperature = (buffer[1] << 8) | buffer[2];
|
||||
temperature >>= 2;
|
||||
|
||||
return (temperature / 32.0) - 50.0;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
float
|
||||
TH02::getHumidity () {
|
||||
uint8_t buffer[3];
|
||||
uint16_t humidity = 0;
|
||||
|
||||
/* Start a new humility conversion */
|
||||
i2cWriteReg (REG_CONFIG, CMD_MEASURE_HUMI);
|
||||
|
||||
/* Wait until conversion is done */
|
||||
while (getStatus() == false);
|
||||
|
||||
if (i2cReadReg_N (REG_DATA_H, 3, buffer) > 2) {
|
||||
humidity = (buffer[1] << 8) | buffer[2];
|
||||
humidity >>= 4;
|
||||
|
||||
return (humidity / 16.0) - 24.0;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool
|
||||
TH02::getStatus () {
|
||||
uint8_t buffer[1];
|
||||
|
||||
if (i2cReadReg_N (REG_STATUS, 1, buffer) > 0) {
|
||||
if (buffer[0] & STATUS_RDY_MASK) {
|
||||
return true; // ready
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* **************
|
||||
* private area
|
||||
* **************
|
||||
*/
|
||||
uint16_t
|
||||
TH02::i2cReadReg_N (int reg, unsigned int len, uint8_t * buffer) {
|
||||
int readByte = 0;
|
||||
|
||||
if (m_i2Ctx == NULL) {
|
||||
throw TH02Exception ("Couldn't find initilized I2C.");
|
||||
}
|
||||
|
||||
mraa_i2c_address(m_i2Ctx, ADDR);
|
||||
mraa_i2c_write_byte(m_i2Ctx, reg);
|
||||
|
||||
mraa_i2c_address(m_i2Ctx, ADDR);
|
||||
readByte = mraa_i2c_read(m_i2Ctx, buffer, len);
|
||||
return readByte;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
TH02::i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer) {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
if (m_i2Ctx == NULL) {
|
||||
throw TH02Exception ("Couldn't find initilized I2C.");
|
||||
}
|
||||
|
||||
error = mraa_i2c_address (m_i2Ctx, ADDR);
|
||||
error = mraa_i2c_write_byte (m_i2Ctx, reg);
|
||||
error = mraa_i2c_write (m_i2Ctx, buffer, len);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
TH02::i2cWriteReg (uint8_t reg, uint8_t data) {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
if (m_i2Ctx == NULL) {
|
||||
throw TH02Exception ("Couldn't find initilized I2C.");
|
||||
}
|
||||
|
||||
error = mraa_i2c_address (m_i2Ctx, ADDR);
|
||||
error = mraa_i2c_write_byte (m_i2Ctx, reg);
|
||||
error = mraa_i2c_write_byte (m_i2Ctx, data);
|
||||
|
||||
return error;
|
||||
}
|
103
src/th02/th02.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Credits to Seeed Studeo.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <mraa/i2c.h>
|
||||
|
||||
#define ADDR 0x40 // device address
|
||||
|
||||
#define REG_STATUS 0x00
|
||||
#define REG_DATA_H 0x01
|
||||
#define REG_DATA_L 0x02
|
||||
#define REG_CONFIG 0x03
|
||||
#define REG_ID 0x11
|
||||
|
||||
#define STATUS_RDY_MASK 0x01
|
||||
|
||||
#define CMD_MEASURE_HUMI 0x01
|
||||
#define CMD_MEASURE_TEMP 0x11
|
||||
|
||||
#define TH02_WR_REG_MODE 0xC0
|
||||
#define TH02_RD_REG_MODE 0x80
|
||||
|
||||
#define HIGH 1
|
||||
#define LOW 0
|
||||
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
* @brief C++ API for TH02 chip (Temperature and Humidity Sensor Pro)
|
||||
*
|
||||
* This file defines the TH02 C++ interface for libth02
|
||||
*
|
||||
* @snippet th02-example.cxx Interesting
|
||||
*
|
||||
*/
|
||||
class TH02 {
|
||||
public:
|
||||
/**
|
||||
* Instanciates a TH02 object
|
||||
*/
|
||||
TH02 ();
|
||||
|
||||
/**
|
||||
* TH02 object destructor, basicaly it close i2c connection.
|
||||
*/
|
||||
~TH02 ();
|
||||
|
||||
/**
|
||||
* Get the temperature value from sensor.
|
||||
*/
|
||||
float getTemperature ();
|
||||
|
||||
/**
|
||||
* Get the humidity value from sensor.
|
||||
*/
|
||||
float getHumidity ();
|
||||
|
||||
/**
|
||||
* Get the sensor's status.
|
||||
*/
|
||||
bool getStatus ();
|
||||
|
||||
/**
|
||||
* Return name of the component
|
||||
*/
|
||||
std::string name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
mraa_i2c_context m_i2Ctx;
|
||||
|
||||
uint16_t i2cReadReg_N (int reg, unsigned int len, uint8_t * buffer);
|
||||
mraa_result_t i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer);
|
||||
mraa_result_t i2cWriteReg (uint8_t reg, uint8_t data);
|
||||
};
|
||||
|
||||
}
|