【发布时间】:2019-01-27 13:18:10
【问题描述】:
我正在尝试从官方的 Raspberry 7" Touch LCD 获取实际的屏幕背光值。我知道“set”命令是 0x86,但“get”命令是什么?猜测是 0x85 或 0x87。
这是我尝试开始工作的代码示例:
public async Task<bool> IsDimmed()
{
string i2cDeviceSelector = I2cDevice.GetDeviceSelector();
I2cConnectionSettings i2CConnectionSettings = new I2cConnectionSettings(0x45);
IReadOnlyList<DeviceInformation> deviceInformationCollection = await DeviceInformation.FindAllAsync(i2cDeviceSelector);
if (deviceInformationCollection.Count > 0)
{
var i2CDevice = await I2cDevice.FromIdAsync(deviceInformationCollection[0].Id, i2CConnectionSettings);
var readBuffer = new byte[1];
var command = new byte[] { 0x85 };
try
{
i2CDevice.WriteRead(command, readBuffer);
i2CDevice.Dispose();
if (readBuffer[0] < 0xff) return true;
}
catch { }
}
return false;
}
我希望“readBuffer”的实际亮度值从 0x00 到 0xff。
【问题讨论】:
标签: c# raspberry-pi windows-10-iot-core