Crates.io | cardputer |
lib.rs | cardputer |
version | 0.1.3 |
source | src |
created_at | 2024-01-22 12:18:54.279019 |
updated_at | 2024-02-05 09:19:37.712874 |
description | Utilities for M5Stack Cardputer |
homepage | |
repository | https://github.com/syurazo/cardputer |
max_upload_size | |
id | 1108717 |
size | 69,579 |
[dependencies]
cardputer = "0.1"
use cardputer::keyboard::Keyboard;
let peripherals = Peripherals::take().unwrap();
let mut keyboard = Keyboard::new(
peripherals.pins.gpio8,
peripherals.pins.gpio9,
peripherals.pins.gpio11,
peripherals.pins.gpio13,
peripherals.pins.gpio15,
peripherals.pins.gpio3,
peripherals.pins.gpio4,
peripherals.pins.gpio5,
peripherals.pins.gpio6,
peripherals.pins.gpio7,
)
.unwrap();
let mut keyboard_state = KeyboardState::default();
keyboard_state.update(&mut keyboard).unwrap();
let keys = keyboard_state.pressed_keys();
Simple example that just outputs the pressed keys to log:info
% cargo run --example key_monitor
:
I (2642) key_monitor: [Q]
I (3142) key_monitor: [W]
I (3642) key_monitor: [E]
I (4142) key_monitor: [R]
I (4642) key_monitor: [T]
I (5142) key_monitor: [Y]
I (5642) key_monitor: [Space]
: