Struct rust_gpiozero::input_devices::Button[][src]

pub struct Button { /* fields omitted */ }

Represents a simple push button or switch. Connect one side of the button to a ground pin, and the other to any GPIO pin. The GPIO pin will be pulled high by default. Alternatively, connect one side of the button to the 3V3 pin, and the other to any GPIO pin, and then create a Button instance with Button::new_with_pulldown

Implementations

impl Button[src]

pub fn new(pin: u8) -> Button[src]

Returns a Button with the pin number given and the pin pulled high with an internal resistor by default

  • pin - The GPIO pin which the device is attached to

pub fn new_with_pulldown(pin: u8) -> Button[src]

Returns a Button with the pin number given and the pin pulled down with an internal resistor by default

  • pin - The GPIO pin which the device is attached to

pub fn is_active(&self) -> bool[src]

Returns True if the device is currently active and False otherwise.

pub fn close(self)[src]

Shut down the device and release all associated resources.

pub fn pin(&self) -> u8[src]

The Pin that the device is connected to.

pub fn value(&self) -> bool[src]

Returns True if the device is currently active and False otherwise.

pub fn wait_for_release(&mut self, timeout: Option<f32>)[src]

  • timeout - Number of seconds to wait before proceeding. If this is None, then wait indefinitely until the device is inactive.

pub fn wait_for_press(&mut self, timeout: Option<f32>)[src]

Pause the program until the device is activated, or the timeout is reached.

  • timeout - Number of seconds to wait before proceeding. If this is None, then wait indefinitely until the device is active.

Auto Trait Implementations

impl !RefUnwindSafe for Button

impl Send for Button

impl Sync for Button

impl Unpin for Button

impl !UnwindSafe for Button

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.