/// <summary> /// Initializes a new instance of the <see cref="GpioPin"/> class. /// </summary> /// <param name="wiringPiPinNumber">The wiring pi pin number.</param> /// <param name="headerPinNumber">The header pin number.</param> private GpioPin(WiringPiPin wiringPiPinNumber, int headerPinNumber) { PinNumber = (int)wiringPiPinNumber; WiringPiPinNumber = wiringPiPinNumber; BcmPinNumber = GpioController.WiringPiToBcmPinNumber((int)wiringPiPinNumber); HeaderPinNumber = headerPinNumber; Header = (PinNumber >= 17 && PinNumber <= 20) ? GpioHeader.P5 : GpioHeader.P1; }
/// <summary> /// Gets the <see cref="GpioPin"/> with the specified Wiring Pi pin number. /// </summary> /// <value> /// The <see cref="GpioPin"/>. /// </value> /// <param name="pinNumber">The pin number.</param> /// <returns>A reference to the GPIO pin.</returns> public GpioPin this[WiringPiPin pinNumber] { get { if (pinNumber == WiringPiPin.Unknown) { throw new InvalidOperationException("You can not get an unknown WiringPi pin."); } return(Pins.First(p => p.WiringPiPinNumber == pinNumber)); } }
public static string GetStatus(WiringPiPin wiringPiPin) { var pin = Pi.Gpio[wiringPiPin]; return($"WiringPiPinNumber: {pin.WiringPiPinNumber} BcmPinNumber: {pin.BcmPinNumber} Name:{pin.Name} Mode:{pin.PinMode} SoftPwmValue:{pin.SoftPwmValue}"); }
private GpioPin toGpioPin(WiringPiPin pin) => gpio.Pins[toPinId(pin)];
private int toPinId(WiringPiPin pin) => WiringPi.WpiPinToGpio((int)pin);
/// <summary> /// Gets the <see cref="GpioPin"/> with the specified Wiring Pi pin number. /// </summary> /// <value> /// The <see cref="GpioPin"/>. /// </value> /// <param name="pinNumber">The pin number.</param> /// <returns>A reference to the GPIO pin</returns> public GpioPin this[WiringPiPin pinNumber] => PinsByWiringPiPinNumber[pinNumber];
/// <summary> /// Gets the <see cref="GpioPin"/> with the specified pin number. /// </summary> /// <value> /// The <see cref="GpioPin"/>. /// </value> /// <param name="pinNumber">The pin number.</param> /// <returns></returns> public GpioPin this[WiringPiPin pinNumber] => _registeredPins[pinNumber];