![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
LOO C++ project
Dependencies: mbed text_to_speak_mbed GroveEarbudSensor
Diff: main.cpp
- Revision:
- 0:213bf9be9e9e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Dec 23 19:51:55 2018 +0000 @@ -0,0 +1,68 @@ + +#include "mbed.h" + +// Blinky +DigitalOut led(LED1); + +Serial pc(p9, p10); // tx, rx + +// 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()); + }*/ + /* pc.baud(19200); + pc.printf("Hello World\n");*/ + + // 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()); + } +}