Struct rust_gpiozero::output_devices::Buzzer [−][src]
pub struct Buzzer { /* fields omitted */ }
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.
Implementations
impl Buzzer
[src]
impl Buzzer
[src]pub fn new(pin: u8) -> Buzzer
[src]
pub fn is_active(&self) -> bool
[src]
pub fn is_active(&self) -> bool
[src]Returns True
if the device is currently active and False
otherwise.
pub fn toggle(&mut self)
[src]
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 active_high(&self) -> bool
[src]
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]
pub fn set_active_high(&mut self, value: bool)
[src]Set the state for active_high
pub fn beep(&mut self, on_time: f32, off_time: f32)
[src]
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]
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