/// <summary>
 ///     Create a new shift register (say 74595) on the specified SPI bus.
 /// </summary>
 /// <param name="spiBus">SPI module connected to the shift register.</param>
 /// <param name="latchPin">Microcontroller pin connected to the latch pin on the shift register.</param>
 /// <param name="bitOrder">Bit order of the data to be transmitted to the shift register.</param>
 /// <param name="setup">ShifterSetup object defining the order of the pins on the shift register and the pins on the LCD.</param>
 public Shifter74Hc595LcdTransferProvider(SPI.SPI_module spiBus, Cpu.Pin latchPin, BitOrder bitOrder,
                                          ShifterSetup setup)
     : base(setup)
 {
     _bitOrder = bitOrder;
     SPI.Configuration spiConfig = new SPI.Configuration(
         ChipSelect_Port: Cpu.Pin.GPIO_NONE,     // No chip select.
         ChipSelect_ActiveState: false,          // Chip select is active low.
         ChipSelect_SetupTime: 0,                // Amount of time between selection and the clock starting
         ChipSelect_HoldTime: 0,                 // Amount of time the device must be active after the data has been read.
         Clock_Edge: false,                      // Sample on the falling edge.
         Clock_IdleState: true,                  // Clock is idle when low.
         Clock_RateKHz: 1000,                    // 1MHz clock speed.
         SPI_mod: spiBus);
     _spi       = new SPI(spiConfig);
     _latchPort = new OutputPort(latchPin, false);
 }
        public Shifter74Hc595LcdTransferProvider(SPI.SPI_module spiBus, Cpu.Pin latchPin, BitOrder bitOrder, ShifterSetup setup)
            : base(setup)
        {
            _bitOrder = bitOrder;

            var spiConfig = new SPI.Configuration(
                Cpu.Pin.GPIO_NONE, //latchPin,
                false, // active state
                0,     // setup time
                0,     // hold time
                false, // clock idle state
                true,  // clock edge
                1000,   // clock rate
                spiBus);

            _spi = new SPI(spiConfig);
            _latchPort = new OutputPort(latchPin, true);
        }
        public MCP23008LcdTransferProvider(I2CBus bus, ushort address, ShifterSetup setup)
            : base(setup)
        {
            _expander = new MCP23008Expander(bus, address);
            Thread.Sleep(10); // make sure bus initializes

            _expander.SetPinMode(setup.Enable, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.RS, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D4, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D5, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D6, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D7, MCP23008Expander.PinMode.Output);

            if (setup.RW != ShifterPin.None)
                _expander.SetPinMode(setup.RW, MCP23008Expander.PinMode.Output);

            if (setup.BL != ShifterPin.None)
                _expander.SetPinMode(setup.BL, MCP23008Expander.PinMode.Output);
        }
        public MCP23008LcdTransferProvider(I2CBus bus, ushort address, ShifterSetup setup)
            : base(setup)
        {
            _expander = new MCP23008Expander(bus, address);
            Thread.Sleep(10); // make sure bus initializes

            _expander.SetPinMode(setup.Enable, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.RS, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D4, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D5, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D6, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D7, MCP23008Expander.PinMode.Output);

            if (setup.RW != ShifterPin.None)
            {
                _expander.SetPinMode(setup.RW, MCP23008Expander.PinMode.Output);
            }

            if (setup.BL != ShifterPin.None)
            {
                _expander.SetPinMode(setup.BL, MCP23008Expander.PinMode.Output);
            }
        }
 /// <summary>
 ///     Constructor for the class.
 /// </summary>
 /// <param name="setup">Configuration of the pin assignment between the shift register and the display.</param>
 protected BaseShifterLcdTransferProvider(ShifterSetup setup)
 {
     _setup = setup;
 }
 protected BaseShifterLcdTransferProvider(ShifterSetup setup)
 {
     _setup = setup;
 }
        public Shifter74Hc595LcdTransferProvider(SPI.SPI_module spiBus, Cpu.Pin latchPin, BitOrder bitOrder, ShifterSetup setup)
            : base(setup)
        {
            _bitOrder = bitOrder;

            var spiConfig = new SPI.Configuration(
                Cpu.Pin.GPIO_NONE, //latchPin,
                false,             // active state
                0,                 // setup time
                0,                 // hold time
                false,             // clock idle state
                true,              // clock edge
                1000,              // clock rate
                spiBus);

            _spi       = new SPI(spiConfig);
            _latchPort = new OutputPort(latchPin, true);
        }