/// <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); }
/// <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 pin {logicalPinNumber} because it is not open."); } if (!_driver.IsPinModeSupported(logicalPinNumber, mode)) { throw new InvalidOperationException($"Pin {pinNumber} does not support mode {mode}."); } _driver.SetPinMode(logicalPinNumber, mode); }
/// <summary> /// Checks if a pinMode is supported by a pin. /// </summary> /// <param name="pinNumber">The pin number in the controller's numbering scheme.</param> /// <param name="mode">The mode to check</param> /// <returns>True if the mode is supported by the pin. False otherwise.</returns> public bool IsPinModeSupported(int pinNumber, PinMode mode) { int logicalPinNumber = ConvertToLogicalPinNumber(pinNumber); return(_driver.IsPinModeSupported(logicalPinNumber, mode)); }
/// <summary> /// Checks if a pin supports a specific mode. /// </summary> /// <param name="pinNumber">The pin number in the controller's numbering scheme.</param> /// <param name="mode">The mode to check.</param> /// <returns>The status if the pin supports the mode.</returns> public virtual bool IsPinModeSupported(int pinNumber, PinMode mode) { int logicalPinNumber = GetLogicalPinNumber(pinNumber); return(_driver.IsPinModeSupported(logicalPinNumber, mode)); }