Skip to content

Commit eb2228d

Browse files
authored
Merge pull request #602 from retiutut/development
Dev 4.1.6-beta.0 PR 2
2 parents cb5a0e7 + c1cc975 commit eb2228d

16 files changed

Lines changed: 367 additions & 135 deletions

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# v4.1.6
2-
Use OpenBCIHub v2.0.9 please.
2+
Use OpenBCIHub v2.1.0 please.
33

44
## Beta 0
55

66
### Improvements
7+
* Cyton+Dongle AutoConnect Button!
78
* GUI error message when using old Cyton firmware #597
9+
* Update Focus widget help button
10+
* Console Log window UI/UX update
11+
* Add GUI Troublshooting Guide button to "Help" dropdown in TopNav.pde
812

913
### Bug Fixes
1014
* Cyton+WiFi unable to start session #555 #590
11-
* Networking start/stop stream #593
15+
* Networking: Start/Stop stream button behavior #593
16+
* Networking: Only show Pulse datatype for Cyton(Live)
17+
* Show error when loading empty playback file and delete file from history
1218

1319
# v4.1.5
1420
Use OpenBCIHub v2.0.9 please.

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ If you're new to Git and want to learn how to fork this repo, make your own addi
1818

1919
### Community
2020

21-
This project is maintained by the [OpenBCI](www.openbci.com) community. Join the [OpenBCI Forum](http://openbci.com/index.php/forum/), where discussions about OpenBCI takes place.
21+
This project is maintained by the [OpenBCI](https://openbci.com) community. Join the [OpenBCI Forum](https://openbci.com/forum/), where discussions about OpenBCI takes place.
2222

2323
## How can I contribute?
2424

25-
This is currently a small, humble project so our contribution process is rather casual. If there's a feature you'd be interested in building, go ahead! Let us know on the [OpenBCI Forum](http://openbci.com/index.php/forum/) or [open an issue](../../issues) so others can follow along and we'll support you as much as we can. When you're finished submit a pull request to the master branch referencing the specific issue you addressed.
25+
This is currently a small, humble project so our contribution process is rather casual. If there's a feature you'd be interested in building, go ahead! Let us know on the [OpenBCI Forum](https://openbci.com/forum/) or [open an issue](../../issues) so others can follow along and we'll support you as much as we can. When you're finished submit a pull request to the master branch referencing the specific issue you addressed.
2626

27-
If you find a bug, or have a suggestion on how to improve the project, just fill out a [Github issue](../../issues)
27+
If you find a bug, or have a suggestion on how to improve the project, please fill out a [Github issue](../../issues).
2828

2929
### Steps to Contribute
3030

OpenBCI_GUI/ConsoleLog.pde

Lines changed: 85 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,23 @@ import java.awt.Desktop;
1717
static class ConsoleWindow extends PApplet {
1818
private static ConsoleWindow instance = null;
1919

20+
PApplet logApplet;
21+
2022
private ControlP5 cp5;
2123
private Textarea consoleTextArea;
2224
private ClipHelper clipboardCopy;
2325

2426
private final int headerHeight = 42;
2527
private final int defaultWidth = 620;
2628
private final int defaultHeight = 500;
27-
private final int buttonWidth = 170;
29+
private final int buttonWidth = 142;
2830
private final int buttonHeight = 34;
29-
private int previousWidth = defaultWidth;
31+
32+
//for screen resizing
33+
private boolean screenHasBeenResized = false;
34+
private float timeOfLastScreenResize = 0;
35+
private int widthOfLastScreen = defaultWidth;
36+
private int heightOfLastScreen = defaultHeight;
3037

3138
public static void display() {
3239
// enforce only one Console Window
@@ -45,6 +52,9 @@ static class ConsoleWindow extends PApplet {
4552
}
4653

4754
void setup() {
55+
56+
logApplet = this;
57+
4858
surface.setAlwaysOnTop(true);
4959
surface.setResizable(true);
5060

@@ -53,6 +63,7 @@ static class ConsoleWindow extends PApplet {
5363

5464
consoleTextArea = cp5.addTextarea("ConsoleWindow")
5565
.setPosition(0, headerHeight)
66+
.setSize(width, height - headerHeight)
5667
.setFont(createFont("arial", 14))
5768
.setLineHeight(18)
5869
.setColor(color(242))
@@ -65,13 +76,15 @@ static class ConsoleWindow extends PApplet {
6576
// register this console's Textarea with the output stream object
6677
outputStream.registerTextArea(consoleTextArea);
6778

68-
int cW = int(width/3);
79+
int cW = int(width/4);
6980
int bX = int((cW - buttonWidth) / 2);
7081
createConsoleLogButton("openLogFileAsText", "Open Log as Text (F)", bX);
7182
bX += cW;
72-
createConsoleLogButton("copyFullTextToClipboard", "Copy Full Log Text (C)", bX);
83+
createConsoleLogButton("copyFullTextToClipboard", "Copy Full Text (C)", bX);
7384
bX += cW;
7485
createConsoleLogButton("copyLastLineToClipboard", "Copy Last Line (L)", bX);
86+
bX += cW;
87+
createConsoleLogButton("jumpToLastLine", "Jump to Last Line (J)", bX);
7588
}
7689

7790
void createConsoleLogButton (String bName, String bText, int x) {
@@ -84,21 +97,45 @@ static class ConsoleWindow extends PApplet {
8497
.setColorBackground(color(144, 100));
8598
cp5.getController(bName)
8699
.getCaptionLabel()
87-
.setFont(createFont("Arial",16,true))
100+
.setFont(createFont("Arial",14,true))
88101
.toUpperCase(false)
89-
.setSize(16)
102+
.setSize(14)
90103
.setText(bText);
91104
}
92105

93106
void draw() {
94-
// dynamically resize text area to fit widget
95-
consoleTextArea.setSize(width, height - headerHeight);
96-
// update button positions when screen width changes
97-
updateButtonPositions();
98-
99107
clear();
100108
scene();
101109
cp5.draw();
110+
//checks if the screen is resized, similar to main GUI window
111+
screenResized();
112+
}
113+
114+
void screenResized() {
115+
if (this.widthOfLastScreen != width || this.heightOfLastScreen != height) {
116+
//println("ConsoleLog: RESIZED");
117+
this.screenHasBeenResized = true;
118+
this.timeOfLastScreenResize = millis();
119+
this.widthOfLastScreen = width;
120+
this.heightOfLastScreen = height;
121+
}
122+
if (this.screenHasBeenResized) {
123+
//setGraphics() is very important, it lets the cp5 elements know where the origin is.
124+
//Without this, cp5 elements won't work after screen is resized.
125+
//This also happens in most widgets when the main GUI window is resized.
126+
logApplet = this;
127+
cp5.setGraphics(logApplet, 0, 0);
128+
129+
imposeMinConsoleLogDimensions();
130+
// dynamically resize text area to fit widget
131+
consoleTextArea.setSize(width, height - headerHeight);
132+
// update button positions when screen width changes
133+
updateButtonPositions();
134+
}
135+
//re-initialize console log if screen has been resized and it's been more than 1 seccond (to prevent reinitialization happening too often)
136+
if (this.screenHasBeenResized == true && (millis() - this.timeOfLastScreenResize) > 1000) {
137+
this.screenHasBeenResized = false;
138+
}
102139
}
103140

104141
void scene() {
@@ -110,14 +147,23 @@ static class ConsoleWindow extends PApplet {
110147
void keyReleased() {
111148
if (key == 'c') {
112149
copyFullTextToClipboard();
113-
}
114-
115-
if (key == 'f') {
150+
} else if (key == 'f') {
116151
openLogFileAsText();
152+
} else if (key == 'l') {
153+
copyLastLineToClipboard();
154+
} else if (key == 'j' ) {
155+
jumpToLastLine();
117156
}
157+
158+
}
118159

119-
if (key == 'l') {
120-
copyLastLineToClipboard();
160+
void keyPressed() {
161+
if (key == CODED) {
162+
if (keyCode == UP) {
163+
consoleTextArea.scrolled(-5);
164+
} else if (keyCode == DOWN) {
165+
consoleTextArea.scrolled(5);
166+
}
121167
}
122168
}
123169

@@ -154,17 +200,30 @@ static class ConsoleWindow extends PApplet {
154200
println("ConsoleLog: Previous line copied to clipboard.");
155201
}
156202

203+
void jumpToLastLine() {
204+
consoleTextArea.scroll(1.0);
205+
}
206+
157207
void updateButtonPositions() {
158-
if (width != previousWidth) {
159-
int cW = width / 3;
160-
int bX = (cW - 170) / 2;
161-
int bY = 4;
162-
cp5.getController("openLogFileAsText").setPosition(bX, bY);
163-
bX += cW;
164-
cp5.getController("copyFullTextToClipboard").setPosition(bX, bY);
165-
bX += cW;
166-
cp5.getController("copyLastLineToClipboard").setPosition(bX, bY);
167-
previousWidth = width;
208+
int cW = width / 4;
209+
int bX = (cW - buttonWidth) / 2;
210+
int bY = 4;
211+
cp5.getController("openLogFileAsText").setPosition(bX, bY);
212+
bX += cW;
213+
cp5.getController("copyFullTextToClipboard").setPosition(bX, bY);
214+
bX += cW;
215+
cp5.getController("copyLastLineToClipboard").setPosition(bX, bY);
216+
bX += cW;
217+
cp5.getController("jumpToLastLine").setPosition(bX, bY);
218+
}
219+
220+
void imposeMinConsoleLogDimensions() {
221+
//impose minimum gui dimensions
222+
int minHeight = int(defaultHeight/2);
223+
if (width < defaultWidth || height < minHeight) {
224+
int _w = (width < defaultWidth) ? defaultWidth : width;
225+
int _h = (height < minHeight) ? minHeight : height;
226+
surface.setSize(_w, _h);
168227
}
169228
}
170229

OpenBCI_GUI/Containers.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ void drawContainers() {
8181
println("OpenBCI_GUI: setup: RESIZED");
8282
setupContainers();
8383
//setupVizs(); //container extension example (more below)
84-
widthOfLastScreen = width;
85-
heightOfLastScreen = height;
84+
settings.widthOfLastScreen = width;
85+
settings.heightOfLastScreen = height;
8686
}
8787
}
8888

0 commit comments

Comments
 (0)