/// /// Configure udev: /// https://github.com/Grix/helios_dac/blob/master/docs/udev_rules_for_linux.md /// use helios_dac::{NativeHeliosDac, NativeHeliosDacController}; use helios_dac::{ // Coordinate, Color, DeviceStatus, Frame, Point as HeliosPoint, }; use crate::conf::HeliosConf; use crate::device::{Device, Status}; use crate::errors::{LJError, LJResult}; use crate::point::Point; pub struct HeliosDevice { pub conf: HeliosConf, dac: NativeHeliosDac, } impl HeliosDevice { pub fn new(conf: &HeliosConf) -> LJResult { let id = conf.id; let controller = NativeHeliosDacController::new()?; let devices = controller.list_devices()?; let Some(device) = devices.into_iter().nth(id as usize) else { return Err(Box::new(LJError::HeliosDeviceMissing)); }; let dac = device.open()?; Ok(Self { conf: (*conf).clone(), dac }) } } impl Device for HeliosDevice { fn status(&self) -> Status { return Status { active: true, last_traced_at: "now".to_string(), properties: vec!["foo".to_string()], }; } fn draw(&self, line: Vec, speed: u32, ) -> LJResult<()> { while let Ok(DeviceStatus::NotReady) = self.dac.status() {} let points: Vec = line.into_iter().map(|p| p.into()).collect(); let frame = Frame::new(speed, points); Ok(()) } fn stop(&mut self) -> LJResult<()> { self.dac.stop()?; Ok(()) } }