Skip to content

Commit

Permalink
Added flicker filtering, and support for expert
Browse files Browse the repository at this point in the history
  • Loading branch information
andymanic committed Aug 10, 2024
1 parent 90a0ed2 commit 4a3f85c
Show file tree
Hide file tree
Showing 15 changed files with 1,282 additions and 929 deletions.
353 changes: 90 additions & 263 deletions Hardware/OSRTT_Expert/file2.ino

Large diffs are not rendered by default.

732 changes: 130 additions & 602 deletions Hardware/OSRTT_Expert/file3.ino

Large diffs are not rendered by default.

687 changes: 687 additions & 0 deletions Hardware/OSRTT_Expert/file4.ino

Large diffs are not rendered by default.

59 changes: 43 additions & 16 deletions Hardware/OSRTT_Pro_Code/file3.ino
Original file line number Diff line number Diff line change
Expand Up @@ -600,22 +600,6 @@ void loop() {
Serial.print("Rotation set as: ");
Serial.println(rotation);
}
else if (input[0] == 'W')
{
long s = micros();
int counter = 10000;
for(int i = 0; i < counter; i++)
{
ADC0->SWTRIG.bit.START = 1; //Start ADC
while (!ADC0->INTFLAG.bit.RESRDY); //wait for ADC to have a new value
adcBuff[i] = ADC0->RESULT.reg;
}
long e = micros();
Serial.print("Sample time: ");
float t = (e - s) / counter;
Serial.println(t);

}
else if (input[0] == 'Y')
{
int counter = 0;
Expand All @@ -640,6 +624,49 @@ void loop() {
delay(10);
}
}
else if (input[0] == 'W')
{
if (input[1] == '1')
{
for (int h = 0; h < 256; h++)
{
digitalPotWrite(h);
Serial.print(h);
Serial.print(",,");
int counter = 0;
long tStart = micros();
while (counter < 10000)
{
ADC0->SWTRIG.bit.START = 1; //Start ADC
while (!ADC0->INTFLAG.bit.RESRDY); //wait for ADC to have a new value
adcBuff[counter] = ADC0->RESULT.reg; //save new ADC value to buffer @ sample_count position
counter++;
}
long tEnd = micros();
for (int i = 0; i < counter; i++)
{
Serial.print(adcBuff[i]);
Serial.print(",");
}
Serial.println();
}
}
else if (input[1] == '2')
{
int potVal = 0;
while (potVal < 256)
{
if (digitalRead(buttonPin))
{
digitalPotWrite(potVal);
Serial.print("POT VAL:");
Serial.println(potVal);
potVal++;
delay(100);
}
}
}
}
else if (input[0] == 'Z')
{
int potVal = 1;
Expand Down
3 changes: 3 additions & 0 deletions OSRTT Launcher/OSRTT Launcher/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
<setting name="movingAverageSize" serializeAs="String">
<value>10</value>
</setting>
<setting name="flickerCulling" serializeAs="String">
<value>True</value>
</setting>
</OSRTT_Launcher.Properties.Settings>
</userSettings>
</configuration>
10 changes: 9 additions & 1 deletion OSRTT Launcher/OSRTT Launcher/LiveView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ public class LiveData

public void addData(LiveData d)
{
xDataList.Add(d.time);
if (m.boardType == 2) // Expert only
{
if (xDataList.Count != 0)
{
xDataList.Add(xDataList.Last() + d.time);
}
else { xDataList.Add(d.time); }
}
else { xDataList.Add(d.time); }
yDataList.Add(d.result);
}
public void copyListToArray()
Expand Down
26 changes: 13 additions & 13 deletions OSRTT Launcher/OSRTT Launcher/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 95 additions & 24 deletions OSRTT Launcher/OSRTT Launcher/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@ public partial class Main : Form
private double boardVersion = 2.6;
private double V1DLFW = 2.8;
private double ProDLFW = 1.7;
private double ExpertDLFW = 1.0;
public int boardType = -1;
private string softwareVersion = "4.7";

// TODO //
//
//
// Current known issues //
//

public static System.IO.Ports.SerialPort port;
delegate void SetTextCallback(string text);
private bool boardUpdate = false;
Expand Down Expand Up @@ -668,14 +663,68 @@ private void listFramerates()
}

private void listCaptureTimes()
{
captureTimeBox.Items.Clear();
captureTimeBox.Items.Add("50ms");
captureTimeBox.Items.Add("100ms");
captureTimeBox.Items.Add("150ms");
captureTimeBox.Items.Add("200ms");
captureTimeBox.Items.Add("250ms");
captureTimeBox.SelectedIndex = Properties.Settings.Default.captureTime;
{
if (captureTimeBox.InvokeRequired)
{
this.Invoke((MethodInvoker)delegate ()
{
captureTimeBox.Items.Clear();
if (boardType != 2)
{
captureTimeBox.Items.Add("50ms");
captureTimeBox.Items.Add("100ms");
captureTimeBox.Items.Add("150ms");
captureTimeBox.Items.Add("200ms");
captureTimeBox.Items.Add("250ms");
}
else
{
captureTimeBox.Items.Add("50ms @ 2.7us");
captureTimeBox.Items.Add("100ms @ 2.7us");
captureTimeBox.Items.Add("150ms @ 2.7us");
captureTimeBox.Items.Add("200ms @ 2.7us");
captureTimeBox.Items.Add("250ms @ 3.7us");
captureTimeBox.Items.Add("350ms @ 4.7us");
captureTimeBox.Items.Add("500ms @ 7.7us");
captureTimeBox.Items.Add("1s @ 13.7us");
}
int savedState = Properties.Settings.Default.captureTime;
if (savedState >= captureTimeBox.Items.Count)
{
savedState = captureTimeBox.Items.Count - 1;
}
captureTimeBox.SelectedIndex = savedState;
});
}
else
{
captureTimeBox.Items.Clear();
if (boardType != 2)
{
captureTimeBox.Items.Add("50ms");
captureTimeBox.Items.Add("100ms");
captureTimeBox.Items.Add("150ms");
captureTimeBox.Items.Add("200ms");
captureTimeBox.Items.Add("250ms");
}
else
{
captureTimeBox.Items.Add("50ms @ 2.7us");
captureTimeBox.Items.Add("100ms @ 2.7us");
captureTimeBox.Items.Add("150ms @ 2.7us");
captureTimeBox.Items.Add("200ms @ 2.7us");
captureTimeBox.Items.Add("250ms @ 3.7us");
captureTimeBox.Items.Add("350ms @ 4.7us");
captureTimeBox.Items.Add("500ms @ 7.7us");
captureTimeBox.Items.Add("1s @ 13.7us");
}
int savedState = Properties.Settings.Default.captureTime;
if (savedState >= captureTimeBox.Items.Count)
{
savedState = captureTimeBox.Items.Count - 1;
}
captureTimeBox.SelectedIndex = savedState;
}
}

private void listVsyncState()
Expand Down Expand Up @@ -789,7 +838,8 @@ private void findAndConnectToBoard()
}
if (s.Contains("adafruit:samd:adafruit_feather_m4"))
{
//boardType = 2; // probably not needed
boardType = 2; // probably not needed
listCaptureTimes();
}
}
if (p != "")
Expand All @@ -811,7 +861,7 @@ private void findAndConnectToBoard()
}
else if (boardUpdate)
{
if ((boardVersion < V1DLFW && boardType == 0) || forceUpdate || (boardVersion < ProDLFW && boardType == 1))
if ((boardVersion < V1DLFW && boardType == 0) || forceUpdate || (boardVersion < ProDLFW && boardType == 1) || (boardVersion < ExpertDLFW && boardType == 2))
{
string p = "";
p = port.PortName;
Expand All @@ -834,19 +884,26 @@ private void findAndConnectToBoard()
process.StartInfo.FileName = "cmd.exe";
string installCommand = "";
string updateCommand = "";
if (boardType == 1)
if (boardType == 1 || boardType == 2)
{
string binFileAvailable = "";
foreach (var f in Directory.GetFiles(localPath + @"\\arduinoCLI"))
{
if (f.Contains("ino.bin") && f.Contains("Pro")) { binFileAvailable = f; }
else if (f.Contains("ino.bin") && f.Contains("Expert")) { binFileAvailable = f; }
}
if (binFileAvailable != "")
{
Console.WriteLine(binFileAvailable);

installCommand = "";
updateCommand = "/C .\\arduinoCLI\\arduino-cli.exe upload --port " + p + " --fqbn adafruit:samd:adafruit_itsybitsy_m4 -i \""+ binFileAvailable + "\"";
Console.WriteLine(updateCommand);
if (boardType == 1)
{
updateCommand = "/C .\\arduinoCLI\\arduino-cli.exe upload --port " + p + " --fqbn adafruit:samd:adafruit_itsybitsy_m4 -i \""+ binFileAvailable + "\"";
}
else if (boardType == 2)
{
updateCommand = "/C .\\arduinoCLI\\arduino-cli.exe upload --port " + p + " --fqbn adafruit:samd:adafruit_feather_m4 -i \"" + binFileAvailable + "\"";
}
}
else
{
Expand Down Expand Up @@ -1948,6 +2005,20 @@ public void Read()
}
File.WriteAllText(USBOutputPath, USBOutputString.ToString());
Console.WriteLine("Test finished");
}
else if (message.Contains("EXSTART"))
{
currentRun = 0;
}
else if (message.Contains("EXSWEEP"))
{
string newMessage = message.Remove(0, 8);
File.AppendAllText(path + "\\expertTest.csv", newMessage);

}
else if (message.Contains("EXFIN"))
{

}
else
{
Expand Down Expand Up @@ -2405,15 +2476,15 @@ private void runTest()
Stopwatch sw = new Stopwatch();
sw.Reset();
sw.Start();
while (sw.ElapsedMilliseconds < 5000)
while (sw.ElapsedMilliseconds < 20000)
{ // wait for CORRECT result to come back
if (currentStart == RGBArr[i] && currentEnd == RGBArr[k] && triggerNextResult)
{
break;
}
Thread.Sleep(10);
}
if (sw.ElapsedMilliseconds > 5000)
if (sw.ElapsedMilliseconds > 20000)
{
DialogResult d = showMessageBox("Error: The test was unable to run the last transition, try again?", "Test Timed Out", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
if (d == DialogResult.Retry)
Expand Down Expand Up @@ -3360,8 +3431,8 @@ private void setProgressBar(bool on)
private void testButtonToolStripMenuItemToolStripMenuItem_Click(object sender, EventArgs e)
{
//testRawInput();
port.Write("J");
//port.Write("W");
//port.Write("J");
port.Write("W");
//Thread.Sleep(500);
//SendKeys.SendWait("{NUM0}");
//runDirectXWindow();
Expand Down
3 changes: 0 additions & 3 deletions OSRTT Launcher/OSRTT Launcher/Main.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@
<metadata name="notifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>149, 22</value>
</metadata>
<metadata name="toolTipController.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>255, 22</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>42</value>
</metadata>
Expand Down
Loading

0 comments on commit 4a3f85c

Please sign in to comment.