X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=src%2Fmachine.rs;h=1d7bb2e0a08184f656066b659ce453141d760c4f;hb=HEAD;hp=9d150dbecf58719396036f8d07fabf6315af18d9;hpb=819c06b7c57614e7771e251e791e50316e6a6ffc;p=temp2RGB.git diff --git a/src/machine.rs b/src/machine.rs index 9d150db..1d7bb2e 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -2,7 +2,8 @@ use log::error; use nvapi::sys::i2c; use crate::{ - a770, asus_aura_usb, corsair_lighting_pro, corsair_vengeance, cpu_temperature, intel_arc, rgb, + /*a770,*/ asus_aura_usb, corsair_lighting_pro, corsair_vengeance, cpu_temperature, + intel_arc, lian_li_sl_infinity, rgb, }; const RGB_FUSION2_GPU_REG_COLOR: u8 = 0x40; @@ -11,7 +12,12 @@ const RGB_FUSION2_GPU_REG_MODE: u8 = 0x88; const GIGABYTE_RTX3080TI_VISION_OC_ADDR: u8 = 0x63; pub trait Machine { - fn set_color(&mut self, color: &rgb::RGB); + fn set_color(&mut self, color: &rgb::RGB) { + self.set_color_1(&color); + self.set_color_2(&color); + } + fn set_color_1(&mut self, color: &rgb::RGB); + fn set_color_2(&mut self, color: &rgb::RGB); fn get_gpu_tmp(&self) -> f32; fn get_cpu_tmp(&self) -> f32; } @@ -19,8 +25,9 @@ pub trait Machine { pub struct MachineJiji { ram: Vec, b650e_device: asus_aura_usb::Device, - a770: a770::A770, - gpu_devices: intel_arc::Devices, + // a770: a770::A770, + // gpu_devices: intel_arc::Devices, + gpus: Vec, } impl MachineJiji { @@ -32,25 +39,28 @@ impl MachineJiji { corsair_vengeance::Controller::new(0x1B), ], b650e_device: asus_aura_usb::Device::new(&api, asus_aura_usb::Motherboard::Asus650e)?, - a770: a770::A770::new()?, - gpu_devices: unsafe { intel_arc::GetDevices() }, + // a770: a770::A770::new()?, + // gpu_devices: unsafe { intel_arc::GetDevices() }, + gpus: nvapi::PhysicalGpu::enumerate()?, }) } } impl Machine for MachineJiji { - fn set_color(&mut self, color: &rgb::RGB) { + fn set_color_1(&mut self, color: &rgb::RGB) { for controller in &self.ram { controller.set_color(&color); } - self.b650e_device.set_color(&color); - if let Err(error) = self.a770.set_color(color.red, color.green, color.blue) { - error!("Unable to set color: {:?}", error); - } + self.b650e_device.set_color(&color).unwrap(); } + fn set_color_2(&mut self, color: &rgb::RGB) {} // No color 2. + fn get_gpu_tmp(&self) -> f32 { - unsafe { intel_arc::GetTemperature(self.gpu_devices, 0) as f32 } + // unsafe { intel_arc::GetTemperature(self.gpu_devices, 0) as f32 } + self.gpus[0].thermal_settings(None).unwrap()[0] + .current_temperature + .0 as f32 } fn get_cpu_tmp(&self) -> f32 { @@ -58,17 +68,18 @@ impl Machine for MachineJiji { } } -impl Drop for MachineJiji { - fn drop(&mut self) { - unsafe { - intel_arc::FreeDevices(self.gpu_devices); - } - } -} +// impl Drop for MachineJiji { +// fn drop(&mut self) { +// unsafe { +// intel_arc::FreeDevices(self.gpu_devices); +// } +// } +// } pub struct MachineLyssMetal { crosshair_device: asus_aura_usb::Device, corsair_lignting_pro: corsair_lighting_pro::Device, + lian_li_sl_infinity: lian_li_sl_infinity::Device, gpus: Vec, } @@ -91,6 +102,7 @@ impl MachineLyssMetal { blue: 40, }, ), + lian_li_sl_infinity: lian_li_sl_infinity::Device::new(&api), gpus: nvapi::PhysicalGpu::enumerate()?, }; @@ -152,12 +164,16 @@ impl MachineLyssMetal { } impl Machine for MachineLyssMetal { - fn set_color(&mut self, color: &rgb::RGB) { - self.crosshair_device.set_color(&color); + fn set_color_1(&mut self, color: &rgb::RGB) { + self.crosshair_device.set_color(&color).unwrap(); self.corsair_lignting_pro.set_color(&color); // self.set_color_3080ti(&color); // TODO. } + fn set_color_2(&mut self, color: &rgb::RGB) { + self.lian_li_sl_infinity.set_color(&color); + } + fn get_gpu_tmp(&self) -> f32 { self.gpus[0].thermal_settings(None).unwrap()[0] .current_temperature