Skip to content

Commit

Permalink
Merge pull request #127 from mangelajo/add-heap-allocation-support
Browse files Browse the repository at this point in the history
Document the heap allocation of Displayxxxx:default()
  • Loading branch information
caemor authored Nov 4, 2024
2 parents e113bea + db0fd5c commit 07d6810
Showing 1 changed file with 18 additions and 0 deletions.
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
///# use epd_waveshare::epd4in2::Display4in2;
///# use epd_waveshare::prelude::*;
///# use embedded_graphics_core::prelude::*;
///# 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

0 comments on commit 07d6810

Please sign in to comment.