Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ gctrl: a simple GUI for grbl

A simple Processing <http://processing.org/> sketch that acts as an
interface to grbl <http://dank.bengler.no/-/page/show/5470_grbl>.
Download latest Processing from https://github.com/processing/processing4
58 changes: 34 additions & 24 deletions gctrl.pde
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -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,
Expand All @@ -44,37 +45,47 @@ 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();
}

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");
Expand Down Expand Up @@ -143,4 +154,3 @@ void serialEvent(Serial p)
if (s.trim().startsWith("ok")) stream();
if (s.trim().startsWith("error")) stream(); // XXX: really?
}