这个周末完成这篇。。。
驱动:GitHub - boochow/MicroPython-ST7735: ST7735 TFT LCD driver for MicroPython
接线:
ST7735 Pin | Pico Pin |
---|---|
VCC | 3.3V |
GND | GND |
SCL (SCK) | GP18 |
SDA (MOSI) | GP19 |
RES (RST) | GP20 |
DC | GP21 |
CS | GP17 |
应用
import machine import st7735 import time import utime # 定义引脚 spi = machine.SPI(0, baudrate=20000000, polarity=0, phase=0, sck=machine.Pin(18), mosi=machine.Pin(19)) dc = machine.Pin(21, machine.Pin.OUT) rst = machine.Pin(20, machine.Pin.OUT) cs = machine.Pin(17, machine.Pin.OUT) # 初始化显示屏 display = st7735.ST7735(spi, dc=dc, rst=rst, cs=cs) # 清屏 display.fill(0) # 显示一些基本图形 display.rect(10, 10, 50, 50, st7735.color565(255, 0, 0)) # 红色矩形 display.line(0, 0, 80, 80, st7735.color565(0, 255, 0)) # 绿色对角线 display.text('Hello, Pico!', 10, 70, st7735.color565(0, 0, 255)) # 蓝色文本 # 刷新显示 display.show() # 保持显示 while True: utime.sleep(1)