ldt0028: Added support for LDT0-028 PZT film-based sensors

Signed-off-by: Sarah Knepper <sarah.knepper@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
sknepper
2014-11-18 14:38:36 -08:00
committed by Brendan Le Foll
parent 931c8e8814
commit c5369315e9
9 changed files with 388 additions and 0 deletions

View File

@ -0,0 +1,5 @@
set (libname "ldt0028")
set (libdescription "upm ldt0028")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -0,0 +1,8 @@
%module jsupm_ldt0028
%include "../upm.i"
%{
#include "ldt0028.h"
%}
%include "ldt0028.h"

46
src/ldt0028/ldt0028.cxx Normal file
View File

@ -0,0 +1,46 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "ldt0028.h"
using namespace upm;
LDT0028::LDT0028(unsigned int pin) {
// initialize analog input
m_pin = mraa_aio_init(pin);
m_name = "ldt0-028";
}
LDT0028::~LDT0028() {
// close analog input
mraa_aio_close(m_pin);
}
std::string LDT0028::name() {
return m_name;
}
int LDT0028::getSample() {
return mraa_aio_read(m_pin);
}

78
src/ldt0028/ldt0028.h Normal file
View File

@ -0,0 +1,78 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.h>
namespace upm {
/**
* @brief LDT0-028 Piezo Vibration sensor library
* @defgroup ldt0028 libupm-ldt0028
*/
/**
* @brief C++ API for LDT0-028 PZT film-based sensors,
* such as the Grove Piezo Vibration sensor
*
* This file defines the LDT0028 C++ interface for libupm-ldt0028
*
* @ingroup ldt0028 aio
* @snippet ldt0028.cxx Interesting
*/
class LDT0028 {
public:
/**
* LDT0028 Piezo Vibration sensor constructor
*
* @param pin AIO pin where sensor is connected
*/
LDT0028(unsigned int pin);
/**
* LDT0028 destructor
*/
~LDT0028();
/**
* Return name of this sensor
*
* @return the name of this sensor
*/
std::string name();
/**
* Return one sample from this sensor
*
* @return one value from this sensor
*/
int getSample();
protected:
std::string m_name; //!< name of this sensor
mraa_aio_context m_pin; //!< AIO pin
};
}

View File

@ -0,0 +1,10 @@
%module pyupm_ldt0028
%include "../upm.i"
%feature("autodoc", "3");
%include "ldt0028.h"
%{
#include "ldt0028.h"
%}