HD44780-based LCD driver
This module provides a simple interface for controlling character LCDs based on the HD44780 driver. It supports displaying text, controlling the cursor position, and creating custom characters on the LCD screen.
Example
from machine import Pin
import time
from lcd_hd44780 import LcdHd44780
# Initialize the LCD with control pins (RS, E) and data pins (D4, D5, D6, D7)
lcd = LcdHd44780(rs=26, e=25, d=[13, 10, 9, 27])
# Move cursor to line 1, column 3 and display text
lcd.move_to(1, 3)
lcd.write("Hello, World!")
lcd.move_to(2, 5)
lcd.write("MicroPython")
Modification history
2024-11-11 : Added Sphinx-style comments for documentation.
2024-10-26 : Added demo method to demonstrate usage of the display.
2023-10-17 : File created, initial release.
- class lcd_hd44780.LcdHd44780(rs, e, d)[source]
Bases:
object
- command(cmd)[source]
Send a command byte to the LCD controller. This method writes to the command register of the LCD (RS = 0).
- Parameters:
cmd – The command byte to send to the LCD.
- custom_char(addr, charmap)[source]
This method writes the pixel data for the custom character to one of the 8 available character generator RAM (CGRAM) locations.
- Parameters:
addr – The address (0 to 7) in the CGRAM to store the custom character.
charmap – A list of 8 bytes representing the custom character’s pixel pattern.
Note
Inspired by peppe8o and MicrocontrollersLab.
- data(val)[source]
Send a data byte to the LCD controller. This method writes to the data register of the LCD (RS = 1).
- Parameters:
val – The data byte to send to the LCD.