7.9.4. 测试指南¶
7.9.4.1. 测试环境¶
7.9.4.1.1. 硬件¶
- 带触屏功能的屏幕 
- 带RTP接口的开发板 
- USB Type-C数据线,用于给开发板供电、烧写 
- USB 转串口的线,用于连接开发板的调试串口 
- 手写笔,可以更方便精准的点击RTP 
7.9.4.1.2. 软件¶
- PC端的串口终端软件,用于PC和开发板进行串口通信 
- AiBurn烧写工具 
- tslib开源库,用于管理input设备和事件、以及坐标校准,luban中已集成 
- ts_draw测试工具,用于测试触屏的坐标事件、跳点统计等,luban中已集成 
7.9.4.2. 配置tslib运行环境¶
在板子的shell中执行以下命令配置几个环境变量:
export TSLIB_FBDEVICE=/dev/fb0
export POINTERCAL_CALIBFILE=/usr/etc/ts-calib.conf
export TSLIB_CONSOLEDEVICE=none
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_PLUGINDIR=/usr/lib/ts
export TSLIB_CALIBFILE=/tmp/pointercal
7.9.4.3. 坐标校准¶
配置好tslib运行环境后,在板子的shell中执行ts_calibrate工具,在触屏界面会出现一个校准界面,按照提示,点击5个小十字的中心,完成校准。
# ts_calibrate
xres = 1024, yres = 600
7.9.4.4. 读取坐标值¶
在板子的shell中执行ts_draw测试工具,点击触屏ts_draw会打印出每次坐标事件。
# ts_draw -d
FB res: X 1024, Y 600,Size 2457600, Border 0, Jump thd 4
1646290364.886053: X -  734 Y -  280 P -   34
1646290364.906078: X -  734 Y -  280 P -   49
1646290364.926056: X -  734 Y -  280 P -   65
1646290364.946044: X -  734 Y -  280 P -   76
1646290364.966063: X -  734 Y -  279 P -   98
1646290364.986043: X -  735 Y -  279 P -  117
小技巧
上述坐标是通过ts_calibrate校准后的坐标,如果要查看原始坐标可增加参数-r。
7.9.4.5. 跳点分析¶
ts_draw具备一个功能,就是统计跳点的个数,判断方法是看到连续出现的两个坐标间距太大就认为是跳点。“间距”门限默认是4,可以通过参数设置该值。
# ts_draw -h
Usage: ts_draw [Options], built on Apr 27 2022 14:42:38
    -r, --raw       Use the raw coordinate, default: disable
    -d, --debug     Open more debug information, default: disable
    -b, --border    The width of border(will ignore), default 0
    -j, --jumb-thd  The threshold to determinate jumb sample, default 4
    -h, --help
# ts_draw  -j 3
FB res: X 800, Y 480,Size 1536000, Boarder 0, Jump thd 3
Stats: Sum 44, Out 0(0.00%), Jump 1(2.27%), Period 5.06 ms
Stats: Sum 265, Out 0(0.00%), Jump 1(0.38%), Period 5.06 ms