Bläddra i källkod

Have M420 report a changed position

Scott Lahteine 7 år sedan
förälder
incheckning
7d2e850577
1 ändrade filer med 15 tillägg och 3 borttagningar
  1. 15
    3
      Marlin/src/gcode/bedlevel/M420.cpp

+ 15
- 3
Marlin/src/gcode/bedlevel/M420.cpp Visa fil

45
  */
45
  */
46
 void GcodeSuite::M420() {
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
   #if ENABLED(AUTO_BED_LEVELING_UBL)
53
   #if ENABLED(AUTO_BED_LEVELING_UBL)
49
 
54
 
50
     // L to load a mesh from the EEPROM
55
     // L to load a mesh from the EEPROM
104
     #endif
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
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
112
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
111
     if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units(), false);
113
     if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units(), false);
112
   #endif
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
   const bool new_status = planner.leveling_active;
122
   const bool new_status = planner.leveling_active;
115
 
123
 
116
   if (to_enable && !new_status) {
124
   if (to_enable && !new_status) {
129
     else
137
     else
130
       SERIAL_ECHOLNPGM(MSG_OFF);
138
       SERIAL_ECHOLNPGM(MSG_OFF);
131
   #endif
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
 #endif // HAS_LEVELING
146
 #endif // HAS_LEVELING

Laddar…
Avbryt
Spara