Skip to content

Commit 47766db

Browse files
authored
Merge pull request #1240 from OpenBCI/independent-widget-settings
GUI v7 - Second major refactor
2 parents fc59720 + 916b941 commit 47766db

60 files changed

Lines changed: 4682 additions & 5545 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

OpenBCI_GUI/ADS1299SettingsController.pde

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import org.apache.commons.lang3.tuple.Pair;
22

33

44
class ADS1299SettingsController {
5-
private PApplet _parentApplet;
5+
private PApplet parentApplet;
66
private boolean isVisible = false;
77
protected int x, y, w, h;
88
protected final int PADDING_3 = 3;
@@ -64,16 +64,16 @@ class ADS1299SettingsController {
6464
protected int channelCount;
6565
protected List<Integer> activeChannels;
6666

67-
ADS1299SettingsController(PApplet _parent, List<Integer> _activeChannels, int _x, int _y, int _w, int _h, int _channelBarHeight) {
67+
ADS1299SettingsController(PApplet _parentApplet, List<Integer> _activeChannels, int _x, int _y, int _w, int _h, int _channelBarHeight) {
6868
x = _x;
6969
y = _y;
7070
w = _w;
7171
h = _h;
7272
channelBarHeight = _channelBarHeight;
7373

74-
_parentApplet = _parent;
75-
hwsCp5 = new ControlP5(_parentApplet);
76-
hwsCp5.setGraphics(_parentApplet, 0,0);
74+
this.parentApplet = _parentApplet;
75+
hwsCp5 = new ControlP5(parentApplet);
76+
hwsCp5.setGraphics(parentApplet, 0,0);
7777
hwsCp5.setAutoDraw(false);
7878

7979
int colOffset = (w / CONTROL_BUTTON_COUNT) / 2;
@@ -180,7 +180,7 @@ class ADS1299SettingsController {
180180
toggleWidthAndHeight = DEFAULT_TOGGLE_WIDTH;
181181
}
182182

183-
hwsCp5.setGraphics(_parentApplet, 0, 0);
183+
hwsCp5.setGraphics(parentApplet, 0, 0);
184184

185185
int colOffset = (w / CONTROL_BUTTON_COUNT) / 2;
186186
int button_y = y + h + PADDING_3;
@@ -233,7 +233,7 @@ class ADS1299SettingsController {
233233
dropdownY = int(y + (channelBarHeight * rowCount) + ((channelBarHeight - dropdownH) / 2));
234234
final int buttonXIncrement = spaceBetweenButtons + dropdownW;
235235

236-
int toggleX = dropdownX + (dropdownW / 2) - (toggleWidthAndHeight);
236+
int toggleX = dropdownX + (dropdownW / 2) - (toggleWidthAndHeight / 2);
237237
channelSelectToggles[i].setPosition(toggleX, dropdownY);
238238
channelSelectToggles[i].setSize(toggleWidthAndHeight, toggleWidthAndHeight);
239239

@@ -750,8 +750,9 @@ void loadHardwareSettings(File selection) {
750750
if (((ADS1299SettingsBoard)currentBoard).getADS1299Settings().loadSettingsValues(selection.getAbsolutePath())) {
751751
outputSuccess("Hardware Settings Loaded!");
752752
for (int i = 0; i < globalChannelCount; i++) {
753-
w_timeSeries.adsSettingsController.updateChanSettingsDropdowns(i, currentBoard.isEXGChannelActive(i));
754-
w_timeSeries.adsSettingsController.updateHasUnappliedSettings(i);
753+
W_TimeSeries timeSeriesWidget = widgetManager.getTimeSeriesWidget();
754+
timeSeriesWidget.adsSettingsController.updateChanSettingsDropdowns(i, currentBoard.isEXGChannelActive(i));
755+
timeSeriesWidget.adsSettingsController.updateHasUnappliedSettings(i);
755756
}
756757
} else {
757758
outputError("Failed to load Hardware Settings.");

OpenBCI_GUI/AccelerometerEnums.pde

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
public enum AccelerometerVerticalScale implements IndexingInterface
2+
{
3+
AUTO (0, 0, "Auto"),
4+
ONE_G (1, 1, "1 g"),
5+
TWO_G (2, 2, "2 g"),
6+
FOUR_G (3, 4, "4 g");
7+
8+
private int index;
9+
private int value;
10+
private String label;
11+
12+
AccelerometerVerticalScale(int _index, int _value, String _label) {
13+
this.index = _index;
14+
this.value = _value;
15+
this.label = _label;
16+
}
17+
18+
public int getValue() {
19+
return value;
20+
}
21+
22+
@Override
23+
public String getString() {
24+
return label;
25+
}
26+
27+
@Override
28+
public int getIndex() {
29+
return index;
30+
}
31+
32+
public int getHighestValue() {
33+
int highestValue = 0;
34+
for (AccelerometerVerticalScale scale : values()) {
35+
if (scale.getValue() > highestValue) {
36+
highestValue = scale.getValue();
37+
}
38+
}
39+
return highestValue;
40+
}
41+
}
42+
43+
public enum AccelerometerHorizontalScale implements IndexingInterface
44+
{
45+
ONE_SEC (1, 1, "1 sec"),
46+
THREE_SEC (2, 3, "3 sec"),
47+
FIVE_SEC (3, 5, "5 sec"),
48+
TEN_SEC (4, 10, "10 sec"),
49+
TWENTY_SEC (5, 20, "20 sec");
50+
51+
private int index;
52+
private int value;
53+
private String label;
54+
55+
AccelerometerHorizontalScale(int _index, int _value, String _label) {
56+
this.index = _index;
57+
this.value = _value;
58+
this.label = _label;
59+
}
60+
61+
public int getValue() {
62+
return value;
63+
}
64+
65+
@Override
66+
public String getString() {
67+
return label;
68+
}
69+
70+
@Override
71+
public int getIndex() {
72+
return index;
73+
}
74+
75+
public int getHighestValue() {
76+
int highestValue = 0;
77+
for (AccelerometerHorizontalScale scale : values()) {
78+
if (scale.getValue() > highestValue) {
79+
highestValue = scale.getValue();
80+
}
81+
}
82+
return highestValue;
83+
}
84+
}

OpenBCI_GUI/AnalogReadEnums.pde

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
public enum AnalogReadVerticalScale implements IndexingInterface
2+
{
3+
AUTO (0, 0, "Auto"),
4+
FIFTY (1, 50, "50 uV"),
5+
ONE_HUNDRED (2, 100, "100 uV"),
6+
TWO_HUNDRED (3, 200, "200 uV"),
7+
FOUR_HUNDRED (4, 400, "400 uV"),
8+
ONE_THOUSAND_FIFTY (5, 1050, "1050 uV"),
9+
TEN_THOUSAND (6, 10000, "10000 uV");
10+
11+
private int index;
12+
private int value;
13+
private String label;
14+
15+
AnalogReadVerticalScale(int _index, int _value, String _label) {
16+
this.index = _index;
17+
this.value = _value;
18+
this.label = _label;
19+
}
20+
21+
public int getValue() {
22+
return value;
23+
}
24+
25+
@Override
26+
public String getString() {
27+
return label;
28+
}
29+
30+
@Override
31+
public int getIndex() {
32+
return index;
33+
}
34+
}
35+
36+
public enum AnalogReadHorizontalScale implements IndexingInterface
37+
{
38+
ONE_SEC (1, 1, "1 sec"),
39+
THREE_SEC (2, 3, "3 sec"),
40+
FIVE_SEC (3, 5, "5 sec"),
41+
TEN_SEC (4, 10, "10 sec"),
42+
TWENTY_SEC (5, 20, "20 sec");
43+
44+
private int index;
45+
private int value;
46+
private String label;
47+
48+
AnalogReadHorizontalScale(int _index, int _value, String _label) {
49+
this.index = _index;
50+
this.value = _value;
51+
this.label = _label;
52+
}
53+
54+
public int getValue() {
55+
return value;
56+
}
57+
58+
@Override
59+
public String getString() {
60+
return label;
61+
}
62+
63+
@Override
64+
public int getIndex() {
65+
return index;
66+
}
67+
}

OpenBCI_GUI/BandPowerEnums.pde

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
public enum BPLogLin implements IndexingInterface {
3+
LOG (0, "Log"),
4+
LINEAR (1, "Linear");
5+
6+
private int index;
7+
private String label;
8+
9+
BPLogLin(int _index, String _label) {
10+
this.index = _index;
11+
this.label = _label;
12+
}
13+
14+
@Override
15+
public String getString() {
16+
return label;
17+
}
18+
19+
@Override
20+
public int getIndex() {
21+
return index;
22+
}
23+
}
24+
25+
public enum BPVerticalScale implements IndexingInterface {
26+
SCALE_10 (0, 10, "10 uV"),
27+
SCALE_50 (1, 50, "50 uV"),
28+
SCALE_100 (2, 100, "100 uV"),
29+
SCALE_500 (3, 500, "500 uV"),
30+
SCALE_1000 (4, 1000, "1000 uV"),
31+
SCALE_1500 (5, 1500, "1500 uV");
32+
33+
private int index;
34+
private final int value;
35+
private String label;
36+
37+
BPVerticalScale(int index, int value, String label) {
38+
this.index = index;
39+
this.value = value;
40+
this.label = label;
41+
}
42+
43+
public int getValue() {
44+
return value;
45+
}
46+
47+
@Override
48+
public String getString() {
49+
return label;
50+
}
51+
52+
@Override
53+
public int getIndex() {
54+
return index;
55+
}
56+
}

OpenBCI_GUI/ChannelSelect.pde

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ class ChannelSelect {
1010
protected boolean channelSelectHover;
1111
protected boolean isVisible;
1212

13-
ChannelSelect(PApplet _parent, int _x, int _y, int _w, int _navH) {
13+
ChannelSelect(PApplet _parentApplet, int _x, int _y, int _w, int _navH) {
1414
x = _x;
1515
y = _y;
1616
w = _w;
1717
h = _navH;
1818
navH = _navH;
1919

2020
//setup for checkboxes
21-
cp5_chanSelect = new ControlP5(_parent);
22-
cp5_chanSelect.setGraphics(_parent, 0, 0);
21+
cp5_chanSelect = new ControlP5(_parentApplet);
22+
cp5_chanSelect.setGraphics(_parentApplet, 0, 0);
2323
cp5_chanSelect.setAutoDraw(false); //draw only when specified
2424
}
2525

@@ -66,8 +66,8 @@ class ChannelSelect {
6666
popStyle();
6767
}
6868

69-
public void screenResized(PApplet _parent) {
70-
cp5_chanSelect.setGraphics(_parent, 0, 0);
69+
public void screenResized(PApplet _parentApplet) {
70+
cp5_chanSelect.setGraphics(_parentApplet, 0, 0);
7171
}
7272

7373
public void mousePressed(boolean dropdownIsActive) {
@@ -111,8 +111,8 @@ class ExGChannelSelect extends ChannelSelect {
111111
protected List<Toggle> channelButtons;
112112
private List<Integer> activeChannels = new ArrayList<Integer>();
113113

114-
ExGChannelSelect(PApplet _parent, int _x, int _y, int _w, int _navH) {
115-
super(_parent, _x, _y, _w, _navH);
114+
ExGChannelSelect(PApplet _parentApplet, int _x, int _y, int _w, int _navH) {
115+
super(_parentApplet, _x, _y, _w, _navH);
116116
createButtons();
117117
}
118118

@@ -232,6 +232,17 @@ class ExGChannelSelect extends ChannelSelect {
232232
return activeChannels;
233233
}
234234

235+
public void updateChannelSelection(List<Integer> channels) {
236+
// First deactivate all channels
237+
deactivateAllButtons();
238+
239+
// Then activate only the selected channels
240+
for (Integer channel : channels) {
241+
if (channel >= 0 && channel < channelButtons.size()) {
242+
setToggleState(channel, true); // Changed from toggleButton
243+
}
244+
}
245+
}
235246
}
236247

237248
class DualChannelSelector {
@@ -282,8 +293,8 @@ class DualExGChannelSelect extends ExGChannelSelect {
282293

283294
DualChannelSelector dualChannelSelector;
284295

285-
DualExGChannelSelect(PApplet _parent, int _x, int _y, int _w, int _navH, boolean isFirstRow) {
286-
super(_parent, _x, _y, _w, _navH);
296+
DualExGChannelSelect(PApplet _parentApplet, int _x, int _y, int _w, int _navH, boolean isFirstRow) {
297+
super(_parentApplet, _x, _y, _w, _navH);
287298
dualChannelSelector = new DualChannelSelector(isFirstRow);
288299
}
289300

OpenBCI_GUI/Containers.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ void drawContainers() {
8080
if (widthOfLastScreen_C != width || heightOfLastScreen_C != height) {
8181
setupContainers();
8282
//setupVizs(); //container extension example (more below)
83-
settings.widthOfLastScreen = width;
84-
settings.heightOfLastScreen = height;
83+
sessionSettings.widthOfLastScreen = width;
84+
sessionSettings.heightOfLastScreen = height;
8585
}
8686
}
8787

0 commit comments

Comments
 (0)