summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwizard23 <wizard23>2008-06-23 21:32:32 +0000
committerwizard23 <wizard23@cb376a5e-1013-0410-a455-b6b1f9ac8223>2008-06-23 21:32:32 +0000
commit9aa3cd255dc4a786a96f516a1de62009b19108b0 (patch)
tree4180720b8119d6b8a5f5860ebb6ea96b80c7631a
parent3d16fe6f89b73d8f95960725caed2d7936dbd2c1 (diff)
downloadreprap-9aa3cd255dc4a786a96f516a1de62009b19108b0.tar.gz
reprap-9aa3cd255dc4a786a96f516a1de62009b19108b0.zip
Processing tool for positioning the XYZ axis for the GCode firmware
git-svn-id: https://reprap.svn.sourceforge.net/svnroot/reprap@1653 cb376a5e-1013-0410-a455-b6b1f9ac8223
-rw-r--r--trunk/users/wizard23/processing/GCode_Exerciser/GCode_Exerciser.pde154
1 files changed, 154 insertions, 0 deletions
diff --git a/trunk/users/wizard23/processing/GCode_Exerciser/GCode_Exerciser.pde b/trunk/users/wizard23/processing/GCode_Exerciser/GCode_Exerciser.pde
new file mode 100644
index 00000000..ea02dfe3
--- /dev/null
+++ b/trunk/users/wizard23/processing/GCode_Exerciser/GCode_Exerciser.pde
@@ -0,0 +1,154 @@
+import processing.serial.*;
+
+
+// The serial port
+Serial myPort;
+String serialLine = "";
+
+boolean initialized = false;
+boolean started = false;
+boolean finished = false;
+boolean commandComplete = true;
+int commandCount = 0;
+
+String temperature = "?";
+
+String gcode[] = {
+};
+int gcodeIndex = 0;
+
+void setup()
+{
+ //init stuff
+ size(1024, 600);
+ //smooth();
+
+ // List all the available serial ports
+ println(Serial.list());
+ //open the first port...
+ myPort = new Serial(this, Serial.list()[0], 19200);
+
+ //load our gcode lines
+ gcode = loadStrings("/home/wizard23/projects/reprap/downloads/gcodestuff/cooled_rings.gcode");
+ //println(gcode);
+}
+
+void draw()
+{
+ String cmd;
+
+ background(20, 20, 20);
+
+ while (myPort.available() > 0)
+ {
+ int inByte = myPort.read();
+
+ if (inByte == '\n')
+ {
+ println("Got: " + serialLine);
+
+ String m[] = match(serialLine, "^T:([0-9]+)");
+ ;
+ if (m != null)
+ temperature = m[0];
+
+ if (match(serialLine, "^start") != null)
+ started = true;
+
+ if (match(serialLine, "^ok") != null)
+ {
+ commandComplete = true;
+
+ if (gcodeIndex == gcode.length)
+ println("Job's done!");
+ }
+
+ serialLine = "";
+ }
+ else if (inByte > 0)
+ {
+ serialLine += (char)inByte;
+ }
+ }
+
+ if (started)
+ {
+ if (commandComplete)
+ {
+
+
+ if (!initialized)
+ {
+ initialized = true;
+ cmd = "G91";
+ }
+ else
+ {
+ cmd = getNextCommand();
+ }
+ if (cmd != null)
+ {
+ commandComplete = false;
+ println("Sent: " +cmd);
+ myPort.write(cmd);
+ }
+ }
+ }
+
+ if (started && finished)
+ {
+ println("Job's done!");
+ started = false;
+ finished = false;
+ }
+
+ PFont font;
+ font = loadFont("ArialMT-48.vlw");
+ textFont(font, 16);
+ String temp = "Temperature: " + temperature + "C";
+ text(temp, 10, 20);
+}
+
+String getNextCommand()
+{
+ if (keyPressed)
+ {
+ String c = null;
+
+ if (key == 'a')
+ {
+ c = "G1 X10 Y0 Z0 F200";
+ }
+ if (key == 'd')
+ {
+ c = "G1 X-10 Y0 Z0 F200";
+ }
+ if (key == 'w')
+ {
+ c = "G1 X0 Y10 Z0 F200";
+ }
+ if (key == 's')
+ {
+ c = "G1 X0 Y-10 Z0 F200";
+ }
+
+ // Z axsis
+ if (key == 'q' || kez == 'Q')
+ {
+ c = "G1 X0 Y0 Z10 F200";
+ }
+
+ if (key == 'z')
+ {
+ c = "G1 X0 Y0 Z-2 F100";
+ }
+ if (key == 'Z')
+ {
+ c = "G1 X0 Y0 Z-0.2 F100";
+ }
+
+ return c;
+ }
+ else
+ return null;
+}