diff --git a/docs/Todo.md b/docs/Todo.md index 73b4cbc0..0f454d4c 100644 --- a/docs/Todo.md +++ b/docs/Todo.md @@ -150,13 +150,6 @@ Hardware features Misc features ============= -* The "pressure advance" algorithm does improve extruder - functionality. However, it's interaction with lookahead is not ideal - as it can cause rapid jerks of the filament when the head speed - changes briefly during cornering. Ideally, pressure advance would - interact better with lookahead to avoid advance during transient - speed changes. - * Possibly use cubic functions instead of quadratic functions in step compression code. diff --git a/klippy/extruder.py b/klippy/extruder.py index 4abbb7dd..12f43141 100644 --- a/klippy/extruder.py +++ b/klippy/extruder.py @@ -59,8 +59,15 @@ class PrinterExtruder: prev_pressure_d += extra_accel_d # Update decel and retract parameters when decelerating if decel_t: - npd = move.end_v * move_extrude_r * self.pressure_advance - extra_decel_d = prev_pressure_d - npd + if move.corner_min: + npd = move.corner_max*move_extrude_r * self.pressure_advance + extra_decel_d = prev_pressure_d - npd + if move.end_v > move.corner_min: + extra_decel_d *= ((move.cruise_v - move.end_v) + / (move.cruise_v - move.corner_min)) + else: + npd = move.end_v * move_extrude_r * self.pressure_advance + extra_decel_d = prev_pressure_d - npd if extra_decel_d > 0.: extra_decel_v = extra_decel_d / decel_t decel_v -= extra_decel_v