Implement multiple fixtures
This commit is contained in:
parent
07ba32f0ee
commit
a2d7bb3211
@ -46,8 +46,16 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
let mut dmx_buffer = [0u8; 512];
|
let mut dmx_buffer = [0u8; 512];
|
||||||
|
|
||||||
let mut movinghead = fixtures::MovingHead14CH::new(1);
|
let mut movingheads = [
|
||||||
movinghead.dimmer = 134;
|
fixtures::MovingHead14CH::new(1),
|
||||||
|
fixtures::MovingHead14CH::new(15),
|
||||||
|
fixtures::MovingHead14CH::new(29),
|
||||||
|
fixtures::MovingHead14CH::new(43),
|
||||||
|
];
|
||||||
|
|
||||||
|
for movinghead in movingheads.iter_mut() {
|
||||||
|
movinghead.dimmer = 134;
|
||||||
|
}
|
||||||
|
|
||||||
let mut ser = serialport::new("/dev/ttyUSB0", 500_000)
|
let mut ser = serialport::new("/dev/ttyUSB0", 500_000)
|
||||||
.timeout(Duration::from_millis(10))
|
.timeout(Duration::from_millis(10))
|
||||||
@ -69,10 +77,18 @@ fn main() -> Result<()> {
|
|||||||
'main: loop {
|
'main: loop {
|
||||||
let loop_start = Instant::now();
|
let loop_start = Instant::now();
|
||||||
|
|
||||||
let hsl_color = Hsl::new(360.0 * ((t % FPS) as f32 / FPS as f32), 1.0, 0.5);
|
let dist = FPS as f32 / movingheads.len() as f32;
|
||||||
movinghead.rgb = hsl_color.into_color();
|
|
||||||
|
|
||||||
movinghead.render(&mut dmx_buffer);
|
for (i, movinghead) in movingheads.iter_mut().enumerate() {
|
||||||
|
let hsl_color = Hsl::new(
|
||||||
|
360.0 * ((t % FPS) as f32 / FPS as f32) + i as f32 * dist,
|
||||||
|
1.0,
|
||||||
|
0.5,
|
||||||
|
);
|
||||||
|
movinghead.rgb = hsl_color.into_color();
|
||||||
|
|
||||||
|
movinghead.render(&mut dmx_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
// write DMX data
|
// write DMX data
|
||||||
let write_result = ser.write(&dmx_buffer);
|
let write_result = ser.write(&dmx_buffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user