[−][src]Struct rust_gpiozero::output_devices::Buzzer
Represents a digital buzzer component.
Connect the cathode (negative pin) of the buzzer to a ground pin; connect the other side to any GPIO pin.
Methods
impl Buzzer
[src]
pub fn new(pin: u8) -> Buzzer
[src]
pub fn is_active(&self) -> bool
[src]
Returns True
if the device is currently active and False
otherwise.
pub fn on(&self)
[src]
Turns the device on.
pub fn off(&self)
[src]
Turns the device off.
pub fn toggle(&mut self)
[src]
Reverse the state of the device. If it's on, turn it off; if it's off, turn it on.
pub fn value(&self) -> bool
[src]
Returns True
if the device is currently active and False
otherwise.
pub fn active_high(&self) -> bool
[src]
When True
, the value
property is True
when the device's
pin
is high. When False
the value
property is
True
when the device's pin is low (i.e. the value is inverted).
Be warned that changing it will invert value
(i.e. changing this property doesn't change
the device's pin state - it just changes how that state is interpreted).
pub fn set_active_high(&mut self, value: bool)
[src]
Set the state for active_high
pub fn pin(&self) -> u8
[src]
The Pin
that the device is connected to.
pub fn close(self)
[src]
Shut down the device and release all associated resources.
pub fn wait(&mut self)
[src]
Block until background process is done
pub fn beep(&mut self, on_time: f32, off_time: f32)
[src]
Make the device turn on and off repeatedly in the background.
Use set_beep_count
to set the number of times to beep the device
on_time
- Number of seconds onoff_time
- Number of seconds off
pub fn set_beep_count(&mut self, n: i32)
[src]
Set the number of times to beep the device
n
- Number of times to beep
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,