aramy
树莓派pico2测评 2.SPI写墨水屏
手头有一片2.9寸的黑白墨水屏。特别喜欢墨水屏的这种质感。今天尝试使用Pico2来驱动这块墨水屏。


1、硬件连接。
这块墨水屏,背面做好了排母,可以和树莓派Pico2 完美对接。

2、软件驱动
继续使用mpy来编程。先在网上找了墨水屏的驱动包:https://gitcode.com/gh_mirrors/uc/uc8151_micropython/。使用micropython的好处就是有大量的包可以调用。需要将uc8151.py文件放到/lib目录下。
墨水屏使用SPI驱动,这里管脚映射:
SPI驱动 | SCK | MOSI | MISO | CS | DC | RST | BUSY |
管脚 | 18 | 19 | 16 | 17 | 20 | 21 | 26 |
首先驱动墨水屏写个“hello world!”
from machine import SPI, Pin
from uc8151 import UC8151
spi = SPI(0, baudrate=12000000, phase=0, polarity=0, sck=Pin(18), mosi=Pin(19), miso=Pin(16))
eink = UC8151(spi,cs=17,dc=20,rst=21,busy=26,speed=2)
# Then write something into the framebuffer and update the display.
eink.fb.text("Hello World!",10,100,2)
eink.update()

阅读文档得知,这块墨水屏还支持灰度显示。参考例程,显示一张图片。
from machine import SPI,Pin
from uc8151 import UC8151
import random
spi = SPI(0, baudrate=12000000, phase=0, polarity=0, sck=Pin(18), mosi=Pin(19), miso=Pin(16))
eink = UC8151(spi,cs=17,dc=20,rst=21,busy=26,speed=2,no_flickering=False)
for greyscale in [4,8,16,32]:
eink.load_greyscale_image("dama.gs8",greyscale)

版块:
开发板测评
2025/04/11 16:48
全部评论