예제 #1
0
        public Task SetPinAsync(int pinNumber, PinValue value)
        {
            if (!gpioController.IsPinOpen(pinNumber))
            {
                gpioController.OpenPin(pinNumber, PinMode.Output);
            }

            gpioController.Write(pinNumber, value);

            return(Task.CompletedTask);
        }
예제 #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);

            _openPins[pinNumber] = value;

            if (_driver.GetPinMode(logicalPinNumber) != PinMode.Output)
            {
                return;
            }

            _driver.Write(logicalPinNumber, value);
        }
예제 #3
0
 /// <summary>
 /// Writes a value to a pin.
 /// </summary>
 /// <param name="pinNumber">The pin number in the driver's logical numbering scheme.</param>
 /// <param name="value">The value to be written to the pin.</param>
 protected internal abstract void Write(int pinNumber, PinValue value);
예제 #4
0
 private extern void WriteNative(PinValue value);
 /// <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)
 {
     NativeWrite(pinNumber, (byte)value);
 }