Skip to content

iCMDdev/CharPi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CharPi - Python HD44780 display driver for Raspberry Pi

Image of a display using CharPiPython character display (Hitachi HD44780) driver for Raspberry Pi with many features, such as Custom Output Handling (makes it easy to use intermediary chips such as Shift Registers) and automatic text alignment (coming in a future update). Includes support for I2C backpacks.

CharPi includes support for most character displays based on the Hitachi HD44780 display (including I2C backpacks). By default, it has support for displays with up to 4 rows, but this can be easily changed by modifying the Python list containing each row's starting DDRAM address.

Special feature: Custom Output Handling

Custom Output Handling makes it easy to use intermediary chips such as Shift Registers, or any other type of complex setups, by providing your own callback function that handles the output signals. Your function will be called by CharPi every time a display command needs to be sent. Note that a display command is not necessarily equivalent to a CharPi function (meaning that if you call a function such as writeString(), your function will be called more than once). Your function will have a binary number as an argument. This argument will store the pin values that will need to be sent to the display, in the following format:

   | Digit 1 | Digit 2 | Digit 3 | Digit 4 |  Digit 5  | Digit 6 | Digit 7 | Digit 8 |
--------------------------------------------------------------------------------------
0b |  PIN 1  |  PIN 2  |  PIN 3  |  PIN 4  | BACKLIGHT |  none   |   RW    |   RS    |

The custom ouput handling object (HD44780CustomDriver()) uses the display in 4-bit mode.

Here is how your callback function should look like:

def functionName(binaryData):
    # send received data to the display

Dependencies

CharPi relies on RPi.GPIO and smbus Python modules to communicate with the display. RPi.GPIO comes with the latest Raspberry Pi OS by default. SMBus isn't preinstalled on the Lite version, but you can install it with pip3.

Python minimum tested version: 3.7. Tested on Raspberry Pi OS Buster & Bullseye. It might work fine on other operating systems too (if the dependencies are installed and the required changes are made).

Installation guide

To install CharPi, you'll first have to download this repository's code. You can use git to download it directly on the RPi.

git clone https://github.com/iCMDgithub/CharPi.git

After downloading, open the Terminal and navigate inside the package using:

cd CharPi/code

Then, you can install the library using the following command (requires root privileges) :

sudo python3 setup.py install

You succesfully installed the library. Now you can start coding, or try out some examples. Good luck on your projects!

Usage

Check out the examples.

Display initialization

A display usually need be initialized using the number of rows and columns of the display. However, in some cases, displays without an auxiliary chip might need to have a different initialization. For example, an original HD44780 16x1 display probably needs to be initialized as an 8x2 display.

Legal

Raspberry Pi is a trademark of Raspberry Pi Ltd. This Python library is not affiliated with Raspberry Pi Ltd. in any way.

About

Python character display (Hitachi HD44780) driver for Raspberry Pi. Includes support for custom characters, I2C backpacks and custom wirings.

Topics

Resources

License

Stars

Watchers

Forks

Languages