Skip to main content

Pins

Trait Pins 

Source
pub trait Pins {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
    fn setup(&mut self, pin: Pin, mode: PinMode) -> Result<()>;
    fn clear(&mut self, pin: Pin) -> Result<()>;
    fn clear_all(&mut self) -> Result<()>;
    fn read(&mut self, pin: Pin) -> Result<bool>;
    fn write(&mut self, pin: Pin, v: bool) -> Result<()>;
}
Expand description

Generic abstraction over a GPIO chip to back all EndBASIC commands.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Returns self as &dyn Any to allow downcasting to a concrete type.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Returns self as &mut dyn Any to allow downcasting to a concrete type.

Source

fn setup(&mut self, pin: Pin, mode: PinMode) -> Result<()>

Configures the pin as either input or output (per mode).

This lazily initialies the GPIO chip as well on the first pin setup.

It is OK to set up a pin multiple times without calling clear() in-between.

Source

fn clear(&mut self, pin: Pin) -> Result<()>

Resets a given pin to its default state.

Source

fn clear_all(&mut self) -> Result<()>

Resets all pins to their default state.

Source

fn read(&mut self, pin: Pin) -> Result<bool>

Reads the value of the given pin, which must have been previously setup as an input pin.

Source

fn write(&mut self, pin: Pin, v: bool) -> Result<()>

Writes v to the given pin, which must have been previously setup as an output pin.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§