Add a color (2 colors can be now defined for a machine).
[temp2RGB.git] / src / machine.rs
index 1012c00..1d7bb2e 100644 (file)
@@ -12,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;
 }
@@ -42,16 +47,15 @@ impl MachineJiji {
 }
 
 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 }
         self.gpus[0].thermal_settings(None).unwrap()[0]
@@ -160,13 +164,16 @@ impl MachineLyssMetal {
 }
 
 impl Machine for MachineLyssMetal {
-    fn set_color(&mut self, color: &rgb::RGB) {
+    fn set_color_1(&mut self, color: &rgb::RGB) {
         self.crosshair_device.set_color(&color).unwrap();
         self.corsair_lignting_pro.set_color(&color);
-        self.lian_li_sl_infinity.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