diff --git a/src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java b/src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java index aad95e13c6521339f543ecfe44b13b2fc2e9baf4..bed06a469898b19b4614ca9e694ed9a79adcbe3d 100644 --- a/src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java +++ b/src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java @@ -440,8 +440,8 @@ public class GenericGcodeDriver extends LaserCutter { } } } - private double currentPower = -1; - private double currentSpeed = -1; + protected double currentPower = -1; + protected double currentSpeed = -1; private double nextPower = -1; private double nextSpeed = -1; private double currentFocus = 0; diff --git a/src/com/t_oster/liblasercut/drivers/Grbl.java b/src/com/t_oster/liblasercut/drivers/Grbl.java index 51d779128510a0c7a87998e90bba3835b0845984..efcb63deada718b9a512236e1203606ebe5b78e5 100644 --- a/src/com/t_oster/liblasercut/drivers/Grbl.java +++ b/src/com/t_oster/liblasercut/drivers/Grbl.java @@ -160,6 +160,55 @@ public class Grbl extends GenericGcodeDriver return null; } + + /** + * Send a G0 rapid move to Grbl. + * Doesn't include travel speed since grbl ignores that anyway. + * + * @param out + * @param x + * @param y + * @param resolution + * @throws IOException + */ + @Override + protected void move(PrintStream out, double x, double y, double resolution) throws IOException { + x = isFlipXaxis() ? getBedWidth() - Util.px2mm(x, resolution) : Util.px2mm(x, resolution); + y = isFlipYaxis() ? getBedHeight() - Util.px2mm(y, resolution) : Util.px2mm(y, resolution); + currentSpeed = getTravel_speed(); + if (blankLaserDuringRapids) + { + currentPower = 0.0; + sendLine("G0 X%f Y%f S0", x, y); + } + else + { + sendLine("G0 X%f Y%f", x, y); + } + } + + /** + * Send a line of gcode to the cutter, stripping out any whitespace in the process + * @param text + * @param parameters + * @throws IOException + */ + @Override + protected void sendLine(String text, Object... parameters) throws IOException + { + out.format(FORMAT_LOCALE, text.replace(" ", "")+LINEEND(), parameters); + //TODO: Remove + System.out.println(String.format(FORMAT_LOCALE, "> "+text+LINEEND(), parameters)); + out.flush(); + if (isWaitForOKafterEachLine()) + { + String line = waitForLine(); + if (!"ok".equals(line)) + { + throw new IOException("Lasercutter did not respond 'ok', but '"+line+"'instead."); + } + } + } @Override public Grbl clone()