problemcontrol gp5 , grafica noLoop()

Hello everyone! I write from the province of Turin, Italy, as soon as I discovered arduino, I opened a passion for data acquisition on engines through an interface interfaced with processing! I'm trying to create a program on processing to read 3 sensors and read them through the library "controlP5. One of these I also want to present it via graphics with the graphic library. THE problem that I am finding and in stopping with noLoop () only the graph and continue to see the values ​​working with controlP5. I can only use noLoop () stopping both the graph and controlP5- !! Where am I wrong?

import processing.serial. *; controllo dell'importazioneP5. *; // import controlP5 library import grafica. *; ControlP5 controlP5; // controlP5 object Serial myPort; // La porta seriale: PFont myFont; // Il carattere del display: String inString; // stringa di input dalla porta seriale: int lf = 10; // ASCII linefeed float deg, val; ; Manopola myKnob1; int knobValue = 100; int xPos = 0; GPlot plot1, plot2; // int DeltaPress = 0; void setup () {size (1500,760); myPort = new Serial (questo, "com3", 9600); myPort.bufferUntil (lf); { liscio(); // ControlP5 controlP5 = new ControlP5 (this); // ControlP5 myKnob1 = controlP5.addKnob ("Portata ARIA") //.setTime loop (); . lock () .setRange (0,1024) .setValue (0) .setPosition (400,605) // posizione. setRadius (50) .setNumberOfTickMarks (10) // linee esterne .snapToTickMarks (true) .setTickMarkLength (6) .setColorForeground (color (# 6AFA05)) .setColorBackground (color (155)) // colore sfondo .setColorValueLabel (colore (# FF0318)) // colore numeri .setColorActive (color (# 6AFA05)) .setDragDirection (Knob.VERTICAL). setColorCaptionLabel (0) // colore scritta; //.setHeight(155)} {// noLoop (); // Crea il primo grafico Crea il primo grafico plot1 = new GPlot (this); plot1.setPos (100,30); // posizione plot1.setMar (0, 100, 0,100); plot1.setDim (1150, 500); // dimensione plot1.setAxesOffset (4); plot1.setTicksLength (4); // Crea il secondo grafico con le stesse dimensioni plot2 = new GPlot (this); // Prepara i punti Prepara i punti int myKnob1 = 0; Punti GPointsArray = new GPointsArray (myKnob1); for (int i = 15; i <13; i ++) {points.add (i, 20 + 10 * noise (i * 0.1)); if (xPos == 13) {}} // Imposta i punti, il titolo e le etichette degli assi plot1.setPoints (punti); plot1.setTitleText ("BENATTI ALESSANDRO"); plot1.getYAxis (). setAxisLabelText ("MASSA ARIA (?)"); plot1.getXAxis (). setAxisLabelText ("APERTURA VALVOLA (mm)"); plot1.activatePanning (); // noLoop (); }} void serialEvent (Serial p) {inString = p.readString (); char primo = inString.charAt (0); // primo carattere String cifra = inString.substring (1); // da secondo carattere in poi float val = parseFloat (cifra); // valore da 0-255 o 0-1023, non sò cosa spedisce arduino print ("val ="); println (val); inString = trim (inString); switch (primo) {case ('A'): myKnob1.setValue (val); rompere; }} void draw () {background (155); {ictus (0); text (int (myKnob1.getValue ()), 70,235); testo ("DIFF. PRESS. (mPa)", 200.600);} GPoint lastPoint = plot2.getPointsRef (). getLastPoint (); if (lastPoint == null) {plot1.addPoint (xPos, + myKnob1.getValue (), "(" + str (xPos) + "," + str (myKnob1.getValue ()) + ")"); } else if (! lastPoint.isValid () || sq (lastPoint.getX () - xPos) + sq (lastPoint.getY () + myKnob1.getValue ())> 2500) {//plot1.addPoint(xPos, - val, "(" + (xPos) + "," + (-val) + ")"); } // Ripristina i punti se l'utente ha premuto la barra spaziatrice if (keyPressed && key == '') {plot1.setPoints (new GPointsArray ()); } // Disegna il primo grafico // Disegna la prima trama plot1.beginDraw (); plot1.drawBox (); plot1.drawXAxis (); plot1.drawYAxis (); plot1.drawTitle (); //plot1.drawPoints();//pallinorosso sul valore plot1.drawGridLines (GPlot.BOTH); plot1.drawLines (); plot1.endDraw (); } void mousePressed () {// if (mouseButton == LEFT) {xPos--; } if (mouseButton == LEFT) xPos + = 1; ridisegnare (); // if (xPos <0) {xPos = 0; }} void GPlot () {noLoop (); } beginDraw (); plot1.drawBox (); plot1.drawXAxis (); plot1.drawYAxis (); plot1.drawTitle (); //plot1.drawPoints();//pallinorosso sul valore plot1.drawGridLines (GPlot.BOTH); plot1.drawLines (); plot1.endDraw (); } void mousePressed () {// if (mouseButton == LEFT) {xPos--; } if (mouseButton == LEFT) xPos + = 1; ridisegnare (); // if (xPos <0) {xPos = 0; }} void GPlot () {noLoop (); } beginDraw (); plot1.drawBox (); plot1.drawXAxis (); plot1.drawYAxis (); plot1.drawTitle (); //plot1.drawPoints();//pallinorosso sul valore plot1.drawGridLines (GPlot.BOTH); plot1.drawLines (); plot1.endDraw (); } void mousePressed () {// if (mouseButton == LEFT) {xPos--; } if (mouseButton == LEFT) xPos + = 1; ridisegnare (); // if (xPos <0) {xPos = 0; }} void GPlot () {noLoop (); }×

Answers

Sign In or Register to comment.