diff --git a/examples/basic-plot/main.rs b/examples/basic-plot/main.rs index 5d16134..2d090a2 100644 --- a/examples/basic-plot/main.rs +++ b/examples/basic-plot/main.rs @@ -9,11 +9,12 @@ use embedded_plots::Plot; fn main() -> Result<(), core::convert::Infallible> { let mut display: SimulatorDisplay = SimulatorDisplay::new(Size::new(480, 272)); - Plot::new( - vec![ - Point::new(100, 100), - Point::new(150, 100), - Point::new(200, 200)],RgbColor::GREEN) + let data = vec![ + Point::new(100, 100), + Point::new(150, 100), + Point::new(200, 200)]; + Plot::new(data.as_slice() + ,RgbColor::GREEN) .draw(&mut display)?; let output_settings = OutputSettingsBuilder::new() diff --git a/src/lib.rs b/src/lib.rs index 8322fed..afd3ccd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![no_std] + use embedded_graphics::drawable::{Drawable}; use embedded_graphics::DrawTarget; use embedded_graphics::geometry::Point; @@ -5,17 +7,16 @@ use embedded_graphics::pixelcolor::{PixelColor}; use embedded_graphics::primitives::{Line, Primitive}; use embedded_graphics::style::PrimitiveStyle; - -pub struct Plot +pub struct Plot<'a, C> { - data: Vec, + data: &'a [Point], color: C, } -impl Plot +impl<'a, C> Plot<'a, C> where C: PixelColor { - pub fn new(data: Vec,color : C) -> Plot { + pub fn new(data: &'a [Point],color : C) -> Plot { Plot { data, color, @@ -23,7 +24,7 @@ impl Plot } } -impl Drawable for Plot +impl<'a, C> Drawable for Plot<'a, C> where C: PixelColor { fn draw>(self, display: &mut D) -> Result<(), >::Error> {