diff --git a/examples/single_plot_rgb.rs b/examples/single_plot_rgb.rs index 3276bd2..d413c68 100644 --- a/examples/single_plot_rgb.rs +++ b/examples/single_plot_rgb.rs @@ -26,7 +26,7 @@ fn main() -> Result<(), core::convert::Infallible> { ]; let curve = Curve::from_data(data.as_slice()); - let plot = SinglePlot::new(&curve, RgbColor::YELLOW, Point { x: 10, y: 10 }, Point { x: 470, y: 260 }); + let plot = SinglePlot::new(&curve, RgbColor::YELLOW, Point { x: 50, y: 10 }, Point { x: 430, y: 250 }); plot.draw(&mut display)?; let output_settings = OutputSettingsBuilder::new() diff --git a/src/axis.rs b/src/axis.rs index 32501f1..629dc94 100644 --- a/src/axis.rs +++ b/src/axis.rs @@ -51,6 +51,10 @@ impl<'a, C, F> Axis<'a, C, F> pub fn new(title: &'a str, orientation: Placement, range: Range, scale: Scale, color: C, text_style: TextStyle, tick_height: usize) -> Axis<'a, C, F> { Axis { title, placement: orientation, range, scale, color, text_style, tick_size: tick_height } } + + pub fn size(&self) -> Point { + Point{x: 50, y: 50} + } } diff --git a/src/single_plot.rs b/src/single_plot.rs index 95d4425..49ad5b3 100644 --- a/src/single_plot.rs +++ b/src/single_plot.rs @@ -3,6 +3,9 @@ use embedded_graphics::drawable::Drawable; use embedded_graphics::DrawTarget; use embedded_graphics::prelude::Point; use embedded_graphics::pixelcolor::PixelColor; +use crate::axis::{Scale, Placement, Axis}; +use embedded_graphics::style::TextStyleBuilder; +use embedded_graphics::fonts::Font6x8; pub struct SinglePlot<'a, C> where @@ -29,6 +32,16 @@ impl<'a, C> Drawable for SinglePlot<'a, C> { fn draw>(self, display: &mut D) -> Result<(), D::Error> { + let text_style = TextStyleBuilder::new(Font6x8) + .text_color(self.color) + .build(); + + Axis::new("X", Placement::X{x1: self.top_left.x, x2: self.bottom_right.x, y: self.bottom_right.y}, 0..100, Scale::Fixed(10), self.color, text_style, 2) + .draw(display)?; + + Axis::new("Y", Placement::Y{y1: self.top_left.y, y2: self.bottom_right.y, x: self.top_left.x}, 0..200, Scale::Fixed(10), self.color, text_style, 1) + .draw(display)?; + self.curve.into_drawable_curve( &self.top_left, &self.bottom_right,