2021-07-23 15:01:38 +00:00
|
|
|
use embedded_graphics::{pixelcolor::Rgb565, prelude::*};
|
2020-12-20 11:11:06 +00:00
|
|
|
|
2021-07-23 15:01:38 +00:00
|
|
|
use embedded_graphics_simulator::{OutputSettingsBuilder, SimulatorDisplay, Window};
|
2020-12-20 11:11:06 +00:00
|
|
|
|
|
|
|
use embedded_plots::{
|
2021-01-04 21:20:07 +00:00
|
|
|
axis::Scale,
|
2021-07-23 15:01:38 +00:00
|
|
|
curve::{Curve, PlotPoint},
|
|
|
|
single_plot::SinglePlot,
|
2020-12-20 11:11:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
fn main() -> Result<(), core::convert::Infallible> {
|
|
|
|
let mut display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(480, 272));
|
|
|
|
let data = vec![
|
|
|
|
PlotPoint { x: 0, y: 0 },
|
2021-01-04 21:20:07 +00:00
|
|
|
PlotPoint { x: 1, y: 2 },
|
|
|
|
PlotPoint { x: 2, y: 2 },
|
2020-12-20 11:11:06 +00:00
|
|
|
PlotPoint { x: 3, y: 0 },
|
|
|
|
];
|
|
|
|
|
2021-07-23 15:01:38 +00:00
|
|
|
let curve = Curve::from_data(data.as_slice());
|
2022-08-13 17:00:41 +00:00
|
|
|
let curve_list = [(curve, RgbColor::YELLOW)];
|
|
|
|
let plot = SinglePlot::new(&curve_list, Scale::RangeFraction(3), Scale::RangeFraction(2))
|
2021-07-23 15:01:38 +00:00
|
|
|
.into_drawable(Point { x: 50, y: 10 }, Point { x: 430, y: 250 })
|
|
|
|
.set_color(RgbColor::YELLOW)
|
|
|
|
.set_text_color(RgbColor::WHITE);
|
2020-12-20 11:11:06 +00:00
|
|
|
|
|
|
|
plot.draw(&mut display)?;
|
2021-07-23 15:01:38 +00:00
|
|
|
|
|
|
|
let output_settings = OutputSettingsBuilder::new().build();
|
|
|
|
|
2020-12-20 11:11:06 +00:00
|
|
|
Window::new("Basic plot", &output_settings).show_static(&display);
|
|
|
|
|
|
|
|
Ok(())
|
2021-07-23 15:01:38 +00:00
|
|
|
}
|