private void Initialize() { resetPort.State = (false); resetPort.State = (true); dataCommandPort.State = (false); // spi.Write(new byte[] { 0x21, 0xBF, 0x04, 0x14, 0x0C, 0x20, 0x0C }); spiDisplay.WriteBytes(new byte[] { 0x21, // LCD Extended Commands. 0xBF, // Set LCD Vop (Contrast). //0xB0 for 5V, 0XB1 for 3.3v, 0XBF if screen too dark 0x04, // Set Temp coefficient. //0x04 0x14, // LCD bias mode 1:48. //0x13 or 0X14 0x0D, // LCD in normal mode. 0x0d for inverse 0x20, // We must send 0x20 before modifying the display control mode 0x0C // Set display control, normal mode. 0x0D for inverse, 0x0C for normal }); dataCommandPort.State = (true); Clear(); Show(); }
public void Clear(bool update = true) { _latchData = new byte[_numberOfChips]; if (update) { _spi.WriteBytes(_latchData); } }
/// <summary> /// Sends data to a specific register replicated for all cascaded devices /// </summary> internal void SetRegister(Register register, byte data) { var i = 0; for (byte deviceId = 0; deviceId < DeviceCount; deviceId++) { writeBuffer[i++] = (byte)register; writeBuffer[i++] = data; } max7219.WriteBytes(writeBuffer); }
protected void Initialize() { Console.WriteLine("Initialize"); dataCommandPort.State = Command; spiPeripheral.WriteBytes(init_128x128); Thread.Sleep(100); // 100ms delay recommended SendCommand(SSD1327_DISPLAYON); // 0xaf SetContrast(0x2F); }
/// <summary> /// Send a sequence of commands to the display. /// </summary> /// <param name="commands">List of commands to send.</param> protected virtual void SendCommands(byte[] commands) { var data = new byte[commands.Length + 1]; data[0] = 0x00; Array.Copy(commands, 0, data, 1, commands.Length); if (connectionType == ConnectionType.SPI) { dataCommandPort.State = Command; _spiPeripheral.WriteBytes(commands); } else { _I2cPeripheral.WriteBytes(data); } }
void WritePayload(byte[] buf, byte data_len, byte writeType) { byte[] current = buf.ToArray(); data_len = Math.Min(data_len, payload_size); byte blank_len = 0; if (dynamic_payloads_enabled) { blank_len = (byte)(payload_size - data_len); } rf24.WriteByte(writeType); rf24.WriteBytes(current); }
/// <summary> /// Send a sequence of commands to the display. /// </summary> /// <param name="commands">List of commands to send.</param> private void SendCommands(byte[] commands) { var data = new byte[commands.Length + 1]; data[0] = 0x00; Array.Copy(commands, 0, data, 1, commands.Length); if (connectionType == ConnectionType.SPI) { dataCommandPort.State = Command; spiDisplay.WriteBytes(commands); } else { i2cPeriferal.WriteBytes(data); } }
protected byte WriteSpiRegister(byte address, byte value) { byte[] writeBuffer = new byte[2]; writeBuffer[0] = (byte)(address + 0x80); writeBuffer[1] = value; spiDevice.WriteBytes(writeBuffer); Thread.Sleep(10); writeBuffer[0] = address; writeBuffer[1] = 0; var readBuffer = spiDevice.WriteRead(writeBuffer, 2); Thread.Sleep(10); return(readBuffer[1]); }
/// <summary> /// Send the data to the SPI interface. /// </summary> protected void LatchData() { var data = new byte[_numberOfChips]; for (var chip = 0; chip < _numberOfChips; chip++) { var dataByte = _numberOfChips - chip - 1; data[dataByte] = 0; byte bitValue = 1; var offset = chip * 8; for (var bit = 0; bit < 8; bit++) { if (_pins[offset + bit]) { data[dataByte] |= bitValue; } bitValue <<= 1; } } _spi.WriteBytes(data); }
/// <summary> /// Reset the sensor. /// </summary> public void Reset() { _adxl362.WriteBytes(new byte[] { Command.WriteRegister, Registers.SoftReset, 0x52 }); Thread.Sleep(10); }
/// <summary> /// Send a command to the display. /// </summary> /// <param name="command">Command byte to send to the display.</param> private void SendCommand(byte command) { dataCommandPort.State = Command; spiPerihperal.WriteBytes(new byte[] { command }); }
protected void Write(byte[] data) { spiDisplay.WriteBytes(data); }
protected void Write(byte value) { spiBOneByteBuffer[0] = value; spi.WriteBytes(spiBOneByteBuffer); }
/// <summary> /// Draw the display buffer to screen /// </summary> public void Refresh() { spiDisplay.WriteBytes(spiBuffer); }