Module microbit::led[][src]

Blocking support for the 5x5 LED display.

This module provides a simple blocking interface to the on board 5x5 LED display. If you need a more sophisticated or non-blocking interface use the display module.

Example

use microbit::{
    display_pins,
    hal::{gpio::p0::Parts, prelude::*, Timer},
};
// take the peripherals
let p = microbit::pac::Peripherals::take().unwrap();
// make a timer
let mut timer = Timer::new(p.TIMER0);
// split off the p0::Parts
let p0parts = Parts::new(p.GPIO);
// create the DisplayPins struct
let pins = display_pins!(p0parts);
// create the Display
let mut leds = led::Display::new(pins);
// and light up some LEDs
let heart = [
    [0, 1, 0, 1, 0],
    [1, 0, 1, 0, 1],
    [1, 0, 0, 0, 1],
    [0, 1, 0, 1, 0],
    [0, 0, 1, 0, 0],
];
loop {
    leds.display(&mut timer, heart, 1000);
    leds.clear();
    timer.delay_ms(250);
}

See a working example at examples/led_blocking.rs

Structs

Display

Blocking interface to the on board LED display