[][src]Struct wiringpi::pin::InputPin

pub struct InputPin<Pin>(_, _);

Methods

impl<P: Pin> InputPin<P>
[src]

This function returns the value read at the given pin.

It will be High or Low (1 or 0) depending on the logic level at the pin.

This returns the value read on the supplied analog input pin. You will need to register additional analog modules to enable this function for devices such as the Gertboard, quick2Wire analog board, etc.

This will register an "Interrupt" to be called when the pin changes state Note the quotes around Interrupt, because the current implementation in the C library seems to be a dedicated thread that polls the gpio device driver, and this callback is called from that thread synchronously, so it's not something that you would call a real interrupt in an embedded environement.

The callback function does not need to be reentrant.

The callback must be an actual function (not a closure!), and must be using the extern "C" modifier so that it can be passed to the wiringpi library, and called from C code.

Unfortunately the C implementation does not allow userdata to be passed around, so the callback must be able to determine what caused the interrupt just by the function that was invoked.

See https://github.com/Ogeon/rust-wiringpi/pull/28 for ideas on how to work around these limitations if you find them too constraining.

use wiringpi;

extern "C" fn change_state() {
  println!("Look ma, I'm being called from an another thread");
}

fn main() {
   let pi = wiringpi::setup();
   let pin = pi.output_pin(0);

   pin.register_isr(Edge::Falling, Some(change_state));

   thread::sleep(60000);
}

impl<P: Pin + RequiresRoot> InputPin<P>
[src]

This sets the pull-up or pull-down resistor mode on the given pin.

Unlike the Arduino, the BCM2835 has both pull-up an down internal resistors. The parameter pud should be; Off, (no pull up/down), Down (pull to ground) or Up (pull to 3.3v)

impl<P: Pin + Pwm> InputPin<P>
[src]

impl<P: Pin + GpioClock> InputPin<P>
[src]

Auto Trait Implementations

impl<Pin> Send for InputPin<Pin> where
    Pin: Send

impl<Pin> Sync for InputPin<Pin> where
    Pin: Sync

Blanket Implementations

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

Performs the conversion.

impl<T> From for T
[src]

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

Immutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

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

Mutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.