This commit is contained in:
Kai Vogelgesang 2021-10-28 01:32:37 +02:00
parent 30a4f83d32
commit 5a71aa2cf0
Signed by: kai
GPG Key ID: 0A95D3B6E62C0879

View File

@ -1,7 +1,6 @@
use std::{io, sync::{Arc, Mutex}, thread, time::{Duration, Instant}}; use std::{io, sync::{Arc, Mutex}, thread, time::{Duration, Instant}};
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use palette::{Hsl, IntoColor, Pixel, Srgb};
use serialport::SerialPort; use serialport::SerialPort;
use crate::fixtures::{DMXFixture, MovingHead}; use crate::fixtures::{DMXFixture, MovingHead};
@ -42,8 +41,6 @@ fn poll_response(ser: &mut dyn SerialPort) -> Result<MCUResponse> {
pub fn controller_thread(running: Arc<Mutex<bool>>, movingheads: Arc<Mutex<[MovingHead; 4]>>) -> Result<()> { pub fn controller_thread(running: Arc<Mutex<bool>>, movingheads: Arc<Mutex<[MovingHead; 4]>>) -> Result<()> {
let frame_time = Duration::from_secs_f64(1.0 / FPS as f64); let frame_time = Duration::from_secs_f64(1.0 / FPS as f64);
let hsl_cycle = 12 * FPS;
let mut dmx_buffer = [0u8; 512]; let mut dmx_buffer = [0u8; 512];
let mut ser = serialport::new("/dev/ttyUSB0", 500_000) let mut ser = serialport::new("/dev/ttyUSB0", 500_000)
@ -58,8 +55,6 @@ pub fn controller_thread(running: Arc<Mutex<bool>>, movingheads: Arc<Mutex<[Movi
} }
} }
let mut t = 0;
'main: loop { 'main: loop {
{ {
let running = running.lock().unwrap(); let running = running.lock().unwrap();
@ -78,9 +73,6 @@ pub fn controller_thread(running: Arc<Mutex<bool>>, movingheads: Arc<Mutex<[Movi
} }
} }
t += 1;
t %= hsl_cycle;
let write_result = ser.write(&dmx_buffer); let write_result = ser.write(&dmx_buffer);
if write_result.is_err() { if write_result.is_err() {