From 92db7feab8d6bfdae2ba3f37fe57d54e4e2d0040 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 5 Oct 2020 17:24:43 +0200 Subject: [PATCH] support for waveshare 4inch display (rev A) --- modules/display_wsLCD4.mk | 77 +++++++++++++++++++++++++++++++ modules/waveshare35a-overlay.dtb | Bin 0 -> 2610 bytes 2 files changed, 77 insertions(+) create mode 100644 modules/display_wsLCD4.mk create mode 100644 modules/waveshare35a-overlay.dtb diff --git a/modules/display_wsLCD4.mk b/modules/display_wsLCD4.mk new file mode 100644 index 0000000..7c32cf5 --- /dev/null +++ b/modules/display_wsLCD4.mk @@ -0,0 +1,77 @@ +PACKAGES += xserver-xorg-input-evdev xinput xinput-calibrator + +define RPICONFIG += + +### Waveshare 4 Inch Display ### +hdmi_force_hotplug=1 +dtparam=i2c_arm=on +dtparam=spi=on +enable_uart=1 +dtoverlay=waveshare35a +# 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 +hdmi_group=2 +hdmi_mode=1 +hdmi_mode=87 +hdmi_cvt 430 320 60 6 0 0 0 +hdmi_drive=2 +display_rotate=0 +endef + +export display_wsLCD4_cfg display_wsLCD4_rotation + +define display_wsLCD4_cfg := +Section "InputClass" + Identifier "calibration" + MatchProduct "ADS7846 Touchscreen" + Option "Calibration" "3950 172 3871 194" + Option "SwapAxes" "1" + Option "EmulateThirdButton" "1" + Option "EmulateThirdButtonTimeout" "1000" + Option "EmulateThirdButtonMoveThreshold" "300" + + # Identifier "evdev touchscreen catchall" + # MatchIsTouchscreen "on" + # Option "Calibration" "200 3950 250 4000" + # MatchDevicePath "/dev/input/event*" + # Driver "evdev" +EndSection +endef + +define display_wsLCD4_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% (*}" + + [ "$${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_wsLCD4 +_config: _display_wsLCD5 ${CFGROOT}/boot/waveshare35a.dtbo +_display_wsLCD4: ${CFGROOT} _copy _mount + # Rough touch calibration + mkdir -p "$${CFGROOT}/usr/share/X11/xorg.conf.d/" + printf '%s\n' "$${display_wsLCD4_cfg}" >"$${CFGROOT}/usr/share/X11/xorg.conf.d/45-evdev.conf" + # Resolution / Rotation stuff + mkdir -p "$${CFGROOT}/etc/X11/Xsession.d/" + printf 'xrandr --size 480x320\n' >"$${CFGROOT}/etc/X11/Xsession.d/10display_resolution" + printf '%s\n' "$$display_wsLCD4_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: 144\n' >"$${CFGROOT}/etc/X11/Xresources/dpi_resolution" + # Workaround for applications that do not handle DPI scaling correctly + -sed -i 's;^Exec=;Exec=env GDK_DPI_SCALE=.5 ;' \ + $${CFGROOT}/usr/share/applications/chromium*.desktop \ + $${CFGROOT}/usr/share/applications/firefox*.desktop \ + $${CFGROOT}/usr/share/applications/exo-web-browser.desktop + +${CFGROOT}/boot/waveshare35a.dtbo: modules/waveshare35a-overlay.dtb + cp "$<" "$@" diff --git a/modules/waveshare35a-overlay.dtb b/modules/waveshare35a-overlay.dtb new file mode 100644 index 0000000000000000000000000000000000000000..9f082e463c72cb8aafd60aaa9ca3709cc214f7fa GIT binary patch literal 2610 zcmbtWO^6&t6t3PRk{^R^BoHw~aRp=8b|;&SI~fEc2znJ%#LH0AT{GLHr@QT{-ktFj z7H{5i2qD+x=)t4c2;#+qH!mL4lNUimug34|s+z7zSd(DEn^)hf_g+=K_v%gmaPptu zg*d(`gy;)#^e6E1pjFVbAdKiE$nVr$Nty7+3N$ zATM9TJRE)>?#dYZ^DLi<8M8hf6*sOk>h$G(zlS-;(wT!?Jj2B-&y2dZ4t8a${{|%s z`wv=V@lnh_PSsd8xe0Z~0O6jM`0JH$eP4*{A^rm36OcdS4K8AMd=v9?0ltkn_x9^| zFlWsYGu~giT4KEYIVk_y$(aKVZ-381;)r_R!RRZ>z*iCc```n>55XCY^WfirzXSd) z_|kyvX9yU_7eQx1^hwM!Gyb*FMdd;S7OeP;S~&{3SY0mmyZ+c65+6KB&_+^=&M}Bpf1lVOtvmlz1`n>xPIVv z;j!i+&j6ed?Ims2S&~uuJV8%opo=r7n#$ z%B@)6%sXp(Wn5{$K!238_E$!eI+XLy_b5-*sF~Om>Ld5j3*d(kYrQ9{cs73v(B@}2 z)br`6%-yZ1e*yY0Z* zKll5cuin7OdZG*h(Fr#@Aw$sS;7{;BI+cr^N+Mn&`-Z5`Jkoxj0K;Rx5e|>}E;u~qd*JYx?|{SMw*HCzS;&ti<+PF} z!>53-r6M#QVWaKmNc#ufezJ_4A~9K6h-ya`DYVyQnj+~sPE?+2v8J=nl$+OTB4C-A zI*$uEReFJX;-MZPd`A%W`3t;gf!8iZjo!;rvm@ZnPZl*MeCdexp^L1@41Qc?=x*wY wM1+ZF!=1%dj%E{=J5xC)8Md!Ilq@eB%?tL#zouE}wg3PC literal 0 HcmV?d00001 -- 2.39.2