|
@@ -1382,15 +1382,9 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
|
1382
|
1382
|
const float esteps_float = de * e_factor[extruder];
|
1383
|
1383
|
const int32_t esteps = abs(esteps_float) + 0.5;
|
1384
|
1384
|
|
1385
|
|
- // Calculate the buffer head after we push this byte
|
1386
|
|
- const uint8_t next_buffer_head = next_block_index(block_buffer_head);
|
1387
|
|
-
|
1388
|
|
- // If the buffer is full: good! That means we are well ahead of the robot.
|
1389
|
|
- // Rest here until there is room in the buffer.
|
1390
|
|
- while (block_buffer_tail == next_buffer_head) idle();
|
1391
|
|
-
|
1392
|
|
- // Prepare to set up new block
|
1393
|
|
- block_t* block = &block_buffer[block_buffer_head];
|
|
1385
|
+ // Wait for the next available block
|
|
1386
|
+ uint8_t next_buffer_head;
|
|
1387
|
+ block_t * const block = get_next_free_block(next_buffer_head);
|
1394
|
1388
|
|
1395
|
1389
|
// Clear all flags, including the "busy" bit
|
1396
|
1390
|
block->flag = 0x00;
|
|
@@ -2033,6 +2027,26 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
|
2033
|
2027
|
} // _buffer_steps()
|
2034
|
2028
|
|
2035
|
2029
|
/**
|
|
2030
|
+ * Planner::buffer_sync_block
|
|
2031
|
+ * Add a block to the buffer that just updates the position
|
|
2032
|
+ */
|
|
2033
|
+void Planner::buffer_sync_block() {
|
|
2034
|
+ // Wait for the next available block
|
|
2035
|
+ uint8_t next_buffer_head;
|
|
2036
|
+ block_t * const block = get_next_free_block(next_buffer_head);
|
|
2037
|
+
|
|
2038
|
+ block->steps[A_AXIS] = position[A_AXIS];
|
|
2039
|
+ block->steps[B_AXIS] = position[B_AXIS];
|
|
2040
|
+ block->steps[C_AXIS] = position[C_AXIS];
|
|
2041
|
+ block->steps[E_AXIS] = position[E_AXIS];
|
|
2042
|
+
|
|
2043
|
+ block->flag = BLOCK_FLAG_SYNC_POSITION;
|
|
2044
|
+
|
|
2045
|
+ block_buffer_head = next_buffer_head;
|
|
2046
|
+ stepper.wake_up();
|
|
2047
|
+} // buffer_sync_block()
|
|
2048
|
+
|
|
2049
|
+/**
|
2036
|
2050
|
* Planner::buffer_segment
|
2037
|
2051
|
*
|
2038
|
2052
|
* Add a new linear movement to the buffer in axis units.
|
|
@@ -2160,19 +2174,19 @@ void Planner::_set_position_mm(const float &a, const float &b, const float &c, c
|
2160
|
2174
|
#else
|
2161
|
2175
|
#define _EINDEX E_AXIS
|
2162
|
2176
|
#endif
|
2163
|
|
- const int32_t na = position[A_AXIS] = LROUND(a * axis_steps_per_mm[A_AXIS]),
|
2164
|
|
- nb = position[B_AXIS] = LROUND(b * axis_steps_per_mm[B_AXIS]),
|
2165
|
|
- nc = position[C_AXIS] = LROUND(c * axis_steps_per_mm[C_AXIS]),
|
2166
|
|
- ne = position[E_AXIS] = LROUND(e * axis_steps_per_mm[_EINDEX]);
|
|
2177
|
+ position[A_AXIS] = LROUND(a * axis_steps_per_mm[A_AXIS]),
|
|
2178
|
+ position[B_AXIS] = LROUND(b * axis_steps_per_mm[B_AXIS]),
|
|
2179
|
+ position[C_AXIS] = LROUND(c * axis_steps_per_mm[C_AXIS]),
|
|
2180
|
+ position[E_AXIS] = LROUND(e * axis_steps_per_mm[_EINDEX]);
|
2167
|
2181
|
#if HAS_POSITION_FLOAT
|
2168
|
|
- position_float[X_AXIS] = a;
|
2169
|
|
- position_float[Y_AXIS] = b;
|
2170
|
|
- position_float[Z_AXIS] = c;
|
|
2182
|
+ position_float[A_AXIS] = a;
|
|
2183
|
+ position_float[B_AXIS] = b;
|
|
2184
|
+ position_float[C_AXIS] = c;
|
2171
|
2185
|
position_float[E_AXIS] = e;
|
2172
|
2186
|
#endif
|
2173
|
|
- stepper.set_position(na, nb, nc, ne);
|
2174
|
2187
|
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
|
2175
|
2188
|
ZERO(previous_speed);
|
|
2189
|
+ buffer_sync_block();
|
2176
|
2190
|
}
|
2177
|
2191
|
|
2178
|
2192
|
void Planner::set_position_mm_kinematic(const float (&cart)[XYZE]) {
|
|
@@ -2220,23 +2234,23 @@ void Planner::set_position_mm(const AxisEnum axis, const float &v) {
|
2220
|
2234
|
#if HAS_POSITION_FLOAT
|
2221
|
2235
|
position_float[axis] = v;
|
2222
|
2236
|
#endif
|
2223
|
|
- stepper.set_position(axis, position[axis]);
|
2224
|
2237
|
previous_speed[axis] = 0.0;
|
|
2238
|
+ buffer_sync_block();
|
2225
|
2239
|
}
|
2226
|
2240
|
|
2227
|
2241
|
// Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
|
2228
|
2242
|
void Planner::reset_acceleration_rates() {
|
2229
|
2243
|
#if ENABLED(DISTINCT_E_FACTORS)
|
2230
|
|
- #define HIGHEST_CONDITION (i < E_AXIS || i == E_AXIS + active_extruder)
|
|
2244
|
+ #define AXIS_CONDITION (i < E_AXIS || i == E_AXIS + active_extruder)
|
2231
|
2245
|
#else
|
2232
|
|
- #define HIGHEST_CONDITION true
|
|
2246
|
+ #define AXIS_CONDITION true
|
2233
|
2247
|
#endif
|
2234
|
2248
|
uint32_t highest_rate = 1;
|
2235
|
2249
|
LOOP_XYZE_N(i) {
|
2236
|
2250
|
max_acceleration_steps_per_s2[i] = max_acceleration_mm_per_s2[i] * axis_steps_per_mm[i];
|
2237
|
|
- if (HIGHEST_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]);
|
|
2251
|
+ if (AXIS_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]);
|
2238
|
2252
|
}
|
2239
|
|
- cutoff_long = 4294967295UL / highest_rate;
|
|
2253
|
+ cutoff_long = 4294967295UL / highest_rate; // 0xFFFFFFFFUL
|
2240
|
2254
|
}
|
2241
|
2255
|
|
2242
|
2256
|
// Recalculate position, steps_to_mm if axis_steps_per_mm changes!
|