Skip to content

Commit 7651ca8

Browse files
committed
update README.md
1 parent 9495485 commit 7651ca8

File tree

2 files changed

+82
-7
lines changed

2 files changed

+82
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "st7567s"
33
description = "Driver for the ST7567S LCD controller"
44
authors = ["Vasilii Ianguzin <[email protected]>"]
55
categories = ["embedded", "no-std"]
6-
version = "0.2.0"
6+
version = "0.2.1"
77
edition = "2021"
88
documentation = "https://docs.rs/st7567s"
99
keywords = ["no-std", "st7567s", "lcd", "embedded", "embedded-hal-driver"]

README.md

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,89 @@ This crate provides a driver for the ST7567S display controller that can be used
77

88
# Features
99

10-
- Supports I2C and SPI communication protocols via the [`display_interface`](https://docs.rs/display_interface) crate.
10+
- Supports I2C and SPI communication protocols via the [`display_interface`](https://docs.rs/display_interface) crate.
1111
- Provides two display modes:
12-
- 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.
13-
- Direct Write Mode: This mode allows you to write directly to the display memory by calling the `draw` method.
12+
- Direct Write Mode (by default): This mode allows you to write directly to the display memory by calling the [`draw`] method.
13+
- 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.
1414

15-
**Note**: This driver is designed to work with a more generic 128x64 resolution, instead of the original 132x65 resolution of the ST7567S controller.
16-
**Note**: SPI communication is not tested yet.
15+
[`embedded-graphics`]: https://docs.rs/embedded-graphics
16+
17+
# Notes
18+
19+
- This driver is designed to work with a more common 128x64 resolution, instead of the original 132x65 resolution of the ST7567S controller.
20+
- SPI communication is not tested yet.
21+
22+
# Examples
23+
24+
### Direct write mode
25+
26+
```rust
27+
use st7567s::{
28+
display::{DirectWriteMode, ST7567S},
29+
interface::{I2CDisplayInterface, I2CInterface},
30+
};
31+
struct I2CStub;
32+
impl embedded_hal::blocking::i2c::Write for I2CStub {
33+
type Error = ();
34+
fn write(&mut self, _addr: u8, _buf: &[u8]) -> Result<(), ()> {
35+
Ok(())
36+
}
37+
}
38+
39+
let i2c = I2CStub;
40+
let interface = I2CDisplayInterface::new(i2c);
41+
let mut display = ST7567S::new(interface);
42+
display.init().unwrap();
43+
44+
// Set all pixels to enabled state
45+
display
46+
.draw([0xff; 128 * 64 / 8].as_slice())
47+
.unwrap();
48+
49+
```
50+
51+
### Buffered mode + embedded_graphics
52+
53+
```rust
54+
use st7567s::{
55+
display::{BufferedMode, ST7567S},
56+
interface::{I2CDisplayInterface, I2CInterface},
57+
};
58+
use embedded_graphics::{
59+
mono_font::{ascii::FONT_6X10, MonoTextStyleBuilder},
60+
pixelcolor::BinaryColor,
61+
prelude::*,
62+
text::{Baseline, Text},
63+
};
64+
struct I2CStub;
65+
impl embedded_hal::blocking::i2c::Write for I2CStub {
66+
type Error = ();
67+
fn write(&mut self, _addr: u8, _buf: &[u8]) -> Result<(), ()> {
68+
Ok(())
69+
}
70+
}
71+
72+
let i2c = I2CStub;
73+
let interface = I2CDisplayInterface::new(i2c);
74+
let mut display = ST7567S::new(interface)
75+
.into_buffered_graphics_mode();
76+
display.init().unwrap();
77+
78+
let text_style = MonoTextStyleBuilder::new()
79+
.font(&FONT_6X10)
80+
.text_color(BinaryColor::On)
81+
.build();
82+
83+
Text::with_baseline("Hello world!", Point::zero(), text_style, Baseline::Top)
84+
.draw(&mut display)
85+
.unwrap();
86+
87+
Text::with_baseline("Hello Rust!", Point::new(0, 16), text_style, Baseline::Top)
88+
.draw(&mut display)
89+
.unwrap();
90+
91+
display.flush().unwrap();
92+
```
1793

1894
Thanks [`ssd1306`](https://github.com/jamwaffles/ssd1306) driver for served as an example.
1995

@@ -33,4 +109,3 @@ at your option.
33109
Unless you explicitly state otherwise, any contribution intentionally submitted
34110
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
35111
dual licensed as above, without any additional terms or conditions.
36-

0 commit comments

Comments
 (0)