Exemplo n.º 1
0
        /// <summary>
        /// Writes a value to a pin.
        /// </summary>
        /// <param name="pinNumber">The pin number in the controller's numbering scheme.</param>
        /// <param name="value">The value to be written to the pin.</param>
        public void Write(int pinNumber, PinValue value)
        {
            int logicalPinNumber = GetLogicalPinNumber(pinNumber);

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

            int logicalPinNumber = GetLogicalPinNumber(pinNumber);

            if (_driver.GetPinMode(logicalPinNumber) != PinMode.Output)
            {
                throw new InvalidOperationException($"Can not write to pin {logicalPinNumber} because it is not set to Output mode.");
            }

            _driver.Write(logicalPinNumber, value);
        }