拉力曲线性能优化&解决划船时间误差问题

This commit is contained in:
lishuo committed 2022-06-21 17:49:43 +08:00
1 parent 6c9b3f825a
commit 573b96d86c
7 files changed
+122 -77

No files matched your search

@@ -51,11 +51,13 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
}
}
public static bool IsUserDefined { get; set; }
public static bool isReadyStatus { get; private set; }
public static RowerTaskPanel.RowerType rowerType { get; private set; }
public void HandleAttributeReceived(byte[] data)
{
Debug.Log("数据" + string.Join(",", data));
if (data[0] == 0x35)
{
PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10, true);
@@ -63,7 +65,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
StrokeCount = BitConvertHelper.ToUInt16(data, 19);
Debug.Log($"峰力值:{PeakDriveForce} 均力值{AverageDriveForce}");
Debug.Log("数据" + string.Join(",", data) +$" | {ElapsedTime}-{TotalDistance}");
}
else if (data[0] == 0x3d)
{
@@ -71,7 +73,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
//List<ushort> r = new List<ushort>();
for (int i = 3; i < data.Length; i += 2)
{
ushort pull = data[i] < 5 ? (ushort)0 : Convert.ToUInt16(Math.Round(LbsToNewton(data[i], true)));
ushort pull = data[i] < 10 ? (ushort)0 : Convert.ToUInt16(Math.Round(LbsToNewton(data[i], true)));
//r.Add(pull);
PullValue = pull;
}
@@ -87,17 +89,21 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
rowerType = new RowerTaskPanel.RowerType();
rowerType.type = 1;
rowerType.value = value;
IsUserDefined = true;
}
else if (status == 0)
{
rowerType = new RowerTaskPanel.RowerType();
rowerType.type = 2;
rowerType.value = value / 100;
IsUserDefined = false;
}
else
{
rowerType = null;
IsUserDefined = false;
}
Debug.Log($"里程:{TotalDistance}峰力值:{PeakDriveForce} 均力值{AverageDriveForce} ReadyStatus:{isReadyStatus} TIME{DateTime.Now}");
//isReadyStatus = data[9] == 0;
var time = ((data[3] << 16) + (data[2] << 8) + data[1]) / 100;
Debug.Log("划船时间" + time);