2020-12-20 11:11:06 +00:00
|
|
|
use embedded_graphics::{
|
|
|
|
prelude::*,
|
2021-01-04 21:20:07 +00:00
|
|
|
pixelcolor::BinaryColor,
|
2020-12-20 11:11:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
use embedded_graphics_simulator::{SimulatorDisplay, Window, OutputSettingsBuilder, BinaryColorTheme};
|
|
|
|
|
|
|
|
use embedded_plots::{
|
|
|
|
single_plot::{SinglePlot},
|
|
|
|
curve::{PlotPoint, Curve},
|
2021-01-04 21:20:07 +00:00
|
|
|
axis::Scale,
|
2020-12-20 11:11:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
fn main() -> Result<(), core::convert::Infallible> {
|
|
|
|
let mut display: SimulatorDisplay<BinaryColor> = SimulatorDisplay::new(Size::new(128, 48));
|
|
|
|
|
|
|
|
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 },
|
|
|
|
];
|
|
|
|
let curve = Curve::from_data(data.as_slice());
|
|
|
|
|
2021-01-04 21:20:07 +00:00
|
|
|
let plot = SinglePlot::new(
|
|
|
|
&curve,
|
|
|
|
Scale::RangeFraction(3),
|
2021-02-16 19:51:09 +00:00
|
|
|
Scale::RangeFraction(2),
|
|
|
|
).into_drawable(
|
|
|
|
BinaryColor::On,
|
|
|
|
Point { x: 18, y: 2 },
|
|
|
|
Point { x: 120, y: 30 },
|
2021-01-04 21:20:07 +00:00
|
|
|
);
|
2020-12-20 11:11:06 +00:00
|
|
|
|
|
|
|
plot.draw(&mut display)?;
|
|
|
|
let output_settings = OutputSettingsBuilder::new()
|
|
|
|
.theme(BinaryColorTheme::OledBlue)
|
|
|
|
.build();
|
|
|
|
Window::new("Basic plot", &output_settings)
|
|
|
|
.show_static(&display);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|