Пример #1
0
  public void InitNumberBox() {
    // Initialize number box
    conf_KP =
        controlP5
            .addNumberbox("KP")
            .setPosition(550, 50)
            .setColorBackground(c_red)
            .setSize(60, 18)
            .setRange(0, 250)
            //      .setScrollSensitivity(5.1)//?
            .setMultiplier(1) // set the sensitifity of the numberbox
            .setDirection(Controller.HORIZONTAL); // change the control direction to left/right

    conf_KI =
        controlP5
            .addNumberbox("KI")
            .setPosition(550, 90)
            .setColorBackground(c_red)
            .setSize(60, 18)
            .setRange(0, 250)
            .setMultiplier(1) // set the sensitifity of the numberbox
            .setDirection(Controller.HORIZONTAL); // change the control direction to left/right

    conf_KD =
        controlP5
            .addNumberbox("KD")
            .setPosition(550, 130)
            .setColorBackground(c_red)
            .setSize(60, 18)
            .setRange(0, 250)
            .setMultiplier(1) // set the sensitifity of the numberbox
            .setDirection(Controller.HORIZONTAL); // change the control direction to left/right
  }
Пример #2
0
  public void InitButton() {
    // Set zero acc e gyro
    controlP5
        .addButton("SET_ZERO")
        // .setValue(0)
        .setPosition(450, 50)
        .setSize(60, 20)
        .setColorBackground(c_blue);

    // Read PID parameter
    controlP5
        .addButton("READ_PID")
        // .setValue(0)
        .setPosition(450, 90)
        .setSize(60, 20)
        .setColorBackground(c_blue);

    // Write PID parameter
    controlP5
        .addButton("WRITE_PID")
        // .setValue(0)
        .setPosition(450, 130)
        .setSize(60, 20)
        .setColorBackground(c_blue);

    // Write PID parameter
    controlP5
        .addButton("SAVE_PID")
        //  .setValue(0)
        .setPosition(450, 170)
        .setSize(60, 20)
        .setColorBackground(c_blue);
    /*
          // START
      controlP5.addButton("START")
         .setPosition(650,50)
         .setSize(60,20)
         .setColorBackground(c_blue)
         ;

      // STOP
      controlP5.addButton("STOP")
         .setPosition(650,90)
         .setSize(60,20)
         .setColorBackground(c_blue)
         ;
    */
  }
Пример #3
0
  public void setup() {
    size(setupw, setuph);
    font = createFont("TAHOMA.TTF", (float) 11.5);

    controlP5 = new ControlP5(this);

    // NORA: initialize all people for static reference
    PApplet p = (PApplet) this;
    people.add(new Person(67, 108, p, 1, p.loadImage("naj.png"), "Najla E.", null));
    people.add(new Person(133, 54, p, 2, p.loadImage("nora.png"), "Nora N.", null));
    people.add(new Person(200, 210, p, 3, p.loadImage("risa.png"), "Risa N.", null));
    people.add(new Person(267, 162, p, 4, p.loadImage("mak.png"), "Makoto B.", null));

    // NORAS INIT: changed these methods to refer to static Person's already created
    // in class Space
    ArrayList<Person> people1 = new ArrayList<Person>();
    people1.add(people.get(0));
    people1.add(people.get(1));
    ArrayList<Person> people2 = new ArrayList<Person>();
    people2.add(people.get(3));
    people2.add(people.get(2));
    people2.add(people.get(1));

    pspace1 = new PrivateSpace(this, people1, 0, controlP5);
    pspace2 = new PrivateSpace(this, people2, setupw / 4, controlP5);
    Tab1 chat = new Chat(this, setupw / 2, controlP5);

    // HAN WEI
    // controlP5 = new ControlP5(this);
    // create a new instance of the PrivateRoomBtn controller.
    // pspace1 = new PrivateRoomBtn(this, controlP5, "privateRoomBtn1", 0, mainh, (height-mainh)/2,
    // (height-mainh));
    // register the newly created PrivateRoomBtn with controlP5
    controlP5.register(pspace1);
    // create a new instance of the PrivateRoomBtn controller.
    // pspace2 = new PrivateRoomBtn(this, controlP5, "privateRoomBtn2", width-(height-mainh)/2,
    // mainh, (height-mainh)/2, (height-mainh));
    // register the newly created PrivateRoomBtn with controlP5
    controlP5.register(pspace2);
    controlP5.register(chat);

    mainSpace = new Space(this, mainh, mainw, 0xFF006699, 255, 0, 0, controlP5, true);
    controlP5.register(mainSpace);

    smooth();
  }
Пример #4
0
  @Override
  public void setup() {
    size(2 * w, h + 150);

    // Camera initiated to capture from device
    capture = HighGui.captureFromCAM(0);

    im = CxCore.createImage(w, h, PixelDepth.IPL_DEPTH_8U, ColorModel.BGR);
    im_thresh = CxCore.createImage(w, h, PixelDepth.IPL_DEPTH_8U, ColorModel.BGR);

    // Init GUI
    ControlP5 controlP5 = new ControlP5(this);
    thresh_slider = controlP5.addSlider("thresh_val", 0, 255, 20, h + 20, 10, 100);
    r = controlP5.addRadioButton("thresh_type", 80, h + 20);
    for (int i = 0; i < ThresholdType.values().length; i++) {
      r.addItem(ThresholdType.values()[i].toString(), i + 1);
    }
    r.activate(0);
  }
  // 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();
  }
Пример #7
0
 public void InitSlider() {
   // Initialize slider plot
   int posX = 330;
   int posY = 50;
   AccSlider =
       controlP5
           .addSlider("Acc_RAW")
           .setPosition(posX, posY)
           .setSize(20, 100)
           .setRange(0, 1023)
           .setValue(0)
           .lock()
           .setColorBackground(c_blue);
   GyroSlider =
       controlP5
           .addSlider("Gyro_RAW")
           .setPosition(posX + 50, posY)
           .setSize(20, 100)
           .setRange(0, 1023)
           .setValue(0)
           .lock()
           .setColorBackground(c_blue);
 }
Пример #8
0
  public void setup() {
    size(1024, 768);
    background(0);
    frameRate(30);
    smooth();

    drawVectors = false;

    paused = true;

    timeline = new Timeline();

    sim = new GravitySimulation();

    sun = new Star(5000, 25, new PVector(300, 500), new PVector(0, 0), 0, "sun");
    planet = new Planet(10, 10, new PVector(500, 500), new PVector(0, 40), "planet");
    planet2 = new Planet(50, 10, new PVector(150, 500), new PVector(0, -40), "planet2");

    timeline.registerStatefulObject(sun);
    timeline.registerStatefulObject(planet);
    timeline.registerStatefulObject(planet2);

    controlP5 = new ControlP5(this);

    btnRewind = controlP5.addButton("btnRewind_OnClick", 0, 800, 20, 50, 20);
    btnRewind.setLabel("Rewind");

    btnPlayPause = controlP5.addButton("btnPlayPause_OnClick", 0, 860, 20, 50, 20);
    btnPlayPause.setLabel("Play");

    btnFastForward = controlP5.addButton("btnFastForward_OnClick", 0, 920, 20, 80, 20);
    btnFastForward.setLabel("Fast Forward");

    sliderTimeline = controlP5.addSlider("sliderTimeline_OnClick", 0, 10000, 0, 20, 720, 900, 10);
    sliderTimeline.setLabel("Timeline");
  }
Пример #9
0
  public void GUISetup() {
    // set up GUI
    String[] outputs = MidiBus.availableOutputs();
    String[] inputs = MidiBus.availableInputs();

    controlP5 = new ControlP5(this);
    programlabel = controlP5.addTextlabel("programlabel", "Programs", 350, 65);
    Radio programs = controlP5.addRadio("programs", 350, 80);
    programs.deactivateAll();
    programs.add("on", 1);
    programs.add("off", 2);
    programs.add("oscillate", 0);
    programs.add("fade", 4);
    programs.add("random", 3);

    midioutlabel = controlP5.addTextlabel("midioutlabel", "MIDI Outputs", 200, 65);
    Radio midioutdevices = controlP5.addRadio("midioutdevices", 200, 80);
    midioutdevices.deactivateAll();
    for (int i = 0; i < (outputs.length - 1); i++) {
      midioutdevices.add(outputs[i], i);
    }

    midiinlabel = controlP5.addTextlabel("midiinlabel", "MIDI Inputs", 100, 65);
    Radio midiindevices = controlP5.addRadio("midiindevices", 100, 80);
    midiindevices.deactivateAll();
    for (int i = 0; i < (inputs.length - 1); i++) {
      midiindevices.add(inputs[i], i);
    }

    options = controlP5.addTextlabel("options", "Options", 10, 65);
    optionsbox = controlP5.addCheckBox("optionsbox", 10, 80);
    optionsbox.setItemsPerRow(3);
    optionsbox.setSpacingColumn(30);
    optionsbox.setSpacingRow(10);
    optionsbox.addItem("notes -> cc", 0);

    heading = controlP5.addTextlabel("heading", "grmnygrmny.lightarray", 200, 20);
  }
Пример #10
0
  /**
   * Creates a thin, dark standard button.
   *
   * @param name of the button
   * @param text to display on the button
   * @param x position of the button
   * @param y position of the button
   * @param m left margin of the text
   * @return a button object
   */
  private controlP5.Button createSelectButton(String name, String text, int x, int y) {
    controlP5.Button b =
        cp5.addButton(name)
            .setPosition(x, y)
            .setSize(100, 20)
            .setColorBackground(color(0, 200))
            .setColorActive(color(0, 200))
            .setColorForeground(color(0, 150));

    b.getCaptionLabel()
        .setFont(arialMain)
        .toUpperCase(false)
        .setSize(12)
        .setText(text)
        .setColor(color(140));

    return b;
  }
Пример #11
0
 public void InitComDropdown() {
   // Initialize portCommList
   int posX = 20;
   int posY = 70;
   PortsList = controlP5.addDropdownList("portComList", posX, posY, 100, 84);
   // Set the background color of the list (you wont see this though).
   PortsList.setBackgroundColor(color(200));
   // Set the height of each item when the list is opened.
   PortsList.setItemHeight(20);
   // Set the height of the bar itself.
   PortsList.setBarHeight(15);
   // Set the lable of the bar when nothing is selected.
   PortsList.captionLabel().set("Select COM port");
   // Set the top margin of the lable.
   PortsList.captionLabel().style().marginTop = 3;
   // Set the left margin of the lable.
   PortsList.captionLabel().style().marginLeft = 3;
   // Set the top margin of the value selected.
   PortsList.valueLabel().style().marginTop = 3;
   // Store the Serial ports in the string comList (char array).
   comList = serial.list();
   // We need to know how many ports there are, to know how many items to add to the list, so we
   // will convert it to a String object (part of a class).
   String comlist = join(comList, ",");
   // We also need how many characters there is in a single port name, we\u00b4ll store the chars
   // here for counting later.
   String COMlist = comList[0];
   // Here we count the length of each port name.
   int size2 = COMlist.length();
   // Now we can count how many ports there are, well that is count how many chars there are, so we
   // will divide by the amount of chars per port name.
   int size1 = comlist.length() / size2;
   // Now well add the ports to the list, we use a for loop for that. How many items is determined
   // by the value of size1.
   for (int i = 0; i < size1; i++) {
     // This is the line doing the actual adding of items, we use the current loop we are in to
     // determin what place in the char array to access and what item number to add it as.
     PortsList.addItem(comList[i], i);
   }
   // Set the color of the background of the items and the bar.
   PortsList.setColorBackground(color(60));
   // Set the color of the item your mouse is hovering over.
   PortsList.setColorActive(color(255, 128));
 }
Пример #12
0
  /**
   * Creates a standard button.
   *
   * @param name of the button
   * @param text to display on the button
   * @param x position of the button
   * @param y position of the button
   * @param m left margin of the text
   * @return a button object
   */
  @SuppressWarnings("deprecation")
  private controlP5.Button createButton(String name, String text, int x, int y, int m) {
    controlP5.Button b =
        cp5.addButton(name)
            .setPosition(x, y)
            .setSize(160, 35)
            .setColorBackground(color(0, 50))
            .setColorActive(color(0, 200))
            .setColorForeground(color(0, 150));

    b.getCaptionLabel()
        .setFont(arialB)
        .setText(text)
        .toUpperCase(false)
        .setSize(18)
        .setColor(color(200));
    b.captionLabel().getStyle().marginLeft = m;

    return b;
  }
Пример #13
0
  public void draw() { // display things

    // execute sceneManager stuff
    resetMatrix();
    // beginCamera();
    camera();
    rotateX(HALF_PI);
    translate(globalCameraX, globalCameraY, globalCameraZ);

    /* rotation using a and d
    PMatrix3D foRealCameraMatrix=new PMatrix3D();
    getMatrix(foRealCameraMatrix);
    */
    // translate(0,-100, -400 );
    // translate(0,0, 0 );
    // rotate(sin(millis() * 0.001), 1,0,0);

    background(bGround);

    for (int i = 0; i < cameras.size(); i++) {
      //    camPicker.start(i);  //add picker to each cam
      picker.start(i);
      cameras.get(i).display();
    }
    //  camPicker.stop();

    for (int i = cameras.size(); i < cameras.size() + characters.size(); i++) {
      //    charPicker.start(i);
      picker.start(i);
      characters.get(i - cameras.size()).display();
    }
    //  charPicker.stop();
    picker.stop();

    // endCamera();

    //  int id = camPicker.get(mouseX, mouseY);
    //  if (id > -1) {
    //    for (int i=0; i<cameras.size(); i++) {
    //      if (i == id) {
    //        cameras.get(id).changeToSelectedColor();
    //        cameras.get(id).isSelected = true;
    //      } else {
    //        cameras.get(i).setDefaultColor();
    //        cameras.get(i).isSelected = false;
    //      }
    //    }
    //  }

    // checks for rule violations
    int id = -1;
    for (int i = 0; i < cameras.size(); i++) {
      if (cameras.get(i).isSelected) {
        if (selectedRule == 0) rulesChecker.checkLineOfAction(cameras, characters, i);
        else if (selectedRule == 1) rulesChecker.checkThirtyDegreeRule(cameras, characters, i);
        else resetAllCams();
      }
    }

    rulesChecker.checkCuttingOnAction(sm, timeline);
    rulesChecker.checkPacing(sm, timeline);

    /* This is for camera rotation using a and d
    resetMatrix();
    pushMatrix();
    setMatrix(myCamera);
    rotate(angle);
    getMatrix();
    popMatrix;
    */

    // have to rotate back to original orientation in order to properly display the drop-down menu

    rotateX(PI);
    rotateX(HALF_PI);

    controlP5.draw();
    timeline.draw();
  }
Пример #14
0
  public void setup() {
    size(800, 500);
    ball = new Ball(width / 2, height / 2, new PVector(5, 5));
    rectMode(CENTER);
    paddles = new Paddle[2];
    paddles[0] = new Paddle(width - 40, 20);
    paddles[1] = new Paddle(40, 20);

    setupContext();
    skeleton = new TSSkeleton();
    cp5 = new ControlP5(this);
    //  cp5.addBang("restart").setPosition(350, 10).setSize(10, 10);

    d1 = cp5.addDropdownList("paddle1").setPosition(width - 150, 20);
    d2 = cp5.addDropdownList("paddle2").setPosition(50, 20);
    d3 = cp5.addDropdownList("1_or_2_player").setPosition(150, 20);
    d4 = cp5.addDropdownList("speed").setPosition(250, 20);

    jointNames = loadStrings("joints.txt");

    d4.addItem("slow", 0);
    d4.addItem("fast", 1);
    d4.addItem("Jeez-us", 2);

    for (int i = 0; i < jointNames.length; i++) {
      d1.addItem(jointNames[i], i);
      d2.addItem(jointNames[i], i);
    }

    d3.addItem("one player", 0);
    d3.addItem("two players", 1);

    smooth();
    println("SimpleOpenNI.SKEL_HEAD " + SimpleOpenNI.SKEL_HEAD);
    println("SimpleOpenNI.SKEL_LEFT_ANKLE " + SimpleOpenNI.SKEL_LEFT_ANKLE);
    println("SimpleOpenNI.SKEL_LEFT_COLLAR " + SimpleOpenNI.SKEL_LEFT_COLLAR);
    println("SimpleOpenNI.SKEL_LEFT_ELBOW " + SimpleOpenNI.SKEL_LEFT_ELBOW);
    println("SimpleOpenNI.SKEL_LEFT_FINGERTIP " + SimpleOpenNI.SKEL_LEFT_FINGERTIP);
    println("SimpleOpenNI.SKEL_LEFT_FOOT " + SimpleOpenNI.SKEL_LEFT_FOOT);
    println("SimpleOpenNI.SKEL_LEFT_HAND " + SimpleOpenNI.SKEL_LEFT_HAND);
    println("SimpleOpenNI.SKEL_LEFT_HIP " + SimpleOpenNI.SKEL_LEFT_HIP);
    println("SimpleOpenNI.SKEL_LEFT_KNEE " + SimpleOpenNI.SKEL_LEFT_KNEE);
    println("SimpleOpenNI.SKEL_LEFT_SHOULDER " + SimpleOpenNI.SKEL_LEFT_SHOULDER);
    println("SimpleOpenNI.SKEL_LEFT_WRIST " + SimpleOpenNI.SKEL_LEFT_WRIST);
    println("SimpleOpenNI.SKEL_NECK " + SimpleOpenNI.SKEL_NECK);
    println("SimpleOpenNI.SKEL_RIGHT_ANKLE " + SimpleOpenNI.SKEL_RIGHT_ANKLE);
    println("SimpleOpenNI.SKEL_RIGHT_COLLAR " + SimpleOpenNI.SKEL_RIGHT_COLLAR);
    println("SimpleOpenNI.SKEL_RIGHT_ELBOW " + SimpleOpenNI.SKEL_RIGHT_ELBOW);
    println("SimpleOpenNI.SKEL_RIGHT_FINGERTIP " + SimpleOpenNI.SKEL_RIGHT_FINGERTIP);
    println("SimpleOpenNI.SKEL_RIGHT_FOOT " + SimpleOpenNI.SKEL_RIGHT_FOOT);
    println("SimpleOpenNI.SKEL_RIGHT_HAND  " + SimpleOpenNI.SKEL_RIGHT_HAND);
    println("SimpleOpenNI.SKEL_RIGHT_HIP " + SimpleOpenNI.SKEL_RIGHT_HIP);
    println("SimpleOpenNI.SKEL_RIGHT_KNEE " + SimpleOpenNI.SKEL_RIGHT_KNEE);
    println("SimpleOpenNI.SKEL_RIGHT_SHOULDER " + SimpleOpenNI.SKEL_RIGHT_SHOULDER);
    println("SimpleOpenNI.SKEL_RIGHT_WRIST " + SimpleOpenNI.SKEL_RIGHT_WRIST);
    println("SimpleOpenNI.SKEL_TORSO " + SimpleOpenNI.SKEL_TORSO);
    println("SimpleOpenNI.SKEL_WAIST " + SimpleOpenNI.SKEL_WAIST);

    translations = new int[jointNames.length];
    translations[0] = 1;
    translations[1] = 19;
    translations[2] = 5;
    translations[3] = 7;
    translations[4] = 10;
    translations[5] = 20;
    translations[6] = 9;
    translations[7] = 17;
    translations[8] = 18;
    translations[9] = 6;
    translations[10] = 8;
    translations[11] = 2;
    translations[12] = 23;
    translations[13] = 11;
    translations[14] = 13;
    translations[15] = 16;
    translations[16] = 24;
    translations[17] = 15;
    translations[18] = 21;
    translations[19] = 22;
    translations[20] = 12;
    translations[21] = 14;
    translations[22] = 3;
    translations[23] = 4;

    font = loadFont("AlBayan-48.vlw");
    textFont(font, 48);
  }
  public void setup() {
    size(800, 600);
    background(255);

    // Local variables to set where the components will be
    int margin = 16;
    int spacing = 36;
    int w = 128;
    int h = 32;

    // Initialize ControlP5
    controlP5 = new ControlP5(this);
    // Set the color of the labels
    controlP5.setColorLabel(color(255, 0, 0));

    // Add components
    controlP5.addButton("Clear Screen", 1, margin, spacing, w, h);
    controlP5.addSlider("Leaf Red", 0, 255, 255, margin, spacing * 2, w, h);
    controlP5.addSlider("Leaf Green", 0, 255, 64, margin, spacing * 3, w, h);
    controlP5.addSlider("Leaf Blue", 0, 255, 0, margin, spacing * 4, w, h);
    controlP5.addSlider("Branch Random", 0, PI, PI / 4, margin, spacing * 5, w, h);
    controlP5.addSlider("Leaf Random", 0, 32, 16, margin, spacing * 6, w, h);
    controlP5.addSlider("Leaf Size", 0, 32, 16, margin, spacing * 7, w, h);
    controlP5.addSlider("Start Size", 0, 128, 64, margin, spacing * 8, w, h);
  }
Пример #16
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_);
  }
Пример #17
0
  /**
   * Creates the window, sets up the fonts and the libraries. Aligns all the buttons, backgrounds
   * and the text.
   */
  public void setup() {

    // Create window
    size(600, 500);

    // Select Fonts
    arialMain = createFont("ArialBold", 32);
    arialB = createFont("Arial", 16);

    // Set the controller
    cp5 = new ControlP5(this);

    // Main Menu text
    cp5.addTextlabel("mainText")
        .setPosition(width / 2 - 85, 30)
        .setText("Main Menu")
        .setFont(arialMain)
        .setColor(200);

    // Help Button
    buttonHelp = createButton("buttonHelp", "Help", 55, 85, 60);

    // Tournament Button
    buttonTournament = createButton("buttonTournament", "Tournament", 220, 85, 27);

    // Random Map Button
    createMap = createButton("createMap", "Random Map", 385, 85, 22);

    // A group to store all the brain related objects
    Group antBrains =
        cp5.addGroup("antBrains")
            .setBackgroundColor(color(0, 64))
            .setBackgroundHeight(270)
            .setWidth(490)
            .setTitle("Ant brain, you choose.")
            .setColorBackground(color(0, 100))
            .setPosition(55, 125)
            .hideArrow()
            .hideBar();

    // Load the background image for the brain group
    bg = loadImage("brainsbg.png");

    // A button is used to store the background image for the brain group.
    bgBrain =
        cp5.addButton("bgBrain")
            .setPosition(0, 0)
            .setImages(bg, bg, bg)
            .updateSize()
            .moveTo(antBrains)
            .setOff();

    // Select Red Brain Button
    selectRedBrain =
        createSelectButton("selectRedBrain", "Select Brain", 490 / 4 - 50, 140).moveTo(antBrains);

    // Select Black Brain Button
    selectBlackBrain =
        createSelectButton("selectBlackBrain", "Select Brain", 490 / 4 * 3 - 50, 140)
            .moveTo(antBrains);

    // Select Map Button
    selectMap =
        cp5.addButton("selectMap")
            .setPosition(0, 232)
            .setSize(490, 35)
            .setColorBackground(color(0, 200))
            .setColorActive(color(0, 200))
            .setColorForeground(color(0, 150))
            .moveTo(antBrains);

    // Set text and font options for the Select Map Button
    selectMap
        .getCaptionLabel()
        .setFont(arialB)
        .setText("Select Map")
        .toUpperCase(false)
        .setSize(18)
        .setColor(color(140))
        .getStyle()
        .setMarginLeft(190);

    // Start Button
    startButton =
        cp5.addButton("startButton")
            .setPosition(55, 400)
            .setSize(490, 65)
            .setColorBackground(color(115, 73, 73))
            .setColorActive(color(215, 73, 73))
            .setColorForeground(color(115, 73, 73))
            .lock();

    // Set text and font options for the Start Button
    startButton
        .getCaptionLabel()
        .setFont(arialB)
        .setText("START")
        .toUpperCase(false)
        .setSize(38)
        .setColor(color(140))
        .getStyle()
        .setMarginLeft(180);

    // Load the main background image
    bgMain = loadImage("bg.jpg");

    // Creates all the temporary files;
    createTempDir();
  }