Crates.io | embedded-graphics-sparklines |
lib.rs | embedded-graphics-sparklines |
version | 0.1.0 |
source | src |
created_at | 2022-02-22 17:01:00.649749 |
updated_at | 2022-03-02 17:30:19.463948 |
description | Sparklines for rust's embedded-graphics |
homepage | |
repository | |
max_upload_size | |
id | 537355 |
size | 62,286 |
Sparklines are small, high resolution graphics embedded in a context of words, numbers or images". Edward Tufte describes sparklines as "data-intense, design-simple, word-sized graphics".
Explore the docs »
Rust Crate
·
Report Bug
·
Request Feature
This library is a Rust implementation of ESParklines library which is extemely useful for creating real-time graphs for use with small embedded systems screeens.
This library is designed to be as simple as possible. It is responsible for:
Make sure you have your rust
environment configurated
Add library to your Cargo.toml
...
[dependencies]
embedded-graphics-sparklines = "0.1.0"
Use the library in you code
let mut display: SimulatorDisplay<BinaryColor> = SimulatorDisplay::new(Size::new(240, 135));
let bbox = Rectangle::new(Point::new(0, 26), Size::new(240, 90));
let draw_fn = |lastp, p| Line::new(lastp, p);
// create sparkline object
let mut sparkline = Sparkline::new(
bbox, // position and size of the sparkline
32, // max samples to store in memory (and display on graph)
BinaryColor::On,
1, // stroke size
draw_fn,
);
let output_settings = OutputSettingsBuilder::new()
.theme(BinaryColorTheme::OledBlue)
.build();
let mut window = Window::new("Sparkline", &output_settings);
loop {
let val = rand::thread_rng().gen_range(0..100);
sparkline.add(val);
sparkline.draw(&mut display)?;
window.update(&display);
thread::sleep( Duration::from_millis(100);
}
Experiment and have fun! :relieved: See main.rs
if you want to run a quick demo.
cargo
set up$ cargo install embedded-graphics-sparklines
$ embedded-graphics-sparklines --features build-binary
See the open issues for a full list of proposed features (and known issues).
Distributed under the MIT License. See LICENSE
for more information.
Bernard Kobos - @bkobos - bkobos@gmail.com
Project Link: https://github.com/bernii/embedded-graphics-sparklines