To maintain an accurate step count (which is required for correct
position recovery), any call to plan_set_position&co needs to be done
synchronously and from a halted state.
However, G92 E* is currently special-cased to skip the sync (likely to
avoid the associated performance cost), causing an incorrect E step
count and position to be set. This breaks absolute position recovery,
miscalculation of the LA factor and possibly other weird issues.
We rewrite the handling of G92 to always sync but still special-case the
frequent "G92 E0" for performance by using a free bit in the block flags.
To avoid a sync, we relay the request for reset first to the planner
which clears its internal state and then relays the request to the final
stepper isr.
When check_z_endstop is set, Z_MIN_PIN is checkend regardless of the
moving direction to support Z calibration. This prevents the ability
to use _just_ SG when moving upwards.
But since we know the extruder is at Z_MIN, it's always safe to raise
irregardless, so we can dodge the issue.
Do not unconditionally enqueue a Z move if no move has been requested.
Since Z is calculated using the absolute current (saved) position and
scheduled for later execution, the queue order becomes relevant.
In preparation for #2161, use MBL (G80) as a "new print" boundary
instead of just re-homing to ensure the reset is issued only once for
each print.
Similarly, do not reset the autodetection when LA is disabled via M900
K0. This can/will be used during a print if different quality settings
are used for different filling roles.
Since the advance factor is computed per-segment in LA15, there's no
need to stop the planner. Allow changing K freely at each segment.
This allows varying quality factors for different filling roles, see:
https://github.com/supermerill/Slic3r/issues/108
During pause/resume/crashdetect or powerpanic K might temporarily be out
of sync when used this way. If this becomes an issue, we might need to
store K for each block, as done for the feedrate.
Move the common checks between filament sensors out of fsensor_update().
Disable the runout check if a saved state is already present (this check
was missing in the PAT9125 variant) as this is currently not supported.
Note that the CHECK_FSENSOR looks completely redundant besides
e_active().
Do not set/clear fsensor_watch_runout within fsensor_oq_meassure_start
which is used outside of fsensor_update where it could have a different
starting value.
Set it within fsensor_stop_and_save_print to immediately prevent
re-entry.
Also check for fan_check_error == EFCE_OK in addition to EFCE_FIXED.
Reorganize the check in order to fix both #if[n]def FANCHECK cases,
as similarly done in the SDSUPPORT case a few lines below.
Allow existing gcode using LA10 to transparently take advantage of LA15
by using a simple linear conversion function based on experimental
results with the MK3 implementation of linear advance.
Autodetect LA10 values based on the first M900 instruction contained in
the print. In order to support printing mixed files without resetting
the printer we also reset the autodetection status when starting a new
SD print and/or when explicitly disabling LA.
Since we cannot reliably detect whether a new print is started when
printing via USB, also reset the detection status when homing in G28,
which is generally performed once at each print. Note that this doesn't
clear the previous K value, it only allows a subsequent M900 to provide
LA10 values when printed after a LA15 file.