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

Files at this revision

API Documentation at this revision

Comitter:
avp2417
Date:
Sun Aug 20 16:21:54 2017 +0000
Parent:
39:69b09bd87502
Child:
41:1141a75eacc4
Commit message:
Modification of BP, ECG and GLC operating ranges into 11th Aug Dharwad code. - By Amit on 12th Aug 2017

Changed in this revision

bp.cpp Show annotated file Show diff for this revision Revisions of this file
ecgg.cpp Show annotated file Show diff for this revision Revisions of this file
glc.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/bp.cpp	Fri Aug 11 12:19:25 2017 +0000
+++ b/bp.cpp	Sun Aug 20 16:21:54 2017 +0000
@@ -16,6 +16,12 @@
 #include "bp.h"
 #include "display_modules.h"
 
+#define MAX_SBP_THRESHOLD 300
+#define MAX_DBP_THRESHOLD 300
+#define MIN_SBP_THRESHOLD 40
+#define MIN_DBP_THRESHOLD 40
+
+
 FILE *fpecg_bp; // file pointer in place of fpecg- Suhasini- 21/7/17
 FILE *fpppg1;
 
@@ -206,7 +212,7 @@
     BLEMsg_info_bp.cal_data.cal_sbp_dummy = (uint16_t) SBP;
     BLEMsg_info_bp.cal_data.cal_dbp_OTtyp = (uint16_t) DBP;
     
-     if((SBP>190 || SBP<70)  && (DBP>100 || DBP<40))              // checking for range below and above and then displaying error
+     if((SBP > MAX_SBP_THRESHOLD || SBP < MIN_SBP_THRESHOLD)  && (DBP > MAX_DBP_THRESHOLD || DBP < MIN_SBP_THRESHOLD))              // checking for range below and above and then displaying error
      {
         screen_bp_error();             // checking for error out of range- nikita 10-7-17
         del_ppg_ecg_BPfile(pid);                          // Copy ECG and PPG data to BP file
--- a/ecgg.cpp	Fri Aug 11 12:19:25 2017 +0000
+++ b/ecgg.cpp	Sun Aug 20 16:21:54 2017 +0000
@@ -15,6 +15,11 @@
 #include "eeprom_pgm.h"
 #include "struct.h"  // Added on 31/5/17_Nidhin
 //#include "test_type.h" //Added on  31/5/17_Nidhin
+
+#define MAX_HR_THRESHOLD 205
+#define MIN_HR_THRESHOLD 25
+
+
 FILE *fpeecg1; // FILE pointer to ECG file
 Serial pc(USBTX,USBRX);  
 
@@ -220,16 +225,16 @@
  // ---------------------- To average individual HRs for higher number of samples -----------------------
  for(uint16_t i = 0;i < n-1;i++)
  {
- HR_sum = HR[i]+HR_sum; 
+ HR_sum = HR[i] + HR_sum; 
  }
- HR_avg = HR_sum/(n-1); // To find average of all the individual HRs calculated
+ HR_avg = (HR_sum / (n-1)); // To find average of all the individual HRs calculated
  printf("Heart Rate sum is = %f\n",HR_sum);
  printf("Heart Rate avg is = %f\n",HR_avg);
  
  fclose(fpeecg1);
  pc.printf("temporary file closed\n"); 
  
-if(HR_avg>100 || HR_avg<40) 
+if(HR_avg > MAX_HR_THRESHOLD || HR_avg < MIN_HR_THRESHOLD) 
     {
         delete_subfiles(pid);   // added on 11/8/17 nikita
         return 1;               // out of range condition returning 1  //nikita//10/7
--- a/glc.cpp	Fri Aug 11 12:19:25 2017 +0000
+++ b/glc.cpp	Sun Aug 20 16:21:54 2017 +0000
@@ -1,174 +1,3 @@
-
-/*
-// Code by nikitha Commented by Nidhin 
-
-/#include "mbed.h"
-#include "glc.h"
-#include "i2c_dec.h"
-//#include "ili9325.h"
-//#include "lcd_base.h"
-#include "display_modules.h"
-//#include "touch_modules.h"
-#include "rtc.h"
-#include "sdcard.h"
-
-
-void sample();
-void Compute();
-void i2c_spec();
-Ticker flipper;
-Ticker flipper1;
-
-//osTimerDef (sample_data, sample);                      // define timers
-//osTimerDef (Compute_GLC, Compute);  
-DigitalIn test_strip(PTA12);
-
-AnalogIn Ain(PTC1);//Electrode one
-AnalogIn Ain2(PTE29); // Electrode two
-AnalogOut DAC_signal(PTE30);
-Serial gtc(USBTX, USBRX);
-//unsigned char  c;
-//unsigned char HOME = 0;
-
-//signed char test_strip = 0;
-unsigned int mgdl = 0;
-unsigned int mgdll = 0;
-unsigned int daata1= 0;
-unsigned int data2 = 0;
-
-unsigned int data1n= 0;
-unsigned int data2n = 0;
-unsigned int datafinal1 = 0;
-unsigned int datafinal2 = 0;
-//unsigned int data_diff = 0;
-unsigned char err = 0;
-
-Serial ble(PTC4,PTC3);
-
-
-
-void sample()
-
-{
-     data1n = Ain.read_u16();
-     data2n = Ain2.read_u16();
-    daata1 = beta*daata1+alpha*data1n;
-    data2 = beta*data2+alpha*data2n;
-      
-     if( ((daata1-data2) >=(data2/10) && (daata1 > data2)) || ((data2-daata1) >=(data2/10) && (data2 > daata1)) )
-         {
-           
-            err = 1;     
-         }
-         else
-         {
-             err = 0;
-         }
-     
-}
-
-
-
-void Compute()
-{
-   
-   
-   datafinal1 = (unsigned int) NUMB1*(data2*VREF/(TOTAL))-NUMB2;
-   datafinal2 = (unsigned int) NUMB1*(daata1*VREF/(TOTAL))-NUMB2;
-   mgdl = (unsigned int) NUMB1*(((daata1+data2)/2)*VREF/(TOTAL))-NUMB2;
-   
-
-   if (err == 0)
-    {
-        
-        glc_4(mgdl);
-        sd_write(mgdl);        // storing value into the sd card
-        sd_close();
-       // ble.printf("blood glucose is %d mg/dl", mgdl);
-        flipper.detach();
-        flipper1.detach();
-      //  return mgdl;
-   
-    }
-    
-    else
-{
-        // lcd1.Print( " ERROR RESULT", 5,220,COLOR_RED,COLOR_BLACK, 0);    
-         //  ble.printf("E:");
-    }
-  
- 
-}
-
-
-
-void  glc(int pid){
-    unsigned char GLC_START = 0;
-    char t_s_d = 0;
-     i2c_spec();                    
-     GLC_START = 1;
-    // ble.baud(115200);
-   if(GLC_START == 1)
-{
-  
- //DisableTouch();
- //gpo_t = 0;
-    //lcd1.FillRect(5,127,230,320,COLOR_BLACK);
-    glc_1();             // displaying messages to insert the test strip
-    err = 0;
-    data1n = 0;
-    data2n = 0;
-    daata1 = 0;
-    data2 = 0;
-    sd_open_GLCfile(pid);      // opening the glc file
-
-    while((test_strip));
-    
-    
-   // wait(500);
-   // Shutdown = 1;
-    
-  if (!test_strip)                  // checks for the presence of test strip
-    { 
-      
-       flipper.attach(&sample, 0.8);    
-      t_s_d = 0;
-      glc_2();                        // displaying message to insert blood
-             
-     while((!t_s_d) && (!test_strip))
-      {
-        
-          gtc.printf("%d\n", data1n);
-          gtc.printf("%d\n", data2n);
-        if ((daata1 >= THRESHOLD) || (data2 >= THRESHOLD)) 
-            { 
-                t_s_d = 1;
-              flipper1.attach(&Compute, 2.25);                  //computing the glucose level
-               glc_3();
-            
-             
-             }
-        else
-            {
-              //wait for insertion of blood;
-            }
-         
-       }
-       
-        
-      //  t_s_d = 0;
-        wait_ms(800);
-        //flipper.detach();
-           
-}
-
-
-}  
-
-}  
-
-*/
-
 // Code Modified with Bluetooth Structure Nidhin 2/6/17
 ///
 #include "mbed.h"
@@ -185,6 +14,8 @@
 #include "struct.h" //Nidhin 31/5/2017
 //#include "test_type.h" //Nidhin 31/5/2017
 
+#define MAX_GLC_THRESHOLD 600
+#define MIN_GLC_THRESHOLD  10
 
 void sample();
 void Compute();
@@ -434,7 +265,7 @@
         structure_file(ptr_BLEMsg_info_glc, pid);           // Copy the structure into the GLC file 
         glcfile_mainfile(pid); 
        }
-  else if(err==1 || mgdl>200 || mgdl<40)      // added threshold to check value out of range   
+  else if(err == 1 || mgdl > MAX_GLC_THRESHOLD || mgdl < MIN_GLC_THRESHOLD)      // added threshold to check value out of range   
     {  
          gtc.printf("replace teststip"); 
          glc_error(); //disaply for showing error//10/7/17//nikita