首页 > 解决方案 > 通过蓝牙的 SPI 显示

问题描述

我想通过 Raspberry Pi 4 的蓝牙完全运行 SPI 显示器。我有一个 ESP32,可用于时钟信号、芯片选择、电源等。我让它们通过蓝牙进行通信,但我只是不知道如何我会通过蓝牙而不是通过 pin 发送数据。我正在使用这个库中的 ST7789 驱动程序。我需要知道我必须更改和/或添加哪些代码才能完成这项工作。

谢谢!

标签: pythonbluetoothraspberry-pispi

解决方案


我建议让 Raspberry Pi 和 ESP32 之间的通信具有比在 SPI 引脚上发送的二进制数据更高的抽象级别。我将获取 ESP32 上使用的方法的参数,并通过蓝牙串行连接传递它们。

例如,假设您将其用作ESP32 上的库。它有如下方法

ST7789.fill(color) # Fill the entire display with the specified color.
ST7789.pixel(x, y, color) # Set the specified pixel to the given color.

您可以通过蓝牙串行端口配置文件 (SPP) 连接发送这样的数据,这将相对直接地在 ESP32 上解包并使用值填充命令。

spp.send('fill, 63488') # Fill the entire display with red
spp.send('pixel, 12, 12, 63488') # # Set pixel 12,12 to red

推荐阅读