From: Paul Hänsch Date: Wed, 24 Jul 2019 00:36:14 +0000 (+0200) Subject: enabled touch rotation, removed fixed screen rotation X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=b92b21b9548a5c7635e9cab6c15b872c5413d9cf;p=blast enabled touch rotation, removed fixed screen rotation --- diff --git a/config.example b/config.example index 95d1485..07edc44 100644 --- a/config.example +++ b/config.example @@ -46,9 +46,6 @@ ## In nodm, use full screen chromium web browser as session # webui=http://localhost/ -## Rotation for some Raspberry Displays -# display_rotate=0 - ## When using NIS modules the directory server should be given # nis_server=nismaster diff --git a/modules/display_ws5inch.mk b/modules/display_ws5inch.mk index 7b3e941..6f03a5d 100644 --- a/modules/display_ws5inch.mk +++ b/modules/display_ws5inch.mk @@ -1,12 +1,4 @@ -ifndef display_rotate - display_rotate := 0 -endif - -ifeq "${display_rotate}" "0" - display_touch_calibration := 200 3950 250 4000 -else ifeq "${display_rotate}" "2" - display_touch_calibration := 3950 200 4000 250 -endif +PACKAGES += xserver-xorg-input-evdev xinput xinput-calibrator define RPICONFIG += @@ -16,30 +8,47 @@ hdmi_mode=87 hdmi_cvt=800 480 60 6 0 0 0 hdmi_drive=1 dtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=50000,keep_vref_on=0,swapxy=0,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900 -display_rotate=${display_rotate} endef +export display_ws5inch_cfg display_ws5inch_rotation + define display_ws5inch_cfg := Section "InputClass" Identifier "evdev touchscreen catchall" MatchIsTouchscreen "on" - Option "Calibration" "${display_touch_calibration}" + Option "Calibration" "200 3950 250 4000" MatchDevicePath "/dev/input/event*" Driver "evdev" EndSection endef -export display_ws5inch_cfg +define display_ws5inch_rotation := +# Keep touch matrix rotated in accordance with screen rotation +while sleep 3; do + oldrotate="$${rotate}" + rotate="$$(xrandr |grep primary)" + rotate="$${rotate#*+0+0 }" + rotate="$${rotate% (*}" -PACKAGES += xserver-xorg-input-evdev xinput xinput-calibrator + [ "$${oldrotate}" = "$${rotate}" ] || case $$rotate in + left) xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1;; + right) xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1;; + inverted) xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1;; + *) xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1;; + esac +done & +endef .PHONY: _display_ws5inch _config: _display_ws5inch _display_ws5inch: ${CFGROOT} _copy _mount + # Rough touch calibration mkdir -p "$${CFGROOT}/usr/share/X11/xorg.conf.d/" printf '%s\n' "$${display_ws5inch_cfg}" >"$${CFGROOT}/usr/share/X11/xorg.conf.d/45-evdev.conf" + # Resolution / Rotation stuff mkdir -p "$${CFGROOT}/etc/X11/Xsession.d/" printf 'xrandr --size 800x480\n' >"$${CFGROOT}/etc/X11/Xsession.d/10display_resolution" + printf '%s\n' "$$display_ws5inch_rotation" >"$${CFGROOT}/etc/X11/Xsession.d/20touch_rotation" # Correct DPI scaling, although application support is mediocre mkdir -p "$${CFGROOT}/etc/X11/Xresources/" printf 'Xft.dpi: 180\n' >"$${CFGROOT}/etc/X11/Xresources/dpi_resolution"