Prusa MINI Firmware overview
planner.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 /**
25  * planner.h
26  *
27  * Buffer movement commands and manage the acceleration profile plan
28  *
29  * Derived from Grbl
30  * Copyright (c) 2009-2011 Simen Svale Skogsrud
31  */
32 
33 #include "../Marlin.h"
34 
35 #include "motion.h"
36 #include "../gcode/queue.h"
37 
38 #if ENABLED(DELTA)
39  #include "delta.h"
40 #endif
41 
42 #if ABL_PLANAR
43  #include "../libs/vector_3.h" // for matrix_3x3
44 #endif
45 
46 #if ENABLED(FWRETRACT)
47  #include "../feature/fwretract.h"
48 #endif
49 
50 #if ENABLED(MIXING_EXTRUDER)
51  #include "../feature/mixing.h"
52 #endif
53 
54 #if HAS_CUTTER
55  #include "../feature/spindle_laser.h"
56 #endif
57 
58 // Feedrate for manual moves
59 #ifdef MANUAL_FEEDRATE
60  constexpr xyze_feedrate_t manual_feedrate_mm_m = MANUAL_FEEDRATE;
61 #endif
62 
63 enum BlockFlagBit : char {
64  // Recalculate trapezoids on entry junction. For optimization.
66 
67  // Nominal speed always reached.
68  // i.e., The segment is long enough, so the nominal speed is reachable if accelerating
69  // from a safe speed (in consideration of jerking from zero speed).
71 
72  // The block is segment 2+ of a longer move
74 
75  // Sync the stepper counts from the block
77 };
78 
79 enum BlockFlag : char {
84 };
85 
86 /**
87  * struct block_t
88  *
89  * A single entry in the planner buffer.
90  * Tracks linear movement over multiple axes.
91  *
92  * The "nominal" values are as-specified by gcode, and
93  * may never actually be reached due to acceleration limits.
94  */
95 typedef struct block_t {
96 
97  volatile uint8_t flag; // Block flags (See BlockFlag enum above) - Modified by ISR and main thread!
98 
99  // Fields used by the motion planner to manage acceleration
100  float nominal_speed_sqr, // The nominal speed for this block in (mm/sec)^2
101  entry_speed_sqr, // Entry speed at previous-current junction in (mm/sec)^2
102  max_entry_speed_sqr, // Maximum allowable junction entry speed in (mm/sec)^2
103  millimeters, // The total travel of this block in mm
104  acceleration; // acceleration mm/sec^2
105 
106  union {
107  abce_ulong_t steps; // Step count along each axis
108  abce_long_t position; // New position to force when this sync block is executed
109  };
110  uint32_t step_event_count; // The number of step events required to complete this block
111 
112  #if EXTRUDERS > 1
113  uint8_t extruder; // The extruder to move (if E move)
114  #else
115  static constexpr uint8_t extruder = 0;
116  #endif
117 
118  #if ENABLED(MIXING_EXTRUDER)
119  MIXER_BLOCK_FIELD; // Normalized color for the mixing steppers
120  #endif
121 
122  // Settings for the trapezoid generator
123  uint32_t accelerate_until, // The index of the step event on which to stop acceleration
124  decelerate_after; // The index of the step event on which to start decelerating
125 
126  #if ENABLED(S_CURVE_ACCELERATION)
127  uint32_t cruise_rate, // The actual cruise rate to use, between end of the acceleration phase and start of deceleration phase
128  acceleration_time, // Acceleration time and deceleration time in STEP timer counts
129  deceleration_time,
130  acceleration_time_inverse, // Inverse of acceleration and deceleration periods, expressed as integer. Scale depends on CPU being used
131  deceleration_time_inverse;
132  #else
133  uint32_t acceleration_rate; // The acceleration rate used for acceleration calculation
134  #endif
135 
136  uint8_t direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
137 
138  // Advance extrusion
139  #if ENABLED(LIN_ADVANCE)
140  bool use_advance_lead;
141  uint16_t advance_speed, // STEP timer value for extruder speed offset ISR
142  max_adv_steps, // max. advance steps to get cruising speed pressure (not always nominal_speed!)
143  final_adv_steps; // advance steps due to exit speed
144  float e_D_ratio;
145  #endif
146 
147  uint32_t nominal_rate, // The nominal step rate for this block in step_events/sec
148  initial_rate, // The jerk-adjusted step rate at start of block
149  final_rate, // The minimal rate at exit
150  acceleration_steps_per_s2; // acceleration steps/sec^2
151 
152  #if HAS_CUTTER
153  cutter_power_t cutter_power; // Power level for Spindle, Laser, etc.
154  #endif
155 
156  #if FAN_COUNT > 0
157  uint8_t fan_speed[FAN_COUNT];
158  #endif
159 
160  #if ENABLED(BARICUDA)
161  uint8_t valve_pressure, e_to_p_pressure;
162  #endif
163 
164  #if HAS_SPI_LCD
165  uint32_t segment_time_us;
166  #endif
167 
168  #if ENABLED(POWER_LOSS_RECOVERY)
169  uint32_t sdpos;
170  #endif
171 
172 } block_t;
173 
174 #define HAS_POSITION_FLOAT ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX)
175 
176 #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
177 
178 typedef struct {
179  uint32_t max_acceleration_mm_per_s2[XYZE_N], // (mm/s^2) M201 XYZE
180  min_segment_time_us; // (µs) M205 B
181  float axis_steps_per_mm[XYZE_N]; // (steps) M92 XYZE - Steps per millimeter
182  feedRate_t max_feedrate_mm_s[XYZE_N]; // (mm/s) M203 XYZE - Max speeds
183  float acceleration, // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves.
184  retract_acceleration, // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes
185  travel_acceleration; // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves.
186  feedRate_t min_feedrate_mm_s, // (mm/s) M205 S - Minimum linear feedrate
187  min_travel_feedrate_mm_s; // (mm/s) M205 T - Minimum travel feedrate
189 
190 #if DISABLED(SKEW_CORRECTION)
191  #define XY_SKEW_FACTOR 0
192  #define XZ_SKEW_FACTOR 0
193  #define YZ_SKEW_FACTOR 0
194 #endif
195 
196 typedef struct {
197  #if ENABLED(SKEW_CORRECTION_GCODE)
198  float xy;
199  #if ENABLED(SKEW_CORRECTION_FOR_Z)
200  float xz, yz;
201  #else
202  const float xz = XZ_SKEW_FACTOR, yz = YZ_SKEW_FACTOR;
203  #endif
204  #else
205  const float xy = XY_SKEW_FACTOR,
206  xz = XZ_SKEW_FACTOR, yz = YZ_SKEW_FACTOR;
207  #endif
208 } skew_factor_t;
209 
210 class Planner {
211  public:
212 
213  /**
214  * The move buffer, calculated in stepper steps
215  *
216  * block_buffer is a ring buffer...
217  *
218  * head,tail : indexes for write,read
219  * head==tail : the buffer is empty
220  * head!=tail : blocks are in the buffer
221  * head==(tail-1)%size : the buffer is full
222  *
223  * Writer of head is Planner::buffer_segment().
224  * Reader of tail is Stepper::isr(). Always consider tail busy / read-only
225  */
227  static volatile uint8_t block_buffer_head, // Index of the next block to be pushed
228  block_buffer_nonbusy, // Index of the first non busy block
229  block_buffer_planned, // Index of the optimally planned block
230  block_buffer_tail; // Index of the busy block, if any
231  static uint16_t cleaning_buffer_counter; // A counter to disable queuing of blocks
232  static uint8_t delay_before_delivering; // This counter delays delivery of blocks when queue becomes empty to allow the opportunity of merging blocks
233 
234 
235  #if ENABLED(DISTINCT_E_FACTORS)
236  static uint8_t last_extruder; // Respond to extruder change
237  #endif
238 
239  #if EXTRUDERS
240  static int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder
241  static float e_factor[EXTRUDERS]; // The flow percentage and volumetric multiplier combine to scale E movement
242  #endif
243 
244  #if DISABLED(NO_VOLUMETRICS)
245  static float filament_size[EXTRUDERS], // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
246  volumetric_area_nominal, // Nominal cross-sectional area
247  volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
248  // May be auto-adjusted by a filament width sensor
249  #endif
250 
252 
253  static uint32_t max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2
254  static float steps_to_mm[XYZE_N]; // Millimeters per step
255 
256  #if DISABLED(CLASSIC_JERK)
257  static float junction_deviation_mm; // (mm) M205 J
258  #if ENABLED(LIN_ADVANCE)
259  static float max_e_jerk // Calculated from junction_deviation_mm
260  #if ENABLED(DISTINCT_E_FACTORS)
261  [EXTRUDERS]
262  #endif
263  ;
264  #endif
265  #endif
266 
267  #if HAS_CLASSIC_JERK
268  #if HAS_LINEAR_E_JERK
269  static xyz_pos_t max_jerk; // (mm/s^2) M205 XYZ - The largest speed change requiring no acceleration.
270  #else
271  static xyze_pos_t max_jerk; // (mm/s^2) M205 XYZE - The largest speed change requiring no acceleration.
272  #endif
273  #endif
274 
275  #if HAS_LEVELING
276  static bool leveling_active; // Flag that bed leveling is enabled
277  #if ABL_PLANAR
278  static matrix_3x3 bed_level_matrix; // Transform to compensate for bed level
279  #endif
280  #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
281  static float z_fade_height, inverse_z_fade_height;
282  #endif
283  #else
284  static constexpr bool leveling_active = false;
285  #endif
286 
287  #if ENABLED(LIN_ADVANCE)
288  static float extruder_advance_K[EXTRUDERS];
289  #endif
290 
291  #if HAS_POSITION_FLOAT
293  #endif
294 
295  #if IS_KINEMATIC
296  static xyze_pos_t position_cart;
297  #endif
298 
300 
301  #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT)
302  static bool abort_on_endstop_hit;
303  #endif
304 
305  private:
306 
307  /**
308  * The current position of the tool in absolute steps
309  * Recalculated if any axis_steps_per_mm are changed by gcode
310  */
311  static xyze_long_t position;
312 
313  /**
314  * Speed of previous path line segment
315  */
316  static xyze_float_t previous_speed;
317 
318  /**
319  * Nominal speed of previous path line segment (mm/s)^2
320  */
321  static float previous_nominal_speed_sqr;
322 
323  /**
324  * Limit where 64bit math is necessary for acceleration calculation
325  */
326  static uint32_t cutoff_long;
327 
328  #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
329  static float last_fade_z;
330  #endif
331 
332  #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
333  /**
334  * Counters to manage disabling inactive extruders
335  */
336  static uint8_t g_uc_extruder_last_move[EXTRUDERS];
337  #endif // DISABLE_INACTIVE_EXTRUDER
338 
339  #ifdef XY_FREQUENCY_LIMIT
340  // Used for the frequency limit
341  #define MAX_FREQ_TIME_US (uint32_t)(1000000.0 / XY_FREQUENCY_LIMIT)
342  // Old direction bits. Used for speed calculations
343  static unsigned char old_direction_bits;
344  // Segment times (in µs). Used for speed calculations
345  static xy_ulong_t axis_segment_time_us[3];
346  #endif
347 
348  #if HAS_SPI_LCD
349  volatile static uint32_t block_buffer_runtime_us; //Theoretical block buffer runtime in µs
350  #endif
351 
352  public:
353 
354  /**
355  * Instance Methods
356  */
357 
358  Planner();
359 
360  void init();
361 
362  /**
363  * Static (class) Methods
364  */
365 
366  static void reset_acceleration_rates();
367  static void refresh_positioning();
368  static void set_max_acceleration(const uint8_t axis, float targetValue);
369  static void set_max_feedrate(const uint8_t axis, float targetValue);
370  static void set_max_jerk(const AxisEnum axis, float targetValue);
371 
372 
373  #if EXTRUDERS
374  FORCE_INLINE static void refresh_e_factor(const uint8_t e) {
375  e_factor[e] = (flow_percentage[e] * 0.01f
376  #if DISABLED(NO_VOLUMETRICS)
377  * volumetric_multiplier[e]
378  #endif
379  );
380  }
381  #endif
382 
383  // Manage fans, paste pressure, etc.
384  static void check_axes_activity();
385 
386  // Update multipliers based on new diameter measurements
387  static void calculate_volumetric_multipliers();
388 
389  #if ENABLED(FILAMENT_WIDTH_SENSOR)
390  void apply_filament_width_sensor(const int8_t encoded_ratio);
391 
392  static inline float volumetric_percent(const bool vol) {
393  return 100.0f * (vol
394  ? volumetric_area_nominal / volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
395  : volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
396  );
397  }
398  #endif
399 
400  #if DISABLED(NO_VOLUMETRICS)
401 
402  FORCE_INLINE static void set_filament_size(const uint8_t e, const float &v) {
403  filament_size[e] = v;
404  // make sure all extruders have some sane value for the filament size
405  for (uint8_t i = 0; i < COUNT(filament_size); i++)
406  if (!filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
407  }
408 
409  #endif
410 
411  #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
412 
413  /**
414  * Get the Z leveling fade factor based on the given Z height,
415  * re-calculating only when needed.
416  *
417  * Returns 1.0 if planner.z_fade_height is 0.0.
418  * Returns 0.0 if Z is past the specified 'Fade Height'.
419  */
420  static inline float fade_scaling_factor_for_z(const float &rz) {
421  static float z_fade_factor = 1;
422  if (!z_fade_height) return 1;
423  if (rz >= z_fade_height) return 0;
424  if (last_fade_z != rz) {
425  last_fade_z = rz;
426  z_fade_factor = 1 - rz * inverse_z_fade_height;
427  }
428  return z_fade_factor;
429  }
430 
431  FORCE_INLINE static void force_fade_recalc() { last_fade_z = -999.999f; }
432 
433  FORCE_INLINE static void set_z_fade_height(const float &zfh) {
434  z_fade_height = zfh > 0 ? zfh : 0;
435  inverse_z_fade_height = RECIPROCAL(z_fade_height);
436  force_fade_recalc();
437  }
438 
439  FORCE_INLINE static bool leveling_active_at_z(const float &rz) {
440  return !z_fade_height || rz < z_fade_height;
441  }
442 
443  #else
444 
445  FORCE_INLINE static float fade_scaling_factor_for_z(const float&) { return 1; }
446 
447  FORCE_INLINE static bool leveling_active_at_z(const float&) { return true; }
448 
449  #endif
450 
451  #if ENABLED(SKEW_CORRECTION)
452 
453  FORCE_INLINE static void skew(float &cx, float &cy, const float &cz) {
454  if (WITHIN(cx, X_MIN_POS + 1, X_MAX_POS) && WITHIN(cy, Y_MIN_POS + 1, Y_MAX_POS)) {
455  const float sx = cx - cy * skew_factor.xy - cz * (skew_factor.xz - (skew_factor.xy * skew_factor.yz)),
456  sy = cy - cz * skew_factor.yz;
457  if (WITHIN(sx, X_MIN_POS, X_MAX_POS) && WITHIN(sy, Y_MIN_POS, Y_MAX_POS)) {
458  cx = sx; cy = sy;
459  }
460  }
461  }
462  FORCE_INLINE static void skew(xyz_pos_t &raw) { skew(raw.x, raw.y, raw.z); }
463 
464  FORCE_INLINE static void unskew(float &cx, float &cy, const float &cz) {
465  if (WITHIN(cx, X_MIN_POS, X_MAX_POS) && WITHIN(cy, Y_MIN_POS, Y_MAX_POS)) {
466  const float sx = cx + cy * skew_factor.xy + cz * skew_factor.xz,
467  sy = cy + cz * skew_factor.yz;
468  if (WITHIN(sx, X_MIN_POS, X_MAX_POS) && WITHIN(sy, Y_MIN_POS, Y_MAX_POS)) {
469  cx = sx; cy = sy;
470  }
471  }
472  }
473  FORCE_INLINE static void unskew(xyz_pos_t &raw) { unskew(raw.x, raw.y, raw.z); }
474 
475  #endif // SKEW_CORRECTION
476 
477  #if HAS_LEVELING
478  /**
479  * Apply leveling to transform a cartesian position
480  * as it will be given to the planner and steppers.
481  */
482  static void apply_leveling(xyz_pos_t &raw);
483  static void unapply_leveling(xyz_pos_t &raw);
485  leveling_active = true;
486  unapply_leveling(raw);
487  leveling_active = false;
488  }
489  #endif
490 
491  #if ENABLED(FWRETRACT)
492  static void apply_retract(float &rz, float &e);
493  FORCE_INLINE static void apply_retract(xyze_pos_t &raw) { apply_retract(raw.z, raw.e); }
494  static void unapply_retract(float &rz, float &e);
495  FORCE_INLINE static void unapply_retract(xyze_pos_t &raw) { unapply_retract(raw.z, raw.e); }
496  #endif
497 
498  #if HAS_POSITION_MODIFIERS
500  #if HAS_LEVELING
501  , bool leveling =
502  #if PLANNER_LEVELING
503  true
504  #else
505  false
506  #endif
507  #endif
508  ) {
509  #if ENABLED(SKEW_CORRECTION)
510  skew(pos);
511  #endif
512  #if HAS_LEVELING
513  if (leveling) apply_leveling(pos);
514  #endif
515  #if ENABLED(FWRETRACT)
516  apply_retract(pos);
517  #endif
518  }
519 
521  #if HAS_LEVELING
522  , bool leveling =
523  #if PLANNER_LEVELING
524  true
525  #else
526  false
527  #endif
528  #endif
529  ) {
530  #if ENABLED(FWRETRACT)
531  unapply_retract(pos);
532  #endif
533  #if HAS_LEVELING
534  if (leveling) unapply_leveling(pos);
535  #endif
536  #if ENABLED(SKEW_CORRECTION)
537  unskew(pos);
538  #endif
539  }
540  #endif // HAS_POSITION_MODIFIERS
541 
542  // Number of moves currently in the planner including the busy block, if any
544 
545  // Number of nonbusy moves currently in the planner
547 
548  // Remove all blocks from the buffer
550 
551  // Check if movement queue is full
552  FORCE_INLINE static bool is_full() { return block_buffer_tail == next_block_index(block_buffer_head); }
553 
554  // Get count of movement slots free
556 
557  /**
558  * Planner::get_next_free_block
559  *
560  * - Get the next head indices (passed by reference)
561  * - Wait for the number of spaces to open up in the planner
562  * - Return the first head block
563  */
564  FORCE_INLINE static block_t* get_next_free_block(uint8_t &next_buffer_head, const uint8_t count=1) {
565 
566  // Wait until there are enough slots free
567  while (moves_free() < count) { idle(); }
568 
569  // Return the first available block
570  next_buffer_head = next_block_index(block_buffer_head);
572  }
573 
574  /**
575  * Planner::_buffer_steps
576  *
577  * Add a new linear movement to the buffer (in terms of steps).
578  *
579  * target - target position in steps units
580  * fr_mm_s - (target) speed of the move
581  * extruder - target extruder
582  * millimeters - the length of the movement, if known
583  *
584  * Returns true if movement was buffered, false otherwise
585  */
586  static bool _buffer_steps(const xyze_long_t &target
588  , const xyze_pos_t &target_float
589  #endif
590  #if IS_KINEMATIC && DISABLED(CLASSIC_JERK)
591  , const xyze_float_t &delta_mm_cart
592  #endif
593  , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
594  );
595 
596  /**
597  * Planner::_populate_block
598  *
599  * Fills a new linear movement in the block (in terms of steps).
600  *
601  * target - target position in steps units
602  * fr_mm_s - (target) speed of the move
603  * extruder - target extruder
604  * millimeters - the length of the movement, if known
605  *
606  * Returns true is movement is acceptable, false otherwise
607  */
608  static bool _populate_block(block_t * const block, bool split_move,
609  const xyze_long_t &target
611  , const xyze_pos_t &target_float
612  #endif
613  #if IS_KINEMATIC && DISABLED(CLASSIC_JERK)
614  , const xyze_float_t &delta_mm_cart
615  #endif
616  , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
617  );
618 
619  /**
620  * Planner::buffer_sync_block
621  * Add a block to the buffer that just updates the position
622  */
623  static void buffer_sync_block();
624 
625  #if IS_KINEMATIC
626  private:
627 
628  // Allow do_homing_move to access internal functions, such as buffer_segment.
629  friend void do_homing_move(const AxisEnum, const float, const feedRate_t);
630  #endif
631 
632  /**
633  * Planner::buffer_segment
634  *
635  * Add a new linear movement to the buffer in axis units.
636  *
637  * Leveling and kinematics should be applied ahead of calling this.
638  *
639  * a,b,c,e - target positions in mm and/or degrees
640  * fr_mm_s - (target) speed of the move
641  * extruder - target extruder
642  * millimeters - the length of the movement, if known
643  */
644  static bool buffer_segment(const float &a, const float &b, const float &c, const float &e
645  #if IS_KINEMATIC && DISABLED(CLASSIC_JERK)
646  , const xyze_float_t &delta_mm_cart
647  #endif
648  , const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
649  );
650 
652  #if IS_KINEMATIC && DISABLED(CLASSIC_JERK)
653  , const xyze_float_t &delta_mm_cart
654  #endif
655  , const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
656  ) {
657  return buffer_segment(abce.a, abce.b, abce.c, abce.e
658  #if IS_KINEMATIC && DISABLED(CLASSIC_JERK)
659  , delta_mm_cart
660  #endif
661  , fr_mm_s, extruder, millimeters);
662  }
663 
664  public:
665 
666  /**
667  * Add a new linear movement to the buffer.
668  * The target is cartesian. It's translated to
669  * delta/scara if needed.
670  *
671  * rx,ry,rz,e - target position in mm or degrees
672  * fr_mm_s - (target) speed of the move (mm/s)
673  * extruder - target extruder
674  * millimeters - the length of the movement, if known
675  * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
676  */
677  static bool buffer_line(const float &rx, const float &ry, const float &rz, const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0
678  #if ENABLED(SCARA_FEEDRATE_SCALING)
679  , const float &inv_duration=0.0
680  #endif
681  );
682 
683  FORCE_INLINE static bool buffer_line(const xyze_pos_t &cart, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0
684  #if ENABLED(SCARA_FEEDRATE_SCALING)
685  , const float &inv_duration=0.0
686  #endif
687  ) {
688  return buffer_line(cart.x, cart.y, cart.z, cart.e, fr_mm_s, extruder, millimeters
689  #if ENABLED(SCARA_FEEDRATE_SCALING)
690  , inv_duration
691  #endif
692  );
693  }
694 
695  /**
696  * Set the planner.position and individual stepper positions.
697  * Used by G92, G28, G29, and other procedures.
698  *
699  * The supplied position is in the cartesian coordinate space and is
700  * translated in to machine space as needed. Modifiers such as leveling
701  * and skew are also applied.
702  *
703  * Multiplies by axis_steps_per_mm[] and does necessary conversion
704  * for COREXY / COREXZ / COREYZ to set the corresponding stepper positions.
705  *
706  * Clears previous speed values.
707  */
708  static void set_position_mm(const float &rx, const float &ry, const float &rz, const float &e);
709  FORCE_INLINE static void set_position_mm(const xyze_pos_t &cart) { set_position_mm(cart.x, cart.y, cart.z, cart.e); }
710  static void set_e_position_mm(const float &e);
711 
712  /**
713  * Set the planner.position and individual stepper positions.
714  *
715  * The supplied position is in machine space, and no additional
716  * conversions are applied.
717  */
718  static void set_machine_position_mm(const float &a, const float &b, const float &c, const float &e);
719  FORCE_INLINE static void set_machine_position_mm(const abce_pos_t &abce) { set_machine_position_mm(abce.a, abce.b, abce.c, abce.e); }
720 
721  /**
722  * Get an axis position according to stepper position(s)
723  * For CORE machines apply translation from ABC to XYZ.
724  */
725  static float get_axis_position_mm(const AxisEnum axis);
726 
727  // SCARA AB axes are in degrees, not mm
728  #if IS_SCARA
729  FORCE_INLINE static float get_axis_position_degrees(const AxisEnum axis) { return get_axis_position_mm(axis); }
730  #endif
731 
732  // Called to force a quick stop of the machine (for example, when
733  // a Full Shutdown is required, or when endstops are hit)
734  static void quick_stop();
735 
736  // Called when an endstop is triggered. Causes the machine to stop inmediately
737  static void endstop_triggered(const AxisEnum axis);
738 
739  // Triggered position of an axis in mm (not core-savvy)
740  static float triggered_position_mm(const AxisEnum axis);
741 
742  // Block until all buffered steps are executed / cleaned
743  static void synchronize();
744 
745  // Wait for moves to finish and disable all steppers
746  static void finish_and_disable();
747 
748  // Periodic tick to handle cleaning timeouts
749  // Called from the Temperature ISR at ~1kHz
750  static void tick() {
753  #if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
754  if (!cleaning_buffer_counter) queue.inject_P(PSTR(SD_FINISHED_RELEASECOMMAND));
755  #endif
756  }
757  }
758 
759  /**
760  * Does the buffer have any blocks queued?
761  */
763 
764  /**
765  * The current block. nullptr if the buffer is empty.
766  * This also marks the block as busy.
767  * WARNING: Called from Stepper ISR context!
768  */
770 
771  // Get the number of moves in the planner queue so far
772  const uint8_t nr_moves = movesplanned();
773 
774  // If there are any moves queued ...
775  if (nr_moves) {
776 
777  // If there is still delay of delivery of blocks running, decrement it
780  // If the number of movements queued is less than 3, and there is still time
781  // to wait, do not deliver anything
782  if (nr_moves < 3 && delay_before_delivering) return nullptr;
784  }
785 
786  // If we are here, there is no excuse to deliver the block
787  block_t * const block = &block_buffer[block_buffer_tail];
788 
789  // No trapezoid calculated? Don't execute yet.
790  if (TEST(block->flag, BLOCK_BIT_RECALCULATE)) return nullptr;
791 
792  #if HAS_SPI_LCD
793  block_buffer_runtime_us -= block->segment_time_us; // We can't be sure how long an active block will take, so don't count it.
794  #endif
795 
796  // As this block is busy, advance the nonbusy block pointer
797  block_buffer_nonbusy = next_block_index(block_buffer_tail);
798 
799  // Push block_buffer_planned pointer, if encountered.
802 
803  // Return the block
804  return block;
805  }
806 
807  // The queue became empty
808  #if HAS_SPI_LCD
809  clear_block_buffer_runtime(); // paranoia. Buffer is empty now - so reset accumulated time to zero.
810  #endif
811 
812  return nullptr;
813  }
814 
815  /**
816  * "Discard" the block and "release" the memory.
817  * Called when the current block is no longer needed.
818  * NB: There MUST be a current block to call this function!!
819  */
821  if (has_blocks_queued())
822  block_buffer_tail = next_block_index(block_buffer_tail);
823  }
824 
825  #if HAS_SPI_LCD
826 
827  static uint16_t block_buffer_runtime() {
828  #ifdef __AVR__
829  // Protect the access to the variable. Only required for AVR, as
830  // any 32bit CPU offers atomic access to 32bit variables
831  bool was_enabled = STEPPER_ISR_ENABLED();
832  if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
833  #endif
834 
835  millis_t bbru = block_buffer_runtime_us;
836 
837  #ifdef __AVR__
838  // Reenable Stepper ISR
839  if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
840  #endif
841 
842  // To translate µs to ms a division by 1000 would be required.
843  // We introduce 2.4% error here by dividing by 1024.
844  // Doesn't matter because block_buffer_runtime_us is already too small an estimation.
845  bbru >>= 10;
846  // limit to about a minute.
847  NOMORE(bbru, 0xFFFFul);
848  return bbru;
849  }
850 
851  static void clear_block_buffer_runtime() {
852  #ifdef __AVR__
853  // Protect the access to the variable. Only required for AVR, as
854  // any 32bit CPU offers atomic access to 32bit variables
855  bool was_enabled = STEPPER_ISR_ENABLED();
856  if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
857  #endif
858 
859  block_buffer_runtime_us = 0;
860 
861  #ifdef __AVR__
862  // Reenable Stepper ISR
863  if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
864  #endif
865  }
866 
867  #endif
868 
869  #if ENABLED(AUTOTEMP)
870  static float autotemp_min, autotemp_max, autotemp_factor;
871  static bool autotemp_enabled;
872  static void getHighESpeed();
873  static void autotemp_M104_M109();
874  #endif
875 
876  #if HAS_LINEAR_E_JERK
877  #pragma GCC diagnostic push
878  #pragma GCC diagnostic ignored "-Wdouble-promotion"
879  FORCE_INLINE static void recalculate_max_e_jerk() {
880  #define GET_MAX_E_JERK(N) SQRT(SQRT(0.5) * junction_deviation_mm * (N) * RECIPROCAL(1.0 - SQRT(0.5)))
881  #if ENABLED(DISTINCT_E_FACTORS)
882  for (uint8_t i = 0; i < EXTRUDERS; i++)
883  max_e_jerk[i] = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]);
884  #else
885  max_e_jerk = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS]);
886  #endif
887  }
888  #pragma GCC diagnostic pop
889  #endif
890 
891  private:
892 
893  /**
894  * Get the index of the next / previous block in the ring buffer
895  */
896  static constexpr uint8_t next_block_index(const uint8_t block_index) { return BLOCK_MOD(block_index + 1); }
897  static constexpr uint8_t prev_block_index(const uint8_t block_index) { return BLOCK_MOD(block_index - 1); }
898 
899  /**
900  * Calculate the distance (not time) it takes to accelerate
901  * from initial_rate to target_rate using the given acceleration:
902  */
903  static float estimate_acceleration_distance(const float &initial_rate, const float &target_rate, const float &accel) {
904  if (accel == 0) return 0; // accel was 0, set acceleration distance to 0
905  return (sq(target_rate) - sq(initial_rate)) / (accel * 2);
906  }
907 
908  /**
909  * Return the point at which you must start braking (at the rate of -'accel') if
910  * you start at 'initial_rate', accelerate (until reaching the point), and want to end at
911  * 'final_rate' after traveling 'distance'.
912  *
913  * This is used to compute the intersection point between acceleration and deceleration
914  * in cases where the "trapezoid" has no plateau (i.e., never reaches maximum speed)
915  */
916  static float intersection_distance(const float &initial_rate, const float &final_rate, const float &accel, const float &distance) {
917  if (accel == 0) return 0; // accel was 0, set intersection distance to 0
918  return (accel * 2 * distance - sq(initial_rate) + sq(final_rate)) / (accel * 4);
919  }
920 
921  /**
922  * Calculate the maximum allowable speed squared at this point, in order
923  * to reach 'target_velocity_sqr' using 'acceleration' within a given
924  * 'distance'.
925  */
926  static float max_allowable_speed_sqr(const float &accel, const float &target_velocity_sqr, const float &distance) {
927  return target_velocity_sqr - 2 * accel * distance;
928  }
929 
930  #if ENABLED(S_CURVE_ACCELERATION)
931  /**
932  * Calculate the speed reached given initial speed, acceleration and distance
933  */
934  static float final_speed(const float &initial_velocity, const float &accel, const float &distance) {
935  return SQRT(sq(initial_velocity) + 2 * accel * distance);
936  }
937  #endif
938 
939  static void calculate_trapezoid_for_block(block_t* const block, const float &entry_factor, const float &exit_factor);
940 
941  static void reverse_pass_kernel(block_t* const current, const block_t * const next);
942  static void forward_pass_kernel(const block_t * const previous, block_t* const current, uint8_t block_index);
943 
944  static void reverse_pass();
945  static void forward_pass();
946 
947  static void recalculate_trapezoids();
948 
949  static void recalculate();
950 
951  #if DISABLED(CLASSIC_JERK)
952 
953  FORCE_INLINE static void normalize_junction_vector(xyze_float_t &vector) {
954  float magnitude_sq = 0;
955  LOOP_XYZE(idx) if (vector[idx]) magnitude_sq += sq(vector[idx]);
956  vector *= RSQRT(magnitude_sq);
957  }
958 
959  FORCE_INLINE static float limit_value_by_axis_maximum(const float &max_value, xyze_float_t &unit_vec) {
960  float limit_value = max_value;
961  LOOP_XYZE(idx) if (unit_vec[idx]) // Avoid divide by zero
962  NOMORE(limit_value, ABS(settings.max_acceleration_mm_per_s2[idx] / unit_vec[idx]));
963  return limit_value;
964  }
965 
966  #endif // !CLASSIC_JERK
967 };
968 
969 #define PLANNER_XY_FEEDRATE() (_MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]))
970 
971 extern Planner planner;
enable_E2
#define enable_E2()
Definition: Marlin.h:276
planner.h
WITHIN
#define WITHIN(N, L, H)
Definition: macros.h:195
BlockFlagBit
BlockFlagBit
Definition: planner.h:63
Planner::buffer_sync_block
static void buffer_sync_block()
Definition: planner.cpp:2529
XYZval::z
T z
Definition: types.h:286
block_t
struct block_t block_t
enable_E0
#define enable_E0()
Definition: Marlin.h:260
Planner::set_machine_position_mm
static void set_machine_position_mm(const float &a, const float &b, const float &c, const float &e)
Definition: planner.cpp:2721
Planner::set_max_jerk
static void set_max_jerk(const AxisEnum axis, float targetValue)
Definition: planner.cpp:2855
Temperature::tooColdToExtrude
static FORCE_INLINE bool tooColdToExtrude(const uint8_t)
Definition: temperature.h:314
SERIAL_CHAR
#define SERIAL_CHAR(x)
Definition: serial.h:69
Y_MIN_POS
#define Y_MIN_POS
Definition: Configuration_A3ides_2209_MINI.h:985
NOLESS
#define NOLESS(v, n)
Definition: macros.h:127
Planner::discard_current_block
static FORCE_INLINE void discard_current_block()
Definition: planner.h:820
DEFAULT_EJERK
#define DEFAULT_EJERK
Definition: Configuration_A3ides_2209_MINI.h:733
backlash
Backlash backlash
Planner::set_machine_position_mm
static FORCE_INLINE void set_machine_position_mm(const abce_pos_t &abce)
Definition: planner.h:719
Planner::buffer_segment
static FORCE_INLINE bool buffer_segment(abce_pos_t &abce, const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0)
Definition: planner.h:651
RSQRT
#define RSQRT(x)
Definition: macros.h:282
XYZEval
Definition: types.h:101
MIXER_POPULATE_BLOCK
#define MIXER_POPULATE_BLOCK()
Definition: mixing.h:72
sq
#define sq(x)
Definition: wiring_constants.h:83
XYZEval::z
T z
Definition: types.h:383
Planner::synchronize
static void synchronize()
Definition: planner.cpp:1556
temperature.h
mbl
mesh_bed_leveling mbl
skew_factor_t
Definition: planner.h:196
LIMIT_ACCEL_LONG
#define LIMIT_ACCEL_LONG(AXIS, INDX)
DEFAULT_MAX_ACCELERATION
#define DEFAULT_MAX_ACCELERATION
Definition: Configuration_A3ides_2209_MINI.h:696
MINIMAL_STEP_RATE
#define MINIMAL_STEP_RATE
Definition: planner.cpp:706
planner_settings_t::min_feedrate_mm_s
feedRate_t min_feedrate_mm_s
Definition: planner.h:186
mixer
Mixer mixer
block_t::flag
volatile uint8_t flag
Definition: planner.h:97
Temperature::degTargetHotend
static FORCE_INLINE int16_t degTargetHotend(const uint8_t E_NAME)
Definition: temperature.h:562
XYZval::x
T x
Definition: types.h:286
mesh_bed_leveling::get_z
static float get_z(const xy_pos_t &pos)
Definition: mesh_bed_leveling.h:107
BLOCK_BIT_CONTINUED
Definition: planner.h:73
Planner::Planner
Planner()
Definition: planner.cpp:232
disable_e_steppers
void disable_e_steppers()
Definition: Marlin.cpp:293
stepper.h
planner_settings_t::max_feedrate_mm_s
feedRate_t max_feedrate_mm_s[XYZE_N]
Definition: planner.h:182
MSG_ERR_COLD_EXTRUDE_STOP
#define MSG_ERR_COLD_EXTRUDE_STOP
Definition: language.h:242
Planner::bed_level_matrix
static matrix_3x3 bed_level_matrix
Definition: planner.h:278
enable_E5
#define enable_E5()
Definition: Marlin.h:300
PROGMEM
#define PROGMEM
Definition: pgmspace.h:29
CORE_IS_XY
#define CORE_IS_XY
Definition: Conditionals_post.h:101
SpindleLaser::power
static cutter_power_t power
Definition: spindle_laser.h:48
queue
GCodeQueue queue
Definition: queue.cpp:28
BLOCK_MOD
#define BLOCK_MOD(n)
Definition: planner.h:176
X_AXIS
Definition: types.h:37
RECIPROCAL
#define RECIPROCAL(x)
Definition: macros.h:273
planner
Planner planner
Definition: planner.cpp:111
level_fulcrum
constexpr xy_pos_t level_fulcrum
Definition: planner.cpp:1369
enable_E3
#define enable_E3()
Definition: Marlin.h:284
UNEAR_ZERO
#define UNEAR_ZERO(x)
Definition: macros.h:269
PrintJobRecovery::command_sdpos
static uint32_t command_sdpos()
Definition: power_loss_recovery.h:135
stepper
Stepper stepper
Definition: stepper.cpp:82
Planner::buffer_segment
static bool buffer_segment(const float &a, const float &b, const float &c, const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0)
Definition: planner.cpp:2568
planner_settings_t::retract_acceleration
float retract_acceleration
Definition: planner.h:183
_MAX
#define _MAX(V...)
Definition: macros.h:346
block_t::acceleration_steps_per_s2
uint32_t acceleration_steps_per_s2
Definition: planner.h:147
Planner::get_axis_position_mm
static float get_axis_position_mm(const AxisEnum axis)
Definition: planner.cpp:1526
Planner::max_acceleration_steps_per_s2
static uint32_t max_acceleration_steps_per_s2[XYZE_N]
Definition: planner.h:253
Planner::_buffer_steps
static bool _buffer_steps(const xyze_long_t &target, const xyze_pos_t &target_float, feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters=0.0)
Definition: planner.cpp:1578
Planner::leveling_active
static bool leveling_active
Definition: planner.h:276
MIN_STEPS_PER_SEGMENT
#define MIN_STEPS_PER_SEGMENT
Definition: Configuration_A3ides_2209_MINI_adv.h:1108
BLOCK_BIT_RECALCULATE
Definition: planner.h:65
FilamentWidthSensor::advance_e
static void advance_e(const float &e_move)
Definition: filwidth.h:80
planner_settings_t
Definition: planner.h:178
Planner::calculate_volumetric_multipliers
static void calculate_volumetric_multipliers()
disable_Z
#define disable_Z()
Definition: Marlin.h:143
C_AXIS
Definition: types.h:39
Stepper::is_block_busy
static bool is_block_busy(const block_t *const block)
Definition: stepper.cpp:1967
PGM_P
#define PGM_P
Definition: pgmspace.h:30
XYZEval::e
T e
Definition: types.h:383
Planner::movesplanned
static FORCE_INLINE uint8_t movesplanned()
Definition: planner.h:543
i
uint8_t i
Definition: screen_test_graph.c:72
Planner
Definition: planner.h:210
_MIN
#define _MIN(V...)
Definition: macros.h:333
LOOP_XYZE_N
#define LOOP_XYZE_N(VAR)
Definition: types.h:62
Planner::block_buffer_tail
static volatile uint8_t block_buffer_tail
Definition: planner.h:227
AxisEnum
AxisEnum
Definition: types.h:36
Stepper::wake_up
static void wake_up()
Definition: stepper.cpp:342
Stepper::endstop_triggered
static void endstop_triggered(const AxisEnum axis)
Definition: stepper.cpp:2237
disable_Y
#define disable_Y()
Definition: Marlin.h:104
enable_Z
#define enable_Z()
Definition: Marlin.h:142
CIRCLE_AREA
#define CIRCLE_AREA(R)
Definition: macros.h:102
CACHED_SQRT
#define CACHED_SQRT(N, V)
LIMIT
#define LIMIT(v, n1, n2)
Definition: macros.h:139
A
#define A(CODE)
Definition: macros.h:75
IS_KINEMATIC
#define IS_KINEMATIC
Definition: Conditionals_LCD.h:545
recovery
PrintJobRecovery recovery
motion.h
block_t::steps
abce_ulong_t steps
Definition: planner.h:107
Planner::block_buffer_head
static volatile uint8_t block_buffer_head
Definition: planner.h:227
STEPPER_ISR_ENABLED
#define STEPPER_ISR_ENABLED()
Definition: HAL.h:143
feedRate_t
float feedRate_t
Definition: types.h:80
matrix_3x3::transpose
static matrix_3x3 transpose(const matrix_3x3 &original)
Definition: vector_3.cpp:131
Planner::endstop_triggered
static void endstop_triggered(const AxisEnum axis)
Definition: planner.cpp:1508
Planner::position_float
static xyze_pos_t position_float
Definition: planner.h:292
extruder_duplication_enabled
bool extruder_duplication_enabled
Definition: motion.cpp:876
skew_factor_t::yz
const float yz
Definition: planner.h:206
Stepper::set_axis_position
static void set_axis_position(const AxisEnum a, const int32_t &v)
Definition: stepper.h:446
cutter
SpindleLaser cutter
Definition: spindle_laser.cpp:33
Planner::unapply_modifiers
static FORCE_INLINE void unapply_modifiers(xyze_pos_t &pos, bool leveling=false)
Definition: planner.h:520
matrix_3x3::set_to_identity
void set_to_identity()
Definition: vector_3.cpp:94
matrix_3x3
Definition: vector_3.h:73
Planner::get_next_free_block
static FORCE_INLINE block_t * get_next_free_block(uint8_t &next_buffer_head, const uint8_t count=1)
Definition: planner.h:564
BLOCK_BIT_NOMINAL_LENGTH
Definition: planner.h:70
cutter_power_t
uint8_t cutter_power_t
Definition: spindle_laser.h:42
HEATER_2_PIN
#define HEATER_2_PIN
Definition: pins_COHESION3D_REMIX.h:116
X_MIN_POS
#define X_MIN_POS
Definition: Configuration_A3ides_2209_MINI.h:984
NOMORE
#define NOMORE(v, n)
Definition: macros.h:133
block_t::cutter_power
cutter_power_t cutter_power
Definition: planner.h:153
XYZval::magnitude
FI T magnitude() const
Definition: types.h:295
pin_t
int8_t pin_t
Definition: HAL.h:65
AXIS_CONDITION
#define AXIS_CONDITION
ABS
#define ABS(a)
Definition: macros.h:266
Planner::block_buffer_nonbusy
static volatile uint8_t block_buffer_nonbusy
Definition: planner.h:227
MIXER_BLOCK_FIELD
#define MIXER_BLOCK_FIELD
Definition: mixing.h:71
Planner::block_buffer
static block_t block_buffer[BLOCK_BUFFER_SIZE]
Definition: planner.h:226
E_AXIS_N
#define E_AXIS_N(E)
Definition: Conditionals_LCD.h:454
delta.h
Planner::refresh_positioning
static void refresh_positioning()
Definition: planner.cpp:2806
AUTO_BED_LEVELING_BILINEAR
#define AUTO_BED_LEVELING_BILINEAR
Definition: Configuration_A3ides_2209_MINI.h:1092
FORCE_INLINE
#define FORCE_INLINE
Definition: macros.h:40
Planner::clear_block_buffer
static FORCE_INLINE void clear_block_buffer()
Definition: planner.h:549
XYZEval::a
T a
Definition: types.h:384
Planner::finish_and_disable
static void finish_and_disable()
Definition: planner.cpp:1517
Y_MAX_POS
#define Y_MAX_POS
Definition: Configuration_A3ides_2209_MINI.h:988
SERIAL_ECHO_MSG
#define SERIAL_ECHO_MSG(S)
Definition: serial.h:183
block_t::position
abce_long_t position
Definition: planner.h:108
RADIANS
#define RADIANS(d)
Definition: macros.h:98
XYZEval::c
T c
Definition: types.h:384
PSTR
#define PSTR(str)
Definition: pgmspace.h:31
BLOCK_BIT_SYNC_POSITION
Definition: planner.h:76
BLOCK_FLAG_CONTINUED
Definition: planner.h:82
current_position
xyze_pos_t current_position
Definition: motion.cpp:102
Planner::apply_modifiers
static FORCE_INLINE void apply_modifiers(xyze_pos_t &pos, bool leveling=false)
Definition: planner.h:499
LROUND
#define LROUND(x)
Definition: macros.h:285
Planner::leveling_active_at_z
static FORCE_INLINE bool leveling_active_at_z(const float &)
Definition: planner.h:447
HAS_LEVELING
#define HAS_LEVELING
Definition: Conditionals_post.h:1408
Backlash::add_correction_steps
void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const uint8_t dm, block_t *const block)
BLOCK_BUFFER_SIZE
#define BLOCK_BUFFER_SIZE
Definition: Configuration_A3ides_2209_MINI_adv.h:1167
apply_rotation_xyz
void apply_rotation_xyz(const matrix_3x3 &matrix, float &_x, float &_y, float &_z)
Definition: vector_3.cpp:88
Planner::init
void init()
Definition: planner.cpp:234
COUNT
#define COUNT(a)
Definition: macros.h:200
XYZEval::b
T b
Definition: types.h:384
block_t::entry_speed_sqr
float entry_speed_sqr
Definition: planner.h:100
block_t::acceleration_rate
uint32_t acceleration_rate
Definition: planner.h:133
filwidth
FilamentWidthSensor filwidth
X_HOME_POS
#define X_HOME_POS
Definition: Conditionals_post.h:156
ENABLE_STEPPER_DRIVER_INTERRUPT
#define ENABLE_STEPPER_DRIVER_INTERRUPT()
Definition: HAL.h:141
FilamentWidthSensor::nominal_mm
static float nominal_mm
Definition: filwidth.h:33
LOOP_XYZ
#define LOOP_XYZ(VAR)
Definition: types.h:60
planner_settings_t::travel_acceleration
float travel_acceleration
Definition: planner.h:183
FLOOR
#define FLOOR(x)
Definition: macros.h:284
planner_settings_t::axis_steps_per_mm
float axis_steps_per_mm[XYZE_N]
Definition: planner.h:181
Y_HOME_POS
#define Y_HOME_POS
Definition: Conditionals_post.h:172
DISABLED
#define DISABLED(V...)
Definition: macros.h:178
block_t::final_rate
uint32_t final_rate
Definition: planner.h:147
block_t::millimeters
float millimeters
Definition: planner.h:100
CEIL
#define CEIL(x)
Definition: macros.h:283
HAS_POSITION_FLOAT
#define HAS_POSITION_FLOAT
Definition: planner.h:174
block_t::nominal_speed_sqr
float nominal_speed_sqr
Definition: planner.h:100
X_HEAD
Definition: types.h:41
Mixer::refresh_collector
static void refresh_collector(const float proportion=1.0, const uint8_t t=selected_vtool, float(&c)[MIXING_STEPPERS]=collector)
planner_settings_t::acceleration
float acceleration
Definition: planner.h:183
Stepper::triggered_position
static int32_t triggered_position(const AxisEnum axis)
Definition: stepper.cpp:2258
XYZEval::x
T x
Definition: types.h:383
baricuda_valve_pressure
uint8_t baricuda_valve_pressure
planner_settings_t::max_acceleration_mm_per_s2
uint32_t max_acceleration_mm_per_s2[XYZE_N]
Definition: planner.h:179
SERIAL_ECHOPGM
#define SERIAL_ECHOPGM(S)
Definition: serial.h:173
Planner::reset_acceleration_rates
static void reset_acceleration_rates()
Definition: planner.cpp:2788
powerManager
Power powerManager
HEATER_1_PIN
#define HEATER_1_PIN
Definition: pins_RAMPS_LINUX.h:196
Planner::buffer_line
static bool buffer_line(const float &rx, const float &ry, const float &rz, const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0)
Definition: planner.cpp:2663
ACCEL_IDX
#define ACCEL_IDX
SERIAL_ECHOLNPAIR
#define SERIAL_ECHOLNPAIR(V...)
Definition: serial.h:144
enable_X
#define enable_X()
Definition: Marlin.h:76
XYval
Definition: types.h:99
createSpeedLookupTable.a
list a
Definition: createSpeedLookupTable.py:29
Stepper::quick_stop
static FORCE_INLINE void quick_stop()
Definition: stepper.h:375
enable_Y
#define enable_Y()
Definition: Marlin.h:103
L
#define L(CODE)
Definition: macros.h:76
disable_all_steppers
void disable_all_steppers()
Definition: Marlin.cpp:308
unified_bed_leveling::get_z_correction
static float get_z_correction(const float &rx0, const float &ry0)
Definition: ubl.h:238
XYZEval::set
FI void set(const T px)
Definition: types.h:391
SQRT
#define SQRT(x)
Definition: macros.h:281
MANUAL_FEEDRATE
#define MANUAL_FEEDRATE
Definition: Configuration_A3ides_2209_MINI_adv.h:521
XYval::x
T x
Definition: types.h:185
block_t::max_entry_speed_sqr
float max_entry_speed_sqr
Definition: planner.h:100
MIXER_STEPPER_LOOP
#define MIXER_STEPPER_LOOP(VAR)
Definition: mixing.h:68
BLOCK_DELAY_FOR_1ST_MOVE
#define BLOCK_DELAY_FOR_1ST_MOVE
Definition: planner.cpp:109
do_homing_move
void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t fr_mm_s=0.0)
Definition: motion.cpp:1232
Y_HEAD
Definition: types.h:41
enable_E1
#define enable_E1()
Definition: Marlin.h:268
uint8_t
const uint8_t[]
Definition: 404_html.c:3
DEFAULT_MAX_FEEDRATE
#define DEFAULT_MAX_FEEDRATE
Definition: Configuration_A3ides_2209_MINI.h:687
bilinear_z_offset
float bilinear_z_offset(const xy_pos_t &raw)
skew_factor_t::xz
const float xz
Definition: planner.h:206
block_t::direction_bits
uint8_t direction_bits
Definition: planner.h:136
DISABLE_STEPPER_DRIVER_INTERRUPT
#define DISABLE_STEPPER_DRIVER_INTERRUPT()
Definition: HAL.h:142
HYPOT
#define HYPOT(x, y)
Definition: macros.h:287
Planner::force_unapply_leveling
static FORCE_INLINE void force_unapply_leveling(xyz_pos_t &raw)
Definition: planner.h:484
_BV
#define _BV(bit)
Definition: wiring_constants.h:99
XYZval::y
T y
Definition: types.h:286
block_t::initial_rate
uint32_t initial_rate
Definition: planner.h:147
Planner::steps_to_mm
static float steps_to_mm[XYZE_N]
Definition: planner.h:254
DEFAULT_NOMINAL_FILAMENT_DIA
#define DEFAULT_NOMINAL_FILAMENT_DIA
Definition: Configuration_A3ides_2209_MINI.h:151
Planner::cleaning_buffer_counter
static uint16_t cleaning_buffer_counter
Definition: planner.h:231
BlockFlag
BlockFlag
Definition: planner.h:79
inverse_kinematics
void inverse_kinematics(const xyz_pos_t &raw)
Planner::is_full
static FORCE_INLINE bool is_full()
Definition: planner.h:552
X_MAX_POS
#define X_MAX_POS
Definition: Configuration_A3ides_2209_MINI.h:987
Y_AXIS
Definition: types.h:38
disable_X
#define disable_X()
Definition: Marlin.h:77
CBI
#define CBI(A, B)
Definition: macros.h:89
block_t::step_event_count
uint32_t step_event_count
Definition: planner.h:110
Planner::quick_stop
static void quick_stop()
Definition: planner.cpp:1475
Planner::set_e_position_mm
static void set_e_position_mm(const float &e)
Definition: planner.cpp:2764
enable_E4
#define enable_E4()
Definition: Marlin.h:292
ubl
unified_bed_leveling ubl
MSG_ERR_LONG_EXTRUDE_STOP
#define MSG_ERR_LONG_EXTRUDE_STOP
Definition: language.h:243
limit_and_warn
void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_name, const xyze_float_t &max_limit)
Definition: planner.cpp:2812
BLOCK_FLAG_SYNC_POSITION
Definition: planner.h:83
Planner::_populate_block
static bool _populate_block(block_t *const block, bool split_move, const xyze_long_t &target, const xyze_pos_t &target_float, feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters=0.0)
Definition: planner.cpp:1641
Planner::moves_free
static FORCE_INLINE uint8_t moves_free()
Definition: planner.h:555
Z_AXIS
Definition: types.h:39
EXTRUDERS
#define EXTRUDERS
Definition: Configuration_A3ides_2209_MINI.h:148
DEBUGGING
#define DEBUGGING(F)
Definition: serial.h:47
FAN_COUNT
#define FAN_COUNT
Definition: Conditionals_post.h:1292
Planner::check_axes_activity
static void check_axes_activity()
Definition: planner.cpp:1180
pgm_read_dword
#define pgm_read_dword(addr)
Definition: pgmspace.h:105
A_AXIS
Definition: types.h:37
block_t::acceleration
float acceleration
Definition: planner.h:100
MINIMUM_PLANNER_SPEED
#define MINIMUM_PLANNER_SPEED
Definition: Configuration_A3ides_2209_MINI_adv.h:545
block_t::decelerate_after
uint32_t decelerate_after
Definition: planner.h:123
Planner::fade_scaling_factor_for_z
static FORCE_INLINE float fade_scaling_factor_for_z(const float &)
Definition: planner.h:445
BLOCK_FLAG_NOMINAL_LENGTH
Definition: planner.h:81
skew_factor_t::xy
const float xy
Definition: planner.h:205
baricuda_e_to_p_pressure
uint8_t baricuda_e_to_p_pressure
Planner::nonbusy_movesplanned
static FORCE_INLINE uint8_t nonbusy_movesplanned()
Definition: planner.h:546
Planner::triggered_position_mm
static float triggered_position_mm(const AxisEnum axis)
Definition: planner.cpp:1513
block_t::nominal_rate
uint32_t nominal_rate
Definition: planner.h:147
TEST
#define TEST(n, b)
Definition: macros.h:81
XYval::y
T y
Definition: types.h:185
XYZE_N
#define XYZE_N
Definition: Conditionals_LCD.h:453
Stepper::position
static int32_t position(const AxisEnum axis)
Definition: stepper.cpp:2214
PLANNER_LEVELING
#define PLANNER_LEVELING
Definition: Conditionals_post.h:1411
Planner::get_current_block
static block_t * get_current_block()
Definition: planner.h:769
XYZval< float >
GCodeQueue::inject_P
static void inject_P(PGM_P const pgcode)
Definition: queue.cpp:206
E_AXIS
Definition: types.h:40
Planner::set_position_mm
static FORCE_INLINE void set_position_mm(const xyze_pos_t &cart)
Definition: planner.h:709
serialprintPGM
void serialprintPGM(PGM_P str)
Definition: serial.cpp:35
B_AXIS
Definition: types.h:38
SBI
#define SBI(A, B)
Definition: macros.h:85
axis_codes
const xyze_char_t axis_codes
Definition: types.h:486
Planner::settings
static planner_settings_t settings
Definition: planner.h:251
SERIAL_ECHOLNPGM
#define SERIAL_ECHOLNPGM(S)
Definition: serial.h:174
Planner::set_position_mm
static void set_position_mm(const float &rx, const float &ry, const float &rz, const float &e)
Definition: planner.cpp:2741
Planner::tick
static void tick()
Definition: planner.h:750
BLOCK_FLAG_RECALCULATE
Definition: planner.h:80
Planner::apply_leveling
static void apply_leveling(xyz_pos_t &raw)
Definition: planner.cpp:1381
Planner::buffer_line
static FORCE_INLINE bool buffer_line(const xyze_pos_t &cart, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0)
Definition: planner.h:683
Planner::set_max_feedrate
static void set_max_feedrate(const uint8_t axis, float targetValue)
Definition: planner.cpp:2841
createSpeedLookupTable.b
list b
Definition: createSpeedLookupTable.py:30
analogWrite
void analogWrite(uint32_t ulPin, uint32_t ulValue)
Definition: wiring_analog.c:12
LOOP_XYZE
#define LOOP_XYZE(VAR)
Definition: types.h:61
Planner::set_max_acceleration
static void set_max_acceleration(const uint8_t axis, float targetValue)
Definition: planner.cpp:2824
Z_HEAD
Definition: types.h:41
idle
void idle()
Definition: Marlin.cpp:629
READ
#define READ(IO)
Definition: fastio.h:95
CORE_IS_XZ
#define CORE_IS_XZ
Definition: Conditionals_post.h:102
planner_settings_t::min_travel_feedrate_mm_s
feedRate_t min_travel_feedrate_mm_s
Definition: planner.h:186
Planner::unapply_leveling
static void unapply_leveling(xyz_pos_t &raw)
Definition: planner.cpp:1415
block_t::accelerate_until
uint32_t accelerate_until
Definition: planner.h:123
block_t
Definition: planner.h:95
thermalManager
Temperature thermalManager
Definition: temperature.cpp:89
UNUSED
#define UNUSED(X)
Definition: stm32f4xx_hal_def.h:74
ARRAY_BY_EXTRUDERS1
#define ARRAY_BY_EXTRUDERS1(v1)
Definition: Conditionals_post.h:534
XYZEval::reset
FI void reset()
Definition: types.h:387
Planner::block_buffer_planned
static volatile uint8_t block_buffer_planned
Definition: planner.h:227
block_t::extruder
static constexpr uint8_t extruder
Definition: planner.h:115
millis_t
uint32_t millis_t
Definition: millis_t.h:26
LIMIT_ACCEL_FLOAT
#define LIMIT_ACCEL_FLOAT(AXIS, INDX)
CORE_IS_YZ
#define CORE_IS_YZ
Definition: Conditionals_post.h:103
Mixer::get_current_vtool
static FORCE_INLINE uint8_t get_current_vtool()
Definition: mixing.h:111
Planner::delay_before_delivering
static uint8_t delay_before_delivering
Definition: planner.h:232
active_extruder
constexpr uint8_t active_extruder
Definition: motion.h:107
Power::power_on
static void power_on()
Stepper::set_position
static void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e)
Definition: stepper.h:437
planner_settings_t::min_segment_time_us
uint32_t min_segment_time_us
Definition: planner.h:179
ENABLED
#define ENABLED(V...)
Definition: macros.h:177
Planner::has_blocks_queued
static FORCE_INLINE bool has_blocks_queued()
Definition: planner.h:762
planner
Planner planner
Definition: planner.cpp:111
XYZEval::y
T y
Definition: types.h:383
createSpeedLookupTable.parser
parser
Definition: createSpeedLookupTable.py:14
SpindleLaser::refresh
static void refresh()
Definition: spindle_laser.h:56
STEPPER_TIMER_RATE
#define STEPPER_TIMER_RATE
Definition: HAL.h:133
EXTRUDE_MAXLENGTH
#define EXTRUDE_MAXLENGTH
Definition: Configuration_A3ides_2209_MINI.h:524
Planner::skew_factor
static skew_factor_t skew_factor
Definition: planner.h:299