d1ff5c495be11b28a0864113de251aa222a2f441
[temp2RGB.git] / src / machine.rs
1 use crate::{a770, corsair_vengeance, rgb, sensors_jiji, winring0, AsusAuraUSB};
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: AsusAuraUSB::Device,
12 a770: a770::A770,
13 sensors: sensors_jiji::Sensors,
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: AsusAuraUSB::Device::new(&api, AsusAuraUSB::Motherboard::Asus650e),
25 a770: a770::A770::new(),
26 sensors: sensors_jiji::Sensors::new(),
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 fn get_gpu_tmp(&self) -> f32 {
42 self.sensors.read_gpu_temp()
43 }
44
45 fn get_cpu_tmp(&self) -> f32 {
46 self.sensors.read_cpu_temp()
47 }
48 }
49
50 struct MachineLyssMetal {}