leds/src/util/lights.rs

18 lines
565 B
Rust
Raw Normal View History

2021-12-24 18:29:57 +00:00
use rs_ws281x::RawColor;
2021-12-24 23:54:53 +00:00
use rs_ws281x::Controller;
use rs_ws281x::WS2811Error;
2021-12-25 00:57:10 +00:00
use std::{thread, time};
2021-12-23 19:34:26 +00:00
2021-12-01 01:27:28 +00:00
pub fn run_lights(controller: &mut Controller, values: &[RawColor; crate::LED_SIZE]) -> Result<(), WS2811Error> {
println!("Value: {:?}", values[0]);
//thread::sleep(time::Duration::from_millis(10));
2021-12-24 23:54:53 +00:00
let channels: Vec<usize> = controller.channels();
let mut strip = controller.leds_mut(channels[0]);
2021-12-01 01:27:28 +00:00
for i in 0..strip.len() {
2021-12-24 23:54:53 +00:00
strip[i] = values[i];
}
controller.render().expect("Error rendering.");
2021-12-24 23:54:53 +00:00
controller.wait()
2021-12-01 01:27:28 +00:00
}