-
Notifications
You must be signed in to change notification settings - Fork 136
Raspberry.IO.GeneralPurpose.GpioConnection
The GpioConnection
class is used in conjunction with PinConfiguration
in order to manage connection to a consistent set of pins (either input or output). Please refer to PinConfiguration documentation for detailed information concerning configuration of GPIO pins.
Since GpioConnection
implements the IDisposable
interface, it must be closed once used, by calling either IDisposable.Dispose
or Close
.
The following initializers may be used to create an instance of GpioConnection
:
GpioConnection(params PinConfiguration[] pins);
GpioConnection(IEnumerable<PinConfiguration> pins);
GpioConnection(IConnectionDriver driver, params PinConfiguration[] pins);
GpioConnection(IConnectionDriver driver, IEnumerable<PinConfiguration> pins);
GpioConnection(bool open, params PinConfiguration[] pins);
GpioConnection(bool open, IEnumerable<PinConfiguration> pins);
GpioConnection(bool open, IConnectionDriver driver, params PinConfiguration[] pins);
GpioConnection(bool open, IConnectionDriver driver, IEnumerable<PinConfiguration> pins);
With:
-
pins
: configurations of pins that must be allocated when connection is established. -
driver
: the driver that must be used. If omitted or set tonull
, a default driver is chosen, depending on.config
file. -
open
: a boolean value indicating whether connection must be opened on initialization or not. Default istrue
.
IConnectionDriver Driver { get; }
The active driver. Should not be used for normal operations.
bool IsOpened { get; }
A boolean value indicating whether the connection is opened.
ConnectedPins Pins { get; }
A container of connected pins, providing access to each pin status and event registration.
bool this[ProcessorPin processorPin] { get; set; }
bool this[ConnectorPin connectorPin] { get; set; }
bool this[PinConfiguration pinConfiguration] { get; set; }
bool this[string pinName] { get; set; }
Gets or sets the state of a pin. An exception is thrown if attempt is made to set the value of an input pin. Indexers are available for use with:
-
processorPin
: a pin, as numbered on processor -
connectorPin
: a pin, as numbered on Raspberry Pi P1 or P5 connector -
pinConfiguration
: a pin configuration, as defined by PinConfiguration -
pinName
: a pin name, if defined in pin configuration