I'm not new to arduino, in fact I've been using it for years. I built my own home automation system using IR,433Mhz and EasyVR voice recognition & 4x4 keypads. I've always been able to find answers but this time I am stopped dead in my tracks.
These are the parts I am using,
Arduino Mega 2560
TFT LCD Mega Shield V1.0 & V2.2 tried both shields
TFT_320QVT
TFT_320QVT_9341
I'm using #include <UTFT.h> #include <URTouch.h>
for my libraries,
I've found several sources that say these will work with my hardware, and several videos using the exact hardware and libraries.
So here's the problem, I've got the display working. I even found out how to get the _9341 display working using Henning Carlson's list and altering the UTFT.h file on the ds[Y] array changing the 399 to 319 and shifting the image to the center of the screen.
So now I have 2 separate shields and 3 touch displays in my hands (two TFT-320QVT that operate using "( ITDB32S ,38,39,40,41);") and (one TFT_320QVT_9341 that uses ITDB32WC ).
So multiple displays with different types all have the same issue, No Y axis. I've tried swapping Landscape to Portrait and the numbers follow the swap, i.e. one way I get only the x axis reporting numbers and the change starts giving me numbers on the Y axis. Always one but not both. I ran the calibration sketch and entered the data into Henning Carlsons Calibration Verifier and it says "the Y axis is out of range, that it is possibly a bad touchscreen or improper model". All 3 screens are using XPT2046 touch screen controllers. I figure it cant be a screen issue because they all act the same using both shields.
I'm all out of ideas, I even updated Arduino IDE to the latest version 1.6.12 to see if that would make a difference. I've downloaded other libraries but they would not compile. If there is another library to use I haven't found a working version of it. I downloaded XPT2046-master, TFT_Touch-master, marekburiak-ILI9341_due libraries but they would not compile. I don't know if it was the version I downloaded or what.
This is my first post to the Forum so please excuse any errors made in the attempt. Any Help would be great, I feel it may be something simple I am overlooking. I am including the sketch I put together to map the X & Y axis to the screen, let me know if you see any errors.
I looked high and low for some answer before adding this post, I couldn't find what I needed or I accidently overlooked it.
I responded to your post on my topic ....... then looked at your .ino which I did not spot before.
Try forcing your sketch to printout temp_x and temp_y immediately after the getX getY calls.
temp_x and temp_y are the raw touch reading in the URtouch library ... code see below
BTW URTouch ignores raw readings above 4096.
you may get error messages ... not declared ... etc but persevere........
best of luck
x=myTouch.getX();
y=myTouch.getY();
Serial.print("raw X"); Serial.println(temp_x); // URTouch library raw X value
Serial.print("raw Y"); Serial.println(temp_y); // URTouch library raw Y value
Serial.println("mark");
Serial.print(x); Serial.println("=X");
Serial.print(y); Serial.println("=Y");
Serial.println("mark");
If this sketch produces values in the X axis starting at zero and going up as I slide my finger from left to right then it means the screen is processing data from the X axis properly, I assume. Will the suggestions given effect one axis? If the code is exactly the same for X and Y axis why wouldn't I get the same results? Even if they are not close to full scale readings. That might be another problem I will have to tackle.
In short , will the suggestions help fix the reason why my data on the Y axis is bad.....i.e. min, middle or max but always the same 3 numbers no mater where u touch on the Y axis. Meanwhile the X axis is coresponding properly with your finger movments...........
hi,
The idea of printing out the raw x and y values is to test your hardware.
Raw values will not start at 0, my touch panel has a raw value of x of around 1960 which I would call pixel 5 (left most edge of TFT) and goes down to about 85 at the right most edge, as if my touch panel is the wrong way round.
If you get non-zero raw values for both x and y, then you know your wiring is correct and your hardware is working. If Y is always zero or always reports the same number then you have a hardware related problem.
I doubt you have the same problem over 2 or 3 touch panels, I suspect its your calibration code.
I do have the same problem over 3 different Touch screens and 2 different sheilds.
TFT LCD Mega Sheild V1.0
TFT LCD Mega Sheild V2.2
TFT_320QVT (2 of these screens)
TFT_320QVT_9341 (1 of these)
All with the same results ....a good x and no Y. Values for Y will read 79 .....249...and no where in between. As the X axis climbs the Y will stay on 79 then jump at random to 249 then back with no real pattern while the X axis rises as it should. Sliding your finger from left to right going up on a diagnal. ..as to increase both axis at the same time.
I know the purpose putting the raw(x) and raw (y) the the screen is to test hardware. That's why I did it. If you have a better scetch that displays x & Y values and uses these libraries can you post it for me.
It seems like a hardware issue...it should be a hardware issue but for 3 separate screens, swapped between 2 different sheilds all exactly the same issue. Is it posible? I hate to buy ANOTHER screen.
If you don't mind posting your scetch for Raw values it would be awesome.....or try mine and see if you get Y values that work.
Thanks for your help and input. It is much appreciated!
So my touch panel is as if upside down and wrong way around compared to the TFT pixel map.
Here are the two pieces of code I use in setup and loop .... the raw function is from XPT2046.h is spapadm library
// in setup()
// when y = 0 ie top of screen vi = 1965, when y = 599 ie bottom of screen vi = 176
yInc = 600.0 / ( 1965.0 - 176 ) ; // per pixel
// when x = 0 ie left of screen vj = 1980, when x = 1023 ie right of screen vj = 64
xInc = 1024.0 / ( 1980.0 - 64 ) ; // per pixel
x and y below are now equivalent to the pixel positions of my TFT pixel map (i.e . 0 to 1024 and 0 to 600)
// in loop()
touch.getRaw(vi, vj); // vi is y pos vj is x pos !!!!!!
x = (int)(( 1980.0 - (float)vj ) * xInc); // x is now equivalent to TFT pixel
y = (int)(( 1965.0 - (float)vi) * yInc); // y is now equivalent to TFT pixel
BTW - your last post is confusing. Are you saying your RAW y value is 79 or 249 only. If that is the case it is a hardware problem. But what is the only common HW in all your setups?
To cblx5, the only common hardware when changing screens and sheilds is the Mega board itself. I have another on the way to test this theory.
Thanks for all the help, I am going to reinstall my libraries to make sure I have the v2.82.
I downloaded my library from Henning carelsons website at rinkydink electronics. I am assuming this is the same URTouch library you are suggesting David.
If it's the code then why do none of the URTouch or UTFT examples work as far as touch screen response....they all have the same issue. The UTFT_buttons demo, URtouch demos all act the same in response to the touch screen.
If those programs are correct then why don't they work Properly. All you do is change a few variables to match your screen type and pinout, those are obviously correct....the same used in my xy axis display scetch.
Why would Henning Karlesens calibration verifier tell me
" the Y axis is out of range, either you have a bad touchscreen or the screen is not supported"
for every screen and both sheilds. Maybe there all bad?
I was thinking of writing a program that uses buttons like thin lines across the X axis and using values greater than or less than X to determine a button press only using one axis......of course this limits the number of buttons but I am truly out of options.
Thanks for your continued help with this. I really don't want to buy another screen. If I do should I get the same type or somthing completely different?
I'm looking for somthing that does not use the XPT2046 touch controller.. ......but who knows......after years of arduino I have finally hit an issue I can't fix. But its only been a few months, I will keep trying........
The disclaimers on the URTouch library state it has been tested on certain TFTs and shields. If yours is not identical, a bit of 'knifing and forking' might be required even though the chip is the same.
As an example I have a Sainsmart TFT and a CTE TFT and they behave differently to the colour GREEN using the UTFT library, but that is off topic.
Please do the following and clearly REPORT what you get. As per one my previous posts it is not clear what you have actually done. If you have then below then please clearly report.
Reload fresh URTouch libary
Carefully add the two raw print statements as shown above IN THE LIBRARY.
Write a VERY simple sketch with only serial monitor and touch initialised , do not include UTFT, ( and so do not initialise the TFT and no TFT calls)
Report on the raw temp_x and temp_y values from serial monitor at -
top of screen, quarter way down, half way down, 3 quarters down and at bottom
do the same for left to right.
That is actually 16 pairs of results!!
When you do that I will see if I can explain what might be happening within the library - but it must be the RAW (repeat RAW) values. Ignore or comment out any post calibration values.
Cblx5,
Step 2.
Are you referring to the 2 statements that you pulled from the xtp2046.h file? One goes in the setup () and the other in the loop ()? It apears those go in your sketch.
To add the raw print statements in the URTtouch library, which file? .h or .ccp
Thanks for the continued help, sorry if any of these questions seem dimwitted, I just wanted to make sure I get the correct code sections into the correct library file for URTouch.
Cblx5
Sorry about the last reply, I figured out what you were getting at.
I just altered the .cpp file properly with your raw values section and it compiled properly....after a little cut and paste.
I'm in the process of getting a quick sketch to get the values to the serial port and get some raw x/y values.
I just wanted to say THANKS AGAIN FOR YOUR HELP, Awesome!!, I'll have some values shortly.
I ended up using my MEGA for my new bedroom voice recognition IR/RF remote control. I'm tearing down my mega home automation test bed to test the touchscreen.....or maybe the one I ordered will show tomorrow.