Chanel Richardson / Mbed OS vitalsplus-max86150_chanel

Dependencies:   max32630fthr USBDevice

Revision:
18:1ad357c3df71
Parent:
17:65a8b29f6bac
diff -r 65a8b29f6bac -r 1ad357c3df71 main.cpp
--- a/main.cpp	Wed Mar 18 17:48:18 2020 +0000
+++ b/main.cpp	Mon Apr 13 22:04:35 2020 +0000
@@ -35,6 +35,9 @@
 float derivative[BUFF_SIZE]={0};
 float squared[BUFF_SIZE]={0};
 float integral[BUFF_SIZE] = {0};
+float ez_output[BUFF_SIZE] = {0};
+float HR_EZ[BUFF_SIZE] = {0};
+float r_peaks[BUFF_SIZE] = {0};
 bool outputSignal[BUFF_SIZE]={0};
 
 // Variables for preprocessing
@@ -88,9 +91,32 @@
     */
     //******* SETUP BLUETOOTH *********   
     eventQueue.call_every(1, periodicCallback); // poll sensor every 1ms. New samples come every 5ms, so polling freq can potentially be decreased
-    BLE &ble = BLE::Instance();
+    /*BLE &ble = BLE::Instance();
     ble.onEventsToProcess(scheduleBleEventsProcessing);
-    ble.init(bleInitComplete);
+    ble.init(bleInitComplete);*/
+    pc.printf("Connected to BLE Client...\n");
+   max86150Sensor.begin(i2c, recommendedi2cFreq, MAX86150_Addr); 
+    wait_ms(300);
+   
+    //unsigned char partID = max86150Sensor.readPartID();
+    unsigned char partID = max86150Sensor.readRegister8(MAX86150_Addr,0xFF);
+    pc.printf("Part ID is: %X\n",partID);
+    while (partID != 0x1E) {/* Connection to sensor is not established */ }
+    
+    
+    //***** SETUP SENSOR */
+    max86150Sensor.setup(); //Configure sensor
+    wait_ms(300);
+    pc.printf("SYSCONTOL REG: %x\n", max86150Sensor.readRegister8(MAX86150_Addr,0x0D));
+    pc.printf("FIFO CONFIG: %X\n",max86150Sensor.readRegister8(MAX86150_Addr,0x08));
+    pc.printf("INT_EN1: %X\n", max86150Sensor.readRegister8(MAX86150_Addr,0x02));
+    pc.printf("INT_EN2: %X\n", max86150Sensor.readRegister8(MAX86150_Addr,0x03));
+    pc.printf("INT STATUS1: %X\n",max86150Sensor.readRegister8(MAX86150_Addr,0x00));
+    pc.printf("INT STATUS2: %X\n",max86150Sensor.readRegister8(MAX86150_Addr,0x01));
+    //*************************************************************//
+    panTompkinsInit();
+    max86150Sensor.clearFIFO();
+    max86150Sensor.writeRegister8(MAX86150_Addr,0x0D,0x04); //start FIFO
     eventQueue.dispatch_forever();