Followup to float maths patch

This commit is contained in:
Scott Lahteine 2018-07-06 20:41:08 -05:00
parent b143441251
commit 63f4c9bdb9
5 changed files with 61 additions and 61 deletions

View file

@ -82,12 +82,12 @@ public:
} }
static int8_t probe_index_x(const float &x) { static int8_t probe_index_x(const float &x) {
int8_t px = (x - (MESH_MIN_X) + 0.5 * (MESH_X_DIST)) * (1.0f / (MESH_X_DIST)); int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * (1.0f / (MESH_X_DIST));
return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1; return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
} }
static int8_t probe_index_y(const float &y) { static int8_t probe_index_y(const float &y) {
int8_t py = (y - (MESH_MIN_Y) + 0.5 * (MESH_Y_DIST)) * (1.0f / (MESH_Y_DIST)); int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * (1.0f / (MESH_Y_DIST));
return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1; return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
} }

View file

@ -65,8 +65,8 @@
unified_bed_leveling::g29_y_flag; unified_bed_leveling::g29_y_flag;
float unified_bed_leveling::g29_x_pos, float unified_bed_leveling::g29_x_pos,
unified_bed_leveling::g29_y_pos, unified_bed_leveling::g29_y_pos,
unified_bed_leveling::g29_card_thickness = 0.0, unified_bed_leveling::g29_card_thickness = 0,
unified_bed_leveling::g29_constant = 0.0; unified_bed_leveling::g29_constant = 0;
#if HAS_BED_PROBE #if HAS_BED_PROBE
int unified_bed_leveling::g29_grid_size; int unified_bed_leveling::g29_grid_size;
@ -346,23 +346,23 @@
case 0: case 0:
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a bowl shape - similar to for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a bowl shape - similar to
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta. for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
const float p1 = 0.5 * (GRID_MAX_POINTS_X) - x, const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
p2 = 0.5 * (GRID_MAX_POINTS_Y) - y; p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
z_values[x][y] += 2.0 * HYPOT(p1, p2); z_values[x][y] += 2.0f * HYPOT(p1, p2);
} }
} }
break; break;
case 1: case 1:
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a diagonal line several Mesh cells thick that is raised for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a diagonal line several Mesh cells thick that is raised
z_values[x][x] += 9.999; z_values[x][x] += 9.999f;
z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999; // We want the altered line several mesh points thick z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
} }
break; break;
case 2: case 2:
// Allow the user to specify the height because 10mm is a little extreme in some cases. // Allow the user to specify the height because 10mm is a little extreme in some cases.
for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++) // Create a rectangular raised area in for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++) // Create a rectangular raised area in
for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) // the center of the bed for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) // the center of the bed
z_values[x][y] += parser.seen('C') ? g29_constant : 9.99; z_values[x][y] += parser.seen('C') ? g29_constant : 9.99f;
break; break;
} }
} }
@ -381,7 +381,7 @@
tilt_mesh_based_on_probed_grid(true /* true says to do 3-Point leveling */ ); tilt_mesh_based_on_probed_grid(true /* true says to do 3-Point leveling */ );
restore_ubl_active_state_and_leave(); restore_ubl_active_state_and_leave();
} }
do_blocking_move_to_xy(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y))); do_blocking_move_to_xy(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)));
report_current_position(); report_current_position();
} }
@ -453,7 +453,7 @@
if (parser.seen('B')) { if (parser.seen('B')) {
g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness((float) Z_CLEARANCE_BETWEEN_PROBES); g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness((float) Z_CLEARANCE_BETWEEN_PROBES);
if (ABS(g29_card_thickness) > 1.5) { if (ABS(g29_card_thickness) > 1.5f) {
SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement."); SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.");
return; return;
} }
@ -509,7 +509,7 @@
} }
else { else {
const float cvf = parser.value_float(); const float cvf = parser.value_float();
switch ((int)truncf(cvf * 10.0) - 30) { // 3.1 -> 1 switch ((int)truncf(cvf * 10.0f) - 30) { // 3.1 -> 1
#if ENABLED(UBL_G29_P31) #if ENABLED(UBL_G29_P31)
case 1: { case 1: {
@ -519,8 +519,8 @@
// P3.12 100X distance weighting // P3.12 100X distance weighting
// P3.13 1000X distance weighting, approaches simple average of nearest points // P3.13 1000X distance weighting, approaches simple average of nearest points
const float weight_power = (cvf - 3.10) * 100.0, // 3.12345 -> 2.345 const float weight_power = (cvf - 3.10f) * 100.0f, // 3.12345 -> 2.345
weight_factor = weight_power ? POW(10.0, weight_power) : 0; weight_factor = weight_power ? POW(10.0f, weight_power) : 0;
smart_fill_wlsf(weight_factor); smart_fill_wlsf(weight_factor);
} }
break; break;
@ -634,7 +634,7 @@
} }
void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) { void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) {
float sum = 0.0; float sum = 0;
int n = 0; int n = 0;
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
@ -648,7 +648,7 @@
// //
// Sum the squares of difference from mean // Sum the squares of difference from mean
// //
float sum_of_diff_squared = 0.0; float sum_of_diff_squared = 0;
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
if (!isnan(z_values[x][y])) if (!isnan(z_values[x][y]))
@ -786,7 +786,7 @@
float unified_bed_leveling::measure_point_with_encoder() { float unified_bed_leveling::measure_point_with_encoder() {
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);
move_z_with_encoder(0.01); move_z_with_encoder(0.01f);
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
return current_position[Z_AXIS]; return current_position[Z_AXIS];
} }
@ -797,8 +797,8 @@
lcd_external_control = true; lcd_external_control = true;
save_ubl_active_state_and_disable(); // Disable bed level correction for probing save_ubl_active_state_and_disable(); // Disable bed level correction for probing
do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height); do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
//, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) / 2.0); //, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) * 0.5f);
planner.synchronize(); planner.synchronize();
SERIAL_PROTOCOLPGM("Place shim under nozzle"); SERIAL_PROTOCOLPGM("Place shim under nozzle");
@ -874,7 +874,7 @@
serialprintPGM(parser.seen('B') ? PSTR(MSG_UBL_BC_INSERT) : PSTR(MSG_UBL_BC_INSERT2)); serialprintPGM(parser.seen('B') ? PSTR(MSG_UBL_BC_INSERT) : PSTR(MSG_UBL_BC_INSERT2));
const float z_step = 0.01; // existing behavior: 0.01mm per click, occasionally step const float z_step = 0.01f; // existing behavior: 0.01mm per click, occasionally step
//const float z_step = planner.steps_to_mm[Z_AXIS]; // approx one step each click //const float z_step = planner.steps_to_mm[Z_AXIS]; // approx one step each click
move_z_with_encoder(z_step); move_z_with_encoder(z_step);
@ -913,7 +913,7 @@
lcd_quick_feedback(true); lcd_quick_feedback(true);
#endif #endif
g29_constant = 0.0; g29_constant = 0;
g29_repetition_cnt = 0; g29_repetition_cnt = 0;
g29_x_flag = parser.seenval('X'); g29_x_flag = parser.seenval('X');
@ -1004,7 +1004,7 @@
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
if (parser.seenval('F')) { if (parser.seenval('F')) {
const float fh = parser.value_float(); const float fh = parser.value_float();
if (!WITHIN(fh, 0.0, 100.0)) { if (!WITHIN(fh, 0, 100)) {
SERIAL_PROTOCOLLNPGM("?(F)ade height for Bed Level Correction not plausible.\n"); SERIAL_PROTOCOLLNPGM("?(F)ade height for Bed Level Correction not plausible.\n");
return UBL_ERR; return UBL_ERR;
} }
@ -1226,7 +1226,7 @@
mesh_index_pair out_mesh; mesh_index_pair out_mesh;
out_mesh.x_index = out_mesh.y_index = -1; out_mesh.x_index = out_mesh.y_index = -1;
out_mesh.distance = -99999.99; out_mesh.distance = -99999.99f;
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) { for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) { for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
@ -1242,7 +1242,7 @@
found_a_NAN = true; found_a_NAN = true;
int8_t closest_x = -1, closest_y = -1; int8_t closest_x = -1, closest_y = -1;
float d1, d2 = 99999.9; float d1, d2 = 99999.9f;
for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) { for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) { for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
if (!isnan(z_values[k][l])) { if (!isnan(z_values[k][l])) {
@ -1279,7 +1279,7 @@
if (!found_a_real && found_a_NAN) { // if the mesh is totally unpopulated, start the probing if (!found_a_real && found_a_NAN) { // if the mesh is totally unpopulated, start the probing
out_mesh.x_index = GRID_MAX_POINTS_X / 2; out_mesh.x_index = GRID_MAX_POINTS_X / 2;
out_mesh.y_index = GRID_MAX_POINTS_Y / 2; out_mesh.y_index = GRID_MAX_POINTS_Y / 2;
out_mesh.distance = 1.0; out_mesh.distance = 1;
} }
return out_mesh; return out_mesh;
} }
@ -1287,13 +1287,13 @@
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]) { 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]) {
mesh_index_pair out_mesh; mesh_index_pair out_mesh;
out_mesh.x_index = out_mesh.y_index = -1; out_mesh.x_index = out_mesh.y_index = -1;
out_mesh.distance = -99999.9; out_mesh.distance = -99999.9f;
// Get our reference position. Either the nozzle or probe location. // Get our reference position. Either the nozzle or probe location.
const float px = rx - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0), const float px = rx - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
py = ry - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0); py = ry - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
float best_so_far = 99999.99; float best_so_far = 99999.99f;
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) { for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) { for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
@ -1320,7 +1320,7 @@
// factor in the distance from the current location for the normal case // factor in the distance from the current location for the normal case
// so the nozzle isn't running all over the bed. // so the nozzle isn't running all over the bed.
distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1; distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1f;
if (distance < best_so_far) { if (distance < best_so_far) {
best_so_far = distance; // We found a closer location with best_so_far = distance; // We found a closer location with
out_mesh.x_index = i; // the specified type of mesh value. out_mesh.x_index = i; // the specified type of mesh value.
@ -1401,8 +1401,8 @@
lcd_refresh(); lcd_refresh();
float new_z = z_values[location.x_index][location.y_index]; float new_z = z_values[location.x_index][location.y_index];
if (isnan(new_z)) new_z = 0.0; // Invalid points begin at 0 if (isnan(new_z)) new_z = 0; // Invalid points begin at 0
new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place new_z = FLOOR(new_z * 1000) * 0.001f; // Chop off digits after the 1000ths place
lcd_mesh_edit_setup(new_z); lcd_mesh_edit_setup(new_z);
@ -1461,7 +1461,7 @@
if (z_values[x1][y1] < z_values[x2][y2]) // Angled downward? if (z_values[x1][y1] < z_values[x2][y2]) // Angled downward?
z_values[x][y] = z_values[x1][y1]; // Use nearest (maybe a little too high.) z_values[x][y] = z_values[x1][y1]; // Use nearest (maybe a little too high.)
else else
z_values[x][y] = 2.0 * z_values[x1][y1] - z_values[x2][y2]; // Angled upward... z_values[x][y] = 2.0f * z_values[x1][y1] - z_values[x2][y2]; // Angled upward...
return true; return true;
} }
return false; return false;
@ -1510,8 +1510,8 @@
float measured_z; float measured_z;
const float dx = float(x_max - x_min) / (g29_grid_size - 1.0), const float dx = float(x_max - x_min) / (g29_grid_size - 1),
dy = float(y_max - y_min) / (g29_grid_size - 1.0); dy = float(y_max - y_min) / (g29_grid_size - 1);
struct linear_fit_data lsf_results; struct linear_fit_data lsf_results;
@ -1634,7 +1634,7 @@
return; return;
} }
vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1.0000).get_normal(); vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1).get_normal();
if (g29_verbose_level > 2) { if (g29_verbose_level > 2) {
SERIAL_ECHOPGM("bed plane normal = ["); SERIAL_ECHOPGM("bed plane normal = [");
@ -1713,7 +1713,7 @@
* The only difference is just 3 points are used in the calculations. That fact guarantees * The only difference is just 3 points are used in the calculations. That fact guarantees
* each probed point should have an exact match when a get_z_correction() for that location * each probed point should have an exact match when a get_z_correction() for that location
* is calculated. The Z error between the probed point locations and the get_z_correction() * is calculated. The Z error between the probed point locations and the get_z_correction()
* numbers for those locations should be 0.000 * numbers for those locations should be 0.
*/ */
#if 0 #if 0
float t, t1, d; float t, t1, d;
@ -1743,13 +1743,13 @@
SERIAL_EOL(); SERIAL_EOL();
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT); t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
d = t + normal.z * 0.000; d = t + normal.z * 0;
SERIAL_ECHOPGM("D from home location with Z=0 : "); SERIAL_ECHOPGM("D from home location with Z=0 : ");
SERIAL_ECHO_F(d, 6); SERIAL_ECHO_F(d, 6);
SERIAL_EOL(); SERIAL_EOL();
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT); t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0.000; d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0;
SERIAL_ECHOPGM("D from home location using mesh value for Z: "); SERIAL_ECHOPGM("D from home location using mesh value for Z: ");
SERIAL_ECHO_F(d, 6); SERIAL_ECHO_F(d, 6);
@ -1800,7 +1800,7 @@
if (TEST(bitmap[jx], jy)) { if (TEST(bitmap[jx], jy)) {
const float ry = mesh_index_to_ypos(jy), const float ry = mesh_index_to_ypos(jy),
rz = z_values[jx][jy], rz = z_values[jx][jy],
w = 1.0 + weight_scaled / HYPOT((rx - px), (ry - py)); w = 1 + weight_scaled / HYPOT((rx - px), (ry - py));
incremental_WLSF(&lsf_results, rx, ry, rz, w); incremental_WLSF(&lsf_results, rx, ry, rz, w);
} }
} }

View file

@ -384,7 +384,7 @@ void MarlinSettings::postprocess() {
* M500 - Store Configuration * M500 - Store Configuration
*/ */
bool MarlinSettings::save(PORTARG_SOLO) { bool MarlinSettings::save(PORTARG_SOLO) {
float dummy = 0.0f; float dummy = 0;
char ver[4] = "ERR"; char ver[4] = "ERR";
uint16_t working_crc = 0; uint16_t working_crc = 0;
@ -466,7 +466,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(mesh_num_y); EEPROM_WRITE(mesh_num_y);
EEPROM_WRITE(mbl.z_values); EEPROM_WRITE(mbl.z_values);
#else // For disabled MBL write a default mesh #else // For disabled MBL write a default mesh
dummy = 0.0f; dummy = 0;
const uint8_t mesh_num_x = 3, mesh_num_y = 3; const uint8_t mesh_num_x = 3, mesh_num_y = 3;
EEPROM_WRITE(dummy); // z_offset EEPROM_WRITE(dummy); // z_offset
EEPROM_WRITE(mesh_num_x); EEPROM_WRITE(mesh_num_x);
@ -488,7 +488,7 @@ void MarlinSettings::postprocess() {
#if ABL_PLANAR #if ABL_PLANAR
EEPROM_WRITE(planner.bed_level_matrix); EEPROM_WRITE(planner.bed_level_matrix);
#else #else
dummy = 0.0f; dummy = 0;
for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy); for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
#endif #endif
@ -512,7 +512,7 @@ void MarlinSettings::postprocess() {
// For disabled Bilinear Grid write an empty 3x3 grid // For disabled Bilinear Grid write an empty 3x3 grid
const uint8_t grid_max_x = 3, grid_max_y = 3; const uint8_t grid_max_x = 3, grid_max_y = 3;
const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 }; const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
dummy = 0.0f; dummy = 0;
EEPROM_WRITE(grid_max_x); EEPROM_WRITE(grid_max_x);
EEPROM_WRITE(grid_max_y); EEPROM_WRITE(grid_max_y);
EEPROM_WRITE(bilinear_grid_spacing); EEPROM_WRITE(bilinear_grid_spacing);
@ -550,7 +550,7 @@ void MarlinSettings::postprocess() {
_FIELD_TEST(x_endstop_adj); _FIELD_TEST(x_endstop_adj);
// Write dual endstops in X, Y, Z order. Unused = 0.0 // Write dual endstops in X, Y, Z order. Unused = 0.0
dummy = 0.0f; dummy = 0;
#if ENABLED(X_DUAL_ENDSTOPS) #if ENABLED(X_DUAL_ENDSTOPS)
EEPROM_WRITE(endstops.x_endstop_adj); // 1 float EEPROM_WRITE(endstops.x_endstop_adj); // 1 float
#else #else
@ -602,7 +602,7 @@ void MarlinSettings::postprocess() {
{ {
dummy = DUMMY_PID_VALUE; // When read, will not change the existing value dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
EEPROM_WRITE(dummy); // Kp EEPROM_WRITE(dummy); // Kp
dummy = 0.0f; dummy = 0;
for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc
} }
@ -848,7 +848,7 @@ void MarlinSettings::postprocess() {
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
EEPROM_WRITE(planner.extruder_advance_K); EEPROM_WRITE(planner.extruder_advance_K);
#else #else
dummy = 0.0f; dummy = 0;
EEPROM_WRITE(dummy); EEPROM_WRITE(dummy);
#endif #endif
@ -870,7 +870,7 @@ void MarlinSettings::postprocess() {
#if ENABLED(CNC_COORDINATE_SYSTEMS) #if ENABLED(CNC_COORDINATE_SYSTEMS)
EEPROM_WRITE(gcode.coordinate_system); // 27 floats EEPROM_WRITE(gcode.coordinate_system); // 27 floats
#else #else
dummy = 0.0f; dummy = 0;
for (uint8_t q = MAX_COORDINATE_SYSTEMS * XYZ; q--;) EEPROM_WRITE(dummy); for (uint8_t q = MAX_COORDINATE_SYSTEMS * XYZ; q--;) EEPROM_WRITE(dummy);
#endif #endif
@ -885,7 +885,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(planner.xz_skew_factor); EEPROM_WRITE(planner.xz_skew_factor);
EEPROM_WRITE(planner.yz_skew_factor); EEPROM_WRITE(planner.yz_skew_factor);
#else #else
dummy = 0.0f; dummy = 0;
for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
#endif #endif
@ -905,7 +905,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(dummy); EEPROM_WRITE(dummy);
} }
#else #else
dummy = 0.0f; dummy = 0;
for (uint8_t q = MAX_EXTRUDERS * 2; q--;) EEPROM_WRITE(dummy); for (uint8_t q = MAX_EXTRUDERS * 2; q--;) EEPROM_WRITE(dummy);
#endif #endif
@ -974,7 +974,7 @@ void MarlinSettings::postprocess() {
eeprom_error = true; eeprom_error = true;
} }
else { else {
float dummy = 0.0f; float dummy = 0;
#if DISABLED(AUTO_BED_LEVELING_UBL) || DISABLED(FWRETRACT) || ENABLED(NO_VOLUMETRICS) #if DISABLED(AUTO_BED_LEVELING_UBL) || DISABLED(FWRETRACT) || ENABLED(NO_VOLUMETRICS)
bool dummyb; bool dummyb;
#endif #endif

View file

@ -157,22 +157,22 @@ float delta_safe_distance_from_top() {
*/ */
void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3) { void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3) {
// Create a vector in old coordinates along x axis of new coordinate // Create a vector in old coordinates along x axis of new coordinate
const float p12[3] = { delta_tower[B_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[B_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z2 - z1 }; const float p12[3] = { delta_tower[B_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[B_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z2 - z1 },
// Get the reciprocal of Magnitude of vector. // Get the reciprocal of Magnitude of vector.
const float d2 = sq(p12[0]) + sq(p12[1]) + sq(p12[2]), inv_d = RSQRT(d2); d2 = sq(p12[0]) + sq(p12[1]) + sq(p12[2]), inv_d = RSQRT(d2),
// Create unit vector by multiplying by the inverse of the magnitude. // Create unit vector by multiplying by the inverse of the magnitude.
const float ex[3] = { p12[0] * inv_d, p12[1] * inv_d, p12[2] * inv_d }; ex[3] = { p12[0] * inv_d, p12[1] * inv_d, p12[2] * inv_d },
// Get the vector from the origin of the new system to the third point. // Get the vector from the origin of the new system to the third point.
const float p13[3] = { delta_tower[C_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[C_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z3 - z1 }; p13[3] = { delta_tower[C_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[C_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z3 - z1 },
// Use the dot product to find the component of this vector on the X axis. // Use the dot product to find the component of this vector on the X axis.
const float i = ex[0] * p13[0] + ex[1] * p13[1] + ex[2] * p13[2]; i = ex[0] * p13[0] + ex[1] * p13[1] + ex[2] * p13[2],
// Create a vector along the x axis that represents the x component of p13. // Create a vector along the x axis that represents the x component of p13.
const float iex[3] = { ex[0] * i, ex[1] * i, ex[2] * i }; iex[3] = { ex[0] * i, ex[1] * i, ex[2] * i };
// Subtract the X component from the original vector leaving only Y. We use the // Subtract the X component from the original vector leaving only Y. We use the
// variable that will be the unit vector after we scale it. // variable that will be the unit vector after we scale it.
@ -190,13 +190,13 @@ void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3)
ex[1] * ey[2] - ex[2] * ey[1], ex[1] * ey[2] - ex[2] * ey[1],
ex[2] * ey[0] - ex[0] * ey[2], ex[2] * ey[0] - ex[0] * ey[2],
ex[0] * ey[1] - ex[1] * ey[0] ex[0] * ey[1] - ex[1] * ey[0]
}; },
// We now have the d, i and j values defined in Wikipedia. // We now have the d, i and j values defined in Wikipedia.
// Plug them into the equations defined in Wikipedia for Xnew, Ynew and Znew // Plug them into the equations defined in Wikipedia for Xnew, Ynew and Znew
const float Xnew = (delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[B_AXIS] + d2) * inv_d * 0.5, Xnew = (delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[B_AXIS] + d2) * inv_d * 0.5,
Ynew = ((delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[C_AXIS] + sq(i) + j2) * 0.5 - i * Xnew) * inv_j, Ynew = ((delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[C_AXIS] + sq(i) + j2) * 0.5 - i * Xnew) * inv_j,
Znew = SQRT(delta_diagonal_rod_2_tower[A_AXIS] - HYPOT2(Xnew, Ynew)); Znew = SQRT(delta_diagonal_rod_2_tower[A_AXIS] - HYPOT2(Xnew, Ynew));
// Start from the origin of the old coordinates and add vectors in the // Start from the origin of the old coordinates and add vectors in the
// old coords that represent the Xnew, Ynew and Znew to find the point // old coords that represent the Xnew, Ynew and Znew to find the point

View file

@ -1317,7 +1317,7 @@ void Planner::check_axes_activity() {
* Return 1.0 with volumetric off or a diameter of 0.0. * Return 1.0 with volumetric off or a diameter of 0.0.
*/ */
inline float calculate_volumetric_multiplier(const float &diameter) { inline float calculate_volumetric_multiplier(const float &diameter) {
return (parser.volumetric_enabled && diameter) ? RECIPROCAL(CIRCLE_AREA(diameter * 0.5f)) : 1; return (parser.volumetric_enabled && diameter) ? 1.0f / CIRCLE_AREA(diameter * 0.5f) : 1;
} }
/** /**