1 PACKAGES += xserver-xorg-input-evdev xinput xinput-calibrator
5 ### Waveshare 4 Inch Display ###
10 dtoverlay=waveshare35a
11 # 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
15 hdmi_cvt 430 320 60 6 0 0 0
20 export display_wsLCD4_cfg display_wsLCD4_rotation
22 define display_wsLCD4_cfg :=
24 Identifier "calibration"
25 MatchProduct "ADS7846 Touchscreen"
26 Option "Calibration" "3950 172 3871 194"
28 Option "EmulateThirdButton" "1"
29 Option "EmulateThirdButtonTimeout" "1000"
30 Option "EmulateThirdButtonMoveThreshold" "300"
32 # Identifier "evdev touchscreen catchall"
33 # MatchIsTouchscreen "on"
34 # Option "Calibration" "200 3950 250 4000"
35 # MatchDevicePath "/dev/input/event*"
40 define display_wsLCD4_rotation :=
41 # Keep touch matrix rotated in accordance with screen rotation
43 oldrotate="$${rotate}"
44 rotate="$$(xrandr |grep primary)"
45 rotate="$${rotate#*+0+0 }"
46 rotate="$${rotate% (*}"
48 [ "$${oldrotate}" = "$${rotate}" ] || case $$rotate in
49 left) xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1;;
50 right) xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1;;
51 inverted) xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1;;
52 *) xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1;;
57 .PHONY: _display_wsLCD4
58 _config: _display_wsLCD5 ${CFGROOT}/boot/waveshare35a.dtbo
59 _display_wsLCD4: ${CFGROOT} _copy _mount
60 # Rough touch calibration
61 mkdir -p "$${CFGROOT}/usr/share/X11/xorg.conf.d/"
62 printf '%s\n' "$${display_wsLCD4_cfg}" >"$${CFGROOT}/usr/share/X11/xorg.conf.d/45-evdev.conf"
63 # Resolution / Rotation stuff
64 mkdir -p "$${CFGROOT}/etc/X11/Xsession.d/"
65 printf 'xrandr --size 480x320\n' >"$${CFGROOT}/etc/X11/Xsession.d/10display_resolution"
66 printf '%s\n' "$$display_wsLCD4_rotation" >"$${CFGROOT}/etc/X11/Xsession.d/20touch_rotation"
67 # Correct DPI scaling, although application support is mediocre
68 mkdir -p "$${CFGROOT}/etc/X11/Xresources/"
69 printf 'Xft.dpi: 144\n' >"$${CFGROOT}/etc/X11/Xresources/dpi_resolution"
70 # Workaround for applications that do not handle DPI scaling correctly
71 -sed -i 's;^Exec=;Exec=env GDK_DPI_SCALE=.5 ;' \
72 $${CFGROOT}/usr/share/applications/chromium*.desktop \
73 $${CFGROOT}/usr/share/applications/firefox*.desktop \
74 $${CFGROOT}/usr/share/applications/exo-web-browser.desktop
76 ${CFGROOT}/boot/waveshare35a.dtbo: modules/waveshare35a-overlay.dtb