Merge branch 'fix/itertools-no-std' into 'master'

Fix/itertools no std

Closes #12

See merge request mchodzikiewicz/embedded-plots!18
This commit is contained in:
Michał Chodzikiewicz 2022-06-27 09:06:51 +00:00
commit f83c47d915
3 changed files with 13 additions and 22 deletions

View file

@ -9,13 +9,13 @@ homepage = "https://gitlab.com/mchodzikiewicz/embedded-plots"
repository = "https://gitlab.com/mchodzikiewicz/embedded-plots" repository = "https://gitlab.com/mchodzikiewicz/embedded-plots"
readme = "README.md" readme = "README.md"
keywords = ["embedded", "plot", "graphics"] keywords = ["embedded", "plot", "graphics"]
categories = ["embedded","visualization"] categories = ["embedded","visualization","no-std","graphics"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
embedded-graphics = "0.6.0" embedded-graphics = "0.6.0"
itertools = "0.9.0" itertools = {version = "0.9.0", default-features = false}
heapless = "0.5.6" heapless = "0.5.6"
[dev-dependencies] [dev-dependencies]

View file

@ -123,22 +123,13 @@ impl<C, I> Drawable<C> for DrawableCurve<C, I>
Some(t) => t, Some(t) => t,
}; };
let style = PrimitiveStyle::with_stroke(color, thickness as u32); let style = PrimitiveStyle::with_stroke(color, thickness as u32);
let mut iter = self.scaled_data.into_iter(); self.scaled_data
let mut prev = iter.next().unwrap(); .tuple_windows()
for point in iter { .try_for_each(|(prev, point)| -> Result<(), D::Error> {
Line::new(prev, point) Line::new(prev, point)
.into_styled(style) .into_styled(style)
.draw(display)?; .draw(display)
prev = point; })
}
Ok(())
} }
} }
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

View file

@ -16,9 +16,9 @@
//! ### Single plot //! ### Single plot
//! Simple plot example //! Simple plot example
//! #### On color display: //! #### On color display:
//! ![single plot on color display](doc-resources/single-plot-color.png "Color plot of single curve") //! ![single plot on color display](https://gitlab.com/mchodzikiewicz/embedded-plots/-/raw/master/single-plot-color.png "Color plot of single curve")
//! #### On monochromatic display: //! #### On monochromatic display:
//! ![single plot on monochromatic display](doc-resources/single-plot-mono.png "Monochromatic plot of single curve") //! ![single plot on monochromatic display](https://gitlab.com/mchodzikiewicz/embedded-plots/-/raw/master/single-plot-mono.png "Monochromatic plot of single curve")
//! //!
//! Code to render: //! Code to render:
//! ```rust //! ```rust
@ -56,7 +56,7 @@
//! //!
//! ### Axis //! ### Axis
//! You can also use axis on its own, it looks like this: //! You can also use axis on its own, it looks like this:
//! ![free axis examples](doc-resources/free-axis-example.png "Free axis example") //! ![free axis examples](https://gitlab.com/mchodzikiewicz/embedded-plots/-/raw/master/doc-resources/free-axis-example.png "Free axis example")
//! Code to render example axis: //! Code to render example axis:
//! ```rust //! ```rust
//! use embedded_plots::axis::{Axis, Scale, Placement}; //! use embedded_plots::axis::{Axis, Scale, Placement};