micsv89: Initial support for MICSV89

Signed off by: Marc Graham <marc@m2ag.net>

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Marc Graham
2015-09-24 16:30:38 -07:00
committed by Mihai Tudor Panu
parent 1040b4e51f
commit bf856c5fca
11 changed files with 350 additions and 0 deletions

View File

@ -146,6 +146,7 @@ add_executable (wheelencoder-example wheelencoder.cxx)
add_executable (sm130-example sm130.cxx)
add_executable (grovegprs-example grovegprs.cxx)
add_executable (lm35-example lm35.cxx)
add_executable (micsv89-example micsv89.cxx)
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
@ -257,6 +258,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/wheelencoder)
include_directories (${PROJECT_SOURCE_DIR}/src/sm130)
include_directories (${PROJECT_SOURCE_DIR}/src/grovegprs)
include_directories (${PROJECT_SOURCE_DIR}/src/lm35)
include_directories (${PROJECT_SOURCE_DIR}/src/micsv89)
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
@ -404,3 +406,4 @@ target_link_libraries (wheelencoder-example wheelencoder ${CMAKE_THREAD_LIBS_INI
target_link_libraries (sm130-example sm130 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovegprs-example grovegprs ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (lm35-example lm35 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (micsv89-example micsv89 ${CMAKE_THREAD_LIBS_INIT})

78
examples/c++/micsv89.cxx Normal file
View File

@ -0,0 +1,78 @@
/*
* Author: Marc Graham <marc@m2ag.net>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "mraa.hpp"
#include <iostream>
#include <unistd.h>
#include "micsv89.h"
/*
* An example for using the MICSV89 sensor library.
* The MICSV89 comes in 4 variants, PWM and I2c
* in 3.3 volts and 5 volts. This library only implements
* the I2c version of the device.
*
* Device output is not valid until a warm up of 15 minutes
* of operation.
*
* Additional linker flags: none
*/
using namespace std;
upm::MICSV89 *sensor = NULL;
int main()
{
sensor = new upm::MICSV89(6);
while(true)
{
sensor->start();
while(!sensor->valid());
cout << "co2: " << sensor->co2equ() << endl;
cout << "short: " << sensor->vocshort() << endl;
cout << "tvoc: " << sensor->tvoc() << endl;
cout << "resistor: " << sensor->resistor() << endl;
cout << "****************************" << endl;
sleep(5);
}
delete sensor;
return MRAA_SUCCESS;
}