63 lines
1.6 KiB
Rust
63 lines
1.6 KiB
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
use core::panic::PanicInfo;
|
|
|
|
use esp_hal::main;
|
|
use esp_println::println;
|
|
|
|
#[panic_handler]
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
println!("{info}");
|
|
esp_hal::system::software_reset()
|
|
}
|
|
|
|
esp_bootloader_esp_idf::esp_app_desc!();
|
|
|
|
#[main]
|
|
fn entrypoint() -> ! {
|
|
_main();
|
|
println!("main exited, entering infinite loop");
|
|
loop {}
|
|
}
|
|
|
|
#[allow(static_mut_refs)]
|
|
fn _main() {
|
|
let peripherals = esp_hal::init(esp_hal::Config::default());
|
|
|
|
let mut keyboard = cardputer_bsc_nostd::keyboard::Keyboard::new(
|
|
peripherals.GPIO8,
|
|
peripherals.GPIO9,
|
|
peripherals.GPIO11,
|
|
peripherals.GPIO13,
|
|
peripherals.GPIO15,
|
|
peripherals.GPIO3,
|
|
peripherals.GPIO4,
|
|
peripherals.GPIO5,
|
|
peripherals.GPIO6,
|
|
peripherals.GPIO7,
|
|
);
|
|
|
|
loop {
|
|
keyboard.scan();
|
|
let key_set = keyboard.pressed_keys();
|
|
if !key_set.is_none() {
|
|
for &(key_name, key) in cardputer_bsc_nostd::keyboard::Key::flags() {
|
|
if key_set.contains(key) {
|
|
println!("Pressed {key_name}");
|
|
}
|
|
}
|
|
}
|
|
keyboard.clear_pressed_keys();
|
|
let key_set = keyboard.released_keys();
|
|
if !key_set.is_none() {
|
|
for &(key_name, key) in cardputer_bsc_nostd::keyboard::Key::flags() {
|
|
if key_set.contains(key) {
|
|
println!("Released {key_name}");
|
|
}
|
|
}
|
|
}
|
|
keyboard.clear_released_keys();
|
|
esp_hal::delay::Delay::new().delay_millis(10);
|
|
}
|
|
}
|