Commit 6f237169 authored by Andre Julius's avatar Andre Julius 👀
Browse files

Add fill_rgb() function.

parent 9eea8248
use std::net::UdpSocket;
fn fill_rgb(sock: &UdpSocket, address: &String, len: usize, r: u8, g: u8, b: u8) -> usize {
let mut bytes = vec![0 as u8; len*3];
for i in 0..len {
bytes[(i*3) + 0] = g;
bytes[(i*3) + 1] = r;
bytes[(i*3) + 2] = b;
}
sock.send_to(&bytes, &address).expect("error sending data")
}
fn main() {
println!("Hello, world!");
let socket = UdpSocket::bind("0.0.0.0:10400").expect(
"Could not connect");
let bytes_sent = fill_rgb(&socket, &"nomled:1234".to_string(), 20, 200, 100, 20);
println!("Total bytes sent: {:?}", bytes_sent);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment