3个版本
0.2.2 | 2020年6月23日 |
---|---|
0.2.1 | 2020年6月20日 |
0.2.0 | 2020年6月20日 |
0.1.1 |
|
0.1.0 |
|
#1808 in 硬件支持
1MB
179 行
包含 (WOFF字体, 190KB) docs/FiraSans-Medium.woff, (WOFF字体, 185KB) docs/FiraSans-Regular.woff, (WOFF字体, 94KB) docs/SourceSerifPro-Bold.ttf.woff, (WOFF字体, 89KB) docs/SourceSerifPro-Regular.ttf.woff, (WOFF字体, 56KB) docs/SourceCodePro-Regular.woff, (WOFF字体, 56KB) docs/SourceCodePro-Semibold.woff 等1个文件.
pca9685_lib
Raspberry Pi的PCA9685驱动程序 文档
此库使用tokio允许在程序运行(当然是一段时间)时运行其他任务,500us,但鉴于Rustaceans正在编写系统级代码,我认为这可能会提高一点性能。
快速入门
use rppal::i2c::{I2c};
use pca9865_lib::PCA9685;
use tokio::time::delay_for;
use std::time::Duration;
#[tokio::main]
async fn main() {
//Create a new device with address 0x40. Note mutability.
let mut device = PCA9685::new(0x40, I2c::new().unwrap()).unwrap();
//Set the refresh rate to 50Hz, (re)start the chip when complete
if let Err(_e) = device.set_prescale_fr(50, true).await {
panic!();
}
//Servo fun time
loop {
//The chip divides the refresh rate into 4096 blocks
//The first tuple is which block to turn on the pulse
//The second tuple is which block to turn the pulse off (in this case ~two milliseconds after);
if let Err(_e) = device.set_channel(0, (0, 0), (0x01, 0x97)) {
panic!();
}
delay_for(Duration::from_secs(2)).await;
//Set Mid
if let Err(_e) = device.set_channel(0, (0, 0), (0x01, 0x33)) {
panic!();
}
delay_for(Duration::from_secs(2)).await;
//Set Min
if let Err(_e) = device.set_channel(0, (0, 0), (0x00, 0xCD)) {
panic!();
}
delay_for(Duration::from_secs(2)).await;
//Set Mid
if let Err(_e) = device.set_channel(0, (0, 0), (0x01, 0x33)) {
panic!();
}
delay_for(Duration::from_secs(2)).await;
}
}
依赖关系
~4MB
~58K SLoC