Go Down

Topic: 2.4 inch TFT touch LCD Screen Module For Arduino UNO R3 SD low price jocks (Read 216800 times) previous topic - next topic


No,  that would not work.

As soon as you call getPoint(),  the XM,YP pins are set to INPUT mode.   The next TFT call will crash.

There are several solutions:
1.  the Touch library should always restore the mode of XM, YP
2.  the TFT library should always set the mode of XM, XP on every call
3.  the User application restores the mode of XM, YP after every getPoint()

Since most apps will have millions of TFT calls e.g. drawPixel() but not many getPoint() calls,  the cost of (2) is far more wasteful than (1).

And since many TFT apps do not use the Touch at all,  (3) would be the most "efficient".
OTOH,  (1) would save you having to worry about it.



yes, youre right, i missed that part when it switches to input.
(1) is way to go then.
Thank you


You would have to persuade the TouchScreen library authors first.

All new library owners would be happy.
But it means that any "old" library versions would fail.

Just accept the status quo.   And do the workaround with (3)
If you create a helper function that combines the getPoint() and pinMode() calls,   you handle it one place.



Can you, pls, explain the algorithm and math behind calibration method as posted in #19 ?
It works pretty well for my 2.4" TS, however not sure how exactly the correction is calculated and implemented via map().

Thx, ZV


It is quite simple.   Obtain the values for LEFT,  RIGHT of the Touch panel.
These are typically 150, 930 or 930, 150.

There are several Calibration sketches that can determine the LEFT, RIGHT, TOP,  BOT values returned by ts.getPoint().   e.g. get more accurate values than 150, 930

Then you map LEFT, RIGHT to 0, width() to obtain the X pixel coordinate.
Similarly for Y.



Thx, David !
Conceptually, it is indeed straightforward.
However, the details of implementation makes me curious.
Proposed code in post #19 uses two point calibration, which is OK for small TFT.
The goal of the calibration is to refine the default values (TS_MINX, TS_MAXX) for "improved" mapping.
Assuming no skew, the standard calibration equation is: x2=x1*k +a;
- k is a slope, and "a" is an offset;
- obviously k= (TS_MAXX-TS_MINX)/width, while I do not have a good idea how to define "a" via TMINX.

Pls see below excerpt from TS_calibration code, as in #19.
As you can see, both coefficients are calculated, using two sample points (opposite corners).
In the code derivation, I use, points p1, p2 are obtained via map(), using defaults TS_MINX, TS_MAXX (some manipulation should be implemented due to rotation of TFT screen vs. Touch screen).
The process starts with the defaults for LEFT-RIGHT (150, 930), which are used for 1st mapping "guess".
Then TS_MINX is being adjusted for the offset, but I don't understand the math behind the code...
 Note:(width-20), (height-20) are used because two sample dots are shown with the offset of (10,10) from the corners.

Thx, VZ.

Code: [Select]

 temp=p2.x-p1.x; // Calculate the new coefficients, get X difference
 TS_MINX=p1.x-( (tempL*10)>>10);// 10 pixels du bord
 TS_MAXX=p1.x+( (tempL*tft.width())>>10);// 220 pixels entre points
 temp=p2.y-p1.y; // ┬Ęget Y difference
 TS_MINY=p1.y-( (tempL*10)>>10);// 10 pixels du bord
 TS_MAXY=TS_MINY+( (tempL*tft.height())>>10);


God invented the map() function so you don't have to.

I am amazed by how people like to complicate things.



I am trying to interface 2.4" tft touch display for S6D0154 driver but i m not getting result please help me to display sensor data on touch screen display with arduino uno and mega both for S6D0154 library.


What S6D0154 library?
Please post a link to the "library"
Please post a link to the actual display that you have bought.


Go Up