Trait led_matrix::LedMatrix

source ·
pub trait LedMatrix: Index<(usize, usize), Output = (u8, u8, u8)> + IndexMut<(usize, usize)> {
Show 13 methods // Required methods fn apply(&mut self); fn set_brightness(&mut self, brightness: u8); fn sleep_ms(&mut self, duration: u32); fn get_sin(&self) -> fn(_: f32) -> f32; fn joystick_position(&mut self) -> JoystickPosition; fn switch(&mut self) -> bool; // Provided methods fn fill(&mut self, color: (u8, u8, u8)) { ... } fn clear(&mut self) { ... } fn draw_coordinates( &mut self, coords: &mut dyn Iterator<Item = (usize, usize)>, color: (u8, u8, u8), ) { ... } fn draw_bitmap(&mut self, bitmap: &[u8]) { ... } fn draw_horizontal_billboard_frame( &mut self, billboard: Billboard, offset: usize, ) { ... } fn draw_vertical_billboard_frame( &mut self, billboard: Billboard, offset: usize, ) { ... } fn draw_text_billboard_frame( &mut self, text: &[Character], frame_offset: usize, ) { ... }
}
Expand description

A high-level interface for programming the LED-matrix.

To update the color of an LED, you can index the LedMatrix with a tuple of integers (x, y) in the range 0..8 each.

After changing the values of one or several LEDs, don’t forget to call apply to actually apply these changes in a batch.

Here is the coordinate system visualized:

╭─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────╮
│ 7,0 │ 7,1 │ 7,2 │ 7,3 │ 7,4 │ 7,5 │ 7,6 │ 7,7 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 6,0 │ 6,1 │ 6,2 │ 6,3 │ 6,4 │ 6,5 │ 6,6 │ 6,7 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 5,0 │ 5,1 │ 5,2 │ 5,3 │ 5,4 │ 5,5 │ 5,6 │ 5,7 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 4,0 │ 4,1 │ 4,2 │ 4,3 │ 4,4 │ 4,5 │ 4,6 │ 4,7 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 3,0 │ 3,1 │ 3,2 │ 3,3 │ 3,4 │ 3,5 │ 3,6 │ 3,7 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 2,0 │ 2,1 │ 2,2 │ 2,3 │ 2,4 │ 2,5 │ 2,6 │ 2,7 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 1,0 │ 1,1 │ 1,2 │ 1,3 │ 1,4 │ 1,5 │ 1,6 │ 1,7 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 0,0 │ 0,1 │ 0,2 │ 0,3 │ 0,4 │ 0,5 │ 0,6 │ 0,7 │
╰─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────╯

Required Methods§

source

fn apply(&mut self)

Tell the LED-matrix to display the currently stored color values for each LED.

If you are drawing in an endless loop, consider calling sleep_ms at some point to slow down the execution.

source

fn set_brightness(&mut self, brightness: u8)

Set the brightness of the display.

The display is set at a default brightness of 50 (about 20%).

This method is a no-op for the GUI emulator.

source

fn sleep_ms(&mut self, duration: u32)

Sleep for the specified amount of milliseconds.

source

fn get_sin(&self) -> fn(_: f32) -> f32

Get a sinus function.

This is necessary to abstract over hardware and emulator.

source

fn joystick_position(&mut self) -> JoystickPosition

Get the current joystick position.

source

fn switch(&mut self) -> bool

Get the current value of the switch.

Provided Methods§

source

fn fill(&mut self, color: (u8, u8, u8))

Set every LED to a single color at the same time.

You still need to call apply afterwards.

source

fn clear(&mut self)

Turn off all LEDs.

source

fn draw_coordinates( &mut self, coords: &mut dyn Iterator<Item = (usize, usize)>, color: (u8, u8, u8), )

Set a list of LEDs to a single color.

LEDs are specified as an iterator of coordinates (x, y).

source

fn draw_bitmap(&mut self, bitmap: &[u8])

Draw a bitmap file with a color depth of 24 bit.

bitmap format: https://en.wikipedia.org/wiki/BMP_file_format

source

fn draw_horizontal_billboard_frame( &mut self, billboard: Billboard, offset: usize, )

Draw a frame of a horizontal billboard at a specified offset.

Construct such a billboard with billboard::horizontal.

This function only draws a single frame, you probably want to loob over offsets and draw each frame with a desired delay using sleep_ms.

See the module documentation of billboard for more information.

source

fn draw_vertical_billboard_frame(&mut self, billboard: Billboard, offset: usize)

Draw a frame of a vertical billboard at a specified offset.

Construct such a billboard with billboard::vertical.

This function is analogous to draw_horizontal_billboard_frame.

source

fn draw_text_billboard_frame(&mut self, text: &[Character], frame_offset: usize)

Draw a frame of a strip of text at a specified offset.

Construct such a strip of text with character::convert_str.

Like draw_horizontal_billboard_frame, this function only draws a single frame. You probably want to loob over offsets and draw each frame with a desired delay using sleep_ms.

Implementors§