|
@@ -180,7 +180,7 @@ void Planner::calculate_trapezoid_for_block(block_t* const block, const float &e
|
180
|
180
|
// block->decelerate_after = accelerate_steps+plateau_steps;
|
181
|
181
|
|
182
|
182
|
CRITICAL_SECTION_START; // Fill variables used by the stepper in a critical section
|
183
|
|
- if (!block->busy) { // Don't update variables if block is busy.
|
|
183
|
+ if (!TEST(block->flag, BLOCK_BIT_BUSY)) { // Don't update variables if block is busy.
|
184
|
184
|
block->accelerate_until = accelerate_steps;
|
185
|
185
|
block->decelerate_after = accelerate_steps + plateau_steps;
|
186
|
186
|
block->initial_rate = initial_rate;
|
|
@@ -212,10 +212,10 @@ void Planner::reverse_pass_kernel(block_t* const current, const block_t *next) {
|
212
|
212
|
if (current->entry_speed != max_entry_speed) {
|
213
|
213
|
// If nominal length true, max junction speed is guaranteed to be reached. Only compute
|
214
|
214
|
// for max allowable speed if block is decelerating and nominal length is false.
|
215
|
|
- current->entry_speed = ((current->flag & BLOCK_FLAG_NOMINAL_LENGTH) || max_entry_speed <= next->entry_speed)
|
|
215
|
+ current->entry_speed = (TEST(current->flag, BLOCK_BIT_NOMINAL_LENGTH) || max_entry_speed <= next->entry_speed)
|
216
|
216
|
? max_entry_speed
|
217
|
217
|
: min(max_entry_speed, max_allowable_speed(-current->acceleration, next->entry_speed, current->millimeters));
|
218
|
|
- current->flag |= BLOCK_FLAG_RECALCULATE;
|
|
218
|
+ SBI(current->flag, BLOCK_BIT_RECALCULATE);
|
219
|
219
|
}
|
220
|
220
|
}
|
221
|
221
|
|
|
@@ -237,7 +237,7 @@ void Planner::reverse_pass() {
|
237
|
237
|
|
238
|
238
|
uint8_t b = BLOCK_MOD(block_buffer_head - 3);
|
239
|
239
|
while (b != tail) {
|
240
|
|
- if (block[0] && (block[0]->flag & BLOCK_FLAG_START_FROM_FULL_HALT)) break;
|
|
240
|
+ if (block[0] && TEST(block[0]->flag, BLOCK_BIT_START_FROM_FULL_HALT)) break;
|
241
|
241
|
b = prev_block_index(b);
|
242
|
242
|
block[2] = block[1];
|
243
|
243
|
block[1] = block[0];
|
|
@@ -255,14 +255,14 @@ void Planner::forward_pass_kernel(const block_t* previous, block_t* const curren
|
255
|
255
|
// full speed change within the block, we need to adjust the entry speed accordingly. Entry
|
256
|
256
|
// speeds have already been reset, maximized, and reverse planned by reverse planner.
|
257
|
257
|
// If nominal length is true, max junction speed is guaranteed to be reached. No need to recheck.
|
258
|
|
- if (!(previous->flag & BLOCK_FLAG_NOMINAL_LENGTH)) {
|
|
258
|
+ if (!TEST(previous->flag, BLOCK_BIT_NOMINAL_LENGTH)) {
|
259
|
259
|
if (previous->entry_speed < current->entry_speed) {
|
260
|
260
|
float entry_speed = min(current->entry_speed,
|
261
|
261
|
max_allowable_speed(-previous->acceleration, previous->entry_speed, previous->millimeters));
|
262
|
262
|
// Check for junction speed change
|
263
|
263
|
if (current->entry_speed != entry_speed) {
|
264
|
264
|
current->entry_speed = entry_speed;
|
265
|
|
- current->flag |= BLOCK_FLAG_RECALCULATE;
|
|
265
|
+ SBI(current->flag, BLOCK_BIT_RECALCULATE);
|
266
|
266
|
}
|
267
|
267
|
}
|
268
|
268
|
}
|
|
@@ -298,11 +298,11 @@ void Planner::recalculate_trapezoids() {
|
298
|
298
|
next = &block_buffer[block_index];
|
299
|
299
|
if (current) {
|
300
|
300
|
// Recalculate if current block entry or exit junction speed has changed.
|
301
|
|
- if ((current->flag & BLOCK_FLAG_RECALCULATE) || (next->flag & BLOCK_FLAG_RECALCULATE)) {
|
|
301
|
+ if (TEST(current->flag, BLOCK_BIT_RECALCULATE) || TEST(next->flag, BLOCK_BIT_RECALCULATE)) {
|
302
|
302
|
// NOTE: Entry and exit factors always > 0 by all previous logic operations.
|
303
|
303
|
float nom = current->nominal_speed;
|
304
|
304
|
calculate_trapezoid_for_block(current, current->entry_speed / nom, next->entry_speed / nom);
|
305
|
|
- current->flag &= ~BLOCK_FLAG_RECALCULATE; // Reset current only to ensure next trapezoid is computed
|
|
305
|
+ CBI(current->flag, BLOCK_BIT_RECALCULATE); // Reset current only to ensure next trapezoid is computed
|
306
|
306
|
}
|
307
|
307
|
}
|
308
|
308
|
block_index = next_block_index(block_index);
|
|
@@ -311,7 +311,7 @@ void Planner::recalculate_trapezoids() {
|
311
|
311
|
if (next) {
|
312
|
312
|
float nom = next->nominal_speed;
|
313
|
313
|
calculate_trapezoid_for_block(next, next->entry_speed / nom, (MINIMUM_PLANNER_SPEED) / nom);
|
314
|
|
- next->flag &= ~BLOCK_FLAG_RECALCULATE;
|
|
314
|
+ CBI(next->flag, BLOCK_BIT_RECALCULATE);
|
315
|
315
|
}
|
316
|
316
|
}
|
317
|
317
|
|
|
@@ -594,12 +594,6 @@ void Planner::check_axes_activity() {
|
594
|
594
|
* extruder - target extruder
|
595
|
595
|
*/
|
596
|
596
|
void Planner::_buffer_line(const float &a, const float &b, const float &c, const float &e, float fr_mm_s, const uint8_t extruder) {
|
597
|
|
- // Calculate the buffer head after we push this byte
|
598
|
|
- int next_buffer_head = next_block_index(block_buffer_head);
|
599
|
|
-
|
600
|
|
- // If the buffer is full: good! That means we are well ahead of the robot.
|
601
|
|
- // Rest here until there is room in the buffer.
|
602
|
|
- while (block_buffer_tail == next_buffer_head) idle();
|
603
|
597
|
|
604
|
598
|
// The target position of the tool in absolute steps
|
605
|
599
|
// Calculate target position in absolute steps
|
|
@@ -662,11 +656,50 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
662
|
656
|
}
|
663
|
657
|
#endif
|
664
|
658
|
|
|
659
|
+ // Compute direction bit-mask for this block
|
|
660
|
+ uint8_t dm = 0;
|
|
661
|
+ #if ENABLED(COREXY)
|
|
662
|
+ if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
|
663
|
+ if (db < 0) SBI(dm, Y_HEAD); // ...and Y
|
|
664
|
+ if (dc < 0) SBI(dm, Z_AXIS);
|
|
665
|
+ if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction
|
|
666
|
+ if (da - db < 0) SBI(dm, B_AXIS); // Motor B direction
|
|
667
|
+ #elif ENABLED(COREXZ)
|
|
668
|
+ if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
|
669
|
+ if (db < 0) SBI(dm, Y_AXIS);
|
|
670
|
+ if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
|
|
671
|
+ if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction
|
|
672
|
+ if (da - dc < 0) SBI(dm, C_AXIS); // Motor C direction
|
|
673
|
+ #elif ENABLED(COREYZ)
|
|
674
|
+ if (da < 0) SBI(dm, X_AXIS);
|
|
675
|
+ if (db < 0) SBI(dm, Y_HEAD); // Save the real Extruder (head) direction in Y Axis
|
|
676
|
+ if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
|
|
677
|
+ if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction
|
|
678
|
+ if (db - dc < 0) SBI(dm, C_AXIS); // Motor C direction
|
|
679
|
+ #else
|
|
680
|
+ if (da < 0) SBI(dm, X_AXIS);
|
|
681
|
+ if (db < 0) SBI(dm, Y_AXIS);
|
|
682
|
+ if (dc < 0) SBI(dm, Z_AXIS);
|
|
683
|
+ #endif
|
|
684
|
+ if (de < 0) SBI(dm, E_AXIS);
|
|
685
|
+
|
|
686
|
+ int32_t esteps = labs(de) * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01 + 0.5;
|
|
687
|
+
|
|
688
|
+ // Calculate the buffer head after we push this byte
|
|
689
|
+ int next_buffer_head = next_block_index(block_buffer_head);
|
|
690
|
+
|
|
691
|
+ // If the buffer is full: good! That means we are well ahead of the robot.
|
|
692
|
+ // Rest here until there is room in the buffer.
|
|
693
|
+ while (block_buffer_tail == next_buffer_head) idle();
|
|
694
|
+
|
665
|
695
|
// Prepare to set up new block
|
666
|
696
|
block_t* block = &block_buffer[block_buffer_head];
|
667
|
697
|
|
668
|
|
- // Mark block as not busy (Not executed by the stepper interrupt)
|
669
|
|
- block->busy = false;
|
|
698
|
+ // Clear all flags, including the "busy" bit
|
|
699
|
+ block->flag = 0;
|
|
700
|
+
|
|
701
|
+ // Set direction bits
|
|
702
|
+ block->direction_bits = dm;
|
670
|
703
|
|
671
|
704
|
// Number of steps for each axis
|
672
|
705
|
#if ENABLED(COREXY)
|
|
@@ -692,15 +725,12 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
692
|
725
|
block->steps[Z_AXIS] = labs(dc);
|
693
|
726
|
#endif
|
694
|
727
|
|
695
|
|
- block->steps[E_AXIS] = labs(de) * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01 + 0.5;
|
696
|
|
- block->step_event_count = MAX4(block->steps[X_AXIS], block->steps[Y_AXIS], block->steps[Z_AXIS], block->steps[E_AXIS]);
|
|
728
|
+ block->steps[E_AXIS] = esteps;
|
|
729
|
+ block->step_event_count = MAX4(block->steps[X_AXIS], block->steps[Y_AXIS], block->steps[Z_AXIS], esteps);
|
697
|
730
|
|
698
|
731
|
// Bail if this is a zero-length block
|
699
|
732
|
if (block->step_event_count < MIN_STEPS_PER_SEGMENT) return;
|
700
|
733
|
|
701
|
|
- // Clear the block flags
|
702
|
|
- block->flag = 0;
|
703
|
|
-
|
704
|
734
|
// For a mixing extruder, get a magnified step_event_count for each
|
705
|
735
|
#if ENABLED(MIXING_EXTRUDER)
|
706
|
736
|
for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
|
|
@@ -716,34 +746,6 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
716
|
746
|
block->e_to_p_pressure = baricuda_e_to_p_pressure;
|
717
|
747
|
#endif
|
718
|
748
|
|
719
|
|
- // Compute direction bit-mask for this block
|
720
|
|
- uint8_t dm = 0;
|
721
|
|
- #if ENABLED(COREXY)
|
722
|
|
- if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
723
|
|
- if (db < 0) SBI(dm, Y_HEAD); // ...and Y
|
724
|
|
- if (dc < 0) SBI(dm, Z_AXIS);
|
725
|
|
- if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction
|
726
|
|
- if (da - db < 0) SBI(dm, B_AXIS); // Motor B direction
|
727
|
|
- #elif ENABLED(COREXZ)
|
728
|
|
- if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
729
|
|
- if (db < 0) SBI(dm, Y_AXIS);
|
730
|
|
- if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
|
731
|
|
- if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction
|
732
|
|
- if (da - dc < 0) SBI(dm, C_AXIS); // Motor C direction
|
733
|
|
- #elif ENABLED(COREYZ)
|
734
|
|
- if (da < 0) SBI(dm, X_AXIS);
|
735
|
|
- if (db < 0) SBI(dm, Y_HEAD); // Save the real Extruder (head) direction in Y Axis
|
736
|
|
- if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
|
737
|
|
- if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction
|
738
|
|
- if (db - dc < 0) SBI(dm, C_AXIS); // Motor C direction
|
739
|
|
- #else
|
740
|
|
- if (da < 0) SBI(dm, X_AXIS);
|
741
|
|
- if (db < 0) SBI(dm, Y_AXIS);
|
742
|
|
- if (dc < 0) SBI(dm, Z_AXIS);
|
743
|
|
- #endif
|
744
|
|
- if (de < 0) SBI(dm, E_AXIS);
|
745
|
|
- block->direction_bits = dm;
|
746
|
|
-
|
747
|
749
|
block->active_extruder = extruder;
|
748
|
750
|
|
749
|
751
|
//enable active axes
|
|
@@ -761,6 +763,12 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
761
|
763
|
enable_z();
|
762
|
764
|
}
|
763
|
765
|
if (block->steps[Y_AXIS]) enable_y();
|
|
766
|
+ #elif ENABLED(COREYZ)
|
|
767
|
+ if (block->steps[B_AXIS] || block->steps[C_AXIS]) {
|
|
768
|
+ enable_y();
|
|
769
|
+ enable_z();
|
|
770
|
+ }
|
|
771
|
+ if (block->steps[X_AXIS]) enable_x();
|
764
|
772
|
#else
|
765
|
773
|
if (block->steps[X_AXIS]) enable_x();
|
766
|
774
|
if (block->steps[Y_AXIS]) enable_y();
|
|
@@ -770,7 +778,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
770
|
778
|
#endif
|
771
|
779
|
|
772
|
780
|
// Enable extruder(s)
|
773
|
|
- if (block->steps[E_AXIS]) {
|
|
781
|
+ if (esteps) {
|
774
|
782
|
|
775
|
783
|
#if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
|
776
|
784
|
|
|
@@ -839,7 +847,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
839
|
847
|
#endif
|
840
|
848
|
}
|
841
|
849
|
|
842
|
|
- if (block->steps[E_AXIS])
|
|
850
|
+ if (esteps)
|
843
|
851
|
NOLESS(fr_mm_s, min_feedrate_mm_s);
|
844
|
852
|
else
|
845
|
853
|
NOLESS(fr_mm_s, min_travel_feedrate_mm_s);
|
|
@@ -1037,7 +1045,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1037
|
1045
|
}while(0)
|
1038
|
1046
|
|
1039
|
1047
|
// Start with print or travel acceleration
|
1040
|
|
- accel = ceil((block->steps[E_AXIS] ? acceleration : travel_acceleration) * steps_per_mm);
|
|
1048
|
+ accel = ceil((esteps ? acceleration : travel_acceleration) * steps_per_mm);
|
1041
|
1049
|
|
1042
|
1050
|
// Limit acceleration per axis
|
1043
|
1051
|
if (block->step_event_count <= cutoff_long){
|
|
@@ -1186,12 +1194,12 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1186
|
1194
|
if (previous_safe_speed > vmax_junction_threshold && safe_speed > vmax_junction_threshold) {
|
1187
|
1195
|
// Not coasting. The machine will stop and start the movements anyway,
|
1188
|
1196
|
// better to start the segment from start.
|
1189
|
|
- block->flag |= BLOCK_FLAG_START_FROM_FULL_HALT;
|
|
1197
|
+ SBI(block->flag, BLOCK_BIT_START_FROM_FULL_HALT);
|
1190
|
1198
|
vmax_junction = safe_speed;
|
1191
|
1199
|
}
|
1192
|
1200
|
}
|
1193
|
1201
|
else {
|
1194
|
|
- block->flag |= BLOCK_FLAG_START_FROM_FULL_HALT;
|
|
1202
|
+ SBI(block->flag, BLOCK_BIT_START_FROM_FULL_HALT);
|
1195
|
1203
|
vmax_junction = safe_speed;
|
1196
|
1204
|
}
|
1197
|
1205
|
|
|
@@ -1224,18 +1232,18 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1224
|
1232
|
// This leads to an enormous number of advance steps due to a huge e_acceleration.
|
1225
|
1233
|
// The math is correct, but you don't want a retract move done with advance!
|
1226
|
1234
|
// So this situation is filtered out here.
|
1227
|
|
- if (!block->steps[E_AXIS] || (!block->steps[X_AXIS] && !block->steps[Y_AXIS]) || stepper.get_advance_k() == 0 || (uint32_t) block->steps[E_AXIS] == block->step_event_count) {
|
|
1235
|
+ if (!esteps || (!block->steps[X_AXIS] && !block->steps[Y_AXIS]) || stepper.get_advance_k() == 0 || (uint32_t)esteps == block->step_event_count) {
|
1228
|
1236
|
block->use_advance_lead = false;
|
1229
|
1237
|
}
|
1230
|
1238
|
else {
|
1231
|
1239
|
block->use_advance_lead = true;
|
1232
|
|
- block->e_speed_multiplier8 = (block->steps[E_AXIS] << 8) / block->step_event_count;
|
|
1240
|
+ block->e_speed_multiplier8 = (esteps << 8) / block->step_event_count;
|
1233
|
1241
|
}
|
1234
|
1242
|
|
1235
|
1243
|
#elif ENABLED(ADVANCE)
|
1236
|
1244
|
|
1237
|
1245
|
// Calculate advance rate
|
1238
|
|
- if (!block->steps[E_AXIS] || (!block->steps[X_AXIS] && !block->steps[Y_AXIS] && !block->steps[Z_AXIS])) {
|
|
1246
|
+ if (!esteps || (!block->steps[X_AXIS] && !block->steps[Y_AXIS] && !block->steps[Z_AXIS])) {
|
1239
|
1247
|
block->advance_rate = 0;
|
1240
|
1248
|
block->advance = 0;
|
1241
|
1249
|
}
|