|
1 |
| -//! Support for the 5×5 LED display. |
| 1 | +//! Non-blocking support for the 5×5 LED display. |
2 | 2 | //!
|
3 | 3 | //! # Scope
|
4 | 4 | //!
|
5 |
| -//! Together with `tiny-led-matrix`, this module provides: |
| 5 | +//! Together with [`tiny-led-matrix`](tiny_led_matrix), this module provides: |
6 | 6 | //! - support for driving the LED display from a timer interrupt
|
7 | 7 | //! - ten levels of brightness for each LED
|
8 | 8 | //! - simple 5×5 greyscale and black-and-white image types.
|
|
13 | 13 | //!
|
14 | 14 | //! # Example
|
15 | 15 | //!
|
16 |
| -//! `examples/led_nonblocking.rs` demonstrates the main features of this |
17 |
| -//! module. |
| 16 | +//! This shows general usage but is not a working example. |
| 17 | +//! For a working exaple see `examples/led_nonblocking.rs`. |
| 18 | +//! |
| 19 | +//! ```no_run |
| 20 | +//! // in your main function |
| 21 | +//! { |
| 22 | +//! let p = pac::Peripherals::take().unwrap(); |
| 23 | +//! let mut timer = MicrobitDisplayTimer::new(p.TIMER1); |
| 24 | +//! let p0parts = P0Parts::new(p.GPIO); |
| 25 | +//! let mut pins = display_pins!(p0parts); |
| 26 | +//! display::initialise_display(&mut timer, &mut pins); |
| 27 | +//! let display = Display::new(); |
| 28 | +//! |
| 29 | +//! static mut FRAME: MicrobitFrame = MicrobitFrame::const_default(); |
| 30 | +//! |
| 31 | +//! loop { |
| 32 | +//! FRAME.set(GreyscaleImage::new(&[ |
| 33 | +//! [0, 7, 0, 7, 0], |
| 34 | +//! [7, 0, 7, 0, 7], |
| 35 | +//! [7, 0, 0, 0, 7], |
| 36 | +//! [0, 7, 0, 7, 0], |
| 37 | +//! [0, 0, 7, 0, 0], |
| 38 | +//! ])); |
| 39 | +//! display.set_frame(&FRAME); |
| 40 | +//! timer2.delay_ms(1000); |
| 41 | +//! |
| 42 | +//! FRAME.set(GreyscaleImage::new(&[ |
| 43 | +//! [0, 0, 0, 0, 0], |
| 44 | +//! [0, 0, 0, 0, 0], |
| 45 | +//! [0, 0, 0, 0, 0], |
| 46 | +//! [0, 0, 0, 0, 0], |
| 47 | +//! [0, 0, 0, 0, 0], |
| 48 | +//! ])); |
| 49 | +//! display.set_frame(&FRAME); |
| 50 | +//! timer2.delay_ms(1000); |
| 51 | +//! } |
| 52 | +//! } |
| 53 | +//! |
| 54 | +//! // in a timer interrupt |
| 55 | +//! { |
| 56 | +//! display::handle_display_event(display, timer, pins); |
| 57 | +//! } |
| 58 | +//! ``` |
18 | 59 | //!
|
19 | 60 | //! # Coordinate system
|
20 | 61 | //!
|
|
52 | 93 | //!
|
53 | 94 | //! The [`image`] submodule provides two static image types implementing
|
54 | 95 | //! `Render`:
|
55 |
| -//! - [`GreyscaleImage`], allowing all 9 levels (using one byte for each LED) |
56 |
| -//! - [`BitImage`], allowing only 'on' and 'off' (using five bytes) |
| 96 | +//! - [`GreyscaleImage`](image::GreyscaleImage), allowing all 9 levels (using one byte for each LED) |
| 97 | +//! - [`BitImage`](image::BitImage), allowing only 'on' and 'off' (using five bytes) |
57 | 98 | //!
|
58 | 99 | //! # Display
|
59 | 100 | //!
|
|
101 | 142 | //! * create a [`MicrobitDisplayTimer`] struct, passing the timer you chose to
|
102 | 143 | //! [`MicrobitDisplayTimer::new()`]
|
103 | 144 | //! * call [`initialise_display()`], passing it the `MicrobitDisplayTimer` and the
|
104 |
| -//! [`crate::led::Pins`] |
| 145 | +//! [`crate::gpio::DisplayPins`] |
105 | 146 | //! * create a [`Display`] struct (a `Display<MicrobitFrame>`).
|
106 | 147 | //!
|
107 | 148 | //! In an interrupt handler for the timer, call [`handle_display_event()`].
|
|
0 commit comments