[SOLVED] arduino tft resistive touch panel senses touch coordinates backwards

Thread Starter

joblake326

Joined Jan 9, 2022
21
I've got a "LCD Display 4 Inch SPI Screen (Touchscreen) - 480x320 Resolution 2". I've installed libraries LCDWIKI_SPI and LCDWIKI_TOUCH. The examples all do what they are supposed to as far as what gets displayed on the screen.
The problem I'm having is with the touch functionality. Where I touch and where Arduino thinks I touch seem to be mirrored. Correct me if I'm wrong but I've concluded that there's no actual x and y pins for the resistive layer. I guess it's decoded on the board and then sent through the SPI.
One thing that is odd is that when I run the "touch_screen_calibration" sketch, it responds correctly to where I press over the moving target and the numbers that it displays on the screen are very close to what is in the cali_para.h file. So whatever method that's used to figure out the location of the touch is different between the calibration sketch and ALL of the touch examples....which is weird. Help me please?
 

DNA Robotics

Joined Jun 13, 2014
624
Could you flip the picture / background you are using to use the coordinates you are getting?
Or translate HorizontalPosition = 480-X.
 

Thread Starter

joblake326

Joined Jan 9, 2022
21
Is the screen rotation oriented the same way round in the calibrate and example programs?
Out of all the example programs, the "touch_screen_calibration" is the only one that responds correctly to the locations that I tap on the screen. For example the telephone keypad example flips my press positions so that if I press "8" it thinks that I hit "2".
 

Thread Starter

joblake326

Joined Jan 9, 2022
21
Then just reverse your data.
I'm very new at this stuff so I'd rather not make things more complicated by work arounds. There's something fundamentally wrong here. I'm guessing something very simple and or dumb. I think the big clue is that the "touch_screen_calibration" example works correctly.
 

djsfantasi

Joined Apr 11, 2010
8,255
Which direction is flipped?
Is it in both horizontal and vertical coordinates?
Given the example he cited, it’s flipping, at least, horizontally. I’d like to see what happens when a “7” is pressed. Does it return a “1” (horizontal flip) ? Or a “3” (flipped both horizontally and vertically) ?

Given that calibration works and ALL examples are flipped, I tend to suspect a software problem, not a hardware problem.

Starting with one example and the calibration sketch, I would check and compare the code. It’s not inconceivable that the examples were copied from those using different hardware and no one noticed the “flip”.
 

Thread Starter

joblake326

Joined Jan 9, 2022
21
I've attached the two sketches. "display_phonecall_1-9-22" draws a phone keypad and a push on the upper left corner registers as a push on the lower right and vice versa. Whereas "touch_screen_calibration_1-9-22" displays moving targets that respond perfectly when pushed with the stylus. And the coordinates that it puts on the screen are the same as what is in the "cali_para.h" file. If it helps I've also attached the 3 library files and a .pdf. I noticed in the .lib files that it says "IMPORTANT: LIBRARY MUST BE SPECIFICALLY CONFIGURED FOR EITHER TFT SHIELD OR BREAKOUT BOARD USAGE" My TFT is not a shield. I just have it connected to the MEGA with a bunch of cables. So I didn't make any changes to the .lib files. Sorry if I've gone overboard with the attachments.
 

Attachments

djsfantasi

Joined Apr 11, 2010
8,255
"IMPORTANT: LIBRARY MUST BE SPECIFICALLY CONFIGURED FOR EITHER TFT SHIELD OR BREAKOUT BOARD USAGE" My TFT is not a shield. I just have it connected to the MEGA with a bunch of cables. So I didn't make any changes to the .lib files. Sorry if I've gone overboard with the attachments
So it’s not a shield. But you’re using it stand-alone which likely means on a “breakout board”. What are the library modifications required for a breakout board? The note says either/or, and doesn’t present a nothing alternative.

I apologize, but I don’t have the time to read through all of the attachments containing all that code. That’s something you should do so you can learn how to use the touchscreen, understand libraries and improve your coding skills.

A pretty simple observation is if ALL of these libraries are used in the calibration code?

Plus, you haven’t answered what pressing a “7” results in?
 

Thread Starter

joblake326

Joined Jan 9, 2022
21
No apologies necessary. Regarding the "7" question, I'm not sure since I'm not running that sketch but I just ran a another example that allows you to draw on the screen. If I move the pen up, the line goes down. If I move the pen to the right, it goes to the left. And the calibration code DOES use the same libraries. And just as an aside, many kudos to this forum for helping me out almost immediately. I've never gotten any help from the "official" Arduino forum. I get a lot of views but no one helps. So thanks again!
 
Top