Library for the Grove Earbud Heartrate Sensor
Dependents: BLE_Police_HRM_Earbud df-2014-salesforce-hrm-k64f BLE_HeartRate_ppm emoSound ... more
GroveEarbudSensor Class Reference
GroveEarbudSensor GroveEarbudSensor a simple API to receive heartrate telemetry from the Grove Earbud Sensor. More...
#include <GroveEarbudSensor.h>
Public Member Functions | |
GroveEarbudSensor (InterruptIn *rx, RawSerial *pc=NULL) | |
Default constructor. | |
GroveEarbudSensor (PinName interrupt_pin, RawSerial *pc=NULL) | |
constructor for internalized InterruptIn usage | |
virtual | ~GroveEarbudSensor () |
Default destructor. | |
void | registerCallback (GroveEarbudSensorCallback *cb_fn, void *cb_data=NULL) |
registerCallback - Register callback function | |
float | getHeartRate (void) |
getHeartRate - get the last sampled heartrate | |
void | interrupt (void) |
interrupt() - interrupt handler for our instance - not normally invoked manually |
Detailed Description
GroveEarbudSensor GroveEarbudSensor a simple API to receive heartrate telemetry from the Grove Earbud Sensor.
Based upon/Credit: http://www.seeedstudio.com/wiki/Grove_-_Ear-clip_Heart_Rate_Sensor
Example Project: http://mbed.org/users/ansond/code/grove-earbud-sensor-sample/
#include "mbed.h" // Blinky DigitalOut led(LED1); // Our sensor as an InterruptIn InterruptIn sensor(D0); // Grove Earbud Sensor include #include "GroveEarbudSensor.h" // callback for receiving heartrate values void heartrateCallback(float heartrate,void *data) { printf("Callback: heartrate = %.1f\r\n",heartrate); } int main() { // announce printf("Grove Earbud Sensor Example v1.0.0\r\n"); // allocate the earbud sensor printf("Allocating earbud sensor instance...\r\n"); GroveEarbudSensor earbud(&sensor); // register our callback function printf("registering callback...\r\n"); earbud.registerCallback(heartrateCallback); // begin main loop printf("Beginning main loop...\r\n"); while (true) { // blink... led = !led; wait(0.5); // we can also call directly //printf("Direct: heartrate = %.1f\r\n",earbud.getHeartRate()); } }
Definition at line 97 of file GroveEarbudSensor.h.
Constructor & Destructor Documentation
GroveEarbudSensor | ( | InterruptIn * | rx, |
RawSerial * | pc = NULL |
||
) |
Default constructor.
- Parameters:
-
rx input InterruptIn instance pc input RawSerial instance for debugging (if NULL, no debugging output will occur in the library)
Definition at line 34 of file GroveEarbudSensor.cpp.
GroveEarbudSensor | ( | PinName | interrupt_pin, |
RawSerial * | pc = NULL |
||
) |
constructor for internalized InterruptIn usage
- Parameters:
-
rx interrupt_pin InterruptIn pin name pc input RawSerial instance for debugging (if NULL, no debugging output will occur in the library)
Definition at line 61 of file GroveEarbudSensor.cpp.
~GroveEarbudSensor | ( | ) | [virtual] |
Default destructor.
Definition at line 88 of file GroveEarbudSensor.cpp.
Member Function Documentation
float getHeartRate | ( | void | ) |
getHeartRate - get the last sampled heartrate
- Returns:
- heartrate - the last calculated heartrate (may also be one of HEARTRATE_OFF, HEARTRATE_MIN, or HEARTRATE_MAX)
Definition at line 106 of file GroveEarbudSensor.cpp.
void interrupt | ( | void | ) |
interrupt() - interrupt handler for our instance - not normally invoked manually
Definition at line 129 of file GroveEarbudSensor.cpp.
void registerCallback | ( | GroveEarbudSensorCallback * | cb_fn, |
void * | cb_data = NULL |
||
) |
registerCallback - Register callback function
- Parameters:
-
cb_fn - callback function of type GroveEarbudSensorCallback cb_data - optional callback data to provide upon callback invocation (default - NULL)
Definition at line 100 of file GroveEarbudSensor.cpp.
Generated on Fri Jul 15 2022 13:36:17 by 1.7.2