Crates.io | ddp-connection |
lib.rs | ddp-connection |
version | 0.1.0 |
source | src |
created_at | 2023-11-11 22:23:41.841809 |
updated_at | 2023-11-11 22:23:41.841809 |
description | Distributed Display Protocol (DDP) in Rust. This is a fork of ddp-rs by Coral https://github.com/coral/ddp-rs |
homepage | |
repository | https://github.com/paulwrath1223/WLED-Streamer |
max_upload_size | |
id | 1032467 |
size | 49,657 |
This package allows you to write pixel data to a LED strip over Distributed Display Protocol (DDP) by 3waylabs.
You can use this to stream pixel data to WLED or any other DDP capable reciever.
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(())
}
or try it by running cargo run --example dev
yes. but it works for WLED, and thats all I can test or care about.
I wanted to stream color values to a WLED controller, and DDP has the highest framerate of any protocol I could find
m8 just open a PR with some gucchimucchi code and I'll review it.