當前位置:編程學習大全網 - 編程語言 - 樹莓派顯示翻轉和觸摸翻轉

樹莓派顯示翻轉和觸摸翻轉

問題:未使用的Pi官方屏幕,所以使用HDMI屏幕顯示的時候,顯示旋轉的同時,觸摸沒有旋轉

目的:旋轉屏幕顯示的同時,使得觸摸也跟隨旋轉

操作總流程:

旋轉180度操作

1.sudo nano /boot/config.txt

2.在文件末尾加入

display_rotate=0

display_rotate=1? //90°

display_rotate=2? //180°

display_rotate=3? //270°

ctrl + o 保存文檔 重啟即可。

這個需要xinput

註:以下操作皆為SSH操作,所以每條指令前都加了DISPLAY=:0,如果本機操作刪掉即可。

sudo apt-get install xinput

xinput --list

如果遠程操作記得在命令前加DISPLAY=:0

得到以下信息:

pi@raspberrypi:~ $ xinput --list

?Virtual corepointer id=2 [masterpointer? (3)]

?Virtual core XTESTpointer id=4 [slave? pointer?(2)]

?Silicon WorksMulti-touch SW4101C id=6 [slave? pointer?(2)]

?Virtual corekeyboard id=3 [master keyboard (2)]

?Virtual core XTEST keyboard? id=5 [slave?keyboard (3)]

pi@raspberrypi:~ $

pi@raspberrypi:~ $ xinput --list-props 6

Device 'Silicon Works Multi-touch SW4101C':

? DeviceEnabled (114):? 1

? CoordinateTransformation Matrix (115):? 1.000000,0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

? libinputCalibration Matrix (246): -1.000000,0.000000, 1.000000, 0.000000, -1.000000, 1.000000, 0.000000, 0.000000, 1.000000

? libinputCalibration Matrix Default (247):? 1.000000,0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

? libinputSend Events Modes Available (248): 1,0

? libinputSend Events Mode Enabled (249): 0, 0

? libinputSend Events Mode Enabled Default (250):? 0,0

? DeviceNode (251):? "/dev/input/event0"

? DeviceProduct ID (252):? 10685, 16641

查看/usr/share/X11/xorg.conf.d/目錄下是否有40-libinput.conf這個文件。

無 則需要安裝

sudo apt-get installxserver-xorg-input-libinput

壹開始xorg.conf.d這個目錄在/etc/X11可能沒有,需要自己創建。

sudo mkdirxorg.conf.d

sudo cp/usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/

cd/etc/X11/xorg.conf.d/

sudo vim 40-libinput.conf

找到touchscreensection

Section"InputClass"

? Identifier "libinput touchscreencatchall"

? MatchIsTouchscreen "on"

? MatchDevicePath "/dev/input/event*"

? Driver "libinput"

EndSection

添加壹行?Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1“

結果為

Section"InputClass"

? Identifier "libinput touchscreencatchall"

? Option "CalibrationMatrix" " -1 0 1 0 -1 1 0 0 1“

? MatchIsTouchscreen "on"

? MatchDevicePath "/dev/input/event*"

? Driver "libinput"

EndSection

Complete the above steps to perform a 90degree rotation.

Note:

90 degree rotation :Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"

180 degree rotation :Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1"

270 degree rotation :Option "CalibrationMatrix" "0 -1 1 1 0 0 0 0 1"

pi@NTGAGE:~ $ DISPLAY=:0 xinput --list-props 7

Device 'WaveShare WaveShare Touchscreen':

Device Enabled (115): ? 1

Coordinate Transformation Matrix (116): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

Device Accel Profile (240): 0

Device Accel Constant Deceleration (241): ? 1.000000

Device Accel Adaptive Deceleration (242): ? 1.000000

Device Accel Velocity Scaling (243): 10.000000

Device Product ID (244): 3823, 5

Device Node (245): ?"/dev/input/event3"

Evdev Axis Inversion (246): 0, 0

Evdev Axis Calibration (247): ? <no items>

Evdev Axes Swap (248): ?0

Axis Labels (249): ?"Abs MT Position X" (267), "Abs MT Position Y" (268), "Abs MT Pressure" (269), "None" (0), "None" (0), "None" (0)

Button Labels (250): "Button Unknown" (233), "Button Unknown" (233), "Button Unknown" (233), "Button Wheel Up" (121), "Button Wheel Down" (122)

Evdev Scrolling Distance (251): 0, 0, 0

Evdev Middle Button Emulation (252): 0

Evdev Middle Button Timeout (253): ?50

Evdev Third Button Emulation (254): 0

Evdev Third Button Emulation Timeout (255): 1000

Evdev Third Button Emulation Button (256): ?3

Evdev Third Button Emulation Threshold (257): ? 20

Evdev Wheel Emulation (258): 0

Evdev Wheel Emulation Axes (259): ? 0, 0, 4, 5

Evdev Wheel Emulation Inertia (260): 10

Evdev Wheel Emulation Timeout (261): 200

Evdev Wheel Emulation Button (262): 4

Evdev Drag Lock Buttons (263): ?0

這塊屏幕正常顯示和觸摸的信息如上。

如果執行到這壹步,發現並沒有以上的Evdev等屬性項,請跳轉2.2。

現在需要達到的目的是在屏幕顯示反轉的同時,使得觸摸也隨顯示翻轉。

屏幕顯示為翻轉90度。/boot/config.txt設置為display_rotate=1

上述信息中Evdev Axis Inversion 項是每條軸的旋轉設置項,後面第壹個參數是x,第二個參數是y.

Evdev Axes Swap項對應的是兩條軸的交換。

0為不翻轉,1為翻轉?

例如。x軸原本是朝向右的,當把Evdev Axis Inversion的第壹個參數

設置為1,即x軸朝向左。

4.旋轉觸摸的坐標軸

現在目的是要觸摸旋轉90度,從坐標軸理解:

即目的x軸正向為初始y軸的反向。目的y軸的正方向為初始x軸的正向。

1)所以先交換x、y軸

DISPLAY=:0 xinput --set-prop '7' 'Evdev Axes Swap' 1

2)然後反轉y軸

DISPLAY=:0 xinput --set-prop '7' 'Evdev Axis Inversion' 0 1

這樣即可完成觸摸旋轉90度。若要旋轉其他角度,推理壹下即可。

顯示旋轉修改之後需要重啟。而觸摸旋轉不需要重啟。

/index.php/7_inch_HDMI_LCD_(H)

  • 上一篇:Python小白應如何入門?
  • 下一篇:四軸,及其四軸以上航拍器起飛工作原理
  • copyright 2024編程學習大全網