Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Cyton Data Smoothing to True by Default and Change Button Text #1033

Merged
merged 15 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ install:
- mkdir $TRAVIS_BUILD_DIR/temp; cd $TRAVIS_BUILD_DIR/temp

### ### LINUX ### ###
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then curl -O -L --insecure https://github.com/processing/processing4/releases/download/processing-1278-4.0b3/processing-4.0b3-linux64.tgz ;fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then tar -xzvf processing-4.0b3-linux64.tgz ;fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then export PATH=$TRAVIS_BUILD_DIR/temp/processing-4.0b3:$PATH ;fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then curl -O -L --insecure https://github.com/processing/processing4/releases/download/processing-1282-4.0b7/processing-4.0b7-linux-x64.tgz ;fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then tar -xzvf processing-4.0b7-linux-x64.tgz ;fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then export PATH=$TRAVIS_BUILD_DIR/temp/processing-4.0b7:$PATH ;fi
# copy libraries to linux location
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then mkdir -p $HOME/sketchbook/libraries/ ;fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cp -a $TRAVIS_BUILD_DIR/OpenBCI_GUI/libraries/. $HOME/sketchbook/libraries/ ;fi

### ### MAC ### ###
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then curl -O -L --insecure https://github.com/processing/processing4/releases/download/processing-1278-4.0b3/processing-4.0b3-macosx.zip ;fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then unzip processing-4.0b3-macosx.zip ;fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then curl -O -L --insecure https://github.com/processing/processing4/releases/download/processing-1282-4.0b7/processing-4.0b7-macos-x64.zip ;fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then unzip processing-4.0b7-macos-x64.zip ;fi
# Processing.app must be in this location for processing-java to work
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then mv Processing.app /Applications/Processing.app ;fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export PATH=$TRAVIS_BUILD_DIR/release_script/mac_only:$PATH ;fi
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
* Revisit Ganglion Impedance widget so it behaves like new Cyton Impedance Widget #1021

### Improvements
* Update to Processing 4 and Java 11 #674 #1025
* Update to Processing 4 #674 #1025
* Add BrainFlow Streamer for File and Network to Control Panel #1007
* Update to BrainFlow v4.9.0 and print version to console log #1028
* Update OpenBCI Logo #1010
* Clarify Cyton Smoothing feature #1027
* Set Cyton Smoothing on by default and increase communication with a popup and additional Help button #1026
* Update help text for various buttons across the GUI to help new and existing users

# v5.0.9

Expand Down
2 changes: 1 addition & 1 deletion OpenBCI_GUI/BoardCyton.pde
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ abstract class BoardCytonSerialBase extends BoardCyton implements SmoothingCapab

public BoardCytonSerialBase() {
super();
smoothData = false;
setSmoothingActive(true);
}

// synchronized is important to ensure that we dont free buffers during getting data
Expand Down
51 changes: 44 additions & 7 deletions OpenBCI_GUI/GuiSettings.pde
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import java.io.*;
import java.util.regex.*;


interface GuiSettingsEnum {
Expand Down Expand Up @@ -30,29 +32,29 @@ enum ExpertModeEnum implements GuiSettingsEnum {
}

public class GuiSettingsValues {
private ExpertModeEnum expertMode = ExpertModeEnum.OFF;
public ExpertModeEnum expertMode = ExpertModeEnum.OFF;
public boolean showCytonSmoothingPopup = true;

public GuiSettingsValues() {
}
}

class GuiSettings {

public GuiSettingsValues values;
private GuiSettingsValues values;
private String filename;
private List<String> valueKeys = Arrays.asList("expertMode", "showCytonSmoothingPopup");

GuiSettings(String settingsDirectory) {

values = new GuiSettingsValues();

StringBuilder settingsFilename = new StringBuilder(settingsDirectory);
settingsFilename.append("GuiWideSettings.json");
filename = settingsFilename.toString();
File fileToCheck = new File(filename);
boolean fileExists = fileToCheck.exists();
if (fileExists) {
loadSettingsValues();
println("OpenBCI_GUI::Settings: Found and loaded existing GUI-wide Settings from file.");
} else {
println("OpenBCI_GUI::Settings: Creating new GUI-wide Settings file.");
saveToFile();
Expand All @@ -61,22 +63,34 @@ class GuiSettings {

public boolean loadSettingsValues() {
try {

File file = new File(filename);
StringBuilder fileContents = new StringBuilder((int)file.length());
Scanner scanner = new Scanner(file);

while(scanner.hasNextLine()) {
fileContents.append(scanner.nextLine() + System.lineSeparator());
}
Gson gson = new Gson();
values = gson.fromJson(fileContents.toString(), GuiSettingsValues.class);

//Check for incompatible or old settings
if (validateJsonKeys(fileContents.toString())) {
Gson gson = new Gson();
values = gson.fromJson(fileContents.toString(), GuiSettingsValues.class);
println("OpenBCI_GUI::Settings: Found and loaded existing GUI-wide Settings from file.");
} else {
println("OpenBCI_GUI::Settings: Incompatible GUI-wide Settings found. Creating new file and resetting defaults.");
Andrey1994 marked this conversation as resolved.
Show resolved Hide resolved
saveToFile();
}

return true;

} catch (IOException e) {
e.printStackTrace();
outputWarn("OpenBCI_GUI::Settings: Error loading GUI-wide settings from file. Attempting to create a new one.");
//If there is an error, attempt to overwrite the file or create a new one
saveToFile();
return false;
}
}
}

public String getJson() {
Expand Down Expand Up @@ -114,6 +128,20 @@ class GuiSettings {
}
}

private boolean validateJsonKeys(String stringToSearch) {
List<String> foundKeys = new ArrayList<String>();
Gson gson = new Gson();
Map<String, Object> map = gson.fromJson(stringToSearch, new TypeToken<Map<String, Object>>() {}.getType());
map.forEach((x, y) -> foundKeys.add(x));

Collections.sort(valueKeys);
Collections.sort(foundKeys);

boolean isEqual = valueKeys.equals(foundKeys);

return isEqual;
}

//Call this method at the end of GUI main Setup in OpenBCI_GUI.pde to make sure everything exists
//Has to be in this class to make sure other classes exist
public void applySettings() {
Expand All @@ -128,4 +156,13 @@ class GuiSettings {
public boolean getExpertModeBoolean() {
return values.expertMode.getBooleanValue();
}

public void setShowCytonSmoothingPopup(boolean b) {
values.showCytonSmoothingPopup = b;
saveToFile();
}

public boolean getShowCytonSmoothingPopup() {
return values.showCytonSmoothingPopup;
}
}
4 changes: 2 additions & 2 deletions OpenBCI_GUI/Info.plist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
<key>NSHumanReadableCopyright</key>
<string>MIT License

Copyright © 2021 OpenBCI
Copyright © 2022 OpenBCI
</string>
<key>CFBundleGetInfoString</key>
<string>February 2021</string>
<string>March 2022</string>
<!-- End of the set that can be customized -->

@@jvm_runtime@@
Expand Down
24 changes: 22 additions & 2 deletions OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ import http.requests.*;
// Global Variables & Instances
//------------------------------------------------------------------------
//Used to check GUI version in TopNav.pde and displayed on the splash screen on startup
String localGUIVersionString = "v5.1.0-alpha.3";
String localGUIVersionDate = "February 2021";
String localGUIVersionString = "v5.1.0-alpha.4";
String localGUIVersionDate = "March 2022";
String guiLatestVersionGithubAPI = "https://api.github.com/repos/OpenBCI/OpenBCI_GUI/releases/latest";
String guiLatestReleaseLocation = "https://github.com/OpenBCI/OpenBCI_GUI/releases/latest";
Boolean guiIsUpToDate;
Expand Down Expand Up @@ -637,6 +637,24 @@ void initSystem() {
return;
}
}

//Show a popup to inform first-time Cyton users about the FTDI buffer fix and Cyton Smoothing feature. Fixes #1026
if (guiSettings.getShowCytonSmoothingPopup()) {
println("OpenBCI_GUI: Showing Cyton FTDI Buffer Fix Popup");
String popupTitle = "Cyton FTDI Buffer Fix Info";
String popupString = "The default settings for the Cyton Dongle driver can make data appear \"choppy.\" Visit the OpenBCI Docs to learn how to fix this. For now, the GUI will \"smooth\" the data for you.";
String popupButtonText = "View Fix";
String popupButtonURL;
if (isMac()) {
popupButtonURL = "https://docs.openbci.com/Troubleshooting/FTDI_Fix_Mac/";
} else if (isLinux()){
popupButtonURL = "https://docs.openbci.com/Troubleshooting/FTDI_Fix_Linux/";
} else {
popupButtonURL = "https://docs.openbci.com/Troubleshooting/FTDI_Fix_Windows/";
}
PopupMessage msg = new PopupMessage(popupTitle, popupString, popupButtonText, popupButtonURL);
guiSettings.setShowCytonSmoothingPopup(false);
}
}

updateToNChan(currentBoard.getNumEXGChannels());
Expand Down Expand Up @@ -687,6 +705,8 @@ void initSystem() {
//Make sure topNav buttons draw in the correct spot
topNav.screenHasBeenResized(width, height);

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

midInit = false;
} //end initSystem

Expand Down
2 changes: 1 addition & 1 deletion OpenBCI_GUI/PopupMessage.pde
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PopupMessage extends PApplet implements Runnable {
private final int headerHeight = 55;
private final int padding = 20;

private final int buttonWidth = 100;
private final int buttonWidth = 120;
private final int buttonHeight = 40;

private String message = "Empty Popup";
Expand Down
2 changes: 1 addition & 1 deletion OpenBCI_GUI/RadioConfig.pde
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class RadioConfig {
String[] s = split(rcStringReceived, ':');
closeSerialPort();
if (s[0].equals("Success")) {
println(rcStringReceived + " using COM port: " + openBCI_portName);
println(rcStringReceived + ". Using COM port: " + openBCI_portName);
return true;
} else {
verbosePrint("Failed to connect using " + openBCI_portName + ". Check hardware or try pressing 'Auto-Scan'.");
Expand Down
44 changes: 35 additions & 9 deletions OpenBCI_GUI/TopNav.pde
Original file line number Diff line number Diff line change
Expand Up @@ -462,16 +462,20 @@ class TopNav {
}

private void createSmoothingButton(String text, int _x, int _y, int _w, int _h, PFont font, int _fontSize, color _bg, color _textColor) {
smoothingButton = createTNButton("smoothingButton", text, _x, _y, _w, _h, font, _fontSize, _bg, _textColor);
SmoothingCapableBoard smoothBoard = (SmoothingCapableBoard)currentBoard;
color bgColor = smoothBoard.getSmoothingActive() ? _bg : BUTTON_LOCKED_GREY;
smoothingButton = createTNButton("smoothingButton", text, _x, _y, _w, _h, font, _fontSize, bgColor, _textColor);
smoothingButton.getCaptionLabel().getStyle().setMarginTop(-int(_h/4));
smoothingButton.onRelease(new CallbackListener() {
public void controlEvent(CallbackEvent theEvent) {
SmoothingCapableBoard smoothBoard = (SmoothingCapableBoard)currentBoard;
smoothBoard.setSmoothingActive(!smoothBoard.getSmoothingActive());
smoothingButton.getCaptionLabel().setText(getSmoothingString());
color _bgColor = smoothBoard.getSmoothingActive() ? _bg : BUTTON_LOCKED_GREY;
smoothingButton.setColorBackground(_bgColor);
}
});
smoothingButton.setDescription("Click here to turn data smoothing on or off.");
smoothingButton.setDescription("The default settings for the Cyton Dongle driver can make data appear \"choppy.\" This feature will \"smooth\" the data for you. Click \"Help\" -> \"Cyton Driver Fix\" for more info. Clicking here will toggle this setting.");
}

private void createLayoutButton(String text, int _x, int _y, int _w, int _h, PFont font, int _fontSize, color _bg, color _textColor) {
Expand Down Expand Up @@ -1070,7 +1074,8 @@ class TutorialSelector {
private Button troubleshootingGuide;
private Button customWidgets;
private Button openbciForum;
private final int numButtons = 5;
private Button ftdiBufferFix;
private final int NUM_TUTORIAL_BUTTONS = 6;

TutorialSelector() {
w = 180;
Expand All @@ -1080,7 +1085,7 @@ class TutorialSelector {
margin = 6;
b_w = w - margin*2;
b_h = 22;
h = margin*(numButtons+1) + b_h*numButtons;
h = margin*(NUM_TUTORIAL_BUTTONS+1) + b_h*NUM_TUTORIAL_BUTTONS;

//Instantiate local cp5 for this box
tutorial_cp5 = new ControlP5(ourApplet);
Expand All @@ -1094,6 +1099,8 @@ class TutorialSelector {
buttonNumber++;
createTestingImpedanceButton("testingImpedance", "Testing Impedance", x + margin, y + margin*(buttonNumber+1) + b_h*(buttonNumber), b_w, b_h);
buttonNumber++;
createFtdiBufferFixButton("ftdiBufferFix", "Cyton Driver Fix", x + margin, y + margin*(buttonNumber+1) + b_h*(buttonNumber), b_w, b_h);
buttonNumber++;
createTroubleshootingGuideButton("troubleshootingGuide", "Troubleshooting Guide", x + margin, y + margin*(buttonNumber+1) + b_h*(buttonNumber), b_w, b_h);
buttonNumber++;
createCustomWidgetsButton("customWidgets", "Building Custom Widgets", x + margin, y + margin*(buttonNumber+1) + b_h*(buttonNumber), b_w, b_h);
Expand Down Expand Up @@ -1192,7 +1199,7 @@ class TutorialSelector {
toggleVisibility(); //shut layoutSelector if something is selected
}
});
//gettingStarted.setDescription("Here you can alter the overall layout of the GUI, allowing for different container configurations with more or less widgets.");
gettingStarted.setDescription("Need help getting started? Click here to view the official OpenBCI Getting Started guides.");
}

private void createTestingImpedanceButton(String name, String text, int _x, int _y, int _w, int _h) {
Expand All @@ -1203,7 +1210,7 @@ class TutorialSelector {
toggleVisibility(); //shut layoutSelector if something is selected
}
});
//testingImpedance.setDescription("Here you can alter the overall layout of the GUI, allowing for different container configurations with more or less widgets.");
testingImpedance.setDescription("Click here to learn more about testing the impedance on electrodes using the OpenBCI GUI. This process is different for Cyton and Ganglion. Checking impedance only works with passive electrodes.");
}

private void createTroubleshootingGuideButton(String name, String text, int _x, int _y, int _w, int _h) {
Expand All @@ -1214,7 +1221,7 @@ class TutorialSelector {
toggleVisibility(); //shut layoutSelector if something is selected
}
});
//troubleshootingGuide.setDescription("Here you can alter the overall layout of the GUI, allowing for different container configurations with more or less widgets.");
troubleshootingGuide.setDescription("Having trouble? Start here with some general troubleshooting tips found on the OpenBCI Docs.");
}

private void createCustomWidgetsButton(String name, String text, int _x, int _y, int _w, int _h) {
Expand All @@ -1225,7 +1232,7 @@ class TutorialSelector {
toggleVisibility(); //shut layoutSelector if something is selected
}
});
//customWidgets.setDescription("Here you can alter the overall layout of the GUI, allowing for different container configurations with more or less widgets.");
customWidgets.setDescription("Click here to learn about creating your own custom OpenBCI widgets!");
}

private void createOpenbciForumButton(String name, String text, int _x, int _y, int _w, int _h) {
Expand All @@ -1236,6 +1243,25 @@ class TutorialSelector {
toggleVisibility(); //shut layoutSelector if something is selected
}
});
//openbciForum.setDescription("Here you can alter the overall layout of the GUI, allowing for different container configurations with more or less widgets.");
openbciForum.setDescription("Click here to visit the official OpenBCI Forum.");
}

private void createFtdiBufferFixButton(String name, String text, int _x, int _y, int _w, int _h) {
openbciForum = createButton(tutorial_cp5, name, text, _x, _y, _w, _h);
openbciForum.onRelease(new CallbackListener() {
public void controlEvent(CallbackEvent theEvent) {
String ftdiDriverDocUrl;
if (isMac()) {
ftdiDriverDocUrl = "https://docs.openbci.com/Troubleshooting/FTDI_Fix_Mac/";
} else if (isLinux()){
ftdiDriverDocUrl = "https://docs.openbci.com/Troubleshooting/FTDI_Fix_Linux/";
} else {
ftdiDriverDocUrl = "https://docs.openbci.com/Troubleshooting/FTDI_Fix_Windows/";
}
openURLInBrowser(ftdiDriverDocUrl);
toggleVisibility(); //shut layoutSelector if something is selected
}
});
openbciForum.setDescription("Here you can alter the overall layout of the GUI, allowing for different container configurations with more or less widgets.");
}
}
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build: off

init:
# add processing-java to the path as well as mt.exe (release script uses it to modify the manifest.xml)
- cmd: set PATH=%APPVEYOR_BUILD_FOLDER%\temp\processing-4.0b3;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\;%PATH%
- cmd: set PATH=%APPVEYOR_BUILD_FOLDER%\temp\processing-4.0b7;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\;%PATH%

install:
# used for getting commit timestamp
Expand All @@ -34,8 +34,8 @@ install:

- mkdir %APPVEYOR_BUILD_FOLDER%\temp
- cd %APPVEYOR_BUILD_FOLDER%\temp
- appveyor DownloadFile https://github.com/processing/processing4/releases/download/processing-1278-4.0b3/processing-4.0b3-windows64.zip
- 7z x processing-4.0b3-windows64.zip -y -aoa
- appveyor DownloadFile https://github.com/processing/processing4/releases/download/processing-1282-4.0b7/processing-4.0b7-windows-x64.zip
- 7z x processing-4.0b7-windows-x64.zip -y -aoa
# cp libraries
- mkdir %userprofile%\documents\processing\libraries
- xcopy %APPVEYOR_BUILD_FOLDER%\OpenBCI_GUI\libraries\* %userprofile%\documents\processing\libraries /s /i /q
Expand Down
Loading