ShiftRegister Class

Definition

Generic shift register implementation. Supports multiple register lengths. Compatible with SN74HC595, MBI5027 and MBI5168, for example. Supports SPI and GPIO control.

public class ShiftRegister : IDisposable
public class ShiftRegister : IDisposable, Iot.Device.Multiplexing.IOutputSegment
type ShiftRegister = class
    interface IDisposable
type ShiftRegister = class
    interface IDisposable
    interface IOutputSegment
Public Class ShiftRegister
Implements IDisposable
Public Class ShiftRegister
Implements IDisposable, IOutputSegment
Inheritance
ShiftRegister
Derived
Implements

Constructors

ShiftRegister(ShiftRegisterPinMapping, Int32, GpioController, Boolean)

Initialize a new shift register connected through GPIO.

ShiftRegister(SpiDevice, Int32)

Initialize a new shift register device connected through SPI. Uses 3 pins (SDI -> SDI, SCLK -> SCLK, CE0 -> LE)

Properties

BitLength

Bit length across all connected registers.

GpioController

GPIO controller.

Length

The length of the segment; the number of GPIO pins it exposes.

OutputEnable

Switch output register to high or low-impedance state. Enables or disables register outputs, but does not delete values. Requires use of GPIO controller.

SpiDevice

SPI device.

UsesGpio

Reports if shift register is connected with GPIO.

UsesSpi

Reports if shift register is connected with SPI.

Methods

Dispose()

Cleanup. Failing to dispose this class, especially when callbacks are active, may lead to undefined behavior.

Latch()

Latches values in data register to output pi. Requires use of GPIO controller.

ShiftBit(PinValue)

Writes PinValue value to storage register. This will shift existing values to the next storage slot. Does not latch. Requires use of GPIO controller.

ShiftByte(Byte, Boolean)

Shifts a byte -- 8 bits -- to the storage register. Assumes register bit length evenly divisible by 8. Pushes / overwrites any existing values. Latches by default.

ShiftClear()

Shifts zeros. Will dim all connected LEDs, for example. Assumes register bit length evenly divisible by 8. Supports GPIO controller or SPI device.

Write(Byte)

Writes discrete underlying bits to a virtual segment. Writes each bit, left to right. Least significant bit will written to index 0. Does not display output.

Write(ReadOnlySpan<Byte>)

Writes discrete underlying bits to a virtual output. Writes each byte, left to right. Least significant bit will written to index 0. Does not display output.

Explicit Interface Implementations

IOutputSegment.Display(CancellationToken)

Displays current state of segment. Segment is displayed at least until token receives a cancellation signal, possibly due to a specified duration expiring.

IOutputSegment.DisplayAsync(CancellationToken)

Displays current state of segment. Segment is displayed at least until token receives a cancellation signal, possibly due to a specified duration expiring.

IOutputSegment.Item[Int32]

Segment values.

IOutputSegment.TurnOffAll()

Clears shift register. Performs a latch.

IOutputSegment.Write(Int32, PinValue)

Writes a PinValue to a virtual segment. Does not display output.

Applies to