mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 09:20:39 +03:00
AD8232: Add string based constructor for Heart Rate Monitor
This commit is contained in:
parent
317a780161
commit
33fcb18cce
@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "upm_string_parser.hpp"
|
||||||
#include "ad8232.hpp"
|
#include "ad8232.hpp"
|
||||||
|
|
||||||
using namespace upm;
|
using namespace upm;
|
||||||
@ -39,6 +39,26 @@ AD8232::AD8232(int loPlus, int loMinus, int output, float aref) :
|
|||||||
m_ares = (1 << m_aioOUT.getBit());
|
m_ares = (1 << m_aioOUT.getBit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AD8232::AD8232(std::string initStr) : mraaIo(initStr), m_gpioLOPlus(mraaIo.gpios[0]),
|
||||||
|
m_gpioLOMinus(mraaIo.gpios[1]), m_aioOUT(mraaIo.aios[0])
|
||||||
|
{
|
||||||
|
std::vector<std::string> upmTokens;
|
||||||
|
|
||||||
|
if(mraaIo.getLeftoverStr() != "")
|
||||||
|
{
|
||||||
|
upmTokens = UpmStringParser::parse(mraaIo.getLeftoverStr());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::string tok : upmTokens)
|
||||||
|
{
|
||||||
|
if(tok.substr(0,5) == "volt:")
|
||||||
|
{
|
||||||
|
m_aref = std::stof(tok.substr(5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_ares = (1 << m_aioOUT.getBit());
|
||||||
|
}
|
||||||
|
|
||||||
AD8232::~AD8232()
|
AD8232::~AD8232()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <mraa/gpio.hpp>
|
#include <mraa/gpio.hpp>
|
||||||
|
|
||||||
#include <mraa/aio.hpp>
|
#include <mraa/aio.hpp>
|
||||||
|
#include <mraa/initio.hpp>
|
||||||
|
|
||||||
#define AD8232_DEFAULT_AREF 3.3
|
#define AD8232_DEFAULT_AREF 3.3
|
||||||
|
|
||||||
@ -84,6 +84,13 @@ namespace upm {
|
|||||||
*/
|
*/
|
||||||
AD8232(int loPlus, int loMinus, int output, float aref=AD8232_DEFAULT_AREF);
|
AD8232(int loPlus, int loMinus, int output, float aref=AD8232_DEFAULT_AREF);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates AD8232 sensor object based on a given string.
|
||||||
|
*
|
||||||
|
* @param initStr string containing specific information for AD8232 sensor initialization.
|
||||||
|
*/
|
||||||
|
AD8232(std::string initStr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AD8232 destructor
|
* AD8232 destructor
|
||||||
*/
|
*/
|
||||||
@ -98,6 +105,7 @@ namespace upm {
|
|||||||
int value();
|
int value();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
mraa::MraaIo mraaIo;
|
||||||
mraa::Gpio m_gpioLOPlus;
|
mraa::Gpio m_gpioLOPlus;
|
||||||
mraa::Gpio m_gpioLOMinus;
|
mraa::Gpio m_gpioLOMinus;
|
||||||
mraa::Aio m_aioOUT;
|
mraa::Aio m_aioOUT;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user