1个不稳定版本
0.1.0 | 2023年11月11日 |
---|
#340 in 多媒体
37KB
872 代码行
由Coral的出色项目此项目的分支。
此包允许您通过3waylabs的分布式显示协议(DDP)将像素数据写入LED灯带。
您可以用它将像素数据流式传输到WLED或其他任何DDP兼容的接收器。
示例
use anyhow::Result;
use ddp_connection::connection;
use ddp_connection::protocol;
fn main() -> Result<()> {
let mut conn = connection::DDPConnection::try_new
(
"192.168.1.40:4048", // The IP address of the device followed by :4048
protocol::PixelConfig::default(), // Default is RGB, 8 bits ber channel
protocol::ID::Default,
std::net::UdpSocket::bind("0.0.0.0:6969")
.unwrap() // can be any unused port on 0.0.0.0, but protocol recommends 4048
)?;
// loop sets some colors for the first 6 pixels to see if it works
for i in 0u8..100u8{
let high = 10u8.overflowing_mul(i).0;
// loop through some colors
let temp: usize = conn.write(&vec![
high/*red value*/, 0/*green value*/, 0/*blue value*/,
high/*red value*/, 0/*green value*/, 0/*blue value*/,
0/*red value*/, high/*green value*/, 0/*blue value*/,
0/*red value*/, high/*green value*/, 0/*blue value*/,
0/*red value*/, 0/*green value*/, high/*blue value*/,
0/*red value*/, 0/*green value*/, high/*blue value*/
])?;
std::thread::sleep(std::time::Duration::from_millis(10));
// this crate is non blocking, so with out the sleep, it will send them all instantly
println!("sent {temp} packets");
}
Ok(())
}
或者尝试运行cargo run --example dev
它是垃圾吗?
是的。但它对WLED有效,这是我唯一测试和关心的。
为什么?
我想将颜色值流式传输到WLED控制器,DDP是所有我能找到的协议中帧率最高的。
贡献
m8只需提交一个包含一些gucchimucchi代码的PR,我会审阅它。
依赖关系
~1.7–8MB
~56K SLoC