-
Notifications
You must be signed in to change notification settings - Fork 139
Raspberry.IO.GeneralPurpose.PinConfiguration
Represents the configuration of a pin.
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.
Depending on pin direction, the following operations may be chained one after the other.
static InputPinConfiguration PinConfigurationExtensionMethods.Input(ProcessorPin processPin);
static InputPinConfiguration PinConfigurationExtensionMethods.Input(ConnectorPin connectorPin);
Creates an InputPinConfiguration
from a pin number.
-
processorPin
: the pin, as numbered on processor -
connectorPin
: the pin, as numbered on Raspberry Pi connectors
var input1 = ProcessorPin.P01.Input();
var input2 = ConnectorPin.P1Pin11.Input();
static OutputPinConfiguration PinConfigurationExtensionMethods.Output(ProcessorPin pin);
static OutputPinConfiguration PinConfigurationExtensionMethods.Output(ConnectorPin pin);
Creates an OutputPinConfiguration
from a pin number.
-
processorPin
: the pin, as numbered on processor -
connectorPin
: the pin, as numbered on Raspberry Pi connectors
var output1 = ProcessorPin.P02.Output();
var output2 = ConnectorPin.P1Pin13.Output();
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
.
-
configuration
: the input pin configuration
var button = ConnectorPin.P1Pin11.Input().Switch();
static T Name<T>(this T configuration, string name) where T : PinConfiguration;
Affects a unique name to the specified pin.
-
configuration
: the pin configuration -
name
: the unique name of the pin
var led1 = ConnectorPin.P1Pin13.Output().Name("yellow");
static T Revert<T>(this T configuration) where T : PinConfiguration;
Reverts the meaning of the pin status: if set, when hardware pin is down, logical pin is true
; when hardware pin is up, logical pin is false
.
-
configuration
: the pin configuration
var led1 = ConnectorPin.P1Pin13.Output().Revert();
static OutputPinConfiguration Enable(this OutputPinConfiguration configuration);
static OutputPinConfiguration Enable(this SwitchInputPinConfiguration configuration);
Indicates the specified pin must be enabled (set to true
) when it is added to the connection. This operation cannot be done on InputPinConfiguration
.
-
configuration
: the pin configuration
var led1 = ConnectorPin.P1Pin13.Output().Enable();
static OutputPinConfiguration Disable(this OutputPinConfiguration configuration);
static OutputPinConfiguration Disable(this SwitchInputPinConfiguration configuration);
Indicates the specified pin must be diisabled(set to false
) when it is added to the connection. This operation cannot be done on InputPinConfiguration
.
-
configuration
: the pin configuration
var led1 = ConnectorPin.P1Pin13.Output().Disable();