gcode_M600_filament_change_z_shift is almost useless, since it performs
what is already been done internally by filament_unload().
However it *does* cause the carriage to raise earlier during unload
compared to making the user wait after "press for unload".
Change it so the calculated Z height matches MIN_Z_FOR_SWAP.
This change restores the minimum extruder height for filament purge
during M600 from the current 50mm back to 27mm from FW 3.9.
We do this by introducing a new option for unload_filament() to indicate
that the unload is part of an automatic swap, and in such cases avoid
raising more than absolutely necessary (this will _also_ come in handy
to avoid the extra purge in PR #2318 during M600).
A new define MIN_Z_FOR_SWAP is introduced for this purpose.
MIN_Z_FOR_UNLOAD is still used for manual lcd unload and for M702 and
hasn't been changed.
If the printer was already being pre-heated but didn't reach the target
temperature yet and a new filament is being inserted, the LCD used to
display a "Preheating to load" message to block the loading until the
extruder is hot.
This message is currently missing, and the ">Cancel" option doesn't
display immediately either, depending on the extruder height.
This PR fixes this behavior, which was broken during an earlier update.
We now force-update LCD updates during the first (and _only_) time the
screen is setup, and push all messages _before_ the carriage is
eventually raised, so that ">Cancel" is shown immediately as well.
mesh_bed_leveling_flag and homing_flag should be set only when the
planner is empty as a consequence of #3100, since any operation executed
*while* the mbl/homing flag is set is considered part of the compound
instruction that generated it (G80, G28, G30, G76).
Failure in doing so can result in instructions just prior being lost,
since they're incorrectly discarded (assumed to be redone).
G1 ; lost ..
G80 ; .. if PP happens here
PR #2967 altered the way ``sdpos_atomic`` was set, causing issues in the
crashdetect/powerpanic recovery offset if the instruction being
recovered happens to contain a comment.
Previously ``sdpos`` was assumed to be a single byte prior to the last
read character. sdpos+1 would thus position the index to the next
instruction. With gcode-filtering in place, sdpos is left just before
the comment, while the actual read position is at the newline. This
causes to parser to resume in the middle of the comment.
Change the value returned by cardreader::get_sdpos() to always return
the last read position, as everybody expects (!!).
This avoids the +1, and correctly sets the resume position to the next
valid instruction without overhead.