t
This commit is contained in:
parent
3f5e8a4804
commit
c781a73d51
3 changed files with 6 additions and 8 deletions
|
@ -30,7 +30,6 @@ fn main() {
|
||||||
run_lights(&mut controller, &lights).expect("Error running lights controller.");
|
run_lights(&mut controller, &lights).expect("Error running lights controller.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let mut x: u8 = 0;
|
|
||||||
loop {
|
loop {
|
||||||
thread::sleep(time::Duration::from_millis(250));
|
thread::sleep(time::Duration::from_millis(250));
|
||||||
let mut lights = lock.write().unwrap();
|
let mut lights = lock.write().unwrap();
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub fn run_lights(controller: &mut Controller, values: &[RawColor; crate::LED_SI
|
||||||
// println!("Value: {:?}", values[0]);
|
// println!("Value: {:?}", values[0]);
|
||||||
//thread::sleep(time::Duration::from_millis(10));
|
//thread::sleep(time::Duration::from_millis(10));
|
||||||
let channels: Vec<usize> = controller.channels();
|
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() {
|
for i in 0..strip.len() {
|
||||||
strip[i] = values[i];
|
strip[i] = values[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ impl<'a> TryFrom<Vec<String>> for Box<dyn Pattern<'a>> {
|
||||||
|
|
||||||
struct Unit;
|
struct Unit;
|
||||||
impl<'a> Pattern<'a> for Unit {
|
impl<'a> Pattern<'a> for Unit {
|
||||||
fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {}
|
fn execute(&self, _values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {}
|
||||||
fn parse(args: Vec<String>) -> Result<Self, ParseError> {
|
fn parse(_args: Vec<String>) -> Result<Self, ParseError> {
|
||||||
Ok(Unit {})
|
Ok(Unit {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,8 @@ struct Value {
|
||||||
|
|
||||||
impl<'a> Pattern<'a> for Value {
|
impl<'a> Pattern<'a> for Value {
|
||||||
fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {
|
fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {
|
||||||
let mut v = *values;
|
|
||||||
for i in 0..crate::LED_SIZE {
|
for i in 0..crate::LED_SIZE {
|
||||||
let mut color: RawColor = v[i];
|
let mut color: RawColor = (*values)[i];
|
||||||
if self.r.is_some() {
|
if self.r.is_some() {
|
||||||
color[0] = self.r.unwrap();
|
color[0] = self.r.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -51,9 +50,8 @@ impl<'a> Pattern<'a> for Value {
|
||||||
if self.b.is_some() {
|
if self.b.is_some() {
|
||||||
color[0] = self.b.unwrap();
|
color[0] = self.b.unwrap();
|
||||||
}
|
}
|
||||||
v[i] = color;
|
(*values)[i] = color;
|
||||||
}
|
}
|
||||||
*values = v;
|
|
||||||
}
|
}
|
||||||
fn parse(args: Vec<String>) -> Result<Self, ParseError> {
|
fn parse(args: Vec<String>) -> Result<Self, ParseError> {
|
||||||
let param1 = args[1].parse::<u8>();
|
let param1 = args[1].parse::<u8>();
|
||||||
|
@ -90,6 +88,7 @@ impl<'a> Pattern<'a> for Value {
|
||||||
b: Some(i)
|
b: Some(i)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
_ => Err("unreachable".into())
|
||||||
},
|
},
|
||||||
Err(e) => Err(Box::new(e))
|
Err(e) => Err(Box::new(e))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue