Пример #1
0
        /// <summary>
        /// Gets the Broadcom GPIO pin number form the Raspberry Pi pin number
        /// </summary>
        /// <param name="pinNumber">The Raspberry Pi pin number</param>
        /// <returns>The equivalent Broadcom ID</returns>
        private static BroadcomPinNumber ConvertToBroadcom(RaspberryPinNumber pinNumber)
        {
            switch (pinNumber)
            {
            case RaspberryPinNumber.Seven:
                return(BroadcomPinNumber.Four);

            case RaspberryPinNumber.Zero:
                return(BroadcomPinNumber.Seventeen);

            case RaspberryPinNumber.One:
                return(BroadcomPinNumber.Eighteen);

            case RaspberryPinNumber.Two:
                return(BroadcomPinNumber.TwentyOne);

            case RaspberryPinNumber.Three:
                return(BroadcomPinNumber.TwentyTwo);

            case RaspberryPinNumber.Four:
                return(BroadcomPinNumber.TwentyThree);

            case RaspberryPinNumber.Five:
                return(BroadcomPinNumber.TwentyFour);

            case RaspberryPinNumber.Six:
                return(BroadcomPinNumber.TwentyFive);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #2
0
 /// <summary>
 /// Closes a GPIO channel
 /// </summary>
 /// <param name="pinNumber">The Raspberry Pi pin number to configure</param>
 public void CloseChannel(RaspberryPinNumber pinNumber)
 {
     this.CloseChannel(ConvertToBroadcom(pinNumber));
 }
Пример #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(RaspberryPinNumber pinNumber)
 {
     return(this.ReadValue(ConvertToBroadcom(pinNumber)));
 }
Пример #4
0
 /// <summary>
 /// Configures a GPIO channel for use
 /// </summary>
 /// <param name="pinNumber">The Raspberry Pi pin number to configure</param>
 /// <param name="direction">The direction to configure the pin for</param>
 public void SetupChannel(RaspberryPinNumber pinNumber, Direction direction)
 {
     this.SetupChannel(ConvertToBroadcom(pinNumber), direction);
 }
Пример #5
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(RaspberryPinNumber pinNumber, bool value)
 {
     this.OutputValue(ConvertToBroadcom(pinNumber), value);
 }
Пример #6
0
 /// <summary>
 /// Configures a GPIO channel for use
 /// </summary>
 /// <param name="pinNumber">The Raspberry Pi pin number to configure</param>
 /// <param name="direction">The direction to configure the pin for</param>
 public void SetupChannel(RaspberryPinNumber pinNumber, Direction direction)
 {
     this.SetupChannel(ConvertToBroadcom(pinNumber), direction);
 }
Пример #7
0
        /// <summary>
        /// Gets the Broadcom GPIO pin number form the Raspberry Pi pin number
        /// </summary>
        /// <param name="pinNumber">The Raspberry Pi pin number</param>
        /// <returns>The equivalent Broadcom ID</returns>
        private static BroadcomPinNumber ConvertToBroadcom(RaspberryPinNumber pinNumber)
        {
            switch (pinNumber)
            {
                case RaspberryPinNumber.Seven:
                    return BroadcomPinNumber.Four;

                case RaspberryPinNumber.Zero:
                    return BroadcomPinNumber.Seventeen;

                case RaspberryPinNumber.One:
                    return BroadcomPinNumber.Eighteen;

                case RaspberryPinNumber.Two:
                    return BroadcomPinNumber.TwentyOne;

                case RaspberryPinNumber.Three:
                    return BroadcomPinNumber.TwentyTwo;

                case RaspberryPinNumber.Four:
                    return BroadcomPinNumber.TwentyThree;

                case RaspberryPinNumber.Five:
                    return BroadcomPinNumber.TwentyFour;

                case RaspberryPinNumber.Six:
                    return BroadcomPinNumber.TwentyFive;

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
Пример #8
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(RaspberryPinNumber pinNumber)
 {
     return this.ReadValue(ConvertToBroadcom(pinNumber));
 }
Пример #9
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(RaspberryPinNumber pinNumber, bool value)
 {
     this.OutputValue(ConvertToBroadcom(pinNumber), value);
 }
Пример #10
0
 /// <summary>
 /// Closes a GPIO channel
 /// </summary>
 /// <param name="pinNumber">The Raspberry Pi pin number to configure</param>
 public void CloseChannel(RaspberryPinNumber pinNumber)
 {
     this.CloseChannel(ConvertToBroadcom(pinNumber));
 }