Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the heap allocation of Displayxxxx:default() #127

Merged
merged 7 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ where
///# Ok(())
///# }
///```
///
/// # Heap allocation
///
/// For systems where stack space is limited but heap space is available
/// (i.e. ESP32 platforms with PSRAM) it's possible to allocate the display buffer
/// in heap; the Displayxxxx:default() is implemented as always inline, so you can
/// use Box::new to request heap space for the display buffer.
///
///```rust, no_run
mangelajo marked this conversation as resolved.
Show resolved Hide resolved
///# use epd_waveshare::epd4in2::Display4in2;
///# use epd_waveshare::prelude::*;
///# use embedded_graphics_core::prelude::*;
caemor marked this conversation as resolved.
Show resolved Hide resolved
///# use embedded_graphics::primitives::*;
///let mut display = Box::new(Display4in2::default());
///let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
/// .into_styled(PrimitiveStyle::with_stroke(Color::Black, 1))
/// .draw(&mut *display);
///```
pub trait WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
Expand Down