Skip to content

Commit aae9798

Browse files
committed
Restore timer_subscribe and delete hello example
1 parent ebadc3e commit aae9798

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

examples/hello.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/timer_subscribe.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#![no_std]
2+
3+
use core::fmt::Write;
4+
use futures::future;
5+
use libtock::result::TockResult;
6+
use libtock::timer::Duration;
7+
use libtock::Drivers;
8+
9+
#[libtock::main]
10+
async fn main() -> TockResult<()> {
11+
let Drivers {
12+
console_driver,
13+
mut timer_context,
14+
..
15+
} = libtock::retrieve_drivers()?;
16+
let mut console = console_driver.create_console();
17+
let mut with_callback = timer_context.with_callback(|_, _| {
18+
writeln!(
19+
console,
20+
"This line is printed 2 seconds after the start of the program.",
21+
)
22+
.unwrap();
23+
});
24+
25+
let mut timer = with_callback.init()?;
26+
timer.set_alarm(Duration::from_ms(2000))?;
27+
28+
future::pending().await
29+
}

0 commit comments

Comments
 (0)