Exemplo n.º 1
0
        /// <summary>
        /// Send a command to the the display controller along with parameters.
        /// </summary>
        /// <param name="command">Command to send.</param>
        /// <param name="data">Span to send as parameters for the command.</param>
        private void SendCommand(Ssd1351Command command, Span <byte> data)
        {
            Span <byte> commandSpan = stackalloc byte[]
            {
                (byte)command
            };

            SendSPI(commandSpan, true);

            if (data != null && data.Length > 0)
            {
                SendSPI(data);

                // detect certain commands that may alter the state of the device. This is done as the
                // SPI device cannot read registers from the ssd1351 and so changes need to be captured
                switch (command)
                {
                // capture changes to the colour depth and colour sequence
                case Ssd1351Command.SetRemap:
                    _colorSequence = (ColorSequence)((data[0] >> 2) & 0x01);
                    _colorDepth    = (ColorDepth)((data[0] >> 6) & 0x03);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Send a command to the the display controller along with associated parameters.
        /// </summary>
        /// <param name="command">Command to send.</param>
        /// <param name="commandParameters">parameteters for the command to be sent</param>
        private void SendCommand(Ssd1351Command command, params byte[] commandParameters)
        {
            Span <byte> paramSpan = stackalloc byte[commandParameters.Length];

            for (int i = 0; i < commandParameters.Length; paramSpan[i] = commandParameters[i], i++)
            {
            }

            SendCommand(command, paramSpan);
        }