Go Down

Topic: minimal touch area on SSD1289 (Read 2200 times) previous topic - next topic


          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
  // Initial setup


void loop()
  if (myTouch.dataAvailable())
    Serial.print(" - ");


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

Have you done that?
Do not IM me. I will not respond. Ask questions in the forum.


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?



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.
Do not IM me. I will not respond. Ask questions in the forum.


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


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


You only need a delay if you're not doing anything with the data, thus creating a really fast, tight loop.
Do not IM me. I will not respond. Ask questions in the forum.

Go Up