|
|
|
|
187
|
/**
|
187
|
/**
|
188
|
* Number of moves currently in the planner
|
188
|
* Number of moves currently in the planner
|
189
|
*/
|
189
|
*/
|
190
|
- static FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
|
|
|
|
|
190
|
+ static uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
|
191
|
|
191
|
|
192
|
#if ENABLED(AUTO_BED_LEVELING_FEATURE) || ENABLED(MESH_BED_LEVELING)
|
192
|
#if ENABLED(AUTO_BED_LEVELING_FEATURE) || ENABLED(MESH_BED_LEVELING)
|
193
|
|
193
|
|
|
|
|
|
233
|
/**
|
233
|
/**
|
234
|
* Does the buffer have any blocks queued?
|
234
|
* Does the buffer have any blocks queued?
|
235
|
*/
|
235
|
*/
|
236
|
- static FORCE_INLINE bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }
|
|
|
|
|
236
|
+ static bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }
|
237
|
|
237
|
|
238
|
/**
|
238
|
/**
|
239
|
* "Discards" the block and "releases" the memory.
|
239
|
* "Discards" the block and "releases" the memory.
|
240
|
* Called when the current block is no longer needed.
|
240
|
* Called when the current block is no longer needed.
|
241
|
*/
|
241
|
*/
|
242
|
- static FORCE_INLINE void discard_current_block() {
|
|
|
|
|
242
|
+ static void discard_current_block() {
|
243
|
if (blocks_queued())
|
243
|
if (blocks_queued())
|
244
|
block_buffer_tail = BLOCK_MOD(block_buffer_tail + 1);
|
244
|
block_buffer_tail = BLOCK_MOD(block_buffer_tail + 1);
|
245
|
}
|
245
|
}
|
|
|
|
|
248
|
* The current block. NULL if the buffer is empty.
|
248
|
* The current block. NULL if the buffer is empty.
|
249
|
* This also marks the block as busy.
|
249
|
* This also marks the block as busy.
|
250
|
*/
|
250
|
*/
|
251
|
- static FORCE_INLINE block_t* get_current_block() {
|
|
|
|
|
251
|
+ static block_t* get_current_block() {
|
252
|
if (blocks_queued()) {
|
252
|
if (blocks_queued()) {
|
253
|
block_t* block = &block_buffer[block_buffer_tail];
|
253
|
block_t* block = &block_buffer[block_buffer_tail];
|
254
|
block->busy = true;
|
254
|
block->busy = true;
|
|
|
|
|
272
|
/**
|
272
|
/**
|
273
|
* Get the index of the next / previous block in the ring buffer
|
273
|
* Get the index of the next / previous block in the ring buffer
|
274
|
*/
|
274
|
*/
|
275
|
- static FORCE_INLINE int8_t next_block_index(int8_t block_index) { return BLOCK_MOD(block_index + 1); }
|
|
|
276
|
- static FORCE_INLINE int8_t prev_block_index(int8_t block_index) { return BLOCK_MOD(block_index - 1); }
|
|
|
|
|
275
|
+ static int8_t next_block_index(int8_t block_index) { return BLOCK_MOD(block_index + 1); }
|
|
|
276
|
+ static int8_t prev_block_index(int8_t block_index) { return BLOCK_MOD(block_index - 1); }
|
277
|
|
277
|
|
278
|
/**
|
278
|
/**
|
279
|
* Calculate the distance (not time) it takes to accelerate
|
279
|
* Calculate the distance (not time) it takes to accelerate
|
280
|
* from initial_rate to target_rate using the given acceleration:
|
280
|
* from initial_rate to target_rate using the given acceleration:
|
281
|
*/
|
281
|
*/
|
282
|
- static FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {
|
|
|
|
|
282
|
+ static float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {
|
283
|
if (acceleration == 0) return 0; // acceleration was 0, set acceleration distance to 0
|
283
|
if (acceleration == 0) return 0; // acceleration was 0, set acceleration distance to 0
|
284
|
return (target_rate * target_rate - initial_rate * initial_rate) / (acceleration * 2);
|
284
|
return (target_rate * target_rate - initial_rate * initial_rate) / (acceleration * 2);
|
285
|
}
|
285
|
}
|
|
|
|
|
292
|
* This is used to compute the intersection point between acceleration and deceleration
|
292
|
* This is used to compute the intersection point between acceleration and deceleration
|
293
|
* in cases where the "trapezoid" has no plateau (i.e., never reaches maximum speed)
|
293
|
* in cases where the "trapezoid" has no plateau (i.e., never reaches maximum speed)
|
294
|
*/
|
294
|
*/
|
295
|
- static FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) {
|
|
|
|
|
295
|
+ static float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) {
|
296
|
if (acceleration == 0) return 0; // acceleration was 0, set intersection distance to 0
|
296
|
if (acceleration == 0) return 0; // acceleration was 0, set intersection distance to 0
|
297
|
return (acceleration * 2 * distance - initial_rate * initial_rate + final_rate * final_rate) / (acceleration * 4);
|
297
|
return (acceleration * 2 * distance - initial_rate * initial_rate + final_rate * final_rate) / (acceleration * 4);
|
298
|
}
|
298
|
}
|
|
|
|
|
302
|
* to reach 'target_velocity' using 'acceleration' within a given
|
302
|
* to reach 'target_velocity' using 'acceleration' within a given
|
303
|
* 'distance'.
|
303
|
* 'distance'.
|
304
|
*/
|
304
|
*/
|
305
|
- static FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) {
|
|
|
|
|
305
|
+ static float max_allowable_speed(float acceleration, float target_velocity, float distance) {
|
306
|
return sqrt(target_velocity * target_velocity - 2 * acceleration * distance);
|
306
|
return sqrt(target_velocity * target_velocity - 2 * acceleration * distance);
|
307
|
}
|
307
|
}
|
308
|
|
308
|
|