X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=src%2Ftests.rs;h=0cf81ad1623584b6a37a9e6ecfe9aeafeff3e08c;hb=bfb3de4d11feee1307654936452e3776ccb3a056;hp=13210058b03948bb7ff1b173141c3111f8621783;hpb=df85fed256d816770034fd4290cf2d3d22e43975;p=temp2RGB.git diff --git a/src/tests.rs b/src/tests.rs index 1321005..0cf81ad 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -19,8 +19,10 @@ pub fn tests() { // test_wmi(); // test_corsair(); // test_a770(); - test_read_temperature_cpu(); - // test_read_temperatur_a770 + test_3080ti(); + // test_read_temperature_cpu(); + // test_read_temperature_a770() + // test_read_temperature_3080(); winring0::deinit(); @@ -84,11 +86,11 @@ fn list_usb_devices() { fn test_asus_aura_usb(motherboard: asus_aura_usb::Motherboard) { let api = hidapi::HidApi::new().unwrap(); - let device = asus_aura_usb::Device::new(&api, motherboard); + let device = asus_aura_usb::Device::new(&api, motherboard).unwrap(); - println!("Firmware: {}", device.get_firmware_string()); + println!("Firmware: {}", device.get_firmware_string().unwrap()); - let configuration = device.get_configuration_table(); + let configuration = device.get_configuration_table().unwrap(); println!("Configuration:"); for i in 0..60 { print!("{:02X} ", configuration[i]); @@ -100,27 +102,38 @@ 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, - blue: 255, - }); + device + .set_color(&RGB { + red: 0, + green: 0, + blue: 255, + }) + .unwrap(); - device.save_current_color(); + device.save_current_color().unwrap(); } 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 +141,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, @@ -139,8 +153,18 @@ fn test_corsair() { fn test_a770() { // a770::set_rgb(255, 0, 0); - let mut a770 = a770::A770::new(); - a770.set_color(255, 0, 0); + let mut a770 = a770::A770::new().unwrap(); + a770.set_color(255, 0, 0).unwrap(); +} + +fn test_3080ti() { + let machine: &mut dyn machine::Machine = &mut machine::MachineLyssMetal::new().unwrap(); + + machine.set_color(&RGB { + red: 255, + green: 0, + blue: 0, + }); } const F17H_M01H_THM_TCON_CUR_TMP: u32 = 0x00059800; @@ -151,8 +175,22 @@ fn test_read_temperature_cpu() { println!("temp cpu: {}", cpu_temperature::read()) } -fn test_read_temperatur_a770() { - let jiji: &dyn machine::Machine = &machine::MachineJiji::new(); +fn test_read_temperature_a770() { + let jiji: &dyn machine::Machine = &machine::MachineJiji::new().unwrap(); 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(); +}