Pages: 1 2 [3] 4 5   Go Down
Author Topic: utouch ssd1963 5 inch problem  (Read 7300 times)
0 Members and 1 Guest are viewing this topic.
Queens, New York
Online Online
Faraday Member
**
Karma: 101
Posts: 3645
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I hate to bring this back up again.  But I am dealing with the same problem.  I am using those same libraries.  The display only reads an X_touch and Y_touch of 320x240.  So clearly the screen is not mapped properly.  I attempted to use the sketch in reply 11 as suggested seeing as how it was noted that changes have been made to it multiple times.  Nothing appears on my screen.  This, however, is after I declared: long tx and long ty.  The compiler says these were not declared.  Regardless, nothing is happening.  What should I be expecting to see?  How can I fix the mapping?

If you have this exact library, then you have "myTouch.getX(), and myTouch.getY();" these are your raw touch data. So if you use myGLCD.printNumI(myTouch.getX(), 10, 50); you should see a value for the X axis.
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Offline Offline
Jr. Member
**
Karma: 1
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Remember remember, the 4th of...July!  Duh.

Queens, New York
Online Online
Faraday Member
**
Karma: 101
Posts: 3645
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Offline Offline
Jr. Member
**
Karma: 1
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Remember remember, the 4th of...July!  Duh.

Queens, New York
Online Online
Faraday Member
**
Karma: 101
Posts: 3645
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Offline Offline
Jr. Member
**
Karma: 1
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://youtu.be/MCAA80sr7_g
Logged

Remember remember, the 4th of...July!  Duh.

Queens, New York
Online Online
Faraday Member
**
Karma: 101
Posts: 3645
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)"
« Last Edit: July 25, 2013, 01:14:40 pm by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Offline Offline
Jr. Member
**
Karma: 1
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Code:
tx = myTouch.TP_X;
XC= constrain (map(tx, 205, 3900,0,239),0,239);
Logged

Remember remember, the 4th of...July!  Duh.

Queens, New York
Online Online
Faraday Member
**
Karma: 101
Posts: 3645
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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)"
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Offline Offline
Jr. Member
**
Karma: 1
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Remember remember, the 4th of...July!  Duh.

Queens, New York
Online Online
Faraday Member
**
Karma: 101
Posts: 3645
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

weird
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Offline Offline
Jr. Member
**
Karma: 1
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Remember remember, the 4th of...July!  Duh.

Queens, New York
Online Online
Faraday Member
**
Karma: 101
Posts: 3645
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Offline Offline
Jr. Member
**
Karma: 1
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
#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);
    }
  }
}
Logged

Remember remember, the 4th of...July!  Duh.

Queens, New York
Online Online
Faraday Member
**
Karma: 101
Posts: 3645
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this.

Code:
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);
    }
  }
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Pages: 1 2 [3] 4 5   Go Up
Jump to: