Move tests in a separate module
[temp2RGB.git] / src / main.rs
index 29a9343..a819b71 100644 (file)
@@ -2,7 +2,6 @@
 extern crate windows_service;
 
 use std::{
-    collections::HashMap,
     env,
     ffi::OsString,
     sync::{
@@ -25,9 +24,6 @@ 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);
 
@@ -41,8 +37,8 @@ mod intel_arc {
     include!(concat!(env!("OUT_DIR"), "/intel_arc.rs"));
 }
 
+mod AsusAuraUSB;
 mod a770;
-mod b650_e;
 mod machine;
 mod main_loop;
 // mod common;
@@ -53,6 +49,7 @@ mod rgb;
 // mod roccat; Disabled.
 mod sensors_jiji;
 mod settings;
+mod tests;
 mod timer;
 
 fn main() -> Result<()> {
@@ -86,7 +83,7 @@ fn main() -> Result<()> {
         let completed: Arc<AtomicBool> = 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 +234,3 @@ fn run_service(_arguments: Vec<OsString>) -> 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<HashMap<String, Variant>> = wmi_con.raw_query("SELECT * FROM Win32_PnPSignedDriver WHERE Description LIKE '%SMBUS%' OR Description LIKE '%SM BUS%'").unwrap();
-    //let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT * FROM Win32_PnPSignedDriver WHERE Description LIKE 'Intel(R) NF I2C Host Controller'").unwrap();
-    let results: Vec<HashMap<String, Variant>> = wmi_con
-        .raw_query("SELECT * FROM Win32_PnPSignedDriver")
-        .unwrap();
-    //let results: Vec<HashMap<String, Variant>> = 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());
-}