diff --git a/Assets/Scripts/Devices/Ble/Characteristic/FtmsRowerData.cs b/Assets/Scripts/Devices/Ble/Characteristic/FtmsRowerData.cs
index 458c0a32..804d86fd 100644
--- a/Assets/Scripts/Devices/Ble/Characteristic/FtmsRowerData.cs
+++ b/Assets/Scripts/Devices/Ble/Characteristic/FtmsRowerData.cs
@@ -25,24 +25,25 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
///
public int AverageStrokeRate { get; set; } = 0;
- //private UInt32 _totalDistance = 1;
- public UInt32 TotalDistance { get; set; } = 1;
- private UInt16 _instantaneousPace = 1;
- ///
- /// 即时配速
- ///
- public UInt16 InstantaneousPace
+ private UInt32 _totalDistance = 1;
+ public UInt32 TotalDistance
{
- get => _instantaneousPace;
+ get => _totalDistance;
set
{
- if (_instantaneousPace == 0 && value != 0 && StartEvent != null)
+ if (_totalDistance == 0 && value != 0 && StartEvent != null)
{
StartEvent.Invoke(this, null);
}
- _instantaneousPace = value;
+ _totalDistance = value;
}
}
+ //private UInt16 _instantaneousPace = 1;
+ ///
+ /// 即时配速
+ ///
+ public UInt16 InstantaneousPace { get; set; } = 0;
+
///
/// 平均配速
///
diff --git a/Assets/Scripts/Devices/Ble/mobile/BleMobileThread.cs b/Assets/Scripts/Devices/Ble/mobile/BleMobileThread.cs
index 1c346c78..909ffa7f 100644
--- a/Assets/Scripts/Devices/Ble/mobile/BleMobileThread.cs
+++ b/Assets/Scripts/Devices/Ble/mobile/BleMobileThread.cs
@@ -1,5 +1,6 @@
using Assets.Scripts.Ble;
using System.Timers;
+using UnityEngine;
namespace Assets.Scripts.Devices.Ble
{
@@ -35,7 +36,7 @@ namespace Assets.Scripts.Devices.Ble
this.managerStatusChanged -= value;
}
}
- WclBleManagerStatus statusEnum = WclBleManagerStatus.RadioOff;
+ WclBleManagerStatus statusEnum = WclBleManagerStatus.RadioOn;
internal BleMobileThread() {
Initialize();//初始蓝牙
}
@@ -44,7 +45,8 @@ namespace Assets.Scripts.Devices.Ble
var self = this;
if (statusEnum == WclBleManagerStatus.RadioOff)
{
- Initialize();
+ //Initialize();
+ BluetoothLEHardwareInterface.BluetoothEnable(true);
}
else
{
@@ -56,6 +58,7 @@ namespace Assets.Scripts.Devices.Ble
}
public void Initialize()
{
+ Debug.Log("Initialize");
var self = this;
BluetoothLEHardwareInterface.BluetoothEnable(true);
BluetoothLEHardwareInterface.Initialize(true, false, () =>
diff --git a/Assets/Scripts/UI/Control/PFUISlider.cs b/Assets/Scripts/UI/Control/PFUISlider.cs
index 807ee35f..262dde8f 100644
--- a/Assets/Scripts/UI/Control/PFUISlider.cs
+++ b/Assets/Scripts/UI/Control/PFUISlider.cs
@@ -37,23 +37,39 @@ public class PFUISlider : MonoBehaviour
public bool runCallback = false;
public void SetValueChanged(System.Action a)
{
+ this.ValueChangedHandler = a;
slider = transform.GetComponent();
slider.onValueChanged.RemoveAllListeners();
+
+ UIManager.AddEvent(slider.gameObject, EventTriggerType.EndDrag, (e) =>
+ {
+ OnValueChanged();
+ });
+
slider.onValueChanged.AddListener((f) =>
{
- var step = 1f / (colorGradientList.Count-1);
- var index = (int)Math.Round(f / step, 0);
- slider.targetGraphic.color = colorGradientList[index];
- text.text = $"{valueHandler(f).ToString("#0")}";
- a.Invoke(f);
+ current = f;
});
}
+
+ float current;
+ System.Action ValueChangedHandler;
+
+ private void OnValueChanged()
+ {
+ float f = current;
+ var step = 1f / (colorGradientList.Count - 1);
+ var index = (int)Math.Round(f / step, 0);
+ slider.targetGraphic.color = colorGradientList[index];
+ text.text = $"{valueHandler(f):#0}";
+ this.ValueChangedHandler?.Invoke(f);
+ }
public void SetValue(float a)
{
a = a > 1 ? 1 : a;
a = a < 0 ? 0 : a;
slider.value = a;
- slider.onValueChanged?.Invoke(a);
+ OnValueChanged();
}
public float GetValue()
diff --git a/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs b/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs
index 0a2e0247..7566a205 100644
--- a/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs
+++ b/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs
@@ -17,6 +17,7 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using UnityEngine;
+using UnityEngine.Android;
using UnityEngine.UI;
using static RowerTaskPanel;
@@ -220,11 +221,7 @@ public class RowerHomeScript : PFUIPanel
{
var v = (ushort)Math.Round((r * 300));
print("设置阻力" + v);
- if (Rower != null)
- {
- Rower.SetResistanceLevel(v);
- //RowerData.
- }
+ StartCoroutine(SetResistanceLevel(v));
});
//transform.Find("Ready/DeviceStatus").gameObject.SetActive(!flag);
//transform.Find("Ready/DeviceStatusConnect").gameObject.SetActive(flag);
@@ -295,8 +292,6 @@ public class RowerHomeScript : PFUIPanel
RowerData.PullChanged += PaintPullCurve;
RowerData.StartEvent -= StartFunc;
RowerData.StartEvent += StartFunc;
- RowerData.RowerResChanged -= ResChanged;
- RowerData.RowerResChanged += ResChanged;
}
rowerType = new RowerType { type = 1, value = 500 };
HandleSelectType();
@@ -304,6 +299,15 @@ public class RowerHomeScript : PFUIPanel
isFirstReset = false;
}
+ IEnumerator SetResistanceLevel(ushort res)
+ {
+ yield return new WaitForSeconds(0.1f);
+ if (Rower != null)
+ {
+ Rower.SetResistanceLevel(res);
+ }
+ }
+
RowerResultModel reRowData = null;
public void ReRow(RowerResultModel r)
{
@@ -797,8 +801,9 @@ public class RowerHomeScript : PFUIPanel
private Text rmyPeakForceText { get; set; }
private bool interruptFlag{ get; set; }
- void TimerTicks()
+ void TimerTicks()
{
+ var heartRate = HeartRate ?? 0;
#if UNITY_EDITOR
var a = tempList[(tempx++) % tempList.Count];
Debug.Log(a);
@@ -825,8 +830,6 @@ public class RowerHomeScript : PFUIPanel
if (interruptFlag) return;
if (RowerData == null) return;
//#endif
- var heartRate = HeartRate ?? 0;
- BPMText.text = heartRate.ToString();
//断线重连继续
var distance = (int)RowerData.TotalDistance + historyDistance;
var energy = RowerData.TotalEnergy + historyEnergy;
@@ -1265,6 +1268,8 @@ public class RowerHomeScript : PFUIPanel
staticTimer -= Time.deltaTime;
if (staticTimer <= 0)
{
+ var heartRate = HeartRate ?? 0;
+ BPMText.text = heartRate == 0 ? "---": heartRate.ToString();
HandleStatic();
staticTimer += 1f;
}
@@ -1323,7 +1328,8 @@ public class RowerHomeScript : PFUIPanel
if (flag && RowerData.TotalDistance != 0)
{
Rower.Reset();
- //RowerData.Reset();
+ if(C2RowerData.IsEnabled)
+ RowerData.Reset();
}
}
if (transform.Find("Stopped").gameObject.activeInHierarchy)
diff --git a/Assets/Scripts/UI/Prefab/Rower/RowerDevicePanel.cs b/Assets/Scripts/UI/Prefab/Rower/RowerDevicePanel.cs
index bf58bb7a..f7301c28 100644
--- a/Assets/Scripts/UI/Prefab/Rower/RowerDevicePanel.cs
+++ b/Assets/Scripts/UI/Prefab/Rower/RowerDevicePanel.cs
@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+using UnityEngine.Android;
using UnityEngine.UI;
public class RowerDevicePanel : PFUIPanel
@@ -26,6 +27,18 @@ public class RowerDevicePanel : PFUIPanel
#if UNITY_ANDROID || UNITY_IOS
#if UNITY_ANDROID
Utils.CallAndroidMethod("OpenLocationService");
+ if (!Permission.HasUserAuthorizedPermission(Permission.CoarseLocation))
+ {
+ Permission.RequestUserPermission(Permission.CoarseLocation);
+ Permission.RequestUserPermission(Permission.FineLocation);
+ UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Powerfun need location service permission,please open the location permission.")
+ , () => {
+ UIManager.CloseConfirm();
+ }, 2
+ , () => {
+ UIManager.CloseConfirm();
+ });
+ }
#endif
App.MainDeviceAdapter.StartScan();
#endif