pub struct InputPin<Pin>(_, _);
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);
}
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)
🔬 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
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Mutably borrows from an owned value. Read more
🔬 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
)