<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with gettext() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=gettext%28%29</link>
      <pubDate>Sun, 08 Aug 2021 21:26:23 +0000</pubDate>
         <description>Tagged with gettext() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedgettext%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>I can't control when the response in the textfield.</title>
      <link>https://forum.processing.org/two/discussion/24340/i-can-t-control-when-the-response-in-the-textfield</link>
      <pubDate>Mon, 02 Oct 2017 08:57:17 +0000</pubDate>
      <dc:creator>Créol</dc:creator>
      <guid isPermaLink="false">24340@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,</p>

<p>I have a little problem with my programme.</p>

<p>I would like to control if the text in the textfield is good or not but it doesn't work.</p>

<p>I can get the text in the textfield but when I want to check if it's good it doesn't work.</p>

<p>Some one has a solution for me please?</p>

<p>The code is here :</p>

<pre><code>String Reponse = "oui";

import controlP5.*;

ControlP5 cp5;

void setup() {
  size(700,400);

  PFont font = createFont("arial",20);

  cp5 = new ControlP5(this);

  cp5.addTextfield("input")
     .setPosition(20,100)
     .setSize(200,40)
     .setFont(font)
     .setFocus(false)
     .setColor(color(255,0,0))
     ;
      cp5.addBang("clear")
     .setPosition(240,170)
     .setSize(80,40)
     .getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
     ;    

    textFont(font);
}

void draw() {
  background(0);
  fill(255);
  text("Ecrivez votre réponse ici",20,90);
  text(cp5.get(Textfield.class,"input").getText(), 360,130);
  if(cp5.get(Textfield.class,"input").getText() == Reponse){
    text("Vrai",20,20);
  }
}

public void clear() {
  cp5.get(Textfield.class,"input").clear();
}
</code></pre>

<p>thank you</p>
]]></description>
   </item>
   <item>
      <title>How to set a password for G4P gui builder</title>
      <link>https://forum.processing.org/two/discussion/20464/how-to-set-a-password-for-g4p-gui-builder</link>
      <pubDate>Wed, 25 Jan 2017 15:30:53 +0000</pubDate>
      <dc:creator>BananaBunch</dc:creator>
      <guid isPermaLink="false">20464@/two/discussions</guid>
      <description><![CDATA[<p>I've got the password box but how do I set it so when the password is correct it does what I ask it to do.
For example: If the password is correct, change the background color.
Something like that</p>
]]></description>
   </item>
   <item>
      <title>Need a better way of creating a list of text field objects</title>
      <link>https://forum.processing.org/two/discussion/20249/need-a-better-way-of-creating-a-list-of-text-field-objects</link>
      <pubDate>Fri, 13 Jan 2017 23:40:37 +0000</pubDate>
      <dc:creator>deano</dc:creator>
      <guid isPermaLink="false">20249@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,</p>

<p>Have constructed a bit of code that creates say 5 text fields along with corresponding submit buttons.</p>

<p>Have managed this with For Loops. Is there a more elegant way to do this?</p>

<p>I feel my code can be improved as it would be very cumbersome to keep copy-pasting and changing the relative numbers especially for the submit() function. The overall code would take up too much space.</p>

<p>Can the submit function reside within a for loop as well?</p>

<p>Would love to hear some ideas so that I can take it forward. Thanks!</p>

<p>Here is the code I'm using:</p>

<pre><code>import controlP5.*;

ControlP5 cp5;

// Should we do an array for this initialization?
// I don't want to type out say 30 textValues. What is the more elegant way to represent this?
// Arrays.fill()??

String textValue_1 = "";
String textValue_2 = "";
String textValue_3 = "";
String textValue_4 = "";
String textValue_5 = "";

void setup() {
  size(800, 1000);
  cp5 = new ControlP5(this);

  for (int i = 1; i &lt; 6; ++i) {
    cp5.addTextfield("textValue" + "_" + i)
      .setPosition(20, 80*i)
        .setSize(200, 40)
          .setFont(createFont("arial", 20))
            .setCaptionLabel("Enter Text for field " + i)
              .setAutoClear(false)
                ;

    cp5.addButton("submit"+ "_" + i)
      .setPosition(240, 80*i)
        .setSize(80, 40)
          .setCaptionLabel("submit")
            .getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
              ;
  }
} 

void draw() {
  background(0);
}

// The function for submit... can this be done in a for loop?
// I may want a large number of text fields
// and it can get tedious typing it all out every time I change the number


public void submit_1() {
  cp5.get(Textfield.class, "textValue_1").submit();
}

public void submit_2() {
  cp5.get(Textfield.class, "textValue_2").submit();
}

public void submit_3() {
  cp5.get(Textfield.class, "textValue_3").submit();
}

public void submit_4() {
  cp5.get(Textfield.class, "textValue_4").submit();
}

public void submit_5() {
  cp5.get(Textfield.class, "textValue_5").submit();
}


void controlEvent(ControlEvent theEvent) {
  if (theEvent.isAssignableFrom(Textfield.class)) {
    println("controlEvent: accessing a string from controller '"
      +theEvent.getName()+"': "
      +theEvent.getStringValue()
      );
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>cp5 textArea multiline</title>
      <link>https://forum.processing.org/two/discussion/18469/cp5-textarea-multiline</link>
      <pubDate>Sun, 09 Oct 2016 04:42:09 +0000</pubDate>
      <dc:creator>miquel_parera</dc:creator>
      <guid isPermaLink="false">18469@/two/discussions</guid>
      <description><![CDATA[<p>Hello.</p>

<p>I wants to show text in the Textarea ouput in mode multiline: every time I press Return on TextField input shows a different line but don't work! any solution? please : )</p>

<hr />

<pre><code>import controlP5.*;

ControlP5 cp5;

String textValue = "";

Textfield input;
Textarea output;

StringList script;

int index = 0;
void setup()
{
  size(1000,700, P3D);
  frameRate(15);

  PFont font = createFont("arial",20);

  cp5 = new ControlP5(this);

  script = new StringList();

  input = cp5.addTextfield("input")
       .setColor(color(0))
       .setColorBackground(color(255,255,255,29))
       .setColorCursor(color(0))
       .setPosition(10,10)
       .setSize(980,40)
       .setFont(font)
       .setFocus(true)
       ;

  output = cp5.addTextarea("output")
       .setColor(color(0))
       .setColorBackground(color(255,255,255,29))
       //.setColorCursor(color(0))
       .setPosition(10,70)
       .setSize(980,600)
       .setFont(font)
       ;

}

void draw()
{
  background(255);

}

void controlEvent(ControlEvent theEvent){
  index = index + 1;
  textValue = input.getText();
  //println(textValue);
  script.append(textValue);
  String item = script.get(index-1);
  item +=item + "\n";
  output.setText(item + "\n");
  //println(script);
}
</code></pre>

<p><strong><em>Code formatted by moderator 23/02/2018</em></strong></p>
]]></description>
   </item>
   <item>
      <title>Save textArea with ControlP5</title>
      <link>https://forum.processing.org/two/discussion/17330/save-textarea-with-controlp5</link>
      <pubDate>Mon, 27 Jun 2016 21:15:00 +0000</pubDate>
      <dc:creator>Jose_Aparecido</dc:creator>
      <guid isPermaLink="false">17330@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys,</p>

<p>How could I save the contents of a textArea in a text file?</p>

<p>It worked to open normal as the example in the link below, but still managed to save not ... tried this code, but it gives error, the syntax is wrong ...</p>

<p><a href="https://forum.processing.org/one/topic/textarea-using-controlp5.html" target="_blank" rel="nofollow">https://forum.processing.org/one/topic/textarea-using-controlp5.html</a></p>

<p>stretch code:</p>

<pre><code>//String[] lines = loadStrings(textArea.getText());
//printArray(lines);

String lines = textArea.getText()
println(lines);

for (int i = 0; i &lt;= lines.length-1; i++){
   lineSave[i] = lines[i];
}

saveStrings(split(lineSave, "\n"));
</code></pre>

<p>Thanks in advance for your attention.</p>
]]></description>
   </item>
   <item>
      <title>Text Fields</title>
      <link>https://forum.processing.org/two/discussion/17183/text-fields</link>
      <pubDate>Fri, 17 Jun 2016 08:30:12 +0000</pubDate>
      <dc:creator>leclerke</dc:creator>
      <guid isPermaLink="false">17183@/two/discussions</guid>
      <description><![CDATA[<p>On the internet I found the following sketch which works perfectly on processing 2.2.1 but not on 3.1.1. Why is that and how can I make it run?</p>

<pre><code>import java.awt.*;

Label textFieldLabel = new Label("Titel des Fensters: ");
TextField textField = new TextField("Ein Fenster", 16);

void setup(){
  size(800, 600);
  add(textFieldLabel);
  add(textField);
}

void draw(){
  frame.setTitle(textField.getText());
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to create an interface asking Username and correct password?..</title>
      <link>https://forum.processing.org/two/discussion/1724/how-to-create-an-interface-asking-username-and-correct-password</link>
      <pubDate>Sat, 30 Nov 2013 18:50:08 +0000</pubDate>
      <dc:creator>Alexis69</dc:creator>
      <guid isPermaLink="false">1724@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>Excuse me, I contact you because I start to use processing but I need your help.</p>

<p>In fact I have 2 tab, and I want to create a tab or something like that who is before these two other tabs where we have to enter an username and a password, if password ok, you « switch » on the other tab and you can do what you want, if the password is wrong, you can’t access once the password is not good.. :/</p>

<p>Is it possible to do something like that or not?</p>

<p>I see that someone do that</p>

<p>import java.awt.*;</p>

<p>import java.awt.event.*;</p>

<p>void setup(){
  size(600, 600);
 Label l1 = new Label("Enter Username"),</p>

<pre><code>l2 = new Label("Enter password");
</code></pre>

<p>TextField t1 = new TextField("",45),
    t2 = new TextField(20);</p>

<pre><code>t2.setEchoChar('*');
add(l1);
add(t1);
add(l2);
add(t2);
</code></pre>

<p>}</p>

<p>i don’t know if it can help you..</p>

<p>Sincerely,
Alexis.</p>
]]></description>
   </item>
   <item>
      <title>Save input text via GUI Builder in a way that i can use it with a Arduino</title>
      <link>https://forum.processing.org/two/discussion/13917/save-input-text-via-gui-builder-in-a-way-that-i-can-use-it-with-a-arduino</link>
      <pubDate>Sat, 12 Dec 2015 15:45:03 +0000</pubDate>
      <dc:creator>humi7</dc:creator>
      <guid isPermaLink="false">13917@/two/discussions</guid>
      <description><![CDATA[<p>I need your help! I'm sittin on a project for university. I have build a gui with the g4p guibuilder in processing. What i want, is that the text you enter in a textfield is saved somewhere in a way that you can use it via a arduino? How can i do that?</p>
]]></description>
   </item>
   <item>
      <title>G4P Library - I cant't retrive the textfield value.</title>
      <link>https://forum.processing.org/two/discussion/12785/g4p-library-i-cant-t-retrive-the-textfield-value</link>
      <pubDate>Fri, 02 Oct 2015 20:49:20 +0000</pubDate>
      <dc:creator>contax63</dc:creator>
      <guid isPermaLink="false">12785@/two/discussions</guid>
      <description><![CDATA[<p>Hi I'm using the G4P library for a GUI inteface that must show some data coming via serial .
I don't have problems to write value inside the texfield using data that are inside a byte[] using the below instructions:</p>

<p>String sonda_F1= str(char(inBuffer[42]))+str(char(inBuffer[44]))+str(char(inBuffer[46]))+str(char(inBuffer[48]));</p>

<p>textfield1.setPromptText(sonda_F1);   **</p>

<p>I've problems when I try to read what I wronte inside the textfield1 as follow :</p>

<p>String my_datatxt = textfield1.getText();</p>

<p>println("My data  :" my_datatxt);**</p>

<p>The output show just "My data  :"</p>

<p>I've used the same method with a lable and lable11.getText() has worked fine ,
Where I'm wrong ?? :(</p>

<p>And another thing... assuming that I'm able to read the content of textfield1 and I got a value like this "1234", how can I split these in for different character to be store inside 4 location of a byte[] ?</p>

<p>Thanks since now for any suggestion ! :D</p>
]]></description>
   </item>
   <item>
      <title>I downloaded 3.0 and now my Arduino PID Tuning FrontEnd sketch by Brett Beauregard does not work</title>
      <link>https://forum.processing.org/two/discussion/12355/i-downloaded-3-0-and-now-my-arduino-pid-tuning-frontend-sketch-by-brett-beauregard-does-not-work</link>
      <pubDate>Wed, 02 Sep 2015 00:56:16 +0000</pubDate>
      <dc:creator>SpinEwe</dc:creator>
      <guid isPermaLink="false">12355@/two/discussions</guid>
      <description><![CDATA[<p>/********************************************************
 * Arduino PID Tuning Front-End,  Version 0.3
 * by Brett Beauregard
 * License: Creative-Commons Attribution Share-Alike
 * April 2011
 *
 * This application is designed to interface with an
 * arduino running the PID Library.  From this Control
 * Panel you can observe &amp; adjust PID performance in 
 * real time
 *
 * The ControlP5 library is required to run this sketch.
 * files and install instructions can be found at
 * <a href="http://www.sojamo.de/libraries/controlP5/" target="_blank" rel="nofollow">http://www.sojamo.de/libraries/controlP5/</a>
 * 
 ********************************************************/
/**********************
* user\Documents\Processing\libraries\PID_FrontEnd_v03\PID_FrontEnd_v03\PID_FrontEnd_v03USER20
********/</p>

<p>import java.nio.ByteBuffer;
import processing.serial.*;
import controlP5.*;</p>

<p>/***********************************************
 * User specification section
 **********************************************/
int windowWidth = 900;      // set the size of the 
int windowHeight = 600;     // form</p>

<p>float InScaleMin = 0;       // set the Y-Axis Min
float InScaleMax = 1024;    // and Max for both
float OutScaleMin = 0;      // the top and 
float OutScaleMax = 255;    // bottom trends</p>

<p>int windowSpan = 300000;    // number of mS into the past you want to display
int refreshRate = 100;      // how often you want the graph to be reDrawn;</p>

<p>//float displayFactor = 1; //display Time as Milliseconds
//float displayFactor = 1000; //display Time as Seconds
float displayFactor = 60000; //display Time as Minutes</p>

<p>String outputFileName = "C:/A1Trash holder/ProcessorOutputFileFolder/USERProcOut.txt"; // if you'd like to output data to 
// a file, specify the path here</p>

<p>/***********************************************
 * end user spec
 **********************************************/</p>

<p>int nextRefresh;
int arrayLength = windowSpan / refreshRate+1;
int[] InputData = new int[arrayLength];     //we might not need them this big, but
int[] SetpointData = new int[arrayLength];  // this is worst case
int[] OutputData = new int[arrayLength];</p>

<p>float inputTop = 25;
float inputHeight = (windowHeight-70)<em>2/3;
float outputTop = inputHeight+50;
float outputHeight = (windowHeight-70)</em>1/3;</p>

<p>float ioLeft = 150, ioWidth = windowWidth-ioLeft-50;
float ioRight = ioLeft+ioWidth;
float pointWidth= (ioWidth)/float(arrayLength-1);</p>

<p>int vertCount = 10;</p>

<p>int nPoints = 0;</p>

<p>float Input, Setpoint, Output;</p>

<p>boolean madeContact =false;
boolean justSent = true;</p>

<p>Serial myPort;</p>

<p>//  USER adds a test to print the String
String inString; // Input string from serial port  USER added</p>

<p>ControlP5 controlP5;
controlP5.Button AMButton, DRButton;
controlP5.Textlabel AMLabel, AMCurrent, InLabel, 
OutLabel, SPLabel, PLabel, 
ILabel, DLabel,DRLabel, DRCurrent;
controlP5.Textfield SPField, InField, OutField, 
PField, IField, DField;</p>

<p>PrintWriter output;
PFont AxisFont, TitleFont;</p>

<p>void setup()
{
  frameRate(30);
  size(900, 600);</p>

<p>println(Serial.list());                                           // * Initialize Serial
  myPort = new Serial(this, Serial.list()[0], 9600); //USER changed 1 to 0for comport 3 
  //USER  Communication with arduino via comport this is because it is the first listed of the serial list and 1st one is number 0
  //
  myPort.bufferUntil(10);                                           //   the Arduino</p>

<p>controlP5 = new ControlP5(this);                                  // * Initialize the various
  SPField= controlP5.addTextfield("Setpoint",10,100,60,20);         //   Buttons, Labels, and
  InField = controlP5.addTextfield("Input",10,150,60,20);           //   Text Fields we'll be
  OutField = controlP5.addTextfield("Output",10,200,60,20);         //   using
  PField = controlP5.addTextfield("Kp (Proportional)",10,275,60,20);          //
  IField = controlP5.addTextfield("Ki (Integral)",10,325,60,20);          //
  DField = controlP5.addTextfield("Kd (Derivative)",10,375,60,20);          //
  AMButton = controlP5.addButton("Toggle_AM",0.0,10,50,60,20);      //
  AMLabel = controlP5.addTextlabel("AM","Manual",12,72);            //
  AMCurrent = controlP5.addTextlabel("AMCurrent","Manual",80,65);   //
  controlP5.addButton("Send_To_Arduino",0.0,10,475,120,20);         //
  SPLabel=controlP5.addTextlabel("SP","3",80,103);                  //
  InLabel=controlP5.addTextlabel("In","1",80,153);                  //
  OutLabel=controlP5.addTextlabel("Out","2",80,203);                //
  PLabel=controlP5.addTextlabel("P","4",80,278);                    //
  ILabel=controlP5.addTextlabel("I","5",80,328);                    //
  DLabel=controlP5.addTextlabel("D","6",80,378);                    //
  DRButton = controlP5.addButton("Toggle_DR",0.0,10,425,60,20);      //
  DRLabel = controlP5.addTextlabel("DR","Direct",12,447);            //
  DRCurrent = controlP5.addTextlabel("DRCurrent","Direct",80,440);   //</p>

<p>AxisFont = loadFont("axis.vlw");
  TitleFont = loadFont("Titles.vlw");</p>

<p>nextRefresh=millis();
  if (outputFileName!="") output = createWriter(outputFileName);
}</p>

<p>void draw()
{
  background(200);
  drawGraph();
  drawButtonArea();</p>

<p>}</p>

<p>void drawGraph()
{
  //draw Base, gridlines
  stroke(0);
  fill(230);
  rect(ioLeft, inputTop,ioWidth-1 , inputHeight);
  rect(ioLeft, outputTop, ioWidth-1, outputHeight);
  stroke(210);</p>

<p>//Section Titles
  textFont(TitleFont);
  fill(255);
  text("PID Input / Setpoint",(int)ioLeft+10,(int)inputTop-5);
  text("PID Output",(int)ioLeft+10,(int)outputTop-5);</p>

<p>//GridLines and Titles
  textFont(AxisFont);</p>

<p>//horizontal grid lines
  int interval = (int)inputHeight/5;
  for(int i=0;i&lt;6;i++)
  {
    if(i&gt;0&amp;&amp;i&lt;5) line(ioLeft+1,inputTop+i<em>interval,ioRight-2,inputTop+i</em>interval);
    text(str((InScaleMax-InScaleMin)/5<em>(float)(5-i)+InScaleMin),ioRight+5,inputTop+i</em>interval+4);</p>

<p>}
  interval = (int)outputHeight/5;
  for(int i=0;i&lt;6;i++)
  {
    if(i&gt;0&amp;&amp;i&lt;5) line(ioLeft+1,outputTop+i<em>interval,ioRight-2,outputTop+i</em>interval);
    text(str((OutScaleMax-OutScaleMin)/5<em>(float)(5-i)+OutScaleMin),ioRight+5,outputTop+i</em>interval+4);
  }</p>

<p>//vertical grid lines and TimeStamps
  int elapsedTime = millis();
  interval = (int)ioWidth/vertCount;
  int shift = elapsedTime*(int)ioWidth / windowSpan;
  shift %=interval;</p>

<p>int iTimeInterval = windowSpan/vertCount;
  float firstDisplay = (float)(iTimeInterval<em>(elapsedTime/iTimeInterval))/displayFactor;
  float timeInterval = (float)(iTimeInterval)/displayFactor;
  for(int i=0;i&lt;vertCount;i++)
  {
    int x = (int)ioRight-shift-2-i</em>interval;</p>

<pre><code>line(x,inputTop+1,x,inputTop+inputHeight-1);
line(x,outputTop+1,x,outputTop+outputHeight-1);    

float t = firstDisplay-(float)i*timeInterval;
if(t&gt;=0)  text(str(t),x,outputTop+outputHeight+10);
</code></pre>

<p>}</p>

<p>// add the latest data to the data Arrays.  the values need
  // to be massaged to get them to graph correctly.  they 
  // need to be scaled to fit where they're going, and 
  // because 0, 0 is the top left, we need to flip the values.
  // this is easier than having the user stand on their head
  // to read the graph.
  if(millis() &gt; nextRefresh &amp;&amp; madeContact)
  {
    nextRefresh += refreshRate;</p>

<pre><code>for(int i=nPoints-1;i&gt;0;i--)
{
  InputData[i]=InputData[i-1];
  SetpointData[i]=SetpointData[i-1];
  OutputData[i]=OutputData[i-1];
}
if (nPoints &lt; arrayLength) nPoints++;

InputData[0] = int(inputHeight)-int(inputHeight*(Input-InScaleMin)/(InScaleMax-InScaleMin));
SetpointData[0] =int( inputHeight)-int(inputHeight*(Setpoint-InScaleMin)/(InScaleMax-InScaleMin));
OutputData[0] = int(outputHeight)-int(outputHeight*(Output-OutScaleMin)/(OutScaleMax-OutScaleMin));
</code></pre>

<p>}
  //draw lines for the input, setpoint, and output
  strokeWeight(2);
  for(int i=0; i&lt;nPoints-2; i++)
  {
    int X1 = int(ioRight-2-float(i)<em>pointWidth);
    int X2 = int(ioRight-2-float(i+1)</em>pointWidth);
    boolean y1Above, y1Below, y2Above, y2Below;</p>

<pre><code>//DRAW THE INPUT
boolean drawLine=true;
stroke(255,0,0);
int Y1 = InputData[i];
int Y2 = InputData[i+1];

y1Above = (Y1&gt;inputHeight);                     // if both points are outside 
y1Below = (Y1&lt;0);                               // the min or max, don't draw the 
y2Above = (Y2&gt;inputHeight);                     // line.  if only one point is 
y2Below = (Y2&lt;0);                               // outside constrain it to the limit, 
if(y1Above)                                     // and leave the other one untouched.
{                                               //
  if(y2Above) drawLine=false;                   //
  else if(y2Below) {                            //
    Y1 = (int)inputHeight;                      //
    Y2 = 0;                                     //
  }                                             //
  else Y1 = (int)inputHeight;                   //
}                                               //
else if(y1Below)                                //
{                                               //
  if(y2Below) drawLine=false;                   //
  else if(y2Above) {                            //
    Y1 = 0;                                     //
    Y2 = (int)inputHeight;                      //
  }                                             //
  else Y1 = 0;                                  //
}                                               //
else                                            //
{                                               //
  if(y2Below) Y2 = 0;                           //
  else if(y2Above) Y2 = (int)inputHeight;       //
}                                               //

if(drawLine)
{
  line(X1,Y1+inputTop, X2, Y2+inputTop);
}

//DRAW THE SETPOINT
drawLine=true;
stroke(0,255,0);
Y1 = SetpointData[i];
Y2 = SetpointData[i+1];

y1Above = (Y1&gt;(int)inputHeight);                // if both points are outside 
y1Below = (Y1&lt;0);                               // the min or max, don't draw the 
y2Above = (Y2&gt;(int)inputHeight);                // line.  if only one point is 
y2Below = (Y2&lt;0);                               // outside constrain it to the limit, 
if(y1Above)                                     // and leave the other one untouched.
{                                               //
  if(y2Above) drawLine=false;                   //
  else if(y2Below) {                            //
    Y1 = (int)(inputHeight);                    //
    Y2 = 0;                                     //
  }                                             //
  else Y1 = (int)(inputHeight);                 //
}                                               //
else if(y1Below)                                //
{                                               //
  if(y2Below) drawLine=false;                   //
  else if(y2Above) {                            //
    Y1 = 0;                                     //
    Y2 = (int)(inputHeight);                    //
  }                                             //
  else Y1 = 0;                                  //
}                                               //
else                                            //
{                                               //
  if(y2Below) Y2 = 0;                           //
  else if(y2Above) Y2 = (int)(inputHeight);     //
}                                               //

if(drawLine)
{
  line(X1, Y1+inputTop, X2, Y2+inputTop);
}

//DRAW THE OUTPUT
drawLine=true;
stroke(0,0,255);
Y1 = OutputData[i];
Y2 = OutputData[i+1];

y1Above = (Y1&gt;outputHeight);                   // if both points are outside 
y1Below = (Y1&lt;0);                              // the min or max, don't draw the 
y2Above = (Y2&gt;outputHeight);                   // line.  if only one point is 
y2Below = (Y2&lt;0);                              // outside constrain it to the limit, 
if(y1Above)                                    // and leave the other one untouched.
{                                              //
  if(y2Above) drawLine=false;                  //
  else if(y2Below) {                           //
    Y1 = (int)outputHeight;                    //
    Y2 = 0;                                    //
  }                                            //
  else Y1 = (int)outputHeight;                 //
}                                              //
else if(y1Below)                               //
{                                              //
  if(y2Below) drawLine=false;                  //
  else if(y2Above) {                           //
    Y1 = 0;                                    //
    Y2 = (int)outputHeight;                    //
  }                                            //  
  else Y1 = 0;                                 //
}                                              //
else                                           //
{                                              //
  if(y2Below) Y2 = 0;                          //
  else if(y2Above) Y2 = (int)outputHeight;     //
}                                              //

if(drawLine)
{
  line(X1, outputTop + Y1, X2, outputTop + Y2);
}
</code></pre>

<p>}
  strokeWeight(1);
}</p>

<p>void drawButtonArea()
{
  stroke(0);
  fill(100);
  rect(0, 0, ioLeft, windowHeight);
}</p>

<p>void Toggle_AM() {
  if(AMLabel.valueLabel().getText()=="Manual") 
  {
    AMLabel.setValue("Automatic");
  }
  else
  {
    AMLabel.setValue("Manual");<br />
  }
}</p>

<p>void Toggle_DR() {
  if(DRLabel.valueLabel().getText()=="Direct") 
  {
    DRLabel.setValue("Reverse");
  }
  else
  {
    DRLabel.setValue("Direct");<br />
  }
}</p>

<p>// Sending Floating point values to the arduino
// is a huge pain.  if anyone knows an easier
// way please let know.  the way I'm doing it:
// - Take the 6 floats we need to send and
//   put them in a 6 member float array.
// - using the java ByteBuffer class, convert
//   that array to a 24 member byte array
// - send those bytes to the arduino
void Send_To_Arduino()
{
  float[] toSend = new float[6];</p>

<p>toSend[0] = float(SPField.getText());
  toSend[1] = float(InField.getText());
  toSend[2] = float(OutField.getText());
  toSend[3] = float(PField.getText());
  toSend[4] = float(IField.getText());
  toSend[5] = float(DField.getText());
  Byte a = (AMLabel.valueLabel().getText()=="Manual")?(byte)0:(byte)1;
  Byte d = (DRLabel.valueLabel().getText()=="Direct")?(byte)0:(byte)1;
  myPort.write(a);
  myPort.write(d);
  myPort.write(floatArrayToByteArray(toSend));
  justSent=true;
}</p>

<p>byte[] floatArrayToByteArray(float[] input)
{
  int len = 4<em>input.length;
  int index=0;
  byte[] b = new byte[4];
  byte[] out = new byte[len];
  ByteBuffer buf = ByteBuffer.wrap(b);
  for(int i=0;i&lt;input.length;i++) 
  {
    buf.position(0);
    buf.putFloat(input[i]);
    for(int j=0;j&lt;4;j++) out[j+i</em>4]=b[3-j];
  }
  return out;
}</p>

<p>//take the string the arduino sends us and parse it
void serialEvent(Serial myPort)
{
// String read = myPort.readStringUntil(10);
   String read = myPort.readStringUntil(10); //USER changed from 10 to 
//  inString = myPort.readString();  //USER added this //try the next one
  String inString = myPort.readStringUntil(10);  //USER added this 
  if(outputFileName!="") output.print(str(millis())+ " "+read);
  String[] s = split(read, " ");</p>

<p>if (s.length ==9)
  {
    Setpoint = float(s[1]);           // * pull the information
    println("setpoint:",Setpoint);      //TBGFE
    Input = float(s[2]);              //   we need out of the
    println("Inpute:", Input);         //TGBFE
    Output = float(s[3]);             //   string and put it
    println("Output: ",Output);        //TGBFE</p>

<p>//USER adds test print
     text(" text received: " + inString, 10,50); //USER added this 
  println ("println read received: " ,read);  //USER added to see what is in string<br />
  println ("println inString received: " ,inString);  //USER added to see what is in string
    SPLabel.setValue(s[1]);           //   where it's needed
    InLabel.setValue(s[2]);           //
    OutLabel.setValue(trim(s[3]));    //
    PLabel.setValue(trim(s[4]));      //
    ILabel.setValue(trim(s[5]));      //
    DLabel.setValue(trim(s[6]));      //
    AMCurrent.setValue(trim(s[7]));   //
    DRCurrent.setValue(trim(s[8]));
    if(justSent)                      // * if this is the first read
    {                                 //   since we sent values to 
      SPField.setText(trim(s[1]));    //   the arduino,  take the
      InField.setText(trim(s[2]));    //   current values and put
      OutField.setText(trim(s[3]));   //   them into the input fields
      PField.setText(trim(s[4]));     //
      IField.setText(trim(s[5]));     //
      DField.setText(trim(s[6]));     //
     // mode = trim(s[7]);              //
      AMLabel.setValue(trim(s[7]));         //
      //dr = trim(s[8]);                //
      DRCurrent.setValue(trim(s[8]));         //
      justSent=false;                 //
    }                                 //</p>

<pre><code>if(!madeContact) madeContact=true;
</code></pre>

<p>}
}</p>
]]></description>
   </item>
   <item>
      <title>Is it possible to create a user login using processing?</title>
      <link>https://forum.processing.org/two/discussion/6556/is-it-possible-to-create-a-user-login-using-processing</link>
      <pubDate>Thu, 31 Jul 2014 08:39:33 +0000</pubDate>
      <dc:creator>imstephenr</dc:creator>
      <guid isPermaLink="false">6556@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys! I'm just wondering if is it possible to create a "User login type" interface using processing IDE, the inputted username and password is fetched from a Database table "Users", and once the username and password is correct, the user will be automatically directed to a "member page/interface", if so, can you show me a sample code? Thanks guys!</p>
]]></description>
   </item>
   </channel>
</rss>