Skip to content

Commit 5547183

Browse files
authored
Merge pull request #1164 from OpenBCI/development
GUI Patch v5.2.1
2 parents 7bf88ed + 9ef8bc9 commit 5547183

15 files changed

+367
-124
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
branches:
1313
only:
1414
- master
15-
- development
15+
#- development
1616

1717
before_install:
1818
- if [ "$TRAVIS_OS_NAME" = osx ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then openssl aes-256-cbc -K $encrypted_2f5d2771e3cb_key -iv $encrypted_2f5d2771e3cb_iv -in release_script/mac_only/Certificates.p12.enc -out release_script/mac_only/Certificates.p12 -d; fi

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# v5.2.1
2+
3+
### Improvements
4+
5+
- Add ability to map channels to EMG Joystick Inputs #1156
6+
- Fix alignment of UI objects in popup windows and EMG settings UI #1157
7+
- Rename "smoothing" to "window" in EMG settings UI #1158
8+
- Add EMG Joystick settings to Session Settings #1159
9+
110
# v5.2.0
211

312
### Bug Fixes

OpenBCI_GUI/EmgSettings.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class EmgSettings {
2121
}
2222
Gson gson = new Gson();
2323
EmgSettingsValues tempValues = gson.fromJson(fileContents.toString(), EmgSettingsValues.class);
24-
if (tempValues.smoothing.length != channelCount) {
24+
if (tempValues.window.length != channelCount) {
2525
outputError("Emg Settings: Loaded EMG Settings file has different number of channels than the current board.");
2626
return false;
2727
}
2828
//Explicitely copy values over to avoid reference issues
2929
//(e.g. values = tempValues "nukes" the old values object)
30-
values.smoothing = tempValues.smoothing;
30+
values.window = tempValues.window;
3131
values.uvLimit = tempValues.uvLimit;
3232
values.creepIncreasing = tempValues.creepIncreasing;
3333
values.creepDecreasing = tempValues.creepDecreasing;

OpenBCI_GUI/EmgSettingsEnums.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ interface EmgSettingsEnum {
33
public String getString();
44
}
55

6-
public enum EmgSmoothing implements EmgSettingsEnum
6+
public enum EmgWindow implements EmgSettingsEnum
77
{
88
ONE_HUNDREDTH_SECOND (0, "0.01 s", .01f),
99
ONE_TENTH_SECOND (1, "0.1 s", .1f),
@@ -18,7 +18,7 @@ public enum EmgSmoothing implements EmgSettingsEnum
1818
private String name;
1919
private float value;
2020

21-
EmgSmoothing(int index, String name, float value) {
21+
EmgWindow(int index, String name, float value) {
2222
this.index = index;
2323
this.name = name;
2424
this.value = value;

OpenBCI_GUI/EmgSettingsUI.pde

Lines changed: 34 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
////////////////////////////////////////////////////////////
2-
// EmgSettingsUI.pde //
2+
// EmgSettingsUI.pde //
33
// Display the Emg Settings UI as a popup //
4+
// Note: This window is never resized. //
45
// //
56
////////////////////////////////////////////////////////////
67

@@ -14,7 +15,7 @@ class EmgSettingsUI extends PApplet implements Runnable {
1415
private ControlP5 emgCp5;
1516
private int x, y, w, h;
1617
private final int HEADER_HEIGHT = 55;
17-
private final int FOOTER_PADDING = 80;
18+
private final int FOOTER_PADDING = 90;
1819
private final int PADDING_3 = 3;
1920
private final int PADDING_12 = 12;
2021
private final int NUM_CONTROL_BUTTONS = 3;
@@ -29,7 +30,7 @@ class EmgSettingsUI extends PApplet implements Runnable {
2930
private final int NUM_FOOTER_OBJECTS = 3;
3031
private final int FOOTER_OBJECT_WIDTH = 45;
3132
private final int FOOTER_OBJECT_HEIGHT = 26;
32-
private int footerObjY = 0;
33+
private int footerObjY;
3334
private int[] footerObjX = new int[NUM_FOOTER_OBJECTS];
3435

3536
private final color HEADER_COLOR = OPENBCI_BLUE;
@@ -42,14 +43,14 @@ class EmgSettingsUI extends PApplet implements Runnable {
4243
public EmgSettingsValues emgSettingsValues;
4344

4445
private TextBox channelColumnLabel;
45-
private TextBox smoothLabel;
46+
private TextBox windowLabel;
4647
private TextBox uvLimitLabel;
4748
private TextBox creepIncLabel;
4849
private TextBox creepDecLabel;
4950
private TextBox minDeltaUvLabel;
5051
private TextBox lowLimitLabel;
5152

52-
private ScrollableList[] smoothLists;
53+
private ScrollableList[] windowLists;
5354
private ScrollableList[] uvLimitLists;
5455
private ScrollableList[] creepIncLists;
5556
private ScrollableList[] creepDecLists;
@@ -118,9 +119,11 @@ class EmgSettingsUI extends PApplet implements Runnable {
118119
scene();
119120

120121
// Draw header
122+
pushStyle();
121123
noStroke();
122124
fill(HEADER_COLOR);
123125
rect(0, 0, width, HEADER_HEIGHT);
126+
popStyle();
124127

125128
emgSettingsValues = dataProcessing.emgSettings.values;
126129

@@ -129,7 +132,7 @@ class EmgSettingsUI extends PApplet implements Runnable {
129132

130133
//Draw column labels
131134
channelColumnLabel.draw();
132-
smoothLabel.draw();
135+
windowLabel.draw();
133136
uvLimitLabel.draw();
134137
creepIncLabel.draw();
135138
creepDecLabel.draw();
@@ -139,56 +142,19 @@ class EmgSettingsUI extends PApplet implements Runnable {
139142
drawChannelLabels();
140143

141144
//Draw cp5 objects on top of everything
142-
emgCp5.draw();
143-
}
144-
145-
private void screenResized() {
146-
x = 0;
147-
y = 0;
148-
w = width;
149-
h = height;
150-
151-
emgCp5.setGraphics(ourApplet, 0, 0);
152-
153-
int colWidth = (width / NUM_COLUMNS);
154-
int colOffset = colWidth / 2;
155-
int labelY = y + HEADER_HEIGHT / 2;
156-
channelColumnLabel.setPosition(x + colOffset, labelY);
157-
smoothLabel.setPosition(x + colOffset + colWidth, labelY);
158-
uvLimitLabel.setPosition(x + colOffset + colWidth*2, labelY);
159-
creepIncLabel.setPosition(x + colOffset + colWidth*3, labelY);
160-
creepDecLabel.setPosition(x + colOffset + colWidth*4, labelY);
161-
minDeltaUvLabel.setPosition(x + colOffset + colWidth*5, labelY);
162-
lowLimitLabel.setPosition(x + colOffset + colWidth*6, labelY);
163-
164-
resizeDropdowns();
145+
try {
146+
emgCp5.draw();
147+
} catch (ConcurrentModificationException e) {
148+
e.printStackTrace();
149+
outputError("EMG Settings UI: Unable to draw cp5 objects.");
150+
}
165151
}
166152

167153
private void scene() {
168154
// Draw background
169155
background(BACKGROUND_COLOR);
170156
}
171157

172-
@Override
173-
public void keyReleased() {
174-
175-
}
176-
177-
@Override
178-
public void keyPressed() {
179-
180-
}
181-
182-
@Override
183-
public void mousePressed() {
184-
185-
}
186-
187-
@Override
188-
public void mouseReleased() {
189-
190-
}
191-
192158
@Override
193159
public void exit() {
194160
dispose();
@@ -229,23 +195,23 @@ class EmgSettingsUI extends PApplet implements Runnable {
229195

230196
for (int i = 0; i < channelCount; i++) {
231197
String channelLabel = channelCount > channelLabels.length ? "Channel " + Integer.toString(i + 1) : channelLabels[i];
232-
text(channelLabel, x + colOffset, dropdownYPositions[i] + (DROPDOWN_HEIGHT / 2));
198+
text(channelLabel, x + colOffset, dropdownYPositions[i] + (DROPDOWN_HEIGHT / 2) - 2);
233199
}
234200

235201
popStyle();
236202
}
237203

238204
private void resizeDropdowns() {
239205
dropdownWidth = int((w - (DROPDOWN_SPACER * (NUM_COLUMNS + 1))) / NUM_COLUMNS);
240-
final int MAX_HEIGHT_ITEMS = channelCount == 4 ? 8 : 5;
206+
final int MAX_HEIGHT_ITEMS = 6;
241207

242208
for (int i = 0; i < channelCount; i++) {
243209
int dropdownX = x + DROPDOWN_SPACER * 2 + dropdownWidth;
244210
dropdownYPositions[i] = HEADER_HEIGHT + int(y + ((ROW_HEIGHT) * i) + (((ROW_HEIGHT) - DROPDOWN_HEIGHT) / 2));
245211
final int buttonXIncrement = DROPDOWN_SPACER + dropdownWidth;
246212

247-
smoothLists[i].setPosition(dropdownX, dropdownYPositions[i]);
248-
smoothLists[i].setSize(dropdownWidth, MAX_HEIGHT_ITEMS * DROPDOWN_HEIGHT);
213+
windowLists[i].setPosition(dropdownX, dropdownYPositions[i]);
214+
windowLists[i].setSize(dropdownWidth, MAX_HEIGHT_ITEMS * DROPDOWN_HEIGHT);
249215

250216
dropdownX += buttonXIncrement;
251217
uvLimitLists[i].setPosition(dropdownX, dropdownYPositions[i]);
@@ -270,7 +236,8 @@ class EmgSettingsUI extends PApplet implements Runnable {
270236
}
271237

272238
private void createAllUIObjects() {
273-
footerObjY = y + h - FOOTER_PADDING + PADDING_3;
239+
final int HALF_FOOTER_HEIGHT = (FOOTER_PADDING + (DROPDOWN_SPACER * 2)) / 2;
240+
footerObjY = y + h - HALF_FOOTER_HEIGHT - (FOOTER_OBJECT_HEIGHT / 2);
274241
int middle = x + w / 2;
275242
int halfObjWidth = FOOTER_OBJECT_WIDTH / 2;
276243
footerObjX[0] = middle - halfObjWidth - PADDING_12 - FOOTER_OBJECT_WIDTH;
@@ -291,13 +258,13 @@ class EmgSettingsUI extends PApplet implements Runnable {
291258
int colWidth = (w / NUM_COLUMNS);
292259
int colOffset = colWidth / 2;
293260
int labelY = y + HEADER_HEIGHT / 2;
294-
channelColumnLabel = new TextBox("Channel", x + colOffset, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
295-
smoothLabel = new TextBox("Smooth", x + colOffset + colWidth, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
296-
uvLimitLabel = new TextBox("uV Limit", x + colOffset + colWidth*2, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
297-
creepIncLabel = new TextBox("Creep +", x + colOffset + colWidth*3, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
298-
creepDecLabel = new TextBox("Creep -", x + colOffset + colWidth*4, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
299-
minDeltaUvLabel = new TextBox("Min \u0394uV", x + colOffset + colWidth*5, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
300-
lowLimitLabel = new TextBox("Low Limit", x + colOffset + colWidth*6, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
261+
channelColumnLabel = new TextBox("Channel", x + colOffset, labelY, labelTxt, labelBG, 14, h4, CENTER, CENTER);
262+
windowLabel = new TextBox("Window", x + colOffset + colWidth, labelY, labelTxt, labelBG, 14, h4, CENTER, CENTER);
263+
uvLimitLabel = new TextBox("uV Limit", x + colOffset + colWidth*2, labelY, labelTxt, labelBG, 14, h4, CENTER, CENTER);
264+
creepIncLabel = new TextBox("Creep +", x + colOffset + colWidth*3, labelY, labelTxt, labelBG, 14, h4, CENTER, CENTER);
265+
creepDecLabel = new TextBox("Creep -", x + colOffset + colWidth*4, labelY, labelTxt, labelBG, 14, h4, CENTER, CENTER);
266+
minDeltaUvLabel = new TextBox("Min \u0394uV", x + colOffset + colWidth*5, labelY, labelTxt, labelBG, 14, h4, CENTER, CENTER);
267+
lowLimitLabel = new TextBox("Low Limit", x + colOffset + colWidth*6, labelY, labelTxt, labelBG, 14, h4, CENTER, CENTER);
301268

302269
createAllDropdowns();
303270
}
@@ -306,7 +273,7 @@ class EmgSettingsUI extends PApplet implements Runnable {
306273
//the size and space of these buttons are dependendant on the size of the screen and full ChannelController
307274
verbosePrint("EmgChannelSettingsUI: Creating EMG channel setting UI objects...");
308275

309-
smoothLists = new ScrollableList[channelCount];
276+
windowLists = new ScrollableList[channelCount];
310277
uvLimitLists = new ScrollableList[channelCount];
311278
creepIncLists = new ScrollableList[channelCount];
312279
creepDecLists = new ScrollableList[channelCount];
@@ -318,7 +285,7 @@ class EmgSettingsUI extends PApplet implements Runnable {
318285
//Init dropdowns in reverse so that chan 1 draws on top of chan 2, etc.
319286
for (int i = channelCount - 1; i >= 0; i--) {
320287
int exgChannel = i;
321-
smoothLists[i] = createDropdown(exgChannel, "smooth_ch_"+(i+1), emgSettingsValues.smoothing[exgChannel].values(), emgSettingsValues.smoothing[exgChannel]);
288+
windowLists[i] = createDropdown(exgChannel, "smooth_ch_"+(i+1), emgSettingsValues.window[exgChannel].values(), emgSettingsValues.window[exgChannel]);
322289
uvLimitLists[i] = createDropdown(exgChannel, "uvLimit_ch_"+(i+1), emgSettingsValues.uvLimit[exgChannel].values(), emgSettingsValues.uvLimit[exgChannel]);
323290
creepIncLists[i] = createDropdown(exgChannel, "creep_inc_ch_"+(i+1), emgSettingsValues.creepIncreasing[exgChannel].values(), emgSettingsValues.creepIncreasing[exgChannel]);
324291
creepDecLists[i] = createDropdown(exgChannel, "creep_dec_ch_"+(i+1), emgSettingsValues.creepDecreasing[exgChannel].values(), emgSettingsValues.creepDecreasing[exgChannel]);
@@ -386,9 +353,8 @@ class EmgSettingsUI extends PApplet implements Runnable {
386353
EmgSettingsEnum myEnum = (EmgSettingsEnum)bob.get("value");
387354
verbosePrint("EmgSettings: " + (theEvent.getController()).getName() + " == " + myEnum.getString());
388355

389-
if (myEnum instanceof EmgSmoothing) {
390-
//verbosePrint("HardwareSettings: previousVal == " + emgSettingsValues.previousValues.gain[channel]);
391-
emgSettingsValues.smoothing[channel] = (EmgSmoothing)myEnum;
356+
if (myEnum instanceof EmgWindow) {
357+
emgSettingsValues.window[channel] = (EmgWindow)myEnum;
392358
} else if (myEnum instanceof EmgUVLimit) {
393359
emgSettingsValues.uvLimit[channel] = (EmgUVLimit)myEnum;
394360
} else if (myEnum instanceof EmgCreepIncreasing) {
@@ -437,15 +403,15 @@ class EmgSettingsUI extends PApplet implements Runnable {
437403
private void updateCp5Objects() {
438404
for (int i = 0; i < channelCount; i++) {
439405
//Fetch values from the EmgSettingsValues object
440-
EmgSmoothing updateSmoothing = emgSettingsValues.smoothing[i];
406+
EmgWindow updateSmoothing = emgSettingsValues.window[i];
441407
EmgUVLimit updateUVLimit = emgSettingsValues.uvLimit[i];
442408
EmgCreepIncreasing updateCreepIncreasing = emgSettingsValues.creepIncreasing[i];
443409
EmgCreepDecreasing updateCreepDecreasing = emgSettingsValues.creepDecreasing[i];
444410
EmgMinimumDeltaUV updateMinimumDeltaUV = emgSettingsValues.minimumDeltaUV[i];
445411
EmgLowerThresholdMinimum updateLowerThresholdMinimum = emgSettingsValues.lowerThresholdMinimum[i];
446412

447413
//Update the ScrollableLists
448-
smoothLists[i].getCaptionLabel().setText(updateSmoothing.getString());
414+
windowLists[i].getCaptionLabel().setText(updateSmoothing.getString());
449415
uvLimitLists[i].getCaptionLabel().setText(updateUVLimit.getString());
450416
creepIncLists[i].getCaptionLabel().setText(updateCreepIncreasing.getString());
451417
creepDecLists[i].getCaptionLabel().setText(updateCreepDecreasing.getString());

OpenBCI_GUI/EmgSettingsValues.pde

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class EmgSettingsValues {
99

1010
//These values can be changed via dropdowns
11-
public EmgSmoothing[] smoothing;
11+
public EmgWindow[] window;
1212
public EmgUVLimit[] uvLimit;
1313
public EmgCreepIncreasing[] creepIncreasing;
1414
public EmgCreepDecreasing[] creepDecreasing;
@@ -27,7 +27,7 @@ class EmgSettingsValues {
2727

2828
channelCount = currentBoard.getNumEXGChannels();
2929

30-
smoothing = new EmgSmoothing[channelCount];
30+
window = new EmgWindow[channelCount];
3131
uvLimit = new EmgUVLimit[channelCount];
3232
creepIncreasing = new EmgCreepIncreasing[channelCount];
3333
creepDecreasing = new EmgCreepDecreasing[channelCount];
@@ -39,7 +39,7 @@ class EmgSettingsValues {
3939
lowerThreshold = new float[channelCount];
4040
averageuV = new float[channelCount];
4141

42-
Arrays.fill(smoothing, EmgSmoothing.ONE_SECOND);
42+
Arrays.fill(window, EmgWindow.ONE_SECOND);
4343
Arrays.fill(uvLimit, EmgUVLimit.TWO_HUNDRED_UV);
4444
Arrays.fill(creepIncreasing, EmgCreepIncreasing.POINT_9);
4545
Arrays.fill(creepDecreasing, EmgCreepDecreasing.POINT_99999);
@@ -55,7 +55,7 @@ class EmgSettingsValues {
5555
public void process(float[][] data_forDisplay_uV) {
5656
//looping over channels and analyzing input data
5757
for (int i = 0; i < channelCount; i++) {
58-
float averagePeriod = currentBoard.getSampleRate() * smoothing[i].getValue();
58+
float averagePeriod = currentBoard.getSampleRate() * window[i].getValue();
5959
int _uvLimit = uvLimit[i].getValue();
6060
float creepSpeedIncreasing = creepIncreasing[i].getValue();
6161
float creepSpeedDecreasing = creepDecreasing[i].getValue();

OpenBCI_GUI/Info.plist.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<key>CFBundleShortVersionString</key>
2424
<string>5</string>
2525
<key>CFBundleVersion</key>
26-
<string>5.2.0</string>
26+
<string>5.2.1</string>
2727
<key>CFBundleSignature</key>
2828
<string>????</string>
2929
<key>NSHumanReadableCopyright</key>
@@ -32,7 +32,7 @@
3232
Copyright © 2023 OpenBCI
3333
</string>
3434
<key>CFBundleGetInfoString</key>
35-
<string>June 2023</string>
35+
<string>July 2023</string>
3636
<!-- End of the set that can be customized -->
3737

3838
@@jvm_runtime@@

OpenBCI_GUI/OpenBCI_GUI.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
6262
// Global Variables & Instances
6363
//------------------------------------------------------------------------
6464
//Used to check GUI version in TopNav.pde and displayed on the splash screen on startup
65-
String localGUIVersionString = "v5.2.0";
66-
String localGUIVersionDate = "June 2023";
65+
String localGUIVersionString = "v5.2.1";
66+
String localGUIVersionDate = "July 2023";
6767
String guiLatestVersionGithubAPI = "https://api.github.com/repos/OpenBCI/OpenBCI_GUI/releases/latest";
6868
String guiLatestReleaseLocation = "https://github.com/OpenBCI/OpenBCI_GUI/releases/latest";
6969
Boolean guiIsUpToDate;

OpenBCI_GUI/PopupMessage.pde

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class PopupMessage extends PApplet implements Runnable {
106106
textFont(p0, 24);
107107
fill(WHITE);
108108
textAlign(LEFT, CENTER);
109-
text(headerMessage, (width - w)/2 + padding, (height - h)/2, w, headerHeight);
109+
text(headerMessage, (width - w)/2 + padding, headerHeight/2);
110110

111111
//draw message
112112
textFont(p3, 16);

0 commit comments

Comments
 (0)