|
@@ -149,6 +149,8 @@ void PrintJobRecovery::prepare() {
|
149
|
149
|
*/
|
150
|
150
|
void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/) {
|
151
|
151
|
|
|
152
|
+ // We don't check IS_SD_PRINTING here so a save may occur during a pause
|
|
153
|
+
|
152
|
154
|
#if SAVE_INFO_INTERVAL_MS > 0
|
153
|
155
|
static millis_t next_save_ms; // = 0
|
154
|
156
|
millis_t ms = millis();
|
|
@@ -192,7 +194,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
|
192
|
194
|
#endif
|
193
|
195
|
|
194
|
196
|
#if DISABLED(NO_VOLUMETRICS)
|
195
|
|
- info.volumetric_enabled = parser.volumetric_enabled;
|
|
197
|
+ info.flag.volumetric_enabled = parser.volumetric_enabled;
|
196
|
198
|
#if HAS_MULTI_EXTRUDER
|
197
|
199
|
for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e];
|
198
|
200
|
#else
|
|
@@ -366,13 +368,16 @@ void PrintJobRecovery::resume() {
|
366
|
368
|
}
|
367
|
369
|
#endif
|
368
|
370
|
|
369
|
|
- // Reset E, raise Z, home XY...
|
|
371
|
+ //
|
|
372
|
+ // Home the axes that can safely be homed, and
|
|
373
|
+ // establish the current position as best we can
|
|
374
|
+ //
|
370
|
375
|
#if Z_HOME_DIR > 0
|
371
|
376
|
|
372
|
|
- // If Z homing goes to max, just reset E and home all
|
|
377
|
+ // If Z homing goes to max...
|
373
|
378
|
gcode.process_subcommands_now_P(PSTR(
|
374
|
|
- "G92.9 E0\n"
|
375
|
|
- "G28R0"
|
|
379
|
+ "G92.9 E0\n" // Reset E to 0
|
|
380
|
+ "G28R0" // Home all axes (no raise)
|
376
|
381
|
));
|
377
|
382
|
|
378
|
383
|
#else // "G92.9 E0 ..."
|
|
@@ -391,19 +396,20 @@ void PrintJobRecovery::resume() {
|
391
|
396
|
|
392
|
397
|
#endif
|
393
|
398
|
|
394
|
|
- #ifdef POWER_LOSS_ZHOME_POS
|
395
|
|
- // If defined move to a safe Z homing position that avoids the print
|
|
399
|
+ #if ENABLED(POWER_LOSS_RECOVER_ZHOME) && defined(POWER_LOSS_ZHOME_POS)
|
|
400
|
+ // Move to a safe XY position where Z can home while avoiding the print.
|
|
401
|
+ // If Z_SAFE_HOMING is enabled, its position must also be outside the print area!
|
396
|
402
|
constexpr xy_pos_t p = POWER_LOSS_ZHOME_POS;
|
397
|
|
- sprintf_P(cmd, PSTR("G1 X%s Y%s F1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2));
|
|
403
|
+ sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2));
|
398
|
404
|
gcode.process_subcommands_now(cmd);
|
399
|
405
|
#endif
|
400
|
406
|
|
401
|
|
- // Ensure that all axes are marked as homed
|
|
407
|
+ // Mark all axes as having been homed (no effect on current_position)
|
402
|
408
|
set_all_homed();
|
403
|
409
|
|
404
|
410
|
#if ENABLED(POWER_LOSS_RECOVER_ZHOME)
|
405
|
|
- // Now move to ZsavedPos + POWER_LOSS_ZRAISE
|
406
|
|
- sprintf_P(cmd, PSTR("G1 F500 Z%s"), dtostrf(info.current_position.z + POWER_LOSS_ZRAISE, 1, 3, str_1));
|
|
411
|
+ // Z was homed. Now move Z back up to the saved Z height, plus the POWER_LOSS_ZRAISE.
|
|
412
|
+ sprintf_P(cmd, PSTR("G1Z%sF500"), dtostrf(info.current_position.z + POWER_LOSS_ZRAISE, 1, 3, str_1));
|
407
|
413
|
gcode.process_subcommands_now(cmd);
|
408
|
414
|
#endif
|
409
|
415
|
|
|
@@ -411,16 +417,16 @@ void PrintJobRecovery::resume() {
|
411
|
417
|
#if DISABLED(NO_VOLUMETRICS)
|
412
|
418
|
#if HAS_MULTI_EXTRUDER
|
413
|
419
|
for (int8_t e = 0; e < EXTRUDERS; e++) {
|
414
|
|
- sprintf_P(cmd, PSTR("M200 T%i D%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1));
|
|
420
|
+ sprintf_P(cmd, PSTR("M200T%iD%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1));
|
415
|
421
|
gcode.process_subcommands_now(cmd);
|
416
|
422
|
}
|
417
|
|
- if (!info.volumetric_enabled) {
|
418
|
|
- sprintf_P(cmd, PSTR("M200 T%i D0"), info.active_extruder);
|
|
423
|
+ if (!info.flag.volumetric_enabled) {
|
|
424
|
+ sprintf_P(cmd, PSTR("M200T%iD0"), info.active_extruder);
|
419
|
425
|
gcode.process_subcommands_now(cmd);
|
420
|
426
|
}
|
421
|
427
|
#else
|
422
|
|
- if (info.volumetric_enabled) {
|
423
|
|
- sprintf_P(cmd, PSTR("M200 D%s"), dtostrf(info.filament_size[0], 1, 3, str_1));
|
|
428
|
+ if (info.flag.volumetric_enabled) {
|
|
429
|
+ sprintf_P(cmd, PSTR("M200D%s"), dtostrf(info.filament_size[0], 1, 3, str_1));
|
424
|
430
|
gcode.process_subcommands_now(cmd);
|
425
|
431
|
}
|
426
|
432
|
#endif
|
|
@@ -437,13 +443,13 @@ void PrintJobRecovery::resume() {
|
437
|
443
|
FANS_LOOP(i) {
|
438
|
444
|
const int f = info.fan_speed[i];
|
439
|
445
|
if (f) {
|
440
|
|
- sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f);
|
|
446
|
+ sprintf_P(cmd, PSTR("M106P%iS%i"), i, f);
|
441
|
447
|
gcode.process_subcommands_now(cmd);
|
442
|
448
|
}
|
443
|
449
|
}
|
444
|
450
|
#endif
|
445
|
451
|
|
446
|
|
- // Restore retract and hop state
|
|
452
|
+ // Restore retract and hop state from an active `G10` command
|
447
|
453
|
#if ENABLED(FWRETRACT)
|
448
|
454
|
LOOP_L_N(e, EXTRUDERS) {
|
449
|
455
|
if (info.retract[e] != 0.0) {
|
|
@@ -458,7 +464,7 @@ void PrintJobRecovery::resume() {
|
458
|
464
|
// Restore leveling state before 'G92 Z' to ensure
|
459
|
465
|
// the Z stepper count corresponds to the native Z.
|
460
|
466
|
if (info.fade || info.flag.leveling) {
|
461
|
|
- sprintf_P(cmd, PSTR("M420 S%i Z%s"), int(info.flag.leveling), dtostrf(info.fade, 1, 1, str_1));
|
|
467
|
+ sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1));
|
462
|
468
|
gcode.process_subcommands_now(cmd);
|
463
|
469
|
}
|
464
|
470
|
#endif
|
|
@@ -468,11 +474,11 @@ void PrintJobRecovery::resume() {
|
468
|
474
|
#endif
|
469
|
475
|
|
470
|
476
|
// Un-retract if there was a retract at outage
|
471
|
|
- #if POWER_LOSS_RETRACT_LEN
|
|
477
|
+ #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0
|
472
|
478
|
gcode.process_subcommands_now_P(PSTR("G1 E" STRINGIFY(POWER_LOSS_RETRACT_LEN) " F3000"));
|
473
|
479
|
#endif
|
474
|
480
|
|
475
|
|
- // Additional purge if configured
|
|
481
|
+ // Additional purge on resume if configured
|
476
|
482
|
#if POWER_LOSS_PURGE_LEN
|
477
|
483
|
sprintf_P(cmd, PSTR("G1 E%d F3000"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN));
|
478
|
484
|
gcode.process_subcommands_now(cmd);
|