Crates.io | smart-leds-matrix |
lib.rs | smart-leds-matrix |
version | 0.2.0 |
source | src |
created_at | 2022-02-06 22:33:17.006639 |
updated_at | 2024-01-17 13:46:49.24706 |
description | DrawTarget implementation for smart led based matrixes. It allows the usage of the embedded-graphics Drawables. |
homepage | |
repository | https://github.com/smart-leds-rs/smart-leds-matrix |
max_upload_size | |
id | 528069 |
size | 26,619 |
A DrawTarget
implementation to use (one, or more) smart LED matrixes as a graphics display driven by embedded-graphics Drawable
objects.
The integrated driver is from smart-leds crate.
layout
.You may start by creating a driver for your LED and controller. Some examples can be found here.
Once you have it, you can plug it into the DrawTarget
implemented by this crate.
Example:
use ws2812_spi as ws2812;
use smart_leds_matrix::{SmartLedMatrix, layout::Rectangular};
use embedded_graphics::{
pixelcolor::*,
prelude::*,
primitives::{
PrimitiveStyleBuilder, Rectangle,
},
};
fn main() -> ! {
[...]
let ws = ws2812::Ws2812::new(spi);
let mut matrix = SmartLedMatrix::<_, _, {8 * 8}>::new(ws, Rectangular::new_inverted_y(8, 8));
matrix.set_brightness(15);
matrix.clear(Rgb888::new(0, 0, 0));
// Drawable objects are calling draw_iter() function of the matrix.
// That is, only the internal frame buffer is updated, no real
// communication happens yet. That is useful when a frame is composed
// of multiple objects, text, etc.
Rectangle::new(Point::new(1, 1), Size::new(6, 6))
.into_styled(
PrimitiveStyleBuilder::new()
.fill_color(Rgb888::RED)
.build(),
).draw(&mut matrix)?;
// Trigger the actual frame update on the matrix with gamma correction.
matrix.flush_with_gamma();
loop{}
}