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?
Answers
I can't help with the arduino side but you can get the text from a textfiled with
String mytext = textfield.getText();
then convert that to a byte array with
byte myByteArray = myText.getBytes();
There must be ways to transfer bytes to the arduino device.
thank you. whre do i have to write these code? sorry, i am a newbie. here is my code:
PImage img; // Need G4P library import g4p_controls.*;
public void setup() { size(870, 550, JAVA2D); createGUI(); customGUI(); // Place your setup code here img = loadImage("background.jpg"); }
public void draw() { image(img, 0, 0, 870, 550); //background(230); }
// Use this method to add additional statements // to customise the GUI controls public void customGUI() { }
and this:
/* ========================================================= * ==== WARNING === * ========================================================= * The code in this tab has been generated from the GUI form * designer and care should be taken when editing this file. * Only add/edit code inside the event handlers i.e. only * use lines between the matching comment tags. e.g.
void myBtnEvents(GButton button) { //CODE:button1:12356: // It is safe to enter your event code here
} //CODE:button1:12356:
public void textfield1_change1(GTextField source, GEvent event) { //CODE:montag:727121: println("textfield1 - GTextField >> GEvent." + event + " @ " + millis()); } //CODE:montag:727121:
public void textfield2_change1(GTextField source, GEvent event) { //CODE:dienstag:280324: println("textfield2 - GTextField >> GEvent." + event + " @ " + millis()); } //CODE:dienstag:280324:
public void textfield3_change1(GTextField source, GEvent event) { //CODE:mittwoch:328203: println("textfield3 - GTextField >> GEvent." + event + " @ " + millis()); } //CODE:mittwoch:328203:
public void textfield4_change1(GTextField source, GEvent event) { //CODE:donnerstag:646605: println("textfield4 - GTextField >> GEvent." + event + " @ " + millis()); } //CODE:donnerstag:646605:
public void textfield5_change1(GTextField source, GEvent event) { //CODE:freitag:458648: println("textfield5 - GTextField >> GEvent." + event + " @ " + millis()); } //CODE:freitag:458648:
public void textfield6_change1(GTextField source, GEvent event) { //CODE:samstag:977639: println("textfield6 - GTextField >> GEvent." + event + " @ " + millis()); } //CODE:samstag:977639:
public void textfield7_change1(GTextField source, GEvent event) { //CODE:sonntag:813671: println("textfield7 - GTextField >> GEvent." + event + " @ " + millis()); } //CODE:sonntag:813671:
public void button1_click1(GButton source, GEvent event) { //CODE:button1:837357: println("button1 - GButton >> GEvent." + event + " @ " + millis()); } //CODE:button1:837357:
public void button2_click1(GButton source, GEvent event) { //CODE:button2:402901: println("button2 - GButton >> GEvent." + event + " @ " + millis()); } //CODE:button2:402901:
// Create all the GUI controls. // autogenerated do not edit public void createGUI(){ G4P.messagesEnabled(false); G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME); G4P.setCursor(ARROW); surface.setTitle("Sketch Window"); montag = new GTextField(this, 32, 278, 64, 19, G4P.SCROLLBARS_NONE); montag.setOpaque(false); montag.addEventHandler(this, "textfield1_change1"); dienstag = new GTextField(this, 155, 278, 64, 19, G4P.SCROLLBARS_NONE); dienstag.setOpaque(false); dienstag.addEventHandler(this, "textfield2_change1"); mittwoch = new GTextField(this, 278, 278, 64, 19, G4P.SCROLLBARS_NONE); mittwoch.setOpaque(false); mittwoch.addEventHandler(this, "textfield3_change1"); donnerstag = new GTextField(this, 401, 278, 64, 19, G4P.SCROLLBARS_NONE); donnerstag.setOpaque(false); donnerstag.addEventHandler(this, "textfield4_change1"); freitag = new GTextField(this, 524, 278, 64, 19, G4P.SCROLLBARS_NONE); freitag.setOpaque(false); freitag.addEventHandler(this, "textfield5_change1"); samstag = new GTextField(this, 647, 278, 64, 19, G4P.SCROLLBARS_NONE); samstag.setOpaque(false); samstag.addEventHandler(this, "textfield6_change1"); sonntag = new GTextField(this, 770, 278, 64, 19, G4P.SCROLLBARS_NONE); sonntag.setOpaque(false); sonntag.addEventHandler(this, "textfield7_change1"); button1 = new GButton(this, 500, 400, 130, 70); button1.setIcon("buttonok.jpg", 1, GAlign.CENTER, GAlign.MIDDLE); button1.setLocalColorScheme(GCScheme.CYAN_SCHEME); button1.addEventHandler(this, "button1_click1"); button2 = new GButton(this, 200, 400, 130, 70); button2.setIcon("buttonabbruch.jpg", 1, GAlign.RIGHT, GAlign.MIDDLE); button2.setLocalColorScheme(GCScheme.CYAN_SCHEME); button2.addEventHandler(this, "button2_click1"); }
// Variable declarations // autogenerated do not edit GTextField montag; GTextField dienstag; GTextField mittwoch; GTextField donnerstag; GTextField freitag; GTextField samstag; GTextField sonntag; GButton button1; GButton button2;
Please format your code for this forum. To find out how click on Discussion and pick the format code and text discussion