调整动画和chart图标细节,重置命令
This commit is contained in:
parent
8d8fd59a80
commit
561ad993b8
@ -26,6 +26,7 @@ namespace ChartAndGraph
|
||||
public static string DateToTimeString(DateTime dateTime)
|
||||
{
|
||||
Debug.Log("暫時");
|
||||
//return dateTime.ToString(@"HH\'mm\'\'");
|
||||
return dateTime.ToString("t");
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ MonoBehaviour:
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_HorizontalOverflow: 1
|
||||
m_VerticalOverflow: 1
|
||||
m_LineSpacing: 1
|
||||
m_Text: New Text
|
||||
m_Text:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -10,5 +10,6 @@ namespace Assets.Scripts.Devices.Ant.Interfaces
|
||||
interface IRowerDevice
|
||||
{
|
||||
FtmsRowerData rowerData { get; }
|
||||
void Reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
PullValue = val;
|
||||
}
|
||||
}
|
||||
//Debug.Log("原始数据:" + string.Join(",", data));
|
||||
Debug.Log("原始数据:" + string.Join(",", data));
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
|
||||
@ -39,7 +39,12 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
{
|
||||
foreach (var character in response.Data)
|
||||
{
|
||||
if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
if (character.MatchGuid(ServiceUuids.Characteristics.FitnessMachineControlPoint))
|
||||
{
|
||||
Debug.Log("中控台获取");
|
||||
this.controlPointCharacteristic = character;
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
Debug.Log("划船机");
|
||||
this.hwInterface.SubscribeCharacteristic(character, (hw, cha, res) =>
|
||||
@ -66,5 +71,11 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Debug.Log("发送重置命令");
|
||||
hwInterface.WriteCharacteristic(this.controlPointCharacteristic, new byte[] { 0x01 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,18 @@ public class RowerHomeScript : PFUIPanel
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private IRowerDevice Rower
|
||||
{
|
||||
get
|
||||
{
|
||||
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType.Rower);
|
||||
if (device != null)
|
||||
{
|
||||
return (IRowerDevice)device;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 心率数据
|
||||
/// </summary>
|
||||
@ -245,6 +257,10 @@ public class RowerHomeScript : PFUIPanel
|
||||
RowerData.PullChanged -= PaintPullCurveDelegate;
|
||||
RowerData.Reset();
|
||||
}
|
||||
if (Rower != null)
|
||||
{
|
||||
Rower.Reset();
|
||||
}
|
||||
btnStart.tag = "Start";
|
||||
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
|
||||
left.Find("Rower").GetComponent<Image>().sprite = spriteDict[0];
|
||||
@ -273,6 +289,11 @@ public class RowerHomeScript : PFUIPanel
|
||||
}
|
||||
private void ReturnHome()
|
||||
{
|
||||
if (seconds > 0)
|
||||
{
|
||||
Utils.showToast(null, "Please end this training.");
|
||||
return;
|
||||
}
|
||||
UIManager.ShowHomePanel();
|
||||
}
|
||||
|
||||
@ -281,7 +302,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
double x = 0f;
|
||||
//List<ushort> tempList = new List<ushort>()
|
||||
//{
|
||||
// 0,1,4,5,12,13,16,20,30,40,50,60,500
|
||||
// 0,1,4,500,12,13,16//,20,30,40,50,60,500
|
||||
//};
|
||||
//int tempx = 0;
|
||||
void TimerTicks()
|
||||
@ -304,13 +325,13 @@ public class RowerHomeScript : PFUIPanel
|
||||
var heartRate = HeartRate ?? 0;
|
||||
bottom.Find("BPM/Value").GetComponent<Text>().text = heartRate.ToString();
|
||||
var strokeCount = RowerData.StrokeCount;
|
||||
if (ushort.TryParse(left.Find("Times/Value").GetComponent<Text>().text, out ushort originStroke))
|
||||
{
|
||||
if (strokeCount != originStroke)
|
||||
{
|
||||
left.Find("Rower").GetComponent<RowerAnimation>().StartAnimation();
|
||||
}
|
||||
}
|
||||
//if (ushort.TryParse(left.Find("Times/Value").GetComponent<Text>().text, out ushort originStroke))
|
||||
//{
|
||||
// if (strokeCount != originStroke)
|
||||
// {
|
||||
// left.Find("Rower").GetComponent<RowerAnimation>().StartAnimation();
|
||||
// }
|
||||
//}
|
||||
left.Find("Times/Value").GetComponent<Text>().text = strokeCount.ToString();
|
||||
left.Find("Calories/Value").GetComponent<Text>().text = RowerData.TotalEnergy.ToString();
|
||||
records.Add($"{RowerData.StrokeCount},{RowerData.ElapsedTime},{RowerData.TotalDistance},{RowerData.InstantaneousPower},{RowerData.InstantaneousPace},{RowerData.StrokeRate},{RowerData.ResistanceLevel},{heartRate}");
|
||||
@ -325,12 +346,13 @@ public class RowerHomeScript : PFUIPanel
|
||||
Debug.Log(ftms.PullValue);
|
||||
PaintPullCurve(ftms.PullValue);
|
||||
}
|
||||
bool isPlay = false;
|
||||
void PaintPullCurve(ushort y)
|
||||
{
|
||||
if (y > 1000) y = 1000;
|
||||
//拉力条
|
||||
var rate = ((float)y) * 2 / 1000;
|
||||
if (rate > 1) rate = 1;
|
||||
if (rate > 1) rate = 1f;
|
||||
left.Find("LeftImage/Value").GetComponent<Image>().fillAmount = rate;
|
||||
left.Find("RightImage/Value").GetComponent<Image>().fillAmount = rate;
|
||||
//动画
|
||||
@ -340,6 +362,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
{
|
||||
if (pullList.Count == 0)
|
||||
{
|
||||
isPlay = true;
|
||||
x = 0;
|
||||
pullList.Add(new DoubleVector2(x, y));
|
||||
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
|
||||
@ -351,6 +374,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
|
||||
pullList.Clear();
|
||||
x = 0;
|
||||
isPlay = true;
|
||||
pullList.Add(new DoubleVector2(x, y));
|
||||
}
|
||||
}
|
||||
@ -358,7 +382,14 @@ public class RowerHomeScript : PFUIPanel
|
||||
{
|
||||
x += 0.1;
|
||||
pullList.Add(new DoubleVector2(x, y));
|
||||
if (pullList.Count > 5 && isPlay)
|
||||
{
|
||||
Debug.Log("开始动画");
|
||||
isPlay = false;
|
||||
left.Find("Rower").GetComponent<RowerAnimation>().StartAnimation();
|
||||
}
|
||||
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
|
||||
|
||||
}
|
||||
Debug.Log($"{x},{y}");
|
||||
//transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
|
||||
|
||||
@ -118,6 +118,7 @@ public class RouteItem : MonoBehaviour
|
||||
{
|
||||
UIManager.ShowConfirm("Re-Rowing", "Rowing again?", () =>
|
||||
{
|
||||
UIManager.CloseConfirm();
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
});
|
||||
|
||||
@ -47,10 +47,15 @@ public class RowerAnimation : PFUIPanel
|
||||
IEnumerator Animation()
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
for (int i = 0; i < 30; i++)
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
image.sprite = sprites[i];
|
||||
yield return new WaitForSeconds(0.08f);
|
||||
yield return new WaitForSeconds(0.02f);
|
||||
}
|
||||
for (int i = 15; i < 30; i++)
|
||||
{
|
||||
image.sprite = sprites[i];
|
||||
yield return new WaitForSeconds(0.04f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -205,6 +205,7 @@ public class RowerDeviceView : MonoBehaviour
|
||||
sprite1 = Resources.Load<Sprite>("Images/Rower/设备 - 划船机 - 未连接");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Rower/设备 - 划船机");
|
||||
powerUnit.text = "";
|
||||
powerValue.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,12 +331,12 @@ public class RowerDeviceView : MonoBehaviour
|
||||
//noDevice.enabled = true;
|
||||
noDevice.text = connectedDevice.Name +" "+ connectedDevice.DeviceNumber.ToString();
|
||||
}
|
||||
noDevice.color = Color.white;
|
||||
noDevice.color = Utils.HexToColorHtml("#f93086");
|
||||
|
||||
if (powerValue != null)
|
||||
{
|
||||
powerValue.text = GetValue(connectedDevice);
|
||||
}
|
||||
//if (powerValue != null)
|
||||
//{
|
||||
// powerValue.text = GetValue(connectedDevice);
|
||||
//}
|
||||
}
|
||||
|
||||
//Debug.Log(Newtonsoft.Json.JsonConvert.SerializeObject(App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType)));
|
||||
@ -359,7 +360,7 @@ public class RowerDeviceView : MonoBehaviour
|
||||
case SensorType.Trainer:
|
||||
return "Smart Trainer";
|
||||
case SensorType.Rower:
|
||||
return "Rower Machine";
|
||||
return "Rowing Machine";
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -40,16 +40,17 @@ public class RowerGraphChartFeed : MonoBehaviour
|
||||
graph.Scrollable = false;
|
||||
//graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
|
||||
graph.DataSource.StartBatch();
|
||||
graph.DataSource.ClearAndMakeBezierCurve("Player 1");
|
||||
graph.DataSource.ClearCategory("Player 1");
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
var item = list[i];
|
||||
if (i == 0)
|
||||
graph.DataSource.SetCurveInitialPoint("Player 1", item.x, item.y);
|
||||
else
|
||||
graph.DataSource.AddLinearCurveToCategory("Player 1", new DoubleVector2(item.x, item.y));
|
||||
graph.DataSource.AddPointToCategory("Player 1", item.x, item.y);
|
||||
//if (i == 0)
|
||||
// graph.DataSource.SetCurveInitialPoint("Player 1", item.x, item.y);
|
||||
//else
|
||||
// graph.DataSource.AddLinearCurveToCategory("Player 1", new DoubleVector2(item.x, item.y));
|
||||
}
|
||||
graph.DataSource.MakeCurveCategorySmooth("Player 1");
|
||||
//graph.DataSource.MakeCurveCategorySmooth("Player 1");
|
||||
graph.DataSource.EndBatch();
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,8 @@ public partial class RowerHoverText : MonoBehaviour
|
||||
public Text TextPrefab;
|
||||
public int FontSize = 5;
|
||||
public Vector3 TextOffset = new Vector3();
|
||||
public string Title;
|
||||
public string Unit;
|
||||
int fractionDigits = 0;
|
||||
AnyChart mChart;
|
||||
|
||||
@ -135,9 +137,9 @@ public partial class RowerHoverText : MonoBehaviour
|
||||
var point = graph.DataSource.GetPoint(args.Category, args.Index);
|
||||
Vector3 position;
|
||||
if(graph.PointToWorldSpace(out position, point.x, point.y, args.Category))
|
||||
PopText($"({args.XString},{args.YString})", position, true);
|
||||
PopText($"{Title}\n{args.YString} {Unit}", position, true);
|
||||
else
|
||||
PopText($"({args.XString},{args.YString})", args.Position,false);
|
||||
PopText($"{Title}\n{args.YString} {Unit}", args.Position,false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@ using System.IO;
|
||||
public partial class RowerLargeDataFeed : MonoBehaviour, IComparer<DoubleVector2>
|
||||
{
|
||||
public string Category = "Player 1";
|
||||
public int DownSampleToPoints = 100;
|
||||
public List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
|
||||
public int DownSampleToPoints = 1000;
|
||||
List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
|
||||
double pageSize = 2f;
|
||||
double currentPagePosition = 0.0;
|
||||
double currentZoom = 0f;
|
||||
@ -169,15 +169,7 @@ public partial class RowerLargeDataFeed : MonoBehaviour, IComparer<DoubleVector2
|
||||
{
|
||||
for (int i = start; i < end; i++) // load the data
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
graph.DataSource.SetCurveInitialPoint(Category, mData[i].x, mData[i].y);
|
||||
}
|
||||
else
|
||||
{
|
||||
graph.DataSource.AddLinearCurveToCategory(Category, new DoubleVector2(mData[i].x, mData[i].y));
|
||||
}
|
||||
//graph.DataSource.AddPointToCategory(Category, mData[i].x, mData[i].y);
|
||||
graph.DataSource.AddPointToCategory(Category, mData[i].x, mData[i].y);
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,14 +221,11 @@ public partial class RowerLargeDataFeed : MonoBehaviour, IComparer<DoubleVector2
|
||||
int start, end;
|
||||
findPointsForPage(pagePosition, out start, out end); // get the page edges
|
||||
graph.DataSource.ClearCategory(Category); // clear the cateogry
|
||||
|
||||
graph.DataSource.HorizontalViewSize = 500 > mData.Count ? mData.Count : 500;
|
||||
|
||||
graph.DataSource.HorizontalViewSize = mData.Count;
|
||||
if (DownSampleToPoints <= 0)
|
||||
LoadWithoutDownSampling(start, end);
|
||||
else
|
||||
LoadWithDownSampling(start, end);
|
||||
//graph.DataSource.MakeCurveCategorySmooth(Category);
|
||||
graph.DataSource.EndBatch();
|
||||
graph.HorizontalScrolling = pagePosition;
|
||||
}
|
||||
|
||||
@ -39,9 +39,9 @@ public class RowerResult : PFUIPanel
|
||||
//}
|
||||
//transform.Find("Scroll View/Viewport/Content/Content/ChartPace/Chart").GetComponent<RowerLargeDataFeed>().SetData(a);
|
||||
}
|
||||
|
||||
public async void Initial(string id)
|
||||
{
|
||||
transform.Find("Scroll View").GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
GetComponent<CanvasGroup>().alpha = 0;
|
||||
var res = await ConfigHelper.rowerApi.GetDetail(id);
|
||||
if (res.result)
|
||||
@ -59,7 +59,7 @@ public class RowerResult : PFUIPanel
|
||||
dataContent.Find("Table/AvgHR/Text").GetComponent<Text>().text
|
||||
= $"{_model.AvgHeartRate} BPM";
|
||||
dataContent.Find("Table/AvgRate/Text").GetComponent<Text>().text
|
||||
= $"{_model.AvgRate.ToString("#0")} W";
|
||||
= $"{_model.AvgRate.ToString("#0")} SPM";
|
||||
dataContent.Find("Table/MaxPower/Text").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.MaxPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("Table/MaxHR/Text").GetComponent<Text>().text
|
||||
@ -85,7 +85,7 @@ public class RowerResult : PFUIPanel
|
||||
//var b = _model.ChartList.Select((x, i) => new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace + UnityEngine.Random.value * 300)))).ToList();
|
||||
//Debug.Log(_model.ChartList.Select((x, i) => new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace + UnityEngine.Random.value * 300)))).ToList());
|
||||
//var a = new List<DoubleVector2>();
|
||||
//for (int i = 0; i < 20000; i++)
|
||||
//for (int i = 0; i < 100; i++)
|
||||
//{
|
||||
// a.Add(new DoubleVector2(i, UnityEngine.Random.value * 200));
|
||||
//}
|
||||
@ -105,6 +105,7 @@ public class RowerResult : PFUIPanel
|
||||
chartRate.GetComponent<RowerLargeDataFeed>()
|
||||
.SetData(_model.ChartList.Select((x, i) => new DoubleVector2(i, x.Rate)).ToList());
|
||||
chartHR.GetComponent<RowerLargeDataFeed>()
|
||||
//.SetData(a);
|
||||
.SetData(_model.ChartList.Select((x, i) => new DoubleVector2(i, x.HeartRate)).ToList());
|
||||
}
|
||||
GetComponent<CanvasGroup>().DOFade(1, 0.3f);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user