2016-07-07 21:52:44 +02:00
|
|
|
# Code for coordinating events on the printer toolhead
|
|
|
|
#
|
2021-01-08 18:07:45 +01:00
|
|
|
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
|
2016-07-07 21:52:44 +02:00
|
|
|
#
|
|
|
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
2018-07-13 04:15:45 +02:00
|
|
|
import math, logging, importlib
|
2021-01-08 18:07:45 +01:00
|
|
|
import mcu, chelper, kinematics.extruder
|
2016-07-12 18:04:06 +02:00
|
|
|
|
2016-07-07 21:52:44 +02:00
|
|
|
# Common suffixes: _d is distance (in mm), _v is velocity (in
|
2017-01-14 19:35:27 +01:00
|
|
|
# mm/second), _v2 is velocity squared (mm^2/s^2), _t is time (in
|
|
|
|
# seconds), _r is ratio (scalar between 0.0 and 1.0)
|
2016-07-07 21:52:44 +02:00
|
|
|
|
2016-07-07 22:01:58 +02:00
|
|
|
# Class to track each move request
|
2016-07-07 21:52:44 +02:00
|
|
|
class Move:
|
2017-01-14 18:41:49 +01:00
|
|
|
def __init__(self, toolhead, start_pos, end_pos, speed):
|
2016-07-07 21:52:44 +02:00
|
|
|
self.toolhead = toolhead
|
2016-10-26 01:11:05 +02:00
|
|
|
self.start_pos = tuple(start_pos)
|
|
|
|
self.end_pos = tuple(end_pos)
|
2017-01-14 18:41:49 +01:00
|
|
|
self.accel = toolhead.max_accel
|
2020-01-03 01:32:10 +01:00
|
|
|
self.timing_callbacks = []
|
2019-01-04 18:42:55 +01:00
|
|
|
velocity = min(speed, toolhead.max_velocity)
|
2017-01-31 17:04:49 +01:00
|
|
|
self.is_kinematic_move = True
|
2016-10-26 01:11:05 +02:00
|
|
|
self.axes_d = axes_d = [end_pos[i] - start_pos[i] for i in (0, 1, 2, 3)]
|
2017-01-31 17:04:49 +01:00
|
|
|
self.move_d = move_d = math.sqrt(sum([d*d for d in axes_d[:3]]))
|
2018-09-11 19:23:20 +02:00
|
|
|
if move_d < .000000001:
|
2017-01-31 17:04:49 +01:00
|
|
|
# Extrude only move
|
2018-09-11 19:23:20 +02:00
|
|
|
self.end_pos = (start_pos[0], start_pos[1], start_pos[2],
|
|
|
|
end_pos[3])
|
|
|
|
axes_d[0] = axes_d[1] = axes_d[2] = 0.
|
2017-01-31 17:04:49 +01:00
|
|
|
self.move_d = move_d = abs(axes_d[3])
|
2019-11-06 14:41:50 +01:00
|
|
|
inv_move_d = 0.
|
|
|
|
if move_d:
|
|
|
|
inv_move_d = 1. / move_d
|
2019-01-04 18:42:55 +01:00
|
|
|
self.accel = 99999999.9
|
|
|
|
velocity = speed
|
2017-01-31 17:04:49 +01:00
|
|
|
self.is_kinematic_move = False
|
2019-11-06 14:41:50 +01:00
|
|
|
else:
|
|
|
|
inv_move_d = 1. / move_d
|
|
|
|
self.axes_r = [d * inv_move_d for d in axes_d]
|
2019-01-04 18:42:55 +01:00
|
|
|
self.min_move_t = move_d / velocity
|
2017-01-14 19:35:27 +01:00
|
|
|
# Junction speeds are tracked in velocity squared. The
|
|
|
|
# delta_v2 is the maximum amount of this squared-velocity that
|
|
|
|
# can change in this move.
|
|
|
|
self.max_start_v2 = 0.
|
2019-01-04 18:42:55 +01:00
|
|
|
self.max_cruise_v2 = velocity**2
|
2017-01-14 19:35:27 +01:00
|
|
|
self.delta_v2 = 2.0 * move_d * self.accel
|
2017-01-31 21:29:16 +01:00
|
|
|
self.max_smoothed_v2 = 0.
|
|
|
|
self.smooth_delta_v2 = 2.0 * move_d * toolhead.max_accel_to_decel
|
2016-09-30 20:47:45 +02:00
|
|
|
def limit_speed(self, speed, accel):
|
2017-02-11 18:29:19 +01:00
|
|
|
speed2 = speed**2
|
|
|
|
if speed2 < self.max_cruise_v2:
|
|
|
|
self.max_cruise_v2 = speed2
|
|
|
|
self.min_move_t = self.move_d / speed
|
2017-01-31 17:04:49 +01:00
|
|
|
self.accel = min(self.accel, accel)
|
|
|
|
self.delta_v2 = 2.0 * self.move_d * self.accel
|
2017-01-31 21:29:16 +01:00
|
|
|
self.smooth_delta_v2 = min(self.smooth_delta_v2, self.delta_v2)
|
2020-09-03 22:22:54 +02:00
|
|
|
def move_error(self, msg="Move out of range"):
|
2020-09-04 17:41:57 +02:00
|
|
|
ep = self.end_pos
|
|
|
|
m = "%s: %.3f %.3f %.3f [%.3f]" % (msg, ep[0], ep[1], ep[2], ep[3])
|
|
|
|
return self.toolhead.printer.command_error(m)
|
2016-07-07 21:52:44 +02:00
|
|
|
def calc_junction(self, prev_move):
|
2017-09-03 20:10:21 +02:00
|
|
|
if not self.is_kinematic_move or not prev_move.is_kinematic_move:
|
2016-09-30 20:47:45 +02:00
|
|
|
return
|
2017-01-28 04:06:54 +01:00
|
|
|
# Allow extruder to calculate its maximum junction
|
|
|
|
extruder_v2 = self.toolhead.extruder.calc_junction(prev_move, self)
|
2019-02-27 19:11:12 +01:00
|
|
|
# Find max velocity using "approximated centripetal velocity"
|
2019-11-06 14:41:50 +01:00
|
|
|
axes_r = self.axes_r
|
|
|
|
prev_axes_r = prev_move.axes_r
|
|
|
|
junction_cos_theta = -(axes_r[0] * prev_axes_r[0]
|
|
|
|
+ axes_r[1] * prev_axes_r[1]
|
|
|
|
+ axes_r[2] * prev_axes_r[2])
|
2016-07-07 21:52:44 +02:00
|
|
|
if junction_cos_theta > 0.999999:
|
|
|
|
return
|
|
|
|
junction_cos_theta = max(junction_cos_theta, -0.999999)
|
2016-07-12 18:04:06 +02:00
|
|
|
sin_theta_d2 = math.sqrt(0.5*(1.0-junction_cos_theta))
|
2019-02-27 19:11:12 +01:00
|
|
|
R = (self.toolhead.junction_deviation * sin_theta_d2
|
|
|
|
/ (1. - sin_theta_d2))
|
2020-02-29 04:27:23 +01:00
|
|
|
# Approximated circle must contact moves no further away than mid-move
|
2018-03-26 00:41:15 +02:00
|
|
|
tan_theta_d2 = sin_theta_d2 / math.sqrt(0.5*(1.0+junction_cos_theta))
|
|
|
|
move_centripetal_v2 = .5 * self.move_d * tan_theta_d2 * self.accel
|
|
|
|
prev_move_centripetal_v2 = (.5 * prev_move.move_d * tan_theta_d2
|
|
|
|
* prev_move.accel)
|
2020-02-29 04:27:23 +01:00
|
|
|
# Apply limits
|
2017-01-14 19:35:27 +01:00
|
|
|
self.max_start_v2 = min(
|
2018-03-26 00:41:15 +02:00
|
|
|
R * self.accel, R * prev_move.accel,
|
|
|
|
move_centripetal_v2, prev_move_centripetal_v2,
|
|
|
|
extruder_v2, self.max_cruise_v2, prev_move.max_cruise_v2,
|
|
|
|
prev_move.max_start_v2 + prev_move.delta_v2)
|
2017-01-31 21:29:16 +01:00
|
|
|
self.max_smoothed_v2 = min(
|
|
|
|
self.max_start_v2
|
|
|
|
, prev_move.max_smoothed_v2 + prev_move.smooth_delta_v2)
|
2017-01-28 04:06:54 +01:00
|
|
|
def set_junction(self, start_v2, cruise_v2, end_v2):
|
2016-07-11 19:21:27 +02:00
|
|
|
# Determine accel, cruise, and decel portions of the move distance
|
2019-11-06 14:23:16 +01:00
|
|
|
half_inv_accel = .5 / self.accel
|
|
|
|
accel_d = (cruise_v2 - start_v2) * half_inv_accel
|
|
|
|
decel_d = (cruise_v2 - end_v2) * half_inv_accel
|
|
|
|
cruise_d = self.move_d - accel_d - decel_d
|
2016-07-07 22:01:58 +02:00
|
|
|
# Determine move velocities
|
2017-01-14 19:35:27 +01:00
|
|
|
self.start_v = start_v = math.sqrt(start_v2)
|
|
|
|
self.cruise_v = cruise_v = math.sqrt(cruise_v2)
|
|
|
|
self.end_v = end_v = math.sqrt(end_v2)
|
2016-07-11 19:21:27 +02:00
|
|
|
# Determine time spent in each portion of move (time is the
|
|
|
|
# distance divided by average velocity)
|
2019-11-06 14:23:16 +01:00
|
|
|
self.accel_t = accel_d / ((start_v + cruise_v) * 0.5)
|
|
|
|
self.cruise_t = cruise_d / cruise_v
|
|
|
|
self.decel_t = decel_d / ((end_v + cruise_v) * 0.5)
|
2016-07-07 21:52:44 +02:00
|
|
|
|
2017-02-11 18:29:19 +01:00
|
|
|
LOOKAHEAD_FLUSH_TIME = 0.250
|
|
|
|
|
2016-07-07 22:01:58 +02:00
|
|
|
# Class to track a list of pending move requests and to facilitate
|
|
|
|
# "look-ahead" across moves to reduce acceleration between moves.
|
|
|
|
class MoveQueue:
|
2019-10-29 23:58:45 +01:00
|
|
|
def __init__(self, toolhead):
|
|
|
|
self.toolhead = toolhead
|
2016-07-07 22:01:58 +02:00
|
|
|
self.queue = []
|
2017-02-11 18:29:19 +01:00
|
|
|
self.junction_flush = LOOKAHEAD_FLUSH_TIME
|
2016-09-19 19:18:55 +02:00
|
|
|
def reset(self):
|
|
|
|
del self.queue[:]
|
2017-02-11 18:29:19 +01:00
|
|
|
self.junction_flush = LOOKAHEAD_FLUSH_TIME
|
2017-02-11 20:43:36 +01:00
|
|
|
def set_flush_time(self, flush_time):
|
|
|
|
self.junction_flush = flush_time
|
2020-01-03 01:32:10 +01:00
|
|
|
def get_last(self):
|
|
|
|
if self.queue:
|
|
|
|
return self.queue[-1]
|
|
|
|
return None
|
2016-07-07 22:01:58 +02:00
|
|
|
def flush(self, lazy=False):
|
2017-02-11 18:29:19 +01:00
|
|
|
self.junction_flush = LOOKAHEAD_FLUSH_TIME
|
2017-01-28 04:06:54 +01:00
|
|
|
update_flush_count = lazy
|
|
|
|
queue = self.queue
|
|
|
|
flush_count = len(queue)
|
2016-07-11 19:21:27 +02:00
|
|
|
# Traverse queue from last to first move and determine maximum
|
|
|
|
# junction speed assuming the robot comes to a complete stop
|
|
|
|
# after the last move.
|
2017-01-31 21:29:16 +01:00
|
|
|
delayed = []
|
|
|
|
next_end_v2 = next_smoothed_v2 = peak_cruise_v2 = 0.
|
2019-11-03 02:08:07 +01:00
|
|
|
for i in range(flush_count-1, -1, -1):
|
2017-01-28 04:06:54 +01:00
|
|
|
move = queue[i]
|
2017-01-14 19:35:27 +01:00
|
|
|
reachable_start_v2 = next_end_v2 + move.delta_v2
|
|
|
|
start_v2 = min(move.max_start_v2, reachable_start_v2)
|
2017-01-31 21:29:16 +01:00
|
|
|
reachable_smoothed_v2 = next_smoothed_v2 + move.smooth_delta_v2
|
|
|
|
smoothed_v2 = min(move.max_smoothed_v2, reachable_smoothed_v2)
|
|
|
|
if smoothed_v2 < reachable_smoothed_v2:
|
|
|
|
# It's possible for this move to accelerate
|
|
|
|
if (smoothed_v2 + move.smooth_delta_v2 > next_smoothed_v2
|
2017-02-20 18:37:43 +01:00
|
|
|
or delayed):
|
|
|
|
# This move can decelerate or this is a full accel
|
|
|
|
# move after a full decel move
|
2017-01-31 21:29:16 +01:00
|
|
|
if update_flush_count and peak_cruise_v2:
|
|
|
|
flush_count = i
|
|
|
|
update_flush_count = False
|
|
|
|
peak_cruise_v2 = min(move.max_cruise_v2, (
|
|
|
|
smoothed_v2 + reachable_smoothed_v2) * .5)
|
|
|
|
if delayed:
|
|
|
|
# Propagate peak_cruise_v2 to any delayed moves
|
2017-02-20 18:37:43 +01:00
|
|
|
if not update_flush_count and i < flush_count:
|
2019-09-25 04:46:17 +02:00
|
|
|
mc_v2 = peak_cruise_v2
|
|
|
|
for m, ms_v2, me_v2 in reversed(delayed):
|
|
|
|
mc_v2 = min(mc_v2, ms_v2)
|
2017-02-20 18:37:43 +01:00
|
|
|
m.set_junction(min(ms_v2, mc_v2), mc_v2
|
|
|
|
, min(me_v2, mc_v2))
|
2017-01-31 21:29:16 +01:00
|
|
|
del delayed[:]
|
|
|
|
if not update_flush_count and i < flush_count:
|
2017-02-20 18:37:43 +01:00
|
|
|
cruise_v2 = min((start_v2 + reachable_start_v2) * .5
|
|
|
|
, move.max_cruise_v2, peak_cruise_v2)
|
2017-01-31 21:29:16 +01:00
|
|
|
move.set_junction(min(start_v2, cruise_v2), cruise_v2
|
|
|
|
, min(next_end_v2, cruise_v2))
|
2017-02-20 18:37:43 +01:00
|
|
|
else:
|
2017-01-31 21:29:16 +01:00
|
|
|
# Delay calculating this move until peak_cruise_v2 is known
|
|
|
|
delayed.append((move, start_v2, next_end_v2))
|
2017-01-14 19:35:27 +01:00
|
|
|
next_end_v2 = start_v2
|
2017-01-31 21:29:16 +01:00
|
|
|
next_smoothed_v2 = smoothed_v2
|
2019-11-03 02:08:07 +01:00
|
|
|
if update_flush_count or not flush_count:
|
2019-11-15 00:36:42 +01:00
|
|
|
return
|
2016-07-11 19:21:27 +02:00
|
|
|
# Generate step times for all moves ready to be flushed
|
2019-11-03 02:08:07 +01:00
|
|
|
self.toolhead._process_moves(queue[:flush_count])
|
2016-07-11 19:21:27 +02:00
|
|
|
# Remove processed moves from the queue
|
2019-11-03 02:08:07 +01:00
|
|
|
del queue[:flush_count]
|
2016-07-07 22:01:58 +02:00
|
|
|
def add_move(self, move):
|
|
|
|
self.queue.append(move)
|
|
|
|
if len(self.queue) == 1:
|
|
|
|
return
|
2016-07-07 22:08:00 +02:00
|
|
|
move.calc_junction(self.queue[-2])
|
2017-02-11 18:29:19 +01:00
|
|
|
self.junction_flush -= move.min_move_t
|
2016-07-07 22:01:58 +02:00
|
|
|
if self.junction_flush <= 0.:
|
2018-09-25 21:44:45 +02:00
|
|
|
# Enough moves have been queued to reach the target flush time.
|
2016-07-07 22:01:58 +02:00
|
|
|
self.flush(lazy=True)
|
|
|
|
|
2019-09-18 04:53:17 +02:00
|
|
|
MIN_KIN_TIME = 0.100
|
2019-10-29 23:58:45 +01:00
|
|
|
MOVE_BATCH_TIME = 0.500
|
2020-02-25 18:54:55 +01:00
|
|
|
SDS_CHECK_TIME = 0.001 # step+dir+step filter in stepcompress.c
|
2016-07-07 21:52:44 +02:00
|
|
|
|
2019-06-26 03:25:01 +02:00
|
|
|
DRIP_SEGMENT_TIME = 0.050
|
2019-09-18 04:53:17 +02:00
|
|
|
DRIP_TIME = 0.100
|
2019-06-26 03:25:01 +02:00
|
|
|
class DripModeEndSignal(Exception):
|
|
|
|
pass
|
|
|
|
|
2016-07-07 22:01:58 +02:00
|
|
|
# Main code to track events (and their timing) on the printer toolhead
|
2016-07-07 21:52:44 +02:00
|
|
|
class ToolHead:
|
2018-06-21 19:47:39 +02:00
|
|
|
def __init__(self, config):
|
|
|
|
self.printer = config.get_printer()
|
|
|
|
self.reactor = self.printer.get_reactor()
|
2018-09-02 18:51:37 +02:00
|
|
|
self.all_mcus = [
|
|
|
|
m for n, m in self.printer.lookup_objects(module='mcu')]
|
2017-08-14 17:46:35 +02:00
|
|
|
self.mcu = self.all_mcus[0]
|
2019-11-08 00:06:46 +01:00
|
|
|
self.can_pause = True
|
|
|
|
if self.mcu.is_fileoutput():
|
|
|
|
self.can_pause = False
|
2019-10-29 23:58:45 +01:00
|
|
|
self.move_queue = MoveQueue(self)
|
2018-07-08 20:08:21 +02:00
|
|
|
self.commanded_pos = [0., 0., 0., 0.]
|
2019-01-08 15:15:40 +01:00
|
|
|
self.printer.register_event_handler("klippy:shutdown",
|
|
|
|
self._handle_shutdown)
|
2018-07-08 20:08:21 +02:00
|
|
|
# Velocity and acceleration control
|
2017-09-03 21:17:02 +02:00
|
|
|
self.max_velocity = config.getfloat('max_velocity', above=0.)
|
2017-04-11 17:37:09 +02:00
|
|
|
self.max_accel = config.getfloat('max_accel', above=0.)
|
2018-04-21 04:13:29 +02:00
|
|
|
self.requested_accel_to_decel = config.getfloat(
|
|
|
|
'max_accel_to_decel', self.max_accel * 0.5, above=0.)
|
2018-10-02 04:02:33 +02:00
|
|
|
self.max_accel_to_decel = self.requested_accel_to_decel
|
2018-07-08 20:08:21 +02:00
|
|
|
self.square_corner_velocity = config.getfloat(
|
|
|
|
'square_corner_velocity', 5., minval=0.)
|
|
|
|
self.junction_deviation = 0.
|
|
|
|
self._calc_junction_deviation()
|
2016-07-07 21:52:44 +02:00
|
|
|
# Print time tracking
|
2017-04-11 17:37:09 +02:00
|
|
|
self.buffer_time_low = config.getfloat(
|
|
|
|
'buffer_time_low', 1.000, above=0.)
|
|
|
|
self.buffer_time_high = config.getfloat(
|
|
|
|
'buffer_time_high', 2.000, above=self.buffer_time_low)
|
|
|
|
self.buffer_time_start = config.getfloat(
|
|
|
|
'buffer_time_start', 0.250, above=0.)
|
|
|
|
self.move_flush_time = config.getfloat(
|
|
|
|
'move_flush_time', 0.050, above=0.)
|
2016-07-07 21:52:44 +02:00
|
|
|
self.print_time = 0.
|
2019-06-26 02:32:33 +02:00
|
|
|
self.special_queuing_state = "Flushed"
|
2016-12-09 15:41:46 +01:00
|
|
|
self.need_check_stall = -1.
|
|
|
|
self.flush_timer = self.reactor.register_timer(self._flush_handler)
|
2017-02-11 20:43:36 +01:00
|
|
|
self.move_queue.set_flush_time(self.buffer_time_high)
|
2019-06-26 02:32:33 +02:00
|
|
|
self.idle_flush_print_time = 0.
|
|
|
|
self.print_stall = 0
|
2019-06-26 03:25:01 +02:00
|
|
|
self.drip_completion = None
|
2019-09-18 04:53:17 +02:00
|
|
|
# Kinematic step generation scan window time tracking
|
2020-02-25 18:54:55 +01:00
|
|
|
self.kin_flush_delay = SDS_CHECK_TIME
|
2019-09-18 04:53:17 +02:00
|
|
|
self.kin_flush_times = []
|
|
|
|
self.last_kin_flush_time = self.last_kin_move_time = 0.
|
2018-07-13 16:52:40 +02:00
|
|
|
# Setup iterative solver
|
|
|
|
ffi_main, ffi_lib = chelper.get_ffi()
|
2019-10-27 23:50:53 +01:00
|
|
|
self.trapq = ffi_main.gc(ffi_lib.trapq_alloc(), ffi_lib.trapq_free)
|
2019-10-29 17:44:39 +01:00
|
|
|
self.trapq_append = ffi_lib.trapq_append
|
2021-07-19 17:12:58 +02:00
|
|
|
self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves
|
2019-11-07 16:59:35 +01:00
|
|
|
self.step_generators = []
|
2017-09-03 21:17:02 +02:00
|
|
|
# Create kinematics class
|
2021-01-08 18:07:45 +01:00
|
|
|
gcode = self.printer.lookup_object('gcode')
|
|
|
|
self.Coord = gcode.Coord
|
2020-09-04 17:49:43 +02:00
|
|
|
self.extruder = kinematics.extruder.DummyExtruder(self.printer)
|
2018-07-13 04:15:45 +02:00
|
|
|
kin_name = config.get('kinematics')
|
|
|
|
try:
|
|
|
|
mod = importlib.import_module('kinematics.' + kin_name)
|
|
|
|
self.kin = mod.load_kinematics(self, config)
|
2018-08-30 16:14:32 +02:00
|
|
|
except config.error as e:
|
|
|
|
raise
|
|
|
|
except self.printer.lookup_object('pins').error as e:
|
|
|
|
raise
|
2018-07-13 04:15:45 +02:00
|
|
|
except:
|
|
|
|
msg = "Error loading kinematics '%s'" % (kin_name,)
|
|
|
|
logging.exception(msg)
|
|
|
|
raise config.error(msg)
|
2020-08-16 20:40:04 +02:00
|
|
|
# Register commands
|
|
|
|
gcode.register_command('G4', self.cmd_G4)
|
|
|
|
gcode.register_command('M400', self.cmd_M400)
|
2019-02-27 19:11:12 +01:00
|
|
|
gcode.register_command('SET_VELOCITY_LIMIT',
|
|
|
|
self.cmd_SET_VELOCITY_LIMIT,
|
2018-04-21 04:13:29 +02:00
|
|
|
desc=self.cmd_SET_VELOCITY_LIMIT_help)
|
2018-06-15 18:00:33 +02:00
|
|
|
gcode.register_command('M204', self.cmd_M204)
|
2019-06-26 02:32:33 +02:00
|
|
|
# Load some default modules
|
2021-01-08 18:37:57 +01:00
|
|
|
modules = ["gcode_move", "homing", "idle_timeout", "statistics",
|
|
|
|
"manual_probe", "tuning_tower"]
|
2020-05-05 20:10:30 +02:00
|
|
|
for module_name in modules:
|
|
|
|
self.printer.load_object(config, module_name)
|
2016-07-07 21:52:44 +02:00
|
|
|
# Print time tracking
|
2019-09-18 04:53:17 +02:00
|
|
|
def _update_move_time(self, next_print_time):
|
2019-10-29 23:58:45 +01:00
|
|
|
batch_time = MOVE_BATCH_TIME
|
2019-09-18 04:53:17 +02:00
|
|
|
kin_flush_delay = self.kin_flush_delay
|
|
|
|
lkft = self.last_kin_flush_time
|
2019-10-29 23:58:45 +01:00
|
|
|
while 1:
|
2019-09-18 04:53:17 +02:00
|
|
|
self.print_time = min(self.print_time + batch_time, next_print_time)
|
|
|
|
sg_flush_time = max(lkft, self.print_time - kin_flush_delay)
|
2019-11-07 16:59:35 +01:00
|
|
|
for sg in self.step_generators:
|
2019-09-18 04:53:17 +02:00
|
|
|
sg(sg_flush_time)
|
|
|
|
free_time = max(lkft, sg_flush_time - kin_flush_delay)
|
2021-07-19 17:12:58 +02:00
|
|
|
self.trapq_finalize_moves(self.trapq, free_time)
|
2019-09-18 04:53:17 +02:00
|
|
|
self.extruder.update_move_time(free_time)
|
|
|
|
mcu_flush_time = max(lkft, sg_flush_time - self.move_flush_time)
|
2019-10-29 23:58:45 +01:00
|
|
|
for m in self.all_mcus:
|
2019-09-18 04:53:17 +02:00
|
|
|
m.flush_moves(mcu_flush_time)
|
2019-10-29 23:58:45 +01:00
|
|
|
if self.print_time >= next_print_time:
|
|
|
|
break
|
2018-10-16 00:24:15 +02:00
|
|
|
def _calc_print_time(self):
|
2018-10-18 18:04:50 +02:00
|
|
|
curtime = self.reactor.monotonic()
|
|
|
|
est_print_time = self.mcu.estimated_print_time(curtime)
|
2019-09-18 04:53:17 +02:00
|
|
|
kin_time = max(est_print_time + MIN_KIN_TIME, self.last_kin_flush_time)
|
|
|
|
kin_time += self.kin_flush_delay
|
|
|
|
min_print_time = max(est_print_time + self.buffer_time_start, kin_time)
|
|
|
|
if min_print_time > self.print_time:
|
2020-08-15 17:23:50 +02:00
|
|
|
self.print_time = min_print_time
|
2018-10-18 18:04:50 +02:00
|
|
|
self.printer.send_event("toolhead:sync_print_time",
|
|
|
|
curtime, est_print_time, self.print_time)
|
2019-10-29 23:58:45 +01:00
|
|
|
def _process_moves(self, moves):
|
|
|
|
# Resync print_time if necessary
|
|
|
|
if self.special_queuing_state:
|
|
|
|
if self.special_queuing_state != "Drip":
|
|
|
|
# Transition from "Flushed"/"Priming" state to main state
|
|
|
|
self.special_queuing_state = ""
|
|
|
|
self.need_check_stall = -1.
|
|
|
|
self.reactor.update_timer(self.flush_timer, self.reactor.NOW)
|
|
|
|
self._calc_print_time()
|
|
|
|
# Queue moves into trapezoid motion queue (trapq)
|
|
|
|
next_move_time = self.print_time
|
|
|
|
for move in moves:
|
|
|
|
if move.is_kinematic_move:
|
|
|
|
self.trapq_append(
|
|
|
|
self.trapq, next_move_time,
|
|
|
|
move.accel_t, move.cruise_t, move.decel_t,
|
|
|
|
move.start_pos[0], move.start_pos[1], move.start_pos[2],
|
2019-11-06 14:41:50 +01:00
|
|
|
move.axes_r[0], move.axes_r[1], move.axes_r[2],
|
2019-10-29 23:58:45 +01:00
|
|
|
move.start_v, move.cruise_v, move.accel)
|
|
|
|
if move.axes_d[3]:
|
|
|
|
self.extruder.move(next_move_time, move)
|
2019-11-05 21:42:19 +01:00
|
|
|
next_move_time = (next_move_time + move.accel_t
|
|
|
|
+ move.cruise_t + move.decel_t)
|
2020-01-03 01:32:10 +01:00
|
|
|
for cb in move.timing_callbacks:
|
|
|
|
cb(next_move_time)
|
2019-10-29 23:58:45 +01:00
|
|
|
# Generate steps for moves
|
2019-09-18 04:53:17 +02:00
|
|
|
if self.special_queuing_state:
|
2019-10-29 23:58:45 +01:00
|
|
|
self._update_drip_move_time(next_move_time)
|
2019-09-18 04:53:17 +02:00
|
|
|
self._update_move_time(next_move_time)
|
|
|
|
self.last_kin_move_time = next_move_time
|
2019-11-14 05:34:21 +01:00
|
|
|
def flush_step_generation(self):
|
2019-06-26 02:32:33 +02:00
|
|
|
# Transition from "Flushed"/"Priming"/main state to "Flushed" state
|
2016-07-07 21:52:44 +02:00
|
|
|
self.move_queue.flush()
|
2019-06-26 02:32:33 +02:00
|
|
|
self.special_queuing_state = "Flushed"
|
|
|
|
self.need_check_stall = -1.
|
|
|
|
self.reactor.update_timer(self.flush_timer, self.reactor.NEVER)
|
|
|
|
self.move_queue.set_flush_time(self.buffer_time_high)
|
2018-01-12 22:24:47 +01:00
|
|
|
self.idle_flush_print_time = 0.
|
2019-09-18 04:53:17 +02:00
|
|
|
flush_time = self.last_kin_move_time + self.kin_flush_delay
|
2020-06-01 21:08:29 +02:00
|
|
|
flush_time = max(flush_time, self.print_time - self.kin_flush_delay)
|
2019-09-18 04:53:17 +02:00
|
|
|
self.last_kin_flush_time = max(self.last_kin_flush_time, flush_time)
|
|
|
|
self._update_move_time(max(self.print_time, self.last_kin_flush_time))
|
2019-06-26 02:32:33 +02:00
|
|
|
def _flush_lookahead(self):
|
|
|
|
if self.special_queuing_state:
|
2019-11-14 05:34:21 +01:00
|
|
|
return self.flush_step_generation()
|
2019-06-26 02:32:33 +02:00
|
|
|
self.move_queue.flush()
|
2017-02-11 20:43:36 +01:00
|
|
|
def get_last_move_time(self):
|
|
|
|
self._flush_lookahead()
|
2019-06-26 02:32:33 +02:00
|
|
|
if self.special_queuing_state:
|
2018-10-16 00:24:15 +02:00
|
|
|
self._calc_print_time()
|
|
|
|
return self.print_time
|
2016-12-09 15:41:46 +01:00
|
|
|
def _check_stall(self):
|
2017-02-06 20:07:55 +01:00
|
|
|
eventtime = self.reactor.monotonic()
|
2019-06-26 02:32:33 +02:00
|
|
|
if self.special_queuing_state:
|
2018-01-12 22:24:47 +01:00
|
|
|
if self.idle_flush_print_time:
|
2019-06-26 02:32:33 +02:00
|
|
|
# Was in "Flushed" state and got there from idle input
|
2018-01-12 22:24:47 +01:00
|
|
|
est_print_time = self.mcu.estimated_print_time(eventtime)
|
|
|
|
if est_print_time < self.idle_flush_print_time:
|
|
|
|
self.print_stall += 1
|
|
|
|
self.idle_flush_print_time = 0.
|
2019-06-26 02:32:33 +02:00
|
|
|
# Transition from "Flushed"/"Priming" state to "Priming" state
|
|
|
|
self.special_queuing_state = "Priming"
|
|
|
|
self.need_check_stall = -1.
|
2017-02-06 20:07:55 +01:00
|
|
|
self.reactor.update_timer(self.flush_timer, eventtime + 0.100)
|
|
|
|
# Check if there are lots of queued moves and stall if so
|
2016-12-09 15:41:46 +01:00
|
|
|
while 1:
|
2017-09-12 18:24:44 +02:00
|
|
|
est_print_time = self.mcu.estimated_print_time(eventtime)
|
|
|
|
buffer_time = self.print_time - est_print_time
|
2016-12-09 15:41:46 +01:00
|
|
|
stall_time = buffer_time - self.buffer_time_high
|
|
|
|
if stall_time <= 0.:
|
|
|
|
break
|
2019-11-08 00:06:46 +01:00
|
|
|
if not self.can_pause:
|
2017-09-12 18:24:44 +02:00
|
|
|
self.need_check_stall = self.reactor.NEVER
|
2016-12-09 15:41:46 +01:00
|
|
|
return
|
2017-09-12 18:24:44 +02:00
|
|
|
eventtime = self.reactor.pause(eventtime + min(1., stall_time))
|
2019-06-26 02:32:33 +02:00
|
|
|
if not self.special_queuing_state:
|
|
|
|
# In main state - defer stall checking until needed
|
2019-06-09 18:35:54 +02:00
|
|
|
self.need_check_stall = (est_print_time + self.buffer_time_high
|
|
|
|
+ 0.100)
|
2016-12-09 15:41:46 +01:00
|
|
|
def _flush_handler(self, eventtime):
|
2016-09-19 19:18:55 +02:00
|
|
|
try:
|
|
|
|
print_time = self.print_time
|
2017-09-12 18:24:44 +02:00
|
|
|
buffer_time = print_time - self.mcu.estimated_print_time(eventtime)
|
2016-09-19 19:18:55 +02:00
|
|
|
if buffer_time > self.buffer_time_low:
|
2017-02-06 20:07:55 +01:00
|
|
|
# Running normally - reschedule check
|
2016-09-19 19:18:55 +02:00
|
|
|
return eventtime + buffer_time - self.buffer_time_low
|
2017-02-06 20:07:55 +01:00
|
|
|
# Under ran low buffer mark - flush lookahead queue
|
2019-11-14 05:34:21 +01:00
|
|
|
self.flush_step_generation()
|
2016-09-19 19:18:55 +02:00
|
|
|
if print_time != self.print_time:
|
2018-01-12 22:24:47 +01:00
|
|
|
self.idle_flush_print_time = self.print_time
|
2016-09-19 19:18:55 +02:00
|
|
|
except:
|
|
|
|
logging.exception("Exception in flush_handler")
|
2017-10-12 21:15:14 +02:00
|
|
|
self.printer.invoke_shutdown("Exception in flush_handler")
|
2017-02-06 20:07:55 +01:00
|
|
|
return self.reactor.NEVER
|
2016-07-07 21:52:44 +02:00
|
|
|
# Movement commands
|
|
|
|
def get_position(self):
|
|
|
|
return list(self.commanded_pos)
|
2018-01-17 00:58:41 +01:00
|
|
|
def set_position(self, newpos, homing_axes=()):
|
2019-11-14 05:34:21 +01:00
|
|
|
self.flush_step_generation()
|
2021-07-23 18:46:14 +02:00
|
|
|
ffi_main, ffi_lib = chelper.get_ffi()
|
|
|
|
ffi_lib.trapq_set_position(self.trapq, self.print_time,
|
|
|
|
newpos[0], newpos[1], newpos[2])
|
2016-07-07 21:52:44 +02:00
|
|
|
self.commanded_pos[:] = newpos
|
2018-01-17 00:58:41 +01:00
|
|
|
self.kin.set_position(newpos, homing_axes)
|
2020-08-17 04:02:23 +02:00
|
|
|
self.printer.send_event("toolhead:set_position")
|
2016-12-01 04:34:38 +01:00
|
|
|
def move(self, newpos, speed):
|
2017-01-14 18:41:49 +01:00
|
|
|
move = Move(self, self.commanded_pos, newpos, speed)
|
2016-10-26 01:11:05 +02:00
|
|
|
if not move.move_d:
|
|
|
|
return
|
2016-12-28 17:48:40 +01:00
|
|
|
if move.is_kinematic_move:
|
|
|
|
self.kin.check_move(move)
|
2016-10-26 01:11:05 +02:00
|
|
|
if move.axes_d[3]:
|
2016-09-30 20:47:45 +02:00
|
|
|
self.extruder.check_move(move)
|
2018-09-11 19:45:33 +02:00
|
|
|
self.commanded_pos[:] = move.end_pos
|
2016-07-07 21:52:44 +02:00
|
|
|
self.move_queue.add_move(move)
|
2016-12-09 15:41:46 +01:00
|
|
|
if self.print_time > self.need_check_stall:
|
|
|
|
self._check_stall()
|
2020-08-17 04:43:03 +02:00
|
|
|
def manual_move(self, coord, speed):
|
|
|
|
curpos = list(self.commanded_pos)
|
|
|
|
for i in range(len(coord)):
|
|
|
|
if coord[i] is not None:
|
|
|
|
curpos[i] = coord[i]
|
|
|
|
self.move(curpos, speed)
|
|
|
|
self.printer.send_event("toolhead:manual_move")
|
2019-06-27 19:17:03 +02:00
|
|
|
def dwell(self, delay):
|
2019-10-29 23:58:45 +01:00
|
|
|
next_print_time = self.get_last_move_time() + max(0., delay)
|
|
|
|
self._update_move_time(next_print_time)
|
2019-06-27 19:17:03 +02:00
|
|
|
self._check_stall()
|
2016-12-29 03:24:12 +01:00
|
|
|
def wait_moves(self):
|
2017-02-11 20:43:36 +01:00
|
|
|
self._flush_lookahead()
|
2017-02-06 19:31:34 +01:00
|
|
|
eventtime = self.reactor.monotonic()
|
2019-06-26 02:32:33 +02:00
|
|
|
while (not self.special_queuing_state
|
2017-09-12 18:24:44 +02:00
|
|
|
or self.print_time >= self.mcu.estimated_print_time(eventtime)):
|
2019-11-08 00:06:46 +01:00
|
|
|
if not self.can_pause:
|
|
|
|
break
|
2016-12-29 03:24:12 +01:00
|
|
|
eventtime = self.reactor.pause(eventtime + 0.100)
|
2019-11-13 17:02:26 +01:00
|
|
|
def set_extruder(self, extruder, extrude_pos):
|
2017-04-29 20:56:39 +02:00
|
|
|
self.extruder = extruder
|
|
|
|
self.commanded_pos[3] = extrude_pos
|
2018-05-20 18:52:19 +02:00
|
|
|
def get_extruder(self):
|
|
|
|
return self.extruder
|
2019-10-29 23:58:45 +01:00
|
|
|
# Homing "drip move" handling
|
|
|
|
def _update_drip_move_time(self, next_print_time):
|
2019-09-18 04:53:17 +02:00
|
|
|
flush_delay = DRIP_TIME + self.move_flush_time + self.kin_flush_delay
|
2019-10-29 23:58:45 +01:00
|
|
|
while self.print_time < next_print_time:
|
|
|
|
if self.drip_completion.test():
|
|
|
|
raise DripModeEndSignal()
|
|
|
|
curtime = self.reactor.monotonic()
|
|
|
|
est_print_time = self.mcu.estimated_print_time(curtime)
|
2019-09-18 04:53:17 +02:00
|
|
|
wait_time = self.print_time - est_print_time - flush_delay
|
2019-11-08 00:06:46 +01:00
|
|
|
if wait_time > 0. and self.can_pause:
|
2019-10-29 23:58:45 +01:00
|
|
|
# Pause before sending more steps
|
|
|
|
self.drip_completion.wait(curtime + wait_time)
|
|
|
|
continue
|
|
|
|
npt = min(self.print_time + DRIP_SEGMENT_TIME, next_print_time)
|
|
|
|
self._update_move_time(npt)
|
2020-02-19 17:38:11 +01:00
|
|
|
def drip_move(self, newpos, speed, drip_completion):
|
2021-03-30 03:06:36 +02:00
|
|
|
self.dwell(self.kin_flush_delay)
|
2019-11-15 00:32:24 +01:00
|
|
|
# Transition from "Flushed"/"Priming"/main state to "Drip" state
|
|
|
|
self.move_queue.flush()
|
2019-06-26 03:25:01 +02:00
|
|
|
self.special_queuing_state = "Drip"
|
|
|
|
self.need_check_stall = self.reactor.NEVER
|
|
|
|
self.reactor.update_timer(self.flush_timer, self.reactor.NEVER)
|
2019-11-15 00:32:24 +01:00
|
|
|
self.move_queue.set_flush_time(self.buffer_time_high)
|
|
|
|
self.idle_flush_print_time = 0.
|
2020-02-19 17:38:11 +01:00
|
|
|
self.drip_completion = drip_completion
|
2019-10-29 23:58:45 +01:00
|
|
|
# Submit move
|
|
|
|
try:
|
|
|
|
self.move(newpos, speed)
|
2020-09-04 17:49:43 +02:00
|
|
|
except self.printer.command_error as e:
|
2019-11-14 05:34:21 +01:00
|
|
|
self.flush_step_generation()
|
2019-10-29 23:58:45 +01:00
|
|
|
raise
|
|
|
|
# Transmit move in "drip" mode
|
2019-06-26 03:25:01 +02:00
|
|
|
try:
|
|
|
|
self.move_queue.flush()
|
|
|
|
except DripModeEndSignal as e:
|
|
|
|
self.move_queue.reset()
|
2021-07-19 17:12:58 +02:00
|
|
|
self.trapq_finalize_moves(self.trapq, self.reactor.NEVER)
|
2019-11-15 00:32:24 +01:00
|
|
|
# Exit "Drip" state
|
2019-11-14 05:34:21 +01:00
|
|
|
self.flush_step_generation()
|
2017-02-06 20:07:55 +01:00
|
|
|
# Misc commands
|
2018-02-05 19:52:05 +01:00
|
|
|
def stats(self, eventtime):
|
2017-08-14 17:46:35 +02:00
|
|
|
for m in self.all_mcus:
|
|
|
|
m.check_active(self.print_time, eventtime)
|
2018-02-05 19:52:05 +01:00
|
|
|
buffer_time = self.print_time - self.mcu.estimated_print_time(eventtime)
|
2019-06-26 02:32:33 +02:00
|
|
|
is_active = buffer_time > -60. or not self.special_queuing_state
|
2019-11-15 18:21:23 +01:00
|
|
|
if self.special_queuing_state == "Drip":
|
|
|
|
buffer_time = 0.
|
2018-02-05 19:52:05 +01:00
|
|
|
return is_active, "print_time=%.3f buffer_time=%.3f print_stall=%d" % (
|
|
|
|
self.print_time, max(buffer_time, 0.), self.print_stall)
|
2018-10-18 18:04:50 +02:00
|
|
|
def check_busy(self, eventtime):
|
|
|
|
est_print_time = self.mcu.estimated_print_time(eventtime)
|
|
|
|
lookahead_empty = not self.move_queue.queue
|
|
|
|
return self.print_time, est_print_time, lookahead_empty
|
2018-02-21 02:50:06 +01:00
|
|
|
def get_status(self, eventtime):
|
2018-07-13 01:07:54 +02:00
|
|
|
print_time = self.print_time
|
|
|
|
estimated_print_time = self.mcu.estimated_print_time(eventtime)
|
2019-11-25 01:16:21 +01:00
|
|
|
res = dict(self.kin.get_status(eventtime))
|
2020-08-15 17:23:50 +02:00
|
|
|
res.update({ 'print_time': print_time,
|
2021-04-10 02:44:27 +02:00
|
|
|
'stalls': self.print_stall,
|
2019-11-25 01:16:21 +01:00
|
|
|
'estimated_print_time': estimated_print_time,
|
|
|
|
'extruder': self.extruder.get_name(),
|
2021-01-08 17:52:28 +01:00
|
|
|
'position': self.Coord(*self.commanded_pos),
|
2020-08-01 17:21:41 +02:00
|
|
|
'max_velocity': self.max_velocity,
|
|
|
|
'max_accel': self.max_accel,
|
|
|
|
'max_accel_to_decel': self.requested_accel_to_decel,
|
|
|
|
'square_corner_velocity': self.square_corner_velocity})
|
2019-11-25 01:16:21 +01:00
|
|
|
return res
|
2019-01-08 15:15:40 +01:00
|
|
|
def _handle_shutdown(self):
|
2019-11-08 00:06:46 +01:00
|
|
|
self.can_pause = False
|
2019-01-08 15:15:40 +01:00
|
|
|
self.move_queue.reset()
|
2017-12-06 15:59:00 +01:00
|
|
|
def get_kinematics(self):
|
|
|
|
return self.kin
|
2019-10-27 23:50:53 +01:00
|
|
|
def get_trapq(self):
|
|
|
|
return self.trapq
|
2019-11-07 16:59:35 +01:00
|
|
|
def register_step_generator(self, handler):
|
|
|
|
self.step_generators.append(handler)
|
2019-09-18 04:53:17 +02:00
|
|
|
def note_step_generation_scan_time(self, delay, old_delay=0.):
|
|
|
|
self.flush_step_generation()
|
|
|
|
cur_delay = self.kin_flush_delay
|
|
|
|
if old_delay:
|
|
|
|
self.kin_flush_times.pop(self.kin_flush_times.index(old_delay))
|
|
|
|
if delay:
|
|
|
|
self.kin_flush_times.append(delay)
|
2020-02-25 18:54:55 +01:00
|
|
|
new_delay = max(self.kin_flush_times + [SDS_CHECK_TIME])
|
2019-09-18 04:53:17 +02:00
|
|
|
self.kin_flush_delay = new_delay
|
2020-01-03 01:32:10 +01:00
|
|
|
def register_lookahead_callback(self, callback):
|
|
|
|
last_move = self.move_queue.get_last()
|
|
|
|
if last_move is None:
|
|
|
|
callback(self.get_last_move_time())
|
|
|
|
return
|
|
|
|
last_move.timing_callbacks.append(callback)
|
2019-11-24 16:59:13 +01:00
|
|
|
def note_kinematic_activity(self, kin_time):
|
|
|
|
self.last_kin_move_time = max(self.last_kin_move_time, kin_time)
|
2017-09-03 21:17:02 +02:00
|
|
|
def get_max_velocity(self):
|
|
|
|
return self.max_velocity, self.max_accel
|
2018-07-08 20:08:21 +02:00
|
|
|
def _calc_junction_deviation(self):
|
|
|
|
scv2 = self.square_corner_velocity**2
|
|
|
|
self.junction_deviation = scv2 * (math.sqrt(2.) - 1.) / self.max_accel
|
2018-10-02 04:02:33 +02:00
|
|
|
self.max_accel_to_decel = min(self.requested_accel_to_decel,
|
|
|
|
self.max_accel)
|
2020-08-16 20:40:04 +02:00
|
|
|
def cmd_G4(self, gcmd):
|
|
|
|
# Dwell
|
|
|
|
delay = gcmd.get_float('P', 0., minval=0.) / 1000.
|
|
|
|
self.dwell(delay)
|
|
|
|
def cmd_M400(self, gcmd):
|
|
|
|
# Wait for current moves to finish
|
|
|
|
self.wait_moves()
|
2018-04-21 04:13:29 +02:00
|
|
|
cmd_SET_VELOCITY_LIMIT_help = "Set printer velocity limits"
|
2020-04-25 01:54:24 +02:00
|
|
|
def cmd_SET_VELOCITY_LIMIT(self, gcmd):
|
2021-08-31 19:37:48 +02:00
|
|
|
max_velocity = gcmd.get_float('VELOCITY', None, above=0.)
|
|
|
|
max_accel = gcmd.get_float('ACCEL', None, above=0.)
|
2020-04-25 01:54:24 +02:00
|
|
|
square_corner_velocity = gcmd.get_float(
|
2021-08-31 19:37:48 +02:00
|
|
|
'SQUARE_CORNER_VELOCITY', None, minval=0.)
|
|
|
|
requested_accel_to_decel = gcmd.get_float(
|
|
|
|
'ACCEL_TO_DECEL', None, above=0.)
|
|
|
|
if max_velocity is not None:
|
|
|
|
self.max_velocity = max_velocity
|
|
|
|
if max_accel is not None:
|
|
|
|
self.max_accel = max_accel
|
|
|
|
if square_corner_velocity is not None:
|
|
|
|
self.square_corner_velocity = square_corner_velocity
|
|
|
|
if requested_accel_to_decel is not None:
|
|
|
|
self.requested_accel_to_decel = requested_accel_to_decel
|
2018-07-08 20:08:21 +02:00
|
|
|
self._calc_junction_deviation()
|
2018-04-21 04:13:29 +02:00
|
|
|
msg = ("max_velocity: %.6f\n"
|
|
|
|
"max_accel: %.6f\n"
|
|
|
|
"max_accel_to_decel: %.6f\n"
|
2021-08-31 19:37:48 +02:00
|
|
|
"square_corner_velocity: %.6f" % (
|
2020-09-21 21:52:49 +02:00
|
|
|
self.max_velocity, self.max_accel,
|
|
|
|
self.requested_accel_to_decel,
|
|
|
|
self.square_corner_velocity))
|
2018-04-21 04:13:29 +02:00
|
|
|
self.printer.set_rollover_info("toolhead", "toolhead: %s" % (msg,))
|
2021-08-31 19:37:48 +02:00
|
|
|
if (max_velocity is None and
|
|
|
|
max_accel is None and
|
|
|
|
square_corner_velocity is None and
|
|
|
|
requested_accel_to_decel is None):
|
|
|
|
gcmd.respond_info(msg, log=False)
|
2020-04-25 01:54:24 +02:00
|
|
|
def cmd_M204(self, gcmd):
|
|
|
|
# Use S for accel
|
|
|
|
accel = gcmd.get_float('S', None, above=0.)
|
|
|
|
if accel is None:
|
2018-09-02 18:22:43 +02:00
|
|
|
# Use minimum of P and T for accel
|
2020-04-25 01:54:24 +02:00
|
|
|
p = gcmd.get_float('P', None, above=0.)
|
|
|
|
t = gcmd.get_float('T', None, above=0.)
|
|
|
|
if p is None or t is None:
|
|
|
|
gcmd.respond_info('Invalid M204 command "%s"'
|
|
|
|
% (gcmd.get_commandline(),))
|
|
|
|
return
|
|
|
|
accel = min(p, t)
|
2021-04-25 20:58:44 +02:00
|
|
|
self.max_accel = accel
|
2018-07-08 20:08:21 +02:00
|
|
|
self._calc_junction_deviation()
|
2017-04-29 19:57:02 +02:00
|
|
|
|
2018-07-13 04:26:32 +02:00
|
|
|
def add_printer_objects(config):
|
|
|
|
config.get_printer().add_object('toolhead', ToolHead(config))
|
2018-07-13 04:15:45 +02:00
|
|
|
kinematics.extruder.add_printer_objects(config)
|