mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +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;
|
||||||
@ -34,11 +34,31 @@ AD8232::AD8232(int loPlus, int loMinus, int output, float aref) :
|
|||||||
{
|
{
|
||||||
m_gpioLOPlus.dir(mraa::DIR_IN);
|
m_gpioLOPlus.dir(mraa::DIR_IN);
|
||||||
m_gpioLOMinus.dir(mraa::DIR_IN);
|
m_gpioLOMinus.dir(mraa::DIR_IN);
|
||||||
|
|
||||||
m_aref = aref;
|
m_aref = 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
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ namespace upm {
|
|||||||
* the intent to send that data, via serial or network port, somewhere to
|
* 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
|
* another piece of software running on a computer that plots the data for
|
||||||
* you, like an EKG.
|
* you, like an EKG.
|
||||||
*
|
*
|
||||||
* Processing (https://www.processing.org/) is software
|
* Processing (https://www.processing.org/) is software
|
||||||
* that should work, using information from the SparkFun* website.
|
* 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);
|
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