Changes done in ECG and BT

Dependencies:   SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217

Fork of merged_code2_20sept_2017_4th_oct_2017 by nikita teggi

Revision:
20:7c64e6ecad76
Parent:
19:1650bbc923cc
Child:
22:ffa88619551d
--- a/ecgg.cpp	Fri Jun 09 17:12:21 2017 +0000
+++ b/ecgg.cpp	Sat Jun 17 09:36:18 2017 +0000
@@ -21,6 +21,8 @@
 
 float ecg(int pid) 
  {
+    
+    uint8_t lead_reg=0;      // added on 14/06 to check lead -off 
     //----------------------- Structure for Bluetooth  Added Nidhin 1/6/2017-------------------//
     
     //BLUETOOTH STRUCTURE
@@ -119,9 +121,10 @@
     pc.baud(baud_rate);
     freqset();               // setting the frequency
     setupfunc();              
-    ecgsetupfunc();
+    lead_reg=ecgsetupfunc();                 // added a return function to read leadoff // 14/06
  //   chk = 1;
- 
+ if (lead_reg==0)                    // checking for proper lead contact// 14/06
+ {
    //ORIGINAL sd_open_ECGfile(pid);        // opening the ecg file  COMMENTED Nidhin 1/6/2017
    sd_open_ECGfilee(pid);  // REPLACED Nidhin 1/6/2017 Nidhin 
    
@@ -134,7 +137,7 @@
      sd_ecgwrite(ecg_ptr); // REPLACED Nidhin 1/6/2017
      
      ecg_buf[i] = concatenate_value2;
-     pc.printf( "%d\n", concatenate_value2); //COMMENTED Nidhin 1/6/2017
+  ////   pc.printf( "%d\n", concatenate_value2); //COMMENTED Nidhin 1/6/2017
    } 
   
    //sd_close();          // closing the file COMMENTED Nidhin 1/6/2017
@@ -176,9 +179,9 @@
    //  if(a_dif <= 0) ------------------------ add this condition if needed ----------------------
    //  {
      pk_val[j] = hi_val; //if condition satisfied, put the "pk" value into "pk_val" buffer
-     pc.printf("peak value= %d\n",pk_val[j]);
+   ////  pc.printf("peak value= %d\n",pk_val[j]);
      pk_pos[j]=a; // also save the peak's position
-     pc.printf("peak position is = %d\n",pk_pos[j]);
+   ////  pc.printf("peak position is = %d\n",pk_pos[j]);
      i = a+120;  // once confirmed that this is the necessary peak, skip the next 120 input values
      n = j; // where n is the number of peaks detected
      j = j+1;
@@ -236,6 +239,13 @@
  
   return HR1;
   // return HR_avg; 
+  }
+  
+ else 
+     {
+        pc.printf("no - leadoff");
+        return 0;
+    } 
   
 }          // End of main function