Touch Screen Calibration (Linux)
Introduction
Touch screen under Embedded Linux requires a kernel module that receives the hardware signals and exports them as an input device to be read in user space by a library.
As an example, if you are using Boot to Qt image with Capacitive Touch Display 7" Parallel, your setup will look like the following flowchart:
On the other hand, if you are using Ångström X11 image with Resistive Touch Display 7" Parallel, your setup will look like the following flowchart:
In this article, touch screen calibration will be discussed applied to different libraries and its methods to correctly calibrate your touchscreen display.
Resistive Touch Screen
Touch screen calibration almost always implies calibrating a resistive touch, since the capacitive touch panels usually are calibrated by default. It means that this article is most useful if you have a resistive touch panel.
Read the following article to learn more about Resistive Touch Screen on our Embedded Linux BSPs.
Toradex Embedded Linux Offerings
BSP Layers and Reference Images for Yocto Project
BSP 5 provides Weston/Wayland support, as described in the BSP Layers and Reference Images for Yocto Project Software. The Reference Multimedia Image comes with weston-touch-calibrator
which can be used to calibrate the touch screen:
# weston-touch-calibrator
You may need to change the default Weston configuration to make it work, though. See how we have implemented the weston-touch-calibrator container on Touch Screen Calibration (Torizon) as an example implementation.
Possibly you'll have to update the weston.ini
file. Check the GitHub repository with the Weston Container.
Torizon
Torizon uses Weston and Libinput. Toradex provides a container for touch screen calibration. For more details read Touch Screen Calibration (Torizon).
Input Libraries
Touch screen calibration concerning the input libraries is provided in this section.
libinput
As mentioned in libinput's wiki:
libinput is a library to handle input devices in Wayland compositors and to provide a generic X.Org input driver. It provides device detection, device handling, input device event processing and abstraction so minimize the amount of custom input code compositors need to provide the common set of functionality that users expect.
Concerning Toradex offerings, Libinput is used by:
Calibration
For static configuration via udev, one can set the LIBINPUT_CALIBRATION_MATRIX udev property as a environment variable with the following udev rule:
ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 1 0"
You can use the following command line examples to create a file with the udev rule.
Default matrix:
echo 'ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 1 0"' > /etc/udev/rules.d/libinput.rules
Invert Y axis only:
echo 'ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 -1 1"' > /etc/udev/rules.d/libinput.rules
Invert X axis only:
echo 'ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 1 0"' > /etc/udev/rules.d/libinput.rules
Invert X and Y axis:
echo 'ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 -1 1"' > /etc/udev/rules.d/libinput.rules
Further information on the LIBINPUT_CALIBRATION_MATRIX, please access the documentation.
Display Servers and Frameworks
Touch screen calibration concerning display servers (such as Xorg and Wayland) or standalone frameworks (such as Qt) is provided in this section.
Qt
The Qt framework supports different input methods. Regardless of this article's information, please also consult the official Qt documentation.
Boot to Qt
The Qt for Device Creation demo image uses libinput, therefore please refer to the previous libinput section for touchscreen calibration information.