[][src]Struct analog_multiplexer::Multiplexer

pub struct Multiplexer<Pins> {
    pub pins: Pins,
    pub num_channels: u8,
    pub active_channel: u8,
    pub enabled: bool,
}

Provides an interface for setting the active channel and enabling/disabling an 8-channel (74HC4051) or 16-channel (74HC4067) analog multiplexer. It also keeps track of which channel is currently active (active_channel) and provides a convenient num_channels field that can be used to iterate over all the multiplexer's channels.

Fields

pins: Pinsnum_channels: u8active_channel: u8enabled: bool

Implementations

impl<Pins: Output> Multiplexer<Pins>[src]

pub fn new(pins: Pins) -> Self[src]

Given a 5 or 4-member tuple, (s0, s1, s2, s3, en) or (s0, s1, s2, en) where every member is an OutputPin, returns a new instance of Multiplexer for a 16-channel or 8-channel analog multiplexer, respectively.

NOTE: Some multiplexers label S0-S3 as A-D. They're the same thing.

pub fn set_channel(&mut self, channel: u8)[src]

Sets the current active channel on the multiplexer (0 up to num_channels) and records that state in self.active_channel

pub fn enable(&mut self)[src]

Enables the multiplexer and sets self.enabled = true

pub fn disable(&mut self)[src]

Disables the multiplexer and sets self.enabled = false

Auto Trait Implementations

impl<Pins> Send for Multiplexer<Pins> where
    Pins: Send

impl<Pins> Sync for Multiplexer<Pins> where
    Pins: Sync

impl<Pins> Unpin for Multiplexer<Pins> where
    Pins: Unpin

Blanket Implementations

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

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

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

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

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

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.

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.