Skip to content

Commit

Permalink
Autogenerated - Upstream 4d89d74
Browse files Browse the repository at this point in the history
  • Loading branch information
Klippy-Tools-Bot committed Aug 3, 2024
1 parent 2de1700 commit 17b0c83
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion klippy/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
171e3bf
4d89d74
8 changes: 5 additions & 3 deletions klippy/extras/servo.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ def _get_pwm_from_pulse_width(self, width):
return width * self.width_to_value
cmd_SET_SERVO_help = "Set servo angle"
def cmd_SET_SERVO(self, gcmd):
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
width = gcmd.get_float('WIDTH', None)
if width is not None:
self._set_pwm(print_time, self._get_pwm_from_pulse_width(width))
value = self._get_pwm_from_pulse_width(width)
else:
angle = gcmd.get_float('ANGLE')
self._set_pwm(print_time, self._get_pwm_from_angle(angle))
value = self._get_pwm_from_angle(angle)
toolhead = self.printer.lookup_object('toolhead')
toolhead.register_lookahead_callback((lambda pt:
self._set_pwm(pt, value)))

def load_config_prefix(config):
return PrinterServo(config)
34 changes: 28 additions & 6 deletions klippy/kinematics/idex_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright (C) 2023 Dmitry Butyugin <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import math
import logging, math
from .. import chelper

INACTIVE = 'INACTIVE'
Expand Down Expand Up @@ -202,14 +202,31 @@ def cmd_RESTORE_DUAL_CARRIAGE_STATE(self, gcmd):
move_speed = gcmd.get_float('MOVE_SPEED', 0., above=0.)
toolhead = self.printer.lookup_object('toolhead')
toolhead.flush_step_generation()
pos = toolhead.get_position()
if gcmd.get_int('MOVE', 1):
homing_speed = 99999999.
cur_pos = []
for i, dc in enumerate(self.dc):
self.toggle_active_dc_rail(i)
saved_pos = saved_state['axes_positions'][i]
toolhead.manual_move(
pos[:self.axis] + [saved_pos] + pos[self.axis+1:],
move_speed or dc.get_rail().homing_speed)
homing_speed = min(homing_speed, dc.get_rail().homing_speed)
cur_pos.append(toolhead.get_position())
move_pos = list(cur_pos[0])
dl = [saved_state['axes_positions'][i] - cur_pos[i][self.axis]
for i in range(2)]
primary_ind = 0 if abs(dl[0]) >= abs(dl[1]) else 1
self.toggle_active_dc_rail(primary_ind)
move_pos[self.axis] = saved_state['axes_positions'][primary_ind]
dc_mode = INACTIVE if min(abs(dl[0]), abs(dl[1])) < 0.000000001 \
else COPY if dl[0] * dl[1] > 0 else MIRROR
if dc_mode != INACTIVE:
self.dc[1-primary_ind].activate(dc_mode, cur_pos[primary_ind])
self.dc[1-primary_ind].override_axis_scaling(
abs(dl[1-primary_ind] / dl[primary_ind]),
cur_pos[primary_ind])
toolhead.manual_move(move_pos, move_speed or homing_speed)
toolhead.flush_step_generation()
# Make sure the scaling coefficients are restored with the mode
self.dc[0].inactivate(move_pos)
self.dc[1].inactivate(move_pos)
for i, dc in enumerate(self.dc):
saved_mode = saved_state['carriage_modes'][i]
self.activate_dc_mode(i, saved_mode)
Expand Down Expand Up @@ -257,3 +274,8 @@ def inactivate(self, position):
self.scale = 0.
self.apply_transform()
self.mode = INACTIVE
def override_axis_scaling(self, new_scale, position):
old_axis_position = self.get_axis_position(position)
self.scale = math.copysign(new_scale, self.scale)
self.offset = old_axis_position - position[self.axis] * self.scale
self.apply_transform()
2 changes: 1 addition & 1 deletion testcases/klippy/dual_carriage.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pid_Kd: 114
min_temp: 0
max_temp: 250

[gcode_macro PARK_extruder0]
[gcode_macro PARK_extruder]
gcode:
G90
G1 X0
Expand Down
12 changes: 12 additions & 0 deletions testcases/klippy/dual_carriage.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ G1 X190 F6000
SET_DUAL_CARRIAGE CARRIAGE=0
G1 X20 F6000

# Save dual carriage state
SAVE_DUAL_CARRIAGE_STATE

G1 X50 F6000

# Go back to alternate carriage
SET_DUAL_CARRIAGE CARRIAGE=1
G1 X170 F6000

# Restore dual carriage state
RESTORE_DUAL_CARRIAGE_STATE

# Test changing extruders
G1 X5
T1
Expand Down

0 comments on commit 17b0c83

Please sign in to comment.