/// <summary> /// Disposes this instance and closes all open pins associated with this controller. /// </summary> /// <param name="disposing">True to dispose all instances, false to dispose only unmanaged resources</param> protected virtual void Dispose(bool disposing) { foreach (int pin in _openPins) { // The list contains the pin in the current NumberingScheme ClosePinCore(pin); } _openPins.Clear(); _driver?.Dispose(); _driver = null !; }
/// <summary> /// Initializes new instance of GpioController that will use the specified numbering scheme and driver. /// </summary> /// <param name="numberingScheme">The numbering scheme used to represent pins provided by the controller.</param> /// <param name="driver">The driver that manages all of the pin operations for the controller.</param> public GpioController(PinNumberingScheme numberingScheme, GpioDriver driver) { _driver = driver; NumberingScheme = numberingScheme; _openPins = new HashSet <int>(); }
/// <summary> /// Initializes a new instance of the <see cref="GpioController"/> class that will use the specified numbering scheme and driver. /// </summary> /// <param name="numberingScheme">The numbering scheme used to represent pins provided by the controller.</param> /// <param name="driver">The driver that manages all of the pin operations for the controller.</param> public GpioController(PinNumberingScheme numberingScheme, GpioDriver driver) { _driver = driver; NumberingScheme = numberingScheme; _openPins = new ConcurrentDictionary <int, PinValue?>(); }