From 490efe176eaa7d52a50ba3961d70d8903558591a Mon Sep 17 00:00:00 2001 From: Bea Nance Date: Fri, 26 Jan 2024 16:39:21 -0500 Subject: [PATCH] store_pa_in_trapq danger flag --- klippy/chelper/kin_extruder.c | 16 +++++++++++++--- klippy/extras/danger_options.py | 1 + klippy/kinematics/extruder.py | 12 ++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/klippy/chelper/kin_extruder.c b/klippy/chelper/kin_extruder.c index b8d1cc221..6f11060a9 100644 --- a/klippy/chelper/kin_extruder.c +++ b/klippy/chelper/kin_extruder.c @@ -59,10 +59,20 @@ pa_move_integrate(struct move *m, double pressure_advance start = 0.; if (end > m->move_t) end = m->move_t; + // figure out what to use for pressure advance + // use_pa_from_trapq is passed in via the move's axes_r.z field + // if this is True (not 0), we use the pressure advance value in the axes_r.y + // otherwise, we use the one passed in as an arg to this function (the stored one) + int use_pa_from_trapq = m->axes_r.z != 0.; + if (use_pa_from_trapq) { + pressure_advance = m->axes_r.y; + } + else { + int can_pressure_advance = m->axes_r.y != 0.; + if (!can_pressure_advance) + pressure_advance = 0.; + } // Calculate base position and velocity with pressure advance - int can_pressure_advance = m->axes_r.y != 0.; - if (!can_pressure_advance) - pressure_advance = 0.; base += pressure_advance * m->start_v; double start_v = m->start_v + pressure_advance * 2. * m->half_accel; // Calculate definitive integral diff --git a/klippy/extras/danger_options.py b/klippy/extras/danger_options.py index 7c838f8d2..cfc392933 100644 --- a/klippy/extras/danger_options.py +++ b/klippy/extras/danger_options.py @@ -23,6 +23,7 @@ def __init__(self, config): "homing_elapsed_distance_tolerance", 0.5, minval=0.0 ) self.adc_ignore_limits = config.getboolean("adc_ignore_limits", False) + self.store_pa_in_trapq = config.getboolean("store_pa_in_trapq", False) def load_config(config): diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py index 5c8428c0d..fa48a0b6d 100644 --- a/klippy/kinematics/extruder.py +++ b/klippy/kinematics/extruder.py @@ -216,6 +216,7 @@ def cmd_SYNC_STEPPER_TO_EXTRUDER(self, gcmd): class PrinterExtruder: def __init__(self, config, extruder_num): self.printer = config.get_printer() + self.danger_options = self.printer.lookup_object("danger_options") self.name = config.get_name() self.last_position = 0.0 # Setup hotend heater @@ -357,9 +358,12 @@ def move(self, print_time, move): accel = move.accel * axis_r start_v = move.start_v * axis_r cruise_v = move.cruise_v * axis_r - can_pressure_advance = False + pressure_advance = 0.0 if axis_r > 0.0 and (move.axes_d[0] or move.axes_d[1]): - can_pressure_advance = True + pressure_advance = self.extruder_stepper.pressure_advance + use_pa_from_trapq = ( + 1.0 if self.danger_options.store_pa_in_trapq else 0.0 + ) # Queue movement (x is extruder movement, y is pressure advance flag) self.trapq_append( self.trapq, @@ -371,8 +375,8 @@ def move(self, print_time, move): 0.0, 0.0, 1.0, - can_pressure_advance, - 0.0, + pressure_advance, + use_pa_from_trapq, start_v, cruise_v, accel,