leds/src/main.rs

33 lines
618 B
Rust
Raw Normal View History

2021-12-23 19:34:26 +00:00
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;
}
}