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-27 01:26:29 +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> {
|
2021-12-27 01:26:29 +00:00
|
|
|
// println!("Value: {:?}", values[0]);
|
2021-12-01 19:36:19 +00:00
|
|
|
//thread::sleep(time::Duration::from_millis(10));
|
2021-12-24 23:54:53 +00:00
|
|
|
let channels: Vec<usize> = controller.channels();
|
2021-12-27 02:42:44 +00:00
|
|
|
let 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];
|
|
|
|
}
|
|
|
|
|
2021-12-01 19:36:19 +00:00
|
|
|
controller.render().expect("Error rendering.");
|
2021-12-24 23:54:53 +00:00
|
|
|
controller.wait()
|
2021-12-01 01:27:28 +00:00
|
|
|
}
|