JoaoLopesF / SPFD5408

Adafruit Libraries changed to works in TFT 2.4 shields with the SPFD5408 controller for Arduino Uno and Mega (Discontinued library)
MIT License
154 stars 110 forks source link

Touch Y coordinate is inverted #4

Closed DominikPalo closed 5 years ago

DominikPalo commented 8 years ago

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 commented 8 years ago

+1

JoaoLopesF commented 8 years ago

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 commented 7 years ago

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!!

detectingdragon77 commented 7 years ago

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

mike-mustermann commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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