summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-07-29 18:14:27 -0700
committerJacob Palecki <[email protected]>2020-07-29 18:14:27 -0700
commit93d4d0fe6a356953b5dd78f60393f2a70a73afb3 (patch)
tree19796bbfeabb82f7b45709bfcdd284b43870497c
parentRename elements and add write button (diff)
downloadrawaccel-93d4d0fe6a356953b5dd78f60393f2a70a73afb3.tar.xz
rawaccel-93d4d0fe6a356953b5dd78f60393f2a70a73afb3.zip
Take new data for most fields by pressing enter
-rw-r--r--grapher/Form1.Designer.cs35
-rw-r--r--grapher/Form1.cs87
2 files changed, 106 insertions, 16 deletions
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index ebf92f0..d2aae7d 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -28,9 +28,9 @@
/// </summary>
private void InitializeComponent()
{
- System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
- System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea10 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend10 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.accelTypeDrop = new System.Windows.Forms.ComboBox();
this.sensitivityBox = new System.Windows.Forms.TextBox();
@@ -56,19 +56,19 @@
//
// AccelerationChart
//
- chartArea2.AxisX.Title = "Speed (counts/ms)";
- chartArea2.AxisY.Title = "Sensitivity (magnitude ratio)";
- chartArea2.Name = "ChartArea1";
- this.AccelerationChart.ChartAreas.Add(chartArea2);
- legend2.Name = "Legend1";
- this.AccelerationChart.Legends.Add(legend2);
+ chartArea10.AxisX.Title = "Speed (counts/ms)";
+ chartArea10.AxisY.Title = "Sensitivity (magnitude ratio)";
+ chartArea10.Name = "ChartArea1";
+ this.AccelerationChart.ChartAreas.Add(chartArea10);
+ legend10.Name = "Legend1";
+ this.AccelerationChart.Legends.Add(legend10);
this.AccelerationChart.Location = new System.Drawing.Point(162, 0);
this.AccelerationChart.Name = "AccelerationChart";
- series2.ChartArea = "ChartArea1";
- series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series2.Legend = "Legend1";
- series2.Name = "Accelerated Sensitivity";
- this.AccelerationChart.Series.Add(series2);
+ series10.ChartArea = "ChartArea1";
+ series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series10.Legend = "Legend1";
+ series10.Name = "Accelerated Sensitivity";
+ this.AccelerationChart.Series.Add(series10);
this.AccelerationChart.Size = new System.Drawing.Size(801, 312);
this.AccelerationChart.TabIndex = 0;
this.AccelerationChart.Text = "chart1";
@@ -96,6 +96,7 @@
this.sensitivityBox.Name = "sensitivityBox";
this.sensitivityBox.Size = new System.Drawing.Size(51, 20);
this.sensitivityBox.TabIndex = 3;
+ this.sensitivityBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.sensitivityBox_KeyDown);
//
// label1
//
@@ -112,6 +113,7 @@
this.rotationBox.Name = "rotationBox";
this.rotationBox.Size = new System.Drawing.Size(51, 20);
this.rotationBox.TabIndex = 5;
+ this.rotationBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.rotationBox_KeyDown);
//
// label2
//
@@ -128,6 +130,7 @@
this.accelerationBox.Name = "accelerationBox";
this.accelerationBox.Size = new System.Drawing.Size(51, 20);
this.accelerationBox.TabIndex = 7;
+ this.accelerationBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.accelerationBox_KeyDown);
//
// label4
//
@@ -144,6 +147,7 @@
this.capBox.Name = "capBox";
this.capBox.Size = new System.Drawing.Size(51, 20);
this.capBox.TabIndex = 10;
+ this.capBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.capBox_KeyDown);
//
// label3
//
@@ -183,6 +187,7 @@
this.limitBox.Name = "limitBox";
this.limitBox.Size = new System.Drawing.Size(51, 20);
this.limitBox.TabIndex = 15;
+ this.limitBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.limitBox_KeyDown);
//
// label6
//
@@ -199,6 +204,7 @@
this.midpointBox.Name = "midpointBox";
this.midpointBox.Size = new System.Drawing.Size(51, 20);
this.midpointBox.TabIndex = 17;
+ this.midpointBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.midpointBox_KeyDown);
//
// label7
//
@@ -215,6 +221,7 @@
this.offsetBox.Name = "offsetBox";
this.offsetBox.Size = new System.Drawing.Size(51, 20);
this.offsetBox.TabIndex = 19;
+ this.offsetBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.offsetBox_KeyDown);
//
// label8
//
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index 3312269..431dd53 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -38,6 +38,10 @@ namespace grapher
this.AccelerationChart.ChartAreas[0].CursorX.IsUserEnabled = true;
this.AccelerationChart.ChartAreas[0].CursorY.IsUserEnabled = true;
+
+ Acceleration = 0;
+ LimitOrExponent = 1.01;
+ Midpoint = 0;
}
#endregion Constructor
@@ -47,7 +51,7 @@ namespace grapher
private int AccelerationType { get; set; }
- private Tuple<double, double> Sensitivity { get; set; }
+ private double Sensitivity { get; set; }
private double Rotation { get; set; }
@@ -116,9 +120,88 @@ namespace grapher
private void writeButton_Click(object sender, EventArgs e)
{
- ManagedAcceleration.UpdateAccel(5, 0, 1.3, 9, 15);
+ ManagedAcceleration.UpdateAccel(5, 0, Acceleration, LimitOrExponent, Midpoint);
ManagedAcceleration.WriteToDriver();
UpdateGraph();
}
+
+ private void sensitivityBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (TryHandleWithEnter(e, sender, out double data))
+ {
+ Sensitivity = data;
+ }
+ }
+
+ private bool TryHandleWithEnter(KeyEventArgs e, object sender, out double data)
+ {
+ bool validEntry = false;
+ data = 0.0;
+
+ if (e.KeyCode == Keys.Enter)
+ {
+ try
+ {
+ data = Convert.ToDouble(((TextBox)sender).Text);
+ validEntry = true;
+ }
+ catch
+ {
+ }
+
+ e.Handled = true;
+ e.SuppressKeyPress = true;
+ }
+
+ return validEntry;
+ }
+
+ private void accelerationBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (TryHandleWithEnter(e, sender, out double data))
+ {
+ Acceleration = data;
+ }
+ }
+
+ private void rotationBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (TryHandleWithEnter(e, sender, out double data))
+ {
+ Rotation = data;
+ }
+ }
+
+ private void capBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (TryHandleWithEnter(e, sender, out double data))
+ {
+ Cap = data;
+ }
+ }
+
+ private void offsetBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (TryHandleWithEnter(e, sender, out double data))
+ {
+ Offset = data;
+ }
+ }
+
+ private void limitBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (TryHandleWithEnter(e, sender, out double data))
+ {
+ LimitOrExponent = data;
+ }
+ }
+
+ private void midpointBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (TryHandleWithEnter(e, sender, out double data))
+ {
+ Midpoint = data;
+ }
+ }
}
}