Skip to content

ESP32-2432S028 touchscreen coordinates to display coordinates transformation and calibration

Notifications You must be signed in to change notification settings

CF20852/ESP32-2432S028-Touchscreen-Calibration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

The calibration sketch, RNT_Touchscreen_Cal_6Pts_BLA.ino, was designed for use with the ESP32-2432S028, aka "Cheap Yellow Display". It can only be used with versions of the CYD that have a resistive touchscreen. Those displays have an XPT2046 chip next to the BOOT switch on the back of the module. The sketch is best used with a Serial Console connected so you can keep an eye on what's going on during data collection and processing.

To use the sketch, flash the sketch on a CYD, and then use a stylus to tap repeatedly and as precisely as possible on the center of each of the six '+' signs that are displayed one at a time after the initial text display. Stop tapping when the '+' sign disappears, and watch for another one to appear, for a total of six appearances of the '+' sign.

After the sketch processes the resistive touchscreen samples you create with your taps for all six points, it will display six '+' symbols where it asked you to tap and six 'X's where it thinks you tapped, after transforming resistive touchscreen coordinates to display coordinates using the coordinate rotation and translation equations shown in Eqs. 1 and 2 of the TI appnote at https://www.ti.com/lit/an/slyt277/slyt277.pdf. It is strongly recommended that you download and review this appnote if you want to understand the algorithm. The sketch will use the Arduino Preferences library to store the X & Y alpha, beta, and delta coefficients in non-volatile storage for use by other sketches.

Note that one tap on the screen often results in multiple samples. The longer you press on the screen during a tap, the more samples are taken. Try to make your taps rapid and brief.

As previously mentioned, the calibration sketch uses the Preferences library to save the alpha/beta/delta X and Y coefficients to non-volatile storage (NVS). The modified 1_9_Touchscreen_Test_w_Cal.ino sketch retrieves the coefficients from NVS and uses them in Eqs. 1 and 2 of the appnote.

The calibration sketch is currently set up to use the Basic Linear Algebra library to do the Eq. 7 calculations in the TI appnote. You must use Version 5.1.0 or later of this library. When I first developed the calibration sketch using Vesrion 5.0.0, I encountered some errors when I tried to compile that library with the ESP32 Dev board selected, and Tom Stewart quickly sent me a patch to install in the ElementStorage.h file, which corrected the problem. Tom has updated the Basic Linear Algebra library to Version 5.1.0. You can also change a couple of lines of code in the sketch to use the Matrix Math library instead of the Basic Linear Algebra library. Simply #undef USE_BLA and #define USE_MATRIX_MATH.

Updated 17 July 2024

About

ESP32-2432S028 touchscreen coordinates to display coordinates transformation and calibration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages