Fix all the following issues which we faced during 01st April internal demo 1) Display hang and jump issue 2) Sequencing issue 3) Issue with BP code

Dependencies:   SDFileSystem ds3231 program mbed testUniGraphic_150217

Fork of Int_Demo_01Apr2017_newdisplaycode_bp_nikita by nikita teggi

touch_modules.cpp

Committer:
nikitateggi
Date:
2017-05-08
Revision:
12:ab85607bb10a
Parent:
11:9a6545c2eb5d

File content as of revision 12:ab85607bb10a:

#include "mbed.h"
//#include "ili9325.h"
//#include "lcd_base.h"
#include "display_modules.h"
#include "touch_modules.h"
InterruptIn Touch_D(PTD6);
int i;
unsigned int xt;
unsigned int yt;
Serial kc(USBTX, USBRX);


void touch1()  //determining the touch co-ordinates
 {
            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
{
    
while(i==1)
{
    while(Touch_D)//touch detection 
    {
         wait_ms(200); ///wait for debounce check
           if (Touch_D)
           {   
            
             Touch_D.fall(&touch1);
               //determine the touch co-ordinates
             break;
            }
        DisableTouch();
          //kc.printf("touch");
           
         }
 }
  EnableTouch();
  
  }



unsigned char touch_main()    //determining the touch for home screen
{
    
    unsigned char state;
        
                  if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // system configuration
                       {
                          
                          state=2;
                        }
    
                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=70) && (yt<=140) ) ) // test
                      {
                           state=3;
                 }   
                 else 
                     state=10;   
                          
         return state;     
    }
   
   
unsigned char touch_main_1()    //determining the touch for System Configuration screen
{
    
    unsigned char state;
        
                  if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) // ble
                       {
                          
                         // state=3;
                        }
    
                 else if ( ((xt >=130) && (xt<=195)) && ( (yt>= 135) && (yt<= 185) ) ) // erase
                      {
                          // state=4;
                        
                          
                       }
                 else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // file
                      {
                               // state=5;
                         
                       }
                 else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // home
                       {
                                 state=1;         //////////
                        
                       }
                   else 
                     state=10;     
                   
         return state;     
    }


 unsigned char touch_main_2()    //determining the touch for TEST screen
{
    
    unsigned char state;
        
                  if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) // GLC
                       {
                          
                          state=4;
                        }
    
                 else if ( ((xt >=130) && (xt<=195)) && ( (yt>= 135) && (yt<= 185) ) ) // ECG
                      {
                           state=5;
                        
                          
                       }
                 else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // BP
                      {
                                state=6;
                         
                       }
                 else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // Home
                       {
                                 state=1;
                        
                       }
                   
                else 
                     state=10;      // default -  goes to wait for a valid touch
                   
         return state;     
    }






unsigned char touch_ecg()     // determining the touch for ecg  main screen
{
      
      unsigned char state;
                 if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // START
                       {
                          
                          state=8;
                        }
    
                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=70) && (yt<=140) ) ) // RETURN
                      {
                          state=3;
                 } 
               else 
                     state=10;   
                                   
           return state;
    }
    

unsigned char touch_ret()     // determining the touch for ecg screen after the test
{
      
      unsigned char state;
                 
    
            if ( ((xt >=70) && (xt<=170)) && ( (yt>=70) && (yt<=140) ) ) // press on return box
                      {
                           state=3;
                 } 
              
              else 
                     state=10;                      
           return state;
    }
    



unsigned char touch_bp()   // //determining the touch for bp main screen

{
        unsigned char state;
                if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // START
                       {
                          
                          state=9;
                        }
    
                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=70) && (yt<=140) ) ) // RETURN
                      {
                          state=3;
                 } 
                else 
                     state=10;
           
           return state;
    }
    
    
    
  unsigned char touch_glc()        //determining the touch for GLC screen
    {
        unsigned char state;

                if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // START
                       {
                          
                          state=7;
                        }
    
                 else if ( ((xt >=70) && (xt<=170)) && ( (yt>=70) && (yt<=140) ) ) // RETURN
                      {
                           state=3;
                 }  
            else 
                  state=10;
           
           return state;
    } 
      
 
 
 unsigned char touch_again_ecg()    //determining the touch for Repeat test 
{
    
    unsigned char state;
        
                    if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // YES
                      {
                                state=8;
                         
                       }
                 else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // NO
                       {
                                 state=3;
                        
                       }
                   else 
                     state=10; 
         return state;     
    }
 
 
 unsigned char touch_again_glc()    //determining the touch for Repeat test 
{
    
    unsigned char state;
        
                    if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // YES
                      {
                                state=7;
                         
                       }
                 else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // NO
                       {
                                 state=3;
                        
                       }
                   else 
                     state=10; 
         return state;     
    }
    
   unsigned char touch_again_bp()    //determining the touch for Repeat test 
{
    
    unsigned char state;
        
                    if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // YES
                      {
                                state=9;
                         
                       }
                 else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // NO
                       {
                                 state=3;
                        
                       }
                   else 
                     state=10; 
         return state;     
    } 
 
 
 
 //TOUCH Functionalities//    

int readTouchY(void)      // read the Y co-ordinate
{      
    DigitalOut YD(PTD6);
     DigitalIn XL(PTD7);
     DigitalOut YU(PTC0);
     YU = 1;
     YD = 0;
     AnalogIn XR(PTB0);
     XL.mode(PullNone);
     return XR.read_u16();
}
    
    
int readTouchX(void)    // // read the X co-ordinate
{
    DigitalOut XR(PTB0);
    DigitalIn YD(PTD6);
     DigitalOut XL(PTD7);
     
     XR = 1;
     XL = 0;
     AnalogIn YU(PTC0);
     YD.mode(PullNone);
     return YU.read_u16();
}

void EnableTouch(void)       // Enable touch 
{
    
    DigitalIn YD(PTD6);
    DigitalOut XL(PTD7);
    DigitalIn YU(PTC0);
    DigitalIn XR(PTB0);
     XL=0;
      YD.mode(PullUp);
     YU.mode(PullNone);
     XR.mode(PullNone);
    i=1;
    Touch_D.fall(&touch1);
    Touch_D.enable_irq();
   
 }

void DisableTouch (void)    // Disable touch 
{
    Touch_D.disable_irq();
    i=0;
    DigitalOut YD(PTD6);
    DigitalOut XL(PTD7);
    DigitalOut YU(PTC0);
    DigitalOut XR(PTB0);
    }