AD8232: Add string based constructor for Heart Rate Monitor

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Adelin Dobre 2018-06-29 14:02:09 +03:00 committed by Mihai Tudor Panu
parent d23183897d
commit dfdc362c2c
2 changed files with 32 additions and 4 deletions

View File

@ -23,7 +23,7 @@
*/
#include <iostream>
#include "upm_string_parser.hpp"
#include "ad8232.hpp"
using namespace upm;
@ -34,11 +34,31 @@ AD8232::AD8232(int loPlus, int loMinus, int output, float aref) :
{
m_gpioLOPlus.dir(mraa::DIR_IN);
m_gpioLOMinus.dir(mraa::DIR_IN);
m_aref = aref;
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()
{
}

View File

@ -27,8 +27,8 @@
#include <sys/time.h>
#include <mraa/gpio.hpp>
#include <mraa/aio.hpp>
#include <mraa/initio.hpp>
#define AD8232_DEFAULT_AREF 3.3
@ -57,7 +57,7 @@ namespace upm {
* the intent to send that data, via serial or network port, somewhere to
* another piece of software running on a computer that plots the data for
* you, like an EKG.
*
*
* Processing (https://www.processing.org/) is software
* that should work, using information from the SparkFun* website.
*
@ -84,6 +84,13 @@ namespace upm {
*/
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
*/
@ -98,6 +105,7 @@ namespace upm {
int value();
private:
mraa::MraaIo mraaIo;
mraa::Gpio m_gpioLOPlus;
mraa::Gpio m_gpioLOMinus;
mraa::Aio m_aioOUT;