樹(shù)莓派如何實(shí)現(xiàn)顯示翻轉(zhuǎn)和觸摸翻轉(zhuǎn)

這篇文章主要為大家展示了“樹(shù)莓派如何實(shí)現(xiàn)顯示翻轉(zhuǎn)和觸摸翻轉(zhuǎn)”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“樹(shù)莓派如何實(shí)現(xiàn)顯示翻轉(zhuǎn)和觸摸翻轉(zhuǎn)”這篇文章吧。

創(chuàng)新互聯(lián)公司專(zhuān)注于企業(yè)成都營(yíng)銷(xiāo)網(wǎng)站建設(shè)、網(wǎng)站重做改版、興安盟網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、HTML5、商城網(wǎng)站開(kāi)發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)公司、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為興安盟等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。

1 翻轉(zhuǎn)顯示:

1.sudo nano /boot/config.txt

2.在文件末尾加入

display_rotate=0

display_rotate=1   //90°

display_rotate=2   //180°

display_rotate=3   //270°

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

2 翻轉(zhuǎn)觸摸

這個(gè)需要xinput

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

2.1  查看觸摸屏信息

2.1.1.安裝xinput

sudo apt-get install xinput

2.1.2.列出所有輸入設(shè)備信息

xinput --list

如果遠(yuǎn)程操作記得在命令前加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:~ $

2.1.3.列出目標(biāo)設(shè)備屬性

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

注意?。。。。。。。。。。。。。。。。。。。。。。。。。。?!如果觸摸屏幕信息,是以上內(nèi)容,請(qǐng)參考2.2;如果不是請(qǐng)參考2.3

2.2  修改配置文件

2.2.1、安裝libinput,

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

無(wú) 則需要安裝

sudo apt-get installxserver-xorg-input-libinput    

,

2.2.2、復(fù)制該文件到/etc/X11/xorg.conf.d/目錄下。

一開(kāi)始xorg.conf.d這個(gè)目錄在/etc/X11可能沒(méi)有,需要自己創(chuàng)建。

sudo mkdirxorg.conf.d

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

2.2.3、進(jìn)入/etc/X11/xorg.conf.d/目錄下修改40-libinput.conf 文件

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“   

結(jié)果為

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"

2.3. 另一種觸摸屏處理方法

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

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

如果執(zhí)行到這一步,發(fā)現(xiàn)并沒(méi)有以上的Evdev等屬性項(xiàng),請(qǐng)?zhí)D(zhuǎn)2.2。

現(xiàn)在需要達(dá)到的目的是在屏幕顯示反轉(zhuǎn)的同時(shí),使得觸摸也隨顯示翻轉(zhuǎn)。

屏幕顯示為翻轉(zhuǎn)90度。/boot/config.txt設(shè)置為display_rotate=1

上述信息中Evdev Axis Inversion 項(xiàng)是每條軸的旋轉(zhuǎn)設(shè)置項(xiàng),后面第一個(gè)參數(shù)是x,第二個(gè)參數(shù)是y.

Evdev Axes Swap項(xiàng)對(duì)應(yīng)的是兩條軸的交換。

0為不翻轉(zhuǎn),1為翻轉(zhuǎn) 

例如。x軸原本是朝向右的,當(dāng)把Evdev Axis Inversion的第一個(gè)參數(shù)

設(shè)置為1,即x軸朝向左。

4.旋轉(zhuǎn)觸摸的坐標(biāo)軸

現(xiàn)在目的是要觸摸旋轉(zhuǎn)90度,從坐標(biāo)軸理解:

即目的x軸正向?yàn)槌跏紋軸的反向。目的y軸的正方向?yàn)槌跏紉軸的正向。

1)所以先交換x、y軸

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

2)然后反轉(zhuǎn)y軸

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

這樣即可完成觸摸旋轉(zhuǎn)90度。若要旋轉(zhuǎn)其他角度,推理一下即可。

顯示旋轉(zhuǎn)修改之后需要重啟。而觸摸旋轉(zhuǎn)不需要重啟。

以上是“樹(shù)莓派如何實(shí)現(xiàn)顯示翻轉(zhuǎn)和觸摸翻轉(zhuǎn)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

本文名稱(chēng):樹(shù)莓派如何實(shí)現(xiàn)顯示翻轉(zhuǎn)和觸摸翻轉(zhuǎn)
當(dāng)前URL:http://www.muchs.cn/article12/phopdc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)品牌網(wǎng)站制作、微信公眾號(hào)、虛擬主機(jī)、建站公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)