本文介绍了[UWP] [C#]自动更新读取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private async void CharacteristicsReadButton_Click()
{
// BT_Code:使用Uncached从设备读取实际值。
GattReadResult result = await selectedCharacteristic.ReadValueAsync(BluetoothCacheMode.Uncached);
if(result.Status == GattCommunicationStatus.Success)
{
string formattedResult = FormatValueByPresentation(result.Value,presentationFormat);
rootPage.NotifyUser($" Read result:{formattedResult}",NotifyType.StatusMessage);
}
else
{
rootPage.NotifyUser($" Read failed:{result.Status}",NotifyType.ErrorMessage);
}
我正面临读取值更改的问题。我用我的rfduino设置了mpu5060,所以每当我的rfduino移动时,它会在我的Arduino串口显示器上显示角度。
我的c#,我可以阅读当我按下"阅读"时的值按钮。但是如果我的值(角度)发生变化,它将不会自动更新以通知用户。我必须手动点击"阅读"按钮再次更改。 如何让
自动更新?
解决方案
private async void CharacteristicReadButton_Click() { // BT_Code: Read the actual value from the device by using Uncached. GattReadResult result = await selectedCharacteristic.ReadValueAsync(BluetoothCacheMode.Uncached); if (result.Status == GattCommunicationStatus.Success) { string formattedResult = FormatValueByPresentation(result.Value, presentationFormat); rootPage.NotifyUser($"Read result: {formattedResult}", NotifyType.StatusMessage); } else { rootPage.NotifyUser($"Read failed: {result.Status}", NotifyType.ErrorMessage); }
I'm facing a problem with the read value change. I have setup mpu5060 with my rfduino, so whenever my rfduino moved, it will display the angle on my Arduino serial monitor.
for my c#, I can read the value when I press the "read" button. But if my value(angle) change, it will not auto update to notify user. I have to manually click the "read" button again to change. How do I make it auto update ?
解决方案
这篇关于[UWP] [C#]自动更新读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!