Struct cupi_shift::Shifter
[−]
[src]
pub struct Shifter { pub data: PinOutput, pub latch: PinOutput, pub clock: PinOutput, // some fields omitted }
Fields
data: PinOutput
latch: PinOutput
clock: PinOutput
Methods
impl Shifter
[src]
fn new(data_pin: usize, latch_pin: usize, clock_pin: usize) -> Shifter
Returns a new Shifter
object that will shift out data using the given
data_pin, latch_pin, and clock_pin. To use a Shifter
instance
you must first call the add()
method for each shift register you
have connected in sequence.
Note about pin numbering
cupi
currently uses GPIO pin numbering. So pin 40 (very last pin on
the Raspberry Pi 2) is actually pin 29. You can refer to this image to
figure out which pin is which:
fn add(&mut self, pins: u8) -> usize
Adds a new shift register to this Shifter and returns a reference to it. You must specify the number of pins.
fn set(&mut self, sr_index: usize, data: usize, apply: bool)
Sets the data on the shift register at the given sr_index.
If apply is true
the change will be applied immediately.
fn set_pin_high(&mut self, sr_index: usize, pin: u8, apply: bool)
Sets the given pin HIGH on the shift register at the given sr_index.
If apply is true
the change will be applied immediately.
fn set_pin_low(&mut self, sr_index: usize, pin: u8, apply: bool)
Sets the given pin LOW on the shift register at the given sr_index.
If apply is true
the change will be applied immediately.
fn invert(&mut self)
This function will invert all logic so that HIGH is LOW and LOW is HIGH. Very convenient if you made a (very common) mistake in your wiring or you need reversed logic for other reasons.
fn apply(&mut self)
Applies all current shift register states by shifting out all the stored data in each ShiftRegister object.