Skip to content

Raspberry.IO.GeneralPurpose.PinConfiguration

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

Represents the configuration of a pin.

Introduction

The configuration of a pin may be defined either by using OutputPinConfiguration, InputPinConfiguration or SwitchInputPinConfiguration class initializers and properties, or in a more declarative way, using provided extension methods on ProcessorPin and ConnectorPin. The second option should be preferred for code readability reasons.

Declarative Configuration

Input

static InputPinConfiguration PinConfigurationExtensionMethods.Input(ProcessorPin processPin);
static InputPinConfiguration PinConfigurationExtensionMethods.Input(ConnectorPin connectorPin);

Creates an InputPinConfiguration from a pin number.

Parameters
  • processorPin: the pin, as numbered on processor
  • connectorPin: the pin, as numbered on Raspberry Pi connector
Samples
var input1 = ProcessorPin.P01.Input();
var input2 = ConnectorPin.P1Pin11.Input();

Output

static OutputPinConfiguration PinConfigurationExtensionMethods.Output(ProcessorPin pin);
static OutputPinConfiguration PinConfigurationExtensionMethods.Output(ConnectorPin pin);

Creates an OutputPinConfiguration from a pin number.

Parameters
  • processorPin: the pin, as numbered on processor
  • connectorPin: the pin, as numbered on Raspberry Pi connector
Samples
var output1 = ProcessorPin.P02.Output();
var output2 = ConnectorPin.P1Pin13.Output();

Switch

static SwitchInputPinConfiguration Switch(this InputPinConfiguration configuration);

Indicates an input pin must act as a switch: its state only changes when the pin is released and its status become true.

Parameters
  • configuration: the input pin configuration
Samples
var button = ConnectorPin.P1Pin11.Input().Switch();

Name

static T Name<T>(this T configuration, string name) where T : PinConfiguration;

Affects a unique name to the specified pin.

Parameters
  • configuration: the pin configuration
  • name: the unique name of the pin
Samples
var led1 = ConnectorPin.P1Pin13.Output().Name("yellow");

Clone this wiki locally