]> git.plutz.net Git - blast/blob - modules/display_ws5inch.mk
default packages
[blast] / modules / display_ws5inch.mk
1 PACKAGES += xserver-xorg-input-evdev xinput xinput-calibrator
2
3 define RPICONFIG +=
4
5 ### Waveshare 5 Inch Display ###
6 hdmi_group=2
7 hdmi_mode=87
8 hdmi_cvt=800 480 60 6 0 0 0
9 hdmi_drive=1
10 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
11 endef
12
13 export display_ws5inch_cfg display_ws5inch_rotation
14
15 define display_ws5inch_cfg :=
16 Section "InputClass"
17         Identifier "evdev touchscreen catchall"
18         MatchIsTouchscreen "on"
19         Option  "Calibration"   "200 3950 250 4000"
20         MatchDevicePath "/dev/input/event*"
21         Driver "evdev"
22 EndSection
23 endef
24
25 define display_ws5inch_rotation :=
26 # Keep touch matrix rotated in accordance with screen rotation
27 while sleep 3; do
28   oldrotate="$${rotate}"
29   rotate="$$(xrandr |grep primary)"
30   rotate="$${rotate#*+0+0 }"
31   rotate="$${rotate% (*}"
32
33   [ "$${oldrotate}" = "$${rotate}" ] || case $$rotate in
34     left)     xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 -1 1  1 0 0  0 0 1;;
35     right)    xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 1 0  -1 0 1  0 0 1;;
36     inverted) xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' -1 0 1  0 -1 1  0 0 1;;
37     *)        xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 1 0 0  0 1 0  0 0 1;;
38   esac
39 done &
40 endef
41
42 .PHONY: _display_ws5inch
43 _config: _display_ws5inch
44 _display_ws5inch: ${CFGROOT} _copy _mount
45         # Rough touch calibration
46         mkdir -p "$${CFGROOT}/usr/share/X11/xorg.conf.d/"
47         printf '%s\n' "$${display_ws5inch_cfg}" >"$${CFGROOT}/usr/share/X11/xorg.conf.d/45-evdev.conf"
48         # Resolution / Rotation stuff
49         mkdir -p "$${CFGROOT}/etc/X11/Xsession.d/"
50         printf 'xrandr --size 800x480\n' >"$${CFGROOT}/etc/X11/Xsession.d/10display_resolution"
51         printf '%s\n' "$$display_ws5inch_rotation" >"$${CFGROOT}/etc/X11/Xsession.d/20touch_rotation"
52         # Correct DPI scaling, although application support is mediocre
53         mkdir -p "$${CFGROOT}/etc/X11/Xresources/"
54         printf 'Xft.dpi: 180\n' >"$${CFGROOT}/etc/X11/Xresources/dpi_resolution"
55         # Workaround for applications that do not handle DPI scaling correctly
56         -sed -i 's;^Exec=;Exec=env GDK_DPI_SCALE=.5 ;' \
57           $${CFGROOT}/usr/share/applications/chromium*.desktop \
58           $${CFGROOT}/usr/share/applications/firefox*.desktop \
59           $${CFGROOT}/usr/share/applications/exo-web-browser.desktop