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> {
let mut display: SimulatorDisplay<Rgb565> = 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()

View file

@ -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<C>
pub struct Plot<'a, C>
{
data: Vec<Point>,
data: &'a [Point],
color: C,
}
impl<C> Plot<C>
impl<'a, C> Plot<'a, C>
where C: PixelColor
{
pub fn new(data: Vec<Point>,color : C) -> Plot<C> {
pub fn new(data: &'a [Point],color : C) -> Plot<C> {
Plot {
data,
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
{
fn draw<D: DrawTarget<C>>(self, display: &mut D) -> Result<(), <D as DrawTarget<C>>::Error> {