mirror of
https://gitlab.com/feliix42/embedded-plots.git
synced 2024-11-22 01:46:30 +00:00
Add no_std attribute
This commit is contained in:
parent
242d8eb750
commit
16838b1f31
2 changed files with 13 additions and 11 deletions
|
@ -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()
|
||||
|
|
13
src/lib.rs
13
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<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> {
|
||||
|
|
Loading…
Reference in a new issue