Skip to content
This repository has been archived by the owner on Sep 26, 2018. It is now read-only.

Touch Y coordinate is inverted #4

Closed
DominikPalo opened this issue Dec 17, 2015 · 8 comments
Closed

Touch Y coordinate is inverted #4

DominikPalo opened this issue Dec 17, 2015 · 8 comments

Comments

@DominikPalo
Copy link

I'm using your library with a 2.4 TFT touchscreen bought on eBay. All works fine, except the touch functionality - every TSPoint obtained using TouchScreen.getPoint() has inverted the Y-coordinate. It would by nice to have an option to set coordinate system for TouchScreen instance (for example as optional parameter of the TouchScreen constructor).

I temporary fixed it by uncommenting the line #159 in the SPFD5408_TouchScreen.cpp file (return TSPoint(x, y, z);).

@ystrem
Copy link

ystrem commented Dec 17, 2015

+1

@JoaoLopesF
Copy link
Owner

Hi,

In mine TFTs I need invert the coords.
Can be in your case it not necessary.

Please modify the SPFD5408_TouchScreen, line 159:

before:

//return TSPoint(x, y, z);

// *** SPFD5408 change -- Begin
// SPFD5408 change, because Y coordinate is inverted in this controller
return TSPoint(x, 1023 - y, z);
// -- End

after:

return TSPoint(x, y, z);

// *** SPFD5408 change -- Begin
// SPFD5408 change, because Y coordinate is inverted in this controller
//return TSPoint(x, 1023 - y, z);
// -- End

If this ok, I can create an #define for this

Please send me if this ok now.

Regards

Joao

@hevergreen
Copy link

hevergreen commented Mar 5, 2017

Solved this in a strange way, but works...

used this tip to invert some pins
https://forum.arduino.cc/index.php?topic=405377.0

Swap the X and Y pin number in the sketch. Change this part:
Original

#define YP A1 // must be an analog pin, use "An" notation!
#define XM A2 // must be an analog pin, use "An" notation!
#define YM 7 // can be a digital pin
#define XP 6 // can be a digital pin

to
#define XM A1 // must be an analog pin, use "An" notation!
#define YP A2 // must be an analog pin, use "An" notation!
#define XP 7 // can be a digital pin
#define YM 6 // can be a digital pin

and set the "SPFD5408_TouchScreen.cpp"to

//return TSPoint(x, y, z);

// *** SPFD5408 change -- Begin
// SPFD5408 change, because Y coordinate is inverted in this controller
return TSPoint(1023- x, 1023 - y, z);
// -- End

Something tell me that I got a trick myself, but works!!

@detectingdragon
Copy link

Thank You, the only working way ive found on the internet!!!!

@mike-mustermann
Copy link

For me this work fine. I played with the TSPoint parameters. And BAM!
// *** SPFD5408 change -- Begin
// SPFD5408 change, because Y coordinate is inverted in this controller
return TSPoint(1100 - y, 1023 - x, 1023 - z);
// -- End

3 similar comments
@mike-mustermann
Copy link

For me this work fine. I played with the TSPoint parameters. And BAM!
// *** SPFD5408 change -- Begin
// SPFD5408 change, because Y coordinate is inverted in this controller
return TSPoint(1100 - y, 1023 - x, 1023 - z);
// -- End

@mike-mustermann
Copy link

For me this work fine. I played with the TSPoint parameters. And BAM!
// *** SPFD5408 change -- Begin
// SPFD5408 change, because Y coordinate is inverted in this controller
return TSPoint(1100 - y, 1023 - x, 1023 - z);
// -- End

@mike-mustermann
Copy link

For me this work fine. I played with the TSPoint parameters. And BAM!
// *** SPFD5408 change -- Begin
// SPFD5408 change, because Y coordinate is inverted in this controller
return TSPoint(1100 - y, 1023 - x, 1023 - z);
// -- End

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants