diff --git a/Hardware/OSRTT_Pro_Code/file2.ino b/Hardware/OSRTT_Pro_Code/file2.ino index bc8928f..d366522 100644 --- a/Hardware/OSRTT_Pro_Code/file2.ino +++ b/Hardware/OSRTT_Pro_Code/file2.ino @@ -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; @@ -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; @@ -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); diff --git a/Hardware/OSRTT_Pro_Code/file3.ino b/Hardware/OSRTT_Pro_Code/file3.ino index f85e22c..0bfd75f 100644 --- a/Hardware/OSRTT_Pro_Code/file3.ino +++ b/Hardware/OSRTT_Pro_Code/file3.ino @@ -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(); @@ -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) { @@ -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; @@ -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; @@ -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 } } @@ -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'; @@ -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'; @@ -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); } } @@ -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') { diff --git a/OSRTT Launcher/OSRTT Launcher/Main.cs b/OSRTT Launcher/OSRTT Launcher/Main.cs index 08d1f9d..2decb54 100644 --- a/OSRTT Launcher/OSRTT Launcher/Main.cs +++ b/OSRTT Launcher/OSRTT Launcher/Main.cs @@ -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"); @@ -459,6 +465,7 @@ public Main() } Thread jsonThread = new Thread(new ThreadStart(getODModesJson)); jsonThread.Start(); + CleanupDevTools(); } private void initialSetup() @@ -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)) { @@ -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 diff --git a/OSRTT Launcher/OSRTT Launcher/OSRTT Launcher.csproj b/OSRTT Launcher/OSRTT Launcher/OSRTT Launcher.csproj index 584e6d8..e87e7b5 100644 --- a/OSRTT Launcher/OSRTT Launcher/OSRTT Launcher.csproj +++ b/OSRTT Launcher/OSRTT Launcher/OSRTT Launcher.csproj @@ -247,6 +247,12 @@ HelpView.cs + + Form + + + protest.cs + Form @@ -310,6 +316,9 @@ HelpView.cs + + protest.cs + ResultsSettings.cs diff --git a/OSRTT Launcher/OSRTT Launcher/protest.Designer.cs b/OSRTT Launcher/OSRTT Launcher/protest.Designer.cs new file mode 100644 index 0000000..ea80024 --- /dev/null +++ b/OSRTT Launcher/OSRTT Launcher/protest.Designer.cs @@ -0,0 +1,58 @@ + +namespace OSRTT_Launcher +{ + partial class protest + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.graphedData = new ScottPlot.FormsPlot(); + this.SuspendLayout(); + // + // graphedData + // + this.graphedData.Location = new System.Drawing.Point(12, 12); + this.graphedData.Name = "graphedData"; + this.graphedData.Size = new System.Drawing.Size(1184, 666); + this.graphedData.TabIndex = 1; + // + // protest + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1210, 682); + this.Controls.Add(this.graphedData); + this.Name = "protest"; + this.Text = "protest"; + this.ResumeLayout(false); + + } + + #endregion + + private ScottPlot.FormsPlot graphedData; + } +} \ No newline at end of file diff --git a/OSRTT Launcher/OSRTT Launcher/protest.cs b/OSRTT Launcher/OSRTT Launcher/protest.cs new file mode 100644 index 0000000..9ea2290 --- /dev/null +++ b/OSRTT Launcher/OSRTT Launcher/protest.cs @@ -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 adcres = new List(); + public protest() + { + InitializeComponent(); + + + } + public void drawScatter() + { + List xs = new List(); + for (int i = 0; i < adcres.Count(); i++) + { + xs.Add(i); + } + List ys = new List(); + for (int i = 0; i < adcres.Count(); i++) + { + ys.Add(Convert.ToDouble(adcres[i])); + } + graphedData.Plot.AddScatter(xs.ToArray(), ys.ToArray()); + graphedData.RefreshRequest(); + } + } +} diff --git a/OSRTT Launcher/OSRTT Launcher/protest.resx b/OSRTT Launcher/OSRTT Launcher/protest.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/OSRTT Launcher/OSRTT Launcher/protest.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file