Commit Graph

5860 Commits

Author SHA1 Message Date
Kevin O'Connor
b60804bb66 trapq: Set the head sentinel to a negative print_time
If a stepper kinematics has a "scan window" defined during its first
flush then the iterative solver may walk past the head sentinel.  Set
a small negative print_time for the head sentinel to avoid this corner
case.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-12 22:41:30 -04:00
Kevin O'Connor
32bd03703b motion_queuing: Don't use lazy_target in drip_update_time()
Using separate flush_time and step_gen_time is a minor optimization.
Using it in drip_update_time() complicates the code and may reduce the
time needed to schedule post homing/probing movements.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-12 22:41:30 -04:00
Kevin O'Connor
3bed65f10f motion_queuing: Move remaining steppersync logic from mcu module
Move the last parts of the steppersync logic into the motion_queuing
module.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-12 22:41:30 -04:00
Kevin O'Connor
22db9bb84e motion_queuing: Require explicit notification on a scan window change
Don't try to infer when the step generation scan window may change.
Instead, require the input_shaper and pressure_advance code call
motion_queuing.check_step_generation_scan_windows() any time a
scanning window may change.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-12 22:41:30 -04:00
Kevin O'Connor
cde57bdcfd toolhead: Set check_stall_time from _flush_lookahead()
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>
2025-09-12 22:41:30 -04:00
Kevin O'Connor
bb88985b8d reactor: Unify handling of fd events
The SelectReactor has a different event dispatch system from the
PollReactor and EPollReactor.  However, in practice the PollReactor
code is always used, so there is no reason to maintain a different
implementation for SelectReactor.  Rework the code so that
SelectReactor file dispatch handling is done the same way as
PollReactor (and EPollReactor).  This simplfiies the code.

Introduce a new _check_fds() method that is shared between Reactor
implementations.

Also, fix some cut-and-paste bugs in SelectReactor and EPollReactor.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-10 21:31:17 -04:00
Kevin O'Connor
a89694ac68 stepcompress: Generate steps in a per-stepper background thread
Create a thread for each stepper and use it for step generation and
step compression.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-07 20:50:41 -04:00
Kevin O'Connor
96c3ca160e gcode: Fix out-of-order check for M112 when read from gcode pseudo-tty
Make sure to check for an out-of-order M112 command on the gcode
pseudo-tty even if there is no pending commands being processed from
that gcode pseudo-tty.  There could be long running commands pending
from webhooks, virtual_sdcard, or similar.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-06 14:06:25 -04:00
Kevin O'Connor
68b67a16d6 display: Check for redraw_request_pending at end of screen_update_event()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-05 12:40:32 -04:00
Kevin O'Connor
aa59b32031 reactor: Prevent update_timer() from running a single timer multiple times
The "lazy" greenlet implementation could allow the same timer to run
multiple times in parallel if the first timer instance calls pause()
and another task calls update_timer().  This is confusing and can
cause hard to debug errors.  Add a new timer_is_running flag to
prevent it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-05 12:40:32 -04:00
Kevin O'Connor
6c1a4a825d docs: Note filemant_motion_sensor can be associated with extruder_stepper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-04 14:21:47 -04:00
Timofey Titovets
58e179d128 filament_motion_sensor: define tests
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-09-04 14:20:25 -04:00
Timofey Titovets
93ea9ddfa9 extruder_stepper: define missing public methods methods
Other modules could access the extruderN by
the printer lookup_object().
That would return this wrapper class.

Specifically, filament_motion_sensor will.
They can try to access missing methods
and klippy would crash.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-09-04 14:20:25 -04:00
Kevin O'Connor
8a833175a5 motion_queuing: Introduce flush_all_steps() helper
Move the "full flush" code from advance_flush_time() to a new
flush_all_steps() method.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-03 12:07:24 -04:00
Kevin O'Connor
5426943501 motion_queuing: Automatically detect changes to kin_flush_delay
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>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
d1974c0d3d motion_queuing: Move flushing logic from toolhead to motion_queuing module
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>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
8c13811c3b toolhead: Avoid using print_time when calling mcu.check_active()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
db5cbe56d3 toolhead: Do not modify print_time in drip_update_time()
Implement drip_update_time() using _advance_flush_time() instead of
_advance_move_time().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
872615cfcf toolhead: Add new _calc_step_gen_restart() helper
Separate out step generation specific handling from _calc_print_time()
code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
4b9a0b4f82 toolhead: Separate lookahead timer flushing to new _check_flush_lookahead()
Separate out the lookahead specific flushing logic from the
_flush_handler() code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
a64207aac3 toolhead: Implement flush "waves" in _advance_flush_time()
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>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
b0a642a8ea toolhead: Add kin_flush_delay in note_mcu_movequeue_activity()
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>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
1e7c67919e toolhead: Rework min_restart_time to last_step_gen_time
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>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
a5218619b7 motion_queuing: Track kin_flush_delay locally
Track the kin_flush_delay in both toolhead.py and motion_queuing.py .

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-03 12:00:31 -04:00
Kevin O'Connor
5056e1031c stepper_enable: Improve timing of manual stepper enable/disable commands
Invoke flush_step_generation() prior to checking motor enable state as
this is the best way to ensure all stepper active callbacks have been
invoked (which could change the enable line state).

Also, there is no longer a reason to add additional toolhead dwells
when enabling a stepper motor.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-03 11:58:35 -04:00
Kevin O'Connor
1f14e950e7 stepper_enable: Unify explicit stepper enable/disable code
There were several slightly different implementations of explicit
stepper motor enabling/disabling in the force_move, stepper_enable,
and manual_stepper modules.  Introduce a new set_motors_enable()
method and use this in all implementations.  This simplifies the code
and reduces the chance of obscure timing issues.

This fixes a manual_stepper error introduced in commit 9399e738.  That
commit changed the manual_stepper class to no longer explicitly flush
and clear all steps after each move, which broke the expectations of
manual_stepper's custom enable code.  Using the more robust
implementation in stepper_enable fixes that issue.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-03 11:57:58 -04:00
Timofey Titovets
77d4cdbae4 pyhelper: drop linux/prctl header for compability with musl
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-09-03 11:44:10 -04:00
Kevin O'Connor
20d9c84a9f toolhead: Fix incorrect response message in SET_VELOCITY_LIMIT
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>
2025-09-01 21:20:00 -04:00
Kevin O'Connor
e4c66452dc temperature_probe: Fix python2 incompatibility
It seems python2 string.split() method does not accept a "maxsplit"
parameter.  Use a format compatible with both python2 and python3.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-31 16:02:44 -04:00
JamesH1978
bab5f8031c docs: Update FAQ.md - Recomendation adjustment (#7025)
This doc still says the Pi 2 is an option for Klipper, in this day and age, i am not sure it is. From anecdotal evidence, the lowest pi recommended should be the zero2w. I also changed the wording and removed some Octoprint wording in that section to better reflect how things are today, as i don't think even with virtual_sdcard these older devices will keep up.

Signed-off-by: James Hartley <james@hartleyns.com>
2025-08-31 14:26:15 -04:00
Kevin O'Connor
179a56ce92 gcode_move: Fix M114 when extra axes are defined
Commit d40fd219 added support for defining extra axes, however that
change could break the M114 command.  Update the code to fix M114.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-31 12:19:43 -04:00
Kevin O'Connor
3aadda6fb3 mcu: Disable waiting in send_wait_ack() if in debugging mode
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-22 16:53:34 -04:00
Timofey Titovets
159b71e51e bus: drop obsolete i2c_write_wait_ack
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-22 16:44:54 -04:00
Timofey Titovets
718be7c6a3 sht3x: drop obsolete i2c_write_wait_ack
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-22 16:44:54 -04:00
Timofey Titovets
eb7bdf18ad bme280: drop obsolete i2c_write_wait_ack
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-22 16:44:54 -04:00
Timofey Titovets
fe44dd8baa bus: make i2c_write syncronous
When we introduce the host-side status check,
it will be synchronous.
There would be no sense in having an asynchronous call.
Preliminary migrate callers to synchronous call.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-22 16:44:54 -04:00
Kevin O'Connor
ae010215e7 chelper: Build library first in temporary file and then rename
Try to avoid cases where an incomplete library build causes confusing
future failures.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-22 16:34:45 -04:00
Timofey Titovets
eec81683eb bus: move early i2c writes to the connect phase
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-22 14:57:28 -04:00
Timofey Titovets
1965298ab0 sx1509: init pwm pin on connect
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-22 14:57:28 -04:00
Timofey Titovets
9a1ac45d19 sx1509: migrate i2c write to connect phase
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-22 14:57:28 -04:00
minicx
b817848567 stm32: enable 64KiB bootloader for n32g45x, clarify Makefile output
- Allow selection of 64KiB bootloader offset for MACH_N32G45x in Kconfig

Signed-off-by: Lev Voronov <minicx@disroot.org>
Co-authored-by: Alexander Simonov <me@darksimpson.com>
2025-08-21 15:24:46 -04:00
minicx
3a11645afe stm32: Fix N32G45x ADC pin mapping (#7016)
Fixes PA0 (GPIO 0) incorrectly mapping to ADC1_IN0 due to
collision with placeholder zeros.

Signed-off-by: Lev Voronov <minicx@disroot.org>
Co-authored-by: Alexander Simonov <me@darksimpson.com>
2025-08-21 11:41:07 -04:00
C0co
7ed7791723 spi_flash: Update board_defs.py (#7006)
Added X-Smart3, X-Plus3 and X-Max3 mainboards

Signed-off-by: Phil Groenewold <philgroenewold@gmx.de>
2025-08-21 11:32:33 -04:00
Hendrik Poernama
3b68769ea5 tmc2240: Add OTW_OV_VTH to FieldFormatters (#6987)
This register is readable and contains the overvoltage and overtemp
threshold settings.

Signed-off-by: Hendrik Poernama <poernahi@gmail.com>
2025-08-21 09:33:31 -04:00
Kevin O'Connor
2ddfa32dd8 heaters: Reduce next_pwm_time window
Commit 0f94f6c8 decreased the MAX_HEAT_TIME from 5 seconds to 3
seconds.  However, that also decreased the amount of tolerance for
lost temperature updates from 1.25 seconds to 0.75 seconds.  With the
default temperature update every 300ms, only 2 consecutive missing
temperature updates could lead to a fault.

Tweak the internal "next_pwm_time" setting so that it is more tolerant
of two consecutive lost temperature updates.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-21 09:25:42 -04:00
Kevin O'Connor
371647109f test: Add a long move test to manual_stepper.test
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-20 16:47:32 -04:00
Kevin O'Connor
91b5e8e942 manual_stepper: Internally track commanded_pos
Commit 9399e738 changed the manual_stepper class to no longer
explicitly flush all steps after each move.  As a result, calls to
self.rail.get_commanded_position() may no longer reflect the last
requested position.  This discrepancy could result in "internal
stepcompress" errors.

Change the manual_stepper code to internally track the last requested
position and use that when scheduling moves.  This allows the
manual_stepper code to utilize the standard "lazy" step flushing
mechanism.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-20 16:41:41 -04:00
BIGTREETECH
d34d3b05b8 stm32: Add i2c2_PA7_PA6 and i2c3_PA7_PA6 for stm32g0 (#7007)
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
2025-08-15 13:43:43 -04:00
Kevin O'Connor
78462cff4c docs: Remove "relative_reference_index" documentation from Bed_Mesh.md
The "relative_reference_index" was deprecated on 20230619 and removed
on 20240215.  So, remove the last references from the documentation.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-15 12:57:19 -04:00
Timofey Titovets
edbfc6f856 resonance_tester: replace missing M204 call
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-14 15:10:13 -04:00