This commit is contained in:
jane 2021-12-26 21:42:44 -05:00
parent 3f5e8a4804
commit c781a73d51
3 changed files with 6 additions and 8 deletions

View file

@ -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();

View file

@ -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<usize> = 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];
}

View file

@ -25,8 +25,8 @@ impl<'a> TryFrom<Vec<String>> for Box<dyn Pattern<'a>> {
struct Unit;
impl<'a> Pattern<'a> for Unit {
fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {}
fn parse(args: Vec<String>) -> Result<Self, ParseError> {
fn execute(&self, _values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {}
fn parse(_args: Vec<String>) -> Result<Self, ParseError> {
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<String>) -> Result<Self, ParseError> {
let param1 = args[1].parse::<u8>();
@ -90,6 +88,7 @@ impl<'a> Pattern<'a> for Value {
b: Some(i)
})
}
_ => Err("unreachable".into())
},
Err(e) => Err(Box::new(e))
}