mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
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:
parent
931c8e8814
commit
c5369315e9
@ -44,6 +44,7 @@ add_executable (nrf_ble_broadcast-example ble_broadcast.cxx)
|
|||||||
add_executable (tsl2561-example tsl2561.cxx)
|
add_executable (tsl2561-example tsl2561.cxx)
|
||||||
add_executable (htu21d-example htu21d.cxx)
|
add_executable (htu21d-example htu21d.cxx)
|
||||||
add_executable (mpl3115a2-example mpl3115a2.cxx)
|
add_executable (mpl3115a2-example mpl3115a2.cxx)
|
||||||
|
add_executable (ldt0028-example ldt0028.cxx)
|
||||||
|
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
|
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
|
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
|
||||||
@ -79,6 +80,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/lol)
|
|||||||
include_directories (${PROJECT_SOURCE_DIR}/src/tsl2561)
|
include_directories (${PROJECT_SOURCE_DIR}/src/tsl2561)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/htu21d)
|
include_directories (${PROJECT_SOURCE_DIR}/src/htu21d)
|
||||||
include_directories (${PROJECT_SOURCE_DIR}/src/mpl3115a2)
|
include_directories (${PROJECT_SOURCE_DIR}/src/mpl3115a2)
|
||||||
|
include_directories (${PROJECT_SOURCE_DIR}/src/ldt0028)
|
||||||
|
|
||||||
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||||
@ -126,3 +128,4 @@ target_link_libraries (nrf_ble_broadcast-example nrf24l01 ${CMAKE_THREAD_LIBS_IN
|
|||||||
target_link_libraries (tsl2561-example tsl2561 ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (tsl2561-example tsl2561 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (htu21d-example htu21d ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (htu21d-example htu21d ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (mpl3115a2-example mpl3115a2 ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (mpl3115a2-example mpl3115a2 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
target_link_libraries (ldt0028-example ldt0028 ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
82
examples/javascript/ldt0028.js
Normal file
82
examples/javascript/ldt0028.js
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load Grove module
|
||||||
|
var sensorModule = require('jsupm_ldt0028');
|
||||||
|
|
||||||
|
var NUMBER_OF_SECONDS = 10;
|
||||||
|
var MILLISECONDS_PER_SECOND = 1000;
|
||||||
|
var SAMPLES_PER_SECOND = 50;
|
||||||
|
var THRESHOLD = 100;
|
||||||
|
|
||||||
|
// Create the LDT0-028 Piezo Vibration Sensor object using AIO pin 0
|
||||||
|
var sensor = new sensorModule.LDT0028(0);
|
||||||
|
|
||||||
|
// Read the signal every 20 milliseconds for 10 seconds
|
||||||
|
console.log("For the next " + NUMBER_OF_SECONDS + " seconds, " +
|
||||||
|
SAMPLES_PER_SECOND + " samples will be taken every second.");
|
||||||
|
console.log("");
|
||||||
|
var buffer = [];
|
||||||
|
for (var i=0; i < NUMBER_OF_SECONDS * SAMPLES_PER_SECOND; i++) {
|
||||||
|
buffer.push(sensor.getSample());
|
||||||
|
delay(MILLISECONDS_PER_SECOND / SAMPLES_PER_SECOND );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print the number of times the reading was greater than the threshold
|
||||||
|
var count = 0;
|
||||||
|
for (var i=0; i < NUMBER_OF_SECONDS * SAMPLES_PER_SECOND; i++) {
|
||||||
|
if (buffer[i] > THRESHOLD) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(sensor.name() + " exceeded the threshold value of " +
|
||||||
|
THRESHOLD + " a total of " + count + " times,");
|
||||||
|
console.log("out of a total of " + NUMBER_OF_SECONDS*SAMPLES_PER_SECOND +
|
||||||
|
" readings.");
|
||||||
|
console.log("");
|
||||||
|
|
||||||
|
// Print a graphical representation of the average value sampled
|
||||||
|
// each second for the past 10 seconds, using a scale factor of 15
|
||||||
|
console.log("Now printing a graphical representation of the average reading ");
|
||||||
|
console.log("each second for the last " + NUMBER_OF_SECONDS + " seconds.");
|
||||||
|
var SCALE_FACTOR = 15;
|
||||||
|
for (var i=0; i < NUMBER_OF_SECONDS; i++) {
|
||||||
|
var sum = 0;
|
||||||
|
for (var j=0; j < SAMPLES_PER_SECOND; j++) {
|
||||||
|
sum += buffer[i*SAMPLES_PER_SECOND+j];
|
||||||
|
}
|
||||||
|
var average = sum / SAMPLES_PER_SECOND;
|
||||||
|
var stars_to_print = Math.round(average / SCALE_FACTOR);
|
||||||
|
var string = "(" + (" " + Math.round(average)).slice(-4) + ") | ";
|
||||||
|
for (var j=0; j < stars_to_print; j++) {
|
||||||
|
string += "*";
|
||||||
|
}
|
||||||
|
console.log(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
function delay( milliseconds ) {
|
||||||
|
var startTime = Date.now();
|
||||||
|
while (Date.now() - startTime < milliseconds);
|
||||||
|
}
|
||||||
|
|
90
examples/ldt0028.cxx
Normal file
90
examples/ldt0028.cxx
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* 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 <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <cmath>
|
||||||
|
#include "ldt0028.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
//! [Interesting]
|
||||||
|
const int NUMBER_OF_SECONDS = 10;
|
||||||
|
const int MICROSECONDS_PER_SECOND = 1000000;
|
||||||
|
const int SAMPLES_PER_SECOND = 50;
|
||||||
|
const int THRESHOLD = 100;
|
||||||
|
|
||||||
|
// Create the LDT0-028 Piezo Vibration Sensor object using AIO pin 0
|
||||||
|
upm::LDT0028* sensor = new upm::LDT0028(0);
|
||||||
|
|
||||||
|
// Read the signal every 20 milliseconds for 10 seconds
|
||||||
|
std::cout << "For the next " << NUMBER_OF_SECONDS << " seconds, "
|
||||||
|
<< SAMPLES_PER_SECOND << " samples will be taken every second."
|
||||||
|
<< std::endl << std::endl;
|
||||||
|
uint16_t* buffer = new uint16_t[NUMBER_OF_SECONDS * SAMPLES_PER_SECOND];
|
||||||
|
for (int i=0; i < NUMBER_OF_SECONDS * SAMPLES_PER_SECOND; i++) {
|
||||||
|
buffer[i] = (uint16_t) sensor->getSample();
|
||||||
|
usleep(MICROSECONDS_PER_SECOND / SAMPLES_PER_SECOND);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print the number of times the reading was greater than the threshold
|
||||||
|
int count = 0;
|
||||||
|
for (int i=0; i < NUMBER_OF_SECONDS * SAMPLES_PER_SECOND; i++) {
|
||||||
|
if (buffer[i] > THRESHOLD) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << sensor->name() << " exceeded the threshold value of " <<
|
||||||
|
THRESHOLD << " a total of " << count << " times," << std::endl
|
||||||
|
<< "out of a total of " << NUMBER_OF_SECONDS*SAMPLES_PER_SECOND
|
||||||
|
<< " readings." << std::endl << std::endl;
|
||||||
|
|
||||||
|
// Print a graphical representation of the average value sampled
|
||||||
|
// each second for the past 10 seconds, using a scale factor of 15
|
||||||
|
std::cout << "Now printing a graphical representation of the average reading "
|
||||||
|
<< std::endl << "each second for the last "
|
||||||
|
<< NUMBER_OF_SECONDS << " seconds." << std::endl;
|
||||||
|
const int SCALE_FACTOR = 15;
|
||||||
|
for (int i=0; i < NUMBER_OF_SECONDS; i++) {
|
||||||
|
long sum = 0;
|
||||||
|
for (int j=0; j < SAMPLES_PER_SECOND; j++) {
|
||||||
|
sum += buffer[i*SAMPLES_PER_SECOND + j];
|
||||||
|
}
|
||||||
|
double average = (double) sum / (double) SAMPLES_PER_SECOND;
|
||||||
|
int stars_to_print = (int) round(average / SCALE_FACTOR);
|
||||||
|
std::cout << "(" << std::setw(4) << (int) round(average) << ") | ";
|
||||||
|
for (int j=0; j<stars_to_print; j++) {
|
||||||
|
std::cout << "*";
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the sensor object
|
||||||
|
delete sensor;
|
||||||
|
//! [Interesting]
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
66
examples/python/ldt0028.py
Normal file
66
examples/python/ldt0028.py
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import time
|
||||||
|
import array
|
||||||
|
import pyupm_ldt0028 as ldt0028
|
||||||
|
|
||||||
|
NUMBER_OF_SECONDS = 10
|
||||||
|
SAMPLES_PER_SECOND = 50
|
||||||
|
THRESHOLD = 100
|
||||||
|
|
||||||
|
# Create the LDT0-028 Piezo Vibration Sensor object using AIO pin 0
|
||||||
|
sensor = ldt0028.LDT0028(0)
|
||||||
|
|
||||||
|
# Read the signal every 20 milliseconds for 10 seconds
|
||||||
|
print 'For the next', NUMBER_OF_SECONDS, 'seconds,', \
|
||||||
|
SAMPLES_PER_SECOND, 'samples will be taken every second.\n'
|
||||||
|
buffer = array.array('H')
|
||||||
|
for i in range(0, NUMBER_OF_SECONDS * SAMPLES_PER_SECOND):
|
||||||
|
buffer.append(sensor.getSample())
|
||||||
|
time.sleep(1.0/SAMPLES_PER_SECOND)
|
||||||
|
|
||||||
|
# Print the number of times the reading was greater than the threshold
|
||||||
|
count = 0
|
||||||
|
for i in range(0, NUMBER_OF_SECONDS * SAMPLES_PER_SECOND):
|
||||||
|
if buffer[i] > THRESHOLD:
|
||||||
|
count += 1
|
||||||
|
print sensor.name(), ' exceeded the threshold value of', \
|
||||||
|
THRESHOLD, 'a total of', count, 'times,'
|
||||||
|
print 'out of a total of', NUMBER_OF_SECONDS*SAMPLES_PER_SECOND, \
|
||||||
|
'reading.\n'
|
||||||
|
|
||||||
|
# Print a graphical representation of the average value sampled
|
||||||
|
# each second for the past 10 seconds, using a scale factor of 15
|
||||||
|
print 'Now printing a graphical representation of the average reading '
|
||||||
|
print 'each second for the last', NUMBER_OF_SECONDS, 'seconds.'
|
||||||
|
SCALE_FACTOR = 15
|
||||||
|
for i in range(0, NUMBER_OF_SECONDS):
|
||||||
|
sum = 0
|
||||||
|
for j in range(0, SAMPLES_PER_SECOND):
|
||||||
|
sum += buffer[i*SAMPLES_PER_SECOND+j]
|
||||||
|
average = sum / SAMPLES_PER_SECOND
|
||||||
|
stars_to_print = int(round(average / SCALE_FACTOR))
|
||||||
|
print '(' + repr(int(round(average))).rjust(4) + ') |', '*' * stars_to_print
|
||||||
|
|
||||||
|
# Delete the sensor object
|
||||||
|
del sensor
|
5
src/ldt0028/CMakeLists.txt
Normal file
5
src/ldt0028/CMakeLists.txt
Normal 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()
|
8
src/ldt0028/jsupm_ldt0028.i
Normal file
8
src/ldt0028/jsupm_ldt0028.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module jsupm_ldt0028
|
||||||
|
%include "../upm.i"
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include "ldt0028.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "ldt0028.h"
|
46
src/ldt0028/ldt0028.cxx
Normal file
46
src/ldt0028/ldt0028.cxx
Normal 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
78
src/ldt0028/ldt0028.h
Normal 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
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
10
src/ldt0028/pyupm_ldt0028.i
Normal file
10
src/ldt0028/pyupm_ldt0028.i
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
%module pyupm_ldt0028
|
||||||
|
%include "../upm.i"
|
||||||
|
|
||||||
|
%feature("autodoc", "3");
|
||||||
|
|
||||||
|
%include "ldt0028.h"
|
||||||
|
%{
|
||||||
|
#include "ldt0028.h"
|
||||||
|
%}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user