pub trait Matrix {
const MATRIX_COLS: usize;
const MATRIX_ROWS: usize;
const IMAGE_COLS: usize;
const IMAGE_ROWS: usize;
// Required method
fn image_coordinates(col: usize, row: usize) -> Option<(usize, usize)>;
}
Expand description
Description of a device’s LED layout.
This describes the correspondence between the visible layout of LEDs and the pins controlling them.
§Example implementation
struct SimpleMatrix ();
impl Matrix for SimpleMatrix {
const MATRIX_COLS: usize = 2;
const MATRIX_ROWS: usize = 3;
const IMAGE_COLS: usize = 3;
const IMAGE_ROWS: usize = 2;
fn image_coordinates(col: usize, row: usize) -> Option<(usize, usize)> {
Some((row, col))
}
}
Required Associated Constants§
Sourceconst MATRIX_COLS: usize
const MATRIX_COLS: usize
The number of pins connected to LED columns.
At present this can be at most 16.
Sourceconst MATRIX_ROWS: usize
const MATRIX_ROWS: usize
The number of pins connected to LED rows.
This should normally be a small number (eg 3).
Sourceconst IMAGE_COLS: usize
const IMAGE_COLS: usize
The number of visible LED columns.
Sourceconst IMAGE_ROWS: usize
const IMAGE_ROWS: usize
The number of visible LED rows.
Required Methods§
Sourcefn image_coordinates(col: usize, row: usize) -> Option<(usize, usize)>
fn image_coordinates(col: usize, row: usize) -> Option<(usize, usize)>
Returns the image coordinates (x, y) to use for the LED at (col, row).
Returns None if (col, row) doesn’t control an LED.
Otherwise the return value is in (0..IMAGE_COLS, 0..IMAGE_ROWS), with (0, 0) representing the top left.
§Panics
Panics if the provided col and row are out of range 0..MATRIX_COLS and 0..MATRIX_ROWS.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.