Skip to content

Commit 07d6810

Browse files
authored
Merge pull request #127 from mangelajo/add-heap-allocation-support
Document the heap allocation of Displayxxxx:default()
2 parents e113bea + db0fd5c commit 07d6810

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/traits.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,24 @@ where
126126
///# Ok(())
127127
///# }
128128
///```
129+
///
130+
/// # Heap allocation
131+
///
132+
/// For systems where stack space is limited but heap space is available
133+
/// (i.e. ESP32 platforms with PSRAM) it's possible to allocate the display buffer
134+
/// in heap; the Displayxxxx:default() is implemented as always inline, so you can
135+
/// use Box::new to request heap space for the display buffer.
136+
///
137+
///```rust, no_run
138+
///# use epd_waveshare::epd4in2::Display4in2;
139+
///# use epd_waveshare::prelude::*;
140+
///# use embedded_graphics_core::prelude::*;
141+
///# use embedded_graphics::primitives::*;
142+
///let mut display = Box::new(Display4in2::default());
143+
///let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
144+
/// .into_styled(PrimitiveStyle::with_stroke(Color::Black, 1))
145+
/// .draw(&mut *display);
146+
///```
129147
pub trait WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
130148
where
131149
SPI: SpiDevice,

0 commit comments

Comments
 (0)