Crates.io | lcd1602rgb-rs |
lib.rs | lcd1602rgb-rs |
version | 0.2.0 |
source | src |
created_at | 2023-01-29 08:52:22.558383 |
updated_at | 2023-01-30 17:24:45.041152 |
description | Native Rust driver for the waveshare LCD1602-RGB display module. |
homepage | |
repository | https://github.com/XavierCyber/LCD1602-RGB |
max_upload_size | |
id | 770801 |
size | 13,577 |
Driver for the LCD1602RGB segmented LCD, it is not intended for use with other segmented LCDs, however you may be able to use this driver for some basic functionality.
I wrote this driver for my own personal use and will maintain it and implement missing instructions when I need them, especially concerning an application I plan to work on. However feel free to submit a pull request.
This my first real embedded Rust project, and I used the following resources:
Follow the instructions here: https://github.com/rp-rs/rp2040-project-template
Include latest version in Cargo.toml
:
[dependencies]
lcd1602rgb-rs = "0.1.0"
Use this example code in the main.rs
of the rp2040 project template.
let mut scl_pin = pins.gpio15.into_mode::<gpio::FunctionI2C>();
let mut sda_pin = pins.gpio14.into_mode::<gpio::FunctionI2C>();
let i2c_dev = i2c::I2C::new_controller(pac.I2C1, sda_pin, scl_pin, 400_u32.kHz(), &mut pac.RESETS, clocks.system_clock.freq());
let mut display_controller = Display::new(i2c_dev, delay).unwrap();
display_controller.write_text("Hello, World! How are you?").unwrap();
let mut r: u8 = 0;
let mut g: u8 = 255;
let mut b: u8 = 128;
let mut r_set = true;
let mut g_set = true;
let mut b_set = true;
loop {
if r == 255 {
r_set = false;
} else if r == 0 {
r_set = true;
}
if r_set {
r += 1;
} else {
r -= 1;
}
if g == 255 {
g_set = false;
} else if g == 0 {
g_set = true;
}
if g_set {
g += 1;
} else {
g -= 1;
}
if b == 255 {
b_set = false;
} else if b == 0 {
b_set = true;
}
if b_set {
b += 1;
} else {
b -= 1;
}
display_controller.delay.delay_ms(10);
display_controller.backlight_colour(r, g, b).unwrap();
}
README.md
.