EHR: Removed Grove dependency

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
Abhishek Malik 2016-09-13 11:10:13 -07:00 committed by Noel Eck
parent f9a36314fb
commit a08b8bbcb0
14 changed files with 61 additions and 61 deletions

View File

@ -143,7 +143,7 @@ add_example (ds1307)
add_example (a110x)
add_example (gp2y0a)
add_example (moisture)
add_example (groveehr)
add_example (ehr)
add_example (ta12200)
add_example (grovelinefinder)
add_example (vdiv)

View File

@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "groveehr.hpp"
#include "ehr.hpp"
using namespace std;
@ -43,8 +43,8 @@ int main()
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
upm::GroveEHR* heart = new upm::GroveEHR(2);
// Instantiate a Ear-clip Heart Rate sensor on digital pin D2
upm::EHR* heart = new upm::EHR(2);
// set the beat counter to 0, init the clock and start counting beats
heart->clearBeatCounter();
@ -75,4 +75,4 @@ int main()
delete heart;
return 0;
}
}

View File

@ -33,7 +33,7 @@ add_example(ES08ASample servo)
add_example(GroveButtonSample grove)
add_example(GroveButton_intrSample grove)
add_example(Collision collision)
add_example(GroveEHRSample groveehr)
add_example(EHRSample ehr)
add_example(Emg emg)
add_example(Gsr gsr)
add_example(GroveLed_multiSample grove)

View File

@ -23,12 +23,12 @@
*/
//NOT TESTED!!!
public class GroveEHRSample {
public class EHRSample {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
upm_groveehr.GroveEHR heart = new upm_groveehr.GroveEHR(2);
// Instantiate a Ear-clip Heart Rate sensor on digital pin D2
upm_ehr.EHR heart = new upm_ehr.EHR(2);
// set the beat counter to 0, init the clock and start counting beats
heart.clearBeatCounter();

View File

@ -23,9 +23,9 @@
*/
// Load heart rate sensor module
var heartRateSensor = require('jsupm_groveehr');
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
var myHeartRateSensor = new heartRateSensor.GroveEHR(2);
var heartRateSensor = require('jsupm_ehr');
// Instantiate a Ear-clip Heart Rate sensor on digital pin D2
var myHeartRateSensor = new heartRateSensor.EHR(2);
// set the beat counter to 0, init the clock and start counting beats
myHeartRateSensor.clearBeatCounter();

View File

@ -23,10 +23,10 @@
import time, sys, signal, atexit
import pyupm_groveehr as upmGroveehr
import pyupm_ehr as upmehr
# Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
myHeartRateSensor = upmGroveehr.GroveEHR(2)
# Instantiate a Ear-clip Heart Rate sensor on digital pin D2
myHeartRateSensor = upmehr.EHR(2)
## Exit handlers ##

5
src/ehr/CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
upm_mixed_module_init (NAME ehr
DESCRIPTION "upm ear-clip heart rate sensor module"
CPP_HDR ehr.hpp
CPP_SRC ehr.cxx
REQUIRES mraa)

View File

@ -26,12 +26,12 @@
#include <string>
#include <stdexcept>
#include "groveehr.hpp"
#include "ehr.hpp"
using namespace upm;
using namespace std;
GroveEHR::GroveEHR(int pin)
EHR::EHR(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) )
{
@ -46,17 +46,17 @@ GroveEHR::GroveEHR(int pin)
m_beatCounter = 0;
}
GroveEHR::~GroveEHR()
EHR::~EHR()
{
mraa_gpio_close(m_gpio);
}
void GroveEHR::initClock()
void EHR::initClock()
{
gettimeofday(&m_startTime, NULL);
}
uint32_t GroveEHR::getMillis()
uint32_t EHR::getMillis()
{
struct timeval elapsed, now;
uint32_t elapse;
@ -84,36 +84,36 @@ uint32_t GroveEHR::getMillis()
return elapse;
}
void GroveEHR::clearBeatCounter()
void EHR::clearBeatCounter()
{
m_beatCounter = 0;
}
void GroveEHR::startBeatCounter()
void EHR::startBeatCounter()
{
// install our interrupt handler
mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING,
&beatISR, this);
}
void GroveEHR::stopBeatCounter()
void EHR::stopBeatCounter()
{
// remove the interrupt handler
mraa_gpio_isr_exit(m_gpio);
}
uint32_t GroveEHR::beatCounter()
uint32_t EHR::beatCounter()
{
return m_beatCounter;
}
void GroveEHR::beatISR(void *ctx)
void EHR::beatISR(void *ctx)
{
upm::GroveEHR *This = (upm::GroveEHR *)ctx;
upm::EHR *This = (upm::EHR *)ctx;
This->m_beatCounter++;
}
int GroveEHR::heartRate()
int EHR::heartRate()
{
uint32_t millis = getMillis();
uint32_t beats = beatCounter();

View File

@ -30,39 +30,39 @@
namespace upm {
/**
* @brief Grove Ear-clip Heart Rate Sensor library
* @defgroup groveehr libupm-groveehr
* @brief Ear-clip Heart Rate Sensor library
* @defgroup ehr libupm-ehr
* @ingroup seeed gpio medical
*/
/**
* @library groveehr
* @sensor groveehr
* @comname Grove Ear-clip Heart Rate Sensor
* @library ehr
* @sensor ehr
* @comname Ear-clip Heart Rate Sensor
* @type medical
* @man seeed
* @con gpio
*
* @brief API for the Grove Ear-clip Heart Rate Sensor
* @brief API for the Ear-clip Heart Rate Sensor
*
* UPM module for the Grove ear-clip heart rate sensor. It is used to measure your
* UPM module for the ear-clip heart rate sensor. It is used to measure your
* heart rate.
*
* @image html groveehr.jpg
* @snippet groveehr.cxx Interesting
* @image html ehr.jpg
* @snippet ehr.cxx Interesting
*/
class GroveEHR {
class EHR {
public:
/**
* GroveEHR constructor
* EHR constructor
*
* @param pin Digital pin to use
*/
GroveEHR(int pin);
EHR(int pin);
/**
* GroveEHR destructor
* EHR destructor
*/
~GroveEHR();
~EHR();
/**
* Returns the time of milliseconds elapsed since initClock()
* was last called.

View File

@ -1,18 +1,18 @@
%module javaupm_groveehr
%module javaupm_ehr
%include "../upm.i"
%ignore beatISR;
%{
#include "groveehr.hpp"
#include "ehr.hpp"
%}
%include "groveehr.hpp"
%include "ehr.hpp"
%pragma(java) jniclasscode=%{
static {
try {
System.loadLibrary("javaupm_groveehr");
System.loadLibrary("javaupm_ehr");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e);
System.exit(1);

8
src/ehr/jsupm_ehr.i Normal file
View File

@ -0,0 +1,8 @@
%module jsupm_ehr
%include "../upm.i"
%{
#include "ehr.hpp"
%}
%include "ehr.hpp"

View File

@ -1,11 +1,11 @@
// Include doxygen-generated documentation
%include "pyupm_doxy2swig.i"
%module pyupm_groveehr
%module pyupm_ehr
%include "../upm.i"
%feature("autodoc", "3");
%include "groveehr.hpp"
%include "ehr.hpp"
%{
#include "groveehr.hpp"
#include "ehr.hpp"
%}

View File

@ -1,5 +0,0 @@
set (libname "groveehr")
set (libdescription "upm grove ear-clip heart rate sensor module")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -1,8 +0,0 @@
%module jsupm_groveehr
%include "../upm.i"
%{
#include "groveehr.hpp"
%}
%include "groveehr.hpp"