2021-12-23 19:34:26 +00:00
|
|
|
pub mod util;
|
|
|
|
|
|
|
|
use util::lights::*;
|
2021-12-24 16:39:02 +00:00
|
|
|
use std::sync::{Arc, RwLock};
|
2021-12-23 19:34:26 +00:00
|
|
|
use std::thread;
|
|
|
|
use candela::Pixel;
|
|
|
|
|
|
|
|
|
|
|
|
pub const LED_SIZE: usize = 450;
|
|
|
|
|
|
|
|
fn main() {
|
2021-12-24 16:39:02 +00:00
|
|
|
let p: Pixel = [0, 0, 0, 0];
|
|
|
|
let lock = Arc::new(RwLock::new([p; LED_SIZE]));
|
|
|
|
let lock_c = Arc::clone(&lock);
|
2021-12-23 19:34:26 +00:00
|
|
|
thread::spawn(move || loop {
|
2021-12-24 16:39:02 +00:00
|
|
|
let lights = lock_c.read().unwrap();
|
2021-12-23 19:34:26 +00:00
|
|
|
run_lights(&lights);
|
|
|
|
});
|
|
|
|
let mut x: u8 = 0;
|
|
|
|
loop {
|
|
|
|
if x == 255 {
|
|
|
|
x = 0;
|
|
|
|
}
|
2021-12-24 16:39:02 +00:00
|
|
|
let color: Pixel = [x, x, x, 255];
|
2021-12-23 19:34:26 +00:00
|
|
|
let mut lights = lock.write().unwrap();
|
|
|
|
lights[0] = color;
|
|
|
|
x += 1;
|
|
|
|
}
|
|
|
|
}
|