From 9bf73cd72dc4b279c52c764e916d8a898adb2761 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 20 Mar 2017 14:39:06 -0400 Subject: [PATCH] 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 --- klippy/extruder.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/klippy/extruder.py b/klippy/extruder.py index 98667b98..b62244e8 100644 --- a/klippy/extruder.py +++ b/klippy/extruder.py @@ -56,10 +56,15 @@ class PrinterExtruder: raise homing.EndstopMoveError( move.end_pos, "Move exceeds maximum extrusion cross section") def calc_junction(self, prev_move, move): - if move.axes_d[3] or prev_move.axes_d[3]: - if (not move.axes_d[3] or not prev_move.axes_d[3] - or move.extrude_r > prev_move.extrude_r * EXTRUDE_DIFF_IGNORE - or prev_move.extrude_r > move.extrude_r * EXTRUDE_DIFF_IGNORE): + extrude = move.axes_d[3] + prev_extrude = prev_move.axes_d[3] + if extrude or prev_extrude: + 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 return 0. move.extrude_r = prev_move.extrude_r