#![no_std]
use embassy_time::{Duration, Timer};
pub struct Beeper {
pin: esp_hal::gpio::Output<'static>,
boat_lost: bool,
}
impl Beeper {
pub async fn new(
pin: esp_hal::gpio::Output<'static>,
boat_lost: bool,
) -> Self {
Self {
pin,
boat_lost,
}
}
pub fn is_lost(&mut self) {
if self.boat_lost == true{
self.pin.set_high();
Timer::after(Duration::from_secs(1));
self.pin.set_low();
Timer::after(Duration::from_secs(1));
}
}
pub async fn battery_alarm(&mut self) {
self.pin.set_high();
Timer::after(Duration::from_secs(1)).await;
self.pin.set_low();
Timer::after(Duration::from_secs(4)).await;
}
}