Pārlūkot izejas kodu

General G76 cleanup

Scott Lahteine 4 gadus atpakaļ
vecāks
revīzija
bfbd976c09
1 mainītis faili ar 25 papildinājumiem un 36 dzēšanām
  1. 25
    36
      Marlin/src/gcode/calibrate/G76_M871.cpp

+ 25
- 36
Marlin/src/gcode/calibrate/G76_M871.cpp Parādīt failu

@@ -92,10 +92,8 @@ void GcodeSuite::G76() {
92 92
     set_bltouch_deployed(false);
93 93
   #endif
94 94
 
95
-  bool do_bed_cal = parser.boolval('B'),
96
-       do_probe_cal = parser.boolval('P');
97
-  if (!do_bed_cal && !do_probe_cal)
98
-    do_bed_cal = do_probe_cal = true;
95
+  bool do_bed_cal = parser.boolval('B'), do_probe_cal = parser.boolval('P');
96
+  if (!do_bed_cal && !do_probe_cal) do_bed_cal = do_probe_cal = true;
99 97
 
100 98
   // Synchronize with planner
101 99
   planner.synchronize();
@@ -133,10 +131,8 @@ void GcodeSuite::G76() {
133 131
     uint16_t target_bed = temp_comp.cali_info_init[TSI_BED].start_temp,
134 132
              target_probe = temp_comp.bed_calib_probe_temp;
135 133
 
136
-    SERIAL_ECHOLNPGM("Waiting for printer to cool down.");
137
-    while (thermalManager.degBed() > target_bed
138
-      || thermalManager.degProbe() > target_probe
139
-    ) {
134
+    SERIAL_ECHOLNPGM("Waiting for cooling.");
135
+    while (thermalManager.degBed() > target_bed || thermalManager.degProbe() > target_probe) {
140 136
       idle_no_sleep();
141 137
       const millis_t ms = millis();
142 138
       if (ELAPSED(ms, next_temp_report)) {
@@ -151,16 +147,16 @@ void GcodeSuite::G76() {
151 147
     #endif
152 148
 
153 149
     bool timeout = false;
154
-    while (true) {
150
+    for (;;) {
155 151
       thermalManager.setTargetBed(target_bed);
156 152
 
157
-      SERIAL_ECHOLNPAIR("Target Bed: ", target_bed, "; Probe: ", target_probe);
153
+      SERIAL_ECHOLNPAIR("Target Bed:", target_bed, " Probe:", target_probe);
158 154
 
159 155
       // Park nozzle
160 156
       do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
161 157
 
162 158
       // Wait for heatbed to reach target temp and probe to cool below target temp
163
-      SERIAL_ECHOLNPGM("Waiting for bed and probe to reach target temp.");
159
+      SERIAL_ECHOLNPGM("Waiting for bed / probe to reach target.");
164 160
       const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
165 161
       while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1 || thermalManager.degProbe() > target_probe) {
166 162
         idle_no_sleep();
@@ -179,7 +175,7 @@ void GcodeSuite::G76() {
179 175
       if (timeout) break;
180 176
 
181 177
       // Move the nozzle to the probing point and wait for the probe to reach target temp
182
-      destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5);
178
+      destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y);
183 179
       do_blocking_move_to(destination);
184 180
       SERIAL_ECHOLNPGM("Waiting for probe heating.");
185 181
       while (thermalManager.degProbe() < target_probe) {
@@ -197,15 +193,12 @@ void GcodeSuite::G76() {
197 193
 
198 194
       // Do a single probe at the current position
199 195
       remember_feedrate_scaling_off();
200
-      const float measured_z = probe.probe_at_point(
201
-        destination.x + probe.offset_xy.x,
202
-        destination.y + probe.offset_xy.y,
203
-        PROBE_PT_NONE
204
-      );
196
+      const xy_pos_t probe_xy = destination + probe.offset_xy;
197
+      const float measured_z = probe.probe_at_point(probe_xy, PROBE_PT_NONE);
205 198
       restore_feedrate_and_scaling();
206 199
 
207 200
       if (isnan(measured_z)) {
208
-        SERIAL_ECHOLNPGM("!Received NAN measurement - aborting.");
201
+        SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
209 202
         break;
210 203
       }
211 204
       else
@@ -224,7 +217,7 @@ void GcodeSuite::G76() {
224 217
     if (temp_comp.finish_calibration(TSI_BED))
225 218
       SERIAL_ECHOLNPGM("Successfully calibrated bed.");
226 219
     else
227
-      SERIAL_ECHOLNPGM("!Failed to calibrated bed - reset calibration values.");
220
+      SERIAL_ECHOLNPGM("!Failed to calibrate bed. Values reset.");
228 221
 
229 222
     // Cleanup
230 223
     thermalManager.setTargetBed(0);
@@ -243,9 +236,11 @@ void GcodeSuite::G76() {
243 236
     do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
244 237
 
245 238
     // Initialize temperatures
246
-    uint16_t target_bed = temp_comp.probe_calib_bed_temp,
247
-             target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp;
239
+    const uint16_t target_bed = temp_comp.probe_calib_bed_temp;
248 240
     thermalManager.setTargetBed(target_bed);
241
+
242
+    uint16_t target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp;
243
+
249 244
     SERIAL_ECHOLNPGM("Waiting for bed and probe temperature.");
250 245
     while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1f
251 246
            || thermalManager.degProbe() > target_probe
@@ -264,16 +259,12 @@ void GcodeSuite::G76() {
264 259
     #endif
265 260
 
266 261
     bool timeout = false;
267
-    while (true) {
262
+    for (;;) {
268 263
       // Move probe to probing point and wait for it to reach target temperature
269
-      destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5);
264
+      destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y);
270 265
       do_blocking_move_to(destination);
271 266
 
272
-      SERIAL_ECHOLNPAIR(
273
-        "Bed temp: ", target_bed,
274
-        "; Probe temp: ", target_probe,
275
-        "  Waiting for probe heating."
276
-      );
267
+      SERIAL_ECHOLNPAIR("Waiting for probe heating. Bed:", target_bed, " Probe:", target_probe);
277 268
 
278 269
       const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
279 270
       while (thermalManager.degProbe() < target_probe) {
@@ -284,7 +275,7 @@ void GcodeSuite::G76() {
284 275
           next_temp_report = ms + 1000;
285 276
         }
286 277
         if (ELAPSED(ms, probe_timeout_ms)) {
287
-          SERIAL_ECHOLNPGM("!Probe heating aborted due to timeout.");
278
+          SERIAL_ECHOLNPGM("!Probe heating timed out.");
288 279
           timeout = true;
289 280
           break;
290 281
         }
@@ -298,11 +289,8 @@ void GcodeSuite::G76() {
298 289
 
299 290
       // Do a single probe
300 291
       remember_feedrate_scaling_off();
301
-      const float measured_z = probe.probe_at_point(
302
-        destination.x + probe.offset_xy.x,
303
-        destination.y + probe.offset_xy.y,
304
-        PROBE_PT_NONE
305
-      );
292
+      const xy_pos_t probe_xy = destination + probe.offset_xy;
293
+      const float measured_z = probe.probe_at_point(probe_xy, PROBE_PT_NONE);
306 294
       restore_feedrate_and_scaling();
307 295
 
308 296
       if (isnan(measured_z)) {
@@ -323,9 +311,10 @@ void GcodeSuite::G76() {
323 311
 
324 312
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
325 313
     if (temp_comp.finish_calibration(TSI_PROBE))
326
-      SERIAL_ECHOLNPGM("Successfully calibrated probe.");
314
+      SERIAL_ECHOPGM("Successfully calibrated");
327 315
     else
328
-      SERIAL_ECHOLNPGM("!Failed to calibrated probe.");
316
+      SERIAL_ECHOPGM("!Failed to calibrate");
317
+    SERIAL_ECHOLNPGM(" probe.");
329 318
 
330 319
     // Cleanup
331 320
     thermalManager.setTargetBed(0);

Notiek ielāde…
Atcelt
Saglabāt