Эх сурвалжийг харах

-地磁校准存储点的数组上限调整为6000
-九轴TimeGap处理
-陀螺仪数据可视化
-电池栏显示模块温度

lvjincheng 3 жил өмнө
parent
commit
f8c747e56d

+ 116 - 3
Assets/BowArrow/Scenes/Home.unity

@@ -958,13 +958,14 @@ RectTransform:
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
   m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 1, y: 1, z: 1}
-  m_Children: []
+  m_Children:
+  - {fileID: 1711599504}
   m_Father: {fileID: 1590289749}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 8.582376, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &219397737
@@ -10657,7 +10658,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 95.74712, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1698308730
@@ -10922,6 +10923,117 @@ CanvasRenderer:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 1707954532}
   m_CullTransparentMesh: 1
+--- !u!1 &1711599503
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 1711599504}
+  - component: {fileID: 1711599508}
+  - component: {fileID: 1711599507}
+  - component: {fileID: 1711599506}
+  - component: {fileID: 1711599505}
+  m_Layer: 5
+  m_Name: LabelTemperature
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &1711599504
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1711599503}
+  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children: []
+  m_Father: {fileID: 219397736}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 1, y: 1}
+  m_AnchorMax: {x: 1, y: 1}
+  m_AnchoredPosition: {x: -53.27, y: -1.2039509}
+  m_SizeDelta: {x: 0, y: 0}
+  m_Pivot: {x: 1, y: 1}
+--- !u!114 &1711599505
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1711599503}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: b7cbfcb0916cf694fb3d059ea4b4c1da, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  textID: 113
+  layoutRebuildObject: {fileID: 1590289749}
+  textFormatArgs: []
+  languageFontSizes: []
+--- !u!114 &1711599506
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1711599503}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_HorizontalFit: 2
+  m_VerticalFit: 2
+--- !u!114 &1711599507
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1711599503}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_RaycastTarget: 1
+  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_FontData:
+    m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
+    m_FontSize: 18
+    m_FontStyle: 0
+    m_BestFit: 0
+    m_MinSize: 1
+    m_MaxSize: 40
+    m_Alignment: 4
+    m_AlignByGeometry: 0
+    m_RichText: 1
+    m_HorizontalOverflow: 0
+    m_VerticalOverflow: 0
+    m_LineSpacing: 1
+  m_Text: "\u6E29\u5EA6"
+--- !u!222 &1711599508
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1711599503}
+  m_CullTransparentMesh: 1
 --- !u!1 &1712528619
 GameObject:
   m_ObjectHideFlags: 0
@@ -12581,6 +12693,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 788b28230007beb44bb1522ebae20506, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  labelTemperature: {fileID: 1711599507}
 --- !u!1 &1945037058
 GameObject:
   m_ObjectHideFlags: 0

+ 12 - 4
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -46,10 +46,10 @@ public class AimHandler : MonoBehaviour
     o0GyrCalibrater GyrCalibrater;
 
     //陀螺仪校准进度记录
-    public int gyrCalibrateCompleteCount = 0;
-    public int gyrCalibrateTotalCount = 300;
+    [NonSerialized] public int gyrCalibrateCompleteCount = 0;
+    [NonSerialized] public int gyrCalibrateTotalCount = 300;
 
-    long msOld = 0;
+    [NonSerialized] public long msOld = 0;
 
     public static AimHandler ins; 
 
@@ -267,6 +267,9 @@ public class AimHandler : MonoBehaviour
             }
             return;
         }
+        if (DeviceBatteryView.ins) {
+            DeviceBatteryView.ins.labelTemperature.text = (TwoByteToFloat(bytes[5], bytes[6]) / 100).ToString("#0.00") + "℃";
+        }
         if (bytes[7] == 0 && bytes[8] == 0 && bytes[9] == 0 && bytes[10] == 0 && bytes[11] == 0 && bytes[12] == 0)
             return;
         if (bytes[19] == 0 && bytes[20] == 0 && bytes[21] == 0 && bytes[22] == 0 && bytes[23] == 0 && bytes[24] == 0)
@@ -275,7 +278,7 @@ public class AimHandler : MonoBehaviour
         if (ban9AxisCalculate) //如果箭射出后禁止九轴计算,就缓存最新几帧九轴数据
         {
             
-            if (cached9AxisFrames.Count < 3)
+            if (cached9AxisFrames.Count < 2)
             {
                 cached9AxisFrames.Enqueue(bytes);
             }
@@ -378,6 +381,10 @@ public class AimHandler : MonoBehaviour
         acc0o = distanceToAxis.AccCorrection(gyr0o, acc0o, GapMs);/**///轴心偏离矫正
         Acc = o0VectorToUnity(acc0o);
 
+        var GyrOperator = new Quaternion();
+        GyrOperator.eulerAngles = Gyr * TimeGap;
+        GryMesh.transform.localRotation *= GyrOperator;
+
         AMesh.transform.localRotation = newRotation = _9Axis.update(Acc * 10, Gyr, Mag, TimeGap);
 
         if (BowQuatDebug.ins) BowQuatDebug.ins.ShowModuleQuat(newRotation.eulerAngles);
@@ -421,6 +428,7 @@ public class AimHandler : MonoBehaviour
     public void Ban9AxisCalculate(bool ban) {
         ban9AxisCalculate = ban;
         if (!ban) {
+            msOld = default;
             //恢复九轴计算时,把缓存的最新几帧计算了
             while (cached9AxisFrames.Count > 0)
             {

+ 1 - 0
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -85,6 +85,7 @@ public class BluetoothAim : MonoBehaviour
         SetStatus(BluetoothStatusEnum.ConnectFail);
         BowCamera.isTouchMode = true;
         DestroyWhenDisconenct();
+        if (AimHandler.ins) AimHandler.ins.msOld = default;
     }
 
     void Update()

+ 1 - 0
Assets/BowArrow/Scripts/Bluetooth/BluetoothHolder.cs

@@ -35,6 +35,7 @@ public class BluetoothHolder : MonoBehaviour
             this.transform.Find("CanvasForOpenDebug").gameObject.SetActive(false);
         }
         CloseDebug();
+        transform.Find("Objects").gameObject.SetActive(true);
     } 
 
     public void ShowMagEllipse(Object viewer)

+ 1 - 1
Assets/BowArrow/Scripts/Bluetooth/o09Axis.cs

@@ -274,7 +274,7 @@ public class o0MagneticCalibraterEllipsoidFitting//默认在无磁干扰环境
         if (Calibration)
         {
             records.Add(v);
-            if (records.Count > 3600) records.RemoveAt(0);
+            if (records.Count > 6000) records.RemoveAt(0);
             return v;
         }
         if(_CorrectMatrix != null)

+ 1 - 0
Assets/BowArrow/Scripts/View/DeviceBatteryView.cs

@@ -8,6 +8,7 @@ using UnityEngine.SceneManagement;
 public class DeviceBatteryView : MonoBehaviour
 {
     public static DeviceBatteryView ins;
+    public Text labelTemperature;
 
     void Start()
     {

+ 1 - 1
Assets/BowArrow/test-ellipse/Ellipse.cs

@@ -65,7 +65,7 @@ public class Ellipse : MonoBehaviour
 
     public void AddAndUpdatePointArray(Vector3 addPoint) {
         this.arrayList.Add(addPoint);
-        if (this.arrayList.Count > 3600) this.arrayList.RemoveAt(0);
+        if (this.arrayList.Count > 6000) this.arrayList.RemoveAt(0);
         this.DrawPointCloud(this.arrayList);
     }