- C 89.3%
- Python 6.9%
- CMake 3.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| include | ||
| src | ||
| CMakeLists.txt | ||
| conanfile.py | ||
| README.md | ||
lf-hd44780
Reusable HD44780/PCF8574 I2C character LCD driver library for the Raspberry Pi Pico C SDK (compatible with RP2040 and RP2350 / Pico 2), packaged as a Conan package. This driver is designed for generic 16x2 and 20x4 LCD screens equipped with the PCF8574 I2C backpack.
This is part of the Lost + Found suite of projects.
🛠️ Usage with CMake
Copy the driver directory into your project as a subdirectory:
add_subdirectory(lib/lf-hd44780)
target_link_libraries(your_project PRIVATE
lf-hd44780
)
And in your C/C++ code:
#include "lf_hd44780.h"
🔌 Hardware Setup
Connect the PCF8574 I2C backpack to your Pico:
- Pico GP4 (SDA) <-> Backpack SDA
- Pico GP5 (SCL) <-> Backpack SCL
- Pico GND <-> Backpack GND
- Pico VBUS (5V, for high LCD contrast) or 3V3 OUT (safe mode, faint contrast) <-> Backpack VCC
⚠️ Pico 2 (RP2350) 5V Tolerance Note
Unlike the RP2040, the RP2350 digital-only GPIO pins (including GP4 and GP5) are 5V tolerant. Raspberry Pi officially confirmed RP2350's 5V tolerance after qualification and documents it in the updated RP2350 datasheet.
If you power the LCD at 5V, the backpack's onboard pull-up resistors will pull the SDA/SCL lines up to 5V. This is safe to connect directly to RP2350 GPIO, provided IOVDD remains powered whenever 5V is present on either signal. The simplest safe arrangement is to derive the LCD's 5V supply from the same powered Pico 2 assembly. Do not leave a separately powered 5V backpack driving SDA/SCL while the Pico 2 is unpowered.
🎨 Custom Characters (CGRAM)
The HD44780 controller has a character generator RAM (CGRAM) that allows you to define up to 8 custom characters (mapped to ASCII indices 0x00 to 0x07).
Each custom character is defined as a 5x8 pixel grid:
- It is represented by an array of 8 bytes.
- Each byte corresponds to one horizontal row of the grid, from top to bottom.
- Only the 5 least-significant bits of each byte are used. A
1bit turns a pixel ON, and a0bit turns it OFF.
Example: Heart Icon Bitmap
const uint8_t icon_heart[8] = {
0b00000, // Row 0: . . . . .
0b01010, // Row 1: . X . X .
0b11111, // Row 2: X X X X X
0b11111, // Row 3: X X X X X
0b11111, // Row 4: X X X X X
0b01110, // Row 5: . X X X .
0b00100, // Row 6: . . X . .
0b00000 // Row 7: . . . . .
};
Driver Upload
lf_hd44780_create_char(&lcd, 0, icon_heart);
How to Display
Once registered, you can print the glyphs using their slot indices 0 through 7 in your strings:
- Via single character write:
lf_hd44780_write_char(&lcd, 0); - Via text strings:
lf_hd44780_write_string(&lcd, "\x00 Custom Heart");
⚙️ Prerequisites: Setting up Conan with uv
To install the Conan CLI package manager securely and in an isolated environment on your system, it is recommended to use uv:
# Install Conan globally as an isolated tool
uv tool install conan
📦 Consumption via Forgejo Conan Registry
The package is hosted and distributed through the Forgejo Conan Package Registry at git.clowderlabs.com.
1. Add the Remote Registry
Add the remote repository to your local Conan configuration:
conan remote add clowder https://git.clowderlabs.com/api/packages/blong/conan
2. Authenticate
Log in using your personal access token:
conan remote login -p <your_token> clowder <username>
3. Add to your Project
Add the dependency to your conanfile.txt (or conanfile.py):
[requires]
lf-hd44780/0.0.1
Then install the dependencies:
conan install . --output-folder=build --build=missing
🛠️ Local Testing
To test building and exporting this Conan package locally without uploading, run:
conan export .
This will register lf-hd44780/0.0.1 in your local Conan cache for offline testing.