Skip to content

Commit

Permalink
EHR: Removed Grove dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
  • Loading branch information
malikabhi05 authored and noel-eck committed Sep 14, 2016
1 parent f9a3631 commit a08b8bb
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion examples/c++/CMakeLists.txt
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions examples/c++/groveehr.cxx → examples/c++/ehr.cxx
Expand Up @@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "groveehr.hpp"
#include "ehr.hpp"

using namespace std;

Expand All @@ -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();
Expand Down Expand Up @@ -75,4 +75,4 @@ int main()

delete heart;
return 0;
}
}
2 changes: 1 addition & 1 deletion examples/java/CMakeLists.txt
Expand Up @@ -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)
Expand Down
Expand Up @@ -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();
Expand Down
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions examples/python/groveehr.py → examples/python/ehr.py
Expand Up @@ -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 ##
Expand Down
5 changes: 5 additions & 0 deletions src/ehr/CMakeLists.txt
@@ -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)
24 changes: 12 additions & 12 deletions src/groveehr/groveehr.cxx → src/ehr/ehr.cxx
Expand Up @@ -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)) )
{
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
28 changes: 14 additions & 14 deletions src/groveehr/groveehr.hpp → src/ehr/ehr.hpp
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/groveehr/javaupm_groveehr.i → src/ehr/javaupm_ehr.i
@@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/ehr/jsupm_ehr.i
@@ -0,0 +1,8 @@
%module jsupm_ehr
%include "../upm.i"

%{
#include "ehr.hpp"
%}

%include "ehr.hpp"
6 changes: 3 additions & 3 deletions src/groveehr/pyupm_groveehr.i → src/ehr/pyupm_ehr.i
@@ -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"
%}
5 changes: 0 additions & 5 deletions src/groveehr/CMakeLists.txt

This file was deleted.

8 changes: 0 additions & 8 deletions src/groveehr/jsupm_groveehr.i

This file was deleted.

0 comments on commit a08b8bb

Please sign in to comment.