diff --git a/src/main.rs b/src/main.rs index 98b1517..59d5147 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,7 @@ fn main() { }); //pattern management + let mut ticks = 0; loop { thread::sleep(time::Duration::from_millis(LOOP_WAIT)); let c_lock = Arc::clone(&lock); @@ -48,7 +49,8 @@ fn main() { for p in *data { //let c_lock = Arc::clone(&lock); //let mut lights = c_lock.write().unwrap(); - p.execute(&mut lights); + p.execute(&mut lights, ticks); } + ticks++; } } diff --git a/src/util/lights.rs b/src/util/lights.rs index a7df178..754f3fc 100644 --- a/src/util/lights.rs +++ b/src/util/lights.rs @@ -4,7 +4,7 @@ use rs_ws281x::WS2811Error; // use std::{thread, time}; pub fn run_lights(controller: &mut Controller, values: &[RawColor; crate::LED_SIZE]) -> Result<(), WS2811Error> { - println!("Value: {:?}", values[0]); + // println!("Value: {:?}", values[0]); //thread::sleep(time::Duration::from_millis(10)); let channels: Vec = controller.channels(); let strip = controller.leds_mut(channels[0]); diff --git a/src/util/pattern.rs b/src/util/pattern.rs index 561d7f0..d051d4c 100644 --- a/src/util/pattern.rs +++ b/src/util/pattern.rs @@ -8,7 +8,7 @@ use std::sync::RwLockWriteGuard; pub type ParseError = Box; pub trait Pattern: Send { - fn execute(&self, values: &mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>); + fn execute(&self, values: &mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>, ticks: u64); fn parse(args: Vec) -> Result where Self: Sized; } @@ -25,7 +25,7 @@ impl TryFrom> for Box { struct Unit; impl Pattern for Unit { - fn execute(&self, _values: &mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {} + fn execute(&self, _values: &mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>, ticks: u64) {} fn parse(_args: Vec) -> Result { Ok(Unit {}) } @@ -38,7 +38,7 @@ struct Value { } impl Pattern for Value { - fn execute(&self, values: &mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) { + fn execute(&self, values: &mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>, ticks: u64) { for i in 0..crate::LED_SIZE { let mut color: RawColor = (*values)[i]; if self.r.is_some() {