GHIElectronics.UAP.Shields.FEZHAT.ReadDigital C# (CSharp) Method

ReadDigital() public method

Reads the current state of the given pin.
public ReadDigital ( DigitalPin pin ) : bool
pin DigitalPin The pin to read.
return bool
        public bool ReadDigital(DigitalPin pin) {
            if (!Enum.IsDefined(typeof(DigitalPin), pin)) throw new ArgumentException(nameof(pin));

            var gpioPin = pin == DigitalPin.DIO16 ? this.dio16 : this.dio26;

            if (gpioPin.GetDriveMode() != GpioPinDriveMode.Input)
                gpioPin.SetDriveMode(GpioPinDriveMode.Input);

            return gpioPin.Read() == GpioPinValue.High;
        }