/// <summary>
        /// Dispose this instance and release managed resources.
        /// </summary>
        /// <param name="disposing">
        /// If set to <c>true</c> disposing and not finalizing.
        /// </param>
        private void Dispose(Boolean disposing)
        {
            if (this._isDisposed)
            {
                return;
            }

            if (this._registerSelectPort != null)
            {
                this._registerSelectPort.Dispose();
                this._registerSelectPort = null;
            }

            if (this._readWritePort != null)
            {
                this._readWritePort.Dispose();
                this._readWritePort = null;
            }

            if (this._enablePort != null)
            {
                this._enablePort.Dispose();
                this._enablePort = null;
            }

            if ((this._dataPorts != null) && (this._dataPorts.Length > 0))
            {
                for (Int32 i = 0; i < 8; i++)
                {
                    if (this._dataPorts[i] != null)
                    {
                        this._dataPorts[i].Dispose();
                    }
                }
                Array.Clear(this._dataPorts, 0, this._dataPorts.Length);
            }

            if (disposing)
            {
                GC.SuppressFinalize(this);
            }
            this._isDisposed = true;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioMemLcdTransferProvider"/>
        /// class with the mode flag, register select pin, read/write pin,
        /// enable pin, and data pins.
        /// </summary>
        /// <param name="fourBitMode">
        /// If set to true, switch to four bit mode instead of 8 bit mode.
        /// </param>
        /// <param name="rs">
        /// The number of the CPU pin that is connected to the RS (Register Select)
        /// pin on the LCD.
        /// </param>
        /// <param name="rw">
        /// The number of the CPU pin that is connected to the RW (Read/Write)
        /// pin on the LCD.
        /// </param>
        /// <param name="enable">
        /// The number of the CPU pin that is connected to the enable pin
        /// on the LCD.
        /// </param>
        /// <param name="d0">
        /// Data line 0.
        /// </param>
        /// <param name="d1">
        /// Data line 1.
        /// </param>
        /// <param name="d2">
        /// Data line 2.
        /// </param>
        /// <param name="d3">
        /// Data line 3.
        /// </param>
        /// <param name="d4">
        /// Data line 4.
        /// </param>
        /// <param name="d5">
        /// Data line 5.
        /// </param>
        /// <param name="d6">
        /// Data line 6.
        /// </param>
        /// <param name="d7">
        /// Data line 7.
        /// </param>
        /// <remarks>
        /// The display can be controlled using 4 or 8 data lines. If the former,
        /// omit the pin numbers for d0 to d3 and leave those lines disconnected.
        /// The RW pin can be tied to ground instead of connected to a pin on the
        /// Arduino; If so, omit it from this constructor's parameters.
        /// </remarks>
        /// <exception cref="ArgumentException">
        /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to
        /// <see cref="GpioPins.GPIO_NONE"/>.
        /// </exception>
        public GpioMemLcdTransferProvider(Boolean fourBitMode, GpioPins rs, GpioPins rw, GpioPins enable,
                                          GpioPins d0, GpioPins d1, GpioPins d2, GpioPins d3, GpioPins d4,
                                          GpioPins d5, GpioPins d6, GpioPins d7)
        {
            this._fourBitMode = fourBitMode;
            if (rs == GpioPins.GPIO_NONE)
            {
                throw new ArgumentException("rs");
            }

            this._registerSelectPort = new GpioMem(rs, PinMode.OUT);
            this._registerSelectPort.Provision();

            // We can save a pin by not using RW. Indicate by passing GpioPins.GPIO_NONE
            // instead of pin # (RW is optional).
            if (rw != GpioPins.GPIO_NONE)
            {
                this._readWritePort = new GpioMem(rw, PinMode.OUT);
                this._readWritePort.Provision();
            }

            if (enable == GpioPins.GPIO_NONE)
            {
                throw new ArgumentException("enable");
            }

            this._enablePort = new GpioMem(enable, PinMode.OUT);
            this._enablePort.Provision();

            GpioPins[] dataPins = { d0, d1, d2, d3, d4, d5, d6, d7 };
            this._dataPorts = new GpioMem[8];
            for (Int32 i = 0; i < 8; i++)
            {
                if (dataPins[i] == GpioPins.GPIO_NONE)
                {
                    this._dataPorts[i] = new GpioMem(dataPins[i], PinMode.OUT);
                    this._dataPorts[i].Provision();
                }
            }
        }