extruder: Make sure EXTRUDE_DIFF_IGNORE doesn't trigger due to rounding

The code disables lookahead between two extruding moves with
significantly different extrude ratios.  Unfortunately, it was
possible for very tiny moves to show different extrude ratios just due
to how the slicer implements rounding when it produces the gcode.
Allow lookahead to be enabled between moves with extrude ratios that
are different if they don't noticeably produce more or less extrusion.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-03-20 14:39:06 -04:00
parent f97cf5c3b6
commit 9bf73cd72d
1 changed files with 9 additions and 4 deletions

View File

@ -56,10 +56,15 @@ class PrinterExtruder:
raise homing.EndstopMoveError( raise homing.EndstopMoveError(
move.end_pos, "Move exceeds maximum extrusion cross section") move.end_pos, "Move exceeds maximum extrusion cross section")
def calc_junction(self, prev_move, move): def calc_junction(self, prev_move, move):
if move.axes_d[3] or prev_move.axes_d[3]: extrude = move.axes_d[3]
if (not move.axes_d[3] or not prev_move.axes_d[3] prev_extrude = prev_move.axes_d[3]
or move.extrude_r > prev_move.extrude_r * EXTRUDE_DIFF_IGNORE if extrude or prev_extrude:
or prev_move.extrude_r > move.extrude_r * EXTRUDE_DIFF_IGNORE): if not extrude or not prev_extrude:
# Extrude move to non-extrude move - disable lookahead
return 0.
if ((move.extrude_r > prev_move.extrude_r * EXTRUDE_DIFF_IGNORE
or prev_move.extrude_r > move.extrude_r * EXTRUDE_DIFF_IGNORE)
and abs(move.move_d * prev_move.extrude_r - extrude) >= .001):
# Extrude ratio between moves is too different # Extrude ratio between moves is too different
return 0. return 0.
move.extrude_r = prev_move.extrude_r move.extrude_r = prev_move.extrude_r