跳转到主要内容

适用于广泛使用的日立HD44780控制器的树莓派LCD库。

项目描述

Build Status PyPI Version PyPI Wheel PyPI Python Versions Dependencies License

A Python 3/2 Raspberry PI Character LCD library for the Hitachi HD44780 controller. It supports both GPIO (parallel) mode as well as boards with an I²C port expander (e.g. the PCF8574 or the MCP23008).

This library is inspired by Adafruit Industries’ CharLCD library as well as by Arduino’s LiquidCrystal library.

For GPIO mode, no external dependencies (except the RPi.GPIO library, which comes preinstalled on Raspbian) are needed to use this library. If you want to control LCDs via I²C, then you also need the python-smbus or smbus2 library. If you want to control the LCD with pigpio, you have to install the pigpio library.

If you’re trying to get started with RPLCD, you should probably read the docs :)

Photo of 20x4 LCD in action

设置

您可以直接通过PyPI使用pip安装RPLCD。

$ sudo pip install RPLCD

如果您想使用I²C,还需要smbus或smbus2库。

$ sudo apt install python-smbus
or
$ sudo pip install smbus2

RPLCD将首先尝试使用smbus(如果可用),如果不可用,将回退到smbus2。

您也可以不使用pip手动安装库。您可以选择将脚本复制到工作目录并导入它们,或者下载存储库并运行python setup.py install将其安装到Python包目录。

功能

已实现

  • 简单易用的API

  • 支持4位和8位模式

  • 支持并行(GPIO)和I²C连接

  • 支持自定义字符

  • 支持背光控制电路

  • 内置支持A00A02(标准HD44780)或ST0B(见ST7066第11页)字符表

  • Python 2/3兼容

  • 缓存:只有当字符发生变化时才写入

  • 没有外部依赖(除RPi.GPIO外,如果需要I²C支持,还需要python-smbussmbus2

愿望列表

以下功能可能在未来的空闲时间和动力下实现

  • MicroPython端口

支持的I²C端口扩展器

  • PCF8574(阿里巴巴国际站上许多I²C LCD适配器使用)

  • MCP23008(用于Adafruit I²C LCD背板)

  • MCP23017

文档

测试

交互式测试脚本

要测试您的LCD,请运行带有testsuite目标的rplcd-tests脚本。

单元测试

还有单元测试。首先,安装依赖项

pip install -U -r requirements-dev.txt

然后运行测试

py.test -v

编码指南

PEP8通过flake8,设置max-line-width为99,忽略E126-E128,C901

flake8 --max-line-length=99 --ignore=E126,E127,E128,C901 RPLCD/lcd.py

关于HD44780

HD44780 LCD控制器是用于驱动字母数字LCD显示的控制器芯片。尽管它不再生产,但它有很多兼容的芯片/克隆,例如ST7066或KS0066。今天在名称中包含“HD44780”的显示器通常使用这些克隆之一构建,尽管它们大多数时候看起来都一样(如本README开头所示)。

资源

许可

此代码根据MIT许可证授权,请参阅LICENSE文件tldrlegal以获取更多信息。

项目详情


下载文件

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

源代码发行版

RPLCD-1.3.1.tar.gz (36.6 kB 查看哈希值)

上传时间 源代码

构建发行版

RPLCD-1.3.1-py2.py3-none-any.whl (49.3 kB 查看哈希值)

上传时间 Python 2 Python 3

由支持