Add support for Corsair Lighting Pro
[temp2RGB.git] / src / machine.rs
1 use crate::{a770, asus_aura_usb, corsair_vengeance, cpu_temperature, intel_arc, rgb};
2
3 pub trait Machine {
4 fn set_color(&mut self, color: &rgb::RGB);
5 fn get_gpu_tmp(&self) -> f32;
6 fn get_cpu_tmp(&self) -> f32;
7 }
8
9 pub struct MachineJiji {
10 ram: Vec<corsair_vengeance::Controller>,
11 b650e_device: asus_aura_usb::Device,
12 a770: a770::A770,
13 gpu_devices: intel_arc::Devices,
14 }
15
16 impl MachineJiji {
17 pub fn new() -> Self {
18 let api = hidapi::HidApi::new().unwrap();
19 let machine = MachineJiji {
20 ram: vec![
21 corsair_vengeance::Controller::new(0x19),
22 corsair_vengeance::Controller::new(0x1B),
23 ],
24 b650e_device: asus_aura_usb::Device::new(&api, asus_aura_usb::Motherboard::Asus650e),
25 a770: a770::A770::new(),
26 gpu_devices: unsafe { intel_arc::GetDevices() },
27 };
28 machine.b650e_device.set_fixed_mode();
29 machine
30 }
31 }
32
33 impl Machine for MachineJiji {
34 fn set_color(&mut self, color: &rgb::RGB) {
35 for controller in &self.ram {
36 controller.set_color(&color);
37 }
38 self.b650e_device.set_color(&color);
39 self.a770.set_color(color.red, color.green, color.blue);
40 }
41
42 fn get_gpu_tmp(&self) -> f32 {
43 unsafe { intel_arc::GetTemperature(self.gpu_devices, 0) as f32 }
44 }
45
46 fn get_cpu_tmp(&self) -> f32 {
47 cpu_temperature::read()
48 }
49 }
50
51 impl Drop for MachineJiji {
52 fn drop(&mut self) {
53 unsafe {
54 intel_arc::FreeDevices(self.gpu_devices);
55 }
56 }
57 }
58
59 struct MachineLyssMetal {}