diff options
| author | Jacob Palecki <[email protected]> | 2020-07-29 17:31:08 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-07-29 17:31:08 -0700 |
| commit | 7d0f8a2028ef8977c68c92c9c0bba4272cc10773 (patch) | |
| tree | 9bd9bba11b5cb815043dc5b26d07ca2ed89e0fc9 | |
| parent | Compiles but may file (diff) | |
| download | rawaccel-7d0f8a2028ef8977c68c92c9c0bba4272cc10773.tar.xz rawaccel-7d0f8a2028ef8977c68c92c9c0bba4272cc10773.zip | |
Rename elements and add write button
| -rw-r--r-- | grapher/Form1.Designer.cs | 211 | ||||
| -rw-r--r-- | grapher/Form1.cs | 100 |
2 files changed, 169 insertions, 142 deletions
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 296749c..ebf92f0 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -28,54 +28,55 @@ /// </summary> private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea11 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend11 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series(); + 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(); this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); - this.textBox1 = new System.Windows.Forms.TextBox(); + this.accelTypeDrop = new System.Windows.Forms.ComboBox(); + this.sensitivityBox = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); - this.textBox2 = new System.Windows.Forms.TextBox(); + this.rotationBox = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); - this.textBox3 = new System.Windows.Forms.TextBox(); + this.accelerationBox = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); - this.textBox4 = new System.Windows.Forms.TextBox(); + this.capBox = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); - this.textBox5 = new System.Windows.Forms.TextBox(); + this.weightBoxFirst = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); - this.textBox6 = new System.Windows.Forms.TextBox(); - this.textBox7 = new System.Windows.Forms.TextBox(); + this.weightBoxSecond = new System.Windows.Forms.TextBox(); + this.limitBox = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); - this.textBox8 = new System.Windows.Forms.TextBox(); + this.midpointBox = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); - this.textBox9 = new System.Windows.Forms.TextBox(); + this.offsetBox = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); + this.writeButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit(); this.SuspendLayout(); // // AccelerationChart // - chartArea11.AxisX.Title = "Speed (counts/ms)"; - chartArea11.AxisY.Title = "Sensitivity (magnitude ratio)"; - chartArea11.Name = "ChartArea1"; - this.AccelerationChart.ChartAreas.Add(chartArea11); - legend11.Name = "Legend1"; - this.AccelerationChart.Legends.Add(legend11); + 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); this.AccelerationChart.Location = new System.Drawing.Point(162, 0); this.AccelerationChart.Name = "AccelerationChart"; - series11.ChartArea = "ChartArea1"; - series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series11.Legend = "Legend1"; - series11.Name = "Accelerated Sensitivity"; - this.AccelerationChart.Series.Add(series11); + series2.ChartArea = "ChartArea1"; + series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series2.Legend = "Legend1"; + series2.Name = "Accelerated Sensitivity"; + this.AccelerationChart.Series.Add(series2); this.AccelerationChart.Size = new System.Drawing.Size(801, 312); this.AccelerationChart.TabIndex = 0; this.AccelerationChart.Text = "chart1"; // - // comboBox1 + // accelTypeDrop // - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(new object[] { + this.accelTypeDrop.FormattingEnabled = true; + this.accelTypeDrop.Items.AddRange(new object[] { "Off", "Linear", "Classic", @@ -83,19 +84,18 @@ "Logarithmic", "Sigmoid", "Power"}); - this.comboBox1.Location = new System.Drawing.Point(15, 86); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(132, 21); - this.comboBox1.TabIndex = 2; - this.comboBox1.Text = "Acceleration Type"; - this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + this.accelTypeDrop.Location = new System.Drawing.Point(15, 86); + this.accelTypeDrop.Name = "accelTypeDrop"; + this.accelTypeDrop.Size = new System.Drawing.Size(132, 21); + this.accelTypeDrop.TabIndex = 2; + this.accelTypeDrop.Text = "Acceleration Type"; // - // textBox1 + // sensitivityBox // - this.textBox1.Location = new System.Drawing.Point(96, 15); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(51, 20); - this.textBox1.TabIndex = 3; + this.sensitivityBox.Location = new System.Drawing.Point(96, 15); + this.sensitivityBox.Name = "sensitivityBox"; + this.sensitivityBox.Size = new System.Drawing.Size(51, 20); + this.sensitivityBox.TabIndex = 3; // // label1 // @@ -105,14 +105,13 @@ this.label1.Size = new System.Drawing.Size(54, 13); this.label1.TabIndex = 4; this.label1.Text = "Sensitivity"; - this.label1.Click += new System.EventHandler(this.label1_Click); // - // textBox2 + // rotationBox // - this.textBox2.Location = new System.Drawing.Point(96, 45); - this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(51, 20); - this.textBox2.TabIndex = 5; + this.rotationBox.Location = new System.Drawing.Point(96, 45); + this.rotationBox.Name = "rotationBox"; + this.rotationBox.Size = new System.Drawing.Size(51, 20); + this.rotationBox.TabIndex = 5; // // label2 // @@ -123,13 +122,12 @@ this.label2.TabIndex = 6; this.label2.Text = "Rotation"; // - // textBox3 + // accelerationBox // - this.textBox3.Location = new System.Drawing.Point(96, 113); - this.textBox3.Name = "textBox3"; - this.textBox3.Size = new System.Drawing.Size(51, 20); - this.textBox3.TabIndex = 7; - this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged); + this.accelerationBox.Location = new System.Drawing.Point(96, 113); + this.accelerationBox.Name = "accelerationBox"; + this.accelerationBox.Size = new System.Drawing.Size(51, 20); + this.accelerationBox.TabIndex = 7; // // label4 // @@ -140,12 +138,12 @@ this.label4.TabIndex = 9; this.label4.Text = "Acceleration"; // - // textBox4 + // capBox // - this.textBox4.Location = new System.Drawing.Point(96, 140); - this.textBox4.Name = "textBox4"; - this.textBox4.Size = new System.Drawing.Size(51, 20); - this.textBox4.TabIndex = 10; + this.capBox.Location = new System.Drawing.Point(96, 140); + this.capBox.Name = "capBox"; + this.capBox.Size = new System.Drawing.Size(51, 20); + this.capBox.TabIndex = 10; // // label3 // @@ -156,12 +154,12 @@ this.label3.TabIndex = 11; this.label3.Text = "Cap"; // - // textBox5 + // weightBoxFirst // - this.textBox5.Location = new System.Drawing.Point(96, 167); - this.textBox5.Name = "textBox5"; - this.textBox5.Size = new System.Drawing.Size(24, 20); - this.textBox5.TabIndex = 12; + this.weightBoxFirst.Location = new System.Drawing.Point(96, 167); + this.weightBoxFirst.Name = "weightBoxFirst"; + this.weightBoxFirst.Size = new System.Drawing.Size(24, 20); + this.weightBoxFirst.TabIndex = 12; // // label5 // @@ -172,19 +170,19 @@ this.label5.TabIndex = 13; this.label5.Text = "Weight"; // - // textBox6 + // weightBoxSecond // - this.textBox6.Location = new System.Drawing.Point(126, 167); - this.textBox6.Name = "textBox6"; - this.textBox6.Size = new System.Drawing.Size(21, 20); - this.textBox6.TabIndex = 14; + this.weightBoxSecond.Location = new System.Drawing.Point(126, 167); + this.weightBoxSecond.Name = "weightBoxSecond"; + this.weightBoxSecond.Size = new System.Drawing.Size(21, 20); + this.weightBoxSecond.TabIndex = 14; // - // textBox7 + // limitBox // - this.textBox7.Location = new System.Drawing.Point(96, 219); - this.textBox7.Name = "textBox7"; - this.textBox7.Size = new System.Drawing.Size(51, 20); - this.textBox7.TabIndex = 15; + this.limitBox.Location = new System.Drawing.Point(96, 219); + this.limitBox.Name = "limitBox"; + this.limitBox.Size = new System.Drawing.Size(51, 20); + this.limitBox.TabIndex = 15; // // label6 // @@ -194,14 +192,13 @@ this.label6.Size = new System.Drawing.Size(78, 13); this.label6.TabIndex = 16; this.label6.Text = "Limit/Exponent"; - this.label6.Click += new System.EventHandler(this.label6_Click); // - // textBox8 + // midpointBox // - this.textBox8.Location = new System.Drawing.Point(96, 245); - this.textBox8.Name = "textBox8"; - this.textBox8.Size = new System.Drawing.Size(51, 20); - this.textBox8.TabIndex = 17; + this.midpointBox.Location = new System.Drawing.Point(96, 245); + this.midpointBox.Name = "midpointBox"; + this.midpointBox.Size = new System.Drawing.Size(51, 20); + this.midpointBox.TabIndex = 17; // // label7 // @@ -212,12 +209,12 @@ this.label7.TabIndex = 18; this.label7.Text = "Midpoint"; // - // textBox9 + // offsetBox // - this.textBox9.Location = new System.Drawing.Point(96, 193); - this.textBox9.Name = "textBox9"; - this.textBox9.Size = new System.Drawing.Size(51, 20); - this.textBox9.TabIndex = 19; + this.offsetBox.Location = new System.Drawing.Point(96, 193); + this.offsetBox.Name = "offsetBox"; + this.offsetBox.Size = new System.Drawing.Size(51, 20); + this.offsetBox.TabIndex = 19; // // label8 // @@ -228,29 +225,40 @@ this.label8.TabIndex = 20; this.label8.Text = "Offset"; // + // writeButton + // + this.writeButton.Location = new System.Drawing.Point(28, 271); + this.writeButton.Name = "writeButton"; + this.writeButton.Size = new System.Drawing.Size(102, 23); + this.writeButton.TabIndex = 21; + this.writeButton.Text = "Write To Driver"; + this.writeButton.UseVisualStyleBackColor = true; + this.writeButton.Click += new System.EventHandler(this.writeButton_Click); + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(963, 310); + this.Controls.Add(this.writeButton); this.Controls.Add(this.label8); - this.Controls.Add(this.textBox9); + this.Controls.Add(this.offsetBox); this.Controls.Add(this.label7); - this.Controls.Add(this.textBox8); + this.Controls.Add(this.midpointBox); this.Controls.Add(this.label6); - this.Controls.Add(this.textBox7); - this.Controls.Add(this.textBox6); + this.Controls.Add(this.limitBox); + this.Controls.Add(this.weightBoxSecond); this.Controls.Add(this.label5); - this.Controls.Add(this.textBox5); + this.Controls.Add(this.weightBoxFirst); this.Controls.Add(this.label3); - this.Controls.Add(this.textBox4); + this.Controls.Add(this.capBox); this.Controls.Add(this.label4); - this.Controls.Add(this.textBox3); + this.Controls.Add(this.accelerationBox); this.Controls.Add(this.label2); - this.Controls.Add(this.textBox2); + this.Controls.Add(this.rotationBox); this.Controls.Add(this.label1); - this.Controls.Add(this.textBox1); - this.Controls.Add(this.comboBox1); + this.Controls.Add(this.sensitivityBox); + this.Controls.Add(this.accelTypeDrop); this.Controls.Add(this.AccelerationChart); this.Name = "RawAcceleration"; this.Text = "Raw Acceleration Graph"; @@ -264,24 +272,25 @@ #endregion private System.Windows.Forms.DataVisualization.Charting.Chart AccelerationChart; - private System.Windows.Forms.ComboBox comboBox1; - private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.ComboBox accelTypeDrop; + private System.Windows.Forms.TextBox sensitivityBox; private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.TextBox rotationBox; private System.Windows.Forms.Label label2; - private System.Windows.Forms.TextBox textBox3; + private System.Windows.Forms.TextBox accelerationBox; private System.Windows.Forms.Label label4; - private System.Windows.Forms.TextBox textBox4; + private System.Windows.Forms.TextBox capBox; private System.Windows.Forms.Label label3; - private System.Windows.Forms.TextBox textBox5; + private System.Windows.Forms.TextBox weightBoxFirst; private System.Windows.Forms.Label label5; - private System.Windows.Forms.TextBox textBox6; - private System.Windows.Forms.TextBox textBox7; + private System.Windows.Forms.TextBox weightBoxSecond; + private System.Windows.Forms.TextBox limitBox; private System.Windows.Forms.Label label6; - private System.Windows.Forms.TextBox textBox8; + private System.Windows.Forms.TextBox midpointBox; private System.Windows.Forms.Label label7; - private System.Windows.Forms.TextBox textBox9; + private System.Windows.Forms.TextBox offsetBox; private System.Windows.Forms.Label label8; + private System.Windows.Forms.Button writeButton; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 6e81984..3312269 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -12,37 +12,14 @@ namespace grapher { public partial class RawAcceleration : Form { + #region Constructor + public RawAcceleration() { InitializeComponent(); - var managedAccel = new ManagedAccel(5, 0, 0.3, 1.25, 15); - var orderedPoints = new SortedDictionary<double, double>(); - - for (int i = 0; i < 100; i++) - { - for (int j = 0; j <= i; j++) - { - var output = managedAccel.Accelerate(i, j, 1); - - var inMagnitude = Magnitude(i,j); - var outMagnitude = Magnitude(output.Item1, output.Item2); - var ratio = inMagnitude > 0 ? outMagnitude / inMagnitude : 0; - - if (!orderedPoints.ContainsKey(inMagnitude)) - { - orderedPoints.Add(inMagnitude, ratio); - } - } - } - - var series = this.AccelerationChart.Series.FirstOrDefault(); - series.Points.Clear(); - - foreach (var point in orderedPoints) - { - series.Points.AddXY(point.Key, point.Value); - } - + ManagedAcceleration = new ManagedAccel(5, 0, 0.3, 1.25, 15); + UpdateGraph(); + this.AccelerationChart.ChartAreas[0].AxisX.RoundAxisValues(); this.AccelerationChart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; @@ -62,6 +39,33 @@ namespace grapher this.AccelerationChart.ChartAreas[0].CursorX.IsUserEnabled = true; this.AccelerationChart.ChartAreas[0].CursorY.IsUserEnabled = true; } + #endregion Constructor + + #region Properties + + public ManagedAccel ManagedAcceleration { get; set; } + + private int AccelerationType { get; set; } + + private Tuple<double, double> Sensitivity { get; set; } + + private double Rotation { get; set; } + + private Tuple<double, double> Weight { get; set; } + + private double Cap { get; set; } + + private double Offset { get; set; } + + private double Acceleration { get; set; } + + private double LimitOrExponent { get; set; } + + private double Midpoint { get; set; } + + #endregion Properties + + #region Methods public static double Magnitude(int x, int y) { @@ -78,29 +82,43 @@ namespace grapher } - private void listBox1_SelectedIndexChanged(object sender, EventArgs e) + private void UpdateGraph() { + var orderedPoints = new SortedDictionary<double, double>(); - } + for (int i = 0; i < 100; i++) + { + for (int j = 0; j <= i; j++) + { + var output = ManagedAcceleration.Accelerate(i, j, 1); - private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) - { + var inMagnitude = Magnitude(i,j); + var outMagnitude = Magnitude(output.Item1, output.Item2); + var ratio = inMagnitude > 0 ? outMagnitude / inMagnitude : 0; - } + if (!orderedPoints.ContainsKey(inMagnitude)) + { + orderedPoints.Add(inMagnitude, ratio); + } + } + } - private void label1_Click(object sender, EventArgs e) - { + var series = this.AccelerationChart.Series.FirstOrDefault(); + series.Points.Clear(); + foreach (var point in orderedPoints) + { + series.Points.AddXY(point.Key, point.Value); + } } - private void textBox3_TextChanged(object sender, EventArgs e) - { - - } + #endregion Methods - private void label6_Click(object sender, EventArgs e) + private void writeButton_Click(object sender, EventArgs e) { - + ManagedAcceleration.UpdateAccel(5, 0, 1.3, 9, 15); + ManagedAcceleration.WriteToDriver(); + UpdateGraph(); } } } |