![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Interrupt
Dependencies: BLE_API BLE_Driver I2C_Driver MAX30100 PROCESAMIENTO_DATOS_SP02 mbed nRF51822 millis
Fork of MAX30100_FirstTry by
mainbletest.cpp@2:065060bb55f2, 2017-03-28 (annotated)
- Committer:
- cesarcazal
- Date:
- Tue Mar 28 02:08:37 2017 +0000
- Revision:
- 2:065060bb55f2
- Parent:
- 1:33d65d13c46a
- Child:
- 3:98ca4bf2e74a
Se agrega la capacidad de revisar los datos le?dos
Who changed what in which revision?
User | Revision | Line number | New 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; |
cesarcazal | 2:065060bb55f2 | 26 | int 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]; |
cesarcazal | 2:065060bb55f2 | 33 | |
Ferszt | 1:33d65d13c46a | 34 | //****************** |
Ferszt | 1:33d65d13c46a | 35 | |
Ferszt | 1:33d65d13c46a | 36 | DigitalOut LIVE_LED(p17, 1); |
Ferszt | 1:33d65d13c46a | 37 | DigitalOut CONECT_LED(p18, 1); |
Ferszt | 1:33d65d13c46a | 38 | DigitalOut TEST_LED(p19, 1); |
Ferszt | 1:33d65d13c46a | 39 | DigitalOut LED(p20, 1); |
Ferszt | 1:33d65d13c46a | 40 | DigitalIn TEST_BUTTON(p13,PullUp); |
Ferszt | 1:33d65d13c46a | 41 | |
Ferszt | 1:33d65d13c46a | 42 | Ticker Flasher; |
Ferszt | 1:33d65d13c46a | 43 | MAX30100 sensor; |
Ferszt | 0:882170680817 | 44 | |
Ferszt | 0:882170680817 | 45 | void callbackBLE(int event) { |
Ferszt | 0:882170680817 | 46 | switch (event){ |
Ferszt | 1:33d65d13c46a | 47 | case 1: CONECT_LED = 1; break; |
Ferszt | 1:33d65d13c46a | 48 | case 2: CONECT_LED = 0; break; |
Ferszt | 0:882170680817 | 49 | default: break; |
Ferszt | 0:882170680817 | 50 | } |
Ferszt | 0:882170680817 | 51 | } |
Ferszt | 0:882170680817 | 52 | |
Ferszt | 0:882170680817 | 53 | void periodicCallback(void){ |
Ferszt | 0:882170680817 | 54 | LIVE_LED =! LIVE_LED; |
Ferszt | 0:882170680817 | 55 | } |
Ferszt | 0:882170680817 | 56 | |
Ferszt | 1:33d65d13c46a | 57 | void store_Samples(void){ |
Ferszt | 1:33d65d13c46a | 58 | if (samples_index == 200){ |
cesarcazal | 2:065060bb55f2 | 59 | periodo = valores(muestras_IR,max_min_period); |
Ferszt | 1:33d65d13c46a | 60 | frecuencia=60/(periodo*0.02); |
Ferszt | 1:33d65d13c46a | 61 | samples_index = 0; |
Ferszt | 1:33d65d13c46a | 62 | sprintf(show, "%f", frecuencia); |
Ferszt | 1:33d65d13c46a | 63 | putBLE(show); |
Ferszt | 1:33d65d13c46a | 64 | putBLE("\n"); |
Ferszt | 1:33d65d13c46a | 65 | } |
Ferszt | 1:33d65d13c46a | 66 | else{ |
Ferszt | 1:33d65d13c46a | 67 | muestras_RED[samples_index] = sensor.RED; |
Ferszt | 1:33d65d13c46a | 68 | muestras_IR[samples_index] = sensor.IR; |
cesarcazal | 2:065060bb55f2 | 69 | sprintf(show, "%d", muestras_IR[samples_index]); |
cesarcazal | 2:065060bb55f2 | 70 | putBLE(show); |
cesarcazal | 2:065060bb55f2 | 71 | putBLE("\n"); |
Ferszt | 1:33d65d13c46a | 72 | samples_index++; |
Ferszt | 1:33d65d13c46a | 73 | } |
Ferszt | 1:33d65d13c46a | 74 | } |
Ferszt | 0:882170680817 | 75 | int main(void){ |
Ferszt | 0:882170680817 | 76 | Flasher.attach(periodicCallback, 1); |
Ferszt | 1:33d65d13c46a | 77 | ini_i2c(SCL, SDA); |
Ferszt | 1:33d65d13c46a | 78 | sensor.begin(pw1600, i17, sr50 ); |
Ferszt | 0:882170680817 | 79 | iniBLE("Sigfried"); |
Ferszt | 0:882170680817 | 80 | while(1){ |
Ferszt | 1:33d65d13c46a | 81 | sensor.readSensor(); |
Ferszt | 1:33d65d13c46a | 82 | store_Samples(); |
cesarcazal | 2:065060bb55f2 | 83 | wait(0.019); |
Ferszt | 1:33d65d13c46a | 84 | |
Ferszt | 0:882170680817 | 85 | } |
Ferszt | 0:882170680817 | 86 | } |
Ferszt | 0:882170680817 | 87 | |
Ferszt | 1:33d65d13c46a | 88 |