当使用树莓派4B+微雪2.8寸DSI屏时,会存在触摸屏显示方向问题,由于此mod原本搭配老的驱动才能使用,该方法已不再适用于Linux6.1 Bookworm,且微雪下架了老版本驱动,以下讲解如何在Bookworm中旋转显示方向。
dtoverlay=vc4-kms-v3d
#DSI1 Use
dtoverlay=vc4-kms-dsi-waveshare-panel,2_8_inch
#DSI0 Use
#dtoverlay=vc4-kms-dsi-waveshare-panel,2_8_inch,dsi0
但此时触摸屏是竖向显示的,需要进行旋转,微雪官网仅给出了在桌面环境下旋转的方法,实测只旋转了显示,触摸依然是竖向,因此弃用该方法。
进入树莓派的SSH,,创建一个旋转显示的配置。
sudo vim /usr/share/X11/xorg.conf.d/90-monitor.conf
若需要输入密码,则一般为 pi
。
按 insert 输入。
Section "Monitor"
Identifier "XWAYLAND0"
# This identifier would be the same as the name of the connector printed by xrandr
# for example "DVI-I-1 connected primary" means that the identifier is "DVI-I-1"
# another example "Unknown19-1 connected primary" some GPIO screens identify as Unknown19
Option "Rotate" "right"
# Valid rotation options are normal,inverted,left,right
Option "PreferredMode" "640x480"
# May be necesary if you are not getting your prefered resolution.
EndSection
按 ESC 退出输入模式。
输入 :wq!
,回车,保存并退出。
重启KS后显示将旋转90度。
测试了ks的wiki写的修改51-touchscreen.rules和40-libinput.conf,无效,另寻他法。
使用以下命令是可以使触摸也旋转90度的,但是重启会失效。
DISPLAY=:0 xinput set-prop "pointer:10-0014 Goodix Capacitive TouchScreen" 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
因此我们需要让他每次开机自动执行一次。
写一个脚本
sudo vim /etc/systemd/system/touchscreen_calibration.service
按 insert 输入
#!/bin/bash
sleep 15 #开机延迟执行
DISPLAY=:0 xinput set-prop "pointer:10-0014 Goodix Capacitive TouchScreen" 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
按 ESC 退出输入
输入 :wq!
保存
使用systemd来每次开机执行
sudo vim /etc/systemd/system/touchscreen_calibration.service
按 insert
在文件内输入
[Unit]
Description=Touchscreen Calibration
[Service]
ExecStart=/usr/local/bin/touchscreen_calibration.sh
Environment=DISPLAY=:0
User=pi #替换为你的用户名
[Install]
WantedBy=multi-user.target
按 ESC 退出输入
输入 :wq!
保存
运行服务
sudo systemctl daemon-reload
sudo systemctl enable touchscreen_calibration.service
sudo systemctl start touchscreen_calibration.service
检查服务是否启动
journalctl -u touchscreen_calibration.service
重启后应该依然能够保持触摸旋转的状态