[−][src]Struct tiny_led_matrix::Display
Manages a small LED display.
There should normally be a single Display
instance for a single piece of
display hardware.
Display is generic over a Frame
type, which holds image data suitable
for display on a particular piece of hardware.
Call initialise_control()
and initialise_timer()
before using a
Display
.
Example
Using cortex-m-rtfm
v0.5:
#[app(device = nrf51, peripherals = true)] const APP: () = { struct Resources { gpio: nrf51::GPIO, timer1: nrf51::TIMER1, display: Display<MyFrame>, } #[init] fn init(cx: init::Context) -> init::LateResources { let mut p: nrf51::Peripherals = cx.device; display::initialise_control(&mut MyDisplayControl(&mut p.GPIO)); display::initialise_timer(&mut MyDisplayTimer(&mut p.TIMER1)); init::LateResources { gpio : p.GPIO, timer1 : p.TIMER1, display : Display::new(), } } }
Methods
impl<F: Frame> Display<F>
[src]
pub fn new() -> Display<F>
[src]
Creates a Display instance, initially holding a blank image.
pub fn set_frame(&mut self, frame: &F)
[src]
Accepts a new image to be displayed.
The code that calls this method must not be interrupting, or
interruptable by, handle_event()
.
After calling this, it's safe to modify the frame again (its data is
copied into the Display
).
Example
In the style of cortex-m-rtfm
v0.5:
#[task(binds = RTC0, priority = 1, resources = [rtc0, display])] fn rtc0(mut cx: rtc0::Context) { static mut FRAME: MyFrame = MyFrame::const_default(); &cx.resources.rtc0.clear_tick_event(); FRAME.set(GreyscaleImage::blank()); cx.resources.display.lock(|display| { display.set_frame(FRAME); }); }
pub fn handle_event(
&mut self,
timer: &mut impl DisplayTimer,
control: &mut impl DisplayControl
) -> Event
[src]
&mut self,
timer: &mut impl DisplayTimer,
control: &mut impl DisplayControl
) -> Event
Updates the LEDs and timer state during a timer interrupt.
You should call this each time the timer's interrupt is signalled.
The timer
parameter must represent the same device each time you
call this method, and the same as originally passed to
initialise_timer()
.
The control
parameter must represent the same device each time you
call this method, and the same as originally passed to
initialise_control()
.
This method always calls the timer's
check_primary()
and
check_secondary()
methods.
As well as updating the LED state by calling DisplayControl
methods, it may update the timer state by calling the timer's
program_secondary()
,
enable_secondary()
, and/or
disable_secondary()
methods.
Returns a value indicating the reason for the interrupt. You can check this if you wish to perform some other action once per primary cycle.
Example
In the style of cortex-m-rtfm
v0.5:
#[task(binds = TIMER1, priority = 2, resources = [timer1, gpio, display])] fn timer1(cx: timer1::Context) { let display_event = cx.resources.display.handle_event( &mut MyDisplayControl(&mut cx.resources.timer1), &mut MyDisplayControl(&mut cx.resources.gpio), ); if display_event.is_new_row() { ... } }
Auto Trait Implementations
impl<F> Unpin for Display<F> where
F: Unpin,
F: Unpin,
impl<F> Send for Display<F> where
F: Send,
F: Send,
impl<F> Sync for Display<F> where
F: Sync,
F: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,