Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ReportRate in TabletDebugger Window #319

Merged
merged 4 commits into from
Sep 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 25 additions & 5 deletions OpenTabletDriver.UX/Windows/TabletDebugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ public TabletDebugger()
Text = "Aux Report",
Padding = App.GroupBoxPadding
};


reportRateCtrl = new GroupBox
{
Text = "Report Rate",
Padding = App.GroupBoxPadding
};

var mainLayout = new TableLayout
{
Width = 640,
Height = 480,
Spacing = new Size(5, 5),
Padding = new Padding(5),
Rows =
Rows =
{
new TableRow
{
Expand All @@ -65,7 +70,16 @@ public TabletDebugger()
}
};

this.Content = mainLayout;
this.Content = new StackLayout
{
Padding = 5,
Spacing = 5,
Items =
{
new StackLayoutItem(mainLayout, HorizontalAlignment.Stretch, true),
new StackLayoutItem(reportRateCtrl, HorizontalAlignment.Stretch)
}
};

InitializeAsync();
}
Expand All @@ -83,16 +97,22 @@ private void InitializeAsync()
};
}

private GroupBox rawTabCtrl, tabReportCtrl, rawAuxCtrl, auxReportCtrl;
private GroupBox rawTabCtrl, tabReportCtrl, rawAuxCtrl, auxReportCtrl, reportRateCtrl;
private float reportRate;
private DateTime lastTime = DateTime.UtcNow;

private void HandleReport(object sender, IDeviceReport report)
{
if (report is ITabletReport tabletReport)
{
Application.Instance.AsyncInvoke(() =>
{
var now = DateTime.UtcNow;
reportRate += (float)(((now - lastTime).TotalMilliseconds - reportRate) / 50);
lastTime = now;
rawTabCtrl.Content = tabletReport?.StringFormat(true);
tabReportCtrl.Content = tabletReport?.StringFormat(false).Replace(", ", Environment.NewLine);
reportRateCtrl.Content = $"{(uint)(1000 / reportRate)}hz";
});
}
if (report is IAuxReport auxReport)
Expand Down