This commit is contained in:
2021-10-28 03:07:03 +02:00
parent 5a71aa2cf0
commit 763aa23ca8
9 changed files with 302 additions and 35 deletions

View File

@@ -1,4 +1,9 @@
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 serialport::SerialPort;
@@ -11,7 +16,9 @@ enum MCUResponse {
Sync,
Ack,
#[allow(dead_code)]
Info { num_pkts: u32 },
Info {
num_pkts: u32,
},
}
fn poll_response(ser: &mut dyn SerialPort) -> Result<MCUResponse> {
@@ -38,9 +45,12 @@ 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 mut dmx_buffer = [0u8; 512];
let mut ser = serialport::new("/dev/ttyUSB0", 500_000)