|
@@ -593,7 +593,7 @@ float junction_deviation = 0.1;
|
|
|
// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in
|
|
|
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
|
|
|
// calculation the caller must also provide the physical length of the line in millimeters.
|
|
|
-void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder)
|
|
|
+void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, uint8_t sdlen)
|
|
|
{
|
|
|
// Calculate the buffer head after we push this byte
|
|
|
int next_buffer_head = next_block_index(block_buffer_head);
|
|
@@ -723,6 +723,9 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
|
|
// Prepare to set up new block
|
|
|
block_t *block = &block_buffer[block_buffer_head];
|
|
|
|
|
|
+ // Set sdlen for calculating sd position
|
|
|
+ block->sdlen = sdlen;
|
|
|
+
|
|
|
// Mark block as not busy (Not executed by the stepper interrupt, could be still tinkered with.)
|
|
|
block->busy = false;
|
|
|
|
|
@@ -1295,4 +1298,17 @@ void planner_queue_min_reset()
|
|
|
{
|
|
|
g_cntr_planner_queue_min = moves_planned();
|
|
|
}
|
|
|
-#endif /* PLANNER_DIAGNOSTICS */
|
|
|
+#endif /* PLANNER_DIAGNOSTICS */
|
|
|
+
|
|
|
+uint16_t planner_calc_sd_length()
|
|
|
+{
|
|
|
+ unsigned char _block_buffer_head = block_buffer_head;
|
|
|
+ unsigned char _block_buffer_tail = block_buffer_tail;
|
|
|
+ uint16_t sdlen = 0;
|
|
|
+ while (_block_buffer_head != _block_buffer_tail)
|
|
|
+ {
|
|
|
+ sdlen += block_buffer[_block_buffer_tail].sdlen;
|
|
|
+ _block_buffer_tail = (_block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
|
|
|
+ }
|
|
|
+ return sdlen;
|
|
|
+}
|