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
@ -42,6 +42,19 @@ ECS1030::ECS1030 (int pinNumber) {
|
||||
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 () {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
|
@ -24,9 +24,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <math.h>
|
||||
#include <mraa/aio.h>
|
||||
#include <mraa/gpio.h>
|
||||
#include <mraa/initio.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -85,6 +87,13 @@ class ECS1030 {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -119,6 +128,7 @@ class ECS1030 {
|
||||
private:
|
||||
std::string m_name;
|
||||
mraa_aio_context m_dataPinCtx;
|
||||
mraa::MraaIo mraaIo;
|
||||
|
||||
double m_calibration;
|
||||
int m_lastSample;
|
||||
|
Loading…
x
Reference in New Issue
Block a user