LCD 类 – LCD 触摸传感器 pyskin 的 LCD 控制¶
LCD 类用于控制 LCD 触摸传感器 pyskin LCD32MKv1.0 上的 LCD。LCD 是一块 128x32 像素的单色屏幕,部件为 NHD-C12832A1Z。
pyskin 必须连接在 X 或 Y 位置,然后使用以下方法制作 LCD 对象:
lcd = pyb.LCD('X')      # if pyskin is in the X position
lcd = pyb.LCD('Y')      # if pyskin is in the Y position
然后你可以使用:
lcd.light(True)                 # turn the backlight on
lcd.write('Hello world!\n')     # print text to the screen
该驱动程序实现了用于设置/获取像素的双缓冲区。例如,要制作一个弹跳点,请尝试:
x = y = 0
dx = dy = 1
while True:
    # update the dot's position
    x += dx
    y += dy
    # make the dot bounce of the edges of the screen
    if x <= 0 or x >= 127: dx = -dx
    if y <= 0 or y >= 31: dy = -dy
    lcd.fill(0)                 # clear the buffer
    lcd.pixel(x, y, 1)          # draw the dot
    lcd.show()                  # show the buffer
    pyb.delay(50)               # pause for 50ms
构造函数¶
- 
class 
pyb.LCD(skin_position)¶ 在给定的皮肤位置构造一个 LCD 对象。
skin_position可以是“X”或“Y”,并且应该与插入 LCD pyskin 的位置匹配。
方法¶
- 
LCD.command(instr_data, buf)¶ 向 LCD 发送任意命令。传 0 为
instr_data发送指令,否则传 1 为发送数据。buf是带有要发送的指令/数据的缓冲区。
- 
LCD.contrast(value)¶ 设置 LCD 的对比度。有效值介于 0 和 47 之间。
- 
LCD.fill(colour)¶ 用给定的颜色填充屏幕(白色或黑色为 0 或 1)。
此方法写入隐藏缓冲区。使用
show()显示缓冲区。
- 
LCD.get(x, y)¶ 获取位置的像素。返回 0 或 1。
(x, y)此方法从可见缓冲区读取。
- 
LCD.light(value)¶ 打开/关闭背光。True 或 1 打开它,False 或 0 关闭它。
- 
LCD.pixel(x, y, colour)¶ 将像素设置为给定的颜色(0 或 1)。
(x, y)。此方法写入隐藏缓冲区。使用
show()显示缓冲区。
- 
LCD.show()¶ 在屏幕上显示隐藏的缓冲区。
- 
LCD.text(str, x, y, colour)¶ 使用给定的颜色(0 或 1)将给定的文本绘制到该位置。
(x, y)此方法写入隐藏缓冲区。使用
show()显示缓冲区。
- 
LCD.write(str)¶ 将字符串写入
str屏幕。它会立即出现。