From 2da4d22520800f44f8b3e0ed1675444842d1299a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 8 Dec 2016 22:51:28 -0800 Subject: [PATCH] Pretty up ADVANCE code --- Marlin/planner.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 68aeac99a5..11b7fc82bf 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -1313,16 +1313,15 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const #elif ENABLED(ADVANCE) // Calculate advance rate - if (!esteps || (!block->steps[X_AXIS] && !block->steps[Y_AXIS] && !block->steps[Z_AXIS])) { - block->advance_rate = 0; - block->advance = 0; - } - else { - long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_steps_per_s2); - float advance = ((STEPS_PER_CUBIC_MM_E) * (EXTRUDER_ADVANCE_K)) * HYPOT(current_speed[E_AXIS], EXTRUSION_AREA) * 256; + if (esteps && (block->steps[X_AXIS] || block->steps[Y_AXIS] || block->steps[Z_AXIS])) { + const long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_steps_per_s2); + const float advance = ((STEPS_PER_CUBIC_MM_E) * (EXTRUDER_ADVANCE_K)) * HYPOT(current_speed[E_AXIS], EXTRUSION_AREA) * 256; block->advance = advance; block->advance_rate = acc_dist ? advance / (float)acc_dist : 0; } + else + block->advance_rate = block->advance = 0; + /** SERIAL_ECHO_START; SERIAL_ECHOPGM("advance :");