pub struct Display<T>where
T: Instance,{ /* private fields */ }
Expand description
Non-blocking interface to the on board 5x5 LED display
Implementations§
Source§impl<T> Display<T>where
T: Instance,
impl<T> Display<T>where
T: Instance,
Sourcepub fn new(timer: T, pins: DisplayPins) -> Display<T>
pub fn new(timer: T, pins: DisplayPins) -> Display<T>
Create and initialise the display driver
DisplayPins
can be used from Board::display_pins
or the display_pins!
macro can be used is manually.
Sourcepub fn free(self) -> (T, DisplayPins)
pub fn free(self) -> (T, DisplayPins)
Release the timer and pins
Sourcepub fn handle_display_event(&mut self)
pub fn handle_display_event(&mut self)
Update the LED display and timer state
Call this in an interrupt handler for the timer you’re using. This method takes care of updating the LED display and clearing the timer’s event registers
This may be called at any time, so long as the code calling it is not interrupting, or
interruptable by tiny_led_matrix::Display::handle_event()
. Within safe code, the borrow
checker ensures that this requirement is fulfilled. When writing unsafe code, this method
should be called from within a critical
section.
Sourcepub fn show<R>(&mut self, image: &R)where
R: Render,
pub fn show<R>(&mut self, image: &R)where
R: Render,
Show a new image
This may be called at any time, so long as the code calling it is not interrupting, or
interruptable by tiny_led_matrix::Display::handle_event()
. Within safe code, the borrow
checker ensures that this requirement is fulfilled. When writing unsafe code, this method
should be called from within a critical
section.
§Example
display.show(&GreyscaleImage::new(&[
[0, 7, 0, 7, 0],
[7, 0, 7, 0, 7],
[7, 0, 0, 0, 7],
[0, 7, 0, 7, 0],
[0, 0, 7, 0, 0],
]));
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the display
This may be called at any time, so long as the code calling it is not interrupting, or
interruptable by tiny_led_matrix::Display::handle_event()
. Within safe code, the borrow
checker ensures that this requirement is fulfilled. When writing unsafe code, this method
should be called from within a critical
section.
Sourcepub fn show_frame(&mut self, frame: &MicrobitFrame)
pub fn show_frame(&mut self, frame: &MicrobitFrame)
Show a new frame
This is similar to show
but accepts a MicrobitFrame
instead.
This may be useful if performance is a concern as calling set
on the frame
can be done outside the critical section.
This may be called at any time, so long as the code calling it is not interrupting, or
interruptable by tiny_led_matrix::Display::handle_event()
. Within safe code, the borrow
checker ensures that this requirement is fulfilled. When writing unsafe code, this method
should be called from within a critical
section.
§Example
FRAME = MicrobitFrame::default();
FRAME.set(&GreyscaleImage::new(&[
[0, 7, 0, 7, 0],
[7, 0, 7, 0, 7],
[7, 0, 0, 0, 7],
[0, 7, 0, 7, 0],
[0, 0, 7, 0, 0],
]));
// only this needs to be in a critical section
display.show_frame(&FRAME);