[−][src]Struct rmicrobit::display::MicrobitDisplay
The micro:bit's display, and one timer to drive it.
Methods
impl<T: As16BitTimer> MicrobitDisplay<T>
[src]
pub fn new(port: DisplayPort, timer: T) -> MicrobitDisplay<T>
[src]
Takes ownership of the display port and one TIMER, and returns a
MicrobitDisplay
.
The timer
parameter can be any of the three nrf51::TIMER
n
peripherals.
Initialises the micro:bit hardware to use the display driver.
The display is initially clear.
Example
use rmicrobit::prelude::*; use rmicrobit::gpio::PinsByKind; use rmicrobit::display::{DisplayPort, MicrobitDisplay}; let p: nrf51::Peripherals = _; let PinsByKind {display_pins, ..} = p.GPIO.split_by_kind(); let display_port = DisplayPort::new(display_pins); let mut display = MicrobitDisplay::new(display_port, p.TIMER1);
pub fn free(self) -> (DisplayPort, T)
[src]
Gives the underlying devices back.
Returns the DisplayPort
and nrf51::TIMER
n instance.
Turns all the LEDs off and stops the TIMER.
pub fn handle_event(&mut self) -> DisplayEvent
[src]
Updates the LEDs and timer state during a timer interrupt.
Call this in an interrupt handler for the MicrobitDisplay
's timer.
See Display::handle_event()
for details.
Returns a DisplayEvent
indicating the reason for the interrupt.
You can check this if you wish to perform some other action once every
6ms.
Example
In the style of cortex-m-rtfm
v0.5:
#[task(binds = TIMER1, priority = 2, resources = [display])] fn timer1(cx: timer1::Context) { let display_event = cx.resources.display.handle_event(); if display_event.is_new_row() { ... } }
pub fn set_frame(&mut self, frame: &MicrobitFrame)
[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).
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: MicrobitFrame = MicrobitFrame::const_default(); &cx.resources.rtc0.clear_tick_event(); FRAME.set(GreyscaleImage::blank()); cx.resources.display.lock(|display| { display.set_frame(FRAME); }); }
Auto Trait Implementations
impl<T> Unpin for MicrobitDisplay<T> where
T: Unpin,
T: Unpin,
impl<T> Send for MicrobitDisplay<T> where
T: Send,
T: Send,
impl<T> Sync for MicrobitDisplay<T> where
T: Sync,
T: 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,
impl<T> Same<T> for T
type Output = T
Should always be Self