/// <summary>
        /// Create a ADJDS311 device
        /// </summary>
        /// <param name="I2CDevice">The I2c port to use</param>
        /// <param name="LedPin">The pin attached to the led</param>
        public Adjds311(I2c I2CDevice, DigitalOutPin LedPin) : base(0x74, I2CDevice)
        {
            _I2C = I2CDevice;
            _I2C.Enabled = true;

            led = LedPin;
            led.MakeDigitalPushPullOut();

            WriteByteData(CAP_RED, 15);
            WriteByteData(CAP_GREEN, 15);
            WriteByteData(CAP_BLUE, 15);
            WriteByteData(CAP_CLEAR, 15);

            WriteByteData(INT_RED_LO, 0x00);
            WriteByteData(INT_RED_HI, 0x4);
            WriteByteData(INT_GREEN_LO, 0x00);
            WriteByteData(INT_GREEN_HI, 0x5);
            WriteByteData(INT_BLUE_LO, 0x00);
            WriteByteData(INT_BLUE_HI, 0x9);
            WriteByteData(INT_CLEAR_LO, 0x00);
            WriteByteData(INT_CLEAR_HI, 0x2);
            
            

        }
        /// <summary>
        /// Construct a dual half bridge with PWM speed control
        /// </summary>
        /// <param name="A">The "A" channel half-bridge input</param>
        /// <param name="B">The "B" channel half-bridge input</param>
        /// <param name="Enable">The PWM input used to control the output enable</param>
        public DualHalfBridge(DigitalOutPin A, DigitalOutPin B, Pwm Enable)
        {
            Enable.Enabled = true;
            Enable.DutyCycle = 0;
            Enable.Enabled = true;
            A.MakeDigitalPushPullOut();
            B.MakeDigitalPushPullOut();

            enablePwm = Enable;
            this.A = A;
            this.B = B;

        }
        /// <summary>
        /// Construct a dual half bridge with no speed control
        /// </summary>
        /// <param name="A">The "A" channel half-bridge input</param>
        /// <param name="B">The "B" channel half-bridge input</param>
        /// <param name="Enable">An optional Enable pin of the H-bridge</param>
        public DualHalfBridge(DigitalOutPin A, DigitalOutPin B, DigitalOutPin Enable = null)
        {
            if(Enable != null)
            {
                Enable.DigitalValue = false;
                Enable.MakeDigitalPushPullOut();
                enable = Enable;
            }
            
            A.MakeDigitalPushPullOut();
            B.MakeDigitalPushPullOut();


            this.A = A;
            this.B = B;
        }
 /// <summary>
 /// Construct a new instance of the Sn74hc166
 /// </summary>
 /// <param name="spiModule">SPI module to use</param>
 /// <param name="loadPin">latch pin</param>
 public Sn74hc166(Spi spiModule, DigitalOutPin loadPin)
 {
     loadPin.MakeDigitalPushPullOut();
     spiModule.Enabled = true;
 }
        /// <summary>
        /// Construct a new HD44780-compatible display
        /// </summary>
        /// <param name="iface">The writable parallel interface to use</param>
        /// <param name="Columns">The number of columns in the display</param>
        /// <param name="Rows">The number of rows of the display</param>
        /// <param name="Backlight">The active-high pin to use for the backlight</param>
        /// <param name="font">The font mode to use</param>
        public Hd44780(WriteOnlyParallelInterface iface, int Columns, int Rows, DigitalOutPin Backlight = null, FontMode font = FontMode.Font_5x8) : base(Columns, Rows)
        {
            if (iface.Width == 8)
                this.bits = BitMode.EightBit;
            else if (iface.Width == 4)
                this.bits = BitMode.FourBit;
            else
                throw new ArgumentException("The IParallelInterface bus must be either 4 or 8 bits wide.", "iface");

            if (Rows == 1)
                this.lines = LinesMode.OneLine;
            else
                this.lines = LinesMode.TwoOrMoreLines;

            this.font = font;
            this.iface = iface;
            iface.DelayMicroseconds = 50;
            iface.Enabled = true;
            byte cmd;

            if (bits == BitMode.FourBit)
            {
                iface.WriteCommand(new uint[] { 0x03 }).Wait();
                Task.Delay(10).Wait();
                iface.WriteCommand(new uint[] { 0x03 }).Wait();
                Task.Delay(10).Wait();
                iface.WriteCommand(new uint[] { 0x03 }).Wait();
                Task.Delay(10).Wait();
                iface.WriteCommand(new uint[] { 0x02 }).Wait();
            }


            cmd = (byte)((byte)Command.FunctionSet | (byte)bits | (byte)lines | (byte)font);
            writeCommand(cmd).Wait();

            Display = true;
            Clear().Wait();

            if (Backlight != null)
            {
                this.backlight = Backlight;
                backlight.MakeDigitalPushPullOut();
            }


            this.Backlight = true;
        }