This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I have a dedicated question to the TI software developers who have developed the example software for GRLIB demo with Kentec320*240 display.
On the source code of the driver "touch.c", there are arrays of parameter to convert the ADC-value to LCD-X/Y-coordinates
//*****************************************************************************
//
// Touchscreen calibration parameters. Screen orientation is a build time
// selection.
//
//*****************************************************************************
const int32_t g_pi32TouchParameters[7] =
{
#ifdef PORTRAIT
3840, // M0
318720, // M1
-297763200, // M2
328576, // M3
-8896, // M4
-164591232, // M5
3100080, // M6
#endif
#ifdef LANDSCAPE
328192, // M0
-4352, // M1
-178717056, // M2
1488, // M3
-314592, // M4
1012670064, // M5
3055164, // M6
#endif
#ifdef PORTRAIT_FLIP
1728, // M0
-321696, // M1
1034304336, // M2
-325440, // M3
1600, // M4
1161009600, // M5
3098070, // M6
#endif
#ifdef LANDSCAPE_FLIP
-326400, // M0
-1024, // M1
1155718720, // M2
3768, // M3
312024, // M4
-299081088, // M5
3013754, // M6
#endif
};
But I want to connect a LCD with 480*320 pixel resolution and 4-wire touch to the microcontroller.
So I have the question, how are the parameters calculated to get the coordiantes of the touched position on the LCD.
The conversion is done be following code:
i32X = g_i16TouchX;
i32Y = g_i16TouchY;
i32Temp = (((i32X * g_pi32TouchParameters[0]) +
(i32Y * g_pi32TouchParameters[1]) + g_pi32TouchParameters[2]) /
g_pi32TouchParameters[6]);
i32Y = (((i32X * g_pi32TouchParameters[3]) +
(i32Y * g_pi32TouchParameters[4]) + g_pi32TouchParameters[5]) /
g_pi32TouchParameters[6]);
i32X = i32Temp;
where g_i16TouchX and g_i16TouchY are the ADC values.
It's very cryptic how it is programmed. Maybe a developer or a user can get an answer to this important question.
with regards...
That code was written 6 years ago and no one in the current TM4C support group was involved. Give me a day or two to inquire internally.
If I may - as one w/(some/slight) Display Experience - the following is offered. It is possible that you seek (only) 'Coordinate Calculations' - I will answer that - yet a 'bit more 'Touch Screen' detail' may prove valuable to others.
I've created a 'new thread' - more in keeping w/the 'Basics of Touch Screens' - as vendor has just announced that such effort was '6 years past.'
https://e2e.ti.com/support/microcontrollers/other/f/908/t/838837
Now our firm's method of 'Screen Calibration' involves, 'Systematic Touches at each Screen Edge and Screen Center - while one of the Screen Planes is powered. (i.e. one plane is powered - the other is then read - the pressure of the 'Touch' proves sufficient to impress voltage upon the 'undriven screen.' (i.e. the orthogonal planes come into 'contact' at the 'touch site!')
In most cases - my firm/others designate the 'Left, Bottom' portion of the Screen as the (near) '0,0' Location. Thus the Right, Top assumes 'max value' - and you are free to assign value to that. Note that the 'normal' touch screens may undergo (some) change in resistance with: 'lot, aging, use & temperature.' Under 'high accuracy demands' - it proves wise to provide regular 'Touch Screen Calibration' - in which the user will 'touch key targets' - which you generate & place 'on-screen' - to receive their (hopefully) overlapped touch. Your software can then make the necessary modifications (as/if required) to re-establish 'Accuracy of Touch.'
You may have been concerned due to vendor's use of 'FLIP' - imposed upon Landscape & Portrait. This provides the ability to 'accommodate' a 'reorientation' of the 'Display' - in case it must be rotated - for any reason. (usually to enable a 'better' fit - or mistaken measurement .)
Now to your 'dedicated question' - those calibration parameters appear in 'Groups of seven' - in my experience '5 such parameters' usually suffice. (4 identify each display corner, 1 marks display center) I believe that the 'enormity' of (many) of those (previous) vendor parameters result from the 'scaling up' of both the 'most significant 8 ADC bits' & the (earlier) 'display's pixel resolution.' The goal (should) be to eliminate the need for 'floats' - while 'Speeding & Easing' the 'ADC Voltage to Screen Pixel Location' Calculations. (i.e. makes the math easier for (both) MCU & programmer.)
It is further suspected that the (unusual), 'Use of Negative Numbered Parameters' is due to 'Designating the exact center of the display screen' as the '0,0' Location. (both horizontally & vertically) In this manner - Touch Location starts from and 'radiates out' from Screen Center. (assume Left & Down - referenced to screen center - yield those negative coordinates.) This methodology seems advantaged - as it may improve Touch Accuracy AND yield Faster Touch Calculations. (as most touch targets are likely to be nearer to screen center than screen edge!) Note that this is (all) 'cb1 theory' - which may - or may not - correctly describe/represent vendor's implementation...
With the vastly increased pixel field (which your 480x320 display provides) it may be that your 'Touch Screen's Resolution' - becomes challenged. It is normal/customary to determine the 'reasonable screen area' over which a 'touch extends' - and then to use that measure to determine 'how many & at what separation' (legitimate) 'Touch Targets' may be placed. You may then 'slide' your touch targets - either left/right or up/down (or both) - to more precisely overlap your display's 'touch directing pixels.' (these announce/present the 'screen's target area for the touch'')
To my mind - the attempt to 'duplicate' the past parameter calculation - may prove w/out substantial merit. It is believed that the 'general methods listed here' - will most usually - enable you to 'generate & detect multiple & efficiently sized/placed 'touch targets.' Relating the resulting ADC voltage produced - to each target's touch location - should not prove (that) difficult - and may resolve via a (near) linear formula.
CB1,
Thank you for a great answer. When I asked internally I was directed to this non-TI explanation.
https://www.embedded.com/design/system-integration/4023968/How-To-Calibrate-Touch-Screens
Bob,
And likewise - thank you - especially for such kind words.
My writing was 'Off the cuff' - represented entirely (my personal) thinking - w/out benefit of any references. (Past - sometimes brutal experience - is a (very) good teacher.)
We have a 'fresh college student crüe' - which describes my 'increased forum presence' - as many of my writings are for 'Staff Knowledge' - as well as, 'Assisting those here.' (if and when - such proves possible...)
Staff will read/review your 'find' - as noted - I'm unaware of its content.
It will prove of much interest - if my 'theory' of Touch Screen Center (both horiz & vert) indeed is recorded as Screen Coordinate '0,0'? Once we 'Put out' the ever arising 'Tech Fires' - new staff may 'deep dive' w/this - and should the forum prove interested - more detail (findings) can be presented... (maybe)
You may wish to glance at my, 'Rat & Pigeon vs cb1' (damn cover is forever blown) Touch Screen Posting - believed 'too broad' for this poster - yet still of value to (many) here. (I hope.)
Bob Crosby said:Thank you for a great answer. When I asked internally I was directed to this non-TI explanation.
https://www.embedded.com/design/system-integration/4023968/How-To-Calibrate-Touch-Screens
Bob,
Staff & I have just read/reviewed the article you linked - it is our impression that:
We have provided Touch-Screens & Mated Displays for the cockpits of fighter planes - and have never 'found the need' to create & resolve 'partial differential equations' - to map touch coordinates to (reasonably) sized displays.