.. currentmodule:: tftlcd .. _tftlcd.LCD32: class LCD32 -- 3.2寸显示屏 =========================== LCD32 类提供一个01Studio 3.2寸显示屏控制接口,通过构建该对象可以轻松实现3.2寸显示屏 的各种画图控制。 .. image:: https://docs.01studio.cc/data/picture/3_2LCD.png :alt: 01Studio 3.2' LCD picture :width: 700px 相关资料请点击下面链接: * `01Studio 3.2' LCD 原理图 `_ (PDF) 示例:: import tftlcd d = tftlcd.LCD32(portrait=1) #构建LCD对象 d.fill((255, 255, 255)) #填充白色 d.drawRect(0, 0, 100, 100, (255,0,0)) #画红色矩形 d.printStr('Hello 01Studio!', 0, 0, (0,255,0)) #写字符 d.Picture(0, 0, '/01studio.jpg') #显示图片 构造函数 ------------ .. class:: LCD32(portrait=1) 构建一个3.2寸LCD对象,参数如下: - ``portrait`` LCD显示方向: - ``1`` - 竖屏,240*320,开发板默认方向; - ``2`` - 横屏,320*240 ,1基础上顺时针旋转90°; - ``3`` - 竖屏,240*320 ,1基础上顺时针旋转180°; - ``4`` - 横屏,320*240 ,1基础上顺时针旋转270°。 使用方法 -------------- .. method:: LCD32.fill(color) 全屏填充: - ``color`` RGB颜色数据,如:(255,0,0)表示红色。 .. method:: LCD32.drawPixel(x,y,color) 画点: - ``x`` 横坐标; - ``y`` 纵坐标; - ``color`` RGB颜色数据,如:(255,0,0)表示红色。 .. method:: LCD32.drawLine(x0,y0,x1,y1,color) 画线段: - ``x0`` 起始横坐标; - ``y0`` 起始纵坐标; - ``x1`` 结束横坐标; - ``y1`` 结束纵坐标; - ``color`` RGB颜色数据,如:(255,0,0)表示红色。 .. method:: LCD32.drawRect(x,y,width,height,color,border=1,fillcolor=None) 画矩形: - ``x`` 起始横坐标; - ``y`` 起始纵坐标; - ``width`` 宽度; - ``height`` 高度; - ``color`` 边框颜色,RGB颜色数据,如:(255,0,0)表示红色。 - ``border`` 边框宽度,单位为像素,默认=1; - ``fillcolor`` 填充颜色,RGB颜色数据,如:(255,0,0)表示红色,默认=None表示不填充。 .. method:: LCD32.drawCircle(x,y,radius,color,border=1,fillcolor=None) 画圆: - ``x`` 圆心横坐标; - ``y`` 圆心纵坐标; - ``radius`` 半径; - ``color`` 边框颜色,RGB颜色数据,如:(255,0,0)表示红色。 - ``border`` 边框宽度,单位为像素,默认=1; - ``fillcolor`` 填充颜色,RGB颜色数据,如:(255,0,0)表示红色,默认=None表示不填充。 .. method:: LCD32.printStr(text,x,y,color,backcolor=None,size=2) 写字符: - ``text`` 字符,string类型; - ``x`` 起始横坐标; - ``y`` 起始纵坐标; - ``color`` 字体颜色,RGB颜色数据,如:(255,0,0)表示红色。 - ``backcolor`` 字体背景颜色,RGB颜色数据,如:(255,0,0)表示红色,默认=None。 - ``size`` 字体尺寸,默认=2表示标准尺寸: - ``1`` - 小号; - ``2`` - 标准; - ``3`` - 中号; - ``4`` - 大号; .. method:: LCD32.Picture(x,y,filename) 显示图片,支持图片格式:jpg/bmp。最大尺寸240*320 - ``x`` 起始横坐标; - ``y`` 起始纵坐标; - ``filename`` 路径+名称,如:"cat.jpg"