pub struct Elc { /* private fields */ }Expand description
Represent the rgb controller
If the device has a kernel driver it will be detached.
It will be reattached when the drop occurs.
Implementations§
Source§impl Elc
impl Elc
Sourcepub fn new() -> Elc
pub fn new() -> Elc
Create a new rgb controller handler.
Examples found in repository?
More examples
examples/save.rs (line 37)
13fn main() {
14 let animation = std::env::var("ANIMATION").unwrap_or("SPECIAL".to_owned());
15 let animation_id: u16 = std::env::var("ANIMATION_ID")
16 .unwrap_or("1".to_owned())
17 .parse()
18 .unwrap_or(1);
19 let red: u8 = std::env::var("RED")
20 .unwrap_or("255".to_owned())
21 .parse()
22 .unwrap_or(255);
23 let green: u8 = std::env::var("GREEN")
24 .unwrap_or("0".to_owned())
25 .parse()
26 .unwrap_or(0);
27 let blue: u8 = std::env::var("BLUE")
28 .unwrap_or("0".to_owned())
29 .parse()
30 .unwrap_or(0);
31 let color = Rgb::new(red, green, blue);
32 let duration_millis: u64 = std::env::var("DURATION")
33 .unwrap_or("1000".to_owned())
34 .parse()
35 .unwrap_or(1000);
36 let duration = Duration::from_millis(duration_millis);
37 let mut elc = Elc::new();
38 let commands = match animation.as_str() {
39 "SPECIAL" => special(animation_id),
40 "BREATHE" => breathe(color, animation_id),
41 "SPECTRUM" => spectrum(duration, animation_id),
42 "WAVE" => wave(color, animation_id),
43 "RAINBOW" => rainbow(duration, animation_id),
44 "BACK_AND_FORTH" => back_and_forth(color, animation_id),
45 _ => special(animation_id),
46 };
47 save(&mut elc, commands).unwrap();
48}Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Elc
impl RefUnwindSafe for Elc
impl Send for Elc
impl Sync for Elc
impl Unpin for Elc
impl UnsafeUnpin for Elc
impl UnwindSafe for Elc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more