lj_rust/src/device.rs

46 lines
889 B
Rust

use crate::point::Point;
mod helios;
use crate::conf::{Conf, DacFamily, /*EtherDreamConf, HeliosConf*/};
use crate::device::helios::HeliosDevice;
use crate::errors::LJResult;
/*
self.protocol_version,
self.le_state,
self.playback_state,
self.source,
self.le_flags,
self.playback_flags,
self.source_flags,
self.fullness,
self.point_rate,
self.point_count
*/
pub struct Status {
pub active: bool,
pub last_traced_at: String,
pub properties: Vec<String>
}
pub trait Device {
fn status( &self ) -> Status;
fn draw(
&mut self,
frame: Vec<Point>,
speed: u32,
) -> LJResult<()> ;
fn stop(&mut self) -> LJResult<()>;
}
pub fn device_factory(config: &Conf) -> LJResult<Box<dyn Device>> {
let device = match &config.dac {
DacFamily::Helios(conf) => Box::new(HeliosDevice::new(conf)?),
DacFamily::Etherdream(_conf) => todo!(),
};
Ok(device)
}