From a92192a54a62974c91d2b40718478281e1f9590d Mon Sep 17 00:00:00 2001 From: PC_WSL Date: Mon, 12 May 2025 15:30:24 +0200 Subject: [PATCH] improved buzzer --- src/buzzer.rs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/buzzer.rs b/src/buzzer.rs index 2cdd6ab..d00b608 100644 --- a/src/buzzer.rs +++ b/src/buzzer.rs @@ -34,7 +34,26 @@ impl GPIOBuzzer { } pub async fn beep_ack(&mut self) -> Result<(), Box>{ + let sleep_ms: u64 = 10; + + self.modulated_tone(1200.0, 100).await?; + sleep(Duration::from_millis(sleep_ms)).await; + self.modulated_tone(2000.0,50).await?; + Ok(()) + } + + pub async fn beep_nak(&mut self) -> Result<(), Box>{ let sleep_ms: u64 = 100; + + self.modulated_tone(600.0, 150).await?; + sleep(Duration::from_millis(sleep_ms)).await; + self.modulated_tone(600.0,150).await?; + Ok(()) + } + + pub async fn beep_unnkown(&mut self) -> Result<(), Box>{ + let sleep_ms: u64 = 100; + self.modulated_tone(750.0, 100).await?; sleep(Duration::from_millis(sleep_ms)).await; self.modulated_tone(1200.0,100).await?; @@ -42,20 +61,4 @@ impl GPIOBuzzer { self.modulated_tone(2300.0,100).await?; Ok(()) } - - pub async fn beep_nak(&mut self) -> Result<(), Box>{ - self.modulated_tone(2300.0,100).await?; - self.modulated_tone(2300.0,100).await?; - Ok(()) - } - - pub async fn beep_unnkown(&mut self) -> Result<(), Box>{ - let sleep_ms: u64 = 100; - self.modulated_tone(2300.0,100).await?; - sleep(Duration::from_millis(sleep_ms)).await; - self.modulated_tone(2300.0,100).await?; - sleep(Duration::from_millis(sleep_ms)).await; - self.modulated_tone(2300.0,100).await?; - Ok(()) - } }