[−][src]Trait tiny_led_matrix::Frame
A 'Compiled' representation of an image to be displayed.
Frame
s are populated from images implementing Render
, then passed on
to Display::set_frame()
.
Implementing Frame
Implementations of Frame
do two things:
- specify the
Matrix
used to convert between image and matrix coordinates - act like an array of
RowPlan
s, one for each matrix row.
Note that implementations of Frame
must also implement Copy
and
Default
.
Example implementation
#[derive(Copy, Clone)] struct SimpleFrame ( [RowPlan; 3] ); impl Default for SimpleFrame { fn default() -> SimpleFrame { SimpleFrame([RowPlan::default(); SimpleFrame::ROWS]) } } impl Frame for SimpleFrame { type Mtx = SimpleMatrix; fn row_plan(&self, row: usize) -> &RowPlan { &self.0[row] } fn row_plan_mut(&mut self, row: usize) -> &mut RowPlan { &mut self.0[row] } }
Associated Types
Loading content...Associated Constants
const COLS: usize
The number of pins connected to LED columns.
const ROWS: usize
The number of pins connected to LED rows.
Required methods
fn row_plan(&self, row: usize) -> &RowPlan
Returns a reference to the RowPlan for a row of LEDs.
Panics
Panics if row
is not in the range 0..ROWS
fn row_plan_mut(&mut self, row: usize) -> &mut RowPlan
Returns a mutable reference to the RowPlan for a row of LEDs.
Panics
Panics if row
is not in the range 0..ROWS
Provided methods
fn set<T: ?Sized>(&mut self, image: &T) where
T: Render,
T: Render,
Stores a new image into the frame.
Example:
ⓘThis example is not tested
frame.set(GreyscaleImage::blank());