This tutorial describes the complete procedure for calibrating a touchscreen display using Weston, specifically validated with the DY1212W LVDS panel on the following NXP development platforms:
i.MX93‑EVK
FRDM‑i.MX95
FRDM‑i.MX8MP
While the initial calibration performed by Weston works only temporarily, this guide will walk you through configuring the system so that the calibration becomes persistent across reboots. The steps below include performing the initial calibration, editing Weston’s configuration, creating a calibration helper script, and applying udev rules to store the calibration matrix automatically.
Temporary Touchscreen Calibration
To begin, run the following command to perform an initial calibration of your touchscreen:
weston-touch-calibrator LVDS-1
After running this command, your display should be correctly calibrated.
However, this calibration is not persistent, and you will need to recalibrate after every reboot unless you complete the persistence steps below.
Making the Calibration Persistent
Follow the steps below to ensure that calibration settings are preserved across system restarts.
Step 1: Edit the Weston Configuration File
Open the following file:
/etc/xdg/weston/weston.ini
Under the [libinput] section, add these lines:
[libinput]
touchscreen_calibrator=true
+ calibration_helper=/usr/bin/save-calibration.sh
This enables the calibration helper script that will automatically save your settings.
Step 2: Create the Calibration Helper Script
Create a new script at:
/usr/bin/save-calibration.sh
Insert the following content:
#!/bin/bash
# Store the transformation arguments for the resistive touchscreen as udev rule
echo 'SUBSYSTEM=="input", KERNEL=="event[0-9]*", ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="'$2' '$3' '$4' '$5' '$6' '$7'"' >> /etc/udev/rules.d/touchscreen.rules
Make the script executable:
chmod 755 /usr/bin/save-calibration.sh
Step 3: Restart Weston and Recalibrate
Restart the Weston service:
systemctl restart weston
Run the calibration tool again to generate the persistent settings:
weston-touch-calibrator LVDS-1
reboot
Conclusion
After completing all of the steps above, your touchscreen calibration will now persist across reboots, ensuring a consistent user experience even after powering off the board. This configuration allows the system to automatically store and apply calibration data through a udev rule generated by your helper script.
If you encounter any issues or require further assistance, feel free to reach out.
Best regards,
Chavira