Commit Graph

5944 Commits

Author SHA1 Message Date
Kevin O'Connor
af17c8c238 stm32: No need to special case GPIOI in spi.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-26 12:28:19 -04:00
Kevin O'Connor
6e73181c47 stm32: No need to special case GPIOI in stm32h7_spi.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-26 12:28:19 -04:00
Kevin O'Connor
870c0437e9 stm32: Verify pin is valid in gpio_peripheral()
Convert direct lookup of digital_regs[] to a new gpio_pin_to_regs()
function that first validates the pin.  This should help prevent
invalid memory accesses if an invalid pin is provided.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-26 12:28:19 -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
1da2e39b85 docs: Update Code_Overview.md with recent motion generation changes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 15:47:13 -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
56fb4d2b04 docs: Update Code_Overview.md to reflect recent steppersync changes
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
Kevin O'Connor
bd747872c3 steppersync: Add new 'struct steppersyncmgr'
Add a new C based mechanism for tracking all the 'struct steppersync'
instances.  This simplifies memory management.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 14:51:34 -04:00
Kevin O'Connor
a66f5cec52 msgblock: Add new clock_fill() function
Add a new function for filling the fields of 'struct clock_estimate'.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 14:51:34 -04:00
Kevin O'Connor
13cfdf5711 motion_queuing: Reorganize code into sections
Only code movement - no code changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-24 14:51:34 -04:00
Dmitry Butyugin
1c76ed1dc9 resonance_tester: Gracefully handle zero accelerations during the test
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-09-23 14:57:00 -04:00
Dmitry Butyugin
599dcd176c resonance_tester: Correctly handle incorrect accelerometer chip names
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-09-23 14:57:00 -04:00
Dmitry Butyugin
5da026a337 input_shaper: Updated definitions of *EI input shapers
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-09-22 15:18:01 -04:00
bigtreetech
1be6c0fce0 stm32: change GPIO_FUNCTION_ALL to SPI_FUNCTION
Signed-off-by: Alan.Ma from BigTreeTech tech@biqu3d.com
2025-09-19 12:19:15 -04:00
bigtreetech
61252819e3 stm32: Clean up SPI code on spi.c
Signed-off-by: Alan.Ma from BigTreeTech tech@biqu3d.com
2025-09-19 12:19:15 -04:00
bigtreetech
e8e88415ea stm32: Clean up SPI code on stm32h7_spi.c
Signed-off-by: Alan.Ma from BigTreeTech tech@biqu3d.com
2025-09-19 12:19:15 -04:00
Kevin O'Connor
8db5d254e0 docs: Update Code_Overview.md with recent motion_queuing changes
Update the documentation to reflect the new threads and new movement
code flow.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-16 12:17:47 -04:00
Kevin O'Connor
c7365c8c58 extruder: Recheck the step generation scan windows on sync_to_extruder()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-16 11:28:16 -04:00
Kevin O'Connor
636380e4f3 toolhead: Avoid numerical stability in _handle_step_flush() comparison
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>
2025-09-15 19:20:00 -04:00
Kevin O'Connor
df29a38011 motion_queuing: Further tune flushing in batches
Avoid unnecessary reactor wakeups if a batch is close to being ready.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-15 14:30:27 -04:00
Kevin O'Connor
4c46b80f38 motion_queuing: Further improve step flushing in batches
Further encourage flushing steps in batches by delaying flushing if a
batch isn't needed yet.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-15 14:19:02 -04:00
Kevin O'Connor
f341031834 motion_queuing: Try harder to use next_batch_time when flushing
Use the next_batch_time even if it is slightly past or before the
ideal flushing window.  This should improve run to run reproducibility
of flush timing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-15 13:46:35 -04:00
Kevin O'Connor
950aa103e4 motion_queuing: It is no longer necessary to loop in _advance_flush_time()
Now that the host code does not flush far into the future, it is no
longer necessary to flush in waves.  Integrate _advance_flush_time()
into _flush_motion_queues().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-12 22:41:30 -04:00
Kevin O'Connor
42d149b40f motion_queuing: Avoid flushing far into the future
If a flush_all_steps() request is for a time far in the future, then
wait for that time to become close prior to flushing steps.  This
avoids committing to a step schedule that is far in the future.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-09-12 22:41:30 -04:00
Kevin O'Connor
7ea5f5d25e motion_queuing: Generate steps from timer instead of from lookahead
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>
2025-09-12 22:41:30 -04:00
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