|
@@ -116,8 +116,7 @@
|
116
|
116
|
* invalidate.
|
117
|
117
|
*
|
118
|
118
|
* J # Grid * Perform a Grid Based Leveling of the current Mesh using a grid with n points on a side.
|
119
|
|
- *
|
120
|
|
- * j EEPROM Dump This function probably goes away after debug is complete.
|
|
119
|
+ * Not specifying a grid size will invoke the 3-Point leveling function.
|
121
|
120
|
*
|
122
|
121
|
* K # Kompare Kompare current Mesh with stored Mesh # replacing current Mesh with the result. This
|
123
|
122
|
* command literally performs a diff between two Meshes.
|
|
@@ -264,8 +263,6 @@
|
264
|
263
|
* at a later date. The GCode output can be saved and later replayed by the host software
|
265
|
264
|
* to reconstruct the current mesh on another machine.
|
266
|
265
|
*
|
267
|
|
- * T 3-Point Perform a 3 Point Bed Leveling on the current Mesh
|
268
|
|
- *
|
269
|
266
|
* U Unlevel Perform a probe of the outer perimeter to assist in physically leveling unlevel beds.
|
270
|
267
|
* Only used for G29 P1 O U It will speed up the probing of the edge of the bed. This
|
271
|
268
|
* is useful when the entire bed does not need to be probed because it will be adjusted.
|
|
@@ -276,12 +273,6 @@
|
276
|
273
|
*
|
277
|
274
|
* Y # * * Y Location for this line of commands
|
278
|
275
|
*
|
279
|
|
- * Z Zero * Probes to set the Z Height of the nozzle. The entire Mesh can be raised or lowered
|
280
|
|
- * by just doing a G29 Z
|
281
|
|
- *
|
282
|
|
- * Z # Zero * The entire Mesh can be raised or lowered to conform with the specified difference.
|
283
|
|
- * zprobe_zoffset is added to the calculation.
|
284
|
|
- *
|
285
|
276
|
*
|
286
|
277
|
* Release Notes:
|
287
|
278
|
* You MUST do M502, M500 to initialize the storage. Failure to do this will cause all
|
|
@@ -329,7 +320,7 @@
|
329
|
320
|
}
|
330
|
321
|
|
331
|
322
|
// Don't allow auto-leveling without homing first
|
332
|
|
- if (!(code_seen('N') && code_value_bool()) && axis_unhomed_error()) // Warning! Use of 'N' flouts established standards.
|
|
323
|
+ if (axis_unhomed_error())
|
333
|
324
|
home_all_axes();
|
334
|
325
|
|
335
|
326
|
if (g29_parameter_parsing()) return; // abort if parsing the simple parameters causes a problem,
|
|
@@ -353,13 +344,16 @@
|
353
|
344
|
}
|
354
|
345
|
|
355
|
346
|
if (code_seen('Q')) {
|
356
|
|
- const int test_pattern = code_has_value() ? code_value_int() : -1;
|
357
|
|
- if (!WITHIN(test_pattern, 0, 2)) {
|
|
347
|
+ const int test_pattern = code_has_value() ? code_value_int() : -99;
|
|
348
|
+ if (!WITHIN(test_pattern, -1, 2)) {
|
358
|
349
|
SERIAL_PROTOCOLLNPGM("Invalid test_pattern value. (0-2)\n");
|
359
|
350
|
return;
|
360
|
351
|
}
|
361
|
352
|
SERIAL_PROTOCOLLNPGM("Loading test_pattern values.\n");
|
362
|
353
|
switch (test_pattern) {
|
|
354
|
+ case -1:
|
|
355
|
+ g29_eeprom_dump();
|
|
356
|
+ break;
|
363
|
357
|
case 0:
|
364
|
358
|
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a bowl shape - similar to
|
365
|
359
|
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
|
|
@@ -385,9 +379,33 @@
|
385
|
379
|
}
|
386
|
380
|
|
387
|
381
|
if (code_seen('J')) {
|
388
|
|
- ubl.save_ubl_active_state_and_disable();
|
389
|
|
- ubl.tilt_mesh_based_on_probed_grid(code_seen('O') || code_seen('M')); // Warning! Use of 'M' flouts established standards.
|
390
|
|
- ubl.restore_ubl_active_state_and_leave();
|
|
382
|
+ if (grid_size!=0) { // if not 0 it is a normal n x n grid being probed
|
|
383
|
+ ubl.save_ubl_active_state_and_disable();
|
|
384
|
+ ubl.tilt_mesh_based_on_probed_grid(code_seen('O'));
|
|
385
|
+ ubl.restore_ubl_active_state_and_leave();
|
|
386
|
+ } else { // grid_size==0 which means a 3-Point leveling has been requested
|
|
387
|
+ float z1 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y), false, g29_verbose_level),
|
|
388
|
+ z2 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y), false, g29_verbose_level),
|
|
389
|
+ z3 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y), true, g29_verbose_level);
|
|
390
|
+
|
|
391
|
+ if ( isnan(z1) || isnan(z2) || isnan(z3)) { // probe_pt will return NAN if unreachable
|
|
392
|
+ SERIAL_ERROR_START;
|
|
393
|
+ SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
|
|
394
|
+ goto LEAVE;
|
|
395
|
+ }
|
|
396
|
+
|
|
397
|
+ // We need to adjust z1, z2, z3 by the Mesh Height at these points. Just because they are non-zero doesn't mean
|
|
398
|
+ // the Mesh is tilted! (We need to compensate each probe point by what the Mesh says that location's height is)
|
|
399
|
+
|
|
400
|
+ ubl.save_ubl_active_state_and_disable();
|
|
401
|
+ z1 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y)) /* + zprobe_zoffset */ ;
|
|
402
|
+ z2 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y)) /* + zprobe_zoffset */ ;
|
|
403
|
+ z3 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y)) /* + zprobe_zoffset */ ;
|
|
404
|
+
|
|
405
|
+ do_blocking_move_to_xy(0.5 * (UBL_MESH_MAX_X - (UBL_MESH_MIN_X)), 0.5 * (UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)));
|
|
406
|
+ ubl.tilt_mesh_based_on_3pts(z1, z2, z3);
|
|
407
|
+ ubl.restore_ubl_active_state_and_leave();
|
|
408
|
+ }
|
391
|
409
|
}
|
392
|
410
|
|
393
|
411
|
if (code_seen('P')) {
|
|
@@ -420,7 +438,7 @@
|
420
|
438
|
SERIAL_PROTOCOLLNPGM(").\n");
|
421
|
439
|
}
|
422
|
440
|
ubl.probe_entire_mesh(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER,
|
423
|
|
- code_seen('O') || code_seen('M'), code_seen('E'), code_seen('U')); // Warning! Use of 'M' flouts established standards.
|
|
441
|
+ code_seen('O'), code_seen('E'), code_seen('U'));
|
424
|
442
|
break;
|
425
|
443
|
|
426
|
444
|
case 2: {
|
|
@@ -469,7 +487,7 @@
|
469
|
487
|
return;
|
470
|
488
|
}
|
471
|
489
|
|
472
|
|
- manually_probe_remaining_mesh(x_pos, y_pos, height, card_thickness, code_seen('O') || code_seen('M')); // Warning! Use of 'M' flouts established standards.
|
|
490
|
+ manually_probe_remaining_mesh(x_pos, y_pos, height, card_thickness, code_seen('O'));
|
473
|
491
|
SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
|
474
|
492
|
} break;
|
475
|
493
|
|
|
@@ -505,7 +523,7 @@
|
505
|
523
|
//
|
506
|
524
|
// Fine Tune (i.e., Edit) the Mesh
|
507
|
525
|
//
|
508
|
|
- fine_tune_mesh(x_pos, y_pos, code_seen('O') || code_seen('M')); // Warning! Use of 'M' flouts established standards.
|
|
526
|
+ fine_tune_mesh(x_pos, y_pos, code_seen('O'));
|
509
|
527
|
break;
|
510
|
528
|
|
511
|
529
|
case 5: ubl.find_mean_mesh_height(); break;
|
|
@@ -515,31 +533,6 @@
|
515
|
533
|
|
516
|
534
|
}
|
517
|
535
|
|
518
|
|
- if (code_seen('T')) {
|
519
|
|
-
|
520
|
|
- float z1 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y), false, g29_verbose_level),
|
521
|
|
- z2 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y), false, g29_verbose_level),
|
522
|
|
- z3 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y), true, g29_verbose_level);
|
523
|
|
-
|
524
|
|
- if ( isnan(z1) || isnan(z2) || isnan(z3)) { // probe_pt will return NAN if unreachable
|
525
|
|
- SERIAL_ERROR_START;
|
526
|
|
- SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
|
527
|
|
- goto LEAVE;
|
528
|
|
- }
|
529
|
|
-
|
530
|
|
- // We need to adjust z1, z2, z3 by the Mesh Height at these points. Just because they are non-zero doesn't mean
|
531
|
|
- // the Mesh is tilted! (We need to compensate each probe point by what the Mesh says that location's height is)
|
532
|
|
-
|
533
|
|
- ubl.save_ubl_active_state_and_disable();
|
534
|
|
- z1 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y)) /* + zprobe_zoffset */ ;
|
535
|
|
- z2 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y)) /* + zprobe_zoffset */ ;
|
536
|
|
- z3 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y)) /* + zprobe_zoffset */ ;
|
537
|
|
-
|
538
|
|
- do_blocking_move_to_xy(0.5 * (UBL_MESH_MAX_X - (UBL_MESH_MIN_X)), 0.5 * (UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)));
|
539
|
|
- ubl.tilt_mesh_based_on_3pts(z1, z2, z3);
|
540
|
|
- ubl.restore_ubl_active_state_and_leave();
|
541
|
|
- }
|
542
|
|
-
|
543
|
536
|
//
|
544
|
537
|
// Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
|
545
|
538
|
// good to have the extra information. Soon... we prune this to just a few items
|
|
@@ -547,12 +540,6 @@
|
547
|
540
|
if (code_seen('W')) ubl.g29_what_command();
|
548
|
541
|
|
549
|
542
|
//
|
550
|
|
- // When we are fully debugged, the EEPROM dump command will get deleted also. But
|
551
|
|
- // right now, it is good to have the extra information. Soon... we prune this.
|
552
|
|
- //
|
553
|
|
- if (code_seen('j')) g29_eeprom_dump(); // Warning! Use of lowercase flouts established standards.
|
554
|
|
-
|
555
|
|
- //
|
556
|
543
|
// When we are fully debugged, this may go away. But there are some valid
|
557
|
544
|
// use cases for the users. So we can wait and see what to do with it.
|
558
|
545
|
//
|
|
@@ -614,9 +601,12 @@
|
614
|
601
|
SERIAL_PROTOCOLLNPGM("Done.\n");
|
615
|
602
|
}
|
616
|
603
|
|
617
|
|
- if (code_seen('O') || code_seen('M')) // Warning! Use of 'M' flouts established standards.
|
|
604
|
+ if (code_seen('O'))
|
618
|
605
|
ubl.display_map(code_has_value() ? code_value_int() : 0);
|
619
|
606
|
|
|
607
|
+ /*
|
|
608
|
+ * This code may not be needed... Prepare for its removal...
|
|
609
|
+ *
|
620
|
610
|
if (code_seen('Z')) {
|
621
|
611
|
if (code_has_value())
|
622
|
612
|
ubl.state.z_offset = code_value_float(); // do the simple case. Just lock in the specified value
|
|
@@ -669,6 +659,7 @@
|
669
|
659
|
ubl.restore_ubl_active_state_and_leave();
|
670
|
660
|
}
|
671
|
661
|
}
|
|
662
|
+ */
|
672
|
663
|
|
673
|
664
|
LEAVE:
|
674
|
665
|
|
|
@@ -1069,8 +1060,8 @@
|
1069
|
1060
|
}
|
1070
|
1061
|
|
1071
|
1062
|
if (code_seen('J')) {
|
1072
|
|
- grid_size = code_has_value() ? code_value_int() : 3;
|
1073
|
|
- if (!WITHIN(grid_size, 2, 9)) {
|
|
1063
|
+ grid_size = code_has_value() ? code_value_int() : 0;
|
|
1064
|
+ if (grid_size!=0 && !WITHIN(grid_size, 2, 9)) {
|
1074
|
1065
|
SERIAL_PROTOCOLLNPGM("?Invalid grid size (J) specified (2-9).\n");
|
1075
|
1066
|
err_flag = true;
|
1076
|
1067
|
}
|
|
@@ -1126,43 +1117,9 @@
|
1126
|
1117
|
SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
|
1127
|
1118
|
return UBL_ERR;
|
1128
|
1119
|
}
|
1129
|
|
-
|
1130
|
|
- // Check if a map type was specified
|
1131
|
|
- if (code_seen('M')) { // Warning! Use of 'M' flouts established standards.
|
1132
|
|
- map_type = code_has_value() ? code_value_int() : 0;
|
1133
|
|
- if (!WITHIN(map_type, 0, 1)) {
|
1134
|
|
- SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
|
1135
|
|
- return UBL_ERR;
|
1136
|
|
- }
|
1137
|
|
- }
|
1138
|
|
-
|
1139
|
1120
|
return UBL_OK;
|
1140
|
1121
|
}
|
1141
|
1122
|
|
1142
|
|
- /**
|
1143
|
|
- * This function goes away after G29 debug is complete. But for right now, it is a handy
|
1144
|
|
- * routine to dump binary data structures.
|
1145
|
|
- */
|
1146
|
|
- /*
|
1147
|
|
- void dump(char * const str, const float &f) {
|
1148
|
|
- char *ptr;
|
1149
|
|
-
|
1150
|
|
- SERIAL_PROTOCOL(str);
|
1151
|
|
- SERIAL_PROTOCOL_F(f, 8);
|
1152
|
|
- SERIAL_PROTOCOLPGM(" ");
|
1153
|
|
- ptr = (char*)&f;
|
1154
|
|
- for (uint8_t i = 0; i < 4; i++)
|
1155
|
|
- SERIAL_PROTOCOLPAIR(" ", hex_byte(*ptr++));
|
1156
|
|
- SERIAL_PROTOCOLPAIR(" isnan()=", isnan(f));
|
1157
|
|
- SERIAL_PROTOCOLPAIR(" isinf()=", isinf(f));
|
1158
|
|
-
|
1159
|
|
- if (f == -INFINITY)
|
1160
|
|
- SERIAL_PROTOCOLPGM(" Minus Infinity detected.");
|
1161
|
|
-
|
1162
|
|
- SERIAL_EOL;
|
1163
|
|
- }
|
1164
|
|
- //*/
|
1165
|
|
-
|
1166
|
1123
|
static int ubl_state_at_invocation = 0,
|
1167
|
1124
|
ubl_state_recursion_chk = 0;
|
1168
|
1125
|
|