2020-06-22 13:23:59 +00:00
|
|
|
#![deny(unused_must_use)]
|
|
|
|
#![no_main]
|
|
|
|
#![no_std]
|
|
|
|
|
|
|
|
use core::str;
|
|
|
|
|
|
|
|
use cortex_m_rt::entry;
|
2021-06-04 11:41:31 +00:00
|
|
|
use heapless::Vec;
|
2021-04-08 09:27:00 +00:00
|
|
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
|
|
|
use apps as _;
|
2020-06-22 13:23:59 +00:00
|
|
|
|
|
|
|
#[entry]
|
|
|
|
fn main() -> ! {
|
|
|
|
dk::init().unwrap();
|
|
|
|
|
|
|
|
// a buffer with capacity for 2 bytes
|
2021-06-04 11:41:31 +00:00
|
|
|
let mut buffer = Vec::<u8, 2>::new();
|
|
|
|
// content type ^^ ^ capacity
|
2020-06-22 13:23:59 +00:00
|
|
|
|
|
|
|
// do some insertions
|
|
|
|
buffer.push(b'H').expect("buffer full");
|
|
|
|
buffer.push(b'i').expect("buffer full");
|
|
|
|
|
|
|
|
// look into the contents so far
|
2021-06-04 11:41:31 +00:00
|
|
|
defmt::info!("{:?}", buffer);
|
2021-04-08 09:27:00 +00:00
|
|
|
|
2020-06-22 13:23:59 +00:00
|
|
|
// or more readable
|
2021-04-08 09:27:00 +00:00
|
|
|
// NOTE utf-8 conversion works as long as you only push bytes in the ASCII range (0..=127)
|
|
|
|
defmt::info!(
|
2020-06-22 13:23:59 +00:00
|
|
|
"{}",
|
|
|
|
str::from_utf8(&buffer).expect("content was not UTF-8")
|
|
|
|
);
|
|
|
|
|
|
|
|
dk::exit()
|
|
|
|
}
|