feat: Added button

This commit is contained in:
Xeovalyte 2023-10-26 15:30:53 +02:00
parent 81edabee6e
commit dc78ea7426

View File

@ -15,9 +15,17 @@ struct Timings {
}
static TIMINGS: Mutex<Lazy<Timings>> = Mutex::new(Lazy::new(|| Timings { charging_start_delay: 1600, charging_delay: 450, charging_end_delay: 400 } ));
static PLAYING: Mutex<bool> = 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;
});
}