9.1. 配置触摸屏¶
luban-lite 可以支持两种触摸屏:
- 电容屏:CTP; 
- 电阻屏:RTP; 
9.1.1. 配置 CTP¶
9.1.1.1. 配置¶
CTP 配置部分,以 D211BBV-DEMO-V2-0 配置 GT911 为例:
- 数据通道采用 i2c3; 
- RST 引脚使用 PA8; 
- INT 引脚使用 PA9; 
通过 scons --menuconfig 命令,进入配置页面,完成如下配置:
Board options  --->
    [*] Using I2c3
        I2c3 Parameter  --->
            I2c3 Master && Slave  (Master)
Rt-Thread options  --->
    RT-Thread Components  --->
        Device Drivers  --->
            [*] Using Touch device drivers
            [*]   touch irq use pin irq
Drivers options  --->
    Peripheral  --->
        Touch Panel Support  --->
            Gt911 touch panel options  --->
                [*] Using touch panel gt911
                (i2c3) gt911 using i2c channel index    # 数据通道
                (PA.8) gt911 reset pin                  # 复位引脚
                (PA.9) gt911 irq pin                    # 中断引脚
    Drivers examples  --->
        [*] Enable touch panel driver test command      # test_gt911 测试程序
9.1.1.2. 验证¶
9.1.1.2.1. 使用LVGL¶
使用默认项目的 test_lvgl 程序验证 CTP 的功能,系统正常启动后,即可在触屏上点触、滑动。
9.1.1.2.2. 使用 test_gt911¶
若使用默认项目配置,可以使用如下配置取消 test_lvgl :
Application options  --->
    [ ] ArtInChip lvgl demo
注意
测试程序运行之前,请务必保证没有 GUI 应用程序打开 gt911 设备。
系统驱动之后,运行 test_gt911 命令,并在 CTP 上触摸滑动,观察调试串口输出如下:
aic/> test_gt911                # 运行测试程序
id = GT911                      # 获取gt911 id
range_x = 1024                  # 打印x范围
range_y = 600                   # 打印y范围
point_num = 1
aic/>
aic/>
aic/>
aic/>
aic/> 0 578 366 12 0            # 有触屏事件时,打印触摸点坐标
0 578 366 12 0
0 578 366 12 0
0 578 366 12 0
0 578 366 12 0
0 578 366 12 0
0 580 372 12 0
0 603 396 12 0
0 627 422 12 0
0 439 386 13 0
0 439 386 13 0
0 439 386 13 0
0 433 384 13 0
0 413 371 13 0
0 387 355 13 0
0 364 340 13 0
0 351 335 13 0
0 296 267 13 0
0 296 267 13 0
0 296 267 13 0
0 297 269 13 0