fix: helios.status state

This commit is contained in:
alban 2023-06-12 19:27:44 +02:00
parent 526a78428b
commit 0f3ee7c54a
1 changed files with 3 additions and 2 deletions

View File

@ -32,7 +32,7 @@ impl HeliosDevice {
return Err(Box::new(LJError::HeliosDeviceMissing));
};
let dac = device.open()?;
Ok(Self { conf: (*conf).clone(), dac, sent_points: 0, state: PlaybackState::IDLE, lack: "".to_string() })
Ok(Self { conf: (*conf).clone(), dac, sent_points: 0, state: PlaybackState::PREPARE, lack: "".to_string() })
}
}
@ -53,13 +53,14 @@ impl Device for HeliosDevice {
line: Vec<Point>,
speed: u32,
) -> LJResult<()> {
self.state = PlaybackState::IDLE;
while let Ok(DeviceStatus::NotReady) = self.dac.status() {}
self.state = PlaybackState::PLAYING;
let points: Vec<helios_dac::Point> = line.into_iter().map(|p| p.into()).collect();
let frame = Frame::new(speed, points.clone());
self.dac.write_frame(frame.clone())?;
self.sent_points = points.len() as u16;
self.state = PlaybackState::PLAYING;
Ok(())
}