utouch ssd1963 5 inch problem

XC = X Coordinate

ok, so you will do this then, X = map( myTouch.getX(), 200, 3800, 0, 479);
Also your Y max and min should be much bigger than X. They should not be the same.

I agree that they shouldn't be, but that doesn't change the fact that they are. Perhaps I've done something wrong?

I have:

x = myTouch.TP_X;
y = myTouch.TP_Y;
and then I am printing both x and y via serial to read their values

I went ahead and printed my code, perhaps you'd like to test it on your display and see if you read similar values. I am thinking that at this point, I should just apply the ratios. 800/3800 and 480/3800 with an offset of 800/200 or something along those lines.

#include <UTFT.h>
#include <UTouch.h>

#define TOUCH_ORIENTATION  PORTRAIT

extern uint8_t BigFont[];

UTFT        myGLCD(SSD1963_800, 38,39,40,41);   // Remember to change the model parameter to suit your display module!
UTouch      myTouch(6,5,4,3,2);

unsigned long tx = 0;
unsigned long XC = 0;

void drawCrossHair(int x, int y)
{
  myGLCD.drawRect(x-10, y-10, x+10, y+10);
  myGLCD.drawLine(x-5, y, x+5, y);
  myGLCD.drawLine(x, y-5, x, y+5);
}

void displayCrosshair() {
  for (int i = 25; i <= 745; i = i + 80) {
    delay(1);
    for (int j = 25; j <= 457; j = j + 48) {
      myGLCD.setColor(255, 255, 255);
      drawCrossHair(i,j);
    }
  }
}

void txtdisplay() {
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.setFont(BigFont);
  myGLCD.print("Here is 25,25", 25, 25);
}

void setup()
{
  myTouch.InitTouch(TOUCH_ORIENTATION);
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myTouch.setPrecision(PREC_MEDIUM);
  //tx = myTouch.TP_X;
  //map(tx, 5, 235, 0, 479);
  
  displayCrosshair();
  //txtdisplay();        //Allos me to know where the top left corner is 
  
  Serial.begin(115200);
  Serial.println(tx);
}

void loop()
{
  long x, y;
  
  while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
    x = myTouch.TP_X;
    y = myTouch.TP_Y;
    if ((x!=-1) and (y!=-1)) {
      Serial.println("X Coordinate");
      Serial.println(x);
      Serial.println("Y Coordinate");
      Serial.println(y);
    }
  }
}

Try this.

while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
    x = myTouch.TP_X;
    y = myTouch.TP_Y;

    int XC = map(x, 200, 3800, 0, 479);

    if ((x!=-1) and (y!=-1)) {
      Serial.print("X Coordinate");
      Serial.print(x);
      Serial.print("  ");
      Serial.print("Y Coordinate");
      Serial.print(y);
      Serial.print("  ");
      Serial.print("Mapped X");
      Serial.println(XC);
    }
  }

How about actually reading the UTouch manual, and especially the part about calibrating.

Proper calibration of the touch screen is REQUIRED when using anything other than a 3.2" display module and may be required even with those as there are minor difference in every single touch screen.

With proper calibration the getX() and getY() functions will be scaled correctly.

/Henning

He's right, I completely forgot about the calibration sketch. The offset values for X and Y need to be calibrated. Once you calibrate the screen with the touch pad, it will give you offset values that you need to change.

I read the manual and did the calibration a long time ago. I went ahead and did it again for doc_norway's sake.

The values:
CAL_X: 0x01F5C7C2
CAL_Y: 0x01FE4837
CAL_S: 0x001DF31F

Just by looking at those values, I shouldn't have to tell you that that just messed it up worse. Wouldn't be asking these questions if I hadn't already gone through the manual....thank you. So back to the original question. How can I map my display?

JHawk88:
CAL_S: 0x001DF31F

This line tells me that you have not followed the instructions in the manual.
If you had set the TOUCH_ORIENTATION correctly it should be 0x8031F1DFUL.

From the UTouch manual: 3. Make sure the TOUCH_ORIENTATION define is correct. You can find a list of the correct parameter for all the tested displays in the UTouch_Supported_display_modules PDF.

From the UTouch_Supported_display_modules.pdf:

Module TOUCH_ORIENTATION
ITDB02-5.0 LANDSCAPE
TFT01-5.0 LANDSCAPE
5.0" TFT LCD Module LANDSCAPE

Notice the pattern? Every 5" module I have seen should have TOUCH_ORIENTATION set to LANDSCAPE...
This is also true for the module used in the video shown earlier in this thread.

/Henning

Orientation: Landscape
LCD Define: ITDB50 which 5.0"

Calibration Coords:
CAL_X: 0x020D87E0
CAL_Y: 0x01F54701 (Not so sure bout those last 2 digits)
CAL_S: 0x8031F1DF

Two times calibrate with slightly diff coords.

Did it work either time? No.

X and Y read 799, 0 respectively all over the screen

JHawk88:
CAL_X: 0x020D87E0
CAL_Y: 0x01F54701
CAL_S: 0x8031F1DF

The data you got here is normally in indication of a defective touch screen (or a completely incompatible display module)...

/Henning

Sorry Henning, but I have to say that the calibration sketch doesn't work as it should (using the latest touch library).

I have a 3.2" display from Sainsmart (SSD1289). The default calibration values are OK, hopefully because when I try to calibrate it myself (and I'm very careful to press center of the crosses), the resulting calibration values are not accurate at all. So I use default values, they aren't perfect but it's OK for my use.

guix:
doesn't work as it should

This does not provide me with any information at all...

The calibration sketch have been tested on all the supported displays, but the SainSmart module will never be among them. SainSmart products are generally of so low quality that I say far away from them.

/Henning

Sainsmart, Elecfreaks, Itead... same products, different names.

Anyway, it worked well with older version of Utouch, and you can see I'm not the only one to have problems with the calibration sketch.

guix:
Sainsmart, Elecfreaks, Itead... same products, different names.

If they are really the same product, please explain this:
I checked the emails I got over a six month period, and the percentage of emails ultimately caused by hardware problems turned out like this:

  • ITead: 1.6%
  • ElecFreaks: 1.8%
  • SainSmart: 98.3%

Does not look like they are the same products to me...

/Henning

I have same problem and I opened utouch.cpp and make some change with disp_x_size and disp_y_size

void UTouch::InitTouch(byte orientation)
{
	orient					= orientation;
	_default_orientation	= CAL_S>>31;
	touch_x_left			= (CAL_X>>14) & 0x3FFF;
	touch_x_right			= CAL_X & 0x3FFF;
	touch_y_top				= (CAL_Y>>14) & 0x3FFF;
	touch_y_bottom			= CAL_Y & 0x3FFF;
	//disp_x_size				= (CAL_S>>12) & 0x0FFF;
	//disp_y_size				= CAL_S & 0x0FFF;
	disp_x_size				= 800;
	disp_y_size				= 480;
	prec					= 10;

	pinMode(T_CLK,  OUTPUT);
    pinMode(T_CS,   OUTPUT);
    pinMode(T_DIN,  OUTPUT);
    pinMode(T_DOUT, INPUT);
    pinMode(T_IRQ,  OUTPUT);

	digitalWrite(T_CS,  HIGH);
	digitalWrite(T_CLK, HIGH);
	digitalWrite(T_DIN, HIGH);
	digitalWrite(T_CLK, HIGH);
}

doc_norway:
If they are really the same product, please explain this:
I checked the emails I got over a six month period, and the percentage of emails ultimately caused by hardware problems turned out like this:

  • ITead: 1.6%
  • ElecFreaks: 1.8%
  • SainSmart: 98.3%

Does not look like they are the same products to me...

/Henning

Sorry, not trying to beat a dead horse here. But have you considered that maybe a big reason why those percentages are that way is that people only buy from SainSmart? If 1400/1500 buy from SainSmart, I would imagine you would get percentages like that.

JHawk88:
Sorry, not trying to beat a dead horse here. But have you considered that maybe a big reason why those percentages are that way is that people only buy from SainSmart? If 1400/1500 buy from SainSmart, I would imagine you would get percentages like that.

I think you have misunderstood what the percentages represents...
They represent the amount of messages I got where the root cause of the problems was a hardware fault or issue, and are a percentage of the total amount of messages regarding that particular vendor.

It has been a while since I did the count so I do not remember the exact figures any longer but the total number of messages was somewhere around 2500 and they were divided by the vendors almost equally (approx: 30% (SainSmart)/33% (ElecFreaks)/37% (ITead)).

Example: Say I got 1000 messages regarding ITead modules then 16 of those messages were about problems caused by hardware faults.

/Henning

Hello,

I solved the problem by adding some delay before SPI reading when CS is driven. According to datasheet it needs minimum 200ns when data is valid. After this mod (I used 2us delay) I'll get very steady readings.
Also I put some debounce for reading touchscreen "keys", now it works perfectly.

Can you explain what you did exactly for proper working? Have the Same Problem. I did the calibration and it is better now, but not very good precision

[EDIT] Did calibration again and in my sketch set precision to High. Now it's good for my touch application
[EDIT2] Ok for small buttons it is not good working. particularly on the borders of the screen.

I found out that if it is longer pressed it gives good coordinates out. Anyone an idea how to improve the code?

Anyone an idea how to improve the code?

What code?