fix: rework device

This commit is contained in:
alban 2023-06-08 20:18:28 +02:00
parent 259fdeb7b0
commit 4b135ce283
2 changed files with 9 additions and 3 deletions

View File

@ -29,7 +29,7 @@ pub struct Status {
pub trait Device {
fn status( &self ) -> Status;
fn draw(
&self,
&mut self,
frame: Vec<Point>,
speed: u32,
) -> LJResult<()> ;

View File

@ -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<Point>,
speed: u32,
) -> LJResult<()> {
@ -52,6 +53,11 @@ impl Device for HeliosDevice {
let points: Vec<helios_dac::Point> = 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(())
}