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:
4:6bd81bb1790d
Parent:
3:9a06c2bed650
Child:
5:a3ea7c82b7e1
--- a/main.cpp	Fri Feb 10 10:39:13 2017 +0000
+++ b/main.cpp	Wed Mar 01 18:49:33 2017 +0000
@@ -8,7 +8,7 @@
 #include "glc.h"
 #include "bp.h"
 #include "sdcard.h"
-
+#include "eeprom_pgm.h"
 
  
 Serial gc(USBTX, USBRX);
@@ -44,9 +44,9 @@
    while(1)
    {
       
-    detect_touch();     // detrmine the touch points
+    detect_touch();     // determine the touch points
     
-    switch(state)
+    switch(state)    // state for touch
   {
       case 1:   state1=touch_main();   // determining the touch for main screen 
                 state=0;
@@ -54,43 +54,43 @@
                  break;
                
       case 2: 
-                state1=touch_main_1();    // determining the touch for glc screen 
+                state1=touch_main_1();    // determining the touch for SYSTEM CONFIGURATION screen 
                 state=0;
                 nstate1=state1;
                 break;
                 
       case 3:  
-               state1=touch_main_2();
-                                         // determining the touch for ecg screen 
+               state1=touch_main_2();     //// determining the touch for TEST screen 
+                                    
                 state=0;
                 nstate1=state1;
                 break;
         
       case 4: 
-                state1=touch_glc();     // determining the touch for bp screen 
+                state1=touch_glc();     // determining the touch for GLC screen 
                 state=0;
                 nstate1=state1;
                 break;       
         
       case 5: 
-                state1=touch_ecg();     // determining the touch for bp screen 
+                state1=touch_ecg();     // determining the touch for ECG screen 
                 state=0;
                 nstate1=state1;
                  break;   
-    case 6: 
-                state1=touch_ret();     // determining the touch for bp screen 
+     case 6: 
+                state1=touch_ret();     // determining the touch for returning back to the main screen 
                 state=0;
                 nstate1=state1;
                 break;
                 
-    case 7: 
-                state1=touch_again();     // determining the touch for bp screen 
+     case 7: 
+                state1=touch_again();     // determining the touch when readings are taken more than once screen 
                 state=0;
                 nstate1=state1;
                 break;
                 
      case 8:    
-                state1=touch_bp();     // determining the touch for bp screen 
+                state1=touch_bp();     // determining the touch for BP screen 
                 state=0;
                 nstate1=state1;
                 break;           
@@ -103,7 +103,7 @@
                  state=nstate;
                   break;
                 
-      default :  DisableTouch();
+     default :  DisableTouch();
                  wait_ms(300);
                  EnableTouch();
                  state=nstate;
@@ -115,29 +115,23 @@
   
   
   
- switch(state1)
+ switch(state1)    // state for display screens
   {
-      
-      case 0: 
-                DisableTouch();
-                 wait_ms(300);
-                  state=nstate;
-                 EnableTouch();
-                break;
+
       
       case 1: DisableTouch();
-                screen_main(); // glc main screen 
+                screen_main();        //  main screen 
                 state1=0;
                 state=1;
                 nstate=state;
                 flag=0;
-                ecg_flag=0;
+                ecg_flag=0;             // ecg, glc flag to determine whether the readings are taken more than once
                 glc_flag=0;
                 EnableTouch();
                 break;
       
       case 2: DisableTouch();
-                screen_main_1();  // glc main screen 
+                screen_main_1();     // System configration screen 
                 state1=0;
                 state=2;
                 nstate=state;
@@ -147,19 +141,22 @@
       case 3: DisableTouch();
               if (flag==0)
               {
-                pid=pid+1; 
+                //pid=pid+1;
+                pid=eprom_read(1);         // reading the patient id from eeprom
+                pid=pid+1;
+               eprom_write(1,pid);         // writing the patient id to eeprom
                 screen_main_2(pid);
-                sd_open_GLCfilee(pid);
+                sd_open_GLCfilee(pid);     // only opening the glc,bp and ecg file
                  sd_close();
                  sd_open_ECGfilee(pid);
                  sd_close();
-                 sd_open_BPfile(pid);
+                 sd_open_BPfilee(pid);
                  sd_close();
                  flag=1;
                  }
                else
                {
-               screen_main_2(pid);
+               screen_main_2(pid);          // TEST screen 
                }
                  
                  state1=0;
@@ -169,15 +166,15 @@
                   break;
                 
       case 4: DisableTouch();
-               if (glc_flag==1)
+               if (glc_flag==1)         // glc_flag=1 when already the reading has been taken 
                {
-                  screen_again();   //bp main screen 
+                  screen_again();    
                  state1=0;
                  state=7;
                  nstate=state;
                  }
             else
-                { screen_glc();  
+                { screen_glc();       // glc screen
                  state1=0;
                  state=4;
                  nstate=state;
@@ -198,7 +195,7 @@
                     
                  else
                  {   
-                  screen_ecg();       //bp main screen 
+                  screen_ecg();       //ecg main screen 
                    state1=0;
                    state=5;
                     nstate=state;
@@ -207,7 +204,7 @@
                 break;
      
      case 6:   DisableTouch();
-               screen_bp();
+               screen_bp();          // bp main screen
                EnableTouch();
                 state1=0;
                 state=8;
@@ -217,49 +214,43 @@
      
      
      
-     case 7:    DisableTouch();
-                glc(pid);
-                
-                
+     case 7:    DisableTouch();     
+                glc(pid);        // glc measurement
                 glc_flag=1;
                 wait(5); 
-              //   glc_4(mgdll);  
-               state1=0;
-                 screen_glc_2();
-              
-                state=6;;
+                state1=0;
+                screen_glc_2();
+                 state=6;;
               //  gc.printf("%d", state);
                EnableTouch();
                 break;
     
     case 8:     DisableTouch();
-    
-               ecg_countdown();
-                ecg(pid);
+                ecg_countdown();    // countdown before ecg capture
+                ecg(pid);           // capturing ecg
                 state1=0;
                 screen_ecg_2();
                 state=6;
                  nstate=state;
                  ecg_flag=1;
-              
-               //    ble.printf("ecg");
-               EnableTouch();
+        //    ble.printf("ecg");
+                EnableTouch();
                 break;
      
      
-     case 9: 
+     /*case 9: 
                 DisableTouch();
-               screen_glc_2();
-               state1=0;
+                screen_glc_2();
+                state1=0;
                 state=6;
                 nstate=state;
                 EnableTouch();
-                 break;
+                 break;*/
         
      case 11: 
                 DisableTouch();
-                screen_bp2();
-                bp();
+                screen_bp2();      // bp main screen
+                bp();              // measuring bp   
                 state1=0;
                // wait(1);
                 state=6;