Beispiel #1
0
  public void CONFIGoff() {

    myPort.write("j"); // exit config command
    buttonWRITE.setColorBackground(gray_);
    buttonREAD.setColorBackground(gray_);
    buttonCONFon.setColorBackground(gray_);
    buttonCONFoff.setColorBackground(green_);
    writeEnable = false;
    readEnable = false;
  }
Beispiel #2
0
  public void CONFIGon() {

    myPort.write("i"); // enter config command
    buttonWRITE.setColorBackground(green_);
    buttonREAD.setColorBackground(green_);
    buttonCONFon.setColorBackground(green_);
    buttonCONFoff.setColorBackground(gray_);
    writeEnable = true;
    readEnable = true;
  }
Beispiel #3
0
  public void READ() {
    if (readEnable == false) return;

    myPort.write("g"); // sends get values command

    while (i < 200000000) {
      i++;
    } // delay
    i = 0;

    // myPort.write("OK");
    readStatus = "Can't Read";

    if (myPort.read() == 'x') {
      PitchP.setValue(myPort.read() / 100.00f);
      RollP.setValue(myPort.read() / 100.00f);
      YawP.setValue(myPort.read() / 100.00f);

      PitchD.setValue(myPort.read() / 100.00f);
      RollD.setValue(myPort.read() / 100.00f);
      YawD.setValue(myPort.read() / 100.00f);

      PitchPWR.setValue(myPort.read());
      RollPWR.setValue(myPort.read());
      YawPWR.setValue(myPort.read());

      RCcontrol = PApplet.parseChar(myPort.read());
      YawRCon = PApplet.parseChar(myPort.read());

      RollCal.setValue((myPort.read() - 100.00f) / 10.00f);

      if (RCcontrol == '0') {
        buttonRCOff.setColorBackground(green_);
        buttonRCOn.setColorBackground(gray_);
      }
      if (RCcontrol == '1') {
        buttonRCOff.setColorBackground(gray_);
        buttonRCOn.setColorBackground(green_);
      }

      if (YawRCon == '0') {
        buttonYawRC.setColorBackground(gray_);
        buttonYawAut.setColorBackground(green_);
      }
      if (YawRCon == '1') {
        buttonYawRC.setColorBackground(green_);
        buttonYawAut.setColorBackground(gray_);
      }

      readStatus = "Read OK";
    }
  }
  public void draw() {
    background(0);

    for (int i = 0; i < cols; i++) {
      for (int j = 0; j < rows; j++) {

        if ((i & 1) == 0) {
          // even rows white
          grid[i][j].display(255);
        } else {
          // odd rows gray
          grid[i][j].display(220);
        }
      }
    }

    if (play == true) {
      int j;
      if (millis() - starttime < delaytime) {
        count_up = (millis() - starttime);
        count_down = delaytime - count_up;
        steptimer = floor(4 / (delaytime / count_up));
        fill(0);
        //        textSize(12);
        //        text(steptimer, mouseX, mouseY);
        for (j = 0; j < rows; j++) {
          grid[steptimer][j].display(120);
          if (grid[steptimer][j].active) {
            grid[steptimer][j].trigger(steptimer, j);
          }
        }

        switch (steptimer) {
          case 0:
            uno = PApplet.parseByte(unbinary("00010001"));
            due = PApplet.parseByte(unbinary("00010001"));
            break;
          case 1:
            uno = PApplet.parseByte(unbinary("00100010"));
            due = PApplet.parseByte(unbinary("00100010"));
            break;
          case 2:
            uno = PApplet.parseByte(unbinary("01000100"));
            due = PApplet.parseByte(unbinary("01000100"));
            break;
          case 3:
            uno = PApplet.parseByte(unbinary("10001000"));
            due = PApplet.parseByte(unbinary("10001000"));
            break;
        }
        print(binary(uno));
        println(binary(due));

        myPort.write(due);
        myPort.write(uno);
        myPort.write(',');
      } else {
        starttime = millis();
        j = 0;
      }

      for (int i = 0; i < cols; i++) {
        for (int k = 0; k < rows; k++) {

          if (grid[i][k].active) {
            // even rows white

            if ((i + 4 * k) < 8) {
              uno |= (1 << i + 4 * k);
            } else {
              due |= (1 << (i + 4 * k) - 8);
            }
          } else {
            // odd rows gray

            if ((i + 4 * k) < 8) {
              uno &= ~(1 << i + 4 * k); // chiedete a vanzati [email protected]
            } else {
              due &= ~(1 << (i + 4 * k) - 8);
            }
          }
        }
      }
    }

    // print(binary(uno));
    // print(binary(due));

    myPort.write(due);
    myPort.write(uno);
    myPort.write(',');

    println();
  }
Beispiel #5
0
  public void WRITE() {
    if (writeEnable == false) return;

    myPort.write("h");

    myPort.write(PApplet.parseInt(PitchP.value() * 100));
    myPort.write(PApplet.parseInt(RollP.value() * 100));
    myPort.write(PApplet.parseInt(YawP.value() * 100));

    myPort.write(PApplet.parseInt(PitchD.value() * 100));
    myPort.write(PApplet.parseInt(RollD.value() * 100));
    myPort.write(PApplet.parseInt(YawD.value() * 100));

    myPort.write(PApplet.parseInt(PitchPWR.value()));
    myPort.write(PApplet.parseInt(RollPWR.value()));
    myPort.write(PApplet.parseInt(YawPWR.value()));

    myPort.write(RCcontrol);
    myPort.write(YawRCon);

    myPort.write(PApplet.parseInt(RollCal.value() * 10 + 100));
    // println (RollCal.value());
    // println (int (RollCal.value()*10+100));

    readStatus = "Write OK";
  }