-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add absolute speed option for Smoothieboard driver
- Loading branch information
Showing
6 changed files
with
175 additions
and
32 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
src/com/t_oster/liblasercut/FloatPowerAbsSpeedFocusProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* This file is part of LibLaserCut. | ||
* Copyright (C) 2011 - 2014 Thomas Oster <mail@thomas-oster.de> | ||
* | ||
* LibLaserCut is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LibLaserCut is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with LibLaserCut. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
**/ | ||
package com.t_oster.liblasercut; | ||
|
||
public class FloatPowerAbsSpeedFocusProperty extends FloatPowerSpeedFocusProperty | ||
{ | ||
private float max_speed = 100; | ||
|
||
public FloatPowerAbsSpeedFocusProperty(float max_speed) | ||
{ | ||
this.max_speed = max_speed; | ||
} | ||
|
||
public void setSpeed(float speed) | ||
{ | ||
speed = speed < 0 ? 0 : speed; | ||
speed = speed > max_speed ? max_speed : speed; | ||
this.speed = speed; | ||
} | ||
|
||
private static String[] propertyNames = new String[]{"power (%)", "speed (mm/min)", "focus (mm)"}; | ||
|
||
@Override | ||
public String[] getPropertyKeys() | ||
{ | ||
return propertyNames; | ||
} | ||
|
||
@Override | ||
public FloatPowerAbsSpeedFocusProperty clone() | ||
{ | ||
FloatPowerAbsSpeedFocusProperty p = new FloatPowerAbsSpeedFocusProperty(this.max_speed); | ||
p.focus = focus; | ||
p.power = power; | ||
p.speed = speed; | ||
return p; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
final FloatPowerAbsSpeedFocusProperty other = (FloatPowerAbsSpeedFocusProperty) obj; | ||
if (Float.floatToIntBits(this.power) != Float.floatToIntBits(other.power)) { | ||
return false; | ||
} | ||
if (Float.floatToIntBits(this.speed) != Float.floatToIntBits(other.speed)) { | ||
return false; | ||
} | ||
if (Float.floatToIntBits(this.max_speed) != Float.floatToIntBits(other.max_speed)) { | ||
return false; | ||
} | ||
if (Float.floatToIntBits(this.focus) != Float.floatToIntBits(other.focus)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int hash = 7; | ||
hash = 67 * hash + Float.floatToIntBits(this.power); | ||
hash = 67 * hash + Float.floatToIntBits(this.speed); | ||
hash = 67 * hash + Float.floatToIntBits(this.max_speed); | ||
hash = 67 * hash + Float.floatToIntBits(this.focus); | ||
return hash; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/com/t_oster/liblasercut/drivers/SmoothieBoardAbsolute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* This file is part of LibLaserCut. | ||
* Copyright (C) 2011 - 2014 Thomas Oster <mail@thomas-oster.de> | ||
* | ||
* LibLaserCut is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LibLaserCut is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with LibLaserCut. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
**/ | ||
package com.t_oster.liblasercut.drivers; | ||
|
||
import com.t_oster.liblasercut.FloatPowerAbsSpeedFocusProperty; | ||
import com.t_oster.liblasercut.LaserProperty; | ||
|
||
public class SmoothieBoardAbsolute extends SmoothieBoard | ||
{ | ||
@Override | ||
public String getModelName() | ||
{ | ||
return "Smoothieboard (absolute speeds)"; | ||
} | ||
|
||
@Override | ||
public LaserProperty getLaserPropertyForVectorPart() { | ||
return new FloatPowerAbsSpeedFocusProperty((float) this.max_speed); | ||
} | ||
|
||
@Override | ||
public LaserProperty getLaserPropertyForRaster3dPart() | ||
{ | ||
return new FloatPowerAbsSpeedFocusProperty((float) this.max_speed); | ||
} | ||
|
||
@Override | ||
public LaserProperty getLaserPropertyForRasterPart() | ||
{ | ||
return new FloatPowerAbsSpeedFocusProperty((float) this.max_speed); | ||
} | ||
|
||
@Override | ||
protected void setSpeed(double speed) | ||
{ | ||
this.nextSpeed = speed; | ||
} | ||
|
||
@Override | ||
public SmoothieBoardAbsolute clone() | ||
{ | ||
SmoothieBoardAbsolute clone = new SmoothieBoardAbsolute(); | ||
clone.copyProperties(this); | ||
return clone; | ||
} | ||
|
||
} |