Crates.io | st7567s |
lib.rs | st7567s |
version | 0.2.1 |
source | src |
created_at | 2023-03-30 06:13:42.959505 |
updated_at | 2023-04-04 10:04:43.91842 |
description | Driver for the ST7567S LCD controller |
homepage | |
repository | https://github.com/kattouf/st7567s |
max_upload_size | |
id | 824678 |
size | 36,177 |
This crate provides a driver for the ST7567S display controller that can be used with Rust embedded projects.
display_interface
crate.draw
] method.set_pixel
], [clear
], or by using the embedded-graphics
crate. Once you have made your changes, you can call the [flush
] method to write the buffer to the display.use st7567s::{
display::{DirectWriteMode, ST7567S},
interface::{I2CDisplayInterface, I2CInterface},
};
struct I2CStub;
impl embedded_hal::blocking::i2c::Write for I2CStub {
type Error = ();
fn write(&mut self, _addr: u8, _buf: &[u8]) -> Result<(), ()> {
Ok(())
}
}
let i2c = I2CStub;
let interface = I2CDisplayInterface::new(i2c);
let mut display = ST7567S::new(interface);
display.init().unwrap();
// Set all pixels to enabled state
display
.draw([0xff; 128 * 64 / 8].as_slice())
.unwrap();
use st7567s::{
display::{BufferedMode, ST7567S},
interface::{I2CDisplayInterface, I2CInterface},
};
use embedded_graphics::{
mono_font::{ascii::FONT_6X10, MonoTextStyleBuilder},
pixelcolor::BinaryColor,
prelude::*,
text::{Baseline, Text},
};
struct I2CStub;
impl embedded_hal::blocking::i2c::Write for I2CStub {
type Error = ();
fn write(&mut self, _addr: u8, _buf: &[u8]) -> Result<(), ()> {
Ok(())
}
}
let i2c = I2CStub;
let interface = I2CDisplayInterface::new(i2c);
let mut display = ST7567S::new(interface)
.into_buffered_graphics_mode();
display.init().unwrap();
let text_style = MonoTextStyleBuilder::new()
.font(&FONT_6X10)
.text_color(BinaryColor::On)
.build();
Text::with_baseline("Hello world!", Point::zero(), text_style, Baseline::Top)
.draw(&mut display)
.unwrap();
Text::with_baseline("Hello Rust!", Point::new(0, 16), text_style, Baseline::Top)
.draw(&mut display)
.unwrap();
display.flush().unwrap();
Thanks ssd1306
driver for served as an example.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.