跳转到主要内容

CircuitPython的RGB显示屏库。

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

将来自https://github.com/adafruit/micropython-adafruit-rgb-display的显示驱动程序移植到Adafruit CircuitPython,以便在Adafruit基于SAMD21和其他CircuitPython板上使用。

此CircuitPython驱动程序目前支持使用以下显示驱动芯片的显示屏:HX8353、HX8357、ILI9341、S6D02A1、ST7789、SSD1331、SSD1351和ST7735(包括ST7735R和ST7735S变体)。

依赖项

此驱动程序依赖于

请确保所有依赖项都可在CircuitPython文件系统中使用。这可以通过下载Adafruit库和驱动程序包轻松实现。

对于枕垫示例,您需要运行CPython。这意味着使用单板计算机,如树莓派,或在Linux、Windows或Mac上使用FT232H等芯片。CircuitPython不支持PIL/pillow(Python图像库)!

为了提高性能,请考虑安装NumPy。

从PyPI安装

在支持的系统上,如树莓派,您可以从PyPI本地安装驱动程序从PyPI安装,为当前用户安装

pip3 install adafruit-circuitpython-rgb-display

系统范围内安装(在某些情况下可能需要)

sudo pip3 install adafruit-circuitpython-rgb-display

在当前项目中安装虚拟环境

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-rgb-display

使用示例

2.2英寸、2.4英寸、2.8英寸、3.2英寸TFT

import time
import busio
import digitalio
from board import SCK, MOSI, MISO, D2, D3

from adafruit_rgb_display import color565
import adafruit_rgb_display.ili9341 as ili9341


# Configuration for CS and DC pins:
CS_PIN = D2
DC_PIN = D3

# Setup SPI bus using hardware SPI:
spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)

# Create the ILI9341 display:
display = ili9341.ILI9341(spi, cs=digitalio.DigitalInOut(CS_PIN),
                          dc=digitalio.DigitalInOut(DC_PIN))

# Main loop:
while True:
    # Clear the display
    display.fill(0)
    # Draw a red pixel in the center.
    display.pixel(120, 160, color565(255, 0, 0))
    # Pause 2 seconds.
    time.sleep(2)
    # Clear the screen blue.
    display.fill(color565(0, 0, 255))
    # Pause 2 seconds.
    time.sleep(2)

1.14英寸TFT与树莓派4

使用1.14英寸布线,以下是工作代码

import time
import busio
import digitalio
from board import SCK, MOSI, MISO, CE0, D24, D25

from adafruit_rgb_display import color565
from adafruit_rgb_display.st7789 import ST7789


# Configuration for CS and DC pins:
CS_PIN = CE0
DC_PIN = D25
RESET_PIN = D24
BAUDRATE = 24000000

# Setup SPI bus using hardware SPI:
spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)

# Create the ST7789 display:
display = ST7789(
    spi,
    rotation=90,
    width=135,
    height=240,
    x_offset=53,
    y_offset=40,
    baudrate=BAUDRATE,
    cs=digitalio.DigitalInOut(CS_PIN),
    dc=digitalio.DigitalInOut(DC_PIN),
    rst=digitalio.DigitalInOut(RESET_PIN))

# Main loop: same as above
while True:
    # Clear the display
    display.fill(0)
    # Draw a red pixel in the center.
    display.pixel(120, 160, color565(255, 0, 0))
    # Pause 2 seconds.
    time.sleep(2)
    # Clear the screen blue.
    display.fill(color565(0, 0, 255))
    # Pause 2 seconds.
    time.sleep(2)

文档

此库的API文档可以在Read the Docs上找到。

有关构建库文档的信息,请参阅此指南

贡献

欢迎贡献!在为该项目做出贡献之前,请阅读我们的行为准则,以帮助该项目保持友好。

项目详情


发布历史 发布通知 | RSS源

下载文件

下载适合您平台文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

构建分布

由以下提供支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面