Merge upstream changes from Marlin 2.1.1
This commit is contained in:
@@ -54,6 +54,10 @@ uint32_t PrintJobRecovery::cmd_sdpos, // = 0
|
||||
#include "../module/temperature.h"
|
||||
#include "../core/serial.h"
|
||||
|
||||
#if HOMING_Z_WITH_PROBE
|
||||
#include "../module/probe.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(FWRETRACT)
|
||||
#include "fwretract.h"
|
||||
#endif
|
||||
@@ -104,13 +108,18 @@ void PrintJobRecovery::changed() {
|
||||
*
|
||||
* If a saved state exists send 'M1000 S' to initiate job recovery.
|
||||
*/
|
||||
void PrintJobRecovery::check() {
|
||||
bool PrintJobRecovery::check() {
|
||||
//if (!card.isMounted()) card.mount();
|
||||
bool success = false;
|
||||
if (card.isMounted()) {
|
||||
load();
|
||||
if (!valid()) return cancel();
|
||||
queue.inject_P(PSTR("M1000S"));
|
||||
success = valid();
|
||||
if (!success)
|
||||
cancel();
|
||||
else
|
||||
queue.inject(F("M1000S"));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +139,7 @@ void PrintJobRecovery::load() {
|
||||
(void)file.read(&info, sizeof(info));
|
||||
close();
|
||||
}
|
||||
debug(PSTR("Load"));
|
||||
debug(F("Load"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +187,8 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
|
||||
info.valid_foot = info.valid_head;
|
||||
|
||||
// Machine state
|
||||
info.current_position = current_position;
|
||||
// info.sdpos and info.current_position are pre-filled from the Stepper ISR
|
||||
|
||||
info.feedrate = uint16_t(MMS_TO_MMM(feedrate_mm_s));
|
||||
info.zraise = zraise;
|
||||
info.flag.raised = raised; // Was Z raised before power-off?
|
||||
@@ -191,7 +201,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
info.flag.volumetric_enabled = parser.volumetric_enabled;
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e];
|
||||
EXTRUDER_LOOP() info.filament_size[e] = planner.filament_size[e];
|
||||
#else
|
||||
if (parser.volumetric_enabled) info.filament_size[0] = planner.filament_size[active_extruder];
|
||||
#endif
|
||||
@@ -244,7 +254,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
|
||||
|
||||
#if POWER_LOSS_RETRACT_LEN
|
||||
// Retract filament now
|
||||
gcode.process_subcommands_now_P(PSTR("G1 F3000 E-" STRINGIFY(POWER_LOSS_RETRACT_LEN)));
|
||||
gcode.process_subcommands_now(F("G1 F3000 E-" STRINGIFY(POWER_LOSS_RETRACT_LEN)));
|
||||
#endif
|
||||
|
||||
#if POWER_LOSS_ZRAISE
|
||||
@@ -265,6 +275,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
|
||||
|
||||
#endif
|
||||
|
||||
#endif // POWER_LOSS_PIN
|
||||
|
||||
#if PIN_EXISTS(POWER_LOSS) || ENABLED(DEBUG_POWER_LOSS_RECOVERY)
|
||||
|
||||
/**
|
||||
* An outage was detected by a sensor pin.
|
||||
* - If not SD printing, let the machine turn off on its own with no "KILL" screen
|
||||
@@ -273,7 +287,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
|
||||
* - If backup power is available Retract E and Raise Z
|
||||
* - Go to the KILL screen
|
||||
*/
|
||||
void PrintJobRecovery::_outage() {
|
||||
void PrintJobRecovery::_outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated/*=false*/)) {
|
||||
#if ENABLED(BACKUP_POWER_SUPPLY)
|
||||
static bool lock = false;
|
||||
if (lock) return; // No re-entrance from idle() during retract_and_lift()
|
||||
@@ -301,17 +315,23 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
|
||||
retract_and_lift(zraise);
|
||||
#endif
|
||||
|
||||
kill(GET_TEXT(MSG_OUTAGE_RECOVERY));
|
||||
if (TERN0(DEBUG_POWER_LOSS_RECOVERY, simulated)) {
|
||||
card.fileHasFinished();
|
||||
current_position.reset();
|
||||
sync_plan_position();
|
||||
}
|
||||
else
|
||||
kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY));
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // POWER_LOSS_PIN || DEBUG_POWER_LOSS_RECOVERY
|
||||
|
||||
/**
|
||||
* Save the recovery info the recovery file
|
||||
*/
|
||||
void PrintJobRecovery::write() {
|
||||
|
||||
debug(PSTR("Write"));
|
||||
debug(F("Write"));
|
||||
|
||||
open(false);
|
||||
file.seekSet(0);
|
||||
@@ -337,7 +357,7 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
#if HAS_LEVELING
|
||||
// Make sure leveling is off before any G92 and G28
|
||||
gcode.process_subcommands_now_P(PSTR("M420 S0 Z0"));
|
||||
gcode.process_subcommands_now(F("M420 S0 Z0"));
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
@@ -373,7 +393,7 @@ void PrintJobRecovery::resume() {
|
||||
// establish the current position as best we can.
|
||||
//
|
||||
|
||||
gcode.process_subcommands_now_P(PSTR("G92.9E0")); // Reset E to 0
|
||||
gcode.process_subcommands_now(F("G92.9E0")); // Reset E to 0
|
||||
|
||||
#if Z_HOME_TO_MAX
|
||||
|
||||
@@ -390,14 +410,12 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVER_ZHOME) && defined(POWER_LOSS_ZHOME_POS)
|
||||
#define HOMING_Z_DOWN 1
|
||||
#else
|
||||
#define HOME_XY_ONLY 1
|
||||
#endif
|
||||
|
||||
float z_now = info.flag.raised ? z_raised : z_print;
|
||||
|
||||
// Reset E to 0 and set Z to the real position
|
||||
#if HOME_XY_ONLY
|
||||
#if !HOMING_Z_DOWN
|
||||
// Set Z to the real position
|
||||
sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 3, str_1));
|
||||
gcode.process_subcommands_now(cmd);
|
||||
#endif
|
||||
@@ -409,15 +427,15 @@ void PrintJobRecovery::resume() {
|
||||
gcode.process_subcommands_now(cmd);
|
||||
}
|
||||
|
||||
// Home XY with no Z raise, and also home Z here if Z isn't homing down below.
|
||||
gcode.process_subcommands_now_P(PSTR("G28R0" TERN_(HOME_XY_ONLY, "XY"))); // No raise during G28
|
||||
// Home XY with no Z raise
|
||||
gcode.process_subcommands_now(F("G28R0XY")); // No raise during G28
|
||||
|
||||
#endif
|
||||
|
||||
#if HOMING_Z_DOWN
|
||||
// Move to a safe XY position and home Z while avoiding the print.
|
||||
constexpr xy_pos_t p = POWER_LOSS_ZHOME_POS;
|
||||
sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2));
|
||||
const xy_pos_t p = xy_pos_t(POWER_LOSS_ZHOME_POS) TERN_(HOMING_Z_WITH_PROBE, - probe.offset_xy);
|
||||
sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28HZ"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2));
|
||||
gcode.process_subcommands_now(cmd);
|
||||
#endif
|
||||
|
||||
@@ -431,7 +449,7 @@ void PrintJobRecovery::resume() {
|
||||
sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1));
|
||||
gcode.process_subcommands_now(cmd);
|
||||
|
||||
#if HOME_XY_ONLY
|
||||
#if !HOMING_Z_DOWN
|
||||
// The physical Z was adjusted at power-off so undo the M420S1 correction to Z with G92.9.
|
||||
sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 1, str_1));
|
||||
gcode.process_subcommands_now(cmd);
|
||||
@@ -448,7 +466,7 @@ void PrintJobRecovery::resume() {
|
||||
// Recover volumetric extrusion state
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
for (int8_t e = 0; e < EXTRUDERS; e++) {
|
||||
EXTRUDER_LOOP() {
|
||||
sprintf_P(cmd, PSTR("M200T%iD%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1));
|
||||
gcode.process_subcommands_now(cmd);
|
||||
}
|
||||
@@ -498,10 +516,10 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
// Restore retract and hop state from an active `G10` command
|
||||
#if ENABLED(FWRETRACT)
|
||||
LOOP_L_N(e, EXTRUDERS) {
|
||||
EXTRUDER_LOOP() {
|
||||
if (info.retract[e] != 0.0) {
|
||||
fwretract.current_retract[e] = info.retract[e];
|
||||
fwretract.retracted[e] = true;
|
||||
fwretract.retracted.set(e);
|
||||
}
|
||||
}
|
||||
fwretract.current_hop = info.retract_hop;
|
||||
@@ -513,17 +531,17 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
// Un-retract if there was a retract at outage
|
||||
#if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0
|
||||
gcode.process_subcommands_now_P(PSTR("G1E" STRINGIFY(POWER_LOSS_RETRACT_LEN) "F3000"));
|
||||
gcode.process_subcommands_now(F("G1F3000E" STRINGIFY(POWER_LOSS_RETRACT_LEN)));
|
||||
#endif
|
||||
|
||||
// Additional purge on resume if configured
|
||||
#if POWER_LOSS_PURGE_LEN
|
||||
sprintf_P(cmd, PSTR("G1 E%d F3000"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN));
|
||||
sprintf_P(cmd, PSTR("G1F3000E%d"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN));
|
||||
gcode.process_subcommands_now(cmd);
|
||||
#endif
|
||||
|
||||
#if ENABLED(NOZZLE_CLEAN_FEATURE)
|
||||
gcode.process_subcommands_now_P(PSTR("G12"));
|
||||
gcode.process_subcommands_now(F("G12"));
|
||||
#endif
|
||||
|
||||
// Move back over to the saved XY
|
||||
@@ -549,7 +567,7 @@ void PrintJobRecovery::resume() {
|
||||
TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);
|
||||
TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift);
|
||||
#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
|
||||
LOOP_LINEAR_AXES(i) update_workspace_offset((AxisEnum)i);
|
||||
LOOP_NUM_AXES(i) update_workspace_offset((AxisEnum)i);
|
||||
#endif
|
||||
|
||||
// Relative axis modes
|
||||
@@ -575,8 +593,8 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
|
||||
|
||||
void PrintJobRecovery::debug(PGM_P const prefix) {
|
||||
DEBUG_ECHOPGM_P(prefix);
|
||||
void PrintJobRecovery::debug(FSTR_P const prefix) {
|
||||
DEBUG_ECHOF(prefix);
|
||||
DEBUG_ECHOLNPGM(" Job Recovery Info...\nvalid_head:", info.valid_head, " valid_foot:", info.valid_foot);
|
||||
if (info.valid_head) {
|
||||
if (info.valid_head == info.valid_foot) {
|
||||
@@ -599,7 +617,7 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
#if HAS_HOME_OFFSET
|
||||
DEBUG_ECHOPGM("home_offset: ");
|
||||
LOOP_LINEAR_AXES(i) {
|
||||
LOOP_NUM_AXES(i) {
|
||||
if (i) DEBUG_CHAR(',');
|
||||
DEBUG_DECIMAL(info.home_offset[i]);
|
||||
}
|
||||
@@ -608,7 +626,7 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
#if HAS_POSITION_SHIFT
|
||||
DEBUG_ECHOPGM("position_shift: ");
|
||||
LOOP_LINEAR_AXES(i) {
|
||||
LOOP_NUM_AXES(i) {
|
||||
if (i) DEBUG_CHAR(',');
|
||||
DEBUG_DECIMAL(info.position_shift[i]);
|
||||
}
|
||||
@@ -621,7 +639,7 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
DEBUG_ECHOPGM("filament_size:");
|
||||
LOOP_L_N(i, EXTRUDERS) DEBUG_ECHOLNPGM(" ", info.filament_size[i]);
|
||||
EXTRUDER_LOOP() DEBUG_ECHOLNPGM(" ", info.filament_size[e]);
|
||||
DEBUG_EOL();
|
||||
#endif
|
||||
|
||||
@@ -653,7 +671,7 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
#if ENABLED(FWRETRACT)
|
||||
DEBUG_ECHOPGM("retract: ");
|
||||
for (int8_t e = 0; e < EXTRUDERS; e++) {
|
||||
EXTRUDER_LOOP() {
|
||||
DEBUG_ECHO(info.retract[e]);
|
||||
if (e < EXTRUDERS - 1) DEBUG_CHAR(',');
|
||||
}
|
||||
|
Reference in New Issue
Block a user