diff --git a/README b/README
index 4f38fb2..15ff104 100644
--- a/README
+++ b/README
@@ -2,3 +2,4 @@ gctrl: a simple GUI for grbl
A simple Processing sketch that acts as an
interface to grbl .
+Download latest Processing from https://github.com/processing/processing4
diff --git a/gctrl.pde b/gctrl.pde
index 4c1730b..91884fc 100644
--- a/gctrl.pde
+++ b/gctrl.pde
@@ -1,9 +1,9 @@
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
import processing.serial.*;
-
+import javax.swing.JFrame;
Serial port = null;
-
+// PImage img;
// select and modify the appropriate line for your operating system
// leave as null to use interactive port (press 'p' in the program)
String portname = null;
@@ -12,7 +12,7 @@ String portname = null;
//String portname = "COM6"; // Windows
boolean streaming = false;
-float speed = 0.001;
+float speed = 0.1;
String[] gcode;
int i = 0;
@@ -28,7 +28,8 @@ void openSerialPort()
void selectSerialPort()
{
- String result = (String) JOptionPane.showInputDialog(this,
+ JFrame frame = new JFrame();
+ String result = (String) JOptionPane.showInputDialog(frame,
"Select the serial port that corresponds to your Arduino board.",
"Select serial port",
JOptionPane.PLAIN_MESSAGE,
@@ -44,7 +45,9 @@ void selectSerialPort()
void setup()
{
- size(500, 250);
+ size(500, 350);
+ openSerialPort();
+ //img = loadImage("myImage.png"); // <-- Make sure your image is in the data folder!
openSerialPort();
}
@@ -52,29 +55,37 @@ void draw()
{
background(0);
fill(255);
- int y = 24, dy = 12;
- text("INSTRUCTIONS", 12, y); y += dy;
- text("p: select serial port", 12, y); y += dy;
- text("1: set speed to 0.001 inches (1 mil) per jog", 12, y); y += dy;
- text("2: set speed to 0.010 inches (10 mil) per jog", 12, y); y += dy;
- text("3: set speed to 0.100 inches (100 mil) per jog", 12, y); y += dy;
- text("arrow keys: jog in x-y plane", 12, y); y += dy;
- text("page up & page down: jog in z axis", 12, y); y += dy;
- text("$: display grbl settings", 12, y); y+= dy;
- text("h: go home", 12, y); y += dy;
- text("0: zero machine (set home to the current location)", 12, y); y += dy;
- text("g: stream a g-code file", 12, y); y += dy;
- text("x: stop streaming g-code (this is NOT immediate)", 12, y); y += dy;
+ textSize(16);
+ int y = 24, dy = 18;
+ text("INSTRUCTIONS", 22, y); y += dy;
+
+ text("p: select serial port", 18, y); y += dy;
+ text("Press 1,2 or 3 to set jog amount ", 22, y); y += dy;
+ text("1: set speed to 1 mm per step (1,0 mm) per jog", 18, y); y += dy;
+ text("2: set speed to 2.5 mm per step (2,5 mil) per jog", 18, y); y += dy;
+ text("3: set speed to 5.0 mm per step (5 mm) per jog", 18, y); y += dy;
+ text("arrow keys: jog in x-y plane", 18, y); y += dy;
+ text("page up & page down: jog in z axis", 18, y); y += dy;
+ text("$: display grbl settings", 18, y); y+= dy;
+ text("h: go home", 18, y); y += dy;
+ text("0: zero machine (set home to the current location)", 18, y); y += dy;
+ text("f: stream a g-code file", 18, y); y += dy;
+ text("x: stop streaming g-code (this is NOT immediate)", 18, y); y += dy;
y = height - dy;
- text("current jog speed: " + speed + " inches per step", 12, y); y -= dy;
- text("current serial port: " + portname, 12, y); y -= dy;
+ text("current jog speed: " + speed + " mm per step", 18, y); y -= dy;
+ text("current serial port: " + portname, 18, y); y -= dy;
+
+ // Draw the image on the right side
+ //int imgX = width - img.width - 20; // 20 pixels padding from right edge
+ //int imgY = 20; // 20 pixels from top
+ //image(img, imgX, imgY);
}
void keyPressed()
{
- if (key == '1') speed = 0.001;
- if (key == '2') speed = 0.01;
- if (key == '3') speed = 0.1;
+ if (key == '1') speed = 1.0;
+ if (key == '2') speed = 2.5;
+ if (key == '3') speed = 5.0;
if (!streaming) {
if (keyCode == LEFT) port.write("G91\nG20\nG00 X-" + speed + " Y0.000 Z0.000\n");
@@ -143,4 +154,3 @@ void serialEvent(Serial p)
if (s.trim().startsWith("ok")) stream();
if (s.trim().startsWith("error")) stream(); // XXX: really?
}
-