SOLVED - Touch screen menu

I've been working on a menu for my touch screen, but i can't get the page mapping to work, so after going rom the main page to the settings page and pressing the top right button (which shares some x and y coordinates with a button on the main page) it carries out the action of the main page button.

See code below

// web: http://www.henningkarlsen.com/electronics
//
//
// Remember to change the next line if you are using as 16bit module!
#include <UTFT.h>
#include <ITDB02_Touch.h>

// Declare which fonts/icons we will be using
extern uint8_t BigFont[];
extern uint8_t SmallFont[];
extern uint8_t SevenSegNumFont[];

// Uncomment the next two lines for the ITDB02 Mega Shield
UTFT myGLCD(ITDB32S,38,39,40,41);   // Remember to add ASPECT_16x9 if you are using an ITDB02-3.2WC!
ITDB02_Touch  myTouch(6,5,4,3,2);

int x, y;
int page = 0;

void setup()
{
// Initial setup
  myGLCD.InitLCD(PORTRAIT);
  myGLCD.clrScr();
  myTouch.InitTouch(PORTRAIT); //LANDSCAPE
  myTouch.setPrecision(PREC_HI);
  mainscr();
  statusbar1();
  statusbar2();
  page = 0;
}
  
 void startupscr()
 {
 }

 void statusbar1() //top status bar
 {
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (0, 22, 239, 0);
  myGLCD.fillRoundRect (0, 22, 239, 0);
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(0, 0, 255);
  myGLCD.setBackColor(255, 255, 255);
  myGLCD.print("Bike System", CENTER, 0);
  myGLCD.print("15:35:44", 10, 10);
  myGLCD.print("12/09/12", 170, 10);
  }
 
 void statusbar2() //bottom status bar
 {
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (0, 295, 239, 319);
  myGLCD.fillRoundRect (0, 295, 239, 319);
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(0, 0, 255);
  myGLCD.setBackColor(255, 255, 255);
  myGLCD.print("Battery status", CENTER, 296);
  myGLCD.print("System -", 4, 308);
  myGLCD.print("Control -", 140, 308);
  myGLCD.setColor(255, 0, 0);
  myGLCD.print("7.4v", 60, 308);
  myGLCD.print("8.0v", 200, 308);
 }
 
 void mainscr()
 {
  myGLCD.fillScr(0, 68, 0);
  myGLCD.setBackColor (0, 68, 0);
  myGLCD.setFont(BigFont);
  myGLCD.setColor(255, 255, 255);  
  myGLCD.setBackColor (0, 0, 0);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRoundRect (0, 40, 239, 110);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (0, 40, 239, 110);
  myGLCD.print("Go Ride", CENTER, 70);
  
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRoundRect (0, 130, 239, 200);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (0, 130, 239, 200);
  myGLCD.print("Settings", CENTER, 160);
  
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRoundRect (0, 220, 239, 290);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (0, 220, 239, 290);
  myGLCD.print("About", CENTER, 250);
 }
     
  void ridescr() 
  { 
  myGLCD.fillScr(0, 68, 0);  
  myGLCD.setBackColor (0, 68, 0);  
  myGLCD.setFont(SevenSegNumFont);  
  myGLCD.setColor(255, 255, 255);
  myGLCD.print("25", 30, 60);
  }
 
  void settingsscr() 
 { 
  myGLCD.fillScr(0, 68, 0);
  myGLCD.setBackColor (0, 0, 0);
  myGLCD.setFont(BigFont);
  //sbutton1
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRoundRect (5, 27, 117, 111);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (5, 27, 117, 111);
  myGLCD.print("TIME", 30, 60);
  //sbutton2
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRoundRect (122, 27, 234, 111);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (122, 27, 234, 111); 
  myGLCD.print("DATE", 145, 60);
  //sbutton3
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRoundRect (5, 116, 117, 200);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (5, 116, 117, 200);
  myGLCD.print("USER", 30, 150);
  //sbutton4
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRoundRect (122, 116, 234, 200);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (122, 116, 234, 200);
 myGLCD.print("????", 145, 150); 
  //sbutton5
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRoundRect (5, 205, 117, 289);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (5, 205, 117, 289);
  myGLCD.print("GPS", 35, 245);
  //sbutton6
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRoundRect (122, 205, 234, 289);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (122, 205, 234, 289);
  myGLCD.print("????", 145, 245);
 }
 

 void stsb1()
 {
 }
  
 void stsb2()
 {
 }

 void stsb3()
 {
 }
 
 void stsb4()
 {
 }
 
 void stsb5()
 {
 }

 
 void aboutscr()
{    
 
}
  


 void loop()
{
    while (true)
  {
    if (myTouch.dataAvailable())
    
    {
      myTouch.read();
      x=myTouch.getX();
      y=myTouch.getY();
      
    //Button: Go Ride        
      
    if ((y>=40) && (y<=110))
  {
    if ((x>=0) && (x<=239));
    page = 1;
    myGLCD.clrScr();
    ridescr();
    statusbar1();
    statusbar2();
    
    } 
    
  //Button: Settings
      
    if ((y>=130) && (y<=200))
  {
    if ((x>=0) && (x<=239));
    page = 2;
    myGLCD.clrScr();
    settingsscr();
    statusbar1();
    statusbar2();
    
  }
 
  // settings page button actions 5, 27, 117, 111
  
  if (page == 2){
  //button1
  if ((y>=27) && (y<=111) && (x>=5) && (x<=117)) 
    {
       myGLCD.clrScr();
    }
  }
    //Button: About 
        
    if ((y>=220) && (y<=290))
  {
    if ((x>=0) && (x<=239));
    page = 3;
    myGLCD.clrScr();
    statusbar1();
    statusbar2();
    aboutscr();
    }
    
    
   
  
  //Return to main screen button used on all screens
  
    if ((y>=0) && (y<=239) && (x>=0) && (x<=22))
  {
    page = 0;
    myGLCD.clrScr();
    mainscr();
    statusbar1();
    statusbar2();
  }
  
  //Power Button
  
    if ((y>=0) && (y<=239) && (x>=295) && (x<=319))
  {
   myGLCD.lcdOff(); 
  }

}}}

If someone could point me in the right direction and what i'm doing wrong, that would be great

This topic says SOLVED. Did you ever get this figured out? I'm working on a similar project so if you are still stumped I will gladly keep you posted on how I did mine! Let me know.
Cheers!

Brian

I am also verry curious about the solution, since I have the same problem

Gabriel

Sorry this has taken me so long to get back to this post but yes I have figured a lot of things out since then. If you have any questions I would happily share my findings with you!

hope all is well!