Hey folks,
PID 1770
https://www.adafruit.com/products/1770
I'm having a bit of an issue working with the touch mapping from the 2.8" TFT LCD with Touchscreen w/Micro SD. Specifically with the difference in drawn coordinates to touch coordinate results. With a menu being drawn with smaller buttons, the difference of +/- up to 20 pixels from drawn "menu options" to the touch response can be pretty agitating.
The screen has been rotated with: tft.setRotation(1);
p.x = map(p.x, TS_MINX, TS_MAXX, tft.height(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.width());
Example of the issue I'm having:
- Two boxes, 50 pixels by 50 pixels, are drawn at (50,50) and (150,150).
- Touch coordinates for (50,50) box: (60,30) top left corner, (101, 80) bottom right corner, (80, 40) center
- Touch coordinates for (150,150) box: (160,140) top left corner, (202, 184) bottom right corner, (180, 150) center
- Top left corner or screen which should be (0,0) gives out (10, - 15)
- Using an old PDA stylus
Have I made an obvious goof up? Asides from hard-coding offsets for the touch coordinates, is there anything I can do to just get it to work as intended? I'm open to any suggestions.
Thank you!
2.8"TFT LCD (PID:1770) - Touch Mapping
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: 2.8"TFT LCD (PID:1770) - Touch Mapping
Looks reasonably linear. I think you just go with the hard-coded offsets.
- Kavus
- Posts: 2
- Joined: Fri May 01, 2015 10:36 am
Re: 2.8"TFT LCD (PID:1770) - Touch Mapping
Thank you for the response. I'll be sure to do that.adafruit_support_rick wrote:Looks reasonably linear. I think you just go with the hard-coded offsets.
I'm still not certain why I'm getting negative results from mapping positive integers.
Thank you.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: 2.8"TFT LCD (PID:1770) - Touch Mapping
actually, your map calls are not correct. This is how you map to a rotation of 1:
Code: Select all
TS_Point p = ts.getPoint();
// Scale using the calibration #'s
// and rotate coordinate system
p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.height());
p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.width());
int y = tft.height() - p.x;
int x = p.y;
Please be positive and constructive with your questions and comments.