Skip to content

Commit

Permalink
changed how backlight strobing detection works
Browse files Browse the repository at this point in the history
  • Loading branch information
andymanic committed Dec 4, 2023
1 parent 3025399 commit ce032ab
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 61 deletions.
18 changes: 11 additions & 7 deletions Hardware/OSRTT_Pro_Code/file2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ bool highspeed = false;

unsigned long loopTimer = millis();

char input[INPUT_SIZE + 1];

void ADC_Clocks() // Turns out to be superfluous as Adafruit wiring.c already sets these clocks. Keeping for now to guarantee settings are set.
{
MCLK->APBDMASK.bit.ADC0_ = 1;
Expand Down Expand Up @@ -363,17 +365,11 @@ void checkLatency() {
Keyboard.print('Q');
delay(100);
runADC(1000, 1000, 'F', "TL:");
char input[INPUT_SIZE + 1];
unsigned long startTime = micros();
while (curr_time < (startTime + 3000))
{
curr_time = micros();
for (int i = 0; i < INPUT_SIZE + 1; i++)
{
input[i] = ' ';
}
byte sized = Serial.readBytes(input, INPUT_SIZE);
input[sized] = 0;
getSerialChars();
if (input[0] == 'X')
{
break;
Expand All @@ -396,6 +392,14 @@ int convertHexToDec(char c) {
}
}

void getSerialChars() {
for (int i = 0; i < INPUT_SIZE + 1; i++) {
input[i] = ' ';
}
byte size = Serial.readBytes(input, INPUT_SIZE);
input[size] = 0;
}

void setup() {
pinMode (CS, OUTPUT);
digitalWrite(CS, HIGH);
Expand Down
71 changes: 19 additions & 52 deletions Hardware/OSRTT_Pro_Code/file3.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
void loop() {
Serial.setTimeout(1000);
char input[INPUT_SIZE + 1];
for (int i = 0; i < INPUT_SIZE + 1; i++)
{
input[i] = ' ';
}
byte size = Serial.readBytes(input, INPUT_SIZE);
input[size] = 0;
getSerialChars();
if (millis() == (loopTimer + 180000))
{
clearDisplayBuffer();
Expand Down Expand Up @@ -57,12 +51,7 @@ void loop() {
while (input[0] != 'X')
{
// Check serial for cancel or new potentiometer value
for (int i = 0; i < INPUT_SIZE + 1; i++)
{
input[i] = ' ';
}
byte sized = Serial.readBytes(input, INPUT_SIZE);
input[sized] = 0;
getSerialChars();
int in = 0;
if (input[0] <= 57)
{
Expand Down Expand Up @@ -297,9 +286,17 @@ void loop() {
}
if ((maxVal - minVal) > 1000)
{
oledFourLines("BACKLIGHT", "STROBING", "TEST", "CANCELLED");
input[0] = 'X';
break;
oledFourLines("BACKLIGHT", "STROBING,", "CONTINUE?", "PRESS BTN");
bool btn = digitalRead(buttonPin);
while (input[0] != 'X' && !btn)
{
getSerialChars();
btn = digitalRead(buttonPin);
}
if (input[0] == 'X')
{
break;
}
}
sample_count = 0;

Expand Down Expand Up @@ -330,12 +327,7 @@ void loop() {
while (input[0] != 'X')
{
//oledFourLines("RUNNING", "FULL", "TEST", "");
for (int i = 0; i < INPUT_SIZE + 1; i++)
{
input[i] = ' ';
}
byte sized = Serial.readBytes(input, INPUT_SIZE);
input[sized] = 0;
getSerialChars();
if (input[0] == 'X')
{
break;
Expand Down Expand Up @@ -402,12 +394,7 @@ void loop() {
{
while (input[0] != 'X' && input[0] != 'S')
{
for (int i = 0; i < INPUT_SIZE + 1; i++)
{
input[i] = ' ';
}
byte sized = Serial.readBytes(input, INPUT_SIZE);
input[sized] = 0;
getSerialChars();
curr_time = micros(); //update current time
}
}
Expand All @@ -429,12 +416,7 @@ void loop() {
Serial.println("IL Clicks");
while (input[0] != 'X')
{
for (int i = 0; i < INPUT_SIZE + 1; i++)
{
input[i] = ' ';
}
byte sized = Serial.readBytes(input, INPUT_SIZE);
input[sized] = 0;
getSerialChars();
if (input[0] != ' ')
{
int firstDigit = input[0] - '0';
Expand All @@ -457,12 +439,7 @@ void loop() {
Serial.println("IL Time");
while (input[0] != 'X')
{
for (int i = 0; i < INPUT_SIZE + 1; i++)
{
input[i] = ' ';
}
byte sized = Serial.readBytes(input, INPUT_SIZE);
input[sized] = 0;
getSerialChars();
if (input[0] != ' ')
{
int firstDigit = input[0] - '0';
Expand Down Expand Up @@ -527,12 +504,7 @@ void loop() {
input[0] = 'X';
break;
}
for (int i = 0; i < INPUT_SIZE + 1; i++)
{
input[i] = ' ';
}
byte sized = Serial.readBytes(input, INPUT_SIZE);
input[sized] = 0;
getSerialChars();
delay(10);
}
}
Expand All @@ -548,12 +520,7 @@ void loop() {
delay(200);
while (input[0] != 'X')
{
for (int i = 0; i < INPUT_SIZE + 1; i++)
{
input[i] = ' ';
}
byte sized = Serial.readBytes(input, INPUT_SIZE);
input[sized] = 0;
getSerialChars();
if (input[0] == 'P')
{

Expand Down
19 changes: 17 additions & 2 deletions OSRTT Launcher/OSRTT Launcher/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ private void appRunning()
}
}

private void CleanupDevTools()
{
if (System.Diagnostics.Debugger.IsAttached) { testButtonMenuItem.Visible = true; }
else { testButtonMenuItem.Visible = false; }
}

private void setupFormElements()
{
this.Icon = (Icon)rm.GetObject("osrttIcon");
Expand Down Expand Up @@ -459,6 +465,7 @@ public Main()
}
Thread jsonThread = new Thread(new ThreadStart(getODModesJson));
jsonThread.Start();
CleanupDevTools();
}

private void initialSetup()
Expand Down Expand Up @@ -1838,7 +1845,7 @@ public void Read()
}
else { continue; }
}
for (int k = 0; k < intValues.Length; k++)
/*for (int k = 0; k < intValues.Length; k++)
{
if ((k != 0 && k < 129) && (intValues[k] > intValues[k - 1] && intValues[k] != 65520))
{
Expand All @@ -1857,7 +1864,15 @@ public void Read()
Console.WriteLine("FAILED");
}
}
}*/

this.Invoke((MethodInvoker)delegate ()
{
protest rv = new protest();
rv.adcres = intValues.ToList();
rv.drawScatter();
rv.Show();
});
// search /Results folder for existing file names, pick new name
string[] existingUSBFile = Directory.GetFiles(path, "PRO-DATA.csv");
// Search \Results folder for existing results to not overwrite existing or have save conflict errors
Expand Down
9 changes: 9 additions & 0 deletions OSRTT Launcher/OSRTT Launcher/OSRTT Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@
<Compile Include="HelpView.Designer.cs">
<DependentUpon>HelpView.cs</DependentUpon>
</Compile>
<Compile Include="protest.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="protest.Designer.cs">
<DependentUpon>protest.cs</DependentUpon>
</Compile>
<Compile Include="ResultsSettings.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -310,6 +316,9 @@
<EmbeddedResource Include="HelpView.resx">
<DependentUpon>HelpView.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="protest.resx">
<DependentUpon>protest.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ResultsSettings.resx">
<DependentUpon>ResultsSettings.cs</DependentUpon>
</EmbeddedResource>
Expand Down
58 changes: 58 additions & 0 deletions OSRTT Launcher/OSRTT Launcher/protest.Designer.cs

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

38 changes: 38 additions & 0 deletions OSRTT Launcher/OSRTT Launcher/protest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OSRTT_Launcher
{
public partial class protest : Form
{
public List<int> adcres = new List<int>();
public protest()
{
InitializeComponent();


}
public void drawScatter()
{
List<double> xs = new List<double>();
for (int i = 0; i < adcres.Count(); i++)
{
xs.Add(i);
}
List<double> ys = new List<double>();
for (int i = 0; i < adcres.Count(); i++)
{
ys.Add(Convert.ToDouble(adcres[i]));
}
graphedData.Plot.AddScatter(xs.ToArray(), ys.ToArray());
graphedData.RefreshRequest();
}
}
}
Loading

0 comments on commit ce032ab

Please sign in to comment.