1 use std
::collections
::HashMap
;
3 use wmi
::{COMLibrary
, Variant
, WMIConnection
};
6 a770
, asus_aura_usb
, corsair_lighting_pro
, corsair_vengeance
, cpu_temperature
, machine
,
7 rgb
::RGB
, winring0
, wrapper_winring0
,
11 println!("Running some tests...");
15 test_asus_aura_usb(asus_aura_usb
::Motherboard
::AsusCrosshairVIIIHero
);
16 // test_corsair_lighting_pro();
17 // list_usb_devices();
22 // test_read_temperature_cpu();
23 // test_read_temperature_a770()
24 // test_read_temperature_3080();
28 println!("Press any key to continue...");
29 std
::io
::stdin().read_line(&mut String
::new()).unwrap();
33 let com_con
= COMLibrary
::new().unwrap();
34 let wmi_con
= WMIConnection
::new(com_con
.into()).unwrap();
36 //let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT * FROM Win32_PnPSignedDriver WHERE Description LIKE '%SMBUS%' OR Description LIKE '%SM BUS%'").unwrap();
37 //let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT * FROM Win32_PnPSignedDriver WHERE Description LIKE 'Intel(R) NF I2C Host Controller'").unwrap();
38 let results
: Vec
<HashMap
<String
, Variant
>> = wmi_con
39 .raw_query("SELECT * FROM Win32_PnPSignedDriver")
41 //let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT * FROM Win32_PnPAllocatedResource").unwrap();
44 println!("-------------------");
45 println!("{:#?}", os
);
49 fn list_usb_devices() {
50 let api
= hidapi
::HidApi
::new().unwrap();
51 for device
in api
.device_list() {
52 println!("{:?}", device
);
53 println!("name: {}", device
.product_string().unwrap());
54 println!("interface number: {}", device
.interface_number());
55 println!("page: {}", device
.usage_page());
56 println!("usage: {}", device
.usage());
62 // let api = hidapi::HidApi::new().unwrap();
63 // let roccat_device = roccat::get_device(&api);
65 // let manufacturer = roccat_device.get_manufacturer_string().unwrap();
66 // dbg!(manufacturer);
68 // let product = roccat_device.get_product_string().unwrap();
71 // let serial = roccat_device.get_serial_number_string().unwrap();
74 // roccat::init(&roccat_device);
85 fn test_asus_aura_usb(motherboard
: asus_aura_usb
::Motherboard
) {
86 let api
= hidapi
::HidApi
::new().unwrap();
88 let device
= asus_aura_usb
::Device
::new(&api
, motherboard
);
90 println!("Firmware: {}", device
.get_firmware_string());
92 let configuration
= device
.get_configuration_table();
93 println!("Configuration:");
95 print!("{:02X} ", configuration
[i
]);
100 println!("Number of addressable header: {}", configuration
[0x02]);
101 println!("Number of leds: {}", configuration
[0x1B]);
102 println!("Number of RGB headers: {}", configuration
[0x1D]);
104 device
.set_color(&RGB
{
110 device
.save_current_color();
113 fn test_corsair_lighting_pro() {
114 let api
= hidapi
::HidApi
::new().unwrap();
115 let device
= corsair_lighting_pro
::Device
::new(
125 if i
% 10 == 0 || i
== 255 || i
== 0 {
126 device
.set_color(&RGB
{
128 green
: 255u8 - i
as u8,
131 std
::thread
::sleep(std
::time
::Duration
::from_millis(200));
137 let corsair_controllers
= [
138 corsair_vengeance
::Controller
::new(0x19),
139 corsair_vengeance
::Controller
::new(0x1B),
142 for controller
in corsair_controllers
{
143 controller
.set_color(&RGB
{
152 // a770::set_rgb(255, 0, 0);
153 let mut a770
= a770
::A770
::new();
154 a770
.set_color(255, 0, 0);
157 const F17H_M01H_THM_TCON_CUR_TMP
: u32 = 0x00059800;
158 const F17H_TEMP_OFFSET_FLAG
: u32 = 0x80000;
159 const FAMILY_17H_PCI_CONTROL_REGISTER
: u32 = 0x60;
161 fn test_read_temperature_cpu() {
162 println!("temp cpu: {}", cpu_temperature
::read())
165 fn test_read_temperature_a770() {
166 let jiji
: &dyn machine
::Machine
= &machine
::MachineJiji
::new();
167 println!("temp gpu: {}", jiji
.get_gpu_tmp());
170 fn test_read_temperature_3080() {
171 nvapi
::initialize().expect("Unable to initialize nvapi (Nvidia API)");
172 // if let Ok(gpus) = {
174 // let thermal = gpu.thermal_settings(None).unwrap()[0];
175 // println!("{:?}", thermal.current_temperature.0)
178 let gpus
= nvapi
::PhysicalGpu
::enumerate().unwrap();
180 let sensor
= gpu
.thermal_settings(None
).unwrap()[0];
181 println!("{:?}", sensor
.current_temperature
.0);
182 nvapi
::unload().unwrap();