luma.oled SPI ssd1306 数据到 GPIO 引脚使用封装/模块的问题

问题描述 投票:0回答:1

我有一个 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")

有人可以帮忙解决这个问题吗!

使用 CircutiPython 参考 SPI

使用 luma.oled 参考 SPI

更新

使用下面的代码似乎有一个令人信服的 GPIO 移动命令,但仍然不对应于真正的 SPI。

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

给出以下内容:

python raspberry-pi spi
1个回答
0
投票

我只是在做一些家务,看起来好像我让这篇文章保持开放状态,最终使用了 Adafruit 模块,而我看到的问题原来是该模块的一个错误,请参阅以下链接了解详细信息

https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/issues/89

虽然现在这个问题已经解决了,但我想没有人会读到这篇文章!

© www.soinside.com 2019 - 2024. All rights reserved.