Add support for Corsair Lighting Pro
[temp2RGB.git] / src / main_loop.rs
index 5c41bb9..ae4c221 100644 (file)
@@ -17,13 +17,13 @@ pub fn main_loop(completed: Arc<AtomicBool>) {
         panic!("Polling frequency must be a multiple of RGB refresh frequency");
     }
 
-    init_winring0();
+    winring0::init();
 
     let sleep = timer::Sleep::new();
     let settings = settings::Settings::read(consts::FILE_CONF).expect("Cannot load settings");
     println!("Settings: {settings:?}");
 
-    let mut machine: &mut dyn machine::Machine = &mut machine::MachineJiji::new();
+    let machine: &mut dyn machine::Machine = &mut machine::MachineJiji::new();
 
     let mut kernel = [0f32; consts::KERNEL_SIZE_SAMPLES];
     let mut current_pos = 0usize;
@@ -35,6 +35,7 @@ pub fn main_loop(completed: Arc<AtomicBool>) {
         if completed.load(Ordering::Relaxed) {
             break;
         }
+
         let time_beginning_loop = time::Instant::now();
 
         let temp = (machine.get_cpu_tmp() + machine.get_gpu_tmp()) / 2f32;
@@ -76,20 +77,5 @@ pub fn main_loop(completed: Arc<AtomicBool>) {
     // println!("Press any key to continue...");
     // std::io::stdin().read_line(&mut String::new()).unwrap();
 
-    unsafe {
-        winring0::DeinitializeOls();
-    }
-}
-
-fn init_winring0() {
-    unsafe {
-        let ols_ok = winring0::InitializeOls() != 0;
-        if !ols_ok {
-            panic!("Unable to initalize WingRing0");
-        }
-        let dll_status = winring0::GetDllStatus();
-        if dll_status != 0 {
-            panic!("WingRing0 DLL status error: {}", dll_status);
-        }
-    }
+    winring0::deinit();
 }