pub struct Multiplexer<Pins> {
pub pins: Pins,
pub num_channels: u8,
pub active_channel: u8,
pub enabled: bool,
}
Expand description
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: Pins
§num_channels: u8
§active_channel: u8
§enabled: bool
Implementations§
Source§impl<Pins: Output> Multiplexer<Pins>
impl<Pins: Output> Multiplexer<Pins>
Sourcepub fn new(pins: Pins) -> Self
pub fn new(pins: Pins) -> Self
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.
Sourcepub fn set_channel(&mut self, channel: u8)
pub fn set_channel(&mut self, channel: u8)
Sets the current active channel on the multiplexer
(0 up to num_channels
) and records that state in
self.active_channel
Auto Trait Implementations§
impl<Pins> Freeze for Multiplexer<Pins>where
Pins: Freeze,
impl<Pins> RefUnwindSafe for Multiplexer<Pins>where
Pins: RefUnwindSafe,
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,
impl<Pins> UnwindSafe for Multiplexer<Pins>where
Pins: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more