mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
ECS1030: Add string based constructor
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
5b97b0a98e
commit
402739fa74
@ -35,13 +35,26 @@ using namespace upm;
|
|||||||
ECS1030::ECS1030 (int pinNumber) {
|
ECS1030::ECS1030 (int pinNumber) {
|
||||||
m_dataPinCtx = mraa_aio_init(pinNumber);
|
m_dataPinCtx = mraa_aio_init(pinNumber);
|
||||||
if (m_dataPinCtx == NULL) {
|
if (m_dataPinCtx == NULL) {
|
||||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
": mraa_aio_init() failed");
|
": mraa_aio_init() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_calibration = 111.1;
|
m_calibration = 111.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ECS1030::ECS1030 (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");
|
||||||
|
} else {
|
||||||
|
m_dataPinCtx = descs->aios[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
m_calibration = 111.1;
|
||||||
|
}
|
||||||
|
|
||||||
ECS1030::~ECS1030 () {
|
ECS1030::~ECS1030 () {
|
||||||
mraa_result_t error = MRAA_SUCCESS;
|
mraa_result_t error = MRAA_SUCCESS;
|
||||||
|
|
||||||
|
@ -24,9 +24,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <mraa/aio.h>
|
#include <mraa/aio.h>
|
||||||
#include <mraa/gpio.h>
|
#include <mraa/gpio.h>
|
||||||
|
#include <mraa/initio.hpp>
|
||||||
|
|
||||||
namespace upm {
|
namespace upm {
|
||||||
|
|
||||||
@ -85,6 +87,13 @@ class ECS1030 {
|
|||||||
*/
|
*/
|
||||||
ECS1030 (int pinNumber);
|
ECS1030 (int pinNumber);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates ECS1030 sensor object based on a given string.
|
||||||
|
*
|
||||||
|
* @param initStr string containing specific information for ECS1030 sensor initialization.
|
||||||
|
*/
|
||||||
|
ECS1030 (std::string initStr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ECS1030 object destructor; basically, it closes the GPIO.
|
* ECS1030 object destructor; basically, it closes the GPIO.
|
||||||
*/
|
*/
|
||||||
@ -119,6 +128,7 @@ class ECS1030 {
|
|||||||
private:
|
private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
mraa_aio_context m_dataPinCtx;
|
mraa_aio_context m_dataPinCtx;
|
||||||
|
mraa::MraaIo mraaIo;
|
||||||
|
|
||||||
double m_calibration;
|
double m_calibration;
|
||||||
int m_lastSample;
|
int m_lastSample;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user