1 个不稳定版本
0.1.0 | 2021年11月7日 |
---|
#766 in Unix API
6KB
79 代码行数(不包括注释)
无干扰 GPIO
一切都在幕后解开,以保持您代码的珍贵美感。它不仅仅是简单的 Rust 包,更是一种生活哲学。
读取
use unbothered_gpio::{UnbotheredGpioPin, UnbotheredGpioPinReader};
// Open pin 17 for reading
let mut reader = UnbotheredGpioPinReader::new(17);
let state: bool = reader.read();
println!("Pin 17 state : {}", state);
写入
use unbothered_gpio::{UnbotheredGpioPin, UnbotheredGpioPinWriter};
// Open pin 17 for writing
let mut writer = UnbotheredGpioPinWriter::new(17);
// Set gpio pin 17 state to true
writer.write(true);
监听
use unbothered_gpio::UnbotheredGpioPinListener;
UnbotheredGpioPinListener::new(17, |state: bool| {
println!("New state for pin 17 : {}", state)
}).keep_alive();
依赖项
~0.6–1MB
~14K SLoC