Skip to content

Commit ef9cde7

Browse files
committed
Moved the 05-led-roulette the-challenge example to project examples
1 parent 11f9aa1 commit ef9cde7

File tree

2 files changed

+46
-44
lines changed

2 files changed

+46
-44
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#![deny(unsafe_code)]
2+
#![no_main]
3+
#![no_std]
4+
5+
use cortex_m_rt::entry;
6+
use rtt_target::rtt_init_print;
7+
use panic_rtt_target as _;
8+
use embedded_hal::delay::DelayNs;
9+
use microbit::{
10+
board::Board,
11+
display::blocking::Display,
12+
hal::Timer,
13+
};
14+
15+
#[entry]
16+
fn main() -> ! {
17+
rtt_init_print!();
18+
19+
let board = Board::take().unwrap();
20+
21+
let mut timer = Timer::new(board.TIMER0);
22+
let mut display = Display::new(board.display_pins);
23+
24+
// Setup the display delay so the math works as expected later.
25+
display.set_delay_ms(1);
26+
27+
let light_it_all = [
28+
[1, 1, 1, 1, 1],
29+
[1, 1, 1, 1, 1],
30+
[1, 1, 1, 1, 1],
31+
[1, 1, 1, 1, 1],
32+
[1, 1, 1, 1, 1],
33+
];
34+
35+
loop {
36+
// Show light_it_all for 1000ms
37+
display.show(&mut timer, light_it_all, 1_000);
38+
39+
// clear the display again
40+
display.clear();
41+
42+
timer.delay_ms(1000_u32);
43+
}
44+
}
45+

microbit/src/05-led-roulette/the-challenge.md

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,7 @@ Since working with the LED pins separately is quite annoying
1818
you can use the display API provided by the BSP. It works like this:
1919

2020
```rust
21-
#![deny(unsafe_code)]
22-
#![no_main]
23-
#![no_std]
24-
25-
use cortex_m_rt::entry;
26-
use rtt_target::rtt_init_print;
27-
use panic_rtt_target as _;
28-
use embedded-hal::delay::DelayNS;
29-
use microbit::{
30-
board::Board,
31-
display::blocking::Display,
32-
hal::Timer,
33-
};
34-
35-
#[entry]
36-
fn main() -> ! {
37-
rtt_init_print!();
38-
39-
let board = Board::take().unwrap();
40-
41-
let mut timer = Timer::new(board.TIMER0);
42-
let mut display = Display::new(board.display_pins);
43-
44-
// Setup the display delay so the math works as expected later.
45-
display.set_delay_ms(1);
46-
47-
let light_it_all = [
48-
[1, 1, 1, 1, 1],
49-
[1, 1, 1, 1, 1],
50-
[1, 1, 1, 1, 1],
51-
[1, 1, 1, 1, 1],
52-
[1, 1, 1, 1, 1],
53-
];
54-
55-
loop {
56-
// Show light_it_all for 1000ms
57-
display.show(&mut timer, light_it_all, 1_000);
58-
59-
// clear the display again
60-
display.clear();
61-
62-
timer.delay_ms(1000_u32);
63-
}
64-
}
21+
{{#include examples/the-challenge.rs}}
6522
```
6623

6724
Equipped with this API your task basically boils down to just having

0 commit comments

Comments
 (0)