From 16838b1f31adf166667c824c133935eca4a9cee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Chodzikiewicz?= Date: Fri, 18 Dec 2020 00:32:58 +0100 Subject: [PATCH] Add no_std attribute --- examples/basic-plot/main.rs | 11 ++++++----- src/lib.rs | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) 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> {