接入基本设备

This commit is contained in:
suntao committed 2021-06-04 13:22:59 +08:00
1 parent 2f84f70a5f
commit 7729332f41
62 files changed
+2880 -86

No files matched your search

@@ -8,6 +8,7 @@ using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using DG.Tweening;
using Assets.Scripts.Devices.Ble.Devices;
public class DeviceController : PFUIPanel
{
@@ -21,6 +22,11 @@ public class DeviceController : PFUIPanel
RectTransform circulo;
private GameObject statusText;
private Image bleStatus;
private Sprite ble0;
private Sprite ble1;
RectTransform bleCirculo;
private bool _available = false;
private bool Available
{
@@ -54,11 +60,38 @@ public class DeviceController : PFUIPanel
}
}
private bool _bleAvailable = false;
private bool BleAvailable
{
get
{
return _bleAvailable;
}
set
{
if (value == _bleAvailable)
return;
_bleAvailable = value;
if (_bleAvailable)
{
bleStatus.sprite = ble1;
DOTween.Kill(bleCirculo, false);
bleCirculo.GetComponent<Image>().sprite = circuloCompleto;
}
else
{
bleStatus.sprite = ble0;
bleCirculo.GetComponent<Image>().sprite = circuloCarga;
bleCirculo.DOLocalRotate(new Vector3(0, 0, 360), 1f, RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1);
}
}
}
protected override void Awake()
{
base.Awake();
Debug.Log("device awake");
//Debug.Log("device awake");
}
// Start is called before the first frame update
@@ -83,14 +116,13 @@ public class DeviceController : PFUIPanel
// Debug.Log("aaaaaaaaaaaaaa");
//});
var bg = this.transform.Find("Status").Find("Bg");
antStatus = bg.Find("Ant+").GetComponent<Image>();
var bg = this.transform.Find("Status").Find("Bg");
statusText = this.transform.Find("Status").Find("GameObject").gameObject;
statusText.SetActive(false);
circulo = bg.Find("Image").GetComponent<RectTransform>();
antStatus = bg.Find("AntIcon/Ant+").GetComponent<Image>();
circulo = bg.Find("AntIcon/Image").GetComponent<RectTransform>();
//circulo.DORotate(new Vector3(0, 0, 360), 1.5f, RotateMode.Fast).SetLoops(-1);
circulo.DOLocalRotate(new Vector3(0, 0, 360), 1f, RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1);
@@ -99,7 +131,42 @@ public class DeviceController : PFUIPanel
circuloCarga = Resources.Load<Sprite>("Images/icon-circulo-carga");
circuloCompleto = Resources.Load<Sprite>("Images/icon-circulo-completo");
bleStatus = bg.Find("BleIcon/Ble").GetComponent<Image>();
bleCirculo = bg.Find("BleIcon/Image").GetComponent<RectTransform>();
bleCirculo.DOLocalRotate(new Vector3(0, 0, 360), 1f, RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1);
ble0 = Resources.Load<Sprite>("Images/Bluetooth_0");
ble1 = Resources.Load<Sprite>("Images/Bluetooth_2");
base.SetRounded(bg, 64);
//var text = this.transform.Find("InputField").GetComponent<InputField>();
//var btn = this.transform.Find("Button").GetComponent<Button>();
//btn.onClick.AddListener(() =>
//{
// //Debug.Log(text.text);
// var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => d.State == DeviceState.Connected && d.Sensor == SensorType.HeartRate);
// if(device == null)
// {
// return;
// }
// //(device as HeartRate).GetBatteryLevel();
// //(device as Tacx).SetResistanceMode(int.Parse(text.text));
// //if (device is Tacx)
// //{
// // (device as Tacx).SetTrackResistance(double.Parse(text.text));
// //}
// //else if(device is FitDevice)
// //{
// // (device as FitDevice).SetErgMode(100* 4);
// //}
//});
}
@@ -109,9 +176,11 @@ public class DeviceController : PFUIPanel
timer -= Time.deltaTime;
if (timer <= 0)
{
//Available = AntConnector.Instance().IsAvailable;
Available = App.MainDeviceAdapter.GetState(Assets.Scripts.Devices.ConnectionInterface.ANT) == Assets.Scripts.Devices.DeviceAdapterState.On;
BleAvailable = App.MainDeviceAdapter.GetState(Assets.Scripts.Devices.ConnectionInterface.BLE) == Assets.Scripts.Devices.DeviceAdapterState.On;
//Debug.Log("ble available:" + App.MainDeviceAdapter.GetState(Assets.Scripts.Devices.ConnectionInterface.BLE).ToString());
timer = 1.0f;
}
}