Browse Source

🚸 Use Tool 0 for G30 (#24511)

InsanityAutomation 2 years ago
parent
commit
258904e86c
No account linked to committer's email address
1 changed files with 43 additions and 31 deletions
  1. 43
    31
      Marlin/src/gcode/probe/G30.cpp

+ 43
- 31
Marlin/src/gcode/probe/G30.cpp View File

@@ -33,6 +33,10 @@
33 33
   #include "../../feature/probe_temp_comp.h"
34 34
 #endif
35 35
 
36
+#if HAS_MULTI_HOTEND
37
+  #include "../../module/tool_change.h"
38
+#endif
39
+
36 40
 #if ENABLED(DWIN_LCD_PROUI)
37 41
   #include "../../lcd/marlinui.h"
38 42
 #endif
@@ -49,6 +53,11 @@
49 53
  */
50 54
 void GcodeSuite::G30() {
51 55
 
56
+  #if HAS_MULTI_HOTEND
57
+    const uint8_t old_tool_index = active_extruder;
58
+    tool_change(0);
59
+  #endif
60
+
52 61
   const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x),
53 62
                          parser.linearval('Y', current_position.y + probe.offset_xy.y) };
54 63
 
@@ -57,40 +66,43 @@ void GcodeSuite::G30() {
57 66
       SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT));
58 67
       LCD_MESSAGE(MSG_ZPROBE_OUT);
59 68
     #endif
60
-    return;
61 69
   }
62
-
63
-  // Disable leveling so the planner won't mess with us
64
-  TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
65
-
66
-  remember_feedrate_scaling_off();
67
-
68
-  TERN_(DWIN_LCD_PROUI, process_subcommands_now(F("G28O")));
69
-
70
-  const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
71
-
72
-  TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool()));
73
-  const float measured_z = probe.probe_at_point(pos, raise_after, 1);
74
-  TERN_(HAS_PTC, ptc.set_enabled(true));
75
-  if (!isnan(measured_z)) {
76
-    SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
77
-    #if ENABLED(DWIN_LCD_PROUI)
78
-      char msg[31], str_1[6], str_2[6], str_3[6];
79
-      sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"),
80
-        dtostrf(pos.x, 1, 1, str_1),
81
-        dtostrf(pos.y, 1, 1, str_2),
82
-        dtostrf(measured_z, 1, 2, str_3)
83
-      );
84
-      ui.set_status(msg);
85
-    #endif
70
+  else {
71
+    // Disable leveling so the planner won't mess with us
72
+    TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
73
+
74
+    remember_feedrate_scaling_off();
75
+
76
+    TERN_(DWIN_LCD_PROUI, process_subcommands_now(F("G28O")));
77
+
78
+    const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
79
+
80
+    TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool()));
81
+    const float measured_z = probe.probe_at_point(pos, raise_after, 1);
82
+    TERN_(HAS_PTC, ptc.set_enabled(true));
83
+    if (!isnan(measured_z)) {
84
+      SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
85
+      #if ENABLED(DWIN_LCD_PROUI)
86
+        char msg[31], str_1[6], str_2[6], str_3[6];
87
+        sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"),
88
+          dtostrf(pos.x, 1, 1, str_1),
89
+          dtostrf(pos.y, 1, 1, str_2),
90
+          dtostrf(measured_z, 1, 2, str_3)
91
+        );
92
+        ui.set_status(msg);
93
+      #endif
94
+    }
95
+
96
+    restore_feedrate_and_scaling();
97
+
98
+    if (raise_after == PROBE_PT_STOW)
99
+      probe.move_z_after_probing();
100
+
101
+    report_current_position();
86 102
   }
87 103
 
88
-  restore_feedrate_and_scaling();
89
-
90
-  if (raise_after == PROBE_PT_STOW)
91
-    probe.move_z_after_probing();
92
-
93
-  report_current_position();
104
+  // Restore the active tool
105
+  TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));
94 106
 }
95 107
 
96 108
 #endif // HAS_BED_PROBE

Loading…
Cancel
Save