Add no_std attribute

This commit is contained in:
Michał Chodzikiewicz 2020-12-18 00:32:58 +01:00
parent 242d8eb750
commit 16838b1f31
2 changed files with 13 additions and 11 deletions

View file

@ -9,11 +9,12 @@ use embedded_plots::Plot;
fn main() -> Result<(), core::convert::Infallible> { fn main() -> Result<(), core::convert::Infallible> {
let mut display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(480, 272)); let mut display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(480, 272));
Plot::new( let data = vec![
vec![ Point::new(100, 100),
Point::new(100, 100), Point::new(150, 100),
Point::new(150, 100), Point::new(200, 200)];
Point::new(200, 200)],RgbColor::GREEN) Plot::new(data.as_slice()
,RgbColor::GREEN)
.draw(&mut display)?; .draw(&mut display)?;
let output_settings = OutputSettingsBuilder::new() let output_settings = OutputSettingsBuilder::new()

View file

@ -1,3 +1,5 @@
#![no_std]
use embedded_graphics::drawable::{Drawable}; use embedded_graphics::drawable::{Drawable};
use embedded_graphics::DrawTarget; use embedded_graphics::DrawTarget;
use embedded_graphics::geometry::Point; use embedded_graphics::geometry::Point;
@ -5,17 +7,16 @@ use embedded_graphics::pixelcolor::{PixelColor};
use embedded_graphics::primitives::{Line, Primitive}; use embedded_graphics::primitives::{Line, Primitive};
use embedded_graphics::style::PrimitiveStyle; use embedded_graphics::style::PrimitiveStyle;
pub struct Plot<'a, C>
pub struct Plot<C>
{ {
data: Vec<Point>, data: &'a [Point],
color: C, color: C,
} }
impl<C> Plot<C> impl<'a, C> Plot<'a, C>
where C: PixelColor where C: PixelColor
{ {
pub fn new(data: Vec<Point>,color : C) -> Plot<C> { pub fn new(data: &'a [Point],color : C) -> Plot<C> {
Plot { Plot {
data, data,
color, color,
@ -23,7 +24,7 @@ impl<C> Plot<C>
} }
} }
impl<C> Drawable<C> for Plot<C> impl<'a, C> Drawable<C> for Plot<'a, C>
where C: PixelColor where C: PixelColor
{ {
fn draw<D: DrawTarget<C>>(self, display: &mut D) -> Result<(), <D as DrawTarget<C>>::Error> { fn draw<D: DrawTarget<C>>(self, display: &mut D) -> Result<(), <D as DrawTarget<C>>::Error> {