From a043e9f728a8c8c3bce610b5fcfa8ee3d29f6d6f Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Pelayo Date: Thu, 8 Dec 2022 15:25:02 +0100 Subject: [PATCH 1/5] Document heap allocation --- src/traits.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/traits.rs b/src/traits.rs index f496f64d..23b4e09c 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -131,6 +131,23 @@ 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 +///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); +/// +///epd.update_frame(&mut spi, display.buffer(), &mut delay)?; +///epd.display_frame(&mut spi, &mut delay)?; +///``` pub trait WaveshareDisplay where SPI: Write, From 75d737d26089807886f0ccf9500482098826e25f Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Pelayo Date: Thu, 8 Dec 2022 19:20:25 +0100 Subject: [PATCH 2/5] Update src/traits.rs Co-authored-by: Christoph Gross <11088935+caemor@users.noreply.github.com> --- src/traits.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/traits.rs b/src/traits.rs index 23b4e09c..d608853e 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -140,6 +140,8 @@ where /// use Box::new to request heap space for the display buffer. /// ///```rust, no_run +///# use epd_waveshare::epd4in2::Display4in2; +///# use embedded_graphics_core::prelude::*; ///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)) From 42414f431e7c18e02f99f62a87c23f4360a3f3c9 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Pelayo Date: Thu, 8 Dec 2022 21:10:59 +0100 Subject: [PATCH 3/5] Update src/traits.rs Co-authored-by: Christoph Gross <11088935+caemor@users.noreply.github.com> --- src/traits.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/traits.rs b/src/traits.rs index d608853e..1bf8ec5e 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -146,9 +146,6 @@ where ///let _ = Line::new(Point::new(0, 120), Point::new(0, 295)) /// .into_styled(PrimitiveStyle::with_stroke(Color::Black, 1)) /// .draw(&mut *display); -/// -///epd.update_frame(&mut spi, display.buffer(), &mut delay)?; -///epd.display_frame(&mut spi, &mut delay)?; ///``` pub trait WaveshareDisplay where From eb625aabffc8bf173dd2b59cfa8c9851e4145af4 Mon Sep 17 00:00:00 2001 From: Christoph Gross <11088935+caemor@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:15:23 +0100 Subject: [PATCH 4/5] Update src/traits.rs --- src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traits.rs b/src/traits.rs index c1b4d93c..d1273c57 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -136,7 +136,7 @@ where /// ///```rust, no_run ///# use epd_waveshare::epd4in2::Display4in2; -///# use embedded_graphics_core::prelude::*; +///# use embedded_graphics::prelude::*; ///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)) From db0fd5ccfba7df20c7b838fcf70f2317081b2f9c Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:22:46 +0100 Subject: [PATCH 5/5] Update to newest embedded graphics version --- src/traits.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/traits.rs b/src/traits.rs index 08ddcb98..abd2b3f9 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -136,7 +136,9 @@ where /// ///```rust, no_run ///# use epd_waveshare::epd4in2::Display4in2; -///# use embedded_graphics::prelude::*; +///# 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))