We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am using ControlP5 GUI library text fields to make a GUI compatible with Arduino. The gui works fine for now but if I need to a new value in the textfield, I have to press "enter" key after typing in the new value. It is getting quite irritating since the gui shows the new value but does not gets transmitted through serial on the backend.
Here is the code I am using to process the textfields:
Textfield paperLengthTextField = jControl.addTextfield("Desired Paper Length (inches):")
.setPosition(280, 180)
.setSize(200, 40)
.setText("1")
.setFont(font)
.setAutoClear(false);
and using this function to send the new entered data to the arduino through serial:
public void controlEvent(ControlEvent theEvent) {
String msg = theEvent.getController().getName();
switch(msg) {
case "Desired Paper Length (inches):":
println("Desired Paper Length: " + theEvent.getStringValue());
myPort.write('i' + theEvent.getStringValue());
break;
case "Number of Pages to Cut:":
println("Number of Pieces to Cut: " + theEvent.getStringValue());
myPort.write('c' + theEvent.getStringValue());
break;
}
}