Interrupt
Dependencies: BLE_API BLE_Driver I2C_Driver MAX30100 PROCESAMIENTO_DATOS_SP02 mbed nRF51822 millis
Fork of MAX30100_FirstTry by
Diff: mainbletest.cpp
- Revision:
- 1:33d65d13c46a
- Parent:
- 0:882170680817
- Child:
- 2:065060bb55f2
--- a/mainbletest.cpp Mon Aug 22 01:04:43 2016 +0000 +++ b/mainbletest.cpp Mon Mar 27 23:23:46 2017 +0000 @@ -1,34 +1,83 @@ #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 -DigitalOut LIVE_LED(LED1, 1); -DigitalOut CONECT_LED(LED2, 1); -DigitalOut TEST_LED(LED3, 1); -DigitalIn TEST_BUTTON(p17,PullUp); +//************************** +int muestras_RED[200]; +int muestras_IR[200]; +int samples_index = 0; +int matriz_minimos[30][2], matriz_maximos[30][2],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 = 0; break; - case 2: CONECT_LED = 1; break; + case 1: CONECT_LED = 1; break; + case 2: CONECT_LED = 0; break; default: break; } } void periodicCallback(void){ LIVE_LED =! LIVE_LED; - uint8_t a; - a= getBLE(); - if (a=='G') - TEST_LED = !TEST_LED; } +void store_Samples(void){ + if (samples_index == 200){ + periodo = valores(muestras_RED,matriz_minimos,matriz_maximos,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; + samples_index++; + } +} int main(void){ - Ticker Flasher; Flasher.attach(periodicCallback, 1); + ini_i2c(SCL, SDA); + sensor.begin(pw1600, i17, sr50 ); iniBLE("Sigfried"); while(1){ - if (TEST_BUTTON == 0) - putBLE("Hola\n\r"); + sensor.readSensor(); + store_Samples(); + } } +