Skip to content
Snippets Groups Projects
Commit 99a72b90 authored by Thomas Oster's avatar Thomas Oster
Browse files

Add possibility to invert X/Y axis

parent a7121b7f
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,8 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -50,6 +50,8 @@ public class GenericGcodeDriver extends LaserCutter {
protected static final String SETTING_BAUDRATE = "Baud Rate (Serial)"; protected static final String SETTING_BAUDRATE = "Baud Rate (Serial)";
protected static final String SETTING_BEDWIDTH = "Laserbed width"; protected static final String SETTING_BEDWIDTH = "Laserbed width";
protected static final String SETTING_BEDHEIGHT = "Laserbed height"; protected static final String SETTING_BEDHEIGHT = "Laserbed height";
protected static final String SETTING_FLIP_X = "Flip X Axis";
protected static final String SETTING_FLIP_Y = "Flip Y Axis";
protected static final String SETTING_HTTP_UPLOAD_URL = "HTTP Upload URL"; protected static final String SETTING_HTTP_UPLOAD_URL = "HTTP Upload URL";
protected static final String SETTING_LINEEND = "Lineend (CR,LF,CRLF)"; protected static final String SETTING_LINEEND = "Lineend (CR,LF,CRLF)";
protected static final String SETTING_MAX_SPEED = "Max speed (in mm/min)"; protected static final String SETTING_MAX_SPEED = "Max speed (in mm/min)";
...@@ -95,6 +97,30 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -95,6 +97,30 @@ public class GenericGcodeDriver extends LaserCutter {
this.baudRate = baudRate; this.baudRate = baudRate;
} }
protected boolean flipXaxis = false;
public boolean isFlipXaxis()
{
return flipXaxis;
}
public void setFlipXaxis(boolean flipXaxis)
{
this.flipXaxis = flipXaxis;
}
protected boolean flipYaxis = false;
public boolean isFlipYaxis()
{
return flipYaxis;
}
public void setFlipYaxis(boolean flipYaxis)
{
this.flipYaxis = flipYaxis;
}
protected String httpUploadUrl = "http://10.10.10.100/upload"; protected String httpUploadUrl = "http://10.10.10.100/upload";
public String getHttpUploadUrl() public String getHttpUploadUrl()
...@@ -317,12 +343,16 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -317,12 +343,16 @@ public class GenericGcodeDriver extends LaserCutter {
} }
} }
protected void move(PrintStream out, int x, int y, double resolution) throws IOException { 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(); currentSpeed = getTravel_speed();
sendLine("G0 X%f Y%f F%d", Util.px2mm(x, resolution), Util.px2mm(y, resolution), (int) (travel_speed)); sendLine("G0 X%f Y%f F%d", x, y, (int) (travel_speed));
} }
protected void line(PrintStream out, int x, int y, double resolution) throws IOException { protected void line(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);
String append = ""; String append = "";
if (nextPower != currentPower) if (nextPower != currentPower)
{ {
...@@ -334,7 +364,7 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -334,7 +364,7 @@ public class GenericGcodeDriver extends LaserCutter {
append += String.format(Locale.US, " F%d", (int) (max_speed*nextSpeed/100.0)); append += String.format(Locale.US, " F%d", (int) (max_speed*nextSpeed/100.0));
currentSpeed = nextSpeed; currentSpeed = nextSpeed;
} }
sendLine("G1 X%f Y%f"+append, Util.px2mm(x, resolution), Util.px2mm(y, resolution)); sendLine("G1 X%f Y%f"+append, x, y);
} }
private void writeInitializationCode() throws IOException { private void writeInitializationCode() throws IOException {
...@@ -680,6 +710,8 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -680,6 +710,8 @@ public class GenericGcodeDriver extends LaserCutter {
SETTING_BEDWIDTH, SETTING_BEDWIDTH,
SETTING_BEDHEIGHT, SETTING_BEDHEIGHT,
SETTING_COMPORT, SETTING_COMPORT,
SETTING_FLIP_X,
SETTING_FLIP_Y,
SETTING_HOST, SETTING_HOST,
SETTING_HTTP_UPLOAD_URL, SETTING_HTTP_UPLOAD_URL,
SETTING_IDENTIFICATION_STRING, SETTING_IDENTIFICATION_STRING,
...@@ -711,6 +743,10 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -711,6 +743,10 @@ public class GenericGcodeDriver extends LaserCutter {
return this.getBedHeight(); return this.getBedHeight();
} else if (SETTING_COMPORT.equals(attribute)) { } else if (SETTING_COMPORT.equals(attribute)) {
return this.getComport(); return this.getComport();
} else if (SETTING_FLIP_X.equals(attribute)) {
return this.isFlipXaxis();
} else if (SETTING_FLIP_Y.equals(attribute)) {
return this.isFlipYaxis();
} else if (SETTING_HOST.equals(attribute)) { } else if (SETTING_HOST.equals(attribute)) {
return this.getHost(); return this.getHost();
} else if (SETTING_HTTP_UPLOAD_URL.equals(attribute)) { } else if (SETTING_HTTP_UPLOAD_URL.equals(attribute)) {
...@@ -752,6 +788,10 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -752,6 +788,10 @@ public class GenericGcodeDriver extends LaserCutter {
this.setBedHeight((Double) value); this.setBedHeight((Double) value);
} else if (SETTING_COMPORT.equals(attribute)) { } else if (SETTING_COMPORT.equals(attribute)) {
this.setComport((String) value); this.setComport((String) value);
} else if (SETTING_FLIP_X.equals(attribute)) {
this.setFlipXaxis((Boolean) value);
} else if (SETTING_FLIP_Y.equals(attribute)) {
this.setFlipYaxis((Boolean) value);
} else if (SETTING_HOST.equals(attribute)) { } else if (SETTING_HOST.equals(attribute)) {
this.setHost((String) value); this.setHost((String) value);
} else if (SETTING_HTTP_UPLOAD_URL.equals(attribute)) { } else if (SETTING_HTTP_UPLOAD_URL.equals(attribute)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment