Exemplo n.º 1
0
        /// <summary>
        /// Sets the mode to a pin.
        /// </summary>
        /// <param name="pinNumber">The pin number in the controller's numbering scheme.</param>
        /// <param name="mode">The mode to be set.</param>
        public void SetPinMode(int pinNumber, PinMode mode)
        {
            int logicalPinNumber = GetLogicalPinNumber(pinNumber);

            if (!_openPins.Contains(logicalPinNumber))
            {
                throw new InvalidOperationException("Can not set a mode to a pin that is not open.");
            }
            if (!_driver.IsPinModeSupported(logicalPinNumber, mode))
            {
                throw new InvalidOperationException("The pin does not support the selected mode.");
            }
            _driver.SetPinMode(logicalPinNumber, mode);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the mode to a pin.
        /// </summary>
        /// <param name="pinNumber">The pin number in the controller's numbering scheme.</param>
        /// <param name="mode">The mode to be set.</param>
        public virtual void SetPinMode(int pinNumber, PinMode mode)
        {
            if (!IsPinOpen(pinNumber))
            {
                throw new InvalidOperationException($"Can not set a mode to pin {pinNumber} because it is not open.");
            }

            int logicalPinNumber = GetLogicalPinNumber(pinNumber);

            if (!IsPinModeSupported(pinNumber, mode))
            {
                throw new InvalidOperationException($"Pin {pinNumber} does not support mode {mode}.");
            }

            if (_openPins.TryGetValue(pinNumber, out var desired) && desired.HasValue)
            {
                _driver.SetPinMode(logicalPinNumber, mode, desired.Value);
            }
            else
            {
                _driver.SetPinMode(logicalPinNumber, mode);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the mode to a pin.
        /// </summary>
        /// <param name="pinNumber">The pin number in the controller's numbering scheme.</param>
        /// <param name="mode">The mode to be set.</param>
        public virtual void SetPinMode(int pinNumber, PinMode mode)
        {
            if (!IsPinOpen(pinNumber))
            {
                throw new InvalidOperationException($"Can not set a mode to pin {pinNumber} because it is not open.");
            }

            int logicalPinNumber = GetLogicalPinNumber(pinNumber);

            if (!IsPinModeSupported(pinNumber, mode))
            {
                throw new InvalidOperationException($"Pin {pinNumber} does not support mode {mode}.");
            }

            _driver.SetPinMode(logicalPinNumber, mode);
        }