fix: rework device
This commit is contained in:
parent
259fdeb7b0
commit
4b135ce283
@ -29,7 +29,7 @@ pub struct Status {
|
|||||||
pub trait Device {
|
pub trait Device {
|
||||||
fn status( &self ) -> Status;
|
fn status( &self ) -> Status;
|
||||||
fn draw(
|
fn draw(
|
||||||
&self,
|
&mut self,
|
||||||
frame: Vec<Point>,
|
frame: Vec<Point>,
|
||||||
speed: u32,
|
speed: u32,
|
||||||
) -> LJResult<()> ;
|
) -> LJResult<()> ;
|
@ -30,7 +30,8 @@ impl HeliosDevice {
|
|||||||
};
|
};
|
||||||
let dac = device.open()?;
|
let dac = device.open()?;
|
||||||
Ok(Self {
|
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>,
|
line: Vec<Point>,
|
||||||
speed: u32,
|
speed: u32,
|
||||||
) -> LJResult<()> {
|
) -> LJResult<()> {
|
||||||
@ -52,6 +53,11 @@ impl Device for HeliosDevice {
|
|||||||
|
|
||||||
let points: Vec<helios_dac::Point> = line.into_iter().map(|p| p.into()).collect();
|
let points: Vec<helios_dac::Point> = line.into_iter().map(|p| p.into()).collect();
|
||||||
let frame = Frame::new(speed, points);
|
let frame = Frame::new(speed, points);
|
||||||
|
|
||||||
|
while let Ok(DeviceStatus::NotReady) = self.dac.status() {
|
||||||
|
self.dac.write_frame(frame.clone())?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user