During normal printing the host software would attempt to stay ahead
of the micro-controller by 2 full seconds. Change that time to 1
second. This should make the software more responsive to user
requests (such as pause requests).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The current code is likely to perform a lazy flush of the lookahead
queue around 4 times a second. Increase that to around 6-7 times a
second. This change may slightly improve the responsiveness to user
requests mid-print (eg, changing extrusion ratio) and may make a
"print stall" less likely in some corner cases.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Normally the toolhead code will flush the lookahead buffer every
~250ms and will briefly pause to avoid buffering too much data. That
pause allows other tasks to run. Make sure to periodically yield to
other tasks on each lookahead buffer flush even if a delay isn't
needed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
After a toolhead dwell, there is no reason to enter the priming state
and to create the priming exiration timer.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The code currently adds an additional 100ms to BUFFER_TIME_HIGH in
_check_pause() to reduce the number of calls to _check_pause().
However, LOOKAHEAD_FLUSH_TIME should already provide sufficient
batching so adding more is not necessary. This change should
hopefully make configuring BUFFER_TIME_HIGH a little more transparent.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Due to differences in mcu clock vs system clock it's possible to
repeatedly underestimate a system delay needed to bring about a
sufficient mcu time - which just wastes cpu cycles retrying a pause.
It's okay to sleep a slightly longer time to avoid the issue.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Previously the code would always keep at least 2 items on the
lookahead queue after a "lazy" flush. In most cases it's okay to
leave only a single item. Update the code to better handle flushing
of items that are fully ready.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Replace "delayed" storage with a full pass through the queue. This
simplifies the lookahead processing logic.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid using "smoothed" and "accel_to_decel" for variables associated
with minimum_cruise_ratio. Instead introduce the prefix "mcr" for use
with these variables.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 7ea5f5d2 changed how the lookahead queue is flushed.
Previously, the main flush timer would always run while the toolhead
was considered in an active state (print_time). After that commit,
the flush timer could sleep if there were no steps generated (no call
to note_mcu_movequeue_activity() ). This could lead to a situation
where a G4 command (or series of commands) could cause the toolhead to
be considered in an active state while the flush timer was disabled.
The result was that a future command may not be properly flushed (the
toolhead would fail to transition to a "Priming" state).
Fix by ensuring that all dwell() requests fully flush the lookahead
queue.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't rely on an exact floating point number match to detect when a
forced lookahead flush is needed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't tie the step generation logic to the toolhead lookahead logic.
Instead, use regular timers to generate steps with a goal of staying
500-750ms ahead of the micro-controllers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a new is_runout parameter to _flush_lookahead() and use that in
places that could set check_stall_time.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Remove the toolhead note_step_generation_scan_time() code and
automatically detect the itersolve scan windows that are in use.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move low-level step generation timing code to the motion_queing
module. This helps simplify the toolhead module. It also helps
centralize the step generation code into the motion_queing module.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move the code that implements flushing in waves from
_advance_move_time() to _advance_flush_time(). This also separates
print_time tracking from the _advance_flush_time() implementation.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Automatically add kin_flush_delay to the requested flush time if
is_step_gen=True. This simplifies the callers.
Also, rename self.step_gen_time to self.need_step_gen_time.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 3d3b87f9 renamed last_sg_flush_time to min_restart_time to
ensure that flush_step_generation() would fully flush out moves
generated from the force_move module. However, now that force_move
calls note_mcu_movequeue_activity() with is_step_gen=True, this is no
longer necessary.
Rework min_restart_time to last_step_gen_time.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit f8da8099 incorrectly changed the order of variables in the
log/response message of the SET_VELOCITY_LIMIT command. Restore the
correct order.
Reported by @berkakinci.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move code from flush_steppersync() to existing flush_motion_queues()
and clean_motion_queues() functions.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add an allocate_trapq() helper function to facilitate the creation of
a low-level C trapq object. Track all trapq objects and clear history
on them globally when the main motion queues are flushed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Create a new module to assist with host management of motion queues.
Register all MCU_stepper objects with this module and use the module
for step generation.
All steppers will now automatically generate steps whenever
toolhead._advance_flush_time() is invoked. It is no longer necessary
for callers to individually call stepper.generate_steps().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Change note_mcu_movequeue_activity() to default to setting the
step_gen_time (instead of the previous default to not set it).
Most users of the mcu "move queue" will be for stepper activity.
There is also little harm in incrementing the tracking of the last
possible step generation time, but accidentally generating a step
without incrementing the tracking can lead to very hard to debug
failures.
The two cases (output_pin.py and pwm_tool.py) where
note_mcu_movequeue_activity() is called and definitely not related to
step generation can explicitly pass 'is_step_gen=False'.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move the g-code command handlers to a new class. This reduces the
size of the main Toolhead() class.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a new add_extra_axes() to support adding additional axes. Once
called, toolhead.get_position() will return a list object with more
than 4 items, and toolhead.move() requires the same size list.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's not valid to alter the extruder position from a call to
set_position(), so don't allow callers to attempt that.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Currently, `MANUAL_STEPPER STOP_ON_ENDSTOP=1` type commands will move
until hitting the endstop, but it will still always consume the total
amount of move time. That is, following moves can't be started until
the total possible time of the homing move is completed.
Implement "drip moves" so that the code only schedules the movement in
small segments. This allows following movements to be scheduled
without a significant delay.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implement move checking and trapq loading directly from drip_move().
This simplifies the interactions between these components.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid lookahead.flush() calling back into toolhead._process_moves().
Instead, rename toolhead._process_moves() to
toolhead._process_lookahead(), have it call lookahead.flush(), and
consistently use it when flushing the lookahead queue.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This significantly reduces the amount of data in the generation 2 garbage collection bucket from the initial startup of klipper.
Signed-off-by: Branden Cash <203336+ammmze@users.noreply.github.com>
Use strings such as "xyz" to specify which axes are to be considered
homing during a set_position() call. This makes the parameter a
little less cryptic.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>