Permalink
Browse files

Processing GUI Updates

- Increased frameRate (16 —> 30)
- aesthetic changes (buttons, hover, cursor)
- added EMG visualizer toggle mode (press ‘.’ to toggle between head
plot and EMG visualizer)
- added signPost() method for detecting system inefficiencies
  • Loading branch information...
1 parent 40a7fea commit 24a897d84b1332adad92b1cc474f2f9991f89dc9 @conorrussomanno conorrussomanno committed Feb 10, 2016
View
142 OpenBCI_GUI/Button.pde 100755 → 100644
@@ -11,21 +11,24 @@
////////////////////
class Button {
-
+
int but_x, but_y, but_dx, but_dy; // Position of square button
//int rectSize = 90; // Diameter of rect
- color color_pressed = color(200);
+
+ color currentColor;
+ color color_hover = color(127, 134, 143);//color(252, 221, 198);
+ color color_pressed = color(227,118,37); //bgColor;
color color_highlight = color(102);
- color color_notPressed = color(255);
+ color color_notPressed = color(255); //color(227,118,37);
color buttonStrokeColor = bgColor;
color textColorActive = color(255);
color textColorNotActive = bgColor;
color rectHighlight;
+ boolean drawHand = false;
//boolean isMouseHere = false;
boolean buttonHasStroke = true;
boolean isActive = false;
boolean isDropdownButton = false;
- boolean drawHand = false;
boolean wasPressed = false;
public String but_txt;
PFont buttonFont = f2;
@@ -46,68 +49,73 @@ class Button {
but_dy = h;
setString(txt);
}
-
+
public void setString(String txt) {
but_txt = txt;
//println("Button: setString: string = " + txt);
}
-
+
public boolean isActive() {
return isActive;
}
-
+
public void setIsActive(boolean val) {
isActive = val;
}
- public void makeDropdownButton(boolean val){
+ public void makeDropdownButton(boolean val) {
isDropdownButton = val;
}
-
+
public boolean isMouseHere() {
if ( overRect(but_x, but_y, but_dx, but_dy) ) {
- // cursor(HAND);
+ cursor(HAND);
return true;
- }
- else {
+ } else {
return false;
}
}
color getColor() {
if (isActive) {
- return color_pressed;
+ currentColor = color_pressed;
+ } else if (isMouseHere()) {
+ currentColor = color_hover;
} else {
- return color_notPressed;
+ currentColor = color_notPressed;
}
+ return currentColor;
+ }
+
+ public void setCurrentColor(color _color){
+ currentColor = _color;
}
- public void setColorPressed(color _color){
+ public void setColorPressed(color _color) {
color_pressed = _color;
}
- public void setColorNotPressed(color _color){
+ public void setColorNotPressed(color _color) {
color_notPressed = _color;
}
- public void setStrokeColor(color _color){
+ public void setStrokeColor(color _color) {
buttonStrokeColor = _color;
}
- public void hasStroke(boolean _trueORfalse){
+ public void hasStroke(boolean _trueORfalse) {
buttonHasStroke = _trueORfalse;
}
boolean overRect(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
- }
- else {
+ } else {
return false;
}
}
- public void draw(int _x, int _y){
+ public void draw(int _x, int _y) {
but_x = _x;
but_y = _y;
draw();
@@ -116,85 +124,73 @@ class Button {
public void draw() {
//draw the button
fill(getColor());
- if(buttonHasStroke){
+ if (buttonHasStroke) {
stroke(buttonStrokeColor); //button border
- }else{
+ } else {
noStroke();
}
// noStroke();
- rect(but_x,but_y,but_dx,but_dy);
-
+ rect(but_x, but_y, but_dx, but_dy);
+
//draw the text
- if(isActive){
+ if (isActive) {
fill(textColorActive);
- }else{
+ } else {
fill(textColorNotActive);
}
stroke(255);
textFont(buttonFont); //load f2 ... from control panel
textSize(12);
textAlign(CENTER, CENTER);
textLeading(round(0.9*(textAscent()+textDescent())));
-// int x1 = but_x+but_dx/2;
-// int y1 = but_y+but_dy/2;
+ // int x1 = but_x+but_dx/2;
+ // int y1 = but_y+but_dy/2;
int x1, y1;
- if (false) {
- //auto wrap
- x1 = but_x;
- y1 = but_y;
- int w = but_dx-2*2; //use a 2 pixel buffer on the left and right sides
- int h = but_dy;
- text(but_txt,x1,y1,w,h);
- } else {
- //no auto wrap
- x1 = but_x+but_dx/2;
- y1 = but_y+but_dy/2;
- text(but_txt,x1,y1);
- }
+ //no auto wrap
+ x1 = but_x+but_dx/2;
+ y1 = but_y+but_dy/2;
+ text(but_txt, x1, y1);
//draw open/close arrow if it's a dropdown button
- if(isDropdownButton){
+ if (isDropdownButton) {
pushStyle();
- fill(255);
- noStroke();
- // smooth();
- // stroke(255);
- // strokeWeight(1);
- if(isActive){
- float point1x = but_x + (but_dx - ((3f*but_dy)/4f));
- float point1y = but_y + but_dy/3f;
- float point2x = but_x + (but_dx-(but_dy/4f));
- float point2y = but_y + but_dy/3f;
- float point3x = but_x + (but_dx - (but_dy/2f));
- float point3y = but_y + (2f*but_dy)/3f;
- triangle(point1x, point1y, point2x, point2y, point3x, point3y); //downward triangle, indicating open
- } else{
- float point1x = but_x + (but_dx - ((3f*but_dy)/4f));
- float point1y = but_y + (2f*but_dy)/3f;
- float point2x = but_x + (but_dx-(but_dy/4f));
- float point2y = but_y + (2f*but_dy)/3f;
- float point3x = but_x + (but_dx - (but_dy/2f));
- float point3y = but_y + but_dy/3f;
- triangle(point1x, point1y, point2x, point2y, point3x, point3y); //upward triangle, indicating closed
- }
+ fill(255);
+ noStroke();
+ // smooth();
+ // stroke(255);
+ // strokeWeight(1);
+ if (isActive) {
+ float point1x = but_x + (but_dx - ((3f*but_dy)/4f));
+ float point1y = but_y + but_dy/3f;
+ float point2x = but_x + (but_dx-(but_dy/4f));
+ float point2y = but_y + but_dy/3f;
+ float point3x = but_x + (but_dx - (but_dy/2f));
+ float point3y = but_y + (2f*but_dy)/3f;
+ triangle(point1x, point1y, point2x, point2y, point3x, point3y); //downward triangle, indicating open
+ } else {
+ float point1x = but_x + (but_dx - ((3f*but_dy)/4f));
+ float point1y = but_y + (2f*but_dy)/3f;
+ float point2x = but_x + (but_dx-(but_dy/4f));
+ float point2y = but_y + (2f*but_dy)/3f;
+ float point3x = but_x + (but_dx - (but_dy/2f));
+ float point3y = but_y + but_dy/3f;
+ triangle(point1x, point1y, point2x, point2y, point3x, point3y); //upward triangle, indicating closed
+ }
popStyle();
}
- if(systemMode == 0){
- if(!isMouseHere() && drawHand){
+ if (true) {
+ if (!isMouseHere() && drawHand) {
cursor(ARROW);
drawHand = false;
verbosePrint("don't draw hand");
}
//if cursor is over button change cursor icon to hand!
- if(isMouseHere() && !drawHand){
+ if (isMouseHere() && !drawHand) {
cursor(HAND);
drawHand = true;
verbosePrint("draw hand");
- }
+ }
}
}
-};
-
-
-
+};
View
25 OpenBCI_GUI/ControlPanel.pde 100755 → 100644
@@ -35,7 +35,6 @@ String[] serialPorts = new String[Serial.list().length];
MenuList sdTimes;
color boxColor = color(200);
-// color boxStrokeColor = color(173,183,192);
color boxStrokeColor = color(138, 146, 153);
color isSelected_color = color(184, 220, 105);
@@ -260,13 +259,13 @@ class ControlPanel {
chanButton8.setIsActive(true);
chanButton8Pressed = true;
chanButton8.color_notPressed = isSelected_color;
- chanButton16.color_notPressed = color(255);
+ chanButton16.color_notPressed = autoFileName.color_notPressed; //default color of button
}
if (chanButton16.isMouseHere()) {
chanButton16.setIsActive(true);
chanButton16Pressed = true;
- chanButton8.color_notPressed = color(255);
+ chanButton8.color_notPressed = autoFileName.color_notPressed; //default color of button
chanButton16.color_notPressed = isSelected_color;
}
}
@@ -331,6 +330,7 @@ class ControlPanel {
initSystemButton.setString("START SYSTEM");
haltSystem();
}
+ //cursor(ARROW); //this this back to ARROW
}
//open or close serial port if serial port button is pressed (left button in serial widget)
@@ -401,10 +401,12 @@ public void controlEvent(ControlEvent theEvent) {
if (theEvent.isFrom("sourceList")) {
Map bob = ((MenuList)theEvent.getController()).getItem(int(theEvent.getValue()));
- output("Data Source = " + (String)bob.get("headline"));
+ String str = (String)bob.get("headline");
+ str = str.substring(0, str.length()-5);
+ //output("Data Source = " + str);
int newDataSource = int(theEvent.getValue());
eegDataSource = newDataSource; // reset global eegDataSource to the selected value from the list
- output("The new data source is " + (String)bob.get("headline"));
+ output("The new data source is " + str);
}
if (theEvent.isFrom("serialList")) {
@@ -454,6 +456,7 @@ class DataSourceBox {
}
public void update() {
+
}
public void draw() {
@@ -758,8 +761,8 @@ class InitBox {
//init button
initSystemButton = new Button (padding, y + padding, w-padding*2, h - padding*2, "START SYSTEM", fontInfo.buttonLabel_size);
- initSystemButton.color_notPressed = color(boxColor);
- initSystemButton.buttonStrokeColor = color(boxColor);
+ //initSystemButton.color_notPressed = color(boolor);
+ //initSystemButton.buttonStrokeColor = color(boxColor);
initButtonPressed = false;
}
@@ -769,7 +772,7 @@ class InitBox {
public void draw() {
pushStyle();
- fill(255);
+ fill(boxColor);
stroke(boxStrokeColor);
strokeWeight(1);
rect(x, y, w, h);
@@ -786,8 +789,4 @@ void playbackSelected(File selection) {
output("You have selected \"" + selection.getAbsolutePath() + "\" for playback.");
playbackData_fname = selection.getAbsolutePath();
}
-}
-
-
-
-
+}
@@ -1,6 +1,6 @@
//import ddf.minim.analysis.*; //for FFT
-boolean drawUser = true; //if true... toggles on EEG_Processing_User.draw and toggles off the headplot in Gui_Manager
+boolean drawUser = false; //if true... toggles on EEG_Processing_User.draw and toggles off the headplot in Gui_Manager
class EEG_Processing_User {
private float fs_Hz; //sample rate
@@ -75,11 +75,11 @@ class EEG_Processing_User {
//attempt to write to serial_output. If this serial port does not exist, do nothing.
try {
- println("inMoov_output: | " + output + " |");
+ //println("inMoov_output: | " + output + " |");
serial_output.write(output);
}
catch(RuntimeException e){
- println("serial not present");
+ if(isVerbose) println("serial not present");
}
//OR, you could loop over each EEG channel and do some sort of frequency-domain processing from the FFT data
@@ -129,8 +129,7 @@ class EEG_Processing_User {
popStyle();
}
-
- myAverage = 0.0;
+
}
class EEG_Processing {
View
@@ -24,6 +24,7 @@ public class MenuList extends Controller {
List< Map<String, Object>> items = new ArrayList< Map<String, Object>>();
PGraphics menu;
boolean updateMenu;
+ boolean drawHand;
int hoverItem = -1;
int activeItem = -1;
PFont menuFont = f2;
@@ -45,6 +46,10 @@ public class MenuList extends Controller {
updateMenu();
}
if (inside()) {
+ if(!drawHand){
+ cursor(HAND);
+ drawHand = true;
+ }
menu.beginDraw();
int len = -(itemHeight * items.size()) + getHeight();
int ty;
@@ -58,6 +63,12 @@ public class MenuList extends Controller {
menu.rect(getWidth()-scrollerWidth-2, ty, scrollerWidth, scrollerLength );
}
menu.endDraw();
+ }
+ else {
+ if(drawHand){
+ drawHand = false;
+ cursor(ARROW);
+ }
}
pg.image(menu, 0, 0);
}
Oops, something went wrong.

0 comments on commit 24a897d

Please sign in to comment.