在I2C上使用HD44780 LCD的简单模块
RPi-GPIO-i2c-LCD的Python项目详细描述
rpi_gpio_i2c_液晶显示器
HD44780 / PCF8574 LCD Module
截面
- 说明
- 功能
- 安装
- 用法
说明
A simple module for working with the HD44780 LCD over I²C using the PCF8574 Backpack
功能
- 非阻塞更新循环
- 支持2x16和4x20显示器
- 易于使用
- 直接更新显示的回调循环
安装
使用pypi:
pip3 install RPi-GPIO-I2C-LCD
使用量
简单
from RPi_GPIO_i2c_LCD import lcd
from time import sleep
## Address of backpack
i2c_address = 0x27
## Initalize display
lcdDisplay = lcd.HD44780(i2c_address)
## Set string value to buffer
lcdDisplay.set("Hello",1)
lcdDisplay.set("World",2)
sleep(1)
回调循环
from RPi_GPIO_i2c_LCD import lcd
from time import sleep, strftime
## Callback function that will run on every display loop
def MyFunction(self):
## Show current time on line 2
self.lcd.display_string(str(strftime("%d/%m %H:%M:%S").center(20,' ')),2)
## Initalize display with callback
lcdDisplay = lcd.HD44780(0x27,MyFunction)
## Set string value to buffer
lcdDisplay.set("The time is:",1)
sleep(6)