这一次我们使用Raspberry pi pico点亮ST7735驱动的1.8寸RGB的TFT屏幕. 网络的资料比较少, 通过bing.com能查到使用Arduino写的例程. 这里我们还是采用熟悉的Micropython编程.
这里主要参考的是 GitHub - stechiez/raspberrypi-picoContribute to stechiez/raspberrypi-pico development by creating an account on GitHub.https://github.com/stechiez/raspberrypi-pico其中提供了ST7735的驱动程序.
将 ST7735.py, sysfont.py 拷贝到/lib 目录下, 将 graphicstest.py 和 tftbmp.py 拷贝到
根目录下, 另外两个示例的bmp文件也拷贝到根目录下.
接线图:
其中 sck=Pin(10), mosi=Pin(11), DC=Pin(16), RST=Pin(17), CS=Pin(18), BLK空置, VCC接3v3.
测试程序
from ST7735 import TFT
from sysfont import sysfont
from machine import SPI,Pin
import time
import math
spi = SPI(1, baudrate=10000000, polarity=0, phase=0,
sck=Pin(10), mosi=Pin(11), miso=None)
tft=TFT(spi,16,17,18)
tft.initb2()#r()
tft.rgb(True)
def testlines(color):
tft.fill(TFT.BLACK)
for x in range(0, tft.size()[0], 6):
tft.line((0,0),(x, tft.size()[1] - 1), color)
for y in range(0, tft.size()[1], 6):
tft.line((0,0),(tft.size()[0] - 1, y), color)
tft.fill(TFT.BLACK)
for x in range(0, tft.size()[0], 6):
tft.line((tft.size()[0] - 1, 0), (x, tft.size()[1] - 1), colo