|
@@ -1015,8 +1015,8 @@ void Planner::reverse_pass() {
|
1015
|
1015
|
// Perform the reverse pass
|
1016
|
1016
|
block_t *current = &block_buffer[block_index];
|
1017
|
1017
|
|
1018
|
|
- // Only consider non sync and page blocks
|
1019
|
|
- if (!TEST(current->flag, BLOCK_BIT_SYNC_POSITION) && !IS_PAGE(current)) {
|
|
1018
|
+ // Only consider non sync-and-page blocks
|
|
1019
|
+ if (!(current->flag & BLOCK_MASK_SYNC) && !IS_PAGE(current)) {
|
1020
|
1020
|
reverse_pass_kernel(current, next);
|
1021
|
1021
|
next = current;
|
1022
|
1022
|
}
|
|
@@ -1111,7 +1111,7 @@ void Planner::forward_pass() {
|
1111
|
1111
|
block = &block_buffer[block_index];
|
1112
|
1112
|
|
1113
|
1113
|
// Skip SYNC and page blocks
|
1114
|
|
- if (!TEST(block->flag, BLOCK_BIT_SYNC_POSITION) && !IS_PAGE(block)) {
|
|
1114
|
+ if (!(block->flag & BLOCK_MASK_SYNC) && !IS_PAGE(block)) {
|
1115
|
1115
|
// If there's no previous block or the previous block is not
|
1116
|
1116
|
// BUSY (thus, modifiable) run the forward_pass_kernel. Otherwise,
|
1117
|
1117
|
// the previous block became BUSY, so assume the current block's
|
|
@@ -1147,7 +1147,7 @@ void Planner::recalculate_trapezoids() {
|
1147
|
1147
|
block_t *prev = &block_buffer[prev_index];
|
1148
|
1148
|
|
1149
|
1149
|
// If not dealing with a sync block, we are done. The last block is not a SYNC block
|
1150
|
|
- if (!TEST(prev->flag, BLOCK_BIT_SYNC_POSITION)) break;
|
|
1150
|
+ if (!(prev->flag & BLOCK_MASK_SYNC)) break;
|
1151
|
1151
|
|
1152
|
1152
|
// Examine the previous block. This and all following are SYNC blocks
|
1153
|
1153
|
head_block_index = prev_index;
|
|
@@ -1161,7 +1161,7 @@ void Planner::recalculate_trapezoids() {
|
1161
|
1161
|
next = &block_buffer[block_index];
|
1162
|
1162
|
|
1163
|
1163
|
// Skip sync and page blocks
|
1164
|
|
- if (!TEST(next->flag, BLOCK_BIT_SYNC_POSITION) && !IS_PAGE(next)) {
|
|
1164
|
+ if (!(next->flag & BLOCK_MASK_SYNC) && !IS_PAGE(next)) {
|
1165
|
1165
|
next_entry_speed = SQRT(next->entry_speed_sqr);
|
1166
|
1166
|
|
1167
|
1167
|
if (block) {
|
|
@@ -1248,6 +1248,63 @@ void Planner::recalculate() {
|
1248
|
1248
|
recalculate_trapezoids();
|
1249
|
1249
|
}
|
1250
|
1250
|
|
|
1251
|
+#if HAS_FAN && DISABLED(LASER_SYNCHRONOUS_M106_M107)
|
|
1252
|
+ #define HAS_TAIL_FAN_SPEED 1
|
|
1253
|
+#endif
|
|
1254
|
+
|
|
1255
|
+/**
|
|
1256
|
+ * Apply fan speeds
|
|
1257
|
+ */
|
|
1258
|
+#if HAS_FAN
|
|
1259
|
+
|
|
1260
|
+ void Planner::sync_fan_speeds(uint8_t (&fan_speed)[FAN_COUNT]) {
|
|
1261
|
+
|
|
1262
|
+ #if FAN_MIN_PWM != 0 || FAN_MAX_PWM != 255
|
|
1263
|
+ #define CALC_FAN_SPEED(f) (fan_speed[f] ? map(fan_speed[f], 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM)
|
|
1264
|
+ #else
|
|
1265
|
+ #define CALC_FAN_SPEED(f) (fan_speed[f] ?: FAN_OFF_PWM)
|
|
1266
|
+ #endif
|
|
1267
|
+
|
|
1268
|
+ #if ENABLED(FAN_SOFT_PWM)
|
|
1269
|
+ #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F);
|
|
1270
|
+ #elif ENABLED(FAST_PWM_FAN)
|
|
1271
|
+ #define _FAN_SET(F) set_pwm_duty(FAN##F##_PIN, CALC_FAN_SPEED(F));
|
|
1272
|
+ #else
|
|
1273
|
+ #define _FAN_SET(F) analogWrite(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F));
|
|
1274
|
+ #endif
|
|
1275
|
+ #define FAN_SET(F) do{ kickstart_fan(fan_speed, ms, F); _FAN_SET(F); }while(0)
|
|
1276
|
+
|
|
1277
|
+ const millis_t ms = millis();
|
|
1278
|
+ TERN_(HAS_FAN0, FAN_SET(0));
|
|
1279
|
+ TERN_(HAS_FAN1, FAN_SET(1));
|
|
1280
|
+ TERN_(HAS_FAN2, FAN_SET(2));
|
|
1281
|
+ TERN_(HAS_FAN3, FAN_SET(3));
|
|
1282
|
+ TERN_(HAS_FAN4, FAN_SET(4));
|
|
1283
|
+ TERN_(HAS_FAN5, FAN_SET(5));
|
|
1284
|
+ TERN_(HAS_FAN6, FAN_SET(6));
|
|
1285
|
+ TERN_(HAS_FAN7, FAN_SET(7));
|
|
1286
|
+ }
|
|
1287
|
+
|
|
1288
|
+ #if FAN_KICKSTART_TIME
|
|
1289
|
+
|
|
1290
|
+ void Planner::kickstart_fan(uint8_t (&fan_speed)[FAN_COUNT], const millis_t &ms, const uint8_t f) {
|
|
1291
|
+ static millis_t fan_kick_end[FAN_COUNT] = { 0 };
|
|
1292
|
+ if (fan_speed[f]) {
|
|
1293
|
+ if (fan_kick_end[f] == 0) {
|
|
1294
|
+ fan_kick_end[f] = ms + FAN_KICKSTART_TIME;
|
|
1295
|
+ fan_speed[f] = 255;
|
|
1296
|
+ }
|
|
1297
|
+ else if (PENDING(ms, fan_kick_end[f]))
|
|
1298
|
+ fan_speed[f] = 255;
|
|
1299
|
+ }
|
|
1300
|
+ else
|
|
1301
|
+ fan_kick_end[f] = 0;
|
|
1302
|
+ }
|
|
1303
|
+
|
|
1304
|
+ #endif
|
|
1305
|
+
|
|
1306
|
+#endif // HAS_FAN
|
|
1307
|
+
|
1251
|
1308
|
/**
|
1252
|
1309
|
* Maintain fans, paste extruder pressure,
|
1253
|
1310
|
*/
|
|
@@ -1257,7 +1314,7 @@ void Planner::check_axes_activity() {
|
1257
|
1314
|
xyze_bool_t axis_active = { false };
|
1258
|
1315
|
#endif
|
1259
|
1316
|
|
1260
|
|
- #if HAS_FAN
|
|
1317
|
+ #if HAS_TAIL_FAN_SPEED
|
1261
|
1318
|
uint8_t tail_fan_speed[FAN_COUNT];
|
1262
|
1319
|
#endif
|
1263
|
1320
|
|
|
@@ -1272,13 +1329,12 @@ void Planner::check_axes_activity() {
|
1272
|
1329
|
|
1273
|
1330
|
if (has_blocks_queued()) {
|
1274
|
1331
|
|
1275
|
|
- #if HAS_FAN || ENABLED(BARICUDA)
|
|
1332
|
+ #if EITHER(HAS_TAIL_FAN_SPEED, BARICUDA)
|
1276
|
1333
|
block_t *block = &block_buffer[block_buffer_tail];
|
1277
|
1334
|
#endif
|
1278
|
1335
|
|
1279
|
|
- #if HAS_FAN
|
1280
|
|
- FANS_LOOP(i)
|
1281
|
|
- tail_fan_speed[i] = thermalManager.scaledFanSpeed(i, block->fan_speed[i]);
|
|
1336
|
+ #if HAS_TAIL_FAN_SPEED
|
|
1337
|
+ FANS_LOOP(i) tail_fan_speed[i] = thermalManager.scaledFanSpeed(i, block->fan_speed[i]);
|
1282
|
1338
|
#endif
|
1283
|
1339
|
|
1284
|
1340
|
#if ENABLED(BARICUDA)
|
|
@@ -1300,9 +1356,8 @@ void Planner::check_axes_activity() {
|
1300
|
1356
|
|
1301
|
1357
|
TERN_(HAS_CUTTER, cutter.refresh());
|
1302
|
1358
|
|
1303
|
|
- #if HAS_FAN
|
1304
|
|
- FANS_LOOP(i)
|
1305
|
|
- tail_fan_speed[i] = thermalManager.scaledFanSpeed(i);
|
|
1359
|
+ #if HAS_TAIL_FAN_SPEED
|
|
1360
|
+ FANS_LOOP(i) tail_fan_speed[i] = thermalManager.scaledFanSpeed(i);
|
1306
|
1361
|
#endif
|
1307
|
1362
|
|
1308
|
1363
|
#if ENABLED(BARICUDA)
|
|
@@ -1321,48 +1376,11 @@ void Planner::check_axes_activity() {
|
1321
|
1376
|
|
1322
|
1377
|
//
|
1323
|
1378
|
// Update Fan speeds
|
|
1379
|
+ // Only if synchronous M106/M107 is disabled
|
1324
|
1380
|
//
|
1325
|
|
- #if HAS_FAN
|
1326
|
|
-
|
1327
|
|
- #if FAN_KICKSTART_TIME > 0
|
1328
|
|
- static millis_t fan_kick_end[FAN_COUNT] = { 0 };
|
1329
|
|
- #define KICKSTART_FAN(f) \
|
1330
|
|
- if (tail_fan_speed[f]) { \
|
1331
|
|
- millis_t ms = millis(); \
|
1332
|
|
- if (fan_kick_end[f] == 0) { \
|
1333
|
|
- fan_kick_end[f] = ms + FAN_KICKSTART_TIME; \
|
1334
|
|
- tail_fan_speed[f] = 255; \
|
1335
|
|
- } else if (PENDING(ms, fan_kick_end[f])) \
|
1336
|
|
- tail_fan_speed[f] = 255; \
|
1337
|
|
- } else fan_kick_end[f] = 0
|
1338
|
|
- #else
|
1339
|
|
- #define KICKSTART_FAN(f) NOOP
|
1340
|
|
- #endif
|
1341
|
|
-
|
1342
|
|
- #if FAN_MIN_PWM != 0 || FAN_MAX_PWM != 255
|
1343
|
|
- #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? map(tail_fan_speed[f], 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM)
|
1344
|
|
- #else
|
1345
|
|
- #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ?: FAN_OFF_PWM)
|
1346
|
|
- #endif
|
1347
|
|
-
|
1348
|
|
- #if ENABLED(FAN_SOFT_PWM)
|
1349
|
|
- #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F);
|
1350
|
|
- #elif ENABLED(FAST_PWM_FAN)
|
1351
|
|
- #define _FAN_SET(F) set_pwm_duty(FAN##F##_PIN, CALC_FAN_SPEED(F));
|
1352
|
|
- #else
|
1353
|
|
- #define _FAN_SET(F) analogWrite(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F));
|
1354
|
|
- #endif
|
1355
|
|
- #define FAN_SET(F) do{ KICKSTART_FAN(F); _FAN_SET(F); }while(0)
|
1356
|
|
-
|
1357
|
|
- TERN_(HAS_FAN0, FAN_SET(0));
|
1358
|
|
- TERN_(HAS_FAN1, FAN_SET(1));
|
1359
|
|
- TERN_(HAS_FAN2, FAN_SET(2));
|
1360
|
|
- TERN_(HAS_FAN3, FAN_SET(3));
|
1361
|
|
- TERN_(HAS_FAN4, FAN_SET(4));
|
1362
|
|
- TERN_(HAS_FAN5, FAN_SET(5));
|
1363
|
|
- TERN_(HAS_FAN6, FAN_SET(6));
|
1364
|
|
- TERN_(HAS_FAN7, FAN_SET(7));
|
1365
|
|
- #endif // HAS_FAN
|
|
1381
|
+ #if HAS_TAIL_FAN_SPEED
|
|
1382
|
+ sync_fan_speeds(tail_fan_speed);
|
|
1383
|
+ #endif
|
1366
|
1384
|
|
1367
|
1385
|
TERN_(AUTOTEMP, getHighESpeed());
|
1368
|
1386
|
|
|
@@ -2675,9 +2693,14 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
2675
|
2693
|
|
2676
|
2694
|
/**
|
2677
|
2695
|
* Planner::buffer_sync_block
|
2678
|
|
- * Add a block to the buffer that just updates the position
|
|
2696
|
+ * Add a block to the buffer that just updates the position,
|
|
2697
|
+ * or in case of LASER_SYNCHRONOUS_M106_M107 the fan PWM
|
2679
|
2698
|
*/
|
2680
|
|
-void Planner::buffer_sync_block() {
|
|
2699
|
+void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_flag)) {
|
|
2700
|
+ #if DISABLED(LASER_SYNCHRONOUS_M106_M107)
|
|
2701
|
+ constexpr uint8_t sync_flag = BLOCK_FLAG_SYNC_POSITION;
|
|
2702
|
+ #endif
|
|
2703
|
+
|
2681
|
2704
|
// Wait for the next available block
|
2682
|
2705
|
uint8_t next_buffer_head;
|
2683
|
2706
|
block_t * const block = get_next_free_block(next_buffer_head);
|
|
@@ -2685,10 +2708,14 @@ void Planner::buffer_sync_block() {
|
2685
|
2708
|
// Clear block
|
2686
|
2709
|
memset(block, 0, sizeof(block_t));
|
2687
|
2710
|
|
2688
|
|
- block->flag = BLOCK_FLAG_SYNC_POSITION;
|
|
2711
|
+ block->flag = sync_flag;
|
2689
|
2712
|
|
2690
|
2713
|
block->position = position;
|
2691
|
2714
|
|
|
2715
|
+ #if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107)
|
|
2716
|
+ FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i];
|
|
2717
|
+ #endif
|
|
2718
|
+
|
2692
|
2719
|
// If this is the first added movement, reload the delay, otherwise, cancel it.
|
2693
|
2720
|
if (block_buffer_head == block_buffer_tail) {
|
2694
|
2721
|
// If it was the first queued block, restart the 1st block delivery delay, to
|
|
@@ -2876,7 +2903,7 @@ bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, con
|
2876
|
2903
|
|
2877
|
2904
|
block->flag = BLOCK_FLAG_IS_PAGE;
|
2878
|
2905
|
|
2879
|
|
- #if FAN_COUNT > 0
|
|
2906
|
+ #if HAS_FAN
|
2880
|
2907
|
FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i];
|
2881
|
2908
|
#endif
|
2882
|
2909
|
|