SouravDas25_Autonomous-Robotic-Arm/bot/master/gui.pde
/* =========================================================
 * ====                   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:
 
 * Do not rename this tab!
 * =========================================================
 */
 
 public int lastSendTIme = millis(),delaytime = 500;

public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:672557:
  fetchCoords();
  lastSendTIme = millis();
} //_CODE_:button1:672557:

public void textfield1_change1(GTextField source, GEvent event) { //_CODE_:coordinate_y:544971:
  if(event == GEvent.ENTERED )
  {
    fetchCoords();
    lastSendTIme = millis();
  }
} //_CODE_:coordinate_y:544971:

public void textfield2_change1(GTextField source, GEvent event) { //_CODE_:coordinate_z:487741:
  if(event == GEvent.ENTERED)
  {
    fetchCoords();
    lastSendTIme = millis();
  }
} //_CODE_:coordinate_z:487741:

public void textfield1_change2(GTextField source, GEvent event) { //_CODE_:coordinate_x:985419:
  if(event == GEvent.ENTERED)
  {
    fetchCoords();
    lastSendTIme = millis();
  }
} //_CODE_:coordinate_x:985419:

public void slider1_change1(GSlider source, GEvent event) { //_CODE_:slider1:567167:
  if(event == GEvent.VALUE_STEADY && millis() - lastSendTIme > delaytime)
  {
    fetchAngle(0,source);
    lastSendTIme = millis();
  }
} //_CODE_:slider1:567167:

public void slider2_change1(GSlider source, GEvent event) { //_CODE_:slider2:555423:
  if(event == GEvent.VALUE_STEADY && millis() - lastSendTIme > delaytime)
  {
    fetchGripper(source);
    lastSendTIme = millis();
  }
} //_CODE_:slider2:555423:

public void slider3_change1(GSlider source, GEvent event) { //_CODE_:slider3:356107:
  if(event == GEvent.VALUE_STEADY && millis() - lastSendTIme > delaytime)
  {
    fetchAngle(2,source);
    lastSendTIme = millis();
  }
} //_CODE_:slider3:356107:

public void slider4_change1(GSlider source, GEvent event) { //_CODE_:slider4:969934:
  if(event == GEvent.VALUE_STEADY && millis() - lastSendTIme > delaytime)
  {
    fetchAngle(1,source);
    lastSendTIme = millis();
  }
} //_CODE_:slider4:969934:

public void button2_click1(GButton source, GEvent event) { //_CODE_:button2:429200:
  move();
} //_CODE_:button2:429200:

synchronized public void win_draw1(PApplet appc, GWinData data) { //_CODE_:window1:887982:
  appc.background(230);
  loopIP(appc);
} //_CODE_:window1:887982:

public void button3_click1(GButton source, GEvent event) { //_CODE_:button3:384003:
  //println("button3 - GButton >> GEvent." + event + " @ " + millis());
  saveImage();
} //_CODE_:button3:384003:



// 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(" Robotic ARM");
  button1 = new GButton(this, 11, 335, 135, 58);
  button1.setText("GO !!");
  button1.setTextBold();
  button1.addEventHandler(this, "button1_click1");
  coordinate_y = new GTextField(this, 90, 301, 79, 29, G4P.SCROLLBARS_NONE);
  coordinate_y.setPromptText("Y");
  coordinate_y.setOpaque(true);
  coordinate_y.addEventHandler(this, "textfield1_change1");
  coordinate_z = new GTextField(this, 176, 300, 76, 30, G4P.SCROLLBARS_NONE);
  coordinate_z.setPromptText("Z");
  coordinate_z.setOpaque(true);
  coordinate_z.addEventHandler(this, "textfield2_change1");
  coordinate_x = new GTextField(this, 12, 301, 73, 30, G4P.SCROLLBARS_NONE);
  coordinate_x.setPromptText("X");
  coordinate_x.setOpaque(true);
  coordinate_x.addEventHandler(this, "textfield1_change2");
  slider1 = new GSlider(this, 395, 195, 243, 45, 10.0);
  slider1.setShowValue(true);
  slider1.setShowLimits(true);
  slider1.setLimits(90, 0, 180);
  slider1.setNumberFormat(G4P.INTEGER, 0);
  slider1.setOpaque(false);
  slider1.addEventHandler(this, "slider1_change1");
  slider2 = new GSlider(this, 393, 347, 245, 43, 10.0);
  slider2.setShowValue(true);
  slider2.setShowLimits(true);
  slider2.setLimits(0.0, 0.0, 180.0);
  slider2.setNumberFormat(G4P.DECIMAL, 2);
  slider2.setOpaque(false);
  slider2.addEventHandler(this, "slider2_change1");
  slider3 = new GSlider(this, 394, 298, 243, 44, 10.0);
  slider3.setShowValue(true);
  slider3.setShowLimits(true);
  slider3.setLimits(90.0, 0.0, 180.0);
  slider3.setNumberFormat(G4P.DECIMAL, 2);
  slider3.setOpaque(false);
  slider3.addEventHandler(this, "slider3_change1");
  slider4 = new GSlider(this, 394, 247, 243, 45, 10.0);
  slider4.setShowValue(true);
  slider4.setShowLimits(true);
  slider4.setLimits(90.0, 0.0, 180.0);
  slider4.setNumberFormat(G4P.DECIMAL, 2);
  slider4.setOpaque(false);
  slider4.addEventHandler(this, "slider4_change1");
  button2 = new GButton(this, 130, 111, 80, 30);
  button2.setText("Move");
  button2.addEventHandler(this, "button2_click1");
  window1 = GWindow.getWindow(this, "Window title", 0, 0, 1080, 720, JAVA2D);
  window1.noLoop();
  window1.setActionOnClose(G4P.CLOSE_WINDOW);
  window1.addDrawHandler(this, "win_draw1");
  button3 = new GButton(window1, 12, 669, 80, 30);
  button3.setText("Save");
  button3.setTextBold();
  button3.addEventHandler(this, "button3_click1");
  window1.loop();
}

// Variable declarations 
// autogenerated do not edit
GButton button1; 
GTextField coordinate_y; 
GTextField coordinate_z; 
GTextField coordinate_x; 
GSlider slider1; 
GSlider slider2; 
GSlider slider3; 
GSlider slider4; 
GButton button2; 
GWindow window1;
GButton button3; 
