First try
Dependencies: BLE_API BLE_Driver I2C_Driver MAX30100 millis mbed nRF51822
Fork of BLE_Driver_Example by
Diff: mainbletest.cpp
- Revision:
- 3:cb0290a123d2
- Parent:
- 2:065060bb55f2
diff -r 065060bb55f2 -r cb0290a123d2 mainbletest.cpp --- a/mainbletest.cpp Tue Mar 28 02:08:37 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -#include "mbed.h" -#include "Ticker.h" -#include "BLE_Driver.h" -#include "MAX30100.h" -#include "I2C_Driver.h" -#include "PROCESAMIENTO_SPO2_FC.h" - -#define nRF51DK -//#define nRF52DK - - -#ifdef nRF52DK -#define SCL 28 -#define SDA 29 -#endif - -#ifdef nRF51DK -#define SCL 7 -#define SDA 6 -#endif - -//************************** -int muestras_RED[200]; -int muestras_IR[200]; -int samples_index = 0; -int max_min_period[2]; -int pico_pico,cresta, valle, cantidad; -float frecuencia,periodo; - -int index, aux1, nmuestra; - - char show[10]; - -//****************** - -DigitalOut LIVE_LED(p17, 1); -DigitalOut CONECT_LED(p18, 1); -DigitalOut TEST_LED(p19, 1); -DigitalOut LED(p20, 1); -DigitalIn TEST_BUTTON(p13,PullUp); - -Ticker Flasher; -MAX30100 sensor; - -void callbackBLE(int event) { - switch (event){ - case 1: CONECT_LED = 1; break; - case 2: CONECT_LED = 0; break; - default: break; - } - } - -void periodicCallback(void){ - LIVE_LED =! LIVE_LED; - } - -void store_Samples(void){ - if (samples_index == 200){ - periodo = valores(muestras_IR,max_min_period); - frecuencia=60/(periodo*0.02); - samples_index = 0; - sprintf(show, "%f", frecuencia); - putBLE(show); - putBLE("\n"); - } - else{ - muestras_RED[samples_index] = sensor.RED; - muestras_IR[samples_index] = sensor.IR; - sprintf(show, "%d", muestras_IR[samples_index]); - putBLE(show); - putBLE("\n"); - samples_index++; - } -} -int main(void){ - Flasher.attach(periodicCallback, 1); - ini_i2c(SCL, SDA); - sensor.begin(pw1600, i17, sr50 ); - iniBLE("Sigfried"); - while(1){ - sensor.readSensor(); - store_Samples(); - wait(0.019); - - } - } - -