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 ZERO() { RollCal.setValue(0.0f); // println (RollCal.value()); // println (int (RollCal.value()*10+100)); }
public void draw() { // String Serial.list()[]; // size(600, 280); // background(80); fill(70); strokeWeight(0); stroke(35); // 75 rect(0, 80, 600, 155, 0); fill(70); strokeWeight(0); stroke(35); rect(440, 80, 600, 155, 0); fill(75); strokeWeight(0); stroke(80); rect(0, 240, 600, 100, 0); fill(255); // Background // setGradient(0, 0, width, 80, c2, c1, Y_AXIS); textSize(12); text("Pitch P:", 35, 112); textSize(12); text("Pitch D:", 155, 112); textSize(12); text("Roll P:", 38, 162); textSize(12); text("Roll D:", 158, 162); textSize(12); text("Yaw P:", 38, 211); textSize(12); text("Yaw D:", 158, 211); textSize(12); text("Pitch Power: %", 301, 112); textSize(12); text("Roll Power: %", 307, 162); textSize(12); text("Yaw Power: %", 305, 212); textSize(12); text("Roll Calibration (degr.)", 460, 190); textSize(16); // fill(0, 102, 153, 204); // text("Connected to:",400,45); text(Serial.list()[0],515,45); // text("Connected to:",400,45); text(Serial.list()[1],515,65); // text("Connected to:",400,45); text(Serial.list()[2],515,65); if (printlist == true) { for (int i = 0; i <= commListMax; i++) { text(Serial.list()[i], 515, 21 + i * 25); } printlist = false; } textSize(12); text(readStatus, 110, 263); if (PitchP.value() == 0) PitchP.setValue(0.01f); if (RollP.value() == 0) RollP.setValue(0.01f); if (YawP.value() == 0) YawP.setValue(0.01f); if (PitchD.value() == 0) PitchD.setValue(0.01f); if (RollD.value() == 0) RollD.setValue(0.01f); if (YawD.value() == 0) YawD.setValue(0.01f); if (PitchPWR.value() == 0) PitchPWR.setValue(1); if (RollPWR.value() == 0) RollPWR.setValue(1); if (YawPWR.value() == 0) YawPWR.setValue(1); // if(RollCal.value()==-9.9)RollCal.setValue(-9.9); }