A Raspberry Pi LCD library for the widely used Hitachi HD44780 controller.
A Python 2/3 Raspberry PI Character LCD library for the Hitachi HD44780 controller.
The GPIO access is provided by the great RPIO library.
- Simple to use API
- Support for both 4 bit and 8 bit modes
- Python 2/3 compatible
>>> from RPLCD import CharLCD >>> lcd = CharLCD() >>> lcd.write_string('Raspberry Pi HD44780') >>> lcd.cursor_pos = (2, 0) >>> lcd.write_string('http://github.com/\n\rdbrgn/RPLCD')
(TLDR: Use pip install RPLCD)
As prerequisite to build the RPIO dependency, you need the python-dev package. And to install the package itself, you’ll want to use pip. Both should already be installed on a regular Raspbian image. Otherwise, install them:
$ sudo apt-get install python-dev python-pip
I would recommend you to always use virtualenv and virtualenvwrapper when developing Python applications. This way, you have an isolated environment for each project, which prevents package version conflicts.
To install virtualenv and virtualenvwrapper:
$ sudo apt-get install virtualenvwrapper
Log out and back in to activate the virtualenvwrapper scripts. Then create a new virtualenv:
$ mkvirtualenv myproject
To enable the virtualenv, use workon myproject and to disable it use deactivate.
Then install the RPLCD library with its dependencies:
$ pip install RPLCD
If you want you can also skip the virtualenv part and install the library system-wide. In that case just run pip as root:
$ sudo pip install RPLCD
You can also install the library manually without pip. Either just copy the scripts to your working directory and import them, or download the repository and run python setup.py install to install it into your Python package directory.
The standard wiring configuration uses the following pins (BOARD numbering scheme):
- RS: 15
- RW: 18
- E: 16
- Data 4-7: 21, 22, 23, 24
Init, Setup, Teardown
import RPIO from RPLCD import CharLCD # Initialize display. All values have default values and are therefore # optional. lcd = CharLCD(pin_rs=15, pin_e=16, pins_data=[21, 22, 23, 24], numbering_mode=RPIO.BOARD, cols=20, rows=4, dotsize=8) ... # If desired, reset the GPIO configuration and optionally clear the screen. # Note that this can lead to undesired effects on the LCD, because the GPIO # pins are not configured as input or output anymore. lcd.close(clear=True)
- display_enabled -> True / False
- cursor_pos -> (row, col)
- text_align_mode -> Alignment.left / Alignment.right
- write_shift_mode -> ShiftMode.cursor / ShiftMode.display
- cursor_mode -> CursorMode.hide / CursorMode.line / CursorMode.blink
High Level Functions
- write_string(value): Write the specified string to the display. You can use newline (\n) and carriage return (\n) characters.
- clear(): Overwrite display with blank characters and reset cursor position.
- home(): Set cursor to initial position and reset any shifting.
- shift_display(amount): Shift the display. Use negative amounts to shift left and positive amounts to shift right.
Mid Level Functions
- write(value): Send a raw command to the LCD.
- command(value): Write a raw byte to the LCD.
To test your display, please run the test.py script and confirm/verify each step with the enter key. If you don’t use the standard wiring, make sure to add your pin numbers to the CharLCD constructor in test.py.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size RPLCD-0.1.tar.gz (9.1 kB)||File type Source||Python version None||Upload date||Hashes View hashes|