mirror of
git://soft.sys114.com/klipper
synced 2026-02-11 03:08:07 +09:00
stepper_enable: Move motor_off() logic to stepper_enable.py
Directly disable all the stepper motors on a global motor_off() from the StepperEnable() class in stepper_enable.py. This simplifies the toolhead and kinematic classes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -17,6 +17,8 @@ class CartKinematics:
|
||||
for s in self.get_steppers():
|
||||
s.set_trapq(toolhead.get_trapq())
|
||||
toolhead.register_step_generator(s.generate_steps)
|
||||
self.printer.register_event_handler("stepper_enable:motor_off",
|
||||
self._motor_off)
|
||||
# Setup boundary checks
|
||||
max_velocity, max_accel = toolhead.get_max_velocity()
|
||||
self.max_z_velocity = config.getfloat(
|
||||
@@ -84,12 +86,8 @@ class CartKinematics:
|
||||
self._activate_carriage(altc)
|
||||
else:
|
||||
self._home_axis(homing_state, axis, self.rails[axis])
|
||||
def motor_off(self, print_time):
|
||||
def _motor_off(self, print_time):
|
||||
self.limits = [(1.0, -1.0)] * 3
|
||||
for rail in self.rails:
|
||||
rail.motor_enable(print_time, 0)
|
||||
for rail in self.dual_carriage_rails:
|
||||
rail.motor_enable(print_time, 0)
|
||||
def _check_endstops(self, move):
|
||||
end_pos = move.end_pos
|
||||
for i in (0, 1, 2):
|
||||
@@ -131,7 +129,6 @@ class CartKinematics:
|
||||
toolhead.set_position(self.calc_position() + [extruder_pos])
|
||||
if self.limits[dc_axis][0] <= self.limits[dc_axis][1]:
|
||||
self.limits[dc_axis] = dc_rail.get_range()
|
||||
self.need_motor_enable = True
|
||||
cmd_SET_DUAL_CARRIAGE_help = "Set which carriage is active"
|
||||
def cmd_SET_DUAL_CARRIAGE(self, params):
|
||||
gcode = self.printer.lookup_object('gcode')
|
||||
|
||||
@@ -20,6 +20,8 @@ class CoreXYKinematics:
|
||||
for s in self.get_steppers():
|
||||
s.set_trapq(toolhead.get_trapq())
|
||||
toolhead.register_step_generator(s.generate_steps)
|
||||
config.get_printer().register_event_handler("stepper_enable:motor_off",
|
||||
self._motor_off)
|
||||
# Setup boundary checks
|
||||
max_velocity, max_accel = toolhead.get_max_velocity()
|
||||
self.max_z_velocity = config.getfloat(
|
||||
@@ -63,10 +65,8 @@ class CoreXYKinematics:
|
||||
forcepos[axis] += 1.5 * (position_max - hi.position_endstop)
|
||||
# Perform homing
|
||||
homing_state.home_rails([rail], forcepos, homepos)
|
||||
def motor_off(self, print_time):
|
||||
def _motor_off(self, print_time):
|
||||
self.limits = [(1.0, -1.0)] * 3
|
||||
for rail in self.rails:
|
||||
rail.motor_enable(print_time, 0)
|
||||
def _check_endstops(self, move):
|
||||
end_pos = move.end_pos
|
||||
for i in (0, 1, 2):
|
||||
|
||||
@@ -23,6 +23,8 @@ class DeltaKinematics:
|
||||
stepper_configs[2], need_position_minmax = False,
|
||||
default_position_endstop=a_endstop)
|
||||
self.rails = [rail_a, rail_b, rail_c]
|
||||
config.get_printer().register_event_handler("stepper_enable:motor_off",
|
||||
self._motor_off)
|
||||
# Setup stepper max halt velocity
|
||||
self.max_velocity, self.max_accel = toolhead.get_max_velocity()
|
||||
self.max_z_velocity = config.getfloat(
|
||||
@@ -105,10 +107,8 @@ class DeltaKinematics:
|
||||
forcepos = list(self.home_position)
|
||||
forcepos[2] = -1.5 * math.sqrt(max(self.arm2)-self.max_xy2)
|
||||
homing_state.home_rails(self.rails, forcepos, self.home_position)
|
||||
def motor_off(self, print_time):
|
||||
def _motor_off(self, print_time):
|
||||
self.limit_xy2 = -1.
|
||||
for rail in self.rails:
|
||||
rail.motor_enable(print_time, 0)
|
||||
self.need_home = True
|
||||
def check_move(self, move):
|
||||
end_pos = move.end_pos
|
||||
|
||||
@@ -87,8 +87,6 @@ class PrinterExtruder:
|
||||
return self.deactivate_gcode.render()
|
||||
def stats(self, eventtime):
|
||||
return self.heater.stats(eventtime)
|
||||
def motor_off(self, print_time):
|
||||
self.stepper.motor_enable(print_time, 0)
|
||||
def check_move(self, move):
|
||||
move.extrude_r = move.axes_r[3]
|
||||
move.extrude_max_corner_v = 0.
|
||||
@@ -231,8 +229,6 @@ class PrinterExtruder:
|
||||
class DummyExtruder:
|
||||
def set_active(self, print_time, is_active):
|
||||
return 0.
|
||||
def motor_off(self, move_time):
|
||||
pass
|
||||
def check_move(self, move):
|
||||
raise homing.EndstopMoveError(
|
||||
move.end_pos, "Extrude when no extruder present")
|
||||
|
||||
@@ -15,8 +15,6 @@ class NoneKinematics:
|
||||
pass
|
||||
def home(self, homing_state):
|
||||
pass
|
||||
def motor_off(self, print_time):
|
||||
pass
|
||||
def check_move(self, move):
|
||||
pass
|
||||
def get_status(self):
|
||||
|
||||
@@ -21,6 +21,8 @@ class PolarKinematics:
|
||||
for s in self.get_steppers():
|
||||
s.set_trapq(toolhead.get_trapq())
|
||||
toolhead.register_step_generator(s.generate_steps)
|
||||
config.get_printer().register_event_handler("stepper_enable:motor_off",
|
||||
self._motor_off)
|
||||
# Setup boundary checks
|
||||
max_velocity, max_accel = toolhead.get_max_velocity()
|
||||
self.max_z_velocity = config.getfloat(
|
||||
@@ -82,11 +84,9 @@ class PolarKinematics:
|
||||
self._home_axis(homing_state, 0, self.rails[0])
|
||||
if home_z:
|
||||
self._home_axis(homing_state, 2, self.rails[1])
|
||||
def motor_off(self, print_time):
|
||||
def _motor_off(self, print_time):
|
||||
self.limit_z = [(1.0, -1.0)]
|
||||
self.limit_xy2 = -1.
|
||||
for s in self.steppers:
|
||||
s.motor_enable(print_time, 0)
|
||||
def check_move(self, move):
|
||||
end_pos = move.end_pos
|
||||
xy2 = end_pos[0]**2 + end_pos[1]**2
|
||||
|
||||
@@ -42,9 +42,6 @@ class WinchKinematics:
|
||||
# XXX - homing not implemented
|
||||
homing_state.set_axes([0, 1, 2])
|
||||
homing_state.set_homed_position([0., 0., 0.])
|
||||
def motor_off(self, print_time):
|
||||
for s in self.steppers:
|
||||
s.motor_enable(print_time, 0)
|
||||
def check_move(self, move):
|
||||
# XXX - boundary checks and speed limits not implemented
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user