Commit Graph

2983 Commits

Author SHA1 Message Date
Kevin O'Connor
84e9a28141 virtual_sdcard: Reduce pause time on busy detection
If there are other users of the gcode mutex then pause for 50ms
(instead of 100ms).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-10 11:07:50 -04:00
Kevin O'Connor
8de426d244 toolhead: Reduce target buffer time to 1 second from 2 seconds
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>
2025-10-10 11:07:50 -04:00
Kevin O'Connor
16fc46fe5f toolhead: Reduce LOOKAHEAD_FLUSH_TIME to 0.150 seconds
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>
2025-10-10 11:07:50 -04:00
Kevin O'Connor
50cb362234 toolhead: Make sure to periodically yield to other tasks when buffering moves
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>
2025-10-10 11:07:50 -04:00
Kevin O'Connor
4415b988c1 toolhead: Clarify priming timer scheduling
Make sure each command gets an additional 100ms before flushing via
the priming timer.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-10 11:07:50 -04:00
Kevin O'Connor
cba7a285e4 trapq: Extend trapq_extract_old() to also check active moves
Support extracting moves from both the "live" trapq->moves as well as
the "history" from trapq->history storage.  Now that moves are flushed
separately from the lookahead queue, there is a good chance that the
current move being processed on the mcus will still be in the active
trapq list.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-09 13:22:32 -04:00
Kevin O'Connor
b85b92fdfb toolhead: Don't enter "Priming" state on a dwell()
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>
2025-10-08 23:08:36 -04:00
Kevin O'Connor
7f177aad1a toolhead: Minor code movement
Move flushing and priming code together.  No code changes - only code
movement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-08 23:08:36 -04:00
Kevin O'Connor
3f9733d04d toolhead: Move priming logic from _check_pause() to new _check_priming_state()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-08 23:08:36 -04:00
Kevin O'Connor
8fd263ca69 toolhead: Add a lookahead.is_empty() helper function
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-08 23:08:36 -04:00
Kevin O'Connor
e87de2ae49 motion_queuing: Don't disable step+dir+step filter in drip_update_time()
Allow the step compress code to perform regular step+dir+step
filtering even during probing and homing actions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-08 20:11:40 -04:00
Kevin O'Connor
d55baaf265 bus: Additional devices require i2c_write_noack()
Currently, the LEDHelper() and GCodeRequestQueue() helper classes
require that their callbacks do not block.  As a result, the pca9533,
pca9632, and sx1509 devices need to use non-blocking i2c write calls.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-06 21:19:01 -04:00
Dmitry Butyugin
b7602ff969 input_shaper: Fixed initialization for dual_carriage
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-10-06 15:41:22 -04:00
Dmitry Butyugin
ec82cee7fc resonance_tester: Support testing resonances over Z axis
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-10-04 19:50:34 -04:00
Dmitry Butyugin
caf7accf2d input_shaper: Z-axis input shaper
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-10-04 19:50:34 -04:00
Kevin O'Connor
c49dbb5a87 trapq: Fix bug that broke numerical stability workaround for initial movement
Commit b60804bb changed the trapq head sentinel to store
print_time=-1.  However, it failed to update trapq_add_move() that
relied on that value to detect the head sentinel.  As a result,
numerical stability issues could lead to stepcompress errors.

Fix by changing trapq_add_move() to detect the head sentinel even with
a negative print_time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-04 19:35:41 -04:00
Dmitry Butyugin
768b19e8be input_shaper: Limit maximum damping_ratio of the shapers
Numerically optimized versions of *EI shapers have been tuned
for specific ranges of damping ratios and will show poor stability
outside of these designated ranges.

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-10-04 13:07:49 -04:00
Kevin O'Connor
0c86b388a9 toolhead: Remove extra batching time added in _check_pause()
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>
2025-10-03 13:13:56 -04:00
Kevin O'Connor
4cd786fe08 toolhead: Avoid pausing an infinitesimal amount of time
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>
2025-10-03 13:13:56 -04:00
Kevin O'Connor
a43846c277 mcu: Reorganize wrapper methods in main mcu class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
95f263fa59 mcu: Directly register "mcu_identify" handler in each helper class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
de73e41d0f mcu: Add new MCURestartHelper helper class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
64c155121e mcu: Add new MCUConfigHelper helper class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
1bb674d0b8 mcu: Add new MCUStatsHelper() helper class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
1668d6d7c6 mcu: Separate low-level connection handling to new MCUConnectHelper class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
b086349a9f mcu: Setup debugging estimated_print_time() in constructor
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
1e18f32914 mcu: Move registration of "starting" message to _post_attach_setup_shutdown()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
fcd9cefb3f mcu: Add _check_restart_on_xxx() helper methods
Breakout each of the possible restart cases into its own internal
method.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
ce55d41166 mcu: Split _mcu_identify() into separate methods
Split up the _mcu_identify() into several internal methods separated
by functionality.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
07466411ac mcu: Remove max_stepper_error config parameter
Use a regular code constant - MAX_STEPCOMPRESS_ERROR in stepper.py.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:28:38 -04:00
Kevin O'Connor
ea9c88526b klippy: Report Linux version in log
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-10-03 12:24:25 -04:00
Kevin O'Connor
35aeb78088 util: Strip all leading/trailing whitespace in get_device_info()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-30 21:40:21 -04:00
Kevin O'Connor
07c5973142 util: Introduce _try_read_file() helper
Introduce a helper function to read the contents of a file and use
that helper throughout util.py .

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-30 21:40:21 -04:00
Timofey Titovets
ac6f059cb9 util: use dmi data on x86 instead of device-tree
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-09-30 18:59:09 -04:00
Timofey Titovets
fe09e2e6bf klippy: track the device model
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-09-30 18:59:09 -04:00
Kevin O'Connor
6118525c19 toolhead: Allow more entries to flush from "lazy" lookahead flush
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>
2025-09-30 09:37:35 -04:00
Kevin O'Connor
41901ec382 toolhead: Simplify LookAheadQueue.flush() code
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>
2025-09-30 09:37:35 -04:00
Kevin O'Connor
ff8c8eab55 toolhead: Clarify internal minimum_cruise_ratio variable names
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>
2025-09-30 09:37:35 -04:00
Kevin O'Connor
184ba4080c toolhead: Flush lookahead on dwell - fix flushing bug after long delays
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>
2025-09-29 11:31:31 -04:00
Kevin O'Connor
30a1f22e1d motion_queuing: Improve run to run stability of flushing when in debug mode
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-26 12:27:26 -04:00
Timofey Titovets
8c7693c048 uc1701: allow non blocking i2c writes
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 19:33:37 -04:00
Kevin O'Connor
3c01f71d9e itersolve: Don't call trapq_check_sentinels() from itersolve_generate_steps()
Commit a89694ac changed the code to run itersolve_generate_steps()
from multiple threads simultaneously.  However,
trapq_check_sentinels() can modify the shared trapq object.  So,
calling it from multiple threads could introduce a race condition.

Move the call to trapq_check_sentinels() to steppersyncmgr_gen_steps()
to avoid the issue.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 18:58:31 -04:00
Kevin O'Connor
dfa666d9c1 stepcompress: Remove stepcompress_queue_msg()
Callers can use syncemitter_queue_msg() instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 15:07:25 -04:00
Kevin O'Connor
546976b1fe steppersync: Print the thread name on a stepcompress error
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 15:07:25 -04:00
Kevin O'Connor
414679ac99 steppersync: Move history clearing to background thread
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 15:07:25 -04:00
Kevin O'Connor
3ef4702e06 steppersync: Move step generation thread from stepcompress.c to steppersync.c
Implement step generation from 'struct syncemitter' instead of in the
stepcompress code.  This simplifies the stepcompress code and
simplifies the overall interface.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 15:07:25 -04:00
Kevin O'Connor
e78d11bc6f steppersync: Support sending messages directly from syncemitter
Move msg_queue allocation from stepcompress to syncemitter.  With this
change the pwm_tool module does not need to allocate a stepcompress
object.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 15:07:25 -04:00
Kevin O'Connor
d831d66c11 steppersync: Introduce new 'struct syncemitter'
Create a new 'struct syncemitter' for each object that can generate
messages for a 'struct steppersync' and store in a regular linked
list.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 15:07:25 -04:00
Kevin O'Connor
a29cfc1701 stepcompress: Pass oid in stepcompress_fill() instead of stepcompress_alloc()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 14:51:34 -04:00
Kevin O'Connor
f21cca049f steppersync: Add new steppersyncmgr_gen_steps() function
Generate and flush all the steppersync instances from a single
steppersyncmgr_gen_steps() call.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 14:51:34 -04:00