Class CharlieplexSegment
- Namespace
- Iot.Device.Multiplexing
- Assembly
- Iot.Device.Charlieplex.dll
Provides support for Charlieplex multiplexing. https://wikipedia.org/wiki/Charlieplexing
public class CharlieplexSegment : IOutputSegment
- Inheritance
-
CharlieplexSegment
- Implements
Constructors
CharlieplexSegment(int[], int, GpioController?, bool)
Initializes a new Charlieplex type that can be use for multiplex over a relatively small number of GPIO pins.
public CharlieplexSegment(int[] pins, int nodeCount = 0, GpioController? gpioController = null, bool shouldDispose = true)
Parameters
pinsint[]The set of pins to use.
nodeCountintThe count of nodes (like LEDs) that will be addressable. If 0, then the Charlieplex maximum is used for the pins provided (n^2-n).
gpioControllerGpioControllerThe GPIO Controller used for interrupt handling.
shouldDisposeboolTrue (the default) if the GPIO controller shall be disposed when disposing this instance.
Properties
Length
The length of the segment; the number of GPIO pins it exposes.
public int Length { get; }
Property Value
NodeCount
The number of nodes (like LEDs) that can be addressed.
public int NodeCount { get; }
Property Value
Methods
Display(CancellationToken)
Displays nodes in their current configuration for the specified duration.
public void Display(CancellationToken token)
Parameters
tokenCancellationTokenCancellationToken used to signal when method should exit.
Dispose()
Cleanup. Failing to dispose this class, especially when callbacks are active, may lead to undefined behavior.
public void Dispose()
GetNodes(int[], int)
Provides the set of Charlie nodes given the set of pins and the count provided. If count = 0, then the Charlieplex maximum is used for the pins provided (n^2-n).
public static CharlieplexSegmentNode[] GetNodes(int[] pins, int nodeCount = 0)
Parameters
pinsint[]The pins to use for the segment.
nodeCountintThe number of nodes to use. Default is the Charlieplex maximum.
Returns
Write(int, PinValue, TimeSpan)
Write a PinValue to a node, to update Charlieplex segment. Address scheme is 0-based. Given 8 nodes, addresses would be 0-7. Displays nodes in their updated configuration for the specified duration.
public void Write(int node, PinValue value, TimeSpan duration = default)