Change the way the last movement is handled and now store the distance movement for up and down for each layer
This commit is contained in:
parent
652d64fe74
commit
61039bab67
23
wow.py
23
wow.py
@ -3,7 +3,14 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
_DefaultMovement = 5 # in mm
|
# Ignore movement which are larger than this value for:
|
||||||
|
# - Layer thickness calculation
|
||||||
|
# - Movement time
|
||||||
|
# This is mainly to ignore the last movement made after the final layer
|
||||||
|
# which as the gcode is made would screw the thickness calculation on that
|
||||||
|
# layer. (There is nothing to know that the layer ended in that specific case)
|
||||||
|
# TODO: this need to be improved in a way. This is not completely reliable
|
||||||
|
_IgnoreMovementLargerThan = 15 # in mm
|
||||||
|
|
||||||
|
|
||||||
class layer:
|
class layer:
|
||||||
@ -15,6 +22,8 @@ class layer:
|
|||||||
self.number = number
|
self.number = number
|
||||||
self.speed_up = 0
|
self.speed_up = 0
|
||||||
self.speed_down = 0
|
self.speed_down = 0
|
||||||
|
self.up_distance = 0
|
||||||
|
self.down_distance = 0
|
||||||
self.exposition = 0
|
self.exposition = 0
|
||||||
self.data = b""
|
self.data = b""
|
||||||
self.width = 0
|
self.width = 0
|
||||||
@ -48,7 +57,13 @@ def _g1(code, cur_layer):
|
|||||||
for param in code:
|
for param in code:
|
||||||
if param[0] == "Z" or param[0] == "z":
|
if param[0] == "Z" or param[0] == "z":
|
||||||
distance = float(param[1:])
|
distance = float(param[1:])
|
||||||
if abs(distance) <= _DefaultMovement:
|
if abs(distance) <= _IgnoreMovementLargerThan:
|
||||||
|
|
||||||
|
if distance > 0:
|
||||||
|
cur_layer.up_distance = distance
|
||||||
|
else:
|
||||||
|
cur_layer.down_distance = distance
|
||||||
|
|
||||||
cur_layer.thickness += distance
|
cur_layer.thickness += distance
|
||||||
cur_layer.thickness = round(cur_layer.thickness, 5)
|
cur_layer.thickness = round(cur_layer.thickness, 5)
|
||||||
if speed is not 0:
|
if speed is not 0:
|
||||||
@ -232,8 +247,8 @@ class WowFile:
|
|||||||
for l in self.layers:
|
for l in self.layers:
|
||||||
# Write layer preamble
|
# Write layer preamble
|
||||||
f.write(self._LayerStart.format(layer=l.number,
|
f.write(self._LayerStart.format(layer=l.number,
|
||||||
up=_DefaultMovement,
|
up=l.up_distance,
|
||||||
down=l.thickness - _DefaultMovement,
|
down=round(l.thickness - l.up_distance, 5),
|
||||||
spdu=l.speed_up,
|
spdu=l.speed_up,
|
||||||
spdd=l.speed_down).encode("ascii"))
|
spdd=l.speed_down).encode("ascii"))
|
||||||
# Write layer image
|
# Write layer image
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user