Exemplo n.º 1
0
        public Ssd1327(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin)
        {
            this.spiBus = (SpiBus)spiBus;

            spiBuffer  = new byte[Width * Height / 2];
            spiReceive = new byte[Width * Height / 2];

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

            spiPeripheral = new SpiPeripheral(spiBus, chipSelectPort);

            Initialize();

            Thread.Sleep(300);

            FillBuffer();
            Show();
        }
Exemplo n.º 2
0
        public PCD8544(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin)
        {
            spiBuffer  = new byte[Width * Height / 8];
            spiReceive = new byte[Width * Height / 8];

            dataCommandPort = device.CreateDigitalOutputPort(dcPin, true);
            resetPort       = device.CreateDigitalOutputPort(resetPin, true);
            var chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin);

            spi        = (SpiBus)spiBus;
            spiDisplay = new SpiPeripheral(spiBus, chipSelectPort);

            Initialize();
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Create a new SSD1306 object using the default parameters for
        /// </summary>
        /// <remarks>
        ///     Note that by default, any pixels out of bounds will throw and exception.
        ///     This can be changed by setting the <seealso cref="IgnoreOutOfBoundsPixels" />
        ///     property to true.
        /// </remarks>
        /// <param name="displayType">Type of SSD1306 display (default = 128x64 pixel display).</param>
        ///
        public SSD1306(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin,
                       DisplayType displayType = DisplayType.OLED128x64)
        {
            dataCommandPort = device.CreateDigitalOutputPort(dcPin, false);
            resetPort       = device.CreateDigitalOutputPort(resetPin, true);
            chipSelectPort  = device.CreateDigitalOutputPort(chipSelectPin, false);

            spi        = (SpiBus)spiBus;
            spiDisplay = new SpiPeripheral(spiBus, chipSelectPort);

            connectionType = ConnectionType.SPI;

            InitSSD1306(displayType);
        }
Exemplo n.º 4
0
        public Max7219(ISpiBus spiBus, IDigitalOutputPort csPort, int deviceCount = 1, Max7219Type maxMode = Max7219Type.Display)
        {
            spi            = (SpiBus)spiBus;
            chipSelectPort = csPort;

            max7219 = new SpiPeripheral(spiBus, csPort);

            DeviceCount = deviceCount;

            _buffer      = new byte[DeviceCount, NumDigits];
            _writeBuffer = new byte[2 * DeviceCount];
            _readBuffer  = new byte[2 * DeviceCount];

            Initialize(maxMode);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
        /*
         * from Netduino testing, can safely remove
         * public void ClearWithoutFullScreenBuffer(ushort color)
         * {
         *  var buffer = new ushort[_width];
         *
         *  for (int x = 0; x < _width; x++)
         *  {
         *      buffer[x] = color;
         *  }
         *
         *  for (int y = 0; y < _height; y++)
         *  {
         *      spiDisplay.WriteBytes(buffer);
         *  }
         * }*/

        public void Dispose()
        {
            spi             = null;
            dataCommandPort = null;
            resetPort       = null;
        }