Exemplo n.º 1
0
 /// <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;
 }
Exemplo n.º 2
0
        /// <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));
            }
        }
Exemplo n.º 3
0
        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}");
        }
Exemplo n.º 4
0
 private GpioPin toGpioPin(WiringPiPin pin) => gpio.Pins[toPinId(pin)];
Exemplo n.º 5
0
 private int toPinId(WiringPiPin pin) => WiringPi.WpiPinToGpio((int)pin);
Exemplo n.º 6
0
 /// <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];
Exemplo n.º 7
0
 /// <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];