Update functions could be called within the flush/lookahead context
If the update function internally does pause()
That would lead to the unpredictable execution of time-critical functions
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
It is not valid to pause in the klippy:ready callback, so perform the
sensor startup process in a separate reactor task.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Determine which mcu raised the shutdown from the shutdown details
report. Also, pass shutdown_clock via that details report.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move reactor debugging info from main klippy.py code to error_mcu code
for improved exception handling.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename the event to make it a little more clear what it is intended
for. Also, check for an exception in each event handler.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Step timing is reset when stepper.set_position() is called. Detect
that case and ensure future steps after set_position start on a new
block. This simplifies the timing for users of the data.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that trapq_extract_old() can return upcoming moves, it's possible
for homing to cause confusing results (as these moves can end early).
Avoid this by delaying query responses until after homing completes.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Batch reading of 8 samples (48 bytes) at a time from the sensor. This
reduces the number of transactions - which can notably improve
performance on i2c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
Fix inverted check for fifo empty. The fifo is empty when the number
of entries in the fifo is zero.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
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>
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>
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>
The change removes the shapers defined there in favor of the
standard ones and makes the script a lot more configurable
via command-line arguments.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>