// hide and show controls
  public void hideControls() {

    if (keyPressed && (key == ' ')) {

      cp5.show();
      // stats and controls
      fill(0, 100);
      noStroke();
      rect(0, 0, 300, 300);

      fill(255);
      textSize(25);
      text("windSpeed: " + String.format("%.2f", wind), 10, 150);
      text("people: " + peopleLength, 10, 180);
      text("behaviors: " + physics.behaviors.size(), 10, 210);
      text("circles: " + circles.size(), 10, 240);
      text("framerate: " + frameRate, 10, 270);
    } else {
      cp5.hide();
    }
  }
  // use this function to calibrate force coefficients in real time
  public void controllers() {

    cp5 = new ControlP5(this);

    // slider control for gravity
    cp5.addSlider("gravY")
        .setPosition(10, height - 60)
        .setRange(0.0f, 0.2f)
        .setSize(200, 10)
        .setColorCaptionLabel(0)
        .setCaptionLabel("gravity");

    // slider control for drag
    cp5.addSlider("drag")
        .setPosition(10, height - 50)
        .setRange(0.0f, 0.2f)
        .setSize(200, 10)
        .setColorCaptionLabel(0);

    // slider control for attractor strength
    cp5.addSlider("attStrength")
        .setPosition(10, height - 35)
        .setRange(0.0f, 0.2f)
        .setSize(200, 10)
        .setColorCaptionLabel(0);

    // slider control for max wind speed
    cp5.addSlider("maxWind")
        .setPosition(10, height - 10)
        .setRange(0.0f, 0.25f)
        .setSize(200, 10)
        .setColorCaptionLabel(0);

    // background color
    cp =
        cp5.addColorPicker("picker")
            .setPosition(10, 65)
            .setColorValue(color(0xff40B785, 255))
            .hideBar();
  }
예제 #3
0
  public void setup() {

    size(600, 280);
    background(75);

    textSize(28);
    fill(0, 120, 170); // blue
    text("EvvGC GUI", 20, 50);
    text(Version, 170, 50);

    // Define colors
    b1 = color(80);
    b2 = color(60);
    c1 = color(80, 80, 80);
    c2 = color(60, 61, 59);

    controlP5 = new ControlP5(this); // initialize the GUI controls

    // List all the available serial ports:
    println(Serial.list());

    commListMax = -1;
    for (int i = 0; i < Serial.list().length; i++) {
      commListMax = i;
    }

    /**
     * ****************************PID
     * cells************************************************************
     */
    PitchP = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("PitchP", 0, xPP, yPP, 40, 16));
    PitchP.setColorBackground(gray_);
    PitchP.setMin(0);
    PitchP.setDirection(Controller.HORIZONTAL);
    PitchP.setDecimalPrecision(2);
    PitchP.setMultiplier(0.01f);
    PitchP.setMax(2.54f);

    PitchD = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("PitchD", 0, xPD, yPD, 40, 16));
    PitchD.setColorBackground(gray_);
    PitchD.setMin(0);
    PitchD.setDirection(Controller.HORIZONTAL);
    PitchD.setDecimalPrecision(2);
    PitchD.setMultiplier(0.01f);
    PitchD.setMax(1);

    RollP = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("RollP", 0, xRP, yRP, 40, 16));
    RollP.setColorBackground(gray_);
    RollP.setMin(0);
    RollP.setDirection(Controller.HORIZONTAL);
    RollP.setDecimalPrecision(2);
    RollP.setMultiplier(0.01f);
    RollP.setMax(2.54f);

    RollD = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("RollD", 0, xRD, yRD, 40, 16));
    RollD.setColorBackground(gray_);
    RollD.setMin(0);
    RollD.setDirection(Controller.HORIZONTAL);
    RollD.setDecimalPrecision(2);
    RollD.setMultiplier(0.01f);
    RollD.setMax(1);

    YawP = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("YawP", 0, xYP, yYP, 40, 16));
    YawP.setColorBackground(gray_);
    YawP.setMin(0);
    YawP.setDirection(Controller.HORIZONTAL);
    YawP.setDecimalPrecision(2);
    YawP.setMultiplier(0.01f);
    YawP.setMax(2.54f);

    YawD = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("YawD", 0, xYD, yYD, 40, 16));
    YawD.setColorBackground(gray_);
    YawD.setMin(0);
    YawD.setDirection(Controller.HORIZONTAL);
    YawD.setDecimalPrecision(2);
    YawD.setMultiplier(0.01f);
    YawD.setMax(1);

    /**
     * ****************************Power
     * cells************************************************************
     */
    PitchPWR =
        (controlP5.Numberbox)
            hideLabel(controlP5.addNumberbox("PitchPWR", 0, xPPWR, yPPWR, 40, 16));
    PitchPWR.setColorBackground(gray_);
    PitchPWR.setMin(0);
    PitchPWR.setDirection(Controller.HORIZONTAL);
    PitchPWR.setDecimalPrecision(0);
    PitchPWR.setMultiplier(1);
    PitchPWR.setMax(100);

    RollPWR =
        (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("RollPWR", 0, xRPWR, yRPWR, 40, 16));
    RollPWR.setColorBackground(gray_);
    RollPWR.setMin(0);
    RollPWR.setDirection(Controller.HORIZONTAL);
    RollPWR.setDecimalPrecision(0);
    RollPWR.setMultiplier(1);
    RollPWR.setMax(100);

    YawPWR =
        (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("YawPWR", 0, xYPWR, yYPWR, 40, 16));
    YawPWR.setColorBackground(gray_);
    YawPWR.setMin(0);
    YawPWR.setDirection(Controller.HORIZONTAL);
    YawPWR.setDecimalPrecision(0);
    YawPWR.setMultiplier(1);
    YawPWR.setMax(100);

    /**
     * ****************************Calibration
     * cells************************************************************
     */
    RollCal =
        (controlP5.Numberbox)
            hideLabel(controlP5.addNumberbox("RollCal", 0, xRollCal, yRollCal, 40, 16));
    RollCal.setColorBackground(gray_);
    RollCal.setMin(-10);
    RollCal.setDirection(Controller.HORIZONTAL);
    RollCal.setDecimalPrecision(1);
    RollCal.setMultiplier(0.2f);
    RollCal.setMax(10);
    buttonZeroRoll = controlP5.addButton("ZERO", 1, 535, 200, 40, 16);
    buttonZeroRoll.setColorBackground(gray_);

    /**
     * **************************Buttons********************************************************************
     */
    buttonWRITE = controlP5.addButton("WRITE", 1, 500, 248, 60, 20);
    buttonWRITE.setColorBackground(gray_);
    buttonREAD = controlP5.addButton("READ", 1, 40, 248, 60, 20);
    buttonREAD.setColorBackground(gray_);

    buttonCONFon = controlP5.addButton("CONFIGon", 1, 400, 10, 60, 60);
    buttonCONFon.setColorBackground(gray_);
    buttonCONFoff = controlP5.addButton("CONFIGoff", 1, 330, 10, 60, 60);
    buttonCONFoff.setColorBackground(gray_);

    buttonP0 = controlP5.addButton("P0", 1, 490, 5, 20, 20);
    buttonP0.setColorBackground(gray_);
    buttonP1 = controlP5.addButton("P1", 1, 490, 30, 20, 20);
    buttonP1.setColorBackground(gray_);
    buttonP2 = controlP5.addButton("P2", 1, 490, 55, 20, 20);
    buttonP2.setColorBackground(gray_);

    buttonRCOff = controlP5.addButton("RC_OFF", 1, 450, 122, 65, 20);
    buttonRCOff.setColorBackground(gray_);
    buttonRCOn = controlP5.addButton("RC_ON", 1, 450, 100, 65, 20);
    buttonRCOn.setColorBackground(gray_);

    buttonYawRC = controlP5.addButton("Yaw_RC_Pan", 1, 520, 100, 75, 20);
    buttonYawRC.setColorBackground(gray_);
    buttonYawAut = controlP5.addButton("Yaw_Auto_Pan", 1, 520, 122, 75, 20);
    buttonYawAut.setColorBackground(gray_);

    buttonCONFoff.setColorBackground(green_);
  }