Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SeesawGpioDriver"/> class that will use the specified Seesaw device.
        /// </summary>
        /// <param name="seesawDevice">The Seesaw device used fir communicating with the Gpio.</param>
        public SeesawGpioDriver(Seesaw seesawDevice)
        {
            _seesawDevice = seesawDevice;

            if (!_seesawDevice.HasModule(Seesaw.SeesawModule.Gpio))
            {
                throw new InvalidOperationException($"The hardware on I2C Bus {seesawDevice.I2cDevice.ConnectionSettings.BusId}, Address 0x{seesawDevice.I2cDevice.ConnectionSettings.DeviceAddress:X2} does not support Adafruit SeeSaw GPIO functionality");
            }

            _openPins = new Dictionary <int, PinMode>();
        }
Esempio n. 2
0
        /// <inheritdoc/>
        protected override void Dispose(bool disposing)
        {
            foreach (int pinNumber in _openPins.Keys)
            {
                ClosePin(pinNumber);
            }

            _openPins.Clear();
            _seesawDevice?.Dispose();
            _seesawDevice = null !;
            base.Dispose(disposing);
        }