Intento 4

Dependencies:   BLE_API BLE_Driver I2C_Driver MAX30100 PROCESAMIENTO_DATOS_SP02 mbed millis nRF51822

Fork of MAX30100_FirstTry by Daniel Ferszt

Committer:
Ferszt
Date:
Mon Mar 27 23:23:46 2017 +0000
Revision:
1:33d65d13c46a
Parent:
0:882170680817
Child:
2:065060bb55f2
primer commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ferszt 0:882170680817 1 #include "mbed.h"
Ferszt 1:33d65d13c46a 2 #include "Ticker.h"
Ferszt 0:882170680817 3 #include "BLE_Driver.h"
Ferszt 1:33d65d13c46a 4 #include "MAX30100.h"
Ferszt 1:33d65d13c46a 5 #include "I2C_Driver.h"
Ferszt 1:33d65d13c46a 6 #include "PROCESAMIENTO_SPO2_FC.h"
Ferszt 1:33d65d13c46a 7
Ferszt 1:33d65d13c46a 8 #define nRF51DK
Ferszt 1:33d65d13c46a 9 //#define nRF52DK
Ferszt 1:33d65d13c46a 10
Ferszt 1:33d65d13c46a 11
Ferszt 1:33d65d13c46a 12 #ifdef nRF52DK
Ferszt 1:33d65d13c46a 13 #define SCL 28
Ferszt 1:33d65d13c46a 14 #define SDA 29
Ferszt 1:33d65d13c46a 15 #endif
Ferszt 1:33d65d13c46a 16
Ferszt 1:33d65d13c46a 17 #ifdef nRF51DK
Ferszt 1:33d65d13c46a 18 #define SCL 7
Ferszt 1:33d65d13c46a 19 #define SDA 6
Ferszt 1:33d65d13c46a 20 #endif
Ferszt 0:882170680817 21
Ferszt 1:33d65d13c46a 22 //**************************
Ferszt 1:33d65d13c46a 23 int muestras_RED[200];
Ferszt 1:33d65d13c46a 24 int muestras_IR[200];
Ferszt 1:33d65d13c46a 25 int samples_index = 0;
Ferszt 1:33d65d13c46a 26 int matriz_minimos[30][2], matriz_maximos[30][2],max_min_period[2];
Ferszt 1:33d65d13c46a 27 int pico_pico,cresta, valle, cantidad;
Ferszt 1:33d65d13c46a 28 float frecuencia,periodo;
Ferszt 1:33d65d13c46a 29
Ferszt 1:33d65d13c46a 30 int index, aux1, nmuestra;
Ferszt 1:33d65d13c46a 31
Ferszt 1:33d65d13c46a 32 char show[10];
Ferszt 1:33d65d13c46a 33 //******************
Ferszt 1:33d65d13c46a 34
Ferszt 1:33d65d13c46a 35 DigitalOut LIVE_LED(p17, 1);
Ferszt 1:33d65d13c46a 36 DigitalOut CONECT_LED(p18, 1);
Ferszt 1:33d65d13c46a 37 DigitalOut TEST_LED(p19, 1);
Ferszt 1:33d65d13c46a 38 DigitalOut LED(p20, 1);
Ferszt 1:33d65d13c46a 39 DigitalIn TEST_BUTTON(p13,PullUp);
Ferszt 1:33d65d13c46a 40
Ferszt 1:33d65d13c46a 41 Ticker Flasher;
Ferszt 1:33d65d13c46a 42 MAX30100 sensor;
Ferszt 0:882170680817 43
Ferszt 0:882170680817 44 void callbackBLE(int event) {
Ferszt 0:882170680817 45 switch (event){
Ferszt 1:33d65d13c46a 46 case 1: CONECT_LED = 1; break;
Ferszt 1:33d65d13c46a 47 case 2: CONECT_LED = 0; break;
Ferszt 0:882170680817 48 default: break;
Ferszt 0:882170680817 49 }
Ferszt 0:882170680817 50 }
Ferszt 0:882170680817 51
Ferszt 0:882170680817 52 void periodicCallback(void){
Ferszt 0:882170680817 53 LIVE_LED =! LIVE_LED;
Ferszt 0:882170680817 54 }
Ferszt 0:882170680817 55
Ferszt 1:33d65d13c46a 56 void store_Samples(void){
Ferszt 1:33d65d13c46a 57 if (samples_index == 200){
Ferszt 1:33d65d13c46a 58 periodo = valores(muestras_RED,matriz_minimos,matriz_maximos,max_min_period);
Ferszt 1:33d65d13c46a 59 frecuencia=60/(periodo*0.02);
Ferszt 1:33d65d13c46a 60 samples_index = 0;
Ferszt 1:33d65d13c46a 61 sprintf(show, "%f", frecuencia);
Ferszt 1:33d65d13c46a 62 putBLE(show);
Ferszt 1:33d65d13c46a 63 putBLE("\n");
Ferszt 1:33d65d13c46a 64 }
Ferszt 1:33d65d13c46a 65 else{
Ferszt 1:33d65d13c46a 66 muestras_RED[samples_index] = sensor.RED;
Ferszt 1:33d65d13c46a 67 muestras_IR[samples_index] = sensor.IR;
Ferszt 1:33d65d13c46a 68 samples_index++;
Ferszt 1:33d65d13c46a 69 }
Ferszt 1:33d65d13c46a 70 }
Ferszt 0:882170680817 71 int main(void){
Ferszt 0:882170680817 72 Flasher.attach(periodicCallback, 1);
Ferszt 1:33d65d13c46a 73 ini_i2c(SCL, SDA);
Ferszt 1:33d65d13c46a 74 sensor.begin(pw1600, i17, sr50 );
Ferszt 0:882170680817 75 iniBLE("Sigfried");
Ferszt 0:882170680817 76 while(1){
Ferszt 1:33d65d13c46a 77 sensor.readSensor();
Ferszt 1:33d65d13c46a 78 store_Samples();
Ferszt 1:33d65d13c46a 79
Ferszt 0:882170680817 80 }
Ferszt 0:882170680817 81 }
Ferszt 0:882170680817 82
Ferszt 1:33d65d13c46a 83