Selaa lähdekoodia

Have M420 report a changed position

Scott Lahteine 7 vuotta sitten
vanhempi
commit
7d2e850577
1 muutettua tiedostoa jossa 15 lisäystä ja 3 poistoa
  1. 15
    3
      Marlin/src/gcode/bedlevel/M420.cpp

+ 15
- 3
Marlin/src/gcode/bedlevel/M420.cpp Näytä tiedosto

@@ -45,6 +45,11 @@
45 45
  */
46 46
 void GcodeSuite::M420() {
47 47
 
48
+  const float oldpos[XYZE] = {
49
+    current_position[X_AXIS], current_position[Y_AXIS],
50
+    current_position[Z_AXIS], current_position[E_AXIS]
51
+  };
52
+
48 53
   #if ENABLED(AUTO_BED_LEVELING_UBL)
49 54
 
50 55
     // L to load a mesh from the EEPROM
@@ -104,13 +109,16 @@ void GcodeSuite::M420() {
104 109
     #endif
105 110
   }
106 111
 
107
-  const bool to_enable = parser.boolval('S');
108
-  if (parser.seen('S')) set_bed_leveling_enabled(to_enable);
109
-
110 112
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
111 113
     if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units(), false);
112 114
   #endif
113 115
 
116
+  bool to_enable = false;
117
+  if (parser.seen('S')) {
118
+    to_enable = parser.value_bool();
119
+    set_bed_leveling_enabled(to_enable);
120
+  }
121
+
114 122
   const bool new_status = planner.leveling_active;
115 123
 
116 124
   if (to_enable && !new_status) {
@@ -129,6 +137,10 @@ void GcodeSuite::M420() {
129 137
     else
130 138
       SERIAL_ECHOLNPGM(MSG_OFF);
131 139
   #endif
140
+
141
+  // Report change in position
142
+  if (memcmp(oldpos, current_position, sizeof(oldpos)))
143
+    report_current_position();
132 144
 }
133 145
 
134 146
 #endif // HAS_LEVELING

Loading…
Peruuta
Tallenna