Updated with option to return from BP screen to main screen, resolved screen navigation issues

Dependencies:   SDFileSystem TFTLCD_8bit ds3231 program mbed

Fork of poc_dis_5 by SenseSemi

Revision:
4:6bd81bb1790d
Parent:
3:9a06c2bed650
Child:
5:a3ea7c82b7e1
--- a/touch_modules.cpp	Fri Feb 10 10:39:13 2017 +0000
+++ b/touch_modules.cpp	Wed Mar 01 18:49:33 2017 +0000
@@ -11,13 +11,12 @@
 
 
 void touch1()  //determining the touch co-ordinates
-{
-   xt = (X_MAX*readTouchX()/TOTAL1);
+ {
+            xt = (X_MAX*readTouchX()/TOTAL1);
             yt = (Y_MAX*readTouchY()/TOTAL1);
             kc.printf("%d\n", xt);
               kc.printf("%d\n", yt);
-            
-    }
+ }
 
 
 void detect_touch()   // detect the touch //debounce
@@ -68,7 +67,7 @@
     }
    
    
-unsigned char touch_main_1()    //determining the touch for home screen
+unsigned char touch_main_1()    //determining the touch for System Configuration screen
 {
     
     unsigned char state;
@@ -101,7 +100,8 @@
          return state;     
     }
 
-unsigned char touch_main_2()    //determining the touch for home screen
+
+ unsigned char touch_main_2()    //determining the touch for TEST screen
 {
     
     unsigned char state;
@@ -130,7 +130,7 @@
                        }
                    
                 else 
-                     state=10;
+                     state=10;      // default -  goes to wait for a valid touch
                    
          return state;     
     }
@@ -140,17 +140,17 @@
 
 
 
-unsigned char touch_ecg()     // determining the touch for ecg screen
+unsigned char touch_ecg()     // determining the touch for ecg  main screen
 {
       
       unsigned char state;
-                 if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // GLC
+                 if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // START
                        {
                           
                           state=8;
                         }
     
-                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=90) && (yt<=140) ) ) // ECG
+                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=90) && (yt<=140) ) ) // RETURN
                       {
                          //  state=2;
                  } 
@@ -161,13 +161,13 @@
     }
     
 
-unsigned char touch_ret()     // determining the touch for ecg screen
+unsigned char touch_ret()     // determining the touch for ecg screen after the test
 {
       
       unsigned char state;
                  
     
-            if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // ECG
+            if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // press on return box
                       {
                            state=3;
                  } 
@@ -180,17 +180,17 @@
 
 
 
-unsigned char touch_bp()   // //determining the touch for bp screen
+unsigned char touch_bp()   // //determining the touch for bp main screen
 
 {
         unsigned char state;
-                if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // GLC
+                if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // START
                        {
                           
                           state=11;
                         }
     
-                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=90) && (yt<=140) ) ) // ECG
+                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=90) && (yt<=140) ) ) // RETURN
                       {
                          //  state=2;
                  } 
@@ -202,17 +202,17 @@
     
     
     
-unsigned char touch_glc()        ////determining the touch for home screen
+  unsigned char touch_glc()        //determining the touch for GLC screen
     {
         unsigned char state;
 
-                if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // GLC
+                if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // START
                        {
                           
                           state=7;
                         }
     
-                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // ECG
+                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // RETURN
                       {
                           // state=2;
                  }  
@@ -224,17 +224,17 @@
       
  
  
- unsigned char touch_again()    //determining the touch for home screen
+ unsigned char touch_again()    //determining the touch for Repeat test 
 {
     
     unsigned char state;
         
-                    if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // BP
+                    if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // YES
                       {
                                 state=8;
                          
                        }
-                 else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // SET
+                 else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // NO
                        {
                                  state=3;
                         
@@ -247,9 +247,10 @@
  
  
  
-     
+ //TOUCH Functionalities//    
 
-int readTouchY(void) {
+int readTouchY(void)      // read the Y co-ordinate
+{      
     DigitalOut YD(PTD6);
      DigitalIn XL(PTD7);
      DigitalOut YU(PTC0);
@@ -260,7 +261,9 @@
      return XR.read_u16();
 }
     
-int readTouchX(void) {
+    
+int readTouchX(void)    // // read the X co-ordinate
+{
     DigitalOut XR(PTB0);
     DigitalIn YD(PTD6);
      DigitalOut XL(PTD7);
@@ -272,7 +275,8 @@
      return YU.read_u16();
 }
 
-void EnableTouch(void){
+void EnableTouch(void)       // Enable touch 
+{
     
     DigitalIn YD(PTD6);
     DigitalOut XL(PTD7);
@@ -282,12 +286,14 @@
       YD.mode(PullUp);
      YU.mode(PullNone);
      XR.mode(PullNone);
-   i=1;
+    i=1;
     Touch_D.fall(&touch1);
     Touch_D.enable_irq();
    
-    }
-void DisableTouch (void){
+ }
+
+void DisableTouch (void)    // Disable touch 
+{
     Touch_D.disable_irq();
     i=0;
     DigitalOut YD(PTD6);