style: clean unused code.
This commit is contained in:
parent
c5d382fafe
commit
65028bd7f6
13
src/beep.rs
13
src/beep.rs
@ -9,8 +9,6 @@ use std::time::Duration;
|
||||
type LedcChannel<P, T, C> = Channel<C, T, Timer<T>, P>;
|
||||
|
||||
pub struct Beep<P: OutputPin, T: ledc::HwTimer, C: ledc::HwChannel> {
|
||||
state: bool,
|
||||
stopped: bool,
|
||||
beat: u8,
|
||||
ringtone: ringtone::Type,
|
||||
channel: LedcChannel<P, T, C>,
|
||||
@ -19,8 +17,6 @@ pub struct Beep<P: OutputPin, T: ledc::HwTimer, C: ledc::HwChannel> {
|
||||
impl<P: OutputPin, T: ledc::HwTimer, C: ledc::HwChannel> Beep<P, T, C> {
|
||||
pub fn new(pin: P, timer: T, channel: C) -> Result<Self, EspError> {
|
||||
return Ok(Beep {
|
||||
state: false,
|
||||
stopped: false,
|
||||
channel: Self::init_channel(pin, timer, channel)?,
|
||||
beat: 0,
|
||||
ringtone: ringtone::SILENCE,
|
||||
@ -36,15 +32,6 @@ impl<P: OutputPin, T: ledc::HwTimer, C: ledc::HwChannel> Beep<P, T, C> {
|
||||
return Ok(channel);
|
||||
}
|
||||
|
||||
pub fn toggle(&mut self) -> Result<(), EspError> {
|
||||
self.state = !self.state;
|
||||
if self.state {
|
||||
self.channel.set_duty(50)
|
||||
} else {
|
||||
self.channel.set_duty(0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play(&mut self, rx: &mut std::sync::mpsc::Receiver<ringtone::Type>) {
|
||||
loop {
|
||||
let curr_ringtone = rx.try_recv().unwrap_or_else(|_| self.ringtone);
|
||||
|
Loading…
Reference in New Issue
Block a user