33 lines
618 B
Rust
33 lines
618 B
Rust
|
pub mod util;
|
||
|
|
||
|
use util::lights::*;
|
||
|
use std::sync::RwLock;
|
||
|
use std::thread;
|
||
|
use candela::Pixel;
|
||
|
|
||
|
|
||
|
pub const LED_SIZE: usize = 450;
|
||
|
|
||
|
fn main() {
|
||
|
let mut p: Pixel = [0, 0, 0, 0];
|
||
|
let lock = RwLock::new([p; LED_SIZE]);
|
||
|
thread::spawn(move || loop {
|
||
|
let lights = lock.read().unwrap();
|
||
|
run_lights(&lights);
|
||
|
});
|
||
|
let mut x: u8 = 0;
|
||
|
loop {
|
||
|
if x == 255 {
|
||
|
x = 0;
|
||
|
}
|
||
|
let color = Color {
|
||
|
r: x,
|
||
|
g: x,
|
||
|
b: x
|
||
|
};
|
||
|
let mut lights = lock.write().unwrap();
|
||
|
lights[0] = color;
|
||
|
x += 1;
|
||
|
}
|
||
|
}
|