Skip to content

Raspberry.IO.GeneralPurpose.GpioConnection

raspberry-sharp edited this page Oct 14, 2012 · 23 revisions

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.

Initializers

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 to null, a default driver is chosen, depending on .config file.
  • open: a boolean value indicating whether connection must be opened on initialization or not. Default is true.

Properties

Driver

IConnectionDriver Driver { get; }

The active driver. Should not be used for normal operations.

IsOpened

bool IsOpened { get; }

A boolean value indicating whether the connection is opened.

Pins

ConnectedPins Pins { get; }

A container of connected pins, providing access to each pin status and event registration.

this (Indexers)

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
Clone this wiki locally