capsules_extra::buzzer_pwm

Struct PwmBuzzer

Source
pub struct PwmBuzzer<'a, A: Alarm<'a>, P: PwmPin> { /* private fields */ }

Implementations§

Source§

impl<'a, A: Alarm<'a>, P: PwmPin> PwmBuzzer<'a, A, P>

Source

pub fn new( pwm_pin: &'a P, alarm: &'a A, max_duration_ms: usize, ) -> PwmBuzzer<'a, A, P>

Trait Implementations§

Source§

impl<'a, A: Alarm<'a>, P: PwmPin> AlarmClient for PwmBuzzer<'a, A, P>

Source§

fn alarm(&self)

Callback indicating the alarm time has been reached. The alarm MUST be disabled when this is called. If a new alarm is needed, the client can call Alarm::set_alarm.
Source§

impl<'a, A: Alarm<'a>, P: PwmPin> Buzzer<'a> for PwmBuzzer<'a, A, P>

Source§

fn set_client(&self, client: &'a dyn BuzzerClient)

Set the client to be used for callbacks of the Buzzer implementation.
Source§

fn buzz(&self, frequency_hz: usize, duration_ms: usize) -> Result<(), ErrorCode>

Play a sound at a chosen frequency and for a chosen duration. Once the buzzer finishes buzzing, the buzzer_done() callback is called. If it is called while the buzzer is playing, the buzzer command will be overridden with the new frequency and duration values. Read more
Source§

fn stop(&self) -> Result<(), ErrorCode>

Stop the sound currently playing. After the buzzer is successfully stopped, the buzzer_done() callback is called. Read more

Auto Trait Implementations§

§

impl<'a, A, P> !Freeze for PwmBuzzer<'a, A, P>

§

impl<'a, A, P> !RefUnwindSafe for PwmBuzzer<'a, A, P>

§

impl<'a, A, P> !Send for PwmBuzzer<'a, A, P>

§

impl<'a, A, P> !Sync for PwmBuzzer<'a, A, P>

§

impl<'a, A, P> Unpin for PwmBuzzer<'a, A, P>

§

impl<'a, A, P> !UnwindSafe for PwmBuzzer<'a, A, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.