G4P -- Simulating button click through two-way serial communication
in
Contributed Library Questions
•
2 months ago
Hey folks,
I am trying to simulate a button click after either a certain amount of time without me having to manually click the button, or once my Arduino sends back serial data.
Here's my code!
- import g4p_controls.*; //GUI Library
import processing.serial.*; //Serial Library
PImage img; //TCAP Image - boolean onbutton1 = false; //button starts as OFF
- Serial myPort; //New serial
public void setup(){
size(996, 679, JAVA2D);
createGUI();
customGUI();
img = loadImage("Background.JPG"); // image
myPort = new Serial(this, Serial.list()[1], 9600);
}- public void draw(){
background(img); - if(millis()>30000) //WHERE I'M HAVING DIFFICULTY!
- { // I want to have the button actuate without clicking
- onbutton1_click1(1,444045); // after 30 seconds using the code from the GUI tab below
- }
}
// Use this method to add additional statements
// to customise the GUI controls
public void customGUI(){- }
In GUI Tab:
-
public void button1_click1(GImageButton source, GEvent event) { //_CODE_:valve1:444045:// got something to do with what I want!
println("imgButton2 - GImageButton event occured " + System.currentTimeMillis()%10000000 );
onbutton1=!onbutton1;
myPort.write(17);
} //_CODE_:valve1:444045: //<------ I'm using this code because I believe it's
My problem isn't on the Arduino side, but here in Processing. When I try the above, I get an error:
"The method button1_click1(GImageButton, GEvent) in "MyProject" is not applicable for the arguments (int, int)"
Any ideas on what I'm doing wrong?
Thanks a lot for the help!
1