diff --git a/toos-dashboard/src-tauri/src/animation.rs b/toos-dashboard/src-tauri/src/animation.rs index 7471fea..be8f299 100644 --- a/toos-dashboard/src-tauri/src/animation.rs +++ b/toos-dashboard/src-tauri/src/animation.rs @@ -15,9 +15,17 @@ struct Timings { } static TIMINGS: Mutex> = Mutex::new(Lazy::new(|| Timings { charging_start_delay: 1600, charging_delay: 450, charging_end_delay: 400 } )); +static PLAYING: Mutex = Mutex::new(false); #[tauri::command] pub fn start() { + let mut playing = PLAYING.lock().unwrap(); + + if *playing { + return; + } else { + *playing = true; + } thread::spawn(move || { println!("Starting animation..."); @@ -28,6 +36,9 @@ pub fn start() { let _ = serial::write_serial(format!("SET_LIGHT:0;").as_str()); stage_one(); stage_two(); + + let mut playing = PLAYING.lock().unwrap(); + *playing = false; }); }