Skip to content

Commit

Permalink
Merge pull request #189 from jetjinser/update-readme-example
Browse files Browse the repository at this point in the history
docs(readme): update example thanks to @jetjinser
  • Loading branch information
caemor authored May 7, 2024
2 parents c5d381a + 553c7aa commit 1244f03
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,28 @@ There are multiple examples in the examples folder. Use `cargo run --example exa

```Rust
// Setup the epd
let mut epd = Epd4in2::new( & mut spi, cs, busy, dc, rst, & mut delay) ?;
let mut epd4in2 =
Epd4in2::new(&mut spi, busy, dc, rst, &mut delay, None).expect("eink initalize error");

// Setup the graphics
let mut display = Display4in2::default ();

// Draw some text
display.draw(
let _ = Text::new("Hello Rust!", Point::new(x, y))
.into_styled(text_style!(
font = Font12x16,
text_color = Black,
background_color = White
))
.draw(display);
);

// Transfer the frame data to the epd and display it
epd.update_and_display_frame( & mut spi, & display.buffer()) ?;
let mut display = Display4in2::default();

// Build the style
let style = MonoTextStyleBuilder::new()
.font(&embedded_graphics::mono_font::ascii::FONT_6X10)
.text_color(Color::White)
.background_color(Color::Black)
.build();
let text_style = TextStyleBuilder::new().baseline(Baseline::Top).build();

// Draw some text at a certain point using the specified text style
let _ = Text::with_text_style("It's working-WoB!", Point::new(175, 250), style, text_style)
.draw(&mut display);

// Going to sleep
epd4in2.sleep(&mut spi, &mut delay)
```
> Check the complete example [here](./examples/epd4in2.rs).
## (Supported) Devices

Expand Down

0 comments on commit 1244f03

Please sign in to comment.