Implement 'set_color' for corsair lighting pro
[temp2RGB.git] / src / tests.rs
index 1321005..09c75e4 100644 (file)
@@ -12,15 +12,16 @@ pub fn tests() {
 
     winring0::init();
 
-    // test_asus_aura_usb(asus_aura_usb::Motherboard::AsusCrosshairVIIIHero);
+    test_asus_aura_usb(asus_aura_usb::Motherboard::AsusCrosshairVIIIHero);
     // test_corsair_lighting_pro();
     // list_usb_devices();
     // test_roccat();
     // test_wmi();
     // test_corsair();
     // test_a770();
-    test_read_temperature_cpu();
-    // test_read_temperatur_a770
+    // test_read_temperature_cpu();
+    // test_read_temperature_a770()
+    // test_read_temperature_3080();
 
     winring0::deinit();
 
@@ -100,9 +101,6 @@ fn test_asus_aura_usb(motherboard: asus_aura_usb::Motherboard) {
     println!("Number of leds: {}", configuration[0x1B]);
     println!("Number of RGB headers: {}", configuration[0x1D]);
 
-    // Only once, at start.
-    device.set_fixed_mode();
-
     device.set_color(&RGB {
         red: 0,
         green: 0,
@@ -114,13 +112,25 @@ fn test_asus_aura_usb(motherboard: asus_aura_usb::Motherboard) {
 
 fn test_corsair_lighting_pro() {
     let api = hidapi::HidApi::new().unwrap();
-    let device = corsair_lighting_pro::Device::new(&api);
-
-    device.set_color(&RGB {
-        red: 0,
-        green: 0,
-        blue: 255,
-    });
+    let device = corsair_lighting_pro::Device::new(
+        &api,
+        &RGB {
+            red: 0,
+            green: 255,
+            blue: 0,
+        },
+    );
+
+    for i in 0..=255 {
+        if i % 10 == 0 || i == 255 || i == 0 {
+            device.set_color(&RGB {
+                red: i as u8,
+                green: 255u8 - i as u8,
+                blue: 0,
+            });
+            std::thread::sleep(std::time::Duration::from_millis(200));
+        }
+    }
 }
 
 fn test_corsair() {
@@ -128,6 +138,7 @@ fn test_corsair() {
         corsair_vengeance::Controller::new(0x19),
         corsair_vengeance::Controller::new(0x1B),
     ];
+
     for controller in corsair_controllers {
         controller.set_color(&RGB {
             red: 0,
@@ -151,8 +162,22 @@ fn test_read_temperature_cpu() {
     println!("temp cpu: {}", cpu_temperature::read())
 }
 
-fn test_read_temperatur_a770() {
+fn test_read_temperature_a770() {
     let jiji: &dyn machine::Machine = &machine::MachineJiji::new();
     println!("temp gpu: {}", jiji.get_gpu_tmp());
 }
 
+fn test_read_temperature_3080() {
+    nvapi::initialize().expect("Unable to initialize nvapi (Nvidia API)");
+    // if let Ok(gpus) =  {
+    //     for gpu in gpus {
+    //         let thermal = gpu.thermal_settings(None).unwrap()[0];
+    //         println!("{:?}", thermal.current_temperature.0)
+    //     }
+    // }
+    let gpus = nvapi::PhysicalGpu::enumerate().unwrap();
+    let gpu = &gpus[0];
+    let sensor = gpu.thermal_settings(None).unwrap()[0];
+    println!("{:?}", sensor.current_temperature.0);
+    nvapi::unload().unwrap();
+}