Ejemplo n.º 1
0
        /// <summary>
        /// Gets the Broadcom GPIO pin number form the physical pin number
        /// </summary>
        /// <param name="pinNumber">The physical pin number</param>
        /// <returns>The equivalent Broadcom ID</returns>
        private static BroadcomPinNumber ConvertToBroadcom(PhysicalPinNumber pinNumber)
        {
            switch (pinNumber)
            {
                case PhysicalPinNumber.Seven:
                    return BroadcomPinNumber.Four;

                case PhysicalPinNumber.Eleven:
                    return BroadcomPinNumber.Seventeen;

                case PhysicalPinNumber.Twelve:
                    return BroadcomPinNumber.Eighteen;

                case PhysicalPinNumber.Thirteen:
                    return BroadcomPinNumber.TwentyOne;

                case PhysicalPinNumber.Fifteen:
                    return BroadcomPinNumber.TwentyTwo;

                case PhysicalPinNumber.Sixteen:
                    return BroadcomPinNumber.TwentyThree;

                case PhysicalPinNumber.Eighteen:
                    return BroadcomPinNumber.TwentyFour;

                case PhysicalPinNumber.TwentyTwo:
                    return BroadcomPinNumber.TwentyFive;

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Configures a GPIO channel for use
 /// </summary>
 /// <param name="pinNumber">The physical pin number to configure</param>
 /// <param name="direction">The direction to configure the pin for</param>
 public void SetupChannel(PhysicalPinNumber pinNumber, Direction direction)
 {
     this.SetupChannel(ConvertToBroadcom(pinNumber), direction);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Reads a value form a GPIO pin
 /// </summary>
 /// <param name="pinNumber">The pin number to read</param>
 /// <returns>The value at that pin</returns>
 /// <exception cref="InvalidOperationException">
 /// Thrown when an attempt to use an incorrectly configured channel is made
 /// </exception>
 public bool ReadValue(PhysicalPinNumber pinNumber)
 {
     return this.ReadValue(ConvertToBroadcom(pinNumber));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Outputs a value to a GPIO pin
 /// </summary>
 /// <param name="pinNumber">The pin number to use</param>
 /// <param name="value">The value to output</param>
 /// <exception cref="InvalidOperationException">
 /// Thrown when an attempt to use an incorrectly configured channel is made
 /// </exception>
 public void OutputValue(PhysicalPinNumber pinNumber, bool value)
 {
     this.OutputValue(ConvertToBroadcom(pinNumber), value);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Reads a value form a GPIO pin
 /// </summary>
 /// <param name="pinNumber">The pin number to read</param>
 /// <returns>The value at that pin</returns>
 /// <exception cref="InvalidOperationException">
 /// Thrown when an attempt to use an incorrectly configured channel is made
 /// </exception>
 public bool ReadValue(PhysicalPinNumber pinNumber)
 {
     return(this.ReadValue(ConvertToBroadcom(pinNumber)));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Outputs a value to a GPIO pin
 /// </summary>
 /// <param name="pinNumber">The pin number to use</param>
 /// <param name="value">The value to output</param>
 /// <exception cref="InvalidOperationException">
 /// Thrown when an attempt to use an incorrectly configured channel is made
 /// </exception>
 public void OutputValue(PhysicalPinNumber pinNumber, bool value)
 {
     this.OutputValue(ConvertToBroadcom(pinNumber), value);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Closes a GPIO channel
 /// </summary>
 /// <param name="pinNumber">The physical pin number to configure</param>
 public void CloseChannel(PhysicalPinNumber pinNumber)
 {
     this.CloseChannel(ConvertToBroadcom(pinNumber));
 }