-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
touch not working #6
Comments
seems like the touch work but there is big offset between where i touch and it react |
if i touch top left i get x=320, y=239, if i touch top right i get x= 4, y=240, if i touch bottom left i get x=320, y=-416 (note: it is negative 416), if i touch bottom right i get x=2, y=-235 seems like need calibration, could you please help |
It seems you just need to swap the x coordinate. You can do it easily here: https://github.com/littlevgl/esp32_ili9341/blob/master/drv/xpt2046.c#L95 x = 320-x;
if( x < 0) x = 0;
if(x > 319) x = 319;
last_x = x; |
with that correction i get the following result if i touch top left i get x=0, y=239, if i touch top right i get x= 320, y=240, if i touch bottom left i get x=0, y=-416 (note: it is negative 416), if i touch bottom right i get x=320, y=-293 here where i added: /*Normalize Data*/
x = x >> 3;
y = y >> 3;
xpt2046_corr(&x, &y);
xpt2046_avg(&x, &y);
x = 320-x;
if( x < 0) x = 0;
if(x > 319) x = 319;
last_x = x;
//last_x = x;
last_y = y; |
more accurate data using pen for touch if i touch top left i get x=0, y=239, if i touch top right i get x= 320, y=240, if i touch bottom left i get x=0, y=-416 (note: it is negative 416), if i touch bottom right i get x=320, y=-416 |
I see. It really still need to be calibrated. You should try to set the MIN coordinates to 0 and MAX to 4096 to disable calibration, check the coordinates and write them as calibration values. I forget that here you can also invert the X and/or Y coordinates if required. So the previous hack is not required. |
ok, if i do min=0 and max 4096 i get teh followings #define XPT2046_X_MIN 39 but when i put them in my code it doesn't work still i also tried the followings but no success #define XPT2046_X_MIN 390 Note, X invert need to be 0 thanks for all your help |
What was the problem with the first version? |
ok i ran it again with 0 and 4096, here are the numbers, if i enter these numbers in my code and compile i get the followings i get bottom left x=379, y=-4118 which make no sense |
I have no idea. The correction happens here: https://github.com/littlevgl/esp32_ili9341/blob/master/drv/xpt2046.c#L116 With the parameters, you provided it should work. You can debug it using |
i can't figure out what is going on, is it possible to recommend me a display that works with this code. thanks, |
i set the invert for Y to 1 and i believe this is where the problem is, it is creating a negative number for Y #if XPT2046_Y_INV != 0 |
top left should be 0,0 or bottom left ? |
Top-left should be (0,0).
You should
Resistive TPs might be different even for the same product type. |
This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I also noticed the touch isn't working, in my case when i touch the screen from right to left the red dots appear from top to bottom, when i touch the screen from bottom to top the red dots appears from right to left. I haven't tried to log the input device output, is there a 'easy' way to do it? Regards |
@C47D Use |
Thanks, i will take a look at it. |
This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
i am using 2.8 inch TFT 320x240 version 1.1 with xpt 2046 touch drive, but the touch part is not working, could you please advice?
i thought it was the screen and bought another one but i have the same issue
link for my screen: https://www.esp8266.com/viewtopic.php?f=160&t=14302
The text was updated successfully, but these errors were encountered: