Capacitive Touchscreen Configuration

If you've grabbed our Easy Install image, or use the script, this step is not required, it's already done! This is just for advanced users who are curious on how to configure and customize the touchscreen

The nifty thing about capacitive touch screens is that they do not require calibration! The calibration is done 'in chip' on the screen itself. However, we still do need to tell the Pi how to read the capacitive chip.

Before we start, we'll make a udev rule for the touchscreen. That's because the eventX name of the device will change a lot and its annoying to figure out what its called depending on whether you have a keyboard or other mouse installed.

First up figure out if you have the FT62X6 driver or FT6236 driver by running dmesg | grep ft6

 

If you are running FT6236 driver

Run

sudo nano /etc/udev/rules.d/95-ft6236.rules

to create a new udev file and copy & paste the following line in:

SUBSYSTEM=="input", ATTRS{name}=="ft6236", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"

If you are running FT6X06 driver

Run

sudo nano /etc/udev/rules.d/95-ft6206.rules

to create a new udev file and copy & paste the following line in:

SUBSYSTEM=="input", ATTRS{name}=="ft6x06_ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"

Reboot the Pi with sudo reboot

Then type ls -l /dev/input/touchscreen
It should point to eventX where X is some number, that number will be different on different setups since other keyboards/mice/USB devices will take up an event slot

Event Testing

Even though capacitive touch screens don't require calibration, there are some useful tools we can use to debug the touchscreen. Install the "event test" and "touchscreen library" packages with

sudo apt-get install evtest tslib libts-bin

Now you can use some tools such as

sudo evtest /dev/input/touchscreen

which will let you see touchscreen events in real time, press on the touchscreen to see the reports.

TSLIB calibration

In order to use TSLIB - basically, the touchscreen without X11 - you'll need to set the calibration for TSLIB in /etc/pointercal

With a resistive touchscreen, you have to calibrate it. Since capacitive touchscreens don't require calibration you can just input the numbers directly. Run
sudo nano /etc/pointercal
And enter in the following values (there's a single space between each number) and hit return afterwards. Then save
320 65536 0 -65536 0 15728640 65536

Next you can run

sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_test

X11 Calibration

We can also manually enter in the touch calibration
edit the file with
sudo nano /etc/X11/xorg.conf.d/90-captouch.conf
and put the following in for rotation=90. For other rotations you may have to tweak SwapAxes and InvertY or InvertX
Section "InputClass"
         Identifier "captouch"
         MatchProduct "ft6x06_ts"
         Option "SwapAxes" "1"
         Option "InvertY" "1"
         Option "Calibration" "0 320 0 240"
EndSection 

Calibration for other rotations

If you rotate the display you need to recalibrate the touchscreen to work with the new screen orientation. Since there's no calibration, you kinda just have to know the values for each rotation. To make it easy, you can run a small Python script which will automatically set a default touchscreen calibration based on the screen orientation.

This helper is automatically installed for you but if you'd like you can check it out here on github

Run it at the command line with sudo adafruit-pitft-touch-cal
it will try to figure out what display you have installed and the rotation it's set up for

By default the script will attempt to read the screen orientation by examining the PiTFT module configuration with modprobe. If the script can read the orientation it will print out the current orientation, the current touchscreen calibration values, and the new touchscreen calibration values baesd on the current orientation. Before updating the calibration the script will ask you to confirm that you'd like to make the change. Press y and enter to confirm.

Last updated on 2016-10-12 at 05.34.26 PM Published on 2014-07-21 at 05.51.08 PM