1extern crate unicornd_client;
17
18use std::thread::sleep;
19use std::time::Duration;
20use unicornd_client::{UnicorndClient, Pos, Pixel};
21
22fn gen_solid(pixel: Pixel) -> [Pixel; 64] {
23 let mut pixels = [Pixel{r:0, g:0, b:0}; 64];
24 for x in 0..64 {
25 pixels[x] = pixel.clone()
26 }
27 pixels
28}
29
30fn main() {
31 let mut u = UnicorndClient::new("/var/run/unicornd.socket".to_string()).unwrap();
32 u.set_brightness(128).unwrap();
33
34 let rgb = [
35 Pixel{r: 255, g: 0, b: 0},
36 Pixel{r: 0, g: 255, b: 0},
37 Pixel{r: 0, g: 0, b: 255}
38 ];
39
40 loop {
41 for p in rgb.iter() {
42 u.set_all_pixels(gen_solid(*p)).unwrap();
43 for x in 3..5 {
44 for y in 3..5 {
45 u.set_pixel(Pos{x, y}, Pixel{r: 255, g: 255, b: 255}).unwrap();
46 }
47 }
48
49 u.show().unwrap();
50 sleep(Duration::new(1, 0));
51 }
52 }
53}