luma.oled SPI ssd1306数据到GPIO引脚使用封装/模块发布

2024-05-17 14:47:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个ssd1306,它正在使用使用CircuitPython的Adafruit库处理SPI0,但是,我希望最终将oled移动到SPI1。因此,我使用luma.oled库,因为它在使用SPI总线方面具有更大的灵活性

我将GPIO连接到逻辑分析仪,并对CircuitPython和luma.oled实现进行了比较,可以看出我没有输出正确的数据,所有接线都是正确的,但我不确定luma.oled的实现

在我看来,SPI GPIO没有正确设置

这就是我所指的文档

https://luma-core.readthedocs.io/en/latest/interface.html

from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.oled.device import ssd1306

serial = spi(device=0, port=0, SCLK=11, SDA=19, CE=5, DC=6, RST=4)

device = ssd1306(serial)

with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((30, 40), "Hello", fill="white")

有人能帮上忙吗

参考SPI,使用CircutiPythonenter image description here

参考SPI使用luma.oledenter image description here

更新

使用下面的代码似乎有一个GPIO命令,但仍然不符合真正的SPI

try:
    serial = spi(device=0, port=0, gpio_CE=5, gpio_DC=6, gpio_RST=4)
    print(type(serial))
    print(serial)

提供以下信息:

enter image description here


Tags: fromcoreimportcircuitpythonspigpiolumadevice