summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-22 02:28:35 -0700
committerJacob Palecki <[email protected]>2020-09-22 02:28:35 -0700
commit8e58892723ee10792c7d3db275da826f98d01677 (patch)
tree25d5c35fba0734f891737aa038e882f318296353
parentMerge remote-tracking branch 'upstream/Experiment' into GUI (diff)
downloadrawaccel-8e58892723ee10792c7d3db275da826f98d01677.tar.xz
rawaccel-8e58892723ee10792c7d3db275da826f98d01677.zip
Mostly works
-rw-r--r--common/accel-experimenttwo.hpp2
-rw-r--r--grapher/Form1.Designer.cs6
-rw-r--r--grapher/Layouts/DefaultLayout.cs1
-rw-r--r--grapher/Layouts/ExperimentOneLayout.cs1
-rw-r--r--grapher/Layouts/LayoutBase.cs7
-rw-r--r--grapher/Layouts/LinearLayout.cs1
-rw-r--r--grapher/Layouts/LogarithmLayout.cs1
-rw-r--r--grapher/Layouts/NaturalGainLayout.cs1
-rw-r--r--grapher/Layouts/NaturalLayout.cs1
-rw-r--r--grapher/Layouts/OffLayout.cs1
-rw-r--r--grapher/Layouts/PowerLayout.cs1
-rw-r--r--grapher/Layouts/SigmoidGainLayout.cs1
-rw-r--r--grapher/Models/Calculations/AccelCalculator.cs5
-rw-r--r--grapher/Models/Calculations/AccelChartData.cs2
-rw-r--r--grapher/Models/Charts/AccelCharts.cs5
-rw-r--r--grapher/Models/Charts/ChartState/ChartState.cs24
-rw-r--r--grapher/Models/Charts/ChartXY.cs16
-rw-r--r--grapher/Models/Mouse/PointData.cs4
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs7
-rw-r--r--grapher/Models/Options/ApplyOptions.cs4
20 files changed, 80 insertions, 11 deletions
diff --git a/common/accel-experimenttwo.hpp b/common/accel-experimenttwo.hpp
index a961f78..b248364 100644
--- a/common/accel-experimenttwo.hpp
+++ b/common/accel-experimenttwo.hpp
@@ -76,7 +76,7 @@ namespace rawaccel {
output += gain * 0.001;
}
- intercept = gain * lookup_speed - output;
+ intercept = output - gain * lookup_speed;
lookup[i] = { gain, intercept };
}
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index 535ee15..46b7a9a 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -580,7 +580,7 @@ namespace grapher
this.gainCapToolStripMenuItem,
this.legacyCapToolStripMenuItem});
this.capStyleToolStripMenuItem.Name = "capStyleToolStripMenuItem";
- this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
+ this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.capStyleToolStripMenuItem.Text = "Cap Style";
//
// gainCapToolStripMenuItem
@@ -603,7 +603,7 @@ namespace grapher
this.gainOffsetToolStripMenuItem,
this.legacyOffsetToolStripMenuItem});
this.offsetStyleToolStripMenuItem.Name = "offsetStyleToolStripMenuItem";
- this.offsetStyleToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
+ this.offsetStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.offsetStyleToolStripMenuItem.Text = "Offset Style";
//
// gainOffsetToolStripMenuItem
@@ -624,7 +624,7 @@ namespace grapher
this.wholeVectorToolStripMenuItem,
this.byVectorComponentToolStripMenuItem});
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
- this.toolStripMenuItem1.Size = new System.Drawing.Size(163, 22);
+ this.toolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem1.Text = "Application Style";
//
// wholeVectorToolStripMenuItem
diff --git a/grapher/Layouts/DefaultLayout.cs b/grapher/Layouts/DefaultLayout.cs
index 83535c2..cf6f87f 100644
--- a/grapher/Layouts/DefaultLayout.cs
+++ b/grapher/Layouts/DefaultLayout.cs
@@ -10,6 +10,7 @@ namespace grapher.Layouts
Name = "Default";
Index = (int)AccelMode.noaccel;
ButtonEnabled = false;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(true, Cap);
diff --git a/grapher/Layouts/ExperimentOneLayout.cs b/grapher/Layouts/ExperimentOneLayout.cs
index 1853fbc..ad6f61a 100644
--- a/grapher/Layouts/ExperimentOneLayout.cs
+++ b/grapher/Layouts/ExperimentOneLayout.cs
@@ -14,6 +14,7 @@ namespace grapher.Layouts
{
Name = "Experiment 1";
Index = (int)AccelMode.experimentone;
+ LogarithmicCharts = true;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs
index 10429fb..b89e2f7 100644
--- a/grapher/Layouts/LayoutBase.cs
+++ b/grapher/Layouts/LayoutBase.cs
@@ -25,15 +25,18 @@ namespace grapher.Layouts
MidpointLayout = new OptionLayout(false, string.Empty);
ButtonEnabled = true;
+ LogarithmicCharts = false;
}
/// <summary>
/// Gets or sets mapping from acceleration type to identifying integer.
/// Must match accel_mode defined in rawaccel-settings.h
/// </summary>
- public int Index { get; internal set; }
+ public int Index { get; protected set; }
- public string Name { get; internal set; }
+ public string Name { get; protected set; }
+
+ public bool LogarithmicCharts { get; protected set; }
protected bool ButtonEnabled { get; set; }
diff --git a/grapher/Layouts/LinearLayout.cs b/grapher/Layouts/LinearLayout.cs
index 8afdc79..e87c851 100644
--- a/grapher/Layouts/LinearLayout.cs
+++ b/grapher/Layouts/LinearLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "Linear";
Index = (int)AccelMode.linear;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(true, Cap);
diff --git a/grapher/Layouts/LogarithmLayout.cs b/grapher/Layouts/LogarithmLayout.cs
index 5b25d60..e39dbe7 100644
--- a/grapher/Layouts/LogarithmLayout.cs
+++ b/grapher/Layouts/LogarithmLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "Logarithm";
Index = (int)AccelMode.logarithm;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Scale);
CapLayout = new OptionLayout(true, Cap);
diff --git a/grapher/Layouts/NaturalGainLayout.cs b/grapher/Layouts/NaturalGainLayout.cs
index dd2cc05..b9cf75e 100644
--- a/grapher/Layouts/NaturalGainLayout.cs
+++ b/grapher/Layouts/NaturalGainLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "NaturalGain";
Index = (int)AccelMode.naturalgain;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Layouts/NaturalLayout.cs b/grapher/Layouts/NaturalLayout.cs
index faa4730..59895df 100644
--- a/grapher/Layouts/NaturalLayout.cs
+++ b/grapher/Layouts/NaturalLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "Natural";
Index = (int)AccelMode.natural;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Layouts/OffLayout.cs b/grapher/Layouts/OffLayout.cs
index 85c8d3f..c47ea39 100644
--- a/grapher/Layouts/OffLayout.cs
+++ b/grapher/Layouts/OffLayout.cs
@@ -10,6 +10,7 @@ namespace grapher.Layouts
Name = "Off";
Index = (int)AccelMode.noaccel;
ButtonEnabled = true;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(false, string.Empty);
CapLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Layouts/PowerLayout.cs b/grapher/Layouts/PowerLayout.cs
index 2004f23..5391506 100644
--- a/grapher/Layouts/PowerLayout.cs
+++ b/grapher/Layouts/PowerLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "Power";
Index = (int)AccelMode.power;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(true, Cap);
diff --git a/grapher/Layouts/SigmoidGainLayout.cs b/grapher/Layouts/SigmoidGainLayout.cs
index c807439..684de83 100644
--- a/grapher/Layouts/SigmoidGainLayout.cs
+++ b/grapher/Layouts/SigmoidGainLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "SigmoidGain";
Index = (int)AccelMode.sigmoidgain;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs
index 8865939..ab6e9de 100644
--- a/grapher/Models/Calculations/AccelCalculator.cs
+++ b/grapher/Models/Calculations/AccelCalculator.cs
@@ -64,6 +64,11 @@ namespace grapher.Models.Calculations
foreach (var magnitudeDatum in magnitudeData)
{
+ if (magnitudeDatum.magnitude <=0)
+ {
+ continue;
+ }
+
var output = accel.Accelerate(magnitudeDatum.x, magnitudeDatum.y, MeasurementTime);
var outMagnitude = Magnitude(output.Item1, output.Item2);
diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs
index fbf1944..5225e08 100644
--- a/grapher/Models/Calculations/AccelChartData.cs
+++ b/grapher/Models/Calculations/AccelChartData.cs
@@ -54,7 +54,6 @@ namespace grapher.Models.Calculations
{
var velIdx = GetVelocityIndex(outVelocityValue);
- velIdx = Math.Min(velIdx, VelocityPoints.Count - 1);
values = (VelocityPoints.ElementAt(velIdx).Key, AccelPoints.ElementAt(velIdx).Value, GainPoints.ElementAt(velIdx).Value);
OutVelocityToPoints.Add(outVelocityValue, values);
return values;
@@ -81,6 +80,7 @@ namespace grapher.Models.Calculations
}
velIdx = Math.Min(velIdx, VelocityPoints.Count - 1);
+ velIdx = Math.Max(velIdx, 0);
return velIdx;
}
diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs
index d22ab78..a0e99c8 100644
--- a/grapher/Models/Charts/AccelCharts.cs
+++ b/grapher/Models/Charts/AccelCharts.cs
@@ -149,6 +149,11 @@ namespace grapher
ChartState.Calculate(accel, settings);
}
+ public void SetLogarithmic(bool x, bool y)
+ {
+ ChartState.SetLogarithmic(x, y);
+ }
+
private static void SetupCharts(
ChartXY sensitivityChart,
ChartXY velocityChart,
diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs
index ea67e83..e1c7d01 100644
--- a/grapher/Models/Charts/ChartState/ChartState.cs
+++ b/grapher/Models/Charts/ChartState/ChartState.cs
@@ -100,5 +100,29 @@ namespace grapher.Models.Charts.ChartState
GainChart.Hide();
form.Height = SensitivityChart.Height + borderHeight;
}
+
+ public void SetLogarithmic(bool x, bool y)
+ {
+ if (x)
+ {
+ ChartXY.SetLogarithmic(SensitivityChart.ChartX);
+ ChartXY.SetLogarithmic(GainChart.ChartX);
+ }
+ else
+ {
+ ChartXY.SetStandard(SensitivityChart.ChartX);
+ ChartXY.SetStandard(GainChart.ChartX);
+ }
+
+ if (y)
+ {
+ ChartXY.SetLogarithmic(SensitivityChart.ChartY);
+ ChartXY.SetLogarithmic(GainChart.ChartY);
+ }
+ {
+ ChartXY.SetStandard(SensitivityChart.ChartY);
+ ChartXY.SetStandard(GainChart.ChartY);
+ }
+ }
}
}
diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs
index fdd0258..b17960b 100644
--- a/grapher/Models/Charts/ChartXY.cs
+++ b/grapher/Models/Charts/ChartXY.cs
@@ -132,6 +132,22 @@ namespace grapher
}
}
+ public static void SetLogarithmic(Chart chart)
+ {
+ chart.ChartAreas[0].AxisX.Minimum = 0.001;
+ chart.ChartAreas[0].AxisX.Maximum = 3500;
+ chart.ChartAreas[0].AxisY.Minimum = 0.001;
+ chart.ChartAreas[0].AxisY.Maximum = 10;
+ chart.ChartAreas[0].AxisX.IsLogarithmic = true;
+ chart.ChartAreas[0].AxisY.IsLogarithmic = true;
+ }
+
+ public static void SetStandard(Chart chart)
+ {
+ chart.ChartAreas[0].AxisX.IsLogarithmic = false;
+ chart.ChartAreas[0].AxisY.IsLogarithmic = false;
+ }
+
public void SetPointBinds(PointData combined, PointData x, PointData y)
{
CombinedPointData = combined;
diff --git a/grapher/Models/Mouse/PointData.cs b/grapher/Models/Mouse/PointData.cs
index 374c52e..e3f44ea 100644
--- a/grapher/Models/Mouse/PointData.cs
+++ b/grapher/Models/Mouse/PointData.cs
@@ -9,8 +9,8 @@ namespace grapher.Models.Mouse
public PointData()
{
Lock = new Object();
- X = new double[] { 0 };
- Y = new double[] { 0 };
+ X = new double[] { 0.01 };
+ Y = new double[] { 0.01 };
}
#endregion Constructors
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index 6f547cd..ce5ec54 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -64,6 +64,7 @@ namespace grapher
#endregion Constructors
#region Properties
+ public AccelCharts AccelCharts { get; }
public Button WriteButton { get; }
@@ -180,8 +181,8 @@ namespace grapher
public void SetActiveValues(int index, AccelArgs args)
{
- var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name;
- AccelTypeActiveValue.SetValue(name);
+ AccelerationType = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value;
+ AccelTypeActiveValue.SetValue(AccelerationType.Name);
Weight.SetActiveValue(args.weight);
Cap.SetActiveValues(args.gainCap, args.scaleCap, args.gainCap > 0);
@@ -189,6 +190,8 @@ namespace grapher
Acceleration.SetActiveValue(args.accel);
LimitOrExponent.SetActiveValue(args.exponent);
Midpoint.SetActiveValue(args.midpoint);
+
+ Layout();
}
public void ShowFull()
diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs
index 6ec9d31..720cb13 100644
--- a/grapher/Models/Options/ApplyOptions.cs
+++ b/grapher/Models/Options/ApplyOptions.cs
@@ -130,6 +130,10 @@ namespace grapher.Models.Options
settings.args.x,
settings.args.y,
settings.combineMagnitudes);
+
+ AccelCharts.SetLogarithmic(
+ OptionSetX.Options.AccelerationType.LogarithmicCharts,
+ OptionSetY.Options.AccelerationType.LogarithmicCharts);
}
public void OnWholeClicked(object sender, EventArgs e)