|
@@ -65,8 +65,6 @@
|
65
|
65
|
#define SIZE_OF_LITTLE_RAISE 0
|
66
|
66
|
#define BIG_RAISE_NOT_NEEDED 0
|
67
|
67
|
extern void lcd_quick_feedback();
|
68
|
|
- extern int ubl_eeprom_start;
|
69
|
|
- extern volatile int ubl_encoderDiff; // This is volatile because it is getting changed at interrupt time.
|
70
|
68
|
|
71
|
69
|
/**
|
72
|
70
|
* G29: Unified Bed Leveling by Roxy
|
|
@@ -146,7 +144,7 @@
|
146
|
144
|
* P0 Phase 0 Zero Mesh Data and turn off the Mesh Compensation System. This reverts the
|
147
|
145
|
* 3D Printer to the same state it was in before the Unified Bed Leveling Compensation
|
148
|
146
|
* was turned on. Setting the entire Mesh to Zero is a special case that allows
|
149
|
|
- * a subsequent G or T leveling operation for backward compatability.
|
|
147
|
+ * a subsequent G or T leveling operation for backward compatibility.
|
150
|
148
|
*
|
151
|
149
|
* P1 Phase 1 Invalidate entire Mesh and continue with automatic generation of the Mesh data using
|
152
|
150
|
* the Z-Probe. Depending upon the values of DELTA_PROBEABLE_RADIUS and
|
|
@@ -299,14 +297,10 @@
|
299
|
297
|
* this is going to be helpful to the users!)
|
300
|
298
|
*
|
301
|
299
|
* The foundation of this Bed Leveling System is built on Epatel's Mesh Bed Leveling code. A big
|
302
|
|
- * 'Thanks!' to him and the creators of 3-Point and Grid Based leveling. Combining thier contributions
|
|
300
|
+ * 'Thanks!' to him and the creators of 3-Point and Grid Based leveling. Combining their contributions
|
303
|
301
|
* we now have the functionality and features of all three systems combined.
|
304
|
302
|
*/
|
305
|
303
|
|
306
|
|
- int ubl_eeprom_start = -1;
|
307
|
|
- bool ubl_has_control_of_lcd_panel = false;
|
308
|
|
- volatile int8_t ubl_encoderDiff = 0; // Volatile because it's changed by Temperature ISR button update
|
309
|
|
-
|
310
|
304
|
// The simple parameter flags and values are 'static' so parameter parsing can be in a support routine.
|
311
|
305
|
static int g29_verbose_level, phase_value = -1, repetition_cnt,
|
312
|
306
|
storage_slot = 0, map_type; //unlevel_value = -1;
|
|
@@ -318,8 +312,8 @@
|
318
|
312
|
#endif
|
319
|
313
|
|
320
|
314
|
void gcode_G29() {
|
321
|
|
- SERIAL_PROTOCOLLNPAIR("ubl_eeprom_start=", ubl_eeprom_start);
|
322
|
|
- if (ubl_eeprom_start < 0) {
|
|
315
|
+ SERIAL_PROTOCOLLNPAIR("ubl.eeprom_start=", ubl.eeprom_start);
|
|
316
|
+ if (ubl.eeprom_start < 0) {
|
323
|
317
|
SERIAL_PROTOCOLLNPGM("?You need to enable your EEPROM and initialize it");
|
324
|
318
|
SERIAL_PROTOCOLLNPGM("with M502, M500, M501 in that order.\n");
|
325
|
319
|
return;
|
|
@@ -340,7 +334,7 @@
|
340
|
334
|
SERIAL_PROTOCOLLNPGM("Entire Mesh invalidated.\n");
|
341
|
335
|
break; // No more invalid Mesh Points to populate
|
342
|
336
|
}
|
343
|
|
- z_values[location.x_index][location.y_index] = NAN;
|
|
337
|
+ ubl.z_values[location.x_index][location.y_index] = NAN;
|
344
|
338
|
}
|
345
|
339
|
SERIAL_PROTOCOLLNPGM("Locations invalidated.\n");
|
346
|
340
|
}
|
|
@@ -359,21 +353,21 @@
|
359
|
353
|
for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++) { // a poorly calibrated Delta.
|
360
|
354
|
const float p1 = 0.5 * (UBL_MESH_NUM_X_POINTS) - x,
|
361
|
355
|
p2 = 0.5 * (UBL_MESH_NUM_Y_POINTS) - y;
|
362
|
|
- z_values[x][y] += 2.0 * HYPOT(p1, p2);
|
|
356
|
+ ubl.z_values[x][y] += 2.0 * HYPOT(p1, p2);
|
363
|
357
|
}
|
364
|
358
|
}
|
365
|
359
|
break;
|
366
|
360
|
case 1:
|
367
|
361
|
for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++) { // Create a diagonal line several Mesh cells thick that is raised
|
368
|
|
- z_values[x][x] += 9.999;
|
369
|
|
- z_values[x][x + (x < UBL_MESH_NUM_Y_POINTS - 1) ? 1 : -1] += 9.999; // We want the altered line several mesh points thick
|
|
362
|
+ ubl.z_values[x][x] += 9.999;
|
|
363
|
+ ubl.z_values[x][x + (x < UBL_MESH_NUM_Y_POINTS - 1) ? 1 : -1] += 9.999; // We want the altered line several mesh points thick
|
370
|
364
|
}
|
371
|
365
|
break;
|
372
|
366
|
case 2:
|
373
|
367
|
// Allow the user to specify the height because 10mm is a little extreme in some cases.
|
374
|
368
|
for (uint8_t x = (UBL_MESH_NUM_X_POINTS) / 3; x < 2 * (UBL_MESH_NUM_X_POINTS) / 3; x++) // Create a rectangular raised area in
|
375
|
369
|
for (uint8_t y = (UBL_MESH_NUM_Y_POINTS) / 3; y < 2 * (UBL_MESH_NUM_Y_POINTS) / 3; y++) // the center of the bed
|
376
|
|
- z_values[x][y] += code_seen('C') ? ubl_constant : 9.99;
|
|
370
|
+ ubl.z_values[x][y] += code_seen('C') ? ubl_constant : 9.99;
|
377
|
371
|
break;
|
378
|
372
|
}
|
379
|
373
|
}
|
|
@@ -395,17 +389,18 @@
|
395
|
389
|
return;
|
396
|
390
|
}
|
397
|
391
|
switch (phase_value) {
|
398
|
|
- //
|
399
|
|
- // Zero Mesh Data
|
400
|
|
- //
|
401
|
392
|
case 0:
|
|
393
|
+ //
|
|
394
|
+ // Zero Mesh Data
|
|
395
|
+ //
|
402
|
396
|
ubl.reset();
|
403
|
397
|
SERIAL_PROTOCOLLNPGM("Mesh zeroed.\n");
|
404
|
398
|
break;
|
405
|
|
- //
|
406
|
|
- // Invalidate Entire Mesh and Automatically Probe Mesh in areas that can be reached by the probe
|
407
|
|
- //
|
|
399
|
+
|
408
|
400
|
case 1:
|
|
401
|
+ //
|
|
402
|
+ // Invalidate Entire Mesh and Automatically Probe Mesh in areas that can be reached by the probe
|
|
403
|
+ //
|
409
|
404
|
if (!code_seen('C') ) {
|
410
|
405
|
ubl.invalidate();
|
411
|
406
|
SERIAL_PROTOCOLLNPGM("Mesh invalidated. Probing mesh.\n");
|
|
@@ -419,10 +414,11 @@
|
419
|
414
|
probe_entire_mesh(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER,
|
420
|
415
|
code_seen('O') || code_seen('M'), code_seen('E'), code_seen('U'));
|
421
|
416
|
break;
|
422
|
|
- //
|
423
|
|
- // Manually Probe Mesh in areas that can't be reached by the probe
|
424
|
|
- //
|
|
417
|
+
|
425
|
418
|
case 2: {
|
|
419
|
+ //
|
|
420
|
+ // Manually Probe Mesh in areas that can't be reached by the probe
|
|
421
|
+ //
|
426
|
422
|
SERIAL_PROTOCOLLNPGM("Manually probing unreachable mesh locations.\n");
|
427
|
423
|
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
428
|
424
|
if (!x_flag && !y_flag) { // use a good default location for the path
|
|
@@ -455,24 +451,24 @@
|
455
|
451
|
|
456
|
452
|
} break;
|
457
|
453
|
|
458
|
|
- //
|
459
|
|
- // Populate invalid Mesh areas with a constant
|
460
|
|
- //
|
461
|
454
|
case 3: {
|
|
455
|
+ //
|
|
456
|
+ // Populate invalid Mesh areas with a constant
|
|
457
|
+ //
|
462
|
458
|
const float height = code_seen('C') ? ubl_constant : 0.0;
|
463
|
459
|
// If no repetition is specified, do the whole Mesh
|
464
|
460
|
if (!repeat_flag) repetition_cnt = 9999;
|
465
|
461
|
while (repetition_cnt--) {
|
466
|
462
|
const mesh_index_pair location = find_closest_mesh_point_of_type(INVALID, x_pos, y_pos, 0, NULL, false); // The '0' says we want to use the nozzle's position
|
467
|
463
|
if (location.x_index < 0) break; // No more invalid Mesh Points to populate
|
468
|
|
- z_values[location.x_index][location.y_index] = height;
|
|
464
|
+ ubl.z_values[location.x_index][location.y_index] = height;
|
469
|
465
|
}
|
470
|
466
|
} break;
|
471
|
467
|
|
472
|
|
- //
|
473
|
|
- // Fine Tune (Or Edit) the Mesh
|
474
|
|
- //
|
475
|
468
|
case 4:
|
|
469
|
+ //
|
|
470
|
+ // Fine Tune (i.e., Edit) the Mesh
|
|
471
|
+ //
|
476
|
472
|
fine_tune_mesh(x_pos, y_pos, code_seen('O') || code_seen('M'));
|
477
|
473
|
break;
|
478
|
474
|
case 5:
|
|
@@ -487,16 +483,16 @@
|
487
|
483
|
SERIAL_ECHO_START;
|
488
|
484
|
SERIAL_ECHOLNPGM("Checking G29 has control of LCD Panel:");
|
489
|
485
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
490
|
|
- ubl_has_control_of_lcd_panel++;
|
|
486
|
+ ubl.has_control_of_lcd_panel++;
|
491
|
487
|
while (!ubl_lcd_clicked()) {
|
492
|
488
|
safe_delay(250);
|
493
|
|
- if (ubl_encoderDiff) {
|
494
|
|
- SERIAL_ECHOLN((int)ubl_encoderDiff);
|
495
|
|
- ubl_encoderDiff = 0;
|
|
489
|
+ if (ubl.encoder_diff) {
|
|
490
|
+ SERIAL_ECHOLN((int)ubl.encoder_diff);
|
|
491
|
+ ubl.encoder_diff = 0;
|
496
|
492
|
}
|
497
|
493
|
}
|
498
|
494
|
SERIAL_ECHOLNPGM("G29 giving back control of LCD Panel.");
|
499
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
495
|
+ ubl.has_control_of_lcd_panel = false;
|
500
|
496
|
KEEPALIVE_STATE(IN_HANDLER);
|
501
|
497
|
break;
|
502
|
498
|
|
|
@@ -508,9 +504,9 @@
|
508
|
504
|
wait_for_user = true;
|
509
|
505
|
while (wait_for_user) {
|
510
|
506
|
safe_delay(250);
|
511
|
|
- if (ubl_encoderDiff) {
|
512
|
|
- SERIAL_ECHOLN((int)ubl_encoderDiff);
|
513
|
|
- ubl_encoderDiff = 0;
|
|
507
|
+ if (ubl.encoder_diff) {
|
|
508
|
+ SERIAL_ECHOLN((int)ubl.encoder_diff);
|
|
509
|
+ ubl.encoder_diff = 0;
|
514
|
510
|
}
|
515
|
511
|
}
|
516
|
512
|
SERIAL_ECHOLNPGM("G29 giving back control of LCD Panel.");
|
|
@@ -562,9 +558,9 @@
|
562
|
558
|
if (code_seen('L')) { // Load Current Mesh Data
|
563
|
559
|
storage_slot = code_has_value() ? code_value_int() : ubl.state.eeprom_storage_slot;
|
564
|
560
|
|
565
|
|
- const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(z_values);
|
|
561
|
+ const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
|
566
|
562
|
|
567
|
|
- if (storage_slot < 0 || storage_slot >= j || ubl_eeprom_start <= 0) {
|
|
563
|
+ if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
|
568
|
564
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
569
|
565
|
return;
|
570
|
566
|
}
|
|
@@ -586,19 +582,19 @@
|
586
|
582
|
SERIAL_ECHOLNPGM("G29 I 999"); // host in a form it can be reconstructed on a different machine
|
587
|
583
|
for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
|
588
|
584
|
for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
|
589
|
|
- if (!isnan(z_values[x][y])) {
|
|
585
|
+ if (!isnan(ubl.z_values[x][y])) {
|
590
|
586
|
SERIAL_ECHOPAIR("M421 I ", x);
|
591
|
587
|
SERIAL_ECHOPAIR(" J ", y);
|
592
|
588
|
SERIAL_ECHOPGM(" Z ");
|
593
|
|
- SERIAL_ECHO_F(z_values[x][y], 6);
|
|
589
|
+ SERIAL_ECHO_F(ubl.z_values[x][y], 6);
|
594
|
590
|
SERIAL_EOL;
|
595
|
591
|
}
|
596
|
592
|
return;
|
597
|
593
|
}
|
598
|
594
|
|
599
|
|
- const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(z_values);
|
|
595
|
+ const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
|
600
|
596
|
|
601
|
|
- if (storage_slot < 0 || storage_slot >= j || ubl_eeprom_start <= 0) {
|
|
597
|
+ if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
|
602
|
598
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
603
|
599
|
SERIAL_PROTOCOLLNPAIR("?Use 0 to ", j - 1);
|
604
|
600
|
goto LEAVE;
|
|
@@ -622,7 +618,7 @@
|
622
|
618
|
save_ubl_active_state_and_disable();
|
623
|
619
|
//measured_z = probe_pt(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER, ProbeDeployAndStow, g29_verbose_level);
|
624
|
620
|
|
625
|
|
- ubl_has_control_of_lcd_panel++; // Grab the LCD Hardware
|
|
621
|
+ ubl.has_control_of_lcd_panel++; // Grab the LCD Hardware
|
626
|
622
|
measured_z = 1.5;
|
627
|
623
|
do_blocking_move_to_z(measured_z); // Get close to the bed, but leave some space so we don't damage anything
|
628
|
624
|
// The user is not going to be locking in a new Z-Offset very often so
|
|
@@ -638,7 +634,7 @@
|
638
|
634
|
do_blocking_move_to_z(measured_z);
|
639
|
635
|
} while (!ubl_lcd_clicked());
|
640
|
636
|
|
641
|
|
- ubl_has_control_of_lcd_panel++; // There is a race condition for the Encoder Wheel getting clicked.
|
|
637
|
+ ubl.has_control_of_lcd_panel++; // There is a race condition for the Encoder Wheel getting clicked.
|
642
|
638
|
// It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
|
643
|
639
|
// or here. So, until we are done looking for a long Encoder Wheel Press,
|
644
|
640
|
// we need to take control of the panel
|
|
@@ -658,7 +654,7 @@
|
658
|
654
|
goto LEAVE;
|
659
|
655
|
}
|
660
|
656
|
}
|
661
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
657
|
+ ubl.has_control_of_lcd_panel = false;
|
662
|
658
|
safe_delay(20); // We don't want any switch noise.
|
663
|
659
|
|
664
|
660
|
ubl.state.z_offset = measured_z;
|
|
@@ -675,7 +671,7 @@
|
675
|
671
|
lcd_quick_feedback();
|
676
|
672
|
#endif
|
677
|
673
|
|
678
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
674
|
+ ubl.has_control_of_lcd_panel = false;
|
679
|
675
|
}
|
680
|
676
|
|
681
|
677
|
void find_mean_mesh_height() {
|
|
@@ -687,8 +683,8 @@
|
687
|
683
|
n = 0;
|
688
|
684
|
for (x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
|
689
|
685
|
for (y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
|
690
|
|
- if (!isnan(z_values[x][y])) {
|
691
|
|
- sum += z_values[x][y];
|
|
686
|
+ if (!isnan(ubl.z_values[x][y])) {
|
|
687
|
+ sum += ubl.z_values[x][y];
|
692
|
688
|
n++;
|
693
|
689
|
}
|
694
|
690
|
|
|
@@ -699,8 +695,8 @@
|
699
|
695
|
//
|
700
|
696
|
for (x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
|
701
|
697
|
for (y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
|
702
|
|
- if (!isnan(z_values[x][y])) {
|
703
|
|
- difference = (z_values[x][y] - mean);
|
|
698
|
+ if (!isnan(ubl.z_values[x][y])) {
|
|
699
|
+ difference = (ubl.z_values[x][y] - mean);
|
704
|
700
|
sum_of_diff_squared += difference * difference;
|
705
|
701
|
}
|
706
|
702
|
|
|
@@ -717,15 +713,15 @@
|
717
|
713
|
if (c_flag)
|
718
|
714
|
for (x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
|
719
|
715
|
for (y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
|
720
|
|
- if (!isnan(z_values[x][y]))
|
721
|
|
- z_values[x][y] -= mean + ubl_constant;
|
|
716
|
+ if (!isnan(ubl.z_values[x][y]))
|
|
717
|
+ ubl.z_values[x][y] -= mean + ubl_constant;
|
722
|
718
|
}
|
723
|
719
|
|
724
|
720
|
void shift_mesh_height() {
|
725
|
721
|
for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
|
726
|
722
|
for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
|
727
|
|
- if (!isnan(z_values[x][y]))
|
728
|
|
- z_values[x][y] += ubl_constant;
|
|
723
|
+ if (!isnan(ubl.z_values[x][y]))
|
|
724
|
+ ubl.z_values[x][y] += ubl_constant;
|
729
|
725
|
}
|
730
|
726
|
|
731
|
727
|
/**
|
|
@@ -735,7 +731,7 @@
|
735
|
731
|
void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest) {
|
736
|
732
|
mesh_index_pair location;
|
737
|
733
|
|
738
|
|
- ubl_has_control_of_lcd_panel++;
|
|
734
|
+ ubl.has_control_of_lcd_panel++;
|
739
|
735
|
save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe
|
740
|
736
|
DEPLOY_PROBE();
|
741
|
737
|
|
|
@@ -745,7 +741,7 @@
|
745
|
741
|
lcd_quick_feedback();
|
746
|
742
|
STOW_PROBE();
|
747
|
743
|
while (ubl_lcd_clicked()) idle();
|
748
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
744
|
+ ubl.has_control_of_lcd_panel = false;
|
749
|
745
|
restore_ubl_active_state_and_leave();
|
750
|
746
|
safe_delay(50); // Debounce the Encoder wheel
|
751
|
747
|
return;
|
|
@@ -761,11 +757,11 @@
|
761
|
757
|
if (rawx < (MIN_PROBE_X) || rawx > (MAX_PROBE_X) || rawy < (MIN_PROBE_Y) || rawy > (MAX_PROBE_Y)) {
|
762
|
758
|
SERIAL_ERROR_START;
|
763
|
759
|
SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
|
764
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
760
|
+ ubl.has_control_of_lcd_panel = false;
|
765
|
761
|
goto LEAVE;
|
766
|
762
|
}
|
767
|
763
|
const float measured_z = probe_pt(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy), stow_probe, g29_verbose_level);
|
768
|
|
- z_values[location.x_index][location.y_index] = measured_z + zprobe_zoffset;
|
|
764
|
+ ubl.z_values[location.x_index][location.y_index] = measured_z + zprobe_zoffset;
|
769
|
765
|
}
|
770
|
766
|
|
771
|
767
|
if (do_ubl_mesh_map) ubl.display_map(map_type);
|
|
@@ -842,7 +838,7 @@
|
842
|
838
|
for (i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
|
843
|
839
|
for (j = 0; j < UBL_MESH_NUM_Y_POINTS; j++) {
|
844
|
840
|
c = -((normal.x * (UBL_MESH_MIN_X + i * (MESH_X_DIST)) + normal.y * (UBL_MESH_MIN_Y + j * (MESH_Y_DIST))) - d);
|
845
|
|
- z_values[i][j] += c;
|
|
841
|
+ ubl.z_values[i][j] += c;
|
846
|
842
|
}
|
847
|
843
|
}
|
848
|
844
|
return normal;
|
|
@@ -852,9 +848,9 @@
|
852
|
848
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
853
|
849
|
while (!ubl_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
854
|
850
|
idle();
|
855
|
|
- if (ubl_encoderDiff) {
|
856
|
|
- do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(ubl_encoderDiff));
|
857
|
|
- ubl_encoderDiff = 0;
|
|
851
|
+ if (ubl.encoder_diff) {
|
|
852
|
+ do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(ubl.encoder_diff));
|
|
853
|
+ ubl.encoder_diff = 0;
|
858
|
854
|
}
|
859
|
855
|
}
|
860
|
856
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
@@ -863,7 +859,7 @@
|
863
|
859
|
|
864
|
860
|
float measure_business_card_thickness(const float &in_height) {
|
865
|
861
|
|
866
|
|
- ubl_has_control_of_lcd_panel++;
|
|
862
|
+ ubl.has_control_of_lcd_panel++;
|
867
|
863
|
save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe
|
868
|
864
|
|
869
|
865
|
SERIAL_PROTOCOLLNPGM("Place Shim Under Nozzle and Perform Measurement.");
|
|
@@ -873,7 +869,7 @@
|
873
|
869
|
|
874
|
870
|
const float z1 = use_encoder_wheel_to_measure_point();
|
875
|
871
|
do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE);
|
876
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
872
|
+ ubl.has_control_of_lcd_panel = false;
|
877
|
873
|
|
878
|
874
|
SERIAL_PROTOCOLLNPGM("Remove Shim and Measure Bed Height.");
|
879
|
875
|
const float z2 = use_encoder_wheel_to_measure_point();
|
|
@@ -890,7 +886,7 @@
|
890
|
886
|
|
891
|
887
|
void manually_probe_remaining_mesh(const float &lx, const float &ly, const float &z_clearance, const float &card_thickness, const bool do_ubl_mesh_map) {
|
892
|
888
|
|
893
|
|
- ubl_has_control_of_lcd_panel++;
|
|
889
|
+ ubl.has_control_of_lcd_panel++;
|
894
|
890
|
save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe
|
895
|
891
|
do_blocking_move_to_z(z_clearance);
|
896
|
892
|
do_blocking_move_to_xy(lx, ly);
|
|
@@ -911,7 +907,7 @@
|
911
|
907
|
if (rawx < (X_MIN_POS) || rawx > (X_MAX_POS) || rawy < (Y_MIN_POS) || rawy > (Y_MAX_POS)) {
|
912
|
908
|
SERIAL_ERROR_START;
|
913
|
909
|
SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
|
914
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
910
|
+ ubl.has_control_of_lcd_panel = false;
|
915
|
911
|
goto LEAVE;
|
916
|
912
|
}
|
917
|
913
|
|
|
@@ -931,13 +927,13 @@
|
931
|
927
|
last_y = yProbe;
|
932
|
928
|
|
933
|
929
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
934
|
|
- ubl_has_control_of_lcd_panel = true;
|
|
930
|
+ ubl.has_control_of_lcd_panel = true;
|
935
|
931
|
|
936
|
932
|
while (!ubl_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
937
|
933
|
idle();
|
938
|
|
- if (ubl_encoderDiff) {
|
939
|
|
- do_blocking_move_to_z(current_position[Z_AXIS] + float(ubl_encoderDiff) / 100.0);
|
940
|
|
- ubl_encoderDiff = 0;
|
|
934
|
+ if (ubl.encoder_diff) {
|
|
935
|
+ do_blocking_move_to_z(current_position[Z_AXIS] + float(ubl.encoder_diff) / 100.0);
|
|
936
|
+ ubl.encoder_diff = 0;
|
941
|
937
|
}
|
942
|
938
|
}
|
943
|
939
|
|
|
@@ -949,17 +945,17 @@
|
949
|
945
|
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
950
|
946
|
lcd_quick_feedback();
|
951
|
947
|
while (ubl_lcd_clicked()) idle();
|
952
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
948
|
+ ubl.has_control_of_lcd_panel = false;
|
953
|
949
|
KEEPALIVE_STATE(IN_HANDLER);
|
954
|
950
|
restore_ubl_active_state_and_leave();
|
955
|
951
|
return;
|
956
|
952
|
}
|
957
|
953
|
}
|
958
|
954
|
|
959
|
|
- z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - card_thickness;
|
|
955
|
+ ubl.z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - card_thickness;
|
960
|
956
|
if (g29_verbose_level > 2) {
|
961
|
957
|
SERIAL_PROTOCOLPGM("Mesh Point Measured at: ");
|
962
|
|
- SERIAL_PROTOCOL_F(z_values[location.x_index][location.y_index], 6);
|
|
958
|
+ SERIAL_PROTOCOL_F(ubl.z_values[location.x_index][location.y_index], 6);
|
963
|
959
|
SERIAL_EOL;
|
964
|
960
|
}
|
965
|
961
|
} while (location.x_index >= 0 && location.y_index >= 0);
|
|
@@ -1110,7 +1106,7 @@
|
1110
|
1106
|
* good to have the extra information. Soon... we prune this to just a few items
|
1111
|
1107
|
*/
|
1112
|
1108
|
void g29_what_command() {
|
1113
|
|
- const uint16_t k = E2END - ubl_eeprom_start;
|
|
1109
|
+ const uint16_t k = E2END - ubl.eeprom_start;
|
1114
|
1110
|
|
1115
|
1111
|
SERIAL_PROTOCOLPGM("Unified Bed Leveling System Version 1.00 ");
|
1116
|
1112
|
if (ubl.state.active)
|
|
@@ -1167,21 +1163,21 @@
|
1167
|
1163
|
SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
|
1168
|
1164
|
SERIAL_EOL;
|
1169
|
1165
|
safe_delay(50);
|
1170
|
|
- SERIAL_PROTOCOLLNPAIR("Free EEPROM space starts at: 0x", hex_word(ubl_eeprom_start));
|
|
1166
|
+ SERIAL_PROTOCOLLNPAIR("Free EEPROM space starts at: 0x", hex_word(ubl.eeprom_start));
|
1171
|
1167
|
|
1172
|
|
- SERIAL_PROTOCOLLNPAIR("end of EEPROM : ", hex_word(E2END));
|
|
1168
|
+ SERIAL_PROTOCOLLNPAIR("end of EEPROM : 0x", hex_word(E2END));
|
1173
|
1169
|
safe_delay(50);
|
1174
|
1170
|
|
1175
|
1171
|
SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl));
|
1176
|
1172
|
SERIAL_EOL;
|
1177
|
|
- SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
|
|
1173
|
+ SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(ubl.z_values));
|
1178
|
1174
|
SERIAL_EOL;
|
1179
|
1175
|
safe_delay(50);
|
1180
|
1176
|
|
1181
|
1177
|
SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: 0x", hex_word(k));
|
1182
|
1178
|
safe_delay(50);
|
1183
|
1179
|
|
1184
|
|
- SERIAL_PROTOCOLPAIR("EEPROM can hold ", k / sizeof(z_values));
|
|
1180
|
+ SERIAL_PROTOCOLPAIR("EEPROM can hold ", k / sizeof(ubl.z_values));
|
1185
|
1181
|
SERIAL_PROTOCOLLNPGM(" meshes.\n");
|
1186
|
1182
|
safe_delay(50);
|
1187
|
1183
|
|
|
@@ -1245,9 +1241,9 @@
|
1245
|
1241
|
}
|
1246
|
1242
|
storage_slot = code_value_int();
|
1247
|
1243
|
|
1248
|
|
- int16_t j = (UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(tmp_z_values);
|
|
1244
|
+ int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(tmp_z_values);
|
1249
|
1245
|
|
1250
|
|
- if (storage_slot < 0 || storage_slot > j || ubl_eeprom_start <= 0) {
|
|
1246
|
+ if (storage_slot < 0 || storage_slot > j || ubl.eeprom_start <= 0) {
|
1251
|
1247
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
1252
|
1248
|
return;
|
1253
|
1249
|
}
|
|
@@ -1256,12 +1252,12 @@
|
1256
|
1252
|
eeprom_read_block((void *)&tmp_z_values, (void *)j, sizeof(tmp_z_values));
|
1257
|
1253
|
|
1258
|
1254
|
SERIAL_ECHOPAIR("Subtracting Mesh ", storage_slot);
|
1259
|
|
- SERIAL_PROTOCOLLNPAIR(" loaded from EEPROM address ", hex_word(j)); // Soon, we can remove the extra clutter of printing
|
|
1255
|
+ SERIAL_PROTOCOLLNPAIR(" loaded from EEPROM address 0x", hex_word(j)); // Soon, we can remove the extra clutter of printing
|
1260
|
1256
|
// the address in the EEPROM where the Mesh is stored.
|
1261
|
1257
|
|
1262
|
1258
|
for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
|
1263
|
1259
|
for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
|
1264
|
|
- z_values[x][y] = z_values[x][y] - tmp_z_values[x][y];
|
|
1260
|
+ ubl.z_values[x][y] -= tmp_z_values[x][y];
|
1265
|
1261
|
}
|
1266
|
1262
|
|
1267
|
1263
|
mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType type, const float &lx, const float &ly, const bool probe_as_reference, unsigned int bits[16], bool far_flag) {
|
|
@@ -1280,8 +1276,8 @@
|
1280
|
1276
|
for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
|
1281
|
1277
|
for (uint8_t j = 0; j < UBL_MESH_NUM_Y_POINTS; j++) {
|
1282
|
1278
|
|
1283
|
|
- if ( (type == INVALID && isnan(z_values[i][j])) // Check to see if this location holds the right thing
|
1284
|
|
- || (type == REAL && !isnan(z_values[i][j]))
|
|
1279
|
+ if ( (type == INVALID && isnan(ubl.z_values[i][j])) // Check to see if this location holds the right thing
|
|
1280
|
+ || (type == REAL && !isnan(ubl.z_values[i][j]))
|
1285
|
1281
|
|| (type == SET_IN_BITMAP && is_bit_set(bits, i, j))
|
1286
|
1282
|
) {
|
1287
|
1283
|
|
|
@@ -1308,7 +1304,7 @@
|
1308
|
1304
|
if (far_flag) { // If doing the far_flag action, we want to be as far as possible
|
1309
|
1305
|
for (uint8_t k = 0; k < UBL_MESH_NUM_X_POINTS; k++) { // from the starting point and from any other probed points. We
|
1310
|
1306
|
for (uint8_t l = 0; l < UBL_MESH_NUM_Y_POINTS; l++) { // want the next point spread out and filling in any blank spaces
|
1311
|
|
- if (!isnan(z_values[k][l])) { // in the mesh. So we add in some of the distance to every probed
|
|
1307
|
+ if (!isnan(ubl.z_values[k][l])) { // in the mesh. So we add in some of the distance to every probed
|
1312
|
1308
|
distance += sq(i - k) * (MESH_X_DIST) * .05 // point we can find.
|
1313
|
1309
|
+ sq(j - l) * (MESH_Y_DIST) * .05;
|
1314
|
1310
|
}
|
|
@@ -1361,19 +1357,19 @@
|
1361
|
1357
|
if (rawx < (X_MIN_POS) || rawx > (X_MAX_POS) || rawy < (Y_MIN_POS) || rawy > (Y_MAX_POS)) { // In theory, we don't need this check.
|
1362
|
1358
|
SERIAL_ERROR_START;
|
1363
|
1359
|
SERIAL_ERRORLNPGM("Attempt to edit off the bed."); // This really can't happen, but do the check for now
|
1364
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
1360
|
+ ubl.has_control_of_lcd_panel = false;
|
1365
|
1361
|
goto FINE_TUNE_EXIT;
|
1366
|
1362
|
}
|
1367
|
1363
|
|
1368
|
1364
|
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE); // Move the nozzle to where we are going to edit
|
1369
|
1365
|
do_blocking_move_to_xy(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy));
|
1370
|
|
- float new_z = z_values[location.x_index][location.y_index];
|
|
1366
|
+ float new_z = ubl.z_values[location.x_index][location.y_index];
|
1371
|
1367
|
|
1372
|
1368
|
round_off = (int32_t)(new_z * 1000.0); // we chop off the last digits just to be clean. We are rounding to the
|
1373
|
1369
|
new_z = float(round_off) / 1000.0;
|
1374
|
1370
|
|
1375
|
1371
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
1376
|
|
- ubl_has_control_of_lcd_panel = true;
|
|
1372
|
+ ubl.has_control_of_lcd_panel = true;
|
1377
|
1373
|
|
1378
|
1374
|
lcd_implementation_clear();
|
1379
|
1375
|
lcd_mesh_edit_setup(new_z);
|
|
@@ -1385,7 +1381,7 @@
|
1385
|
1381
|
|
1386
|
1382
|
lcd_return_to_status();
|
1387
|
1383
|
|
1388
|
|
- ubl_has_control_of_lcd_panel = true; // There is a race condition for the Encoder Wheel getting clicked.
|
|
1384
|
+ ubl.has_control_of_lcd_panel = true; // There is a race condition for the Encoder Wheel getting clicked.
|
1389
|
1385
|
// It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
|
1390
|
1386
|
// or here.
|
1391
|
1387
|
|
|
@@ -1406,7 +1402,7 @@
|
1406
|
1402
|
|
1407
|
1403
|
safe_delay(20); // We don't want any switch noise.
|
1408
|
1404
|
|
1409
|
|
- z_values[location.x_index][location.y_index] = new_z;
|
|
1405
|
+ ubl.z_values[location.x_index][location.y_index] = new_z;
|
1410
|
1406
|
|
1411
|
1407
|
lcd_implementation_clear();
|
1412
|
1408
|
|
|
@@ -1414,7 +1410,7 @@
|
1414
|
1410
|
|
1415
|
1411
|
FINE_TUNE_EXIT:
|
1416
|
1412
|
|
1417
|
|
- ubl_has_control_of_lcd_panel = false;
|
|
1413
|
+ ubl.has_control_of_lcd_panel = false;
|
1418
|
1414
|
KEEPALIVE_STATE(IN_HANDLER);
|
1419
|
1415
|
|
1420
|
1416
|
if (do_ubl_mesh_map) ubl.display_map(map_type);
|