Skip to content

Commit

Permalink
New touchscreen calibration script
Browse files Browse the repository at this point in the history
Supports calibration in all 4 directions. Screen rotation is
implemented using LIBINPUT_CALIBRATION_MATRIX property instead of
tslib because tslib rotation is buggy

see Openvario#17 (comment)
  • Loading branch information
kedder committed Jun 15, 2020
1 parent 2e06396 commit d6db196
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
20 changes: 20 additions & 0 deletions recipes-apps/ovmenu-ng-skripts/files/ov-calibrate-ts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
ROT=`cat /sys/class/graphics/fbcon/rotate`

# Perform the calibration
TSLIB_TSDEVICE=/dev/input/touchscreen0 ts_calibrate -r $ROT

echo "Applying the libinput calibration matrix according to current rotation ($ROT)"
case $ROT in
0) ROTMATRIX="1 0 0 0 1 0" ;;
1) ROTMATRIX="0 1 0 -1 0 1" ;;
2) ROTMATRIX="-1 0 1 0 -1 1" ;;
3) ROTMATRIX="0 -1 1 1 0 0" ;;
esac

echo "ENV{LIBINPUT_CALIBRATION_MATRIX}=\"$ROTMATRIX\"" > /etc/udev/rules.d/libinput-ts.rules
udevadm control --reload
udevadm trigger

echo Restart ts_uinput
systemctl restart ts_uinput
3 changes: 3 additions & 0 deletions recipes-apps/ovmenu-ng-skripts/ovmenu-ng-skripts_0.1.bb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ SRC_URI = "\
file://upload-all.sh \
file://upload-xcsoar.sh \
file://download-all.sh \
file://ov-calibrate-ts.sh \
"


Expand All @@ -39,6 +40,7 @@ do_install() {
install -m 0755 ${S}/upload-all.sh ${D}/usr/bin/upload-all.sh
install -m 0755 ${S}/upload-xcsoar.sh ${D}/usr/bin/upload-xcsoar.sh
install -m 0755 ${S}/download-all.sh ${D}/usr/bin/download-all.sh
install -m 0755 ${S}/ov-calibrate-ts.sh ${D}/usr/bin/ov-calibrate-ts.sh
}

FILES_${PN} = "/usr/bin/xcsoar_config.sh \
Expand All @@ -48,4 +50,5 @@ FILES_${PN} = "/usr/bin/xcsoar_config.sh \
/usr/bin/upload-all.sh \
/usr/bin/download-all.sh \
/usr/bin/upload-xcsoar.sh \
/usr/bin/ov-calibrate-ts.sh \
"
6 changes: 2 additions & 4 deletions recipes-apps/ovmenu-ng/files/openvario-43-rgb/ovmenu-ng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,8 @@ function calibrate_sensors() {

function calibrate_touch() {
echo "Calibrating Touch ..." >> /tmp/tail.$$
# reset touch calibration
# uboot rotation
ts_calibrate -r $(cat /sys/class/graphics/fbcon/rotate)
dialog --msgbox "Calibration OK !!\nPlease reboot to apply !!" 10 50
/usr/bin/ov-calibrate-ts.sh >> /tmp/tail.$$
dialog --msgbox "Calibration OK!" 10 50
}

# Copy /usb/usbstick/openvario/maps to /home/root/.xcsoar
Expand Down
6 changes: 2 additions & 4 deletions recipes-apps/ovmenu-ng/files/openvario-57-lvds/ovmenu-ng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,8 @@ function calibrate_sensors() {

function calibrate_touch() {
echo "Calibrating Touch ..." >> /tmp/tail.$$
# reset touch calibration
# uboot rotation
ts_calibrate -r $(cat /sys/class/graphics/fbcon/rotate)
dialog --msgbox "Calibration OK !!\nPlease reboot to apply !!" 10 50
/usr/bin/ov-calibrate-ts.sh >> /tmp/tail.$$
dialog --msgbox "Calibration OK!" 10 50
}

# Copy /usb/usbstick/openvario/maps to /home/root/.xcsoar
Expand Down
6 changes: 2 additions & 4 deletions recipes-apps/ovmenu-ng/files/openvario-7-CH070/ovmenu-ng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,8 @@ function calibrate_sensors() {

function calibrate_touch() {
echo "Calibrating Touch ..." >> /tmp/tail.$$
# reset touch calibration
# uboot rotation
ts_calibrate -r $(cat /sys/class/graphics/fbcon/rotate)
dialog --msgbox "Calibration OK !!\nPlease reboot to apply !!" 10 50
/usr/bin/ov-calibrate-ts.sh >> /tmp/tail.$$
dialog --msgbox "Calibration OK!" 10 50
}

# Copy /usb/usbstick/openvario/maps to /home/root/.xcsoar
Expand Down
6 changes: 2 additions & 4 deletions recipes-apps/ovmenu-ng/files/openvario-7-PQ070/ovmenu-ng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,8 @@ function calibrate_sensors() {

function calibrate_touch() {
echo "Calibrating Touch ..." >> /tmp/tail.$$
# reset touch calibration
# uboot rotation
ts_calibrate -r $(cat /sys/class/graphics/fbcon/rotate)
dialog --msgbox "Calibration OK !!\nPlease reboot to apply !!" 10 50
/usr/bin/ov-calibrate-ts.sh >> /tmp/tail.$$
dialog --msgbox "Calibration OK!" 10 50
}

# Copy /usb/usbstick/openvario/maps to /home/root/.xcsoar
Expand Down

0 comments on commit d6db196

Please sign in to comment.