Skip to content

Commit

Permalink
store_pa_in_trapq danger flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bwnance authored and rogerlz committed Jan 28, 2024
1 parent 261da3c commit 490efe1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
16 changes: 13 additions & 3 deletions klippy/chelper/kin_extruder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions klippy/extras/danger_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 8 additions & 4 deletions klippy/kinematics/extruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 490efe1

Please sign in to comment.