Skip to content

Driver for the ST7567S LCD controller

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACH
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

rust-embedded-community/st7567s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

8 Commits

ST7567S Display Controller Driver

Crates.io Docs.rs

This crate provides a driver for the ST7567S display controller that can be used with Rust embedded projects.

Features

  • Supports I2C and SPI communication protocols via thedisplay_interfacecrate.
  • Provides two display modes:
    • Direct Write Mode (by default): This mode allows you to write directly to the display memory by calling the [draw] method.
    • Buffered Mode: This mode allows you to modify an internal buffer by using methods like [set_pixel], [clear], or by using theembedded-graphicscrate. Once you have made your changes, you can call the [flush] method to write the buffer to the display.

Notes

  • This driver is designed to work with a more common 128x64 resolution, instead of the original 132x65 resolution of the ST7567S controller.
  • SPI communication is not tested yet.

Examples

Direct write mode

usest7567s::{
display::{DirectWriteMode,ST7567S},
interface::{I2CDisplayInterface,I2CInterface},
};
structI2CStub;
implembedded_hal::blocking::i2c::WriteforI2CStub{
typeError=();
fnwrite(&mutself,_addr:u8,_buf:&[u8])->Result<(),()>{
Ok(())
}
}

leti2c =I2CStub;
letinterface =I2CDisplayInterface::new(i2c);
letmutdisplay =ST7567S::new(interface);
display.init().unwrap();

// Set all pixels to enabled state
display
.draw([0xff;128*64/8].as_slice())
.unwrap();

Buffered mode + embedded_graphics

usest7567s::{
display::{BufferedMode,ST7567S},
interface::{I2CDisplayInterface,I2CInterface},
};
useembedded_graphics::{
mono_font::{ascii::FONT_6X10,MonoTextStyleBuilder},
pixelcolor::BinaryColor,
prelude::*,
text::{Baseline,Text},
};
structI2CStub;
implembedded_hal::blocking::i2c::WriteforI2CStub{
typeError=();
fnwrite(&mutself,_addr:u8,_buf:&[u8])->Result<(),()>{
Ok(())
}
}

leti2c =I2CStub;
letinterface =I2CDisplayInterface::new(i2c);
letmutdisplay =ST7567S::new(interface)
.into_buffered_graphics_mode();
display.init().unwrap();

lettext_style =MonoTextStyleBuilder::new()
.font(&FONT_6X10)
.text_color(BinaryColor::On)
.build();

Text::with_baseline("Hello world!",Point::zero(),text_style,Baseline::Top)
.draw(&mutdisplay)
.unwrap();

Text::with_baseline("Hello Rust!",Point::new(0,16),text_style,Baseline::Top)
.draw(&mutdisplay)
.unwrap();

display.flush().unwrap();

Thanksssd1306driver for served as an example.

License

Licensed under either of

at your option.

Contribution

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.