mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
Added interfaces iEC,iEmg,iClock,iHeartRate,iLineFinder
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
This commit is contained in:

committed by
Serban Waltter

parent
e7820f2831
commit
69464ae93b
@ -65,12 +65,12 @@ uint32_t GroveEHR::getMillis()
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
// compute the delta since m_startTime
|
||||
if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 )
|
||||
if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 )
|
||||
{
|
||||
elapsed.tv_usec += 1000000;
|
||||
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec;
|
||||
}
|
||||
@ -92,7 +92,7 @@ void GroveEHR::clearBeatCounter()
|
||||
void GroveEHR::startBeatCounter()
|
||||
{
|
||||
// install our interrupt handler
|
||||
mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING,
|
||||
mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING,
|
||||
&beatISR, this);
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ int GroveEHR::heartRate()
|
||||
{
|
||||
uint32_t millis = getMillis();
|
||||
uint32_t beats = beatCounter();
|
||||
|
||||
|
||||
float heartRate = 0;
|
||||
// wait at least 5 seconds before attempting to compute the
|
||||
// heart rate
|
||||
@ -128,3 +128,8 @@ int GroveEHR::heartRate()
|
||||
|
||||
return int(heartRate);
|
||||
}
|
||||
|
||||
int GroveEHR::getHeartRate()
|
||||
{
|
||||
return GroveEHR::heartRate();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
#include <mraa/gpio.h>
|
||||
#include <interfaces/iHeartRate.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -48,12 +49,12 @@ namespace upm {
|
||||
* @brief API for the Grove Ear-clip Heart Rate Sensor
|
||||
*
|
||||
* UPM module for the Grove ear-clip heart rate sensor. It is used to measure your
|
||||
* heart rate.
|
||||
* heart rate.
|
||||
*
|
||||
* @image html groveehr.jpg
|
||||
* @image html groveehr.jpg
|
||||
* @snippet groveehr.cxx Interesting
|
||||
*/
|
||||
class GroveEHR {
|
||||
class GroveEHR : virtual public iHeartRate {
|
||||
public:
|
||||
/**
|
||||
* GroveEHR constructor
|
||||
@ -112,17 +113,22 @@ namespace upm {
|
||||
*/
|
||||
int heartRate();
|
||||
|
||||
/**
|
||||
* Retrieve the computed heart rate
|
||||
*
|
||||
* @return Computed heart rate
|
||||
*/
|
||||
virtual int getHeartRate();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Beat interrupt service routine (ISR)
|
||||
*
|
||||
*/
|
||||
static void beatISR(void *ctx);
|
||||
|
||||
|
||||
volatile uint32_t m_beatCounter;
|
||||
struct timeval m_startTime;
|
||||
mraa_gpio_context m_gpio;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user