Skip to content

Commit

Permalink
Support X and Y axis flip
Browse files Browse the repository at this point in the history
Signed-off-by: Klaus Kämpf <[email protected]>
  • Loading branch information
kkaempf authored and mgmax committed Apr 19, 2024
1 parent e4f91f5 commit e8cad48
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/main/java/de/thomas_oster/liblasercut/drivers/Ruida.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public class Ruida extends LaserCutter
protected static final String SETTING_MAX_POWER = "Max laser power (%)";
protected static final String SETTING_BED_WIDTH = "Bed width (mm)";
protected static final String SETTING_BED_HEIGHT = "Bed height (mm)";
protected static final String SETTING_FLIP_X = "Flip X Axis";
protected static final String SETTING_FLIP_Y = "Flip Y Axis";
protected static final Locale FORMAT_LOCALE = Locale.US;

protected static final String[] uploadMethodList = {UPLOAD_METHOD_FILE, UPLOAD_METHOD_IP, UPLOAD_METHOD_SERIAL};
Expand Down Expand Up @@ -138,6 +140,30 @@ public void setComport(String comport)
this.comport = comport;
}

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;
}

/* -----------------------------------------------------------------------*/

public Ruida()
Expand Down Expand Up @@ -267,8 +293,8 @@ private void find_and_write_bounding_box(LaserJob job) throws IOException

private void vector(double x, double y, double dpi, boolean as_cut, boolean force_abs) throws IOException
{
double x_mm = Util.px2mm(x, dpi);
double y_mm = Util.px2mm(y, dpi);
double x_mm = isFlipXaxis() ? getBedWidth() - Util.px2mm(x, dpi) : Util.px2mm(x, dpi);
double y_mm = isFlipYaxis() ? getBedHeight() - Util.px2mm(y, dpi) : Util.px2mm(y, dpi);
boolean as_absolute;

/* compute distance to last known position */
Expand Down Expand Up @@ -935,6 +961,8 @@ else if (getExportPath() != null && getExportPath().length() > 0)
SETTING_MAX_POWER,
SETTING_BED_WIDTH,
SETTING_BED_HEIGHT,
SETTING_FLIP_X,
SETTING_FLIP_Y,
};

@Override
Expand All @@ -961,6 +989,10 @@ public Object getProperty(String attribute) {
return this.getBedWidth();
} else if (SETTING_BED_HEIGHT.equals(attribute)) {
return this.getBedHeight();
} else if (SETTING_FLIP_X.equals(attribute)) {
return this.isFlipXaxis();
} else if (SETTING_FLIP_Y.equals(attribute)) {
return this.isFlipYaxis();
}
return null;
}
Expand Down Expand Up @@ -994,6 +1026,10 @@ public void setProperty(String attribute, Object value) {
this.setBedHeigth((Double)value);
} else if (SETTING_BED_WIDTH.equals(attribute)) {
this.setBedWidth((Double)value);
} else if (SETTING_FLIP_X.equals(attribute)) {
this.setFlipXaxis((Boolean) value);
} else if (SETTING_FLIP_Y.equals(attribute)) {
this.setFlipYaxis((Boolean) value);
}
}

Expand Down

0 comments on commit e8cad48

Please sign in to comment.