light/
light.rs

1extern crate busylight;
2
3use busylight::{BusyLight};
4use std::{thread, time};
5
6fn main() {
7
8    let mut bl = BusyLight::new();
9    bl.keepalive_enable();
10
11    bl.light("red");
12    println!("just set red");
13
14    let one_seconds = time::Duration::from_secs(1);
15    let thirty_seconds = time::Duration::from_secs(35);
16
17    //sleep 1 sec
18    thread::sleep(one_seconds);
19    bl.light("blue");
20    println!("just set blue");
21
22    //sleep 1 sec
23    thread::sleep(one_seconds);
24    bl.light("rgb(0, 255, 0)");
25    println!("just set rgb");
26
27    //sleep 1 sec
28    thread::sleep(one_seconds);
29    bl.light("#0000ff");
30    println!("just set hex");
31
32    //sleep 30sec - Light should not go off before changing again, as keepalive should work
33    thread::sleep(thirty_seconds);
34    println!("stopped sleeping, setting red");
35    bl.light("red");
36
37    thread::sleep(one_seconds);
38    bl.stop_light();
39
40    println!("stopped light");
41    thread::sleep(one_seconds);
42}