mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
APDS-9002: Add string based constructor for Luminance Sensor
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
This commit is contained in:
parent
7265373a47
commit
dad2e1f81a
@ -27,6 +27,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#include "apds9002.hpp"
|
||||
#include "upm_string_parser.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
@ -40,6 +41,26 @@ APDS9002::APDS9002(int pin)
|
||||
}
|
||||
}
|
||||
|
||||
APDS9002::APDS9002(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_aio = descs->aios[0]) )
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_aio_init() failed, invalid pin?");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
APDS9002::~APDS9002()
|
||||
{
|
||||
mraa_aio_close(m_aio);
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/aio.h>
|
||||
#include <mraa/initio.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -60,6 +61,12 @@ namespace upm {
|
||||
* @param pin Analog pin to use
|
||||
*/
|
||||
APDS9002(int pin);
|
||||
/**
|
||||
* Instantiates APDS-9002 Luminance Sensor based on a given string.
|
||||
*
|
||||
* @param initStr string containing specific information for APDS-9002 initialization.
|
||||
*/
|
||||
APDS9002(std::string initStr);
|
||||
/**
|
||||
* APDS9002 destructor
|
||||
*/
|
||||
@ -73,6 +80,7 @@ namespace upm {
|
||||
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
mraa::MraaIo mraaIo;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user