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.
It works on some level. Rectangles are fine.
There are interesting issues though, with my setup (stm32f401 + 8x8 ws2812 matrix): * circles are not exacly drawn always to the same position * write operation usually gets back with an overrun error, while the display is still updated for ~every second time
Transformation
.You may start by creating 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: ```rust use ws2812_spi as ws2812;
use smartledsmatrix::*;
use embedded_graphics::{ pixelcolor::, prelude::, primitives::{ PrimitiveStyleBuilder, Rectangle, }, };
fn main() -> ! { [...] let ws = ws2812::Ws2812::new(spi); let mut matrix = new8x8yinverted(ws); matrix.setbrightness(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 flush().
matrix.flush();
loop{}
} ```