/// /// 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 { /// This is fabulous doc ! /// # Woot /// /// ` some example ` /// pub fn new(conf: HeliosConf) -> LJResult { let id = conf.id; let controller = NativeHeliosDacController::new()?; let devices = controller.list_devices()?; let Some( dac) = devices.iter().nth(id as usize) else { return Err(Box::new(LJError::HeliosDeviceMissing)); }; dac.open()?; Ok(Self { conf, dac, }) } } // // fn get_helios_device() -> LJResult { // let controller = NativeHeliosDacController::new()?; // let devices = controller.list_devices()?; // let Some(device) = devices.into_iter().next() else { // return Err(Box::new(LJError::HeliosDeviceMissing)); // }; // let device = device.open()?; // Ok(device) // } 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(true) } }