From dc78ea74269a6843d236587500b8c9cc0392b51d Mon Sep 17 00:00:00 2001 From: Xeovalyte Date: Thu, 26 Oct 2023 15:30:53 +0200 Subject: [PATCH] feat: Added button --- toos-dashboard/src-tauri/src/animation.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; }); }