Don't know how to work with touch screen...

Hi.

I am using Arduino MEGA 2560 with utft screen(touch screen is already included) - http://www.ebay.com/itm/3-2-tft-lcd-shield-touch-panel-TF-Reader-for-arduino-/270972145966?pt=LH_DefaultDomain_0&hash=item3f1732d12e

Also I’m using this library to init utft screen and touch screen : http://www.uctronics.com/download/Arduino_shileds/3inch2_RevB.zip

The question is : how can I get if the rectangle was touched?

#include <UTFT.h>
#include <ITDB02_Touch.h>
#include <SD.h>

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

UTFT screen(ITDB32S,A1,A2,A0,A3);
ITDB02_Touch  tscreen(13,10,11,12,9);

boolean welcome = true;

void setup() {
  screen.InitLCD(PORTRAIT);
  screen.clrScr();
  screen.setFont(BigFont);
  
  tscreen.InitTouch();
  tscreen.setPrecision(PREC_LOW);
}

void loop() {
   if (welcome) {
   screen.setColor(255,0,0);
   screen.fillRect( 20,20,60,60); //How can I get if this rect was touched?
   }
}

I have not programmed touch screens, but I can help you. (I have programmed a lot of small games for PCs)

Everytime when I wanted to get that an object is clicked and mouse got above it I was comparing actual position of mouse X and Y. I think that applies too for touchscreen. Try to compare the position of touched finger with position of rectangle (X and Y ofc)

Well, I programming apps for PC too, and commands like getX or getY are just don't wont to work.(screen.print((String)(touchscreen.getX()), LEFT, 100):wink:

Why they won't work? I'm wondering that its what are you looking for.

Hello,

I am having problems with Touch Screen too.
I am using a MEGA 2560 board interfaced to a Smart GPU2 touch screen. There are examples that are used
for the Ardunio UNO. But none of them work with the MEGA 2560. My interface is good. I have used wires
to connect the boards to each other.
When I try any of the examples, it gives me an error message for the line SMARTGPU2 lcd;

“GPU_Interface:29: error: ‘SMARTGPU2’ does not name a type”.

I am using Ardunio program version 1.5.6. The 1.05 version does not provide any error message and does not do anything either.

These lines are in every example;
#include <SMARTGPU2.h>
SMARTGPU2 lcd;

void setup() {

lcd.init();
lcd.start();

I have copied the GPU2 Library files into the Ardunio Library directory.
I appreciate any help possible.

Thank You

I think, that Your screen need to be initialized. Try to add "(10, 9)" after Your SMARTGPU2.
9 AND 10 are ports for connecting a screen, I guess...