コード例 #1
0
 /// <summary>
 ///     Constructor a ShiftRegister74595 object.
 /// </summary>
 /// <param name="pins">Number of pins in the shift register (should be a multiple of 8 pins).</param>
 /// <param name="config">SPI Configuration object.</param>
 public x74595(int pins, Spi.Configuration config)
 {
     if ((pins > 0) && ((pins % 8) == 0))
     {
         _pins          = new bool[pins];
         _numberOfChips = pins / 8;
         Clear();
         _spi = new SPIBus(config);
     }
     else
     {
         throw new ArgumentOutOfRangeException(
                   "x74595: Size must be greater than zero and a multiple of 8 pins");
     }
 }
コード例 #2
0
        public PCD8544(IDigitalPin chipSelectPin, IDigitalPin dcPin, IDigitalPin resetPin,
                       Spi.SPI_module spiModule = Spi.SPI_module.SPI1,
                       uint speedKHz            = 4000)
        {
            spiBuffer = new byte[Width * Height / 8];

            dataCommandPort = new DigitalOutputPort(dcPin, true);
            resetPort       = new DigitalOutputPort(resetPin, true);

            var spiConfig = new Spi.Configuration(
                SPI_mod: spiModule,
                ChipSelect_Port: chipSelectPin,
                ChipSelect_ActiveState: false,
                ChipSelect_SetupTime: 0,
                ChipSelect_HoldTime: 0,
                Clock_IdleState: false,
                Clock_Edge: true,
                Clock_RateKHz: speedKHz);

            spi = new Spi(spiConfig);

            Initialize();
        }