跳转到主要内容

CircuitPython库,用于SSD1306 OLED显示屏。

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

Adafruit CircuitPython驱动程序,用于SSD1306或SSD1305 OLED显示屏。请注意,SSD1305显示屏向后兼容,因此可以使用与SSD1306相同的代码和命令替换。

此驱动程序实现了adafruit_framebuf接口。它不是SSD1306的displayio驱动程序。有关displayio支持,请参阅Adafruit CircuitPython DisplayIO SSD1306驱动程序

依赖项

此驱动程序依赖于

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

从PyPI安装

在支持GNU/Linux系统(如Raspberry Pi)上,您可以从PyPI本地安装驱动程序。安装当前用户

pip3 install adafruit-circuitpython-ssd1306

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

sudo pip3 install adafruit-circuitpython-ssd1306

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

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

使用示例

# Basic example of clearing and drawing pixels on a SSD1306 OLED display.
# This example and library is meant to work with Adafruit CircuitPython API.
# Author: Tony DiCola
# License: Public Domain

# Import all board pins.
from board import SCL, SDA
import busio

# Import the SSD1306 module.
import adafruit_ssd1306


# Create the I2C interface.
i2c = busio.I2C(SCL, SDA)

# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height.  Change these
# to the right size for your display!
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# Alternatively you can change the I2C address of the device with an addr parameter:
#display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31)

# Clear the display.  Always call show after changing pixels to make the display
# update visible!
display.fill(0)

display.show()

# Set a pixel in the origin 0,0 position.
display.pixel(0, 0, 1)
# Set a pixel in the middle 64, 16 position.
display.pixel(64, 16, 1)
# Set a pixel in the opposite 127, 31 position.
display.pixel(127, 31, 1)
display.show()

更多示例和详情请参阅adafruit_framebuf文档

文档

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

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

贡献

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

项目详情


下载文件

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

源代码分发

adafruit-circuitpython-ssd1306-2.12.17.tar.gz (41.0 kB 查看哈希)

上传时间 源代码

构建分发

adafruit_circuitpython_ssd1306-2.12.17-py3-none-any.whl (7.6 kB 查看哈希)

上传时间 Python 3

支持者

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