diff --git a/src/main.rs b/src/main.rs index db861ca..e0cc252 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,6 @@ fn main() { run_lights(&mut controller, &lights).expect("Error running lights controller."); } }); - let mut x: u8 = 0; loop { thread::sleep(time::Duration::from_millis(250)); let mut lights = lock.write().unwrap(); diff --git a/src/util/lights.rs b/src/util/lights.rs index d43793d..754f3fc 100644 --- a/src/util/lights.rs +++ b/src/util/lights.rs @@ -7,7 +7,7 @@ pub fn run_lights(controller: &mut Controller, values: &[RawColor; crate::LED_SI // println!("Value: {:?}", values[0]); //thread::sleep(time::Duration::from_millis(10)); let channels: Vec = controller.channels(); - let mut strip = controller.leds_mut(channels[0]); + let strip = controller.leds_mut(channels[0]); for i in 0..strip.len() { strip[i] = values[i]; } diff --git a/src/util/pattern.rs b/src/util/pattern.rs index 231113e..3d5eb25 100644 --- a/src/util/pattern.rs +++ b/src/util/pattern.rs @@ -25,8 +25,8 @@ impl<'a> TryFrom> for Box> { struct Unit; impl<'a> Pattern<'a> for Unit { - fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {} - fn parse(args: Vec) -> Result { + fn execute(&self, _values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {} + fn parse(_args: Vec) -> Result { Ok(Unit {}) } } @@ -39,9 +39,8 @@ struct Value { impl<'a> Pattern<'a> for Value { fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) { - let mut v = *values; for i in 0..crate::LED_SIZE { - let mut color: RawColor = v[i]; + let mut color: RawColor = (*values)[i]; if self.r.is_some() { color[0] = self.r.unwrap(); } @@ -51,9 +50,8 @@ impl<'a> Pattern<'a> for Value { if self.b.is_some() { color[0] = self.b.unwrap(); } - v[i] = color; + (*values)[i] = color; } - *values = v; } fn parse(args: Vec) -> Result { let param1 = args[1].parse::(); @@ -90,6 +88,7 @@ impl<'a> Pattern<'a> for Value { b: Some(i) }) } + _ => Err("unreachable".into()) }, Err(e) => Err(Box::new(e)) }