upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

API for the Grove Ear-clip Heart Rate Sensor. More...

Detailed Description

UPM module for the Grove ear-clip heart rate sensor. It is used to measure your heart rate.

groveehr.jpg
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
// set the beat counter to 0, init the clock and start counting beats
heart.initClock();
heart.startBeatCounter();
while (true) {
long millis = heart.getMillis();
long beats = heart.beatCounter();
// heartRate() requires that at least 5 seconds pass before
// returning anything other than 0
int hr = heart.heartRate();
// output milliseconds passed, beat count, and computed heart rate
System.out.println("Millis: " + millis + ", Beats: " + beats + ", Heart rate: " + hr);
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 GroveEHR (int pin)
 
long getMillis ()
 
void initClock ()
 
void clearBeatCounter ()
 
void startBeatCounter ()
 
void stopBeatCounter ()
 
long beatCounter ()
 
int heartRate ()
 

Constructor & Destructor Documentation

GroveEHR ( int  pin)

GroveEHR constructor

Parameters
pinDigital pin to use

Member Function Documentation

long beatCounter ( )

Gets the beat Counter

Returns
Beat counter
void clearBeatCounter ( )

Resets the beat counter to 0. The beat counter should be stopped via stopBeatCounter() prior to calling this function.

long getMillis ( )

Returns the time of milliseconds elapsed since initClock() was last called.

Returns
Elapsed milliseconds
int heartRate ( )

Computes the heart rate

Returns
Computed heart rate
void initClock ( )

Resets the clock

void startBeatCounter ( )

Starts the beat counter

void stopBeatCounter ( )

Stops the beat counter


The documentation for this class was generated from the following file: