Skip to main content

Class IPinExtensions

Extension methods for the IPin interface

Assembly: Meadow.Contracts.dll
View Source
Declaration
public static class IPinExtensions

Methods

Supports<TChannel>(IPin)

Checks if the pin supports the specified channel type.

View Source
Declaration
public static bool Supports<TChannel>(this IPin pin) where TChannel : IChannelInfo
Returns

System.Boolean: True if the pin supports the specified channel type; otherwise, false.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to check.
Type Parameters
NameDescription
TChannelThe type of channel to check for.

Supports<TChannel>(IPin, Func<TChannel, bool>)

Checks if the pin supports the specified channel type based on a condition.

View Source
Declaration
public static bool Supports<TChannel>(this IPin pin, Func<TChannel, bool> where) where TChannel : IChannelInfo
Returns

System.Boolean: True if the pin supports the specified channel type based on the condition; otherwise, false.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to check.
System.Func<<TChannel>,System.Boolean>whereThe condition to apply.
Type Parameters
NameDescription
TChannelThe type of channel to check for.

CreateDigitalOutputPort(IPin, bool)

Creates a digital output port for the specified pin.

View Source
Declaration
public static IDigitalOutputPort CreateDigitalOutputPort(this IPin pin, bool initialState = false)
Returns

Meadow.Hardware.IDigitalOutputPort: The created digital output port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create a digital output port for.
System.BooleaninitialStateThe initial state of the digital output port (default is false).

CreateDigitalInterruptPort(IPin, InterruptMode, ResistorMode, TimeSpan, TimeSpan)

Creates a digital interrupt port for the specified pin with specified configurations.

View Source
Declaration
public static IDigitalInterruptPort CreateDigitalInterruptPort(this IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, TimeSpan debounceDuration, TimeSpan glitchDuration)
Returns

Meadow.Hardware.IDigitalInterruptPort: The created digital interrupt port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create a digital interrupt port for.
Meadow.Hardware.InterruptModeinterruptModeThe interrupt mode for the digital interrupt port.
Meadow.Hardware.ResistorModeresistorModeThe resistor mode for the digital interrupt port.
System.TimeSpandebounceDurationThe debounce duration for the digital interrupt port.
System.TimeSpanglitchDurationThe glitch duration for the digital interrupt port.

CreateDigitalInputPort(IPin, ResistorMode)

Creates a digital input port for the specified pin with the specified resistor mode.

View Source
Declaration
public static IDigitalInputPort CreateDigitalInputPort(this IPin pin, ResistorMode resistorMode = ResistorMode.Disabled)
Returns

Meadow.Hardware.IDigitalInputPort: The created digital input port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create a digital input port for.
Meadow.Hardware.ResistorModeresistorModeThe resistor mode for the digital input port (default is ResistorMode.Disabled).

CreateDigitalInterruptPort(IPin, InterruptMode, ResistorMode)

Creates a digital interrupt port for the specified pin with the specified configurations.

View Source
Declaration
public static IDigitalInterruptPort CreateDigitalInterruptPort(this IPin pin, InterruptMode interruptMode, ResistorMode resistorMode = ResistorMode.Disabled)
Returns

Meadow.Hardware.IDigitalInterruptPort: The created digital interrupt port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create a digital interrupt port for.
Meadow.Hardware.InterruptModeinterruptModeThe interrupt mode for the digital interrupt port.
Meadow.Hardware.ResistorModeresistorModeThe resistor mode for the digital interrupt port (default is ResistorMode.Disabled).

CreateAnalogInputPort(IPin, int, TimeSpan, Voltage)

Creates an analog input port for the specified pin with the given sample count, sample interval, and reference voltage.

View Source
Declaration
public static IAnalogInputPort CreateAnalogInputPort(this IPin pin, int sampleCount, TimeSpan sampleInterval, Voltage referenceVoltage)
Returns

Meadow.Hardware.IAnalogInputPort: The created analog input port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create an analog input port for.
System.Int32sampleCountThe number of samples to take during each reading.
System.TimeSpansampleIntervalThe interval between each sample.
Meadow.Units.VoltagereferenceVoltageThe reference voltage for the analog input port.

CreateAnalogInputPort(IPin, int)

Creates an analog input port for the specified pin with the default sample count and default settings.

View Source
Declaration
public static IAnalogInputPort CreateAnalogInputPort(this IPin pin, int sampleCount = 5)
Returns

Meadow.Hardware.IAnalogInputPort: The created analog input port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create an analog input port for.
System.Int32sampleCountThe number of samples to take during each reading (default is 5).

CreateAnalogOutputPort(IPin)

Creates an analog output port for the specified pin.

View Source
Declaration
public static IAnalogOutputPort CreateAnalogOutputPort(this IPin pin)
Returns

Meadow.Hardware.IAnalogOutputPort: The created analog output port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create an analog output port for.

CreatePwmPort(IPin, Frequency, float, bool)

Creates a PWM (Pulse Width Modulation) port for the specified pin with the given frequency, duty cycle, and inversion setting.

View Source
Declaration
public static IPwmPort CreatePwmPort(this IPin pin, Frequency frequency, float dutyCycle = 0.5, bool invert = false)
Returns

Meadow.Hardware.IPwmPort: The created PWM port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create a PWM port for.
Meadow.Units.FrequencyfrequencyThe frequency of the PWM signal.
System.SingledutyCycleThe duty cycle of the PWM signal (default is 0.5).
System.BooleaninvertWhether to invert the PWM signal (default is false).

CreateBiDirectionalPort(IPin, bool, InterruptMode, ResistorMode, PortDirectionType, TimeSpan, TimeSpan)

Creates a bidirectional interrupt port for the specified pin with the specified initial state, interrupt mode, resistor mode, initial direction, debounce duration, and glitch duration.

View Source
Declaration
public static IBiDirectionalInterruptPort CreateBiDirectionalPort(this IPin pin, bool initialState, InterruptMode interruptMode, ResistorMode resistorMode, PortDirectionType initialDirection, TimeSpan debounceDuration, TimeSpan glitchDuration)
Returns

Meadow.Hardware.IBiDirectionalInterruptPort: The created bidirectional interrupt port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create a bidirectional interrupt port for.
System.BooleaninitialStateThe initial state of the port.
Meadow.Hardware.InterruptModeinterruptModeThe interrupt mode for the port.
Meadow.Hardware.ResistorModeresistorModeThe resistor mode for the port.
Meadow.Hardware.PortDirectionTypeinitialDirectionThe initial direction of the port.
System.TimeSpandebounceDurationThe debounce duration for the port.
System.TimeSpanglitchDurationThe glitch duration for the port.

CreateBiDirectionalPort(IPin, bool, InterruptMode, ResistorMode, PortDirectionType)

Creates a bidirectional interrupt port for the specified pin with default settings.

View Source
Declaration
public static IBiDirectionalInterruptPort CreateBiDirectionalPort(this IPin pin, bool initialState = false, InterruptMode interruptMode = InterruptMode.None, ResistorMode resistorMode = ResistorMode.Disabled, PortDirectionType initialDirection = PortDirectionType.Input)
Returns

Meadow.Hardware.IBiDirectionalInterruptPort: The created bidirectional interrupt port.

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to create a bidirectional interrupt port for.
System.BooleaninitialStateThe initial state of the port (default is false).
Meadow.Hardware.InterruptModeinterruptModeThe interrupt mode for the port (default is InterruptMode.None).
Meadow.Hardware.ResistorModeresistorModeThe resistor mode for the port (default is ResistorMode.Disabled).
Meadow.Hardware.PortDirectionTypeinitialDirectionThe initial direction of the port (default is PortDirectionType.Input).