diff --git a/OpenBCI_GUI/SessionSettings.pde b/OpenBCI_GUI/SessionSettings.pde index b90bf1180..bea71ae8a 100644 --- a/OpenBCI_GUI/SessionSettings.pde +++ b/OpenBCI_GUI/SessionSettings.pde @@ -200,6 +200,11 @@ class SessionSettings { private int loadMarkerWindow; private int loadMarkerVertScale; + //Focus Widget + private int loadFocusMetric; + private int loadFocusThreshold; + private int loadFocusWindow; + //Primary JSON objects for saving and loading data private JSONObject saveSettingsJSONData; private JSONObject loadSettingsJSONData; @@ -218,6 +223,7 @@ class SessionSettings { private final String kJSONKeyEmg = "emg"; private final String kJSONKeyEmgJoystick = "emgJoystick"; private final String kJSONKeyMarker = "marker"; + private final String kJSONKeyFocus = "focus"; //used only in this class to count the number of channels being used while saving/loading, this gets updated in updateToNChan whenever the number of channels being used changes int slnchan; @@ -497,6 +503,13 @@ class SessionSettings { saveMarkerSettings.setInt("markerVertScale", w_marker.getMarkerVertScale().getIndex()); saveSettingsJSONData.setJSONObject(kJSONKeyMarker, saveMarkerSettings); + ///////////////////////////////////////////////Setup new JSON object to save Marker Widget Settings + JSONObject saveFocusSettings = new JSONObject(); + saveFocusSettings.setInt("focusMetric", w_focus.getFocusMetric().getIndex()); + saveFocusSettings.setInt("focusThreshold", w_focus.getFocusThreshold().getIndex()); + saveFocusSettings.setInt("focusWindow", w_focus.getFocusWindow().getIndex()); + saveSettingsJSONData.setJSONObject(kJSONKeyFocus, saveFocusSettings); + ///////////////////////////////////////////////Setup new JSON object to save Widgets Active in respective Containers JSONObject saveWidgetSettings = new JSONObject(); @@ -691,6 +704,12 @@ class SessionSettings { loadMarkerWindow = loadMarkerSettings.getInt("markerWindow"); loadMarkerVertScale = loadMarkerSettings.getInt("markerVertScale"); + //Get Focus widget settings + JSONObject loadFocusSettings = loadSettingsJSONData.getJSONObject(kJSONKeyFocus); + loadFocusMetric = loadFocusSettings.getInt("focusMetric"); + loadFocusThreshold = loadFocusSettings.getInt("focusThreshold"); + loadFocusWindow = loadFocusSettings.getInt("focusWindow"); + //get the Widget/Container settings JSONObject loadWidgetSettings = loadSettingsJSONData.getJSONObject(kJSONKeyWidget); //Apply Layout directly before loading and applying widgets to containers @@ -955,6 +974,14 @@ class SessionSettings { w_marker.setMarkerVertScale(loadMarkerVertScale); w_marker.cp5_widget.getController("markerVertScaleDropdown").getCaptionLabel().setText(w_marker.getMarkerVertScale().getString()); + ////////////////////////////Apply Focus Widget settings + w_focus.setMetric(loadFocusMetric); + w_focus.cp5_widget.getController("focusMetricDropdown").getCaptionLabel().setText(w_focus.getFocusMetric().getString()); + w_focus.setThreshold(loadFocusThreshold); + w_focus.cp5_widget.getController("focusThresholdDropdown").getCaptionLabel().setText(w_focus.getFocusThreshold().getString()); + w_focus.setFocusHorizScale(loadFocusWindow); + w_focus.cp5_widget.getController("focusWindowDropdown").getCaptionLabel().setText(w_focus.getFocusWindow().getString()); + //////////////////////////////////////////////////////////// // Apply more loaded widget settings above this line // diff --git a/OpenBCI_GUI/W_Focus.pde b/OpenBCI_GUI/W_Focus.pde index e08f33695..83357b650 100644 --- a/OpenBCI_GUI/W_Focus.pde +++ b/OpenBCI_GUI/W_Focus.pde @@ -90,7 +90,6 @@ class W_Focus extends Widget { //This is the protocol for setting up dropdowns. dropdownWidth = 60; //Override the default dropdown width for this widget addDropdown("focusMetricDropdown", "Metric", focusMetric.getEnumStringsAsList(), focusMetric.getIndex()); - addDropdown("focusClassifierDropdown", "Classifier", focusClassifier.getEnumStringsAsList(), focusClassifier.getIndex()); addDropdown("focusThresholdDropdown", "Threshold", focusThreshold.getEnumStringsAsList(), focusThreshold.getIndex()); addDropdown("focusWindowDropdown", "Window", xLimit.getEnumStringsAsList(), xLimit.getIndex()); @@ -191,12 +190,7 @@ class W_Focus extends Widget { //Custom resize these dropdowns due to longer text strings as options cp5_widget.get(ScrollableList.class, "focusMetricDropdown").setWidth(METRIC_DROPDOWN_W); cp5_widget.get(ScrollableList.class, "focusMetricDropdown").setPosition( - x0 + w0 - (dropdownWidth*2) - METRIC_DROPDOWN_W - CLASSIFIER_DROPDOWN_W - (PAD_TWO*4), - navH + y0 + PAD_TWO - ); - cp5_widget.get(ScrollableList.class, "focusClassifierDropdown").setWidth(CLASSIFIER_DROPDOWN_W); - cp5_widget.get(ScrollableList.class, "focusClassifierDropdown").setPosition( - x0 + w0 - (dropdownWidth*2) - CLASSIFIER_DROPDOWN_W - (PAD_TWO*3), + x0 + w0 - (dropdownWidth*2) - METRIC_DROPDOWN_W - (PAD_TWO*3), navH + y0 + PAD_TWO ); } @@ -416,6 +410,18 @@ class W_Focus extends Widget { metricPrediction = updateFocusState(); predictionExceedsThreshold = metricPrediction > focusThreshold.getValue(); } + + public FocusMetric getFocusMetric() { + return focusMetric; + } + + public FocusThreshold getFocusThreshold() { + return focusThreshold; + } + + public FocusXLim getFocusWindow() { + return xLimit; + } }; //end of class //The following global functions are used by the Focus widget dropdowns. This method is the least amount of code. @@ -427,10 +433,6 @@ public void focusMetricDropdown(int n) { w_focus.setMetric(n); } -public void focusClassifierDropdown(int n) { - w_focus.setClassifier(n); -} - public void focusThresholdDropdown(int n) { w_focus.setThreshold(n); }