Browse Source

General G76 cleanup

Scott Lahteine 4 years ago
parent
commit
bfbd976c09
1 changed files with 25 additions and 36 deletions
  1. 25
    36
      Marlin/src/gcode/calibrate/G76_M871.cpp

+ 25
- 36
Marlin/src/gcode/calibrate/G76_M871.cpp View File

92
     set_bltouch_deployed(false);
92
     set_bltouch_deployed(false);
93
   #endif
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
   // Synchronize with planner
98
   // Synchronize with planner
101
   planner.synchronize();
99
   planner.synchronize();
133
     uint16_t target_bed = temp_comp.cali_info_init[TSI_BED].start_temp,
131
     uint16_t target_bed = temp_comp.cali_info_init[TSI_BED].start_temp,
134
              target_probe = temp_comp.bed_calib_probe_temp;
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
       idle_no_sleep();
136
       idle_no_sleep();
141
       const millis_t ms = millis();
137
       const millis_t ms = millis();
142
       if (ELAPSED(ms, next_temp_report)) {
138
       if (ELAPSED(ms, next_temp_report)) {
151
     #endif
147
     #endif
152
 
148
 
153
     bool timeout = false;
149
     bool timeout = false;
154
-    while (true) {
150
+    for (;;) {
155
       thermalManager.setTargetBed(target_bed);
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
       // Park nozzle
155
       // Park nozzle
160
       do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
156
       do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
161
 
157
 
162
       // Wait for heatbed to reach target temp and probe to cool below target temp
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
       const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
160
       const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
165
       while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1 || thermalManager.degProbe() > target_probe) {
161
       while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1 || thermalManager.degProbe() > target_probe) {
166
         idle_no_sleep();
162
         idle_no_sleep();
179
       if (timeout) break;
175
       if (timeout) break;
180
 
176
 
181
       // Move the nozzle to the probing point and wait for the probe to reach target temp
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
       do_blocking_move_to(destination);
179
       do_blocking_move_to(destination);
184
       SERIAL_ECHOLNPGM("Waiting for probe heating.");
180
       SERIAL_ECHOLNPGM("Waiting for probe heating.");
185
       while (thermalManager.degProbe() < target_probe) {
181
       while (thermalManager.degProbe() < target_probe) {
197
 
193
 
198
       // Do a single probe at the current position
194
       // Do a single probe at the current position
199
       remember_feedrate_scaling_off();
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
       restore_feedrate_and_scaling();
198
       restore_feedrate_and_scaling();
206
 
199
 
207
       if (isnan(measured_z)) {
200
       if (isnan(measured_z)) {
208
-        SERIAL_ECHOLNPGM("!Received NAN measurement - aborting.");
201
+        SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
209
         break;
202
         break;
210
       }
203
       }
211
       else
204
       else
224
     if (temp_comp.finish_calibration(TSI_BED))
217
     if (temp_comp.finish_calibration(TSI_BED))
225
       SERIAL_ECHOLNPGM("Successfully calibrated bed.");
218
       SERIAL_ECHOLNPGM("Successfully calibrated bed.");
226
     else
219
     else
227
-      SERIAL_ECHOLNPGM("!Failed to calibrated bed - reset calibration values.");
220
+      SERIAL_ECHOLNPGM("!Failed to calibrate bed. Values reset.");
228
 
221
 
229
     // Cleanup
222
     // Cleanup
230
     thermalManager.setTargetBed(0);
223
     thermalManager.setTargetBed(0);
243
     do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
236
     do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
244
 
237
 
245
     // Initialize temperatures
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
     thermalManager.setTargetBed(target_bed);
240
     thermalManager.setTargetBed(target_bed);
241
+
242
+    uint16_t target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp;
243
+
249
     SERIAL_ECHOLNPGM("Waiting for bed and probe temperature.");
244
     SERIAL_ECHOLNPGM("Waiting for bed and probe temperature.");
250
     while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1f
245
     while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1f
251
            || thermalManager.degProbe() > target_probe
246
            || thermalManager.degProbe() > target_probe
264
     #endif
259
     #endif
265
 
260
 
266
     bool timeout = false;
261
     bool timeout = false;
267
-    while (true) {
262
+    for (;;) {
268
       // Move probe to probing point and wait for it to reach target temperature
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
       do_blocking_move_to(destination);
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
       const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
269
       const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
279
       while (thermalManager.degProbe() < target_probe) {
270
       while (thermalManager.degProbe() < target_probe) {
284
           next_temp_report = ms + 1000;
275
           next_temp_report = ms + 1000;
285
         }
276
         }
286
         if (ELAPSED(ms, probe_timeout_ms)) {
277
         if (ELAPSED(ms, probe_timeout_ms)) {
287
-          SERIAL_ECHOLNPGM("!Probe heating aborted due to timeout.");
278
+          SERIAL_ECHOLNPGM("!Probe heating timed out.");
288
           timeout = true;
279
           timeout = true;
289
           break;
280
           break;
290
         }
281
         }
298
 
289
 
299
       // Do a single probe
290
       // Do a single probe
300
       remember_feedrate_scaling_off();
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
       restore_feedrate_and_scaling();
294
       restore_feedrate_and_scaling();
307
 
295
 
308
       if (isnan(measured_z)) {
296
       if (isnan(measured_z)) {
323
 
311
 
324
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
312
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
325
     if (temp_comp.finish_calibration(TSI_PROBE))
313
     if (temp_comp.finish_calibration(TSI_PROBE))
326
-      SERIAL_ECHOLNPGM("Successfully calibrated probe.");
314
+      SERIAL_ECHOPGM("Successfully calibrated");
327
     else
315
     else
328
-      SERIAL_ECHOLNPGM("!Failed to calibrated probe.");
316
+      SERIAL_ECHOPGM("!Failed to calibrate");
317
+    SERIAL_ECHOLNPGM(" probe.");
329
 
318
 
330
     // Cleanup
319
     // Cleanup
331
     thermalManager.setTargetBed(0);
320
     thermalManager.setTargetBed(0);

Loading…
Cancel
Save