コード例 #1
0
ファイル: Max7219.cs プロジェクト: Rhynier/Meadow.Foundation
        public Max7219(ISpiBus spiBus, IDigitalOutputPort csPort, int deviceRows, int deviceColumns, Max7219Type maxMode = Max7219Type.Display)
        {
            spi            = (SpiBus)spiBus;
            chipSelectPort = csPort;

            max7219 = new SpiPeripheral(spiBus, csPort);

            DeviceRows    = deviceRows;
            DeviceColumns = deviceColumns;

            buffer      = new byte[DeviceCount, NumDigits];
            writeBuffer = new byte[2 * DeviceCount];
            readBuffer  = new byte[2 * DeviceCount];

            Initialize(maxMode);
        }
コード例 #2
0
ファイル: Nrf24l01.cs プロジェクト: Rhynier/Meadow.Foundation
        public Nrf24l01(
            ISpiBus spiBus,
            IDigitalOutputPort chipEnablePort,
            IDigitalOutputPort chipSelectPort,
            IDigitalInterruptPort interruptPort)
        {
            pipe0_reading_address[0] = 0;

            this.spiBus = spiBus;
            rf24        = new SpiPeripheral(spiBus, chipSelectPort);

            this.chipEnablePort = chipEnablePort;
            this.interruptPort  = interruptPort;

            Initialize();
        }
コード例 #3
0
ファイル: x74595.cs プロジェクト: jovicde/Meadow.Foundation
        /// <summary>
        ///     Constructor a ShiftRegister 74595 object.
        /// </summary>
        /// <param name="pins">Number of pins in the shift register (should be a multiple of 8 pins).</param>
        /// <param name="spiBus">SpiBus object</param>
        public x74595(IIODevice device, ISpiBus spiBus, IPin pinChipSelect, int pins = 8)
        {
            // if ((pins > 0) && ((pins % 8) == 0))
            if (pins == 8)
            {
                _numberOfChips = pins / 8;

                _latchData = new byte[_numberOfChips];

                _spi = new SpiPeripheral(spiBus, device.CreateDigitalOutputPort(pinChipSelect));
            }
            else
            {
                throw new ArgumentOutOfRangeException(
                          "x74595: Size must be greater than zero and a multiple of 8 pins, driver is currently limited to one chip (8 pins)");
            }
        }
コード例 #4
0
        public DisplayTftSpiBase(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin,
            uint width, uint height)
        {
            _width = width;
            _height = height;

            spi = (SpiBus)spiBus;

            spiBuffer = new byte[_width * _height * sizeof(ushort)];
            spiReceive = new byte[_width * _height * sizeof(ushort)];

            dataCommandPort = device.CreateDigitalOutputPort(dcPin, false);
            if (resetPin != null) { resetPort = device.CreateDigitalOutputPort(resetPin, true); }
            if (chipSelectPin != null) { chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin, false); }

            spiDisplay = new SpiPeripheral(spiBus, chipSelectPort);
        }
コード例 #5
0
        public TftSpiBase(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin,
                          int width, int height, DisplayColorMode mode = DisplayColorMode.Format16bppRgb565)
        {
            this.width  = width;
            this.height = height;

            spi = (SpiBus)spiBus;

            dataCommandPort = device.CreateDigitalOutputPort(dcPin, false);
            if (resetPin != null)
            {
                resetPort = device.CreateDigitalOutputPort(resetPin, true);
            }
            if (chipSelectPin != null)
            {
                chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin, false);
            }

            spiDisplay = new SpiPeripheral(spiBus, chipSelectPort);

            SetColorMode(mode);
        }