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>
Some Creality bootloaders skip flashing if the firmware filename is
unchanged. By appending a timestamp to the firmware filename during
sdcard upload, each update generates a unique name, ensuring that
the bootloader always accepts and flashes the new firmware.
Signed-off-by: Sezgin AÇIKGÖZ <sezginacikgoz@mail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>