@@ -698,69 +698,35 @@ void Planner::calculate_volumetric_multipliers() {
698698#endif // PLANNER_LEVELING
699699
700700/* *
701- * Planner::_buffer_line
701+ * Planner::_buffer_steps
702702 *
703- * Add a new linear movement to the buffer in axis units .
703+ * Add a new linear movement to the buffer ( in terms of steps) .
704704 *
705- * Leveling and kinematics should be applied ahead of calling this.
706- *
707- * a,b,c,e - target positions in mm and/or degrees
705+ * target - target position in steps units
708706 * fr_mm_s - (target) speed of the move
709707 * extruder - target extruder
710708 */
711- void Planner::_buffer_line (const float &a, const float &b, const float &c, const float &e, float fr_mm_s, const uint8_t extruder) {
712-
713- // The target position of the tool in absolute steps
714- // Calculate target position in absolute steps
715- // this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
716- const long target[XYZE] = {
717- LROUND (a * axis_steps_per_mm[X_AXIS]),
718- LROUND (b * axis_steps_per_mm[Y_AXIS]),
719- LROUND (c * axis_steps_per_mm[Z_AXIS]),
720- LROUND (e * axis_steps_per_mm[E_AXIS_N])
721- };
722-
723- // When changing extruders recalculate steps corresponding to the E position
724- #if ENABLED(DISTINCT_E_FACTORS)
725- if (last_extruder != extruder && axis_steps_per_mm[E_AXIS_N] != axis_steps_per_mm[E_AXIS + last_extruder]) {
726- position[E_AXIS] = LROUND (position[E_AXIS] * axis_steps_per_mm[E_AXIS_N] * steps_to_mm[E_AXIS + last_extruder]);
727- last_extruder = extruder;
728- }
729- #endif
709+ void Planner::_buffer_steps (const int32_t target[XYZE], float fr_mm_s, const uint8_t extruder) {
730710
731711 const int32_t da = target[X_AXIS] - position[X_AXIS],
732712 db = target[Y_AXIS] - position[Y_AXIS],
733713 dc = target[Z_AXIS] - position[Z_AXIS];
734714
735- /*
736- SERIAL_ECHOPAIR(" Planner FR:", fr_mm_s);
737- SERIAL_CHAR(' ');
738- #if IS_KINEMATIC
739- SERIAL_ECHOPAIR("A:", a);
740- SERIAL_ECHOPAIR(" (", da);
741- SERIAL_ECHOPAIR(") B:", b);
742- #else
743- SERIAL_ECHOPAIR("X:", a);
715+ int32_t de = target[E_AXIS] - position[E_AXIS];
716+
717+ /* <-- add a slash to enable
718+ SERIAL_ECHOPAIR(" _buffer_steps FR:", fr_mm_s);
719+ SERIAL_ECHOPAIR(" A:", target[A_AXIS]);
744720 SERIAL_ECHOPAIR(" (", da);
745- SERIAL_ECHOPAIR(") Y:", b);
746- #endif
747- SERIAL_ECHOPAIR(" (", db);
748- #if ENABLED(DELTA)
749- SERIAL_ECHOPAIR(") C:", c);
750- #else
751- SERIAL_ECHOPAIR(") Z:", c);
752- #endif
753- SERIAL_ECHOPAIR(" (", dc);
754- SERIAL_CHAR(')');
755- SERIAL_EOL();
721+ SERIAL_ECHOPAIR(" steps) B:", target[B_AXIS]);
722+ SERIAL_ECHOPAIR(" (", db);
723+ SERIAL_ECHOLNPGM(" steps) C:", target[C_AXIS]);
724+ SERIAL_ECHOPAIR(" (", dc);
725+ SERIAL_ECHOLNPGM(" steps) E:", target[E_AXIS]);
726+ SERIAL_ECHOPAIR(" (", de);
727+ SERIAL_ECHOLNPGM(" steps)");
756728 //*/
757729
758- // DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied
759- if (DEBUGGING (DRYRUN))
760- position[E_AXIS] = target[E_AXIS];
761-
762- int32_t de = target[E_AXIS] - position[E_AXIS];
763-
764730 #if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
765731 if (de) {
766732 #if ENABLED(PREVENT_COLD_EXTRUSION)
@@ -1067,6 +1033,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
10671033 // Segment time im micro seconds
10681034 uint32_t segment_time_us = LROUND (1000000.0 / inverse_secs);
10691035 #endif
1036+
10701037 #if ENABLED(SLOWDOWN)
10711038 if (WITHIN (moves_queued, 2 , (BLOCK_BUFFER_SIZE) / 2 - 1 )) {
10721039 if (segment_time_us < min_segment_time_us) {
@@ -1305,7 +1272,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
13051272 }
13061273 }
13071274
1308- if (moves_queued > 1 && !UNEAR_ZERO (previous_nominal_speed)) {
1275+ if (moves_queued && !UNEAR_ZERO (previous_nominal_speed)) {
13091276 // Estimate a maximum velocity allowed at a joint of two successive segments.
13101277 // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
13111278 // then the machine is not coasting anymore and the safe entry / exit velocities shall be used.
@@ -1417,9 +1384,79 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
14171384
14181385 recalculate ();
14191386
1387+ } // _buffer_steps()
1388+
1389+ /* *
1390+ * Planner::_buffer_line
1391+ *
1392+ * Add a new linear movement to the buffer in axis units.
1393+ *
1394+ * Leveling and kinematics should be applied ahead of calling this.
1395+ *
1396+ * a,b,c,e - target positions in mm and/or degrees
1397+ * fr_mm_s - (target) speed of the move
1398+ * extruder - target extruder
1399+ */
1400+ void Planner::_buffer_line (const float &a, const float &b, const float &c, const float &e, const float &fr_mm_s, const uint8_t extruder) {
1401+ // When changing extruders recalculate steps corresponding to the E position
1402+ #if ENABLED(DISTINCT_E_FACTORS)
1403+ if (last_extruder != extruder && axis_steps_per_mm[E_AXIS_N] != axis_steps_per_mm[E_AXIS + last_extruder]) {
1404+ position[E_AXIS] = LROUND (position[E_AXIS] * axis_steps_per_mm[E_AXIS_N] * steps_to_mm[E_AXIS + last_extruder]);
1405+ last_extruder = extruder;
1406+ }
1407+ #endif
1408+
1409+ // The target position of the tool in absolute steps
1410+ // Calculate target position in absolute steps
1411+ const int32_t target[XYZE] = {
1412+ LROUND (a * axis_steps_per_mm[X_AXIS]),
1413+ LROUND (b * axis_steps_per_mm[Y_AXIS]),
1414+ LROUND (c * axis_steps_per_mm[Z_AXIS]),
1415+ LROUND (e * axis_steps_per_mm[E_AXIS_N])
1416+ };
1417+
1418+ /* <-- add a slash to enable
1419+ SERIAL_ECHOPAIR(" _buffer_line FR:", fr_mm_s);
1420+ #if IS_KINEMATIC
1421+ SERIAL_ECHOPAIR(" A:", a);
1422+ SERIAL_ECHOPAIR(" (", target[A_AXIS]);
1423+ SERIAL_ECHOPAIR(" steps) B:", b);
1424+ #else
1425+ SERIAL_ECHOPAIR(" X:", a);
1426+ SERIAL_ECHOPAIR(" (", target[X_AXIS]);
1427+ SERIAL_ECHOPAIR(" steps) Y:", b);
1428+ #endif
1429+ SERIAL_ECHOPAIR(" (", target[Y_AXIS]);
1430+ #if ENABLED(DELTA)
1431+ SERIAL_ECHOPAIR(" steps) C:", c);
1432+ #else
1433+ SERIAL_ECHOPAIR(" steps) Z:", c);
1434+ #endif
1435+ SERIAL_ECHOPAIR(" (", target[Z_AXIS]);
1436+ SERIAL_ECHOPAIR(" steps) E:", e);
1437+ SERIAL_ECHOPAIR(" (", target[E_AXIS]);
1438+ SERIAL_ECHOLNPGM(" steps)");
1439+ //*/
1440+
1441+ // DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied
1442+ if (DEBUGGING (DRYRUN))
1443+ position[E_AXIS] = target[E_AXIS];
1444+
1445+ // Always split the first move in two so it can chain
1446+ if (!blocks_queued ()) {
1447+ DISABLE_STEPPER_DRIVER_INTERRUPT ();
1448+ #define _BETWEEN (A ) (position[A##_AXIS] + target[A##_AXIS]) >> 1
1449+ const int32_t between[XYZE] = { _BETWEEN (X), _BETWEEN (Y), _BETWEEN (Z), _BETWEEN (E) };
1450+ _buffer_steps (between, fr_mm_s, extruder);
1451+ _buffer_steps (target, fr_mm_s, extruder);
1452+ ENABLE_STEPPER_DRIVER_INTERRUPT ();
1453+ }
1454+ else
1455+ _buffer_steps (target, fr_mm_s, extruder);
1456+
14201457 stepper.wake_up ();
14211458
1422- } // buffer_line ()
1459+ } // _buffer_line ()
14231460
14241461/* *
14251462 * Directly set the planner XYZ position (and stepper positions)
0 commit comments