|
@@ -65,8 +65,8 @@
|
65
|
65
|
unified_bed_leveling::g29_y_flag;
|
66
|
66
|
float unified_bed_leveling::g29_x_pos,
|
67
|
67
|
unified_bed_leveling::g29_y_pos,
|
68
|
|
- unified_bed_leveling::g29_card_thickness = 0.0,
|
69
|
|
- unified_bed_leveling::g29_constant = 0.0;
|
|
68
|
+ unified_bed_leveling::g29_card_thickness = 0,
|
|
69
|
+ unified_bed_leveling::g29_constant = 0;
|
70
|
70
|
|
71
|
71
|
#if HAS_BED_PROBE
|
72
|
72
|
int unified_bed_leveling::g29_grid_size;
|
|
@@ -346,23 +346,23 @@
|
346
|
346
|
case 0:
|
347
|
347
|
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a bowl shape - similar to
|
348
|
348
|
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
|
349
|
|
- const float p1 = 0.5 * (GRID_MAX_POINTS_X) - x,
|
350
|
|
- p2 = 0.5 * (GRID_MAX_POINTS_Y) - y;
|
351
|
|
- z_values[x][y] += 2.0 * HYPOT(p1, p2);
|
|
349
|
+ const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
|
|
350
|
+ p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
|
|
351
|
+ z_values[x][y] += 2.0f * HYPOT(p1, p2);
|
352
|
352
|
}
|
353
|
353
|
}
|
354
|
354
|
break;
|
355
|
355
|
case 1:
|
356
|
356
|
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a diagonal line several Mesh cells thick that is raised
|
357
|
|
- z_values[x][x] += 9.999;
|
358
|
|
- z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999; // We want the altered line several mesh points thick
|
|
357
|
+ z_values[x][x] += 9.999f;
|
|
358
|
+ z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
|
359
|
359
|
}
|
360
|
360
|
break;
|
361
|
361
|
case 2:
|
362
|
362
|
// Allow the user to specify the height because 10mm is a little extreme in some cases.
|
363
|
363
|
for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++) // Create a rectangular raised area in
|
364
|
364
|
for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) // the center of the bed
|
365
|
|
- z_values[x][y] += parser.seen('C') ? g29_constant : 9.99;
|
|
365
|
+ z_values[x][y] += parser.seen('C') ? g29_constant : 9.99f;
|
366
|
366
|
break;
|
367
|
367
|
}
|
368
|
368
|
}
|
|
@@ -381,7 +381,7 @@
|
381
|
381
|
tilt_mesh_based_on_probed_grid(true /* true says to do 3-Point leveling */ );
|
382
|
382
|
restore_ubl_active_state_and_leave();
|
383
|
383
|
}
|
384
|
|
- do_blocking_move_to_xy(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)));
|
|
384
|
+ do_blocking_move_to_xy(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)));
|
385
|
385
|
report_current_position();
|
386
|
386
|
}
|
387
|
387
|
|
|
@@ -453,7 +453,7 @@
|
453
|
453
|
|
454
|
454
|
if (parser.seen('B')) {
|
455
|
455
|
g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness((float) Z_CLEARANCE_BETWEEN_PROBES);
|
456
|
|
- if (ABS(g29_card_thickness) > 1.5) {
|
|
456
|
+ if (ABS(g29_card_thickness) > 1.5f) {
|
457
|
457
|
SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.");
|
458
|
458
|
return;
|
459
|
459
|
}
|
|
@@ -509,7 +509,7 @@
|
509
|
509
|
}
|
510
|
510
|
else {
|
511
|
511
|
const float cvf = parser.value_float();
|
512
|
|
- switch ((int)truncf(cvf * 10.0) - 30) { // 3.1 -> 1
|
|
512
|
+ switch ((int)truncf(cvf * 10.0f) - 30) { // 3.1 -> 1
|
513
|
513
|
#if ENABLED(UBL_G29_P31)
|
514
|
514
|
case 1: {
|
515
|
515
|
|
|
@@ -519,8 +519,8 @@
|
519
|
519
|
// P3.12 100X distance weighting
|
520
|
520
|
// P3.13 1000X distance weighting, approaches simple average of nearest points
|
521
|
521
|
|
522
|
|
- const float weight_power = (cvf - 3.10) * 100.0, // 3.12345 -> 2.345
|
523
|
|
- weight_factor = weight_power ? POW(10.0, weight_power) : 0;
|
|
522
|
+ const float weight_power = (cvf - 3.10f) * 100.0f, // 3.12345 -> 2.345
|
|
523
|
+ weight_factor = weight_power ? POW(10.0f, weight_power) : 0;
|
524
|
524
|
smart_fill_wlsf(weight_factor);
|
525
|
525
|
}
|
526
|
526
|
break;
|
|
@@ -634,7 +634,7 @@
|
634
|
634
|
}
|
635
|
635
|
|
636
|
636
|
void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) {
|
637
|
|
- float sum = 0.0;
|
|
637
|
+ float sum = 0;
|
638
|
638
|
int n = 0;
|
639
|
639
|
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
640
|
640
|
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
@@ -648,7 +648,7 @@
|
648
|
648
|
//
|
649
|
649
|
// Sum the squares of difference from mean
|
650
|
650
|
//
|
651
|
|
- float sum_of_diff_squared = 0.0;
|
|
651
|
+ float sum_of_diff_squared = 0;
|
652
|
652
|
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
653
|
653
|
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
654
|
654
|
if (!isnan(z_values[x][y]))
|
|
@@ -786,7 +786,7 @@
|
786
|
786
|
|
787
|
787
|
float unified_bed_leveling::measure_point_with_encoder() {
|
788
|
788
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
789
|
|
- move_z_with_encoder(0.01);
|
|
789
|
+ move_z_with_encoder(0.01f);
|
790
|
790
|
KEEPALIVE_STATE(IN_HANDLER);
|
791
|
791
|
return current_position[Z_AXIS];
|
792
|
792
|
}
|
|
@@ -797,8 +797,8 @@
|
797
|
797
|
lcd_external_control = true;
|
798
|
798
|
save_ubl_active_state_and_disable(); // Disable bed level correction for probing
|
799
|
799
|
|
800
|
|
- do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
|
801
|
|
- //, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) / 2.0);
|
|
800
|
+ do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
|
|
801
|
+ //, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) * 0.5f);
|
802
|
802
|
planner.synchronize();
|
803
|
803
|
|
804
|
804
|
SERIAL_PROTOCOLPGM("Place shim under nozzle");
|
|
@@ -874,7 +874,7 @@
|
874
|
874
|
|
875
|
875
|
serialprintPGM(parser.seen('B') ? PSTR(MSG_UBL_BC_INSERT) : PSTR(MSG_UBL_BC_INSERT2));
|
876
|
876
|
|
877
|
|
- const float z_step = 0.01; // existing behavior: 0.01mm per click, occasionally step
|
|
877
|
+ const float z_step = 0.01f; // existing behavior: 0.01mm per click, occasionally step
|
878
|
878
|
//const float z_step = planner.steps_to_mm[Z_AXIS]; // approx one step each click
|
879
|
879
|
|
880
|
880
|
move_z_with_encoder(z_step);
|
|
@@ -913,7 +913,7 @@
|
913
|
913
|
lcd_quick_feedback(true);
|
914
|
914
|
#endif
|
915
|
915
|
|
916
|
|
- g29_constant = 0.0;
|
|
916
|
+ g29_constant = 0;
|
917
|
917
|
g29_repetition_cnt = 0;
|
918
|
918
|
|
919
|
919
|
g29_x_flag = parser.seenval('X');
|
|
@@ -1004,7 +1004,7 @@
|
1004
|
1004
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
1005
|
1005
|
if (parser.seenval('F')) {
|
1006
|
1006
|
const float fh = parser.value_float();
|
1007
|
|
- if (!WITHIN(fh, 0.0, 100.0)) {
|
|
1007
|
+ if (!WITHIN(fh, 0, 100)) {
|
1008
|
1008
|
SERIAL_PROTOCOLLNPGM("?(F)ade height for Bed Level Correction not plausible.\n");
|
1009
|
1009
|
return UBL_ERR;
|
1010
|
1010
|
}
|
|
@@ -1226,7 +1226,7 @@
|
1226
|
1226
|
|
1227
|
1227
|
mesh_index_pair out_mesh;
|
1228
|
1228
|
out_mesh.x_index = out_mesh.y_index = -1;
|
1229
|
|
- out_mesh.distance = -99999.99;
|
|
1229
|
+ out_mesh.distance = -99999.99f;
|
1230
|
1230
|
|
1231
|
1231
|
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
1232
|
1232
|
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
|
@@ -1242,7 +1242,7 @@
|
1242
|
1242
|
found_a_NAN = true;
|
1243
|
1243
|
|
1244
|
1244
|
int8_t closest_x = -1, closest_y = -1;
|
1245
|
|
- float d1, d2 = 99999.9;
|
|
1245
|
+ float d1, d2 = 99999.9f;
|
1246
|
1246
|
for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
|
1247
|
1247
|
for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
|
1248
|
1248
|
if (!isnan(z_values[k][l])) {
|
|
@@ -1279,7 +1279,7 @@
|
1279
|
1279
|
if (!found_a_real && found_a_NAN) { // if the mesh is totally unpopulated, start the probing
|
1280
|
1280
|
out_mesh.x_index = GRID_MAX_POINTS_X / 2;
|
1281
|
1281
|
out_mesh.y_index = GRID_MAX_POINTS_Y / 2;
|
1282
|
|
- out_mesh.distance = 1.0;
|
|
1282
|
+ out_mesh.distance = 1;
|
1283
|
1283
|
}
|
1284
|
1284
|
return out_mesh;
|
1285
|
1285
|
}
|
|
@@ -1287,13 +1287,13 @@
|
1287
|
1287
|
mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const float &rx, const float &ry, const bool probe_as_reference, uint16_t bits[16]) {
|
1288
|
1288
|
mesh_index_pair out_mesh;
|
1289
|
1289
|
out_mesh.x_index = out_mesh.y_index = -1;
|
1290
|
|
- out_mesh.distance = -99999.9;
|
|
1290
|
+ out_mesh.distance = -99999.9f;
|
1291
|
1291
|
|
1292
|
1292
|
// Get our reference position. Either the nozzle or probe location.
|
1293
|
1293
|
const float px = rx - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
|
1294
|
1294
|
py = ry - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
|
1295
|
1295
|
|
1296
|
|
- float best_so_far = 99999.99;
|
|
1296
|
+ float best_so_far = 99999.99f;
|
1297
|
1297
|
|
1298
|
1298
|
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
1299
|
1299
|
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
|
@@ -1320,7 +1320,7 @@
|
1320
|
1320
|
|
1321
|
1321
|
// factor in the distance from the current location for the normal case
|
1322
|
1322
|
// so the nozzle isn't running all over the bed.
|
1323
|
|
- distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1;
|
|
1323
|
+ distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1f;
|
1324
|
1324
|
if (distance < best_so_far) {
|
1325
|
1325
|
best_so_far = distance; // We found a closer location with
|
1326
|
1326
|
out_mesh.x_index = i; // the specified type of mesh value.
|
|
@@ -1401,8 +1401,8 @@
|
1401
|
1401
|
lcd_refresh();
|
1402
|
1402
|
|
1403
|
1403
|
float new_z = z_values[location.x_index][location.y_index];
|
1404
|
|
- if (isnan(new_z)) new_z = 0.0; // Invalid points begin at 0
|
1405
|
|
- new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
|
|
1404
|
+ if (isnan(new_z)) new_z = 0; // Invalid points begin at 0
|
|
1405
|
+ new_z = FLOOR(new_z * 1000) * 0.001f; // Chop off digits after the 1000ths place
|
1406
|
1406
|
|
1407
|
1407
|
lcd_mesh_edit_setup(new_z);
|
1408
|
1408
|
|
|
@@ -1461,7 +1461,7 @@
|
1461
|
1461
|
if (z_values[x1][y1] < z_values[x2][y2]) // Angled downward?
|
1462
|
1462
|
z_values[x][y] = z_values[x1][y1]; // Use nearest (maybe a little too high.)
|
1463
|
1463
|
else
|
1464
|
|
- z_values[x][y] = 2.0 * z_values[x1][y1] - z_values[x2][y2]; // Angled upward...
|
|
1464
|
+ z_values[x][y] = 2.0f * z_values[x1][y1] - z_values[x2][y2]; // Angled upward...
|
1465
|
1465
|
return true;
|
1466
|
1466
|
}
|
1467
|
1467
|
return false;
|
|
@@ -1510,8 +1510,8 @@
|
1510
|
1510
|
|
1511
|
1511
|
float measured_z;
|
1512
|
1512
|
|
1513
|
|
- const float dx = float(x_max - x_min) / (g29_grid_size - 1.0),
|
1514
|
|
- dy = float(y_max - y_min) / (g29_grid_size - 1.0);
|
|
1513
|
+ const float dx = float(x_max - x_min) / (g29_grid_size - 1),
|
|
1514
|
+ dy = float(y_max - y_min) / (g29_grid_size - 1);
|
1515
|
1515
|
|
1516
|
1516
|
struct linear_fit_data lsf_results;
|
1517
|
1517
|
|
|
@@ -1634,7 +1634,7 @@
|
1634
|
1634
|
return;
|
1635
|
1635
|
}
|
1636
|
1636
|
|
1637
|
|
- vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1.0000).get_normal();
|
|
1637
|
+ vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1).get_normal();
|
1638
|
1638
|
|
1639
|
1639
|
if (g29_verbose_level > 2) {
|
1640
|
1640
|
SERIAL_ECHOPGM("bed plane normal = [");
|
|
@@ -1713,7 +1713,7 @@
|
1713
|
1713
|
* The only difference is just 3 points are used in the calculations. That fact guarantees
|
1714
|
1714
|
* each probed point should have an exact match when a get_z_correction() for that location
|
1715
|
1715
|
* is calculated. The Z error between the probed point locations and the get_z_correction()
|
1716
|
|
- * numbers for those locations should be 0.000
|
|
1716
|
+ * numbers for those locations should be 0.
|
1717
|
1717
|
*/
|
1718
|
1718
|
#if 0
|
1719
|
1719
|
float t, t1, d;
|
|
@@ -1743,13 +1743,13 @@
|
1743
|
1743
|
SERIAL_EOL();
|
1744
|
1744
|
|
1745
|
1745
|
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
|
1746
|
|
- d = t + normal.z * 0.000;
|
|
1746
|
+ d = t + normal.z * 0;
|
1747
|
1747
|
SERIAL_ECHOPGM("D from home location with Z=0 : ");
|
1748
|
1748
|
SERIAL_ECHO_F(d, 6);
|
1749
|
1749
|
SERIAL_EOL();
|
1750
|
1750
|
|
1751
|
1751
|
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
|
1752
|
|
- d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0.000;
|
|
1752
|
+ d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0;
|
1753
|
1753
|
SERIAL_ECHOPGM("D from home location using mesh value for Z: ");
|
1754
|
1754
|
SERIAL_ECHO_F(d, 6);
|
1755
|
1755
|
|
|
@@ -1800,7 +1800,7 @@
|
1800
|
1800
|
if (TEST(bitmap[jx], jy)) {
|
1801
|
1801
|
const float ry = mesh_index_to_ypos(jy),
|
1802
|
1802
|
rz = z_values[jx][jy],
|
1803
|
|
- w = 1.0 + weight_scaled / HYPOT((rx - px), (ry - py));
|
|
1803
|
+ w = 1 + weight_scaled / HYPOT((rx - px), (ry - py));
|
1804
|
1804
|
incremental_WLSF(&lsf_results, rx, ry, rz, w);
|
1805
|
1805
|
}
|
1806
|
1806
|
}
|