ITEAD创易工作室 发表于 2014-8-14 10:43:28

【教程补充】树莓派2.8寸触摸屏操作系统演示

本帖最后由 ITEAD创易工作室 于 2014-10-9 17:05 编辑

目标:
    在Raspberry Pi v2上使用Raspberry PI 2.8 TFT Add-on v1.1 显示桌面(支持触摸屏操作)

http://player.youku.com/player.php/sid/XNzU0Njc3NzE2/v.swf

准备工作:
    烧写2014-01-07-wheezy-raspbian.img到SD卡,并启动Raspberry Pi v2
    保证网络连接正常
    将Raspberry PI 2.8 TFT Add-on v1.1与Raspberry版正确连接



0. 安装rpi-update以及fbtft驱动(以模块方式安装)
0.1 进入/etc/modprobe.d/raspi-blacklist.conf
sudo vi /etc/modprobe.d/raspi-blacklist.conf
注释掉/etc/modprobe.d/raspi-blacklist.conf中关于spi的屏蔽

#blacklist spi-bcm2708

0.2 调整时间为当前时间:
    date -s "2014-07-16 16:27:00"
0.3 安装必要的软件
    sudo apt-get update
    sudo apt-get install xinput evtest tslib libts-bin

0.4 下载fbtft驱动模块
    可能需要运行三次下面的命令:
    sudo REPO_URI=https://github.com/notro/rpi-firmware rpi-update

    最终会得到
         *** Running pre-install script
         Work around rpi-update issue #106
         *** Updating firmware
         *** Updating kernel modules
         *** depmod 3.12.21+
         *** Updating VideoCore libraries
         *** Using HardFP libraries
         *** Updating SDK
         *** Running ldconfig
         *** Storing current firmware revision
         *** Running post-install script
             /lib/firmware
         *** Deleting downloaded files
         *** Syncing changes to disk
         *** If no errors appeared, your firmware was successfully updated to b77683205688d3f6ae2b32a3c7f4e63de1c06a5d
         *** A reboot is needed to activate the new firmware
    此时,重新启动即可。
      sudo reboot

1. 配置/usr/share/X11/xorg.conf.d/99-fbdev.conf:



[中括号内为文件内容,不包含中括号和本行文本
      Section "Device"
          Identifier "itdb28"
          Driver "fbdev"
          Option "fbdev" "/dev/fb1"
      EndSection
]


2. 加载tft显示驱动
sudo modprobe fbtft_device name=itdb28 gpios=reset:14,dc:2,wr:3,cs:8,db00:17,db01:18,db02:27,db03:22,db04:23,db05:24,db06:25,db07:4 rotate=90 fps=50

3. 启动x
startx &


4. 加载触摸屏驱动
sudo modprobe ads7846_device cs=1 speed=2000000 gpio_pendown=15 x_max=3850 x_min=230 x_plate_ohms=100 swap_xy=1 verbose=2 pressure_max=255 y_min=190 y_max=3850

5 调整触摸屏的X与Y方向
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0


6. 测试
6.1 查看与触摸屏对应的event事件编号
   pi@raspberrypi ~ $ cat /proc/bus/input/devices
      I: Bus=0000 Vendor=0000 Product=0000 Version=0000
      N: Name="ADS7846 Touchscreen"
      P: Phys=spi0.1/input0
      S: Sysfs=/devices/platform/bcm2708_spi.0/spi_master/spi0/spi0.1/input/input0
      U: Uniq=
      H: Handlers=mouse0 event0
      B: PROP=0
      B: EV=b
      B: KEY=400 0 0 0 0 0 0 0 0 0 0
      B: ABS=1000003

    pi@raspberrypi ~ $

    应该是event0

每个人获得的event值是不同的,根据个人实际操作。如图



6.2 校准触摸屏
    sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_calibrate

6.3 测试触摸屏
    sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_test

专为树莓派设计的2.8寸触摸显示屏,直接叠加。


wing 发表于 2014-8-14 12:20:26

可惜啊,没有DSI的屏

沧海笑1122 发表于 2014-8-14 14:14:52

店里还没上架啊

潇洒哥 发表于 2014-8-14 21:14:24

不知道兼容B+啊??
分辨率太低,显示不全。
若能支持4.3寸,或者5寸480*272就好了

ITEAD创易工作室 发表于 2014-8-15 09:39:20

wing 发表于 2014-8-14 12:20 static/image/common/back.gif
可惜啊,没有DSI的屏

树莓派的DSI显示接口就是个大坑!市面上很难买到DSI接口的屏幕,更重要的是到现在树莓派还没有提供使用DSI接口驱动一个屏幕的案例。 DSI接口就是用来吃灰的{:2_28:}

ITEAD创易工作室 发表于 2014-8-15 09:45:22

本帖最后由 ITEAD创易工作室 于 2014-8-18 10:19 编辑

沧海笑1122 发表于 2014-8-14 14:14 static/image/common/back.gif
店里还没上架啊

店里已经上架了。还有更多专为树莓派设计的Add-on功能扩展板哦。

ITEAD创易工作室 发表于 2014-8-15 09:50:58

本帖最后由 ITEAD创易工作室 于 2014-8-18 10:18 编辑

潇洒哥 发表于 2014-8-14 21:14 static/image/common/back.gif
不知道兼容B+啊??
分辨率太低,显示不全。
若能支持4.3寸,或者5寸480*272就好了

这个兼容树莓派B+。目前提供直接叠加的也只有2.8寸的屏了,4.3以上的屏现成的接口不够,在这个基础上扩充咯,这是技术活。。

suoma 发表于 2015-3-30 21:40:34

2.8寸多少钱?

ITEAD创易工作室 发表于 2015-3-31 11:43:23

suoma 发表于 2015-3-30 21:40 static/image/common/back.gif
2.8寸多少钱?

看我签名,搜2.8寸
页: [1]
查看完整版本: 【教程补充】树莓派2.8寸触摸屏操作系统演示