Calibrating a 5″ Raspberry Pi touchscreen in Jessie

Previously, I posted about a 5″ touchscreen for the Raspberry Pi.

But I did not mention calibrating the touchscreen.

After a week’s holiday, I came back and sorted this fairly easily.

I was using Raspbian Jessie from NOOBS 1.8

First I installed a new utility:

sudo apt-get install xinput-calibrator

 Calibration

To calibrate the touchscreen, go to the menu>preferences>select “Calibrate touchscreen”

Touch each of the red crosses on the screen in turn, then cut and paste the resulting snippet to the following file by using this command:

sudo nano /usr/share/X11/xorg.conf.d/98-calibration.conf

(this will create a new file and open it for editing)

My entries are below:

Section “InputClass”

Identifier “calibration”

MatchProduct “ADS7846 Touchscreen”

Option “Calibration” “120 3970 205 3920” #(enter your numbers here)

Option “SwapAxes” “0”

EndSection

Ctrl-O to save, Crtl-x to exit, and then reboot, and your pointer should follow your finger correctly!

5″ touchscreen for a Raspberry Pi

Recently bought a Generic 5″ touchscreen from AliExpress.

Model number ZC37200

resolution 800×480

XPT2046 touch controller.

Excellent quality, but getting it working was a bit of a trial.

Many of the tutorials out there are misleading, outdated, or just plain wrong.

This is what I did:

 

First (easy part), connect it all up, and install Raspbian from NOOBS 1.8.

Either open a terminal or from another PC:

ssh pi@<IP address of your pi>

First the easy part, we get the screen working with a full display.

Because these small screens will only display at native resolution, you may get a partial screen display, or a distorted one.

You need to force native resolution, in the case of the 5” display, that is 800×480.

edit /boot/config.txt

sudo nano /boot/config.txt

edit these lines as follows:

# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (here we are forcing 800x480)
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0

The next step is to enable the touchscreen.

In the same file, remove the # from this line:

dtparam=spi=on

and add this line:

dtoverlay=ads7846,penirq=25,speed=10000,penirq_pull=2,xohms=150

save and reboot, everything worked!

Next we need to calibrate it, but I need more time to work that one out, will post in the next few days.