[][src]Struct tiny_led_matrix::Display

pub struct Display<F: Frame> { /* fields omitted */ }

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.4.1:

This example is not tested
#[app(device = nrf51)]
const APP: () = {
    static mut GPIO: nrf51::GPIO = ();
    static mut TIMER1: nrf51::TIMER1 = ();
    static mut DISPLAY: Display<MyFrame> = ();

    #[init]
    fn init() -> init::LateResources {
        let mut p: nrf51::Peripherals = 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.4:

This example is not tested
#[interrupt(priority = 1, resources = [RTC0, DISPLAY])]
fn RTC0() {
    static mut FRAME: MyFrame = MyFrame::const_default();
    let event_reg = &resources.RTC0.events_tick;
    event_reg.write(|w| unsafe {w.bits(0)} );
    FRAME.set(GreyscaleImage::blank());
    resources.DISPLAY.lock(|display| {
        display.set_frame(FRAME);
    });
}

pub fn handle_event(
    &mut self,
    timer: &mut impl DisplayTimer,
    control: &mut impl DisplayControl
) -> Event
[src]

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.4:

This example is not tested
#[interrupt(priority = 2, resources = [TIMER1, GPIO, DISPLAY])]
fn TIMER1() {
    let display_event = resources.DISPLAY.handle_event(
        &mut MyDisplayControl(&mut resources.TIMER1),
        &mut MyDisplayControl(&mut resources.GPIO),
    );
    if display_event.is_new_row() {
        ...
    }
}

Auto Trait Implementations

impl<F> Send for Display<F> where
    F: Send

impl<F> Sync for Display<F> where
    F: Sync

Blanket Implementations

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> From for T[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]