Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kattouf committed Apr 4, 2023
1 parent 9495485 commit 7651ca8
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "st7567s"
description = "Driver for the ST7567S LCD controller"
authors = ["Vasilii Ianguzin <vasiliy.kattouf@gmail.com>"]
categories = ["embedded", "no-std"]
version = "0.2.0"
version = "0.2.1"
edition = "2021"
documentation = "https://docs.rs/st7567s"
keywords = ["no-std", "st7567s", "lcd", "embedded", "embedded-hal-driver"]
Expand Down
87 changes: 81 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,89 @@ This crate provides a driver for the ST7567S display controller that can be used

# Features

- Supports I2C and SPI communication protocols via the [`display_interface`](https://docs.rs/display_interface) crate.
- Supports I2C and SPI communication protocols via the [`display_interface`](https://docs.rs/display_interface) crate.
- Provides two display modes:
- Internal Buffer Mode: This mode allows you to modify an internal buffer by using methods like `set_pixel`, `clear`, or by using the [`embedded-graphics`](https://docs.rs/embedded-graphics) crate. Once you have made your changes, you can call the `flush` method to write the buffer to the display.
- Direct Write Mode: This mode allows you to write directly to the display memory by calling the `draw` method.
- 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 the [`embedded-graphics`] crate. Once you have made your changes, you can call the [`flush`] method to write the buffer to the display.

**Note**: This driver is designed to work with a more generic 128x64 resolution, instead of the original 132x65 resolution of the ST7567S controller.
**Note**: SPI communication is not tested yet.
[`embedded-graphics`]: https://docs.rs/embedded-graphics

# 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

```rust
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();

```

### Buffered mode + embedded_graphics

```rust
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`](https://github.com/jamwaffles/ssd1306) driver for served as an example.

Expand All @@ -33,4 +109,3 @@ 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.

0 comments on commit 7651ca8

Please sign in to comment.