utouch ssd1963 5 inch problem

At the moment, I have been using Serial.println(x); to display the coordinates. So far, they tell me only 320x240

320 x 240? Then your screen is already mapped. So if you touch the middle of the screen do you get something like 160 x 120? Basically if you touch the screen anywhere, do the values change?

Yes. I get a value wherever I touch the screen. I have my serial print out the x and y coordinates. Out of curiosity I went ahead and did a trace program. Draws the coordinates as I touch the screen. I drew on the entire screen and it only drew in the top left. Which I assume to be coordinates 320x240. You mentioned that my screen is already mapped. How can I remap it?

Can you post a picture or make a small video? Its possible that your screen is 800 x 600 (maybe a little smaller), but the way its coded "myGLCD(SSD1963_800, 38,39,40,41);" may be set for a screen of 320x240, and not what you have.

Ok, so I uploaded a video. Here's the link.

I'm curious, what happens if you do this,

myGLCD.drawPixel(myTouch.getX(),myTouch.getY());

I posted a reply on your youtube video.

EDIT:
I took a look at the UTFT library and you do have the screen set correctly.
Now what you need to do is print out the X coordinates as you touch the screen, and keep track of the screen boundaries. So you touch the screen as close to the left edge, to where it is still on the screen and not touching the black plastic part. Then do the same for the right side of the screen. Then once you have those two values, you can map them like so.

tx = myTouch.TP_X;
XC= constrain (map(tx, 205, 3900,0,239),0,239); // this filters out the black plastic part of the screen and just gives me the visual part.
My actual screen size is 0 - 239, but my touch data goes from 205 - 3900, So this is what I did to map my touch data to my screen. Yours may be "map(tx, 5, 235, 0, 479)"

I'm curious, what happens if you do this,

myGLCD.drawPixel(myTouch.getX(),myTouch.getY());

I am currently trying to make an excel sheet mapping. But if what you suggested fixes the problem, then that would resolve my problem and I would no longer have to waste my time w/ this array. But to answer you question, coordinate (25,25) tells me that it is approx (0,10). (105,25) reports a coordinate of (23,15). (265,25) reports a coordinate of (47,15). So you can see my frustration as to what is going on here. I was thinking that maybe I'd come up with some equation that just resolves this matter (exponential by the looks of it) but I know that doesn't really solve the problem and will leave a lot to be desired. The code you offered, do I put this in the library or on my main sketch?

tx = myTouch.TP_X;
XC= constrain (map(tx, 205, 3900,0,239),0,239);

The code you offered, do I put this in the library or on my main sketch?

No, that just what I did to map my screen. But you may be able to reverse it for yours. Use this as a test and see what you get map(tx, 5, 235, 0, 479)"

In the setup? Also, just a peculiar problem I am dealing with.... (745,457) = (226,315)? Weird yes?

weird

Ok, so I found that my X_max = 3850, X_min = 150(prob make 200), Y_max = 3800, Y_min = 150(prob make 200). So do I apply these values to that constrain? What exactly is that XC?

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