.. currentmodule:: touch .. _touch.XPT2046: class XPT2046 -- XPT2046电阻屏 =============================== XPT2046类提供XPT2046电阻触摸屏控制接口,通过构建该对象可以轻松实现驱动XPT2046电阻触摸屏。 .. image:: https://docs.01studio.cc/data/picture/3_2LCD.png :alt: 01Studio 3.2' LCD picture :width: 700px 相关资料请点击下面链接: * `01Studio 3.2' LCD 原理图 `_ (PDF) 示例:: import touch t = touch.XPT2046(portrait=1) #构建触摸屏对象 t.read() #获取触摸状态和坐标 构造函数 ------------ .. class:: XPT2046(portrait=1) 构建一个XPT2046电容触摸屏对象对象,参数如下: - ``portrait`` LCD显示方向: - ``1`` - 竖屏,240*320,开发板默认方向; - ``2`` - 横屏,320*240 ,1基础上顺时针旋转90°; - ``3`` - 竖屏,240*320 ,1基础上顺时针旋转180°; - ``4`` - 横屏,320*240 ,1基础上顺时针旋转270°。 使用方法 -------------- .. method:: XPT2046.read() 读取触摸屏坐标,返回(states,x,y) - ``states`` 当前触摸状态: - ``0`` - Press 按下; - ``1`` - Move 移动; - ``2`` - Release 松开。 - ``x`` 横坐标; - ``y`` 纵坐标; .. method:: XPT2046.tick_inc() 触摸屏响应。