Pages: [1]   Go Down
Author Topic: minimal touch area on SSD1289  (Read 977 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
          I'm a new kid on the block and my first attempt to get a touch screen to work has had limited success.
I have SainSmart Mega2560 +3.2" LCD TFT Touch Screen with SD Reader
Only the bottom right hand corner of the screen shows any valid touch input.
Here is the code. It is as simple as I can get and simply initializes the screen then in the Serial Monitor it displays the value of x and y.
Any help is gratefully appreciated.
#include <UTFT.h>
#include <UTouch.h>
int x, y;  // Have tried as long with same result.
UTFT        myGLCD(ITDB32S, 38,39,40,41);
UTouch      myTouch(6,5,4,3,2);


void setup()
{
  // Setup Serial connection
  Serial.begin(9600);
  // Initial setup
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_LOW);
  x=0;
  y=0;
}


void loop()
{
  if (myTouch.dataAvailable())
  {
    myTouch.read();
    x=myTouch.getX();
    y=myTouch.getY();
    Serial.print(x);
    Serial.print(" - ");
    Serial.println(y);
  }
  delay(100);
}
Logged

Offline Offline
Sr. Member
****
Karma: 12
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you use UTouch, you have to run the calibration sketch example that comes with it.

Have you done that?
Logged

Do not IM me. I will not respond. Ask questions in the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've now followed the rules and run the calibration sketch.
All areas of the screen were accessible to touch and the sketch proved the values to edit in the required .h file.
Having done this I have now run across something totally unexpected.
If I run my code without the serial monitor the values are wrong as the touches do not work as expected,
run the serial monitor, the screen blanks out for fraction of a second and they show up as bad values.
close the serial monitor, the screen blinks and the touches work, open the serial monitor and it tracks the correct values.

Has anyone got any idea what could be going on there?


Logged

Offline Offline
Sr. Member
****
Karma: 12
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmmm.

I suspect you're misinterpreting what you're seeing here.

If the calibration software has worked correctly, and you have copied the values correctly, UTouch is probably now working correctly.

Try running the other UTouch examples and if they work correctly, it proves the problem is in your sketch.

FWIW, dataAvailable() returns true continuously while your finger is on the screen. The loop is also called continously so you'll be generating a lot of output in your sketch while your finger is pressed down as it is currently written. This could conceivably cause a problem.
Logged

Do not IM me. I will not respond. Ask questions in the forum.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got the same thing.  Without a delay after while (myTouch.dataAvailable() == true){
the coordinates got corrupted.  Try this thread to sort it out.

http://forum.arduino.cc/index.php?topic=198188.0

Note: I also got corruption from setting the color, etc... so strip your code down until you see the problem.
Logged

Offline Offline
Sr. Member
****
Karma: 12
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You only need a delay if you're not doing anything with the data, thus creating a really fast, tight loop.
Logged

Do not IM me. I will not respond. Ask questions in the forum.

Pages: [1]   Go Up
Jump to: