This commit is contained in:
jane 2021-12-28 21:45:19 -05:00
parent 712140fc8d
commit 10e71b6ccc

View file

@ -14,7 +14,7 @@ pub const LOOP_WAIT: u64 = 250;
fn main() { fn main() {
let p: RawColor = [0, 0, 0, 0]; let p: RawColor = [0, 0, 0, 0];
let lock = Arc::new(RwLock::new([p; LED_SIZE])); let lock = Arc::new(RwLock::new([p; LED_SIZE]));
let mut pattern: Arc<Mutex<Vec<Box<dyn Pattern>>>> = Arc::new(Mutex::new(Vec::new())); let pattern: Arc<Mutex<Vec<Box<dyn Pattern>>>> = Arc::new(Mutex::new(Vec::new()));
let read = Arc::clone(&lock); let read = Arc::clone(&lock);
//light management //light management
thread::spawn(move || { thread::spawn(move || {
@ -45,8 +45,8 @@ fn main() {
thread::sleep(time::Duration::from_millis(LOOP_WAIT)); thread::sleep(time::Duration::from_millis(LOOP_WAIT));
let c_lock = Arc::clone(&lock); let c_lock = Arc::clone(&lock);
let mut lights = c_lock.write().unwrap(); let mut lights = c_lock.write().unwrap();
let mut data = pattern.lock().unwrap(); let data = pattern.lock().unwrap();
for p in *data { for p in &*data {
//let c_lock = Arc::clone(&lock); //let c_lock = Arc::clone(&lock);
//let mut lights = c_lock.write().unwrap(); //let mut lights = c_lock.write().unwrap();
p.execute(&mut lights, ticks); p.execute(&mut lights, ticks);