Skip to content

Commit

Permalink
Merge pull request #947 from retiutut/session_settings_fix_jan2021
Browse files Browse the repository at this point in the history
Session settings fix jan2021
  • Loading branch information
retiutut authored Jan 26, 2021
2 parents ae39b8e + 8b9fee8 commit 0b8b64c
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Fix Pulse LSL output error #943
* Fix Accel/Aux UDP output #944
* Fix Expert Mode unplanned keyboard shortcuts crash GUI #941
* Fix bugs found when loading Session Settings #942

# v5.0.2

Expand Down
4 changes: 2 additions & 2 deletions OpenBCI_GUI/DataProcessing.pde
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class DataProcessing {
float data_std_uV[];
float polarity[];
boolean newDataToSend;
BandPassRanges bpRange = BandPassRanges.FiveToFifty;
BandStopRanges bsRange = BandStopRanges.Sixty;
public BandPassRanges bpRange = BandPassRanges.FiveToFifty;
public BandStopRanges bsRange = BandStopRanges.Sixty;
final int[] processing_band_low_Hz = {
1, 4, 8, 13, 30
}; //lower bound for each frequency band of interest (2D classifier only)
Expand Down
44 changes: 33 additions & 11 deletions OpenBCI_GUI/FilterEnums.pde
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
public enum BandStopRanges
{
Sixty(60.0d),
Fifty(50.0d),
None(null);
Sixty(0, 60.0d),
Fifty(1, 50.0d),
None(2, null);

private int index;
private Double freq;

private static BandStopRanges[] vals = values();

BandStopRanges(Double freq) {
BandStopRanges(int index, Double freq) {
this.index = index;
this.freq = freq;
}

public int getIndex() {
return index;
}

public Double getFreq() {
return freq;
}

public static BandStopRanges getByIndex(int i)
{
return vals[i];
}

public BandStopRanges next()
{
return vals[(this.ordinal() + 1) % vals.length];
Expand All @@ -31,22 +42,28 @@ public enum BandStopRanges

public enum BandPassRanges
{
FiveToFifty(5.0d, 50.0d),
SevenToThirteen(7.0d, 13.0d),
FifteenToFifty(15.0d, 50.0d),
OneToFifty(1.0d, 50.0d),
OneToHundred(1.0d, 100.0d),
None(null, null);
FiveToFifty(0, 5.0d, 50.0d),
SevenToThirteen(1, 7.0d, 13.0d),
FifteenToFifty(2, 15.0d, 50.0d),
OneToFifty(3, 1.0d, 50.0d),
OneToHundred(4, 1.0d, 100.0d),
None(5, null, null);

private int index;
private Double start;
private Double stop;

private static BandPassRanges[] vals = values();

BandPassRanges(Double start, Double stop) {
BandPassRanges(int index, Double start, Double stop) {
this.index = index;
this.start = start;
this.stop = stop;
}

public int getIndex() {
return index;
}

public Double getStart() {
return start;
Expand All @@ -56,6 +73,11 @@ public enum BandPassRanges
return stop;
}

public static BandPassRanges getByIndex(int i)
{
return vals[i];
}

public BandPassRanges next()
{
return vals[(this.ordinal() + 1) % vals.length];
Expand Down
2 changes: 1 addition & 1 deletion 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.3-alpha.3</string>
<string>5.0.3-beta.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ 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.0.3-alpha.3";
String localGUIVersionString = "v5.0.3-beta.0";
String localGUIVersionDate = "January 2020";
String guiLatestVersionGithubAPI = "https://api.github.com/repos/OpenBCI/OpenBCI_GUI/releases/latest";
String guiLatestReleaseLocation = "https://github.com/OpenBCI/OpenBCI_GUI/releases/latest";
Expand Down
54 changes: 33 additions & 21 deletions OpenBCI_GUI/SessionSettings.pde
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ class SessionSettings {
CColor dropdownColors = new CColor();
///These `Save` vars are set to default when each widget instantiates
///and updated every time user selects from dropdown
//Notch and Bandpass filter variables for save
int dataProcessingNotchSave = 0;
int dataProcessingBandpassSave = 3;
//Accelerometer settings
int accVertScaleSave;
int accHorizScaleSave;
Expand Down Expand Up @@ -171,11 +168,6 @@ class SessionSettings {
String[] spectMaxFrqArray = {"20 Hz", "40 Hz", "60 Hz", "100 Hz", "120 Hz", "250 Hz"};
String[] spectSampleRateArray = {"1 Hz", "5 hz", "10 Hz", "20 Hz", "40 Hz"};

//Load global settings variables
int loadLayoutSetting;
int loadNotchSetting;
int loadBandpassSetting;

//Load Accel. dropdown variables
int loadAccelVertScale;
int loadAccelHorizScale;
Expand Down Expand Up @@ -376,10 +368,13 @@ class SessionSettings {
JSONObject saveGlobalSettings = new JSONObject();
saveGlobalSettings.setBoolean("Expert Mode", expertModeToggle);
saveGlobalSettings.setInt("Current Layout", currentLayout);
saveGlobalSettings.setInt("Notch", dataProcessingNotchSave);
saveGlobalSettings.setInt("Bandpass Filter", dataProcessingBandpassSave);
saveGlobalSettings.setInt("Notch", dataProcessing.bsRange.getIndex());
saveGlobalSettings.setInt("Bandpass Filter", dataProcessing.bpRange.getIndex());
saveGlobalSettings.setInt("Analog Read Vert Scale", arVertScaleSave);
saveGlobalSettings.setInt("Analog Read Horiz Scale", arHorizScaleSave);
if (currentBoard instanceof SmoothingCapableBoard) {
saveGlobalSettings.setBoolean("Data Smoothing", ((SmoothingCapableBoard)currentBoard).getSmoothingActive());
}
saveSettingsJSONData.setJSONObject(kJSONKeySettings, saveGlobalSettings);

/////Setup JSON Object for gui version and settings Version
Expand Down Expand Up @@ -585,15 +580,15 @@ class SessionSettings {

//get the global settings JSON object
JSONObject loadGlobalSettings = loadSettingsJSONData.getJSONObject(kJSONKeySettings);
loadLayoutSetting = loadGlobalSettings.getInt("Current Layout");
loadNotchSetting = loadGlobalSettings.getInt("Notch");
loadBandpassSetting = loadGlobalSettings.getInt("Bandpass Filter");
Boolean loadExpertModeToggle = loadGlobalSettings.getBoolean("Expert Mode");
//Store loaded layout to current layout variable
currentLayout = loadGlobalSettings.getInt("Current Layout");
loadAnalogReadVertScale = loadGlobalSettings.getInt("Analog Read Vert Scale");
loadAnalogReadHorizScale = loadGlobalSettings.getInt("Analog Read Horiz Scale");
//Store loaded layout to current layout variable
currentLayout = loadLayoutSetting;
//Load more global settings after this line, if needed
int loadNotchSetting = loadGlobalSettings.getInt("Notch");
int loadBandpassSetting = loadGlobalSettings.getInt("Bandpass Filter");
Boolean loadExpertModeToggle = loadGlobalSettings.getBoolean("Expert Mode");
Boolean loadDataSmoothingSetting = (currentBoard instanceof SmoothingCapableBoard) ? loadGlobalSettings.getBoolean("Data Smoothing") : null;

//get the FFT settings
JSONObject loadFFTSettings = loadSettingsJSONData.getJSONObject(kJSONKeyFFT);
Expand Down Expand Up @@ -717,8 +712,8 @@ class SessionSettings {
//get the Widget/Container settings
JSONObject loadWidgetSettings = loadSettingsJSONData.getJSONObject(kJSONKeyWidget);
//Apply Layout directly before loading and applying widgets to containers
wm.setNewContainerLayout(loadLayoutSetting);
verbosePrint("LoadGUISettings: Layout " + loadLayoutSetting + " Loaded!");
wm.setNewContainerLayout(currentLayout);
verbosePrint("LoadGUISettings: Layout " + currentLayout + " Loaded!");
numLoadedWidgets = loadWidgetSettings.size();


Expand Down Expand Up @@ -749,11 +744,28 @@ class SessionSettings {

/////////////////////////////////////////////////////////////
// Load more widget settings above this line as above //
/////////////////////////////////////////////////////////////

//}//end case for all objects in JSON
/////////////////////////////////////////////////////////////
// Apply Settings below this line //
/////////////////////////////////////////////////////////////

//Apply notch
dataProcessing.bsRange = BandStopRanges.getByIndex(loadNotchSetting);
topNav.filtNotchButton.getCaptionLabel().setText("Notch\n" + dataProcessing.getShortNotchDescription());
//Apply Bandpass filter
dataProcessing.bpRange = BandPassRanges.getByIndex(loadBandpassSetting);
topNav.filtBPButton.getCaptionLabel().setText("BP Filt\n" + dataProcessing.getShortFilterDescription());

//Apply Data Smoothing for capable boards
if (currentBoard instanceof SmoothingCapableBoard) {
((SmoothingCapableBoard)currentBoard).setSmoothingActive(loadDataSmoothingSetting);
topNav.updateSmoothingButtonText();
}

//Apply Expert Mode toggle
topNav.configSelector.toggleExpertMode(loadExpertModeToggle);
//This should not be loaded with other session settings - RW Jan 2021
//topNav.configSelector.toggleExpertMode(loadExpertModeToggle);

//Load and apply all of the settings that are in dropdown menus. It's a bit much, so it has it's own function below.
loadApplyWidgetDropdownText();
Expand Down Expand Up @@ -987,7 +999,7 @@ class SessionSettings {
w_timeSeries.cp5_widget.getController("VertScale_TS").getCaptionLabel().setText(w_timeSeries.getTSVertScale().getString()); //changes front-end

w_timeSeries.setTSHorizScale(loadTimeSeriesSettings.getInt("Time Series Horiz Scale"));
w_timeSeries.cp5_widget.getController("Duration").getCaptionLabel().setText(w_timeSeries.getTSVertScale().getString());
w_timeSeries.cp5_widget.getController("Duration").getCaptionLabel().setText(w_timeSeries.getTSHorizScale().getString());

JSONArray loadTSChan = loadTimeSeriesSettings.getJSONArray("activeChannels");
w_timeSeries.tsChanSelect.deactivateAllButtons();
Expand Down
4 changes: 4 additions & 0 deletions OpenBCI_GUI/TopNav.pde
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ class TopNav {
return val;
}

public void updateSmoothingButtonText() {
smoothingButton.getCaptionLabel().setText(getSmoothingString());
}

private String getSmoothingString() {
return ((SmoothingCapableBoard)currentBoard).getSmoothingActive() ? "Smoothing\n On" : "Smoothing\n Off";
}
Expand Down
3 changes: 0 additions & 3 deletions OpenBCI_GUI/W_Spectrogram.pde
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,6 @@ class W_Spectrogram extends Widget {
//triggered when there is an event in the Spectrogram Widget MaxFreq. Dropdown
void SpectrogramMaxFreq(int n) {
settings.spectMaxFrqSave = n;
//Link the choices made in the FFT widget and the Spectrogram Widget for this parameter
MaxFreq(n);
w_fft.cp5_widget.getController("MaxFreq").getCaptionLabel().setText(settings.fftMaxFrqArray[n]);
//reset the vertical axis labelss
w_spectrogram.vertAxisLabel = w_spectrogram.vertAxisLabels[n];
//Resize the height of the data image
Expand Down

0 comments on commit 0b8b64c

Please sign in to comment.