Skip to content

Commit

Permalink
Merge pull request #829 from retiutut/sd-card-ux-cleanup
Browse files Browse the repository at this point in the history
SD Card UX Cleanup
  • Loading branch information
retiutut authored Jul 21, 2020
2 parents a3a1028 + 3217d2e commit 2c756b6
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 109 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Use BrainFlow Java Binding to handle data acquisition (no need to run the Hub!)
* Speed up entire GUI by plotting data more efficiently
* Updated OpenBCI Data Format (CSV) Files, with more detailed information and data
* Popup with link to GUI v4 file coverter script
* Improved Playback Mode and Time Series
* Refactored GUI data flow
* Add Travis and Appveyor CI tests and builds for all OS
Expand Down
84 changes: 20 additions & 64 deletions OpenBCI_GUI/ControlPanel.pde
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Button_obci sampleDataButton; // Used to easily find GUI sample data for Playbac
Button_obci chanButton8;
Button_obci chanButton16;
Button_obci selectPlaybackFile;
Button_obci selectSDFile;
Button_obci popOutRadioConfigButton;

//Radio Button_obci Definitions
Expand Down Expand Up @@ -213,8 +212,9 @@ public void controlEvent(ControlEvent theEvent) {
//println("got a menu event from item " + s);
String filePath = controlPanel.recentPlaybackBox.longFilePaths.get(s);
if (new File(filePath).isFile()) {
playbackFileSelected(filePath, s);
playbackFileFromList(filePath, s);
} else {
verbosePrint("Playback History: " + filePath);
outputError("Playback History: Selected file does not exist. Try another file or clear settings to remove this entry.");
}
}
Expand Down Expand Up @@ -291,7 +291,6 @@ class ControlPanel {
RecentPlaybackBox recentPlaybackBox;
PlaybackFileBox playbackFileBox;
NovaXRBox novaXRBox;
SDConverterBox sdConverterBox;
BLEBox bleBox;
SessionDataBox dataLogBoxGanglion;
WifiBox wifiBox;
Expand Down Expand Up @@ -345,8 +344,7 @@ class ControlPanel {
//boxes active when eegDataSource = Playback
int playbackWidth = int(w * 1.35);
playbackFileBox = new PlaybackFileBox(x + w, dataSourceBox.y, playbackWidth, h, globalPadding);
sdConverterBox = new SDConverterBox(x + w, (playbackFileBox.y + playbackFileBox.h), playbackWidth, h, globalPadding);
recentPlaybackBox = new RecentPlaybackBox(x + w, (sdConverterBox.y + sdConverterBox.h), playbackWidth, h, globalPadding);
recentPlaybackBox = new RecentPlaybackBox(x + w, (playbackFileBox.y + playbackFileBox.h), playbackWidth, h, globalPadding);

novaXRBox = new NovaXRBox(x + w, dataSourceBox.y, w, h, globalPadding);

Expand Down Expand Up @@ -412,7 +410,6 @@ class ControlPanel {
//update playback box sizes when dropdown is selected
recentPlaybackBox.update();
playbackFileBox.update();
sdConverterBox.update();

novaXRBox.update();

Expand Down Expand Up @@ -501,7 +498,6 @@ class ControlPanel {
} else if (eegDataSource == DATASOURCE_PLAYBACKFILE) { //when data source is from playback file
recentPlaybackBox.draw();
playbackFileBox.draw();
sdConverterBox.draw();

//set other CP5 controllers invisible
comPortBox.serialList.setVisible(false);
Expand Down Expand Up @@ -769,10 +765,6 @@ class ControlPanel {
selectPlaybackFile.setIsActive(true);
selectPlaybackFile.wasPressed = true;
}
if (selectSDFile.isMouseHere()) {
selectSDFile.setIsActive(true);
selectSDFile.wasPressed = true;
}
if (sampleDataButton.isMouseHere()) {
sampleDataButton.setIsActive(true);
sampleDataButton.wasPressed = true;
Expand Down Expand Up @@ -1061,11 +1053,6 @@ class ControlPanel {
new File(settings.guiDataPath + "Recordings"));
}

if (selectSDFile.isMouseHere() && selectSDFile.wasPressed) {
output("Select an SD file to playback");
selectInput("Select an SD file to playback:", "sdFileSelected");
}


if (sampleDataButton.isMouseHere() && sampleDataButton.wasPressed) {
output("Select a file for playback");
Expand Down Expand Up @@ -1127,8 +1114,6 @@ class ControlPanel {
chanButton16.wasPressed = false;
selectPlaybackFile.setIsActive(false);
selectPlaybackFile.wasPressed = false;
selectSDFile.setIsActive(false);
selectSDFile.wasPressed = false;
sampleDataButton.setIsActive(false);
sampleDataButton.wasPressed = false;
}
Expand Down Expand Up @@ -2067,17 +2052,19 @@ class SyntheticChannelCountBox {
};

class RecentPlaybackBox {
int x, y, w, h, padding; //size and position
StringList shortFileNames = new StringList();
StringList longFilePaths = new StringList();
private int x, y, w, h, padding; //size and position
private StringList shortFileNames = new StringList();
private StringList longFilePaths = new StringList();
private String filePickedShort = "Select Recent Playback File";
ControlP5 cp5_recentPlayback_dropdown;
private ControlP5 cp5_recentPlayback_dropdown;
private int titleH = 14;
private int buttonH = 24;

RecentPlaybackBox(int _x, int _y, int _w, int _h, int _padding) {
x = _x;
y = _y;
w = _w;
h = 67;
h = titleH + buttonH + _padding*3;
padding = _padding;

cp5_recentPlayback_dropdown = new ControlP5(ourApplet);
Expand All @@ -2088,7 +2075,7 @@ class RecentPlaybackBox {
createDropdown("recentFiles", Arrays.asList(temp));
cp5_recentPlayback_dropdown.setGraphics(ourApplet, 0,0);
cp5_recentPlayback_dropdown.get(ScrollableList.class, "recentFiles").setPosition(x + padding, y + padding*2 + 13);
cp5_recentPlayback_dropdown.get(ScrollableList.class, "recentFiles").setSize(w - padding*2, (temp.length + 1) * 24);
cp5_recentPlayback_dropdown.get(ScrollableList.class, "recentFiles").setSize(w - padding*2, (temp.length + 1) * buttonH);
}

/////*Update occurs while control panel is open*/////
Expand All @@ -2099,7 +2086,7 @@ class RecentPlaybackBox {
getRecentPlaybackFiles();
String[] temp = shortFileNames.array();
cp5_recentPlayback_dropdown.get(ScrollableList.class, "recentFiles").addItems(temp);
cp5_recentPlayback_dropdown.get(ScrollableList.class, "recentFiles").setSize(w - padding*2, (temp.length + 1) * 24);
cp5_recentPlayback_dropdown.get(ScrollableList.class, "recentFiles").setSize(w - padding*2, (temp.length + 1) * buttonH);
}
}

Expand All @@ -2116,7 +2103,7 @@ class RecentPlaybackBox {
fill(boxColor);
stroke(boxStrokeColor);
strokeWeight(1);
rect(x, y, w, h + cp5_recentPlayback_dropdown.getController("recentFiles").getHeight() - padding*2);
rect(x, y, w, h + cp5_recentPlayback_dropdown.getController("recentFiles").getHeight() - padding*2.5);
fill(bgColor);
textFont(h3, 16);
textAlign(LEFT, TOP);
Expand Down Expand Up @@ -2297,18 +2284,20 @@ class NovaXRBox {
};

class PlaybackFileBox {
int x, y, w, h, padding; //size and position
int sampleDataButton_w = 100;
int sampleDataButton_h = 20;
private int x, y, w, h, padding; //size and position
private int sampleDataButton_w = 100;
private int sampleDataButton_h = 20;
private int titleH = 14;
private int buttonH = 24;

PlaybackFileBox(int _x, int _y, int _w, int _h, int _padding) {
x = _x;
y = _y;
w = _w;
h = 67;
h = buttonH + (_padding * 3) + titleH;
padding = _padding;

selectPlaybackFile = new Button_obci (x + padding, y + padding*2 + 13, w - padding*2, 24, "SELECT PLAYBACK FILE", fontInfo.buttonLabel_size);
selectPlaybackFile = new Button_obci (x + padding, y + padding*2 + titleH, w - padding*2, buttonH, "SELECT OPENBCI PLAYBACK FILE", fontInfo.buttonLabel_size);
selectPlaybackFile.setHelpText("Click to open a dialog box to select an OpenBCI playback file (.txt or .csv).");

// Sample data button
Expand Down Expand Up @@ -2527,39 +2516,6 @@ class RadioConfigBox {
}
};

class SDConverterBox {
int x, y, w, h, padding; //size and position

SDConverterBox(int _x, int _y, int _w, int _h, int _padding) {
x = _x;
y = _y;
w = _w;
h = 67;
padding = _padding;

selectSDFile = new Button_obci (x + padding, y + padding*2 + 13, w - padding*2, 24, "SELECT SD FILE", fontInfo.buttonLabel_size);
selectSDFile.setHelpText("Click here to select an SD file generated by Cyton or Cyton+Daisy and convert to plain text format.");
}

public void update() {
}

public void draw() {
pushStyle();
fill(boxColor);
stroke(boxStrokeColor);
strokeWeight(1);
rect(x, y, w, h);
fill(bgColor);
textFont(h3, 16);
textAlign(LEFT, TOP);
text("SELECT SD FILE FOR PLAYBACK", x + padding, y + padding);
popStyle();

selectSDFile.draw();
}
};

class ChannelPopup {
int x, y, w, h, padding; //size and position
boolean clicked;
Expand Down
11 changes: 0 additions & 11 deletions OpenBCI_GUI/DataSourceSDCard.pde
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,3 @@ class DataSourceSDCard implements DataSource, FileBoard, AccelerometerCapableBoa
}

}


void sdFileSelected(File selection) {
if (selection == null) {
println("Window was closed or the user hit cancel.");
} else {
println("User selected " + selection.getAbsolutePath());
playbackData_fname = "N/A"; // to create instance of DataSourceSDCard
sdData_fname = selection.getAbsolutePath();
}
}
4 changes: 2 additions & 2 deletions OpenBCI_GUI/Info.plist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>CFBundleShortVersionString</key>
<string>4</string>
<key>CFBundleVersion</key>
<string>5.0.0-beta.1</string>
<string>5.0.0-beta.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSHumanReadableCopyright</key>
Expand All @@ -32,7 +32,7 @@
Copyright © 2020 OpenBCI
</string>
<key>CFBundleGetInfoString</key>
<string>June 2020</string>
<string>July 2020</string>
<!-- End of the set that can be customized -->

@@jvm_runtime@@
Expand Down
6 changes: 3 additions & 3 deletions OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ import com.fazecast.jSerialComm.*; //Helps distinguish serial ports on Windows
// Global Variables & Instances
//------------------------------------------------------------------------
//Used to check GUI version in TopNav.pde and displayed on the splash screen on startup
String localGUIVersionString = "v5.0.0-beta.1";
String localGUIVersionDate = "June 2020";
String localGUIVersionString = "v5.0.0-beta.2";
String localGUIVersionDate = "July 2020";
String guiLatestReleaseLocation = "https://github.com/OpenBCI/OpenBCI_GUI/releases/latest";
Boolean guiVersionCheckHasOccured = false;

Expand Down Expand Up @@ -504,7 +504,7 @@ void initSystem() {
}
else {
// no code path to it
println("Nor playback nor sd file selected.");
println("No playback or SD file selected.");
}
}
break;
Expand Down
25 changes: 21 additions & 4 deletions OpenBCI_GUI/PopupMessage.pde
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class PopupMessage extends PApplet implements Runnable {

private String message = "Empty Popup";
private String headerMessage = "Error";
private String buttonMessage = "OK";
private String buttonLink = null;

private color headerColor = openbciBlue;
private color buttonColor = openbciBlue;
Expand All @@ -32,6 +34,18 @@ class PopupMessage extends PApplet implements Runnable {
t.start();
}

public PopupMessage(String header, String msg, String btnMsg, String btnLink) {
super();

headerMessage = header;
message = msg;
buttonMessage = btnMsg;
buttonLink = btnLink;

Thread t = new Thread(this);
t.start();
}

@Override
public void run() {
PApplet.runSketch(new String[] {headerMessage}, this);
Expand All @@ -50,18 +64,18 @@ class PopupMessage extends PApplet implements Runnable {

cp5 = new ControlP5(this);

cp5.addButton("onOkButtonPressed")
cp5.addButton("onButtonPressed")
.setPosition(width/2 - buttonWidth/2, height - buttonHeight - padding)
.setSize(buttonWidth, buttonHeight)
.setColorLabel(color(255))
.setColorForeground(buttonColor)
.setColorBackground(buttonColor);
cp5.getController("onOkButtonPressed")
cp5.getController("onButtonPressed")
.getCaptionLabel()
.setFont(createFont("Arial",20,true))
.toUpperCase(false)
.setSize(20)
.setText("OK");
.setText(buttonMessage);
}

@Override
Expand Down Expand Up @@ -114,7 +128,10 @@ class PopupMessage extends PApplet implements Runnable {
dispose();
}

public void onOkButtonPressed() {
public void onButtonPressed() {
if (buttonLink != null) {
link(buttonLink);
}
noLoop();
Frame frame = ( (SmoothCanvas) ((PSurfaceAWT)surface).getNative()).getFrame();
frame.dispose();
Expand Down
Loading

0 comments on commit 2c756b6

Please sign in to comment.