Skip to content

Commit

Permalink
Merge pull request #508 from retiutut/4.1.2-UI-fixes
Browse files Browse the repository at this point in the history
Dev 4.1.2 Minor UI Fixes and Edits
  • Loading branch information
daniellasry authored May 9, 2019
2 parents 5fee7aa + 842dfc4 commit 03110ab
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 73 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# v4.1.2
Use OpenBCIHub v2.0.8 please.

## Beta 2

### Improvements
* Add additional button hover text
* Console log message cleanup

### Bug Fixes
* Fix #418, #493, #506, #422, and #509

## Beta 1

### Improvements
Expand Down
22 changes: 14 additions & 8 deletions OpenBCI_GUI/BoardCyton.pde
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ final char[] command_deactivate_channel = {'1', '2', '3', '4', '5', '6', '7', '8
final char[] command_activate_channel = {'!', '@', '#', '$', '%', '^', '&', '*', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I'};

enum BoardMode {
DEFAULT,
DEBUG,
ANALOG,
DIGITAL,
MARKER
DEFAULT(0),
DEBUG(1),
ANALOG(2),
DIGITAL(3),
MARKER(4);

private final int value;
BoardMode(final int newValue) {
value = newValue;
}
public int getValue() { return value; }
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -69,7 +75,7 @@ class Cyton {
// needed by interfaceserial
public int hardwareSyncStep = 0; //start this at 0...
public String potentialFailureMessage = "";
public String defaultChannelSettings = "";
public String defaultChannelSettings = "";
public String daisyOrNot = "";

//some get methods
Expand Down Expand Up @@ -105,9 +111,9 @@ class Cyton {
}

public void setBoardMode(BoardMode boardMode) {
hub.sendCommand("/" + boardMode);
hub.sendCommand("/" + boardMode.getValue());
curBoardMode = boardMode;
print("Cyton: setBoardMode to :" + curBoardMode);
println("Cyton: setBoardMode to :" + curBoardMode);
}

public void setSampleRate(int _sampleRate) {
Expand Down
7 changes: 6 additions & 1 deletion OpenBCI_GUI/ControlPanel.pde
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,12 @@ public void initButtonPressed(){
}
midInit = true;
println("Calling initSystem()");
initSystem(); //calls the initSystem() funciton of the OpenBCI_GUI.pde file
try {
initSystem(); //found in OpenBCI_GUI.pde
} catch (Exception e) {
println(e.getMessage());
haltSystem();
}
}
}

Expand Down
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>4.1.2-beta.1</string>
<string>4.1.2-beta.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSHumanReadableCopyright</key>
Expand All @@ -32,7 +32,7 @@
Copyright © 2019 OpenBCI
</string>
<key>CFBundleGetInfoString</key>
<string>April 2019</string>
<string>May 2019</string>
<!-- End of the set that can be customized -->

@@jvm_runtime@@
Expand Down
14 changes: 8 additions & 6 deletions OpenBCI_GUI/Interactivity.pde
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,14 @@ class Button {
public boolean isMouseHere() {
if ( overRect(but_x, but_y, but_dx, but_dy) ) {
// cursor(HAND);
if(!helpTimerStarted){
helpTimerStarted = true;
mouseOverButtonStart = millis();
} else {
if(millis()-mouseOverButtonStart >= 1000){
showHelpText = true;
if (!ignoreHover) {
if(!helpTimerStarted){
helpTimerStarted = true;
mouseOverButtonStart = millis();
} else {
if(millis()-mouseOverButtonStart >= 1000){
showHelpText = true;
}
}
}
return true;
Expand Down
4 changes: 4 additions & 0 deletions OpenBCI_GUI/InterfaceHub.pde
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,10 @@ class Hub {
return dataPacket.copyTo(target);
}

public String getFirmwareVersion() {
return firmwareVersion;
}

private void getRawValues(DataPacket_ADS1299 packet) {
for (int i=0; i < nchan; i++) {
int val = packet.values[i];
Expand Down
48 changes: 26 additions & 22 deletions OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ import gifAnimation.*;
// Global Variables & Instances
//------------------------------------------------------------------------
//Used to check GUI version in TopNav.pde and displayed on the splash screen on startup
String localGUIVersionString = "v4.1.2-beta.1";
String localGUIVersionDate = "April 2019";
String localGUIVersionString = "v4.1.2-beta.2";
String localGUIVersionDate = "May 2019";
String guiLatestReleaseLocation = "https://github.com/OpenBCI/OpenBCI_GUI/releases/latest";
Boolean guiVersionCheckHasOccured = false;

Expand Down Expand Up @@ -440,18 +440,10 @@ void udpReceiveHandler(byte[] data, String ip, int portRX) {
println(udpString+" from: "+ip+" and port: "+portRX);
if (udpString.length() >=5 && udpString.indexOf("MARK") >= 0) {

/* Old version with 10 markers
char c = value.charAt(4);
if ( c>= '0' && c <= '9') {
println("Found a valid UDP STIM of value: "+int(c)+" chr: "+c);
hub.sendCommand("`"+char(c-(int)'0'));
*/
int intValue = Integer.parseInt(udpString.substring(4));

if (intValue > 0 && intValue < 96) { // Since we only send single char ascii value markers (from space to char(126)

String sendString = "`"+char(intValue+31);

println("Marker value: "+udpString+" with numeric value of char("+intValue+") as : "+sendString);
hub.sendCommand(sendString);

Expand Down Expand Up @@ -651,33 +643,36 @@ void setupWidgetManager() {
}

//Initialize the system
void initSystem() {
void initSystem() throws Exception {
println("");
println("");
println("=================================================");
println("|| INITIALIZING SYSTEM ||");
println("=================================================");
println("");

verbosePrint("OpenBCI_GUI: initSystem: -- Init 0 -- " + millis());
timeOfInit = millis(); //store this for timeout in case init takes too long
verbosePrint("timeOfInit = " + timeOfInit);

//prepare data variables
verbosePrint("OpenBCI_GUI: initSystem: -- Init 0 -- " + timeOfInit);
//Checking status here causes "error: resource busy" during init
/*
if (eegDataSource == DATASOURCE_CYTON) {
verbosePrint("OpenBCI_GUI: initSystem: Checking Cyton Connection...");
system_status(rcBox);
if (rcStringReceived.startsWith("Cyton dongle could not connect") || rcStringReceived.startsWith("Failure")) {
throw new Exception("OpenBCI_GUI: initSystem: Dongle failed to connect to Cyton...");
}
}
*/
verbosePrint("OpenBCI_GUI: initSystem: Preparing data variables...");

//initialize playback file if necessary
if (eegDataSource == DATASOURCE_PLAYBACKFILE) {
initPlaybackFileToTable(); //found in W_Playback.pde
}

verbosePrint("OpenBCI_GUI: initSystem: Initializing core data objects");

initCoreDataObjects();

verbosePrint("OpenBCI_GUI: initSystem: -- Init 1 -- " + millis());
verbosePrint("OpenBCI_GUI: initSystem: Initializing FFT data objects");

initFFTObjectsAndBuffer();

//prepare some signal processing stuff
Expand Down Expand Up @@ -766,10 +761,19 @@ void initSystem() {

verbosePrint("OpenBCI_GUI: initSystem: -- Init 4 -- " + millis());

//Init software settings: create default settings files, load user settings, etc.
settings.init();
if (eegDataSource == DATASOURCE_CYTON && hub.getFirmwareVersion().equals("v1.0.0")) {
abandonInit = true;
}

settings.initCheckPointFive();
if (!abandonInit) {
//Init software settings: create default settings files, load user settings, etc.
settings.init();
settings.initCheckPointFive();
} else {
haltSystem();
outputError("Failed to connect to data source. Check that the device is powered on and in range.");
controlPanel.open();
}

//reset init variables
midInit = false;
Expand Down
33 changes: 22 additions & 11 deletions OpenBCI_GUI/Radios_Config.pde
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
//
////////////////////////////////////////////////////////////////////////////////

String rcStringReceived = "";

void autoconnect(){
//Serial locBoard; //local serial instance just to make sure it's openbci, then connect to it if it is
String[] serialPorts = new String[Serial.list().length];
Expand Down Expand Up @@ -103,16 +105,20 @@ boolean confirm_connected(){
/**** Helper function to read from the serial easily ****/
boolean print_bytes(RadioConfigBox rc){
if(board_message != null){
println(board_message.toString());
rc.print_onscreen(board_message.toString());
println("Radios_Config: " + board_message.toString());
rcStringReceived = board_message.toString();
if(rcStringReceived.equals("Failure: System is Down")) {
rcStringReceived = "Cyton dongle could not connect to the board. Perhaps they are on different channels? Try pressing AUTOSCAN.";
}
rc.print_onscreen(rcStringReceived);
return true;
} else {
return false;
}
}

void print_bytes_error(RadioConfigBox rcConfig){
println("Error reading from Serial/COM port");
println("Radios_Config: Error reading from Serial/COM port");
rcConfig.print_onscreen("Error reading from Serial port. Try a different port?");
board = null;
}
Expand All @@ -123,27 +129,26 @@ boolean connect_to_portName(RadioConfigBox rcConfig){
if(openBCI_portName != "N/A"){
output("Attempting to open Serial/COM port: " + openBCI_portName);
try {
println("Radios_Config: connect_to_portName: attempting to open serial port: " + openBCI_portName);
println("Radios_Config: connect_to_portName: Attempting to open serial port: " + openBCI_portName);
serial_output = new Serial(this, openBCI_portName, openBCI_baud); //open the com port
serial_output.clear(); // clear anything in the com port's buffer
// portIsOpen = true;
println("Radios_Config: connect_to_portName: port is open!");
println("Radios_Config: connect_to_portName: Port is open!");
// changeState(HubState.COMINIT);
board = serial_output;
return true;
}
catch (RuntimeException e){
if (e.getMessage().contains("<init>")) {
serial_output = null;
println("Radios_Config: connect_to_portName: port in use, trying again later...");
println("Radios_Config: connect_to_portName: Port in use, trying again later...");
// portIsOpen = false;
} else{
println("RunttimeException: " + e);
output("Error connecting to selected Serial/COM port. Make sure your board is powered up and your dongle is plugged in.");
} else {
println("Error connecting to selected Serial/COM port. Make sure your board is powered up and your dongle is plugged in.");
rcConfig.print_onscreen("Error connecting to Serial port. Try a different port?");
}
board = null;
println("Radios_Config: connect_to_portName: failed to connect to " + openBCI_portName);
println("Failed to connect using " + openBCI_portName);
return false;
}
} else {
Expand Down Expand Up @@ -180,6 +185,13 @@ void system_status(RadioConfigBox rcConfig){
delay(100);
if(!print_bytes(rcConfig)){
print_bytes_error(rcConfig);
} else {
String[] s = split(rcStringReceived, ':');
if (s[0].equals("Success")) {
outputSuccess("Successfully connected to Cyton using " + openBCI_portName);
} else {
outputError("Failed to connect using " + openBCI_portName + ". Check hardware or try pressing 'Autoscan'.");
}
}
} else {
println("Error, no board connected");
Expand Down Expand Up @@ -315,4 +327,3 @@ void set_channel_over(RadioConfigBox rcConfig, int channel_number){
rcConfig.print_onscreen("No board connected!");
}
}

13 changes: 11 additions & 2 deletions OpenBCI_GUI/SoftwareSettings.pde
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ class SoftwareSettings {

//Take a snapshot of the default GUI settings on every system init
println("InitSettings: Saving Default Settings to file!");
this.save(defaultSettingsFileToSave); //to avoid confusion with save() image
try {
this.save(defaultSettingsFileToSave); //to avoid confusion with save() image
} catch (Exception e) {
println("InitSettings: Error trying to save settings");
}

//Try Auto-load GUI settings between checkpoints 4 and 5 during system init.
//Otherwise, load default settings.
Expand All @@ -294,6 +298,10 @@ class SoftwareSettings {
//e.printStackTrace();
println("InitSettings: " + settingsFileToLoad + " not found or other error.");
errorUserSettingsNotFound = true;
File f = new File(sketchPath()+System.getProperty("file.separator")+settingsFileToLoad);
if (f.exists()) {
if (f.delete()) println("SoftwareSettings: Removed old settings file.");
}
}
}

Expand Down Expand Up @@ -1454,8 +1462,9 @@ void loadConfigFile(File selection) {
} else if (settings.dataSourceError == true) {
outputError("Settings Error: Data Source Mismatch Detected");
} else {
outputError("Error trying to load settings file. Try 'Clear All Settings'");
outputError("Error trying to load settings file, possibly from previous GUI. Removing old settings.");
}
if (selection.exists()) selection.delete();
}
settings.loadDialogName = null; //reset this variable for future use
}
Expand Down
Loading

0 comments on commit 03110ab

Please sign in to comment.