| Crates.io | char_lcd_rgb_i2c |
| lib.rs | char_lcd_rgb_i2c |
| version | 0.1.0 |
| created_at | 2025-03-13 23:45:59.317751+00 |
| updated_at | 2025-03-13 23:45:59.317751+00 |
| description | Rust library for controlling RGB1602 LCD displays via MCP23017 I/O expanders |
| homepage | |
| repository | https://github.com/jyap808/char_lcd_rgb_i2c |
| max_upload_size | |
| id | 1591633 |
| size | 84,694 |
A Rust library for controlling RGB1602 LCD displays connected to Raspberry Pi via MCP23017 I/O expanders.
This project is a Rust port of a Go implementation for interfacing with RGB1602 LCD displays using the MCP23017 I/O expander chip. The MCP23017 communicates with the Raspberry Pi via I2C protocol, providing additional GPIO pins to control the LCD, backlight, and RGB LED.
Key features:
This library was developed for a specific RGB1602 LCD board with the following features:

While similar to the Adafruit 16x2 Character LCD Plus Keypad for Raspberry Pi, this board has different backlight functionality which this library specifically addresses.
Add the library to your Cargo.toml:
[dependencies]
char_lcd_rgb_i2c = { git = "https://github.com/jyap808/char_lcd_rgb_i2c.git" }
Basic example:
use char_lcd_rgb_i2c::{CharLCDRGBI2C, LcdError};
use std::{thread::sleep, time::Duration};
fn main() -> Result<(), LcdError> {
// Initialize a 16x2 LCD
let mut lcd = CharLCDRGBI2C::new(16, 2)?;
// Set backlight and display some text
lcd.set_backlight(true)?;
lcd.set_color(100, 0, 0)?; // Red
lcd.message("Hello, world!\nFrom Rust!")?;
sleep(Duration::from_secs(2));
// Change LED color to blue
lcd.set_color(0, 0, 100)?;
Ok(())
}
See the examples/lcd_demo.rs file for a more comprehensive example.
rppal crate for Raspberry Pi GPIO accessFor cross-compiling to Raspberry Pi, add this to your .cargo/config.toml:
[target.armv7-unknown-linux-gnueabihf]
linker = "armv7l-unknown-linux-gnueabihf-gcc"
# Required for NixOS
rustflags = [
"-C", "link-arg=-Wl,-dynamic-linker=/lib/ld-linux-armhf.so.3"
]
Then build with:
cargo build --target armv7-unknown-linux-gnueabihf
This library is a Rust port created as an exercise in library development and cross-language porting. The implementation is inspired by the Adafruit CircuitPython CharLCD Library.