問題描述
因爲項目需要將21寸的橫屏觸摸屏旋轉成豎屏使用,如果是在x86平臺上直接在系統設置一下屏幕旋轉就解決了,但是在arm平臺上這個問題就有點麻煩了。一開始使用xrand命令能夠實現屏幕旋轉,但是卻出現觸摸屏觸摸不準的問題,費勁查詢很多資料嘗試了很多方法最終得以解決。
解決過程
查看系統支持的顯示設備
在終端輸入
xrandr
查詢結果如下:
修改配置文件
在終端輸入
sudo vim /etc/X11/xorg.conf
如果不存在xorg.conf文件的話直接在/etc/X11/路徑下創建該文件即可。將文件內容修改如下:
Section "Monitor"
Identifier "HDMI-1"
Option "Rotate" "normal"
EndSection
Section "Screen"
Identifier "Screen0"
Monitor "HDMI-1"
Option "RandRRotation"
EndSection
Section "ServerLayout"
Identifier "DefaultLayout"
Screen "Screen0"
EndSection
Section "InputClass"
Identifier "touchscreen"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "SwapAxes" "true"
Option "InvertX" "false"
Option "InvertY" "true"
EndSection
參數說明:
Section "Monitor"
Identifier "HDMI-1" #設置默認顯示器爲HDMI-1
Option "Rotate" "normal" #設置屏幕旋轉 normal爲正常,left向左旋轉90度,
#right向右旋轉90度,inverted爲上下翻轉
EndSection
Section "Screen"
Identifier "Screen0"
Monitor "HDMI-1" #設置屏幕爲HDMI-1
Option "RandRRotation" #設置支持HDMI旋轉
EndSection
Section "InputClass"
Identifier "touchscreen" #觸摸屏設置
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "SwapAxes" "true"
Option "InvertX" "false" #設置觸摸屏X軸旋轉,true爲開啓,false爲關閉
Option "InvertY" "true" #設置觸摸屏Y軸旋轉,true爲開啓,false爲關閉
EndSection
總結
在arm板上因爲觸摸屏觸摸不準問題導致項目選擇顯示屏比較困難,現在解決了這個問題,以後對觸摸屏的選擇就多了,不同尺寸,橫豎屏都沒問題。注意,該方法只支持使用X11框架的linux系統。