X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=src%2Fmain.rs;h=fdbb104a19702978ad57eda801b534919a45f889;hb=0c50e4418792d9f5b78ef1c96d66514058beec26;hp=29a9343e695473dde361f9d46683792c8ae95fa6;hpb=52520a2f096921aa4e26818c669dc5fdf01c0528;p=temp2RGB.git diff --git a/src/main.rs b/src/main.rs index 29a9343..fdbb104 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,6 @@ extern crate windows_service; use std::{ - collections::HashMap, env, ffi::OsString, sync::{ @@ -25,34 +24,32 @@ use windows_service::{ service_dispatcher, service_manager::{ServiceManager, ServiceManagerAccess}, }; -use wmi::{COMLibrary, Variant, WMIConnection}; - -use crate::rgb::RGB; define_windows_service!(ffi_service_main, service_main); -mod winring0 { +mod wrapper_winring0 { #![allow(warnings, unused)] include!(concat!(env!("OUT_DIR"), "/ols_api.rs")); } - mod intel_arc { #![allow(warnings, unused)] include!(concat!(env!("OUT_DIR"), "/intel_arc.rs")); } - mod a770; -mod b650_e; +mod asus_aura_usb; +mod corsair_lighting_pro; mod machine; mod main_loop; +mod winring0; // mod common; mod consts; mod corsair_vengeance; mod piix4_i2c; mod rgb; // mod roccat; Disabled. -mod sensors_jiji; +mod cpu_temperature; mod settings; +mod tests; mod timer; fn main() -> Result<()> { @@ -78,6 +75,8 @@ fn main() -> Result<()> { .print_message() .start()?; + log_panics::init(); + let args: Vec = env::args().collect(); info!("Temperature to RGB"); @@ -86,7 +85,7 @@ fn main() -> Result<()> { let completed: Arc = Arc::new(AtomicBool::new(false)); main_loop::main_loop(completed.clone()); } else if args.contains(&"--tests".to_string()) { - tests(); + tests::tests(); } else if args.contains(&"--install-service".to_string()) { println!("Installing service..."); install_service()?; @@ -237,126 +236,3 @@ fn run_service(_arguments: Vec) -> Result<(), windows_service::Error> Ok(()) } - -fn tests() { - println!("Running some tests..."); - - // test_b650_e(); - // list_usb_devices(); - // test_roccat(); - // test_wmi(); - // test_corsair(); - test_a770(); - // test_read_temp(); - - println!("Press any key to continue..."); - std::io::stdin().read_line(&mut String::new()).unwrap(); -} - -fn test_wmi() { - let com_con = COMLibrary::new().unwrap(); - let wmi_con = WMIConnection::new(com_con.into()).unwrap(); - - //let results: Vec> = wmi_con.raw_query("SELECT * FROM Win32_PnPSignedDriver WHERE Description LIKE '%SMBUS%' OR Description LIKE '%SM BUS%'").unwrap(); - //let results: Vec> = wmi_con.raw_query("SELECT * FROM Win32_PnPSignedDriver WHERE Description LIKE 'Intel(R) NF I2C Host Controller'").unwrap(); - let results: Vec> = wmi_con - .raw_query("SELECT * FROM Win32_PnPSignedDriver") - .unwrap(); - //let results: Vec> = wmi_con.raw_query("SELECT * FROM Win32_PnPAllocatedResource").unwrap(); - - for os in results { - println!("-------------------"); - println!("{:#?}", os); - } -} -fn list_usb_devices() { - let api = hidapi::HidApi::new().unwrap(); - for device in api.device_list() { - println!("{:?}", device); - println!("name: {}", device.product_string().unwrap()); - println!("interface number: {}", device.interface_number()); - println!("page: {}", device.usage_page()); - println!("usage: {}", device.usage()); - println!("----"); - } -} - -// fn test_roccat() { -// let api = hidapi::HidApi::new().unwrap(); -// let roccat_device = roccat::get_device(&api); - -// let manufacturer = roccat_device.get_manufacturer_string().unwrap(); -// dbg!(manufacturer); - -// let product = roccat_device.get_product_string().unwrap(); -// dbg!(product); - -// let serial = roccat_device.get_serial_number_string().unwrap(); -// dbg!(serial); - -// roccat::init(&roccat_device); -// roccat::set_color( -// &roccat_device, -// &RGB { -// red: 0, -// green: 255, -// blue: 40, -// }, -// ); -// } - -fn test_b650_e() { - let api = hidapi::HidApi::new().unwrap(); - - let b650e_device = b650_e::get_device(&api); - - println!("Firmware: {}", b650_e::get_firmware_string(&b650e_device)); - - let configuration = b650_e::get_configuration_table(&b650e_device); - println!("Configuration:"); - for i in 0..60 { - print!("{:02X} ", configuration[i]); - if (i + 1) % 6 == 0 { - println!(""); - } - } - - // Only once, at start. - b650_e::set_fixed_mode(&b650e_device); - - b650_e::set_color( - &b650e_device, - &RGB { - red: 255, - green: 0, - blue: 0, - }, - ); - b650_e::save_current_color(&b650e_device); -} - -fn test_corsair() { - let corsair_controllers = [ - corsair_vengeance::Controller::new(0x19), - corsair_vengeance::Controller::new(0x1B), - ]; - for controller in corsair_controllers { - controller.set_color(&RGB { - red: 255, - green: 0, - blue: 0, - }); - } -} - -fn test_a770() { - // a770::set_rgb(255, 0, 0); - let mut a770 = a770::A770::new(); - a770.set_color(255, 0, 0); -} - -fn test_read_temp() { - let sensors = sensors_jiji::Sensors::new(); - println!("temp cpu: {}", sensors.read_cpu_temp()); - println!("temp gpu: {}", sensors.read_gpu_temp()); -}