OpenBCI_GUI: Adding UI elements inside the Playground Class

edited August 2016 in OpenBCI_GUI
Greetings all,
I'm trying to add some UI elements that will be constrained by and only show while the "Developer Playground" is expanded. If there's a better method please let me know.

I've taken some Minim audioplayer code from a player with oscilloscope that I already have in Processing. I've got the audio and oscilloscope working nicely and can have it stop/start audio after I pick which MP3 to load. I'm having some trouble identifying the best way to confine the controls and oscilloscope to the playground area and to only have it show while expanded.

Any tips would be greatly appreciated. My original code was something like this:

  xCenter = width/2;
  yCenter = height/2;
  for(int i = 0; i < player.bufferSize() - 1; i++)
  {
    //line(x1, y1, x2, y2)
    line(i, yCenter-200+player.left.get(i)*100, i+1, yCenter-200+player.left.get(i+1)*100);
    line(i, yCenter+200+player.right.get(i+1)*100, i+1, yCenter+200+player.right.get(i)*100);
  }

I've got the oscilloscope right below the text("Developer Playground", x + 10, y + 10); in the Playground class but that's definitely not right. What's the best bet for making sure everything stays within these variables?
    x = width;
    y = topMargin;
    w = 0;
    h = height - (topMargin+bottomMargin);
Will provide the code via Github once done.
Thanks so much,
Corey

Comments

  • Well, I'm sure this isn't the best solution I've managed to keep the oscilloscope and buttons inside the playground. It'd be super helpful if there were a xPlaygroundCenter and yPlaygroundCenter variable to align playground UI elements.

    I've done this for the oscilloscope:
            line(i+x, yCenter-100+player.left.get(i)*100, i+x+1, yCenter-100+player.left.get(i+1)*100);
            line(i+x, yCenter+100+player.right.get(i)*100, i+x+1, yCenter+100+player.right.get(i+1)*100);

    Am still reading through the Button and GUI code to try and integrate and implement things smoothly.
    -Corey
  • Hey Corey,

    Thanks for the feedback. 

    Are you suggesting that we implement 2 additional internal class variables (to the playground), that keep track of the x and y centers of the playground?

    Any other suggestions for the GUI code are much appreciated. We're starting to revamp it now, prepping for the release of the new hardware.

    Best,

    Conor
Sign In or Register to comment.