Browse Source

Fix and improve Power-Loss Recovery (#21779)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
tobuh 3 years ago
parent
commit
8e56f9366d
No account linked to committer's email address

+ 13
- 4
Marlin/src/feature/pause.cpp View File

406
   // Save current position
406
   // Save current position
407
   resume_position = current_position;
407
   resume_position = current_position;
408
 
408
 
409
+  // Will the nozzle be parking?
410
+  const bool do_park = !axes_should_home();
411
+
412
+  #if ENABLED(POWER_LOSS_RECOVERY)
413
+    // Save PLR info in case the power goes out while parked
414
+    const float park_raise = do_park ? nozzle.park_mode_0_height(park_point.z) - current_position.z : POWER_LOSS_ZRAISE;
415
+    if (was_sd_printing && recovery.enabled) recovery.save(true, park_raise, do_park);
416
+  #endif
417
+
409
   // Wait for buffered blocks to complete
418
   // Wait for buffered blocks to complete
410
   planner.synchronize();
419
   planner.synchronize();
411
 
420
 
419
     unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
428
     unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
420
   }
429
   }
421
 
430
 
422
-  // Park the nozzle by doing a Minimum Z Raise followed by an XY Move
423
-  if (!axes_should_home())
424
-    nozzle.park(0, park_point);
431
+  // If axes don't need to home then the nozzle can park
432
+  if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move
425
 
433
 
426
   #if ENABLED(DUAL_X_CARRIAGE)
434
   #if ENABLED(DUAL_X_CARRIAGE)
427
     const int8_t saved_ext        = active_extruder;
435
     const int8_t saved_ext        = active_extruder;
429
     set_duplication_enabled(false, DXC_ext);
437
     set_duplication_enabled(false, DXC_ext);
430
   #endif
438
   #endif
431
 
439
 
432
-  if (unload_length)   // Unload the filament
440
+  // Unload the filament, if specified
441
+  if (unload_length)
433
     unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT);
442
     unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT);
434
 
443
 
435
   #if ENABLED(DUAL_X_CARRIAGE)
444
   #if ENABLED(DUAL_X_CARRIAGE)

+ 119
- 53
Marlin/src/feature/powerloss.cpp View File

144
 /**
144
 /**
145
  * Save the current machine state to the power-loss recovery file
145
  * Save the current machine state to the power-loss recovery file
146
  */
146
  */
147
-void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/) {
147
+void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POWER_LOSS_ZRAISE*/, const bool raised/*=false*/) {
148
 
148
 
149
   // We don't check IS_SD_PRINTING here so a save may occur during a pause
149
   // We don't check IS_SD_PRINTING here so a save may occur during a pause
150
 
150
 
181
     info.current_position = current_position;
181
     info.current_position = current_position;
182
     info.feedrate = uint16_t(MMS_TO_MMM(feedrate_mm_s));
182
     info.feedrate = uint16_t(MMS_TO_MMM(feedrate_mm_s));
183
     info.zraise = zraise;
183
     info.zraise = zraise;
184
+    info.flag.raised = raised;                      // Was Z raised before power-off?
184
 
185
 
185
     TERN_(GCODE_REPEAT_MARKERS, info.stored_repeat = repeat);
186
     TERN_(GCODE_REPEAT_MARKERS, info.stored_repeat = repeat);
186
     TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset);
187
     TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset);
187
     TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift);
188
     TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift);
188
-
189
-    #if HAS_MULTI_EXTRUDER
190
-      info.active_extruder = active_extruder;
191
-    #endif
189
+    TERN_(HAS_MULTI_EXTRUDER, info.active_extruder = active_extruder);
192
 
190
 
193
     #if DISABLED(NO_VOLUMETRICS)
191
     #if DISABLED(NO_VOLUMETRICS)
194
       info.flag.volumetric_enabled = parser.volumetric_enabled;
192
       info.flag.volumetric_enabled = parser.volumetric_enabled;
289
       constexpr float zraise = 0;
287
       constexpr float zraise = 0;
290
     #endif
288
     #endif
291
 
289
 
292
-    // Save, including the limited Z raise
293
-    if (IS_SD_PRINTING()) save(true, zraise);
290
+    // Save the current position, distance that Z was (or should be) raised,
291
+    // and a flag whether the raise was already done here.
292
+    if (IS_SD_PRINTING()) save(true, zraise, ENABLED(BACKUP_POWER_SUPPLY));
294
 
293
 
295
     // Disable all heaters to reduce power loss
294
     // Disable all heaters to reduce power loss
296
     thermalManager.disable_all_heaters();
295
     thermalManager.disable_all_heaters();
350
     }
349
     }
351
   #endif
350
   #endif
352
 
351
 
353
-  // Restore all hotend temperatures
352
+  // Heat hotend enough to soften material
354
   #if HAS_HOTEND
353
   #if HAS_HOTEND
355
     HOTEND_LOOP() {
354
     HOTEND_LOOP() {
356
-      const celsius_t et = info.target_temperature[e];
355
+      const celsius_t et = _MAX(info.target_temperature[e], 180);
357
       if (et) {
356
       if (et) {
358
         #if HAS_MULTI_HOTEND
357
         #if HAS_MULTI_HOTEND
359
           sprintf_P(cmd, PSTR("T%iS"), e);
358
           sprintf_P(cmd, PSTR("T%iS"), e);
365
     }
364
     }
366
   #endif
365
   #endif
367
 
366
 
367
+  // Interpret the saved Z according to flags
368
+  const float z_print = info.current_position.z,
369
+              z_raised = z_print + info.zraise;
370
+
368
   //
371
   //
369
   // Home the axes that can safely be homed, and
372
   // Home the axes that can safely be homed, and
370
   // establish the current position as best we can.
373
   // establish the current position as best we can.
371
   //
374
   //
375
+
376
+  gcode.process_subcommands_now_P(PSTR("G92.9E0")); // Reset E to 0
377
+
372
   #if Z_HOME_DIR > 0
378
   #if Z_HOME_DIR > 0
373
 
379
 
374
-    // If Z homing goes to max...
380
+    float z_now = z_raised;
381
+
382
+    // If Z homing goes to max then just move back to the "raised" position
375
     gcode.process_subcommands_now_P(PSTR(
383
     gcode.process_subcommands_now_P(PSTR(
376
-      "G92.9 E0\n"                          // Reset E to 0
377
-      "G28R0"                               // Home all axes (no raise)
378
-    ));
384
+        "G28R0\n"     // Home all axes (no raise)
385
+        "G1Z%sF1200"  // Move Z down to (raised) height
386
+      ),
387
+      dtostrf(z_now, 1, 3, str_1)
388
+    );
379
 
389
 
380
   #else
390
   #else
381
 
391
 
382
-    // If a Z raise occurred at outage restore Z, otherwise raise Z now
383
-    sprintf_P(cmd, PSTR("G92.9 E0 " TERN(BACKUP_POWER_SUPPLY, "Z%s", "Z0\nG1Z%s")), dtostrf(info.zraise, 1, 3, str_1));
384
-    gcode.process_subcommands_now(cmd);
392
+    #if ENABLED(POWER_LOSS_RECOVER_ZHOME) && defined(POWER_LOSS_ZHOME_POS)
393
+      #define HOMING_Z_DOWN 1
394
+    #else
395
+      #define HOME_XY_ONLY 1
396
+    #endif
385
 
397
 
386
-    // Home safely with no Z raise
387
-    gcode.process_subcommands_now_P(PSTR(
388
-      "G28R0"                               // No raise during G28
389
-      #if IS_CARTESIAN && (DISABLED(POWER_LOSS_RECOVER_ZHOME) || defined(POWER_LOSS_ZHOME_POS))
390
-        "XY"                                // Don't home Z on Cartesian unless overridden
391
-      #endif
392
-    ));
398
+    float z_now = info.flag.raised ? z_raised : z_print;
399
+
400
+    // Reset E to 0 and set Z to the real position
401
+    #if HOME_XY_ONLY
402
+      sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 3, str_1));
403
+      gcode.process_subcommands_now(cmd);
404
+    #endif
405
+
406
+    // Does Z need to be raised now? It should be raised before homing XY.
407
+    if (z_raised > z_now) {
408
+      z_now = z_raised;
409
+      sprintf_P(cmd, PSTR("G1Z%sF600"), dtostrf(z_now, 1, 3, str_1));
410
+      gcode.process_subcommands_now(cmd);
411
+    }
412
+
413
+    // Home XY with no Z raise, and also home Z here if Z isn't homing down below.
414
+    gcode.process_subcommands_now_P(PSTR("G28R0" TERN_(HOME_XY_ONLY, "XY"))); // No raise during G28
393
 
415
 
394
   #endif
416
   #endif
395
 
417
 
396
-  #if ENABLED(POWER_LOSS_RECOVER_ZHOME) && defined(POWER_LOSS_ZHOME_POS)
397
-    // Move to a safe XY position where Z can home while avoiding the print.
398
-    // If Z_SAFE_HOMING is enabled, its position must also be outside the print area!
418
+  #if HOMING_Z_DOWN
419
+    // Move to a safe XY position and home Z while avoiding the print.
399
     constexpr xy_pos_t p = POWER_LOSS_ZHOME_POS;
420
     constexpr xy_pos_t p = POWER_LOSS_ZHOME_POS;
400
     sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2));
421
     sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2));
401
     gcode.process_subcommands_now(cmd);
422
     gcode.process_subcommands_now(cmd);
404
   // Mark all axes as having been homed (no effect on current_position)
425
   // Mark all axes as having been homed (no effect on current_position)
405
   set_all_homed();
426
   set_all_homed();
406
 
427
 
428
+  #if HAS_LEVELING
429
+    // Restore Z fade and possibly re-enable bed leveling compensation.
430
+    // Leveling may already be enabled due to the ENABLE_LEVELING_AFTER_G28 option.
431
+    // TODO: Add a G28 parameter to leave leveling disabled.
432
+    sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1));
433
+    gcode.process_subcommands_now(cmd);
434
+
435
+    #if HOME_XY_ONLY
436
+      // The physical Z was adjusted at power-off so undo the M420S1 correction to Z with G92.9.
437
+      sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 1, str_1));
438
+      gcode.process_subcommands_now(cmd);
439
+    #endif
440
+  #endif
441
+
407
   #if ENABLED(POWER_LOSS_RECOVER_ZHOME)
442
   #if ENABLED(POWER_LOSS_RECOVER_ZHOME)
408
-    // Z was homed. Now move Z back up to the saved Z height, plus the POWER_LOSS_ZRAISE.
409
-    sprintf_P(cmd, PSTR("G1Z%sF500"), dtostrf(info.current_position.z + POWER_LOSS_ZRAISE, 1, 3, str_1));
443
+    // Z was homed down to the bed, so move up to the raised height.
444
+    z_now = z_raised;
445
+    sprintf_P(cmd, PSTR("G1Z%sF600"), dtostrf(z_now, 1, 3, str_1));
410
     gcode.process_subcommands_now(cmd);
446
     gcode.process_subcommands_now(cmd);
411
   #endif
447
   #endif
412
 
448
 
429
     #endif
465
     #endif
430
   #endif
466
   #endif
431
 
467
 
432
-  // Select the previously active tool (with no_move)
433
-  #if HAS_MULTI_EXTRUDER
468
+  // Restore all hotend temperatures
469
+  #if HAS_HOTEND
470
+    HOTEND_LOOP() {
471
+      const celsius_t et = info.target_temperature[e];
472
+      if (et) {
473
+        #if HAS_MULTI_HOTEND
474
+          sprintf_P(cmd, PSTR("T%iS"), e);
475
+          gcode.process_subcommands_now(cmd);
476
+        #endif
477
+        sprintf_P(cmd, PSTR("M109S%i"), et);
478
+        gcode.process_subcommands_now(cmd);
479
+      }
480
+    }
481
+  #endif
482
+
483
+  // Restore the previously active tool (with no_move)
484
+  #if HAS_MULTI_EXTRUDER || HAS_MULTI_HOTEND
434
     sprintf_P(cmd, PSTR("T%i S"), info.active_extruder);
485
     sprintf_P(cmd, PSTR("T%i S"), info.active_extruder);
435
     gcode.process_subcommands_now(cmd);
486
     gcode.process_subcommands_now(cmd);
436
   #endif
487
   #endif
457
     fwretract.current_hop = info.retract_hop;
508
     fwretract.current_hop = info.retract_hop;
458
   #endif
509
   #endif
459
 
510
 
460
-  #if HAS_LEVELING
461
-    // Restore leveling state before 'G92 Z' to ensure
462
-    // the Z stepper count corresponds to the native Z.
463
-    if (info.fade || info.flag.leveling) {
464
-      sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1));
465
-      gcode.process_subcommands_now(cmd);
466
-    }
467
-  #endif
468
-
469
   #if ENABLED(GRADIENT_MIX)
511
   #if ENABLED(GRADIENT_MIX)
470
     memcpy(&mixer.gradient, &info.gradient, sizeof(info.gradient));
512
     memcpy(&mixer.gradient, &info.gradient, sizeof(info.gradient));
471
   #endif
513
   #endif
492
   );
534
   );
493
   gcode.process_subcommands_now(cmd);
535
   gcode.process_subcommands_now(cmd);
494
 
536
 
495
-  // Move back to the saved Z
496
-  dtostrf(info.current_position.z, 1, 3, str_1);
497
-  #if Z_HOME_DIR > 0 || ENABLED(POWER_LOSS_RECOVER_ZHOME)
498
-    sprintf_P(cmd, PSTR("G1 Z%s F500"), str_1);
499
-  #else
500
-    gcode.process_subcommands_now_P(PSTR("G1 Z0 F200"));
501
-    sprintf_P(cmd, PSTR("G92.9 Z%s"), str_1);
502
-  #endif
537
+  // Move back down to the saved Z for printing
538
+  sprintf_P(cmd, PSTR("G1Z%sF600"), dtostrf(z_print, 1, 3, str_1));
503
   gcode.process_subcommands_now(cmd);
539
   gcode.process_subcommands_now(cmd);
504
 
540
 
505
   // Restore the feedrate
541
   // Restore the feedrate
552
         }
588
         }
553
         DEBUG_EOL();
589
         DEBUG_EOL();
554
 
590
 
555
-        DEBUG_ECHOLNPAIR("zraise: ", info.zraise);
591
+        DEBUG_ECHOLNPAIR("feedrate: ", info.feedrate);
592
+
593
+        DEBUG_ECHOLNPAIR("zraise: ", info.zraise, " ", info.flag.raised ? "(before)" : "");
594
+
595
+        #if ENABLED(GCODE_REPEAT_MARKERS)
596
+          DEBUG_ECHOLNPAIR("repeat index: ", info.stored_repeat.index);
597
+          LOOP_L_N(i, info.stored_repeat.index)
598
+            DEBUG_ECHOLNPAIR("..... sdpos: ", info.stored_repeat.marker.sdpos, " count: ", info.stored_repeat.marker.counter);
599
+        #endif
556
 
600
 
557
         #if HAS_HOME_OFFSET
601
         #if HAS_HOME_OFFSET
558
           DEBUG_ECHOPGM("home_offset: ");
602
           DEBUG_ECHOPGM("home_offset: ");
572
           DEBUG_EOL();
616
           DEBUG_EOL();
573
         #endif
617
         #endif
574
 
618
 
575
-        DEBUG_ECHOLNPAIR("feedrate: ", info.feedrate);
576
-
577
         #if HAS_MULTI_EXTRUDER
619
         #if HAS_MULTI_EXTRUDER
578
           DEBUG_ECHOLNPAIR("active_extruder: ", info.active_extruder);
620
           DEBUG_ECHOLNPAIR("active_extruder: ", info.active_extruder);
579
         #endif
621
         #endif
580
 
622
 
623
+        #if DISABLED(NO_VOLUMETRICS)
624
+          DEBUG_ECHOPGM("filament_size:");
625
+          LOOP_L_N(i, EXTRUDERS) DEBUG_ECHOLNPAIR(" ", info.filament_size[i]);
626
+          DEBUG_EOL();
627
+        #endif
628
+
581
         #if HAS_HOTEND
629
         #if HAS_HOTEND
582
           DEBUG_ECHOPGM("target_temperature: ");
630
           DEBUG_ECHOPGM("target_temperature: ");
583
           HOTEND_LOOP() {
631
           HOTEND_LOOP() {
601
         #endif
649
         #endif
602
 
650
 
603
         #if HAS_LEVELING
651
         #if HAS_LEVELING
604
-          DEBUG_ECHOLNPAIR("leveling: ", info.flag.leveling, " fade: ", info.fade);
652
+          DEBUG_ECHOLNPAIR("leveling: ", info.flag.leveling ? "ON" : "OFF", "  fade: ", info.fade);
605
         #endif
653
         #endif
654
+
606
         #if ENABLED(FWRETRACT)
655
         #if ENABLED(FWRETRACT)
607
           DEBUG_ECHOPGM("retract: ");
656
           DEBUG_ECHOPGM("retract: ");
608
           for (int8_t e = 0; e < EXTRUDERS; e++) {
657
           for (int8_t e = 0; e < EXTRUDERS; e++) {
612
           DEBUG_EOL();
661
           DEBUG_EOL();
613
           DEBUG_ECHOLNPAIR("retract_hop: ", info.retract_hop);
662
           DEBUG_ECHOLNPAIR("retract_hop: ", info.retract_hop);
614
         #endif
663
         #endif
664
+
665
+        // Mixing extruder and gradient
666
+        #if BOTH(MIXING_EXTRUDER, GRADIENT_MIX)
667
+          DEBUG_ECHOLNPAIR("gradient: ", info.gradient.enabled ? "ON" : "OFF");
668
+        #endif
669
+
615
         DEBUG_ECHOLNPAIR("sd_filename: ", info.sd_filename);
670
         DEBUG_ECHOLNPAIR("sd_filename: ", info.sd_filename);
616
         DEBUG_ECHOLNPAIR("sdpos: ", info.sdpos);
671
         DEBUG_ECHOLNPAIR("sdpos: ", info.sdpos);
617
         DEBUG_ECHOLNPAIR("print_job_elapsed: ", info.print_job_elapsed);
672
         DEBUG_ECHOLNPAIR("print_job_elapsed: ", info.print_job_elapsed);
618
-        DEBUG_ECHOLNPAIR("dryrun: ", AS_DIGIT(info.flag.dryrun));
619
-        DEBUG_ECHOLNPAIR("allow_cold_extrusion: ", info.flag.allow_cold_extrusion);
673
+
674
+        DEBUG_ECHOPGM("axis_relative:");
675
+        if (TEST(info.axis_relative, REL_X)) DEBUG_ECHOPGM(" REL_X");
676
+        if (TEST(info.axis_relative, REL_Y)) DEBUG_ECHOPGM(" REL_Y");
677
+        if (TEST(info.axis_relative, REL_Z)) DEBUG_ECHOPGM(" REL_Z");
678
+        if (TEST(info.axis_relative, REL_E)) DEBUG_ECHOPGM(" REL_E");
679
+        if (TEST(info.axis_relative, E_MODE_ABS)) DEBUG_ECHOPGM(" E_MODE_ABS");
680
+        if (TEST(info.axis_relative, E_MODE_REL)) DEBUG_ECHOPGM(" E_MODE_REL");
681
+        DEBUG_EOL();
682
+
683
+        DEBUG_ECHOLNPAIR("flag.dryrun: ", AS_DIGIT(info.flag.dryrun));
684
+        DEBUG_ECHOLNPAIR("flag.allow_cold_extrusion: ", AS_DIGIT(info.flag.allow_cold_extrusion));
685
+        DEBUG_ECHOLNPAIR("flag.volumetric_enabled: ", AS_DIGIT(info.flag.volumetric_enabled));
620
       }
686
       }
621
       else
687
       else
622
         DEBUG_ECHOLNPGM("INVALID DATA");
688
         DEBUG_ECHOLNPGM("INVALID DATA");

+ 2
- 1
Marlin/src/feature/powerloss.h View File

117
 
117
 
118
   // Misc. Marlin flags
118
   // Misc. Marlin flags
119
   struct {
119
   struct {
120
+    bool raised:1;                // Raised before saved
120
     bool dryrun:1;                // M111 S8
121
     bool dryrun:1;                // M111 S8
121
     bool allow_cold_extrusion:1;  // M302 P1
122
     bool allow_cold_extrusion:1;  // M302 P1
122
     #if ENABLED(HAS_LEVELING)
123
     #if ENABLED(HAS_LEVELING)
182
     static inline void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); }
183
     static inline void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); }
183
 
184
 
184
     static void load();
185
     static void load();
185
-    static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=0);
186
+    static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false);
186
 
187
 
187
     #if PIN_EXISTS(POWER_LOSS)
188
     #if PIN_EXISTS(POWER_LOSS)
188
       static inline void outage() {
189
       static inline void outage() {

+ 0
- 2
Marlin/src/gcode/feature/pause/M125.cpp View File

78
   // If possible, show an LCD prompt with the 'P' flag
78
   // If possible, show an LCD prompt with the 'P' flag
79
   const bool show_lcd = TERN0(HAS_LCD_MENU, parser.boolval('P'));
79
   const bool show_lcd = TERN0(HAS_LCD_MENU, parser.boolval('P'));
80
 
80
 
81
-  TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true));
82
-
83
   if (pause_print(retract, park_point, show_lcd, 0)) {
81
   if (pause_print(retract, park_point, show_lcd, 0)) {
84
     if (ENABLED(EXTENSIBLE_UI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) || !sd_printing || show_lcd) {
82
     if (ENABLED(EXTENSIBLE_UI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) || !sd_printing || show_lcd) {
85
       wait_for_confirmation(false, 0);
83
       wait_for_confirmation(false, 0);

+ 1
- 1
Marlin/src/gcode/sd/M24_M25.cpp View File

105
       if (IS_SD_PRINTING()) card.pauseSDPrint();
105
       if (IS_SD_PRINTING()) card.pauseSDPrint();
106
     #endif
106
     #endif
107
 
107
 
108
-    #if ENABLED(POWER_LOSS_RECOVERY)
108
+    #if ENABLED(POWER_LOSS_RECOVERY) && DISABLED(DGUS_LCD_UI_MKS)
109
       if (recovery.enabled) recovery.save(true);
109
       if (recovery.enabled) recovery.save(true);
110
     #endif
110
     #endif
111
 
111
 

+ 2
- 0
Marlin/src/inc/SanityCheck.h View File

2903
     #error "POWER_LOSS_RECOVER_ZHOME cannot be used with Z_SAFE_HOMING."
2903
     #error "POWER_LOSS_RECOVER_ZHOME cannot be used with Z_SAFE_HOMING."
2904
   #elif BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN)
2904
   #elif BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN)
2905
     #error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time."
2905
     #error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time."
2906
+  #elif ENABLED(POWER_LOSS_RECOVER_ZHOME) && Z_HOME_DIR > 0
2907
+    #error "POWER_LOSS_RECOVER_ZHOME is not needed on a machine that homes to ZMAX."
2906
   #elif BOTH(IS_CARTESIAN, POWER_LOSS_RECOVER_ZHOME) && Z_HOME_DIR < 0 && !defined(POWER_LOSS_ZHOME_POS)
2908
   #elif BOTH(IS_CARTESIAN, POWER_LOSS_RECOVER_ZHOME) && Z_HOME_DIR < 0 && !defined(POWER_LOSS_ZHOME_POS)
2907
     #error "POWER_LOSS_RECOVER_ZHOME requires POWER_LOSS_ZHOME_POS for a Cartesian that homes to ZMIN."
2909
     #error "POWER_LOSS_RECOVER_ZHOME requires POWER_LOSS_ZHOME_POS for a Cartesian that homes to ZMIN."
2908
   #endif
2910
   #endif

+ 10
- 0
Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp View File

39
   #include "../../../../module/stepper/trinamic.h"
39
   #include "../../../../module/stepper/trinamic.h"
40
 #endif
40
 #endif
41
 
41
 
42
+#if ENABLED(POWER_LOSS_RECOVERY)
43
+  #include "../../../../../feature/powerloss.h"
44
+#endif
45
+
42
 #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
46
 #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
43
   uint16_t distanceToMove = 10;
47
   uint16_t distanceToMove = 10;
44
 #endif
48
 #endif
78
 void MKS_pause_print_move() {
82
 void MKS_pause_print_move() {
79
   queue.exhaust();
83
   queue.exhaust();
80
   position_before_pause = current_position;
84
   position_before_pause = current_position;
85
+
86
+  // Save the current position, the raise amount, and 'already raised'
87
+  TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true, mks_park_pos.z, true));
88
+
81
   destination.z = _MIN(current_position.z + mks_park_pos.z, Z_MAX_POS);
89
   destination.z = _MIN(current_position.z + mks_park_pos.z, Z_MAX_POS);
82
   prepare_internal_move_to_destination(park_speed_z);
90
   prepare_internal_move_to_destination(park_speed_z);
91
+
83
   destination.set(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y);
92
   destination.set(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y);
84
   prepare_internal_move_to_destination(park_speed_xy);
93
   prepare_internal_move_to_destination(park_speed_xy);
85
 }
94
 }
89
   prepare_internal_move_to_destination(park_speed_xy);
98
   prepare_internal_move_to_destination(park_speed_xy);
90
   destination.z = position_before_pause.z;
99
   destination.z = position_before_pause.z;
91
   prepare_internal_move_to_destination(park_speed_z);
100
   prepare_internal_move_to_destination(park_speed_z);
101
+  TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true));
92
 }
102
 }
93
 
103
 
94
 float z_offset_add = 0;
104
 float z_offset_add = 0;

+ 4
- 4
buildroot/tests/rambo View File

14
         EXTRUDERS 2 TEMP_SENSOR_0 -2 TEMP_SENSOR_1 1 TEMP_SENSOR_BED 2 \
14
         EXTRUDERS 2 TEMP_SENSOR_0 -2 TEMP_SENSOR_1 1 TEMP_SENSOR_BED 2 \
15
         TEMP_SENSOR_PROBE 1 TEMP_PROBE_PIN 12 \
15
         TEMP_SENSOR_PROBE 1 TEMP_PROBE_PIN 12 \
16
         TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 3 HEATER_CHAMBER_PIN 45 \
16
         TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 3 HEATER_CHAMBER_PIN 45 \
17
-        Z_HOME_DIR 1 GRID_MAX_POINTS_X 16 \
17
+        GRID_MAX_POINTS_X 16 \
18
         FANMUX0_PIN 53
18
         FANMUX0_PIN 53
19
-opt_disable USE_ZMIN_PLUG Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN USE_WATCHDOG
19
+opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN USE_WATCHDOG
20
 opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \
20
 opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \
21
            FIX_MOUNTED_PROBE CODEPENDENT_XY_HOMING PIDTEMPBED PROBE_TEMP_COMPENSATION \
21
            FIX_MOUNTED_PROBE CODEPENDENT_XY_HOMING PIDTEMPBED PROBE_TEMP_COMPENSATION \
22
            PREHEAT_BEFORE_PROBING PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \
22
            PREHEAT_BEFORE_PROBING PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \
32
            SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \
32
            SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \
33
            BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \
33
            BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \
34
            FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \
34
            FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \
35
-           PSU_CONTROL AUTO_POWER_CONTROL POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME \
35
+           PSU_CONTROL AUTO_POWER_CONTROL POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \
36
            SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \
36
            SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \
37
            HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL
37
            HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL
38
 opt_add DEBUG_POWER_LOSS_RECOVERY
38
 opt_add DEBUG_POWER_LOSS_RECOVERY
43
 #
43
 #
44
 restore_configs
44
 restore_configs
45
 opt_set MOTHERBOARD BOARD_RAMBO \
45
 opt_set MOTHERBOARD BOARD_RAMBO \
46
-        EXTRUDERS 0 TEMP_SENSOR_0 999 DUMMY_THERMISTOR_999_VALUE 170 \
46
+        EXTRUDERS 0 TEMP_SENSOR_0 999 DUMMY_THERMISTOR_999_VALUE 170 Z_HOME_DIR 1 \
47
         DIGIPOT_MOTOR_CURRENT '{ 120, 120, 120, 120, 120 }' \
47
         DIGIPOT_MOTOR_CURRENT '{ 120, 120, 120, 120, 120 }' \
48
         LEVEL_CORNERS_LEVELING_ORDER '{ LF, RF }'
48
         LEVEL_CORNERS_LEVELING_ORDER '{ LF, RF }'
49
 opt_enable USE_XMAX_PLUG USE_YMAX_PLUG USE_ZMAX_PLUG \
49
 opt_enable USE_XMAX_PLUG USE_YMAX_PLUG USE_ZMAX_PLUG \

Loading…
Cancel
Save