Open
![@ghost](https://github.com/ghost.png?size=80)
Description
I have a micro:bit v2.21 and using Linux Kubuntu, i created a new rust project using cargo and modified the files like this:
Cargo.toml
[package]
name = "test_0"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
microbit-v2 = { version = "0.13.0", optional = true }
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt-rtt = "0.4.0"
defmt = "0.3.2"
[features]
v2 = ["microbit-v2"]
default = ["defmt-default"]
# do NOT modify these features
defmt-default = []
defmt-trace = []
defmt-debug = []
defmt-info = []
defmt-warn = []
defmt-error = []
main.rs
#![no_std]
#![no_main]
use defmt_rtt as _;
use panic_halt as _;
use cortex_m_rt::entry;
use microbit::{
board::Board,
display::blocking::Display,
hal::{prelude::*, Timer},
};
#[entry]
fn main() -> ! {
if let Some(board) = Board::take() {
let mut timer = Timer::new(board.TIMER0);
let mut display = Display::new(board.display_pins);
#[allow(non_snake_case)]
let letter_I = [
[0, 1, 1, 1, 0],
[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0],
[0, 1, 1, 1, 0],
];
let heart = [
[0, 1, 0, 1, 0],
[1, 0, 1, 0, 1],
[1, 0, 0, 0, 1],
[0, 1, 0, 1, 0],
[0, 0, 1, 0, 0],
];
#[allow(non_snake_case)]
let letter_R = [
[0, 1, 1, 0, 0],
[0, 1, 0, 1, 0],
[0, 1, 1, 0, 0],
[0, 1, 0, 1, 0],
[0, 1, 0, 1, 0],
];
#[allow(non_snake_case)]
let letter_u = [
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 1, 0, 1, 0],
[0, 1, 0, 1, 0],
[0, 1, 1, 1, 0],
];
#[allow(non_snake_case)]
let letter_s = [
[0, 0, 0, 0, 0],
[0, 0, 1, 1, 0],
[0, 1, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 1, 1, 1, 0],
];
#[allow(non_snake_case)]
let letter_t = [
[0, 0, 1, 0, 0],
[0, 1, 1, 1, 0],
[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0],
];
loop {
display.show(&mut timer, letter_I, 1000);
display.show(&mut timer, heart, 1000);
display.show(&mut timer, letter_R, 1000);
display.show(&mut timer, letter_u, 1000);
display.show(&mut timer, letter_s, 1000);
display.show(&mut timer, letter_t, 1000);
display.clear();
timer.delay_ms(250_u32);
}
}
panic!("End");
}
When i run cargo embed --target thumbv7em-none-eabihf
, i get that error:
error: could not compile `test_0` due to 3 previous errors
error[E0433]: failed to resolve: use of undeclared crate or module `microbit`
--> src/main.rs:9:5
|
9 | use microbit::{
| ^^^^^^^^ use of undeclared crate or module `microbit`
error[E0432]: unresolved imports `microbit::board::Board`, `microbit::display::blocking::Display`, `microbit::hal::Timer`
--> src/main.rs:10:5
|
10 | board::Board,
| ^^^^^^^^^^^^
11 | display::blocking::Display,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
12 | hal::{prelude::*, Timer},
| ^^^^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
Error Failed to run cargo build: exit code = Some(101).
Metadata
Assignees
Labels
No labels