mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
LDT0-028: Add string based constructor for Piezo Vibration Sensor
Signed-off-by: Adelin Dobre <adelin.dobre1994@gmail.com>
This commit is contained in:
parent
1f3520b770
commit
f34360c8ec
@ -31,7 +31,7 @@ using namespace upm;
|
||||
|
||||
LDT0028::LDT0028(unsigned int pin) {
|
||||
// initialize analog input
|
||||
if ( !(m_pin = mraa_aio_init(pin)) )
|
||||
if ( !(m_pin = mraa_aio_init(pin)) )
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_aio_init() failed, invalid pin?");
|
||||
@ -40,6 +40,26 @@ LDT0028::LDT0028(unsigned int pin) {
|
||||
m_name = "ldt0-028";
|
||||
}
|
||||
|
||||
LDT0028::LDT0028(std::string initStr) : mraaIo(initStr) {
|
||||
mraa_io_descriptor* descs = mraaIo.getMraaDescriptors();
|
||||
|
||||
if(!descs->aios)
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_aio_init() failed, invalid pin?");
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !(m_pin = descs->aios[0]) )
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_aio_init() failed, invalid pin?");
|
||||
|
||||
}
|
||||
}
|
||||
m_name = "ldt0-028";
|
||||
}
|
||||
|
||||
LDT0028::~LDT0028() {
|
||||
// close analog input
|
||||
mraa_aio_close(m_pin);
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/aio.h>
|
||||
#include <mraa/initio.hpp>
|
||||
#include <mraa/initio.h>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -61,6 +63,13 @@ class LDT0028 {
|
||||
*/
|
||||
LDT0028(unsigned int pin);
|
||||
|
||||
/**
|
||||
* Instantiates LDT0-028 Sensor object based on a given string.
|
||||
*
|
||||
* @param initStr string containing specific information for LDT0-028 Sensor initialization.
|
||||
*/
|
||||
LDT0028(std::string initStr);
|
||||
|
||||
/**
|
||||
* LDT0028 destructor
|
||||
*/
|
||||
@ -82,6 +91,7 @@ class LDT0028 {
|
||||
|
||||
protected:
|
||||
std::string m_name; //!< name of this sensor
|
||||
mraa::MraaIo mraaIo;
|
||||
mraa_aio_context m_pin; //!< AIO pin
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user