Crates.io | qwiic-lcd-rs |
lib.rs | qwiic-lcd-rs |
version | 0.1.11 |
source | src |
created_at | 2021-10-13 03:43:58.673127 |
updated_at | 2022-06-25 04:39:31.854005 |
description | This library aims at controlling QwiicLCD screens using I2C from Linux. |
homepage | |
repository | https://github.com/PixelCoda/QwiicLCD-Rust |
max_upload_size | |
id | 464321 |
size | 24,343 |
This library aims at controlling QwiicLCD screens using I2C from Linux. It primary target is ARM devices such as RaspberryPi or FriendlyARM's NanoPi Neo. It should nonetheless work on other Linux distributions with access to an I2C bus.
Currently I only have access to the 20x4 LCD for testing purposes. If you have issues with other Qwiic LCDs please submit an issue or a pull request.
Add the following line to your cargo.toml:
qwiic-lcd-rs = "0.1.11"
Or for the most recent commit on the master branch use:
qwiic-lcd-rs = { git = "https://github.com/PixelCoda/QwiicLCD-Rust.git", version = "*" }
Example:
extern crate qwiic_lcd_rs;
use qwiic_lcd_rs::*;
use std::thread;
use std::time::Duration;
fn main() {
// Default LCDSize is 4x20
let mut config = ScreenConfig::default();
// Uncomment and modify the values below to use different screen sizes
// config.max_rows = 2;
// config.max_columns = 16;
// Default Qwiic address is 0x72
let mut screen = Screen::new(config, "/dev/i2c-1", 0x72).expect("Could not init device");
// Set backlight to green and wait 1 second
screen.change_backlight(0, 255, 0).unwrap();
thread::sleep(Duration::from_secs(1));
// Set backlight to bright white
screen.change_backlight(255, 255, 255).unwrap();
// Clear the screen
screen.clear().unwrap();
// Move the cursor to 0,0
screen.move_cursor(0,0).unwrap();
// Print text
screen.print("Hello from Rust!").unwrap();
// Move to the next line
screen.move_cursor(1,0).unwrap();
// Print text
screen.print("It works! :)").unwrap();
}
Released under Apache 2.0.