diff --git a/src/device/mod.rs b/src/device.rs similarity index 98% rename from src/device/mod.rs rename to src/device.rs index 70a3916..e231299 100644 --- a/src/device/mod.rs +++ b/src/device.rs @@ -29,7 +29,7 @@ pub struct Status { pub trait Device { fn status( &self ) -> Status; fn draw( - &self, + &mut self, frame: Vec, speed: u32, ) -> LJResult<()> ; diff --git a/src/device/helios.rs b/src/device/helios.rs index a090209..518a45a 100644 --- a/src/device/helios.rs +++ b/src/device/helios.rs @@ -30,7 +30,8 @@ impl HeliosDevice { }; let dac = device.open()?; Ok(Self { - conf: (*conf).clone(), dac, + conf: (*conf).clone(), + dac, }) } } @@ -44,7 +45,7 @@ impl Device for HeliosDevice { }; } - fn draw(&self, + fn draw(&mut self, line: Vec, speed: u32, ) -> LJResult<()> { @@ -52,6 +53,11 @@ impl Device for HeliosDevice { let points: Vec = line.into_iter().map(|p| p.into()).collect(); let frame = Frame::new(speed, points); + + while let Ok(DeviceStatus::NotReady) = self.dac.status() { + self.dac.write_frame(frame.clone())?; + } + Ok(()) }