HD44780 / PCF8574 LCD Module
View on PyPi.org
- Description
- Features
- Install
- Usage
A simple module for working with the HD44780 LCD over I²C using the PCF8574 Backpack
- Non-Blocking update loop
- Supports 2x16 and 4x20 Displays
- Easy to use
- Callback loop for updating display directly
Make sure i2c is enabled!
sudo raspi-config
pip3 install RPi-GPIO-I2C-LCD
set(string,line)
Sets string to given line
get(line)
Returns string of given line from buffer
backlight(on|off)
Turns backlight on or off (default is on)
clear()
Clears display buffers
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)
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)
while(True):
lcdDisplay.backlight("off")
sleep(1)
lcdDisplay.backlight("on")
sleep(1)